From 7e14b5231b193b7a831bc77a3a0ff6c743ffbbc4 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 21 Sep 2016 13:48:28 +0100 Subject: [PATCH] Let git handle line endings for us. --- .gitattributes | 29 + README.txt | 100 +- build.properties | 42 +- build.xml | 186 +- pom.xml | 642 +-- rm-server/build.properties | 14 +- rm-server/build.xml | 238 +- .../org_alfresco_module_rm/action-context.xml | 130 +- .../alfresco-global.properties | 158 +- .../org_alfresco_module_rm/audit/rm-audit.xml | 180 +- .../bootstrap/RMDataDictionaryBootstrap.xml | 506 +-- .../notify-records-due-for-review-email.ftl | 246 +- .../bootstrap/content/onCreate_supersedes.js | 30 +- .../content/record-rejected-email.ftl | 240 +- .../content/record-superseded-email.ftl | 236 +- .../bootstrap/content/recordsCustomModel.xml | 316 +- .../content/rmEventConfigBootstrap.json | 152 +- .../bootstrap/content/rma_isClosed.js | 24 +- .../report_rmr_destructionReport.html.ftl | 230 +- .../report/report_rmr_holdReport.html.ftl | 238 +- .../report/report_rmr_transferReport.html.ftl | 172 +- .../groups/rm-capability-groups-context.xml | 168 +- .../rm-capabilities-audit-context.xml | 144 +- .../rm-capabilities-condition-context.xml | 452 +-- .../rm-capabilities-config-context.xml | 186 +- .../rm-capabilities-disposition-context.xml | 630 +-- .../rm-capabilities-event-context.xml | 82 +- .../rm-capabilities-fileplan-context.xml | 192 +- .../rm-capabilities-freeze-context.xml | 340 +- .../rm-capabilities-group-context.xml | 496 +-- .../rm-capabilities-record-context.xml | 776 ++-- .../rm-capabilities-recordfolder-context.xml | 452 +-- .../rm-capabilities-reference-context.xml | 44 +- .../rm-capabilities-rule-context.xml | 38 +- .../rm-capabilities-security-context.xml | 120 +- .../dod5015/DODExampleFilePlan.xml | 2090 +++++----- ...15-capabilities-classification-context.xml | 162 +- .../dod5015/dod5015-context.xml | 120 +- .../dod5015/dod5015Model.xml | 866 ++-- .../dod5015/messages/dod5015-model.properties | 196 +- .../messages/dod5015-model_de.properties | 196 +- .../messages/dod5015-model_es.properties | 196 +- .../messages/dod5015-model_fr.properties | 196 +- .../messages/dod5015-model_it.properties | 196 +- .../messages/dod5015-model_ja.properties | 196 +- .../messages/dod5015-model_nl.properties | 196 +- .../messages/dod5015-model_zh_CN.properties | 196 +- .../dod5015/messages/dod5015.properties | 14 +- .../dod5015/messages/dod5015_de.properties | 14 +- .../dod5015/messages/dod5015_es.properties | 14 +- .../dod5015/messages/dod5015_fr.properties | 14 +- .../dod5015/messages/dod5015_it.properties | 14 +- .../dod5015/messages/dod5015_ja.properties | 14 +- .../dod5015/messages/dod5015_nl.properties | 14 +- .../dod5015/messages/dod5015_zh_CN.properties | 14 +- .../extended-repository-context.xml | 568 +-- .../org_alfresco_module_rm/log4j.properties | 116 +- .../messages/action-service.properties | 76 +- .../messages/action-service_de.properties | 76 +- .../messages/action-service_es.properties | 76 +- .../messages/action-service_fr.properties | 76 +- .../messages/action-service_it.properties | 76 +- .../messages/action-service_ja.properties | 76 +- .../messages/action-service_nl.properties | 76 +- .../messages/action-service_zh_CN.properties | 76 +- .../messages/actions.properties | 420 +- .../messages/actions_de.properties | 422 +- .../messages/actions_es.properties | 420 +- .../messages/actions_fr.properties | 420 +- .../messages/actions_it.properties | 420 +- .../messages/actions_ja.properties | 420 +- .../messages/actions_nl.properties | 420 +- .../messages/actions_zh_CN.properties | 420 +- .../messages/admin-service.properties | 30 +- .../messages/admin-service_de.properties | 30 +- .../messages/admin-service_es.properties | 30 +- .../messages/admin-service_fr.properties | 30 +- .../messages/admin-service_it.properties | 30 +- .../messages/admin-service_ja.properties | 30 +- .../messages/admin-service_nl.properties | 30 +- .../messages/admin-service_zh_CN.properties | 30 +- .../messages/audit-service.properties | 32 +- .../messages/audit-service_de.properties | 32 +- .../messages/audit-service_es.properties | 32 +- .../messages/audit-service_fr.properties | 32 +- .../messages/audit-service_it.properties | 32 +- .../messages/audit-service_ja.properties | 32 +- .../messages/audit-service_nl.properties | 32 +- .../messages/audit-service_zh_CN.properties | 32 +- .../messages/capability-service.properties | 208 +- .../messages/capability-service_de.properties | 208 +- .../messages/capability-service_es.properties | 208 +- .../messages/capability-service_fr.properties | 208 +- .../messages/capability-service_it.properties | 208 +- .../messages/capability-service_ja.properties | 208 +- .../messages/capability-service_nl.properties | 208 +- .../capability-service_zh_CN.properties | 208 +- .../messages/notification-service.properties | 4 +- .../notification-service_de.properties | 4 +- .../notification-service_es.properties | 4 +- .../notification-service_fr.properties | 4 +- .../notification-service_it.properties | 4 +- .../notification-service_ja.properties | 4 +- .../notification-service_nl.properties | 4 +- .../notification-service_zh_CN.properties | 4 +- .../records-management-service.properties | 40 +- .../records-management-service_de.properties | 40 +- .../records-management-service_es.properties | 40 +- .../records-management-service_fr.properties | 40 +- .../records-management-service_it.properties | 40 +- .../records-management-service_ja.properties | 40 +- .../records-management-service_nl.properties | 40 +- ...ecords-management-service_zh_CN.properties | 40 +- .../messages/records-model.properties | 528 +-- .../messages/records-model_de.properties | 528 +-- .../messages/records-model_es.properties | 528 +-- .../messages/records-model_fr.properties | 528 +-- .../messages/records-model_it.properties | 528 +-- .../messages/records-model_ja.properties | 528 +-- .../messages/records-model_nl.properties | 528 +-- .../messages/records-model_zh_CN.properties | 528 +-- .../messages/report-model.properties | 24 +- .../messages/report-model_de.properties | 24 +- .../messages/report-model_es.properties | 24 +- .../messages/report-model_fr.properties | 24 +- .../messages/report-model_it.properties | 24 +- .../messages/report-model_ja.properties | 24 +- .../messages/report-model_nl.properties | 24 +- .../messages/report-model_zh_CN.properties | 24 +- .../messages/rm-actions.properties | 16 +- .../messages/rm-actions_de.properties | 16 +- .../messages/rm-actions_es.properties | 16 +- .../messages/rm-actions_fr.properties | 16 +- .../messages/rm-actions_it.properties | 16 +- .../messages/rm-actions_ja.properties | 16 +- .../messages/rm-actions_nl.properties | 16 +- .../messages/rm-actions_zh_CN.properties | 16 +- .../messages/rm-events.properties | 42 +- .../messages/rm-events_de.properties | 42 +- .../messages/rm-events_es.properties | 42 +- .../messages/rm-events_fr.properties | 42 +- .../messages/rm-events_it.properties | 42 +- .../messages/rm-events_ja.properties | 42 +- .../messages/rm-events_nl.properties | 42 +- .../messages/rm-events_zh_CN.properties | 42 +- .../messages/rm-system.properties | 48 +- .../messages/rm-system_de.properties | 48 +- .../messages/rm-system_es.properties | 48 +- .../messages/rm-system_fr.properties | 48 +- .../messages/rm-system_it.properties | 48 +- .../messages/rm-system_ja.properties | 48 +- .../messages/rm-system_nl.properties | 48 +- .../messages/rm-system_zh_CN.properties | 48 +- .../messages/template.properties | 52 +- .../model/recordableVersionModel.xml | 256 +- .../model/recordsModel.xml | 2462 ++++++------ .../model/recordsPermissionModel.xml | 992 ++--- .../model/reportModel.xml | 100 +- .../model/rm-model-security-context.xml | 322 +- .../org_alfresco_module_rm/module-context.xml | 482 +-- .../org_alfresco_module_rm/module.properties | 20 +- .../patch/rm-patch-context.xml | 88 +- .../patch/rm-patch-v20-context.xml | 130 +- .../patch/rm-patch-v21-context.xml | 212 +- .../patch/rm-patch-v22-context.xml | 210 +- .../patch/rm-patch-v23-context.xml | 72 +- .../query/rm-common-SqlMap.xml | 44 +- .../query/rm-common-SqlMapConfig.xml | 24 +- .../query/rm-query-context.xml | 48 +- .../rm-action-context.xml | 2304 +++++------ .../rm-audit-context.xml | 190 +- .../rm-capabilities-context.xml | 310 +- .../rm-deprecated-context.xml | 270 +- .../rm-disposition-properties-context.xml | 78 +- .../org_alfresco_module_rm/rm-id-context.xml | 92 +- .../org_alfresco_module_rm/rm-job-context.xml | 300 +- .../rm-model-context.xml | 388 +- .../rm-public-services-security-context.xml | 350 +- .../rm-report-context.xml | 210 +- .../rm-service-context.xml | 3298 +++++++-------- .../rm-ui-evaluators-context.xml | 1850 ++++----- .../rm-version-context.xml | 182 +- .../rm-webscript-context.xml | 1330 +++--- .../rm-workflow-context.xml | 52 +- .../security/rm-default-roles-bootstrap.json | 448 +-- .../security/rm-method-security-context.xml | 38 +- .../security/rm-method-security.properties | 454 +-- .../roles/rm-authorities.delete.desc.xml | 22 +- .../roles/rm-authorities.post.desc.xml | 22 +- ...rm-actionconditiondefinitions.get.desc.xml | 14 +- .../rule/rm-actiondefinitions.get.desc.xml | 14 +- .../rm-substitutionsuggestions.get.desc.xml | 14 +- .../version/rm-version.get.desc.xml | 16 +- .../repository/version/rm-version.get.js | 248 +- .../version/rm-version.get.json.ftl | 42 +- .../rma/admin/emailmap.delete.desc.xml | 28 +- .../rma/admin/emailmap.delete.json.ftl | 12 +- .../alfresco/rma/admin/emailmap.get.desc.xml | 56 +- .../alfresco/rma/admin/emailmap.get.json.ftl | 12 +- .../org/alfresco/rma/admin/emailmap.lib.ftl | 26 +- .../alfresco/rma/admin/emailmap.post.desc.xml | 38 +- .../alfresco/rma/admin/emailmap.post.json.ftl | 12 +- .../rma/admin/emailmapkeys.get.desc.xml | 16 +- .../rma/admin/emailmapkeys.get.json.ftl | 24 +- .../admin/rmconstraint/rmconstraint-utils.js | 34 +- .../rmconstraint/rmconstraint.delete.desc.xml | 24 +- .../admin/rmconstraint/rmconstraint.delete.js | 52 +- .../rmconstraint/rmconstraint.delete.json.ftl | 8 +- .../rmconstraint/rmconstraint.get.desc.xml | 42 +- .../admin/rmconstraint/rmconstraint.get.js | 48 +- .../rmconstraint/rmconstraint.get.json.ftl | 14 +- .../admin/rmconstraint/rmconstraint.lib.ftl | 120 +- .../rmconstraint/rmconstraint.put.desc.xml | 36 +- .../rmconstraint/rmconstraint.put.json.ftl | 20 +- .../rmconstraint/rmconstraint.put.json.js | 118 +- .../rmconstraint/rmconstraints.get.desc.xml | 34 +- .../admin/rmconstraint/rmconstraints.get.js | 36 +- .../rmconstraint/rmconstraints.get.json.ftl | 24 +- .../rmconstraint/rmconstraints.post.desc.xml | 38 +- .../rmconstraint/rmconstraints.post.json.ftl | 20 +- .../rmconstraint/rmconstraints.post.json.js | 106 +- .../values/rmconstraint.get.desc.xml | 124 +- .../rmconstraint/values/rmconstraint.get.js | 48 +- .../values/rmconstraint.get.json.ftl | 12 +- .../values/rmconstraint.post.desc.xml | 54 +- .../values/rmconstraint.post.json.ftl | 12 +- .../values/rmconstraint.post.json.js | 76 +- .../values/rmconstraintvalue.delete.desc.xml | 20 +- .../values/rmconstraintvalue.delete.js | 80 +- .../values/rmconstraintvalue.delete.json.ftl | 12 +- .../values/rmconstraintvalue.get.desc.xml | 92 +- .../values/rmconstraintvalue.get.js | 70 +- .../values/rmconstraintvalue.get.json.ftl | 12 +- .../rma/admin/rmevent/rmevent.delete.desc.xml | 26 +- .../rma/admin/rmevent/rmevent.get.desc.xml | 26 +- .../rma/admin/rmevent/rmevent.lib.ftl | 24 +- .../rma/admin/rmevent/rmevent.put.desc.xml | 26 +- .../rma/admin/rmevent/rmevents.get.desc.xml | 26 +- .../rma/admin/rmevent/rmevents.post.desc.xml | 26 +- .../admin/rmevent/rmeventtypes.get.desc.xml | 26 +- .../rma/admin/rmrole/rmrole.delete.desc.xml | 30 +- .../rma/admin/rmrole/rmrole.get.desc.xml | 30 +- .../alfresco/rma/admin/rmrole/rmrole.lib.ftl | 76 +- .../rma/admin/rmrole/rmrole.put.desc.xml | 30 +- .../rma/admin/rmrole/rmroles.get.desc.xml | 42 +- .../rma/admin/rmrole/rmroles.post.desc.xml | 30 +- .../rma/applydodcertmodelfixes.get.desc.xml | 28 +- .../rma/applydodcertmodelfixes.get.json.ftl | 10 +- .../alfresco/rma/applyfixmob1573.get.desc.xml | 16 +- .../alfresco/rma/applyfixmob1573.get.json.ftl | 10 +- .../rma/bootstraptestdata.get.desc.xml | 16 +- .../rma/bootstraptestdata.get.json.ftl | 10 +- .../rma/capability/capabilities.get.desc.xml | 18 +- .../rma/capability/capabilities.get.json.ftl | 64 +- .../rma/custompropdefinition.delete.desc.xml | 36 +- .../rma/custompropdefinition.delete.json.ftl | 16 +- .../rma/custompropdefinition.post.json.ftl | 14 +- .../rma/custompropdefinition.put.json.ftl | 14 +- .../alfresco/rma/customref.delete.desc.xml | 28 +- .../alfresco/rma/customref.delete.json.ftl | 4 +- .../org/alfresco/rma/customref.post.json.ftl | 8 +- .../rma/customrefdefinition.post.json.ftl | 18 +- .../rma/customrefdefinition.put.json.ftl | 12 +- .../org/alfresco/rma/dataset.post.desc.xml | 16 +- .../org/alfresco/rma/dataset.post.json.ftl | 10 +- .../org/alfresco/rma/datasets.get.desc.xml | 16 +- .../org/alfresco/rma/datasets.get.json.ftl | 28 +- ...ispositionactiondefinition.delete.desc.xml | 16 +- .../rma/dispositionactiondefinition.lib.ftl | 34 +- .../dispositionactiondefinition.put.desc.xml | 40 +- .../dispositionactiondefinition.put.json.ftl | 8 +- ...dispositionactiondefinitions.post.desc.xml | 40 +- ...dispositionactiondefinitions.post.json.ftl | 10 +- .../rma/dispositionlifecycle.get.desc.xml | 16 +- .../rma/dispositionlifecycle.get.json.ftl | 78 +- .../rma/dispositionproperties.get.desc.xml | 16 +- .../rma/dispositionproperties.get.json.ftl | 26 +- .../rma/dispositionschedule.get.desc.xml | 16 +- .../rma/dispositionschedule.get.json.ftl | 56 +- .../org/alfresco/rma/export.post.desc.xml | 30 +- .../org/alfresco/rma/hold.post.desc.xml | 32 +- .../org/alfresco/rma/hold.put.desc.xml | 32 +- .../org/alfresco/rma/holds.get.desc.xml | 38 +- .../org/alfresco/rma/holds.get.json.ftl | 30 +- .../org/alfresco/rma/import.post.desc.xml | 32 +- .../org/alfresco/rma/import.post.json.ftl | 8 +- .../alfresco/rma/listofvalues.get.desc.xml | 16 +- .../alfresco/rma/listofvalues.get.json.ftl | 2 +- .../org/alfresco/rma/listofvalues.lib.ftl | 150 +- .../alfresco/rma/relationship.delete.json.ftl | 4 +- .../alfresco/rma/relationships.get.json.ftl | 28 +- .../alfresco/rma/rmauditlog.delete.desc.xml | 16 +- .../alfresco/rma/rmauditlog.delete.json.ftl | 2 +- .../org/alfresco/rma/rmauditlog.get.desc.xml | 42 +- .../org/alfresco/rma/rmauditlog.lib.ftl | 24 +- .../org/alfresco/rma/rmauditlog.post.desc.xml | 44 +- .../org/alfresco/rma/rmauditlog.put.desc.xml | 30 +- .../org/alfresco/rma/rmauditlog.put.json.ftl | 2 +- .../rma/rmauditlogstatus.get.desc.xml | 22 +- .../rma/rmauditlogstatus.get.json.ftl | 10 +- .../alfresco/rma/rmconstraints.get.desc.xml | 26 +- .../alfresco/rma/rmconstraints.get.json.ftl | 28 +- .../alfresco/rma/rmpermissions.post.desc.xml | 70 +- .../alfresco/rma/rmpermissions.post.json.js | 112 +- .../org/alfresco/rma/transfer.get.desc.xml | 16 +- .../alfresco/rma/transferreport.get.desc.xml | 16 +- .../alfresco/rma/transferreport.post.desc.xml | 30 +- .../rma/userrightsreport.get.desc.xml | 16 +- .../rma/userrightsreport.get.json.ftl | 90 +- .../documentlibrary-v2/rm-doclist.get.js | 22 +- .../documentlibrary-v2/rm-filters.lib.js | 390 +- .../documentlibrary-v2/rm-parse-args.lib.js | 320 +- .../recorded-version-config.get.desc.xml | 16 +- .../recorded-version-config.get.json.ftl | 30 +- .../recorded-version-config.post.desc.xml | 16 +- .../slingshot/forms/metadata.get.desc.xml | 14 +- .../slingshot/forms/metadata.get.json.ftl | 30 +- .../rmsearch/rmsavedsearches.delete.desc.xml | 16 +- .../rmsearch/rmsavedsearches.delete.json.ftl | 4 +- .../rmsearch/rmsavedsearches.get.desc.xml | 16 +- .../rmsearch/rmsavedsearches.get.json.ftl | 30 +- .../rmsearch/rmsavedsearches.post.desc.xml | 16 +- .../rmsearch/rmsavedsearches.post.json.ftl | 4 +- .../slingshot/rmsearch/rmsearch.get.desc.xml | 16 +- .../slingshot/rmsearch/rmsearch.get.json.ftl | 94 +- .../rmsearch/rmsearchproperties.get.desc.xml | 16 +- .../rmsearch/rmsearchproperties.get.json.ftl | 52 +- .../alfresco/workflow/requestInfo.bpmn20.xml | 202 +- .../workflow/rm-workflow-messages.properties | 44 +- .../rm-workflow-messages_de.properties | 44 +- .../rm-workflow-messages_es.properties | 44 +- .../rm-workflow-messages_fr.properties | 44 +- .../rm-workflow-messages_it.properties | 44 +- .../rm-workflow-messages_ja.properties | 44 +- .../rm-workflow-messages_nl.properties | 44 +- .../rm-workflow-messages_zh_CN.properties | 44 +- rm-server/pom.xml | 526 +-- .../caveat/RMListOfValuesConstraint.java | 64 +- .../RecordsManagementAdminService.java | 58 +- .../RecordsManagementService.java | 598 +-- .../RecordsManagementServiceImpl.java | 990 ++--- ...cordsManagementAuditServiceDeprecated.java | 142 +- .../compatibility/CompatibilityModel.java | 78 +- .../RecordsManagementSecurityService.java | 412 +- .../RecordsManagementSecurityServiceImpl.java | 442 +- .../org_alfresco_module_rm/security/Role.java | 128 +- .../RecordsManagementPolicies.java | 240 +- .../RecordsManagementServiceRegistry.java | 368 +- .../RecordsManagementServiceRegistryImpl.java | 398 +- .../AuditableActionExecuterAbstractBase.java | 320 +- ...PropertySubActionExecuterAbstractBase.java | 174 +- .../action/RMActionExecuterAbstractBase.java | 1224 +++--- ...DispositionActionExecuterAbstractBase.java | 606 +-- .../action/RecordsManagementAction.java | 184 +- .../RecordsManagementActionCondition.java | 122 +- ...dsManagementActionConditionDefinition.java | 66 +- ...nagementActionConditionDefinitionImpl.java | 88 +- ...tActionConditionEvaluatorAbstractBase.java | 430 +- .../RecordsManagementActionDefinition.java | 76 +- ...RecordsManagementActionDefinitionImpl.java | 132 +- .../action/RecordsManagementActionResult.java | 98 +- .../RecordsManagementActionService.java | 258 +- .../RecordsManagementActionServiceImpl.java | 650 +-- .../action/ScheduledDispositionJob.java | 258 +- .../constraint/CustomParameterConstraint.java | 130 +- .../DispositionActionParameterConstraint.java | 128 +- .../ManualEventParameterConstraint.java | 134 +- .../RecordTypeParameterConstraint.java | 236 +- .../VersionParameterConstraint.java | 100 +- .../action/dm/CreateRecordAction.java | 466 +-- .../dm/DeclareAsVersionRecordAction.java | 470 +-- .../action/dm/ExecuteScriptAction.java | 94 +- .../action/dm/HideRecordAction.java | 204 +- .../action/dm/MoveDmRecordAction.java | 286 +- .../dm/RecordableVersionConfigAction.java | 390 +- .../CapabilityConditionEvaluator.java | 114 +- .../evaluator/DelegateActionCondition.java | 138 +- .../DispositionActionRelativePositions.java | 60 +- .../HasDispositionActionEvaluator.java | 258 +- .../action/evaluator/IsKindEvaluator.java | 146 +- .../evaluator/IsRecordTypeEvaluator.java | 164 +- .../action/impl/AddRecordTypeAction.java | 242 +- .../action/impl/ApplyCustomTypeAction.java | 292 +- ...spositionActionDefinitionUpdateAction.java | 532 +-- .../action/impl/CloseRecordFolderAction.java | 160 +- .../action/impl/CompleteEventAction.java | 178 +- .../impl/CopyMoveLinkFileToBaseAction.java | 880 ++-- .../action/impl/CopyToAction.java | 38 +- .../impl/CreateDispositionScheduleAction.java | 168 +- .../action/impl/CutOffAction.java | 176 +- .../action/impl/DeclareRecordAction.java | 412 +- .../action/impl/DelegateAction.java | 176 +- .../action/impl/DeleteHoldAction.java | 106 +- .../action/impl/DestroyAction.java | 568 +-- .../EditDispositionActionAsOfDateAction.java | 144 +- .../action/impl/EditHoldReasonAction.java | 128 +- .../action/impl/EditReviewAsOfDateAction.java | 138 +- .../action/impl/FileReportAction.java | 382 +- .../action/impl/FileToAction.java | 40 +- .../action/impl/FreezeAction.java | 132 +- .../action/impl/LinkToAction.java | 38 +- .../action/impl/MoveToAction.java | 38 +- .../action/impl/OpenRecordFolderAction.java | 172 +- .../action/impl/RejectAction.java | 132 +- .../action/impl/RelinquishHoldAction.java | 104 +- .../action/impl/RequestInfoAction.java | 338 +- .../action/impl/RetainAction.java | 86 +- .../action/impl/SplitEmailAction.java | 586 +-- .../action/impl/TransferAction.java | 218 +- .../action/impl/TransferCompleteAction.java | 170 +- .../action/impl/UnCutoffAction.java | 176 +- .../action/impl/UndeclareRecordAction.java | 136 +- .../action/impl/UndoEventAction.java | 138 +- .../action/impl/UnfreezeAction.java | 80 +- .../action/impl/UnlinkFromAction.java | 128 +- ...annotApplyConstraintMetadataException.java | 80 +- .../admin/CustomMetadataException.java | 72 +- .../InvalidCustomAspectMetadataException.java | 80 +- .../NotCustomisableMetadataException.java | 78 +- ...ropertyAlreadyExistsMetadataException.java | 80 +- .../admin/RecordsManagementAdminBase.java | 752 ++-- .../admin/RecordsManagementAdminService.java | 810 ++-- .../RecordsManagementAdminServiceImpl.java | 2726 ++++++------- .../audit/RecordsManagementAuditEntry.java | 536 +-- ...RecordsManagementAuditQueryParameters.java | 410 +- .../audit/RecordsManagementAuditService.java | 426 +- .../RecordsManagementAuditServiceImpl.java | 3498 ++++++++-------- .../audit/event/AuditEvent.java | 270 +- .../audit/event/CopyToAuditEvent.java | 122 +- .../audit/event/CreateObjectAuditEvent.java | 98 +- .../audit/event/CreatePersonAuditEvent.java | 98 +- .../audit/event/DeleteObjectAuditEvent.java | 98 +- .../audit/event/FileToAuditEvent.java | 114 +- .../audit/event/LinkToAuditEvent.java | 112 +- .../audit/event/MoveToAuditEvent.java | 100 +- .../RecordableVersionPolicyAuditEvent.java | 116 +- .../audit/event/UpdateObjectAuditEvent.java | 108 +- .../AuthenticatedUserRolesDataExtractor.java | 236 +- .../FilePlanIdentifierDataExtractor.java | 140 +- .../FilePlanNamePathDataExtractor.java | 240 +- .../FilePlanNodeRefPathDataExtractor.java | 212 +- .../BootstrapImporterModuleComponent.java | 182 +- ...rdContributorsGroupBootstrapComponent.java | 146 +- .../bootstrap/RecordsManagementBootstrap.java | 228 +- .../capability/AbstractCapability.java | 620 +-- .../capability/Capability.java | 210 +- .../capability/CapabilityService.java | 286 +- .../capability/CapabilityServiceImpl.java | 552 +-- .../capability/CompositeCapability.java | 74 +- .../capability/Group.java | 98 +- .../capability/GroupImpl.java | 210 +- .../capability/PolicyRegister.java | 58 +- .../capability/RMActionProxyFactoryBean.java | 186 +- .../capability/RMAfterInvocationProvider.java | 1924 ++++----- .../capability/RMEntryVoter.java | 808 ++-- .../capability/RMPermissionModel.java | 254 +- .../capability/RMSecurityCommon.java | 792 ++-- .../AbstractCapabilityCondition.java | 340 +- .../declarative/CapabilityCondition.java | 88 +- .../declarative/DeclarativeCapability.java | 748 ++-- .../DeclarativeCompositeCapability.java | 278 +- .../condition/AtLeastOneCondition.java | 158 +- .../condition/ClosedCapabilityCondition.java | 144 +- .../condition/CutoffCapabilityCondition.java | 82 +- .../DeclaredCapabilityCondition.java | 80 +- .../DestroyedCapabilityCondition.java | 72 +- .../condition/FailCapabilityCondition.java | 74 +- .../FileableCapabilityCondition.java | 116 +- .../condition/FillingCapabilityCondition.java | 96 +- ...ingOnHoldContainerCapabilityCondition.java | 120 +- .../condition/FrozenCapabilityCondition.java | 154 +- .../condition/FrozenOrHoldCondition.java | 86 +- .../HasAspectCapabilityCondition.java | 122 +- ...HasDispositionDateCapabilityCondition.java | 134 +- .../HasEventsCapabilityCondition.java | 126 +- .../condition/HoldCapabilityCondition.java | 170 +- .../IsClassifiedCapabilityCondition.java | 120 +- .../condition/IsPropertySetCondition.java | 176 +- .../condition/IsRecordCategoryCondition.java | 88 +- .../condition/IsRecordCondition.java | 88 +- .../condition/IsRecordFolderCondition.java | 88 +- .../IsScheduledCapabilityCondition.java | 154 +- ...sTransferAccessionCapabilityCondition.java | 100 +- .../LastDispositionActionCondition.java | 124 +- .../MayBeScheduledCapabilityCondition.java | 202 +- .../RecordFiledCapabilityCondition.java | 82 +- .../TransferredCapabilityCondition.java | 70 +- ...italRecordOrFolderCapabilityCondition.java | 104 +- .../ChangeOrDeleteReferencesCapability.java | 132 +- .../capability/impl/CreateCapability.java | 360 +- .../impl/DeleteLinksCapability.java | 128 +- .../impl/EditNonRecordMetadataCapability.java | 124 +- .../capability/impl/UpdateCapability.java | 94 +- .../impl/ViewRecordsCapability.java | 104 +- .../capability/policy/AbstractBasePolicy.java | 384 +- .../capability/policy/AssocPolicy.java | 74 +- .../policy/ConfigAttributeDefinition.java | 292 +- .../capability/policy/CreatePolicy.java | 108 +- .../capability/policy/DeclarePolicy.java | 72 +- .../capability/policy/DeletePolicy.java | 102 +- .../capability/policy/MovePolicy.java | 152 +- .../capability/policy/Policy.java | 96 +- .../capability/policy/ReadPolicy.java | 84 +- .../capability/policy/UpdatePolicy.java | 106 +- .../policy/UpdatePropertiesPolicy.java | 68 +- .../capability/policy/WriteContentPolicy.java | 72 +- .../caveat/PivotUtil.java | 124 +- .../caveat/RMCaveatConfigComponent.java | 224 +- .../caveat/RMCaveatConfigComponentImpl.java | 30 +- .../caveat/RMCaveatConfigService.java | 304 +- .../caveat/RMCaveatConfigServiceImpl.java | 30 +- .../caveat/RMConstraintInfo.java | 158 +- .../caveat/RMListOfValuesConstraint.java | 30 +- .../caveat/ScriptAuthority.java | 102 +- .../caveat/ScriptConstraint.java | 524 +-- .../caveat/ScriptConstraintAuthority.java | 98 +- .../caveat/ScriptConstraintValue.java | 114 +- .../caveat/ScriptRMCaveatConfigService.java | 330 +- .../dataset/DataSet.java | 54 +- .../dataset/DataSetBase.java | 206 +- .../dataset/DataSetService.java | 152 +- .../dataset/DataSetServiceImpl.java | 994 ++--- .../disposition/DispositionAction.java | 288 +- .../DispositionActionDefinition.java | 246 +- .../DispositionActionDefinitionImpl.java | 492 +-- .../disposition/DispositionActionImpl.java | 1024 ++--- .../disposition/DispositionSchedule.java | 164 +- .../disposition/DispositionScheduleImpl.java | 370 +- .../DispositionSelectionStrategy.java | 396 +- .../disposition/DispositionService.java | 470 +-- .../disposition/DispositionServiceImpl.java | 2146 +++++----- .../property/DispositionProperty.java | 534 +-- .../dod5015/DOD5015FilePlanTypeBootstrap.java | 102 +- .../dod5015/DOD5015Model.java | 182 +- .../model/dod/aspect/DOD5015RecordAspect.java | 188 +- .../email/CustomEmailMappingService.java | 130 +- .../email/CustomEmailMappingServiceImpl.java | 972 ++--- .../email/CustomMapping.java | 222 +- .../CustomisableEmailMappingKeyBootstrap.java | 130 +- .../email/RFC822MetadataExtracter.java | 222 +- .../event/EventCompletionDetails.java | 334 +- .../event/OnReferenceCreateEventType.java | 288 +- .../event/OnReferencedRecordActionedUpon.java | 502 +-- .../event/RecordsManagementEvent.java | 196 +- .../event/RecordsManagementEventService.java | 222 +- .../RecordsManagementEventServiceImpl.java | 758 ++-- .../event/RecordsManagementEventType.java | 96 +- .../SimpleRecordsManagementEventTypeImpl.java | 200 +- .../fileplan/FilePlanComponentKind.java | 86 +- .../fileplan/FilePlanService.java | 676 ++-- .../fileplan/FilePlanServiceImpl.java | 1260 +++--- .../forms/RecordsManagementFormFilter.java | 368 +- .../RecordsManagementNodeFormFilter.java | 820 ++-- .../RecordsManagementTypeFormFilter.java | 364 +- .../freeze/FreezeService.java | 280 +- .../freeze/FreezeServiceImpl.java | 762 ++-- .../hold/HoldService.java | 374 +- .../hold/HoldServiceImpl.java | 1526 +++---- .../identifier/BasicIdentifierGenerator.java | 112 +- .../identifier/IdentifierGenerator.java | 90 +- .../identifier/IdentifierGeneratorBase.java | 206 +- .../identifier/IdentifierService.java | 118 +- .../identifier/IdentifierServiceImpl.java | 392 +- .../job/DispositionLifecycleJobExecuter.java | 462 +-- ...otifyOfRecordsDueForReviewJobExecuter.java | 30 +- .../job/PublishUpdatesJobExecuter.java | 816 ++-- .../job/RecordsManagementJob.java | 318 +- .../job/RecordsManagementJobExecuter.java | 160 +- .../job/publish/BasePublishExecutor.java | 94 +- ...sitionActionDefinitionPublishExecutor.java | 176 +- .../job/publish/PublishExecutor.java | 82 +- .../job/publish/PublishExecutorRegistry.java | 108 +- .../jscript/ScriptCapability.java | 130 +- .../jscript/ScriptRecordsManagmentNode.java | 156 +- .../ScriptRecordsManagmentService.java | 244 +- .../jscript/app/BaseEvaluator.java | 534 +-- .../jscript/app/JSONConversionComponent.java | 1158 +++--- .../app/evaluator/CutoffEvaluator.java | 86 +- .../EditRecordMetadataActionEvaluator.java | 80 +- .../evaluator/FolderOpenClosedEvaluator.java | 82 +- .../app/evaluator/FrozenEvaluator.java | 118 +- .../app/evaluator/HasAspectEvaluator.java | 90 +- .../app/evaluator/MultiParentEvaluator.java | 134 +- .../app/evaluator/NonElectronicEvaluator.java | 98 +- .../evaluator/SplitEmailActionEvaluator.java | 108 +- .../app/evaluator/TransferEvaluator.java | 232 +- .../jscript/app/evaluator/TrueEvaluator.java | 72 +- .../app/evaluator/VitalRecordEvaluator.java | 84 +- .../model/BaseBehaviourBean.java | 132 +- .../model/CustomisableTypesBootstrap.java | 160 +- .../model/RecordsManagementCustomModel.java | 112 +- .../model/RecordsManagementModel.java | 540 +-- .../behaviour/AbstractDisposableItem.java | 130 +- .../RecordsManagementSearchBehaviour.java | 1808 ++++----- .../DictionaryBootstrapPostProcessor.java | 78 +- .../model/rma/aspect/AccendedAspect.java | 112 +- .../model/rma/aspect/CutoffAspect.java | 112 +- .../rma/aspect/DeclaredRecordAspect.java | 112 +- .../aspect/DispositionLifecycleAspect.java | 194 +- .../rma/aspect/ExtendedSecurityAspect.java | 136 +- .../rma/aspect/FilePlanComponentAspect.java | 664 +-- .../model/rma/aspect/FrozenAspect.java | 410 +- .../model/rma/aspect/GhostedAspect.java | 146 +- .../model/rma/aspect/RecordAspect.java | 642 +-- .../RecordComponentIdentifierAspect.java | 464 +-- .../RecordOriginatingDetailsAspect.java | 112 +- .../model/rma/aspect/RecordSearchAspect.java | 108 +- .../model/rma/aspect/ScheduledAspect.java | 144 +- .../model/rma/aspect/TransferredAspect.java | 112 +- .../model/rma/aspect/TransferringAspect.java | 112 +- .../model/rma/aspect/UncutoffAspect.java | 112 +- .../model/rma/aspect/VersionRecordAspect.java | 246 +- .../model/rma/aspect/VitalRecordAspect.java | 108 +- .../aspect/VitalRecordDefinitionAspect.java | 184 +- .../model/rma/type/CmObjectType.java | 330 +- .../type/DispositionActionDefinitionType.java | 198 +- .../model/rma/type/FilePlanType.java | 404 +- .../model/rma/type/RecordCategoryType.java | 414 +- .../model/rma/type/RecordFolderType.java | 504 +-- .../type/RecordsManagementContainerType.java | 424 +- .../model/rma/type/RmSiteType.java | 578 +-- .../security/ModelAccessDeniedException.java | 84 +- .../model/security/ModelSecurityService.java | 276 +- .../security/ModelSecurityServiceImpl.java | 726 ++-- .../model/security/ProtectedAspect.java | 56 +- .../security/ProtectedModelArtifact.java | 248 +- .../model/security/ProtectedProperty.java | 94 +- .../RecordsManagementNotificationHelper.java | 934 ++--- .../patch/AbstractModulePatch.java | 578 +-- .../patch/ModulePatch.java | 128 +- .../patch/ModulePatchExecuter.java | 80 +- .../patch/ModulePatchExecuterImpl.java | 336 +- .../patch/common/CapabilityPatch.java | 280 +- .../compatibility/ModulePatchComponent.java | 274 +- .../patch/v20/NotificationTemplatePatch.java | 404 +- .../patch/v20/RMv2FilePlanNodeRefPatch.java | 346 +- .../patch/v20/RMv2ModelPatch.java | 294 +- .../patch/v20/RMv2SavedSearchPatch.java | 234 +- .../v21/NotificationTemplatePatch_v21.java | 234 +- .../patch/v21/RMv21BehaviorScriptsPatch.java | 350 +- .../patch/v21/RMv21CapabilityPatch.java | 334 +- .../patch/v21/RMv21InPlacePatch.java | 448 +-- .../patch/v21/RMv21PatchComponent.java | 150 +- .../v21/RMv21RecordInheritancePatch.java | 274 +- .../patch/v21/RMv21ReportServicePatch.java | 280 +- .../patch/v21/RMv21RolesPatch.java | 218 +- .../patch/v22/RMv22CapabilityPatch.java | 124 +- .../patch/v22/RMv22DODCompliantSitePatch.java | 164 +- .../RMv22DODModelSeparationModulePatch.java | 336 +- .../RMv22FileHoldReportCapabilityPatch.java | 88 +- ...2GhostOnDestroyDispositionActionPatch.java | 360 +- .../patch/v22/RMv22HoldCapabilityPatch.java | 96 +- .../patch/v22/RMv22HoldReportPatch.java | 218 +- .../RMv22RemoveInPlaceRolesFromAllPatch.java | 194 +- .../patch/v22/RMv22ReportTemplatePatch.java | 224 +- .../v23/RMv23EndRetentionCapabilityPatch.java | 90 +- .../RMv23RecordContributorsGroupPatch.java | 106 +- .../patch/v23/RMv23VersionsEventPatch.java | 118 +- .../query/RecordsManagementQueryDAO.java | 80 +- .../query/RecordsManagementQueryDAOImpl.java | 182 +- .../record/InplaceRecordService.java | 90 +- .../record/InplaceRecordServiceImpl.java | 370 +- .../record/RecordLinkRuntimeException.java | 106 +- .../record/RecordMetadataBootstrap.java | 184 +- .../record/RecordService.java | 542 +-- .../record/RecordServiceImpl.java | 3554 ++++++++--------- .../RecordableVersionConfigService.java | 98 +- .../RecordableVersionConfigServiceImpl.java | 254 +- .../recordfolder/RecordFolderService.java | 316 +- .../recordfolder/RecordFolderServiceImpl.java | 624 +-- .../relationship/Relationship.java | 102 +- .../relationship/RelationshipDefinition.java | 98 +- .../RelationshipDefinitionImpl.java | 230 +- .../relationship/RelationshipDisplayName.java | 214 +- .../relationship/RelationshipImpl.java | 314 +- .../relationship/RelationshipService.java | 294 +- .../relationship/RelationshipServiceImpl.java | 1920 ++++----- .../relationship/RelationshipType.java | 62 +- .../org_alfresco_module_rm/report/Report.java | 110 +- .../report/ReportGenerator.java | 90 +- .../report/ReportModel.java | 98 +- .../report/ReportService.java | 156 +- .../report/ReportServiceImpl.java | 250 +- .../report/generator/BaseReportGenerator.java | 296 +- .../generator/DeclarativeReportGenerator.java | 736 ++-- .../report/generator/ReportInfo.java | 206 +- .../generator/transfer/TransferNode.java | 130 +- .../transfer/TransferReportGenerator.java | 466 +-- .../role/FilePlanRoleService.java | 430 +- .../role/FilePlanRoleServiceImpl.java | 1752 ++++---- .../org_alfresco_module_rm/role/Role.java | 228 +- .../script/AbstractRmWebScript.java | 296 +- .../script/ApplyDodCertModelFixesGet.java | 434 +- .../script/ApplyFixMob1573Get.java | 308 +- .../script/AuditLogDelete.java | 96 +- .../script/AuditLogGet.java | 310 +- .../script/AuditLogPost.java | 576 +-- .../script/AuditLogPut.java | 172 +- .../script/AuditLogStatusGet.java | 176 +- .../script/BaseAuditAdminWebScript.java | 182 +- .../script/BaseAuditRetrievalWebScript.java | 544 +-- .../script/BaseCustomPropertyWebScript.java | 126 +- .../script/BaseTransferWebScript.java | 428 +- .../script/BootstrapTestDataGet.java | 692 ++-- .../CustomPropertyDefinitionDelete.java | 224 +- .../script/CustomPropertyDefinitionPost.java | 30 +- .../script/CustomPropertyDefinitionPut.java | 30 +- .../script/CustomPropertyDefinitionsGet.java | 240 +- .../script/CustomRefDelete.java | 30 +- .../script/CustomRefPost.java | 30 +- .../script/CustomReferenceDefinitionBase.java | 188 +- .../script/CustomReferenceDefinitionPost.java | 30 +- .../script/CustomReferenceDefinitionPut.java | 30 +- .../script/CustomReferenceDefinitionsGet.java | 270 +- .../script/CustomReferenceType.java | 114 +- .../script/CustomRefsGet.java | 466 +-- .../script/CustomisableGet.java | 334 +- .../script/DataSetPost.java | 234 +- .../script/DataSetsGet.java | 208 +- .../script/DispositionAbstractBase.java | 30 +- .../DispositionActionDefinitionDelete.java | 146 +- .../DispositionActionDefinitionPost.java | 316 +- .../DispositionActionDefinitionPut.java | 314 +- .../script/DispositionLifecycleGet.java | 366 +- .../script/DispositionPropertiesGet.java | 234 +- .../script/DispositionScheduleGet.java | 86 +- .../script/DodCustomTypesGet.java | 136 +- .../script/EmailMapDelete.java | 154 +- .../script/EmailMapGet.java | 118 +- .../script/EmailMapKeysGet.java | 118 +- .../script/EmailMapPost.java | 180 +- .../script/ExportPost.java | 350 +- .../script/ImportPost.java | 510 +-- .../script/ListOfValuesGet.java | 588 +-- .../script/RMConstraintGet.java | 138 +- .../script/RecordMetaDataAspectsGet.java | 280 +- .../script/RelationshipDelete.java | 232 +- .../script/RelationshipLabelsGet.java | 436 +- .../script/RelationshipsGet.java | 368 +- .../script/RmActionPost.java | 436 +- .../script/TransferGet.java | 194 +- .../script/TransferReportGet.java | 574 +-- .../script/TransferReportPost.java | 904 ++--- .../script/UserRightsReportGet.java | 688 ++-- .../script/admin/RMEventBase.java | 134 +- .../script/admin/RmEventDelete.java | 154 +- .../script/admin/RmEventGet.java | 152 +- .../script/admin/RmEventPut.java | 294 +- .../script/admin/RmEventTypesGet.java | 124 +- .../script/admin/RmEventsGet.java | 124 +- .../script/admin/RmEventsPost.java | 294 +- .../script/admin/RmRoleDelete.java | 142 +- .../script/admin/RmRoleGet.java | 136 +- .../script/admin/RmRolePut.java | 226 +- .../script/admin/RmRolesGet.java | 170 +- .../script/admin/RmRolesPost.java | 196 +- .../admin/RoleDeclarativeWebScript.java | 566 +-- .../script/capability/CapabilitiesGet.java | 428 +- .../script/hold/BaseHold.java | 502 +-- .../script/hold/Hold.java | 136 +- .../script/hold/HoldPost.java | 82 +- .../script/hold/HoldPut.java | 82 +- .../script/hold/HoldsGet.java | 482 +-- .../slingshot/RMSavedSearchesDelete.java | 188 +- .../script/slingshot/RMSavedSearchesGet.java | 296 +- .../script/slingshot/RMSavedSearchesPost.java | 316 +- .../script/slingshot/RMSearchGet.java | 864 ++-- .../slingshot/RMSearchPropertiesGet.java | 418 +- .../slingshot/RecordedVersionConfigGet.java | 150 +- .../slingshot/RecordedVersionConfigPost.java | 184 +- .../script/slingshot/Version.java | 184 +- .../script/slingshot/forms/RMMetaDataGet.java | 430 +- .../RecordsManagementSearchParameters.java | 738 ++-- .../RecordsManagementSearchService.java | 186 +- .../RecordsManagementSearchServiceImpl.java | 1260 +++--- .../search/ReportDetails.java | 222 +- .../search/SavedSearchDetails.java | 622 +-- .../SavedSearchDetailsCompatibility.java | 444 +- .../search/SortItem.java | 30 +- .../security/ExtendedSecurityService.java | 210 +- .../security/ExtendedSecurityServiceImpl.java | 1292 +++--- .../security/FilePlanPermissionService.java | 130 +- .../FilePlanPermissionServiceImpl.java | 1232 +++--- .../security/RMMethodSecurityInterceptor.java | 670 ++-- .../RMMethodSecurityPostProcessor.java | 400 +- .../site/GetChildrenCannedQueryFactory.java | 96 +- .../transfer/TransferService.java | 120 +- .../transfer/TransferServiceImpl.java | 624 +-- .../util/AlfrescoTransactionSupport.java | 108 +- .../util/AuthenticationUtil.java | 196 +- .../util/PoliciesUtil.java | 154 +- .../util/ServiceBaseImpl.java | 1056 ++--- .../util/TransactionalResourceHelper.java | 212 +- .../version/ExtendedVersionableAspect.java | 430 +- .../version/RecordableVersionModel.java | 102 +- .../RecordableVersionNodeServiceImpl.java | 496 +-- .../version/RecordableVersionPolicy.java | 60 +- .../version/RecordableVersionService.java | 192 +- .../version/RecordableVersionServiceImpl.java | 1744 ++++---- .../version/model/VersionableAspect.java | 112 +- .../BroadcastVitalRecordDefinitionAction.java | 268 +- .../vital/ReviewedAction.java | 180 +- .../vital/VitalRecordDefinition.java | 112 +- .../vital/VitalRecordDefinitionImpl.java | 196 +- .../vital/VitalRecordService.java | 148 +- .../vital/VitalRecordServiceImpl.java | 408 +- .../action/ExtendedActionServiceImpl.java | 264 +- .../parameter/DateParameterProcessor.java | 500 +-- .../parameter/MessageParameterProcessor.java | 110 +- .../parameter/NodeParameterProcessor.java | 588 +-- .../NodeParameterSuggesterBootstrap.java | 184 +- .../action/parameter/ParameterProcessor.java | 188 +- .../ParameterProcessorComponent.java | 332 +- .../ParameterSubstitutionSuggester.java | 56 +- .../alfresco/repo/jscript/ExtendedSearch.java | 106 +- .../ExtendedFileFolderServiceImpl.java | 100 +- .../repo/rule/ExtendedRuleServiceImpl.java | 502 +-- ...foreDeleteChildAssociationRuleTrigger.java | 206 +- .../repo/security/authority/RMAuthority.java | 86 +- .../authority/RMAuthorityDAOImpl.java | 162 +- .../impl/ExtendedPermissionService.java | 100 +- .../impl/RMPermissionServiceImpl.java | 704 ++-- .../impl/acegi/RMACLEntryVoter.java | 102 +- .../web/scripts/dictionary/RmClassesGet.java | 482 +-- .../RmDictionaryWebServiceUtils.java | 112 +- .../scripts/dictionary/RmPropertiesGet.java | 350 +- .../scripts/roles/AbstractRmAuthorities.java | 198 +- .../scripts/roles/RmAuthoritiesDelete.java | 106 +- .../web/scripts/roles/RmAuthoritiesPost.java | 106 +- .../rule/RmActionConditionDefinitionsGet.java | 162 +- .../scripts/rule/RmActionDefinitionsGet.java | 142 +- .../RmSubstitutionSuggestionsGet.java | 612 +-- .../org/alfresco/util/WebScriptUtils.java | 644 +-- .../alfresco/workflow/RMWorkflowModel.java | 90 +- .../RequestInfoAssignmentHandler.java | 262 +- .../requestInfo/RequestInfoNotifier.java | 144 +- .../requestInfo/RequestInfoUtils.java | 274 +- .../RequestInfoVariableHandler.java | 98 +- .../test/AllTestSuite.java | 114 +- .../integration/IntegrationTestSuite.java | 122 +- .../integration/disposition/CutOffTest.java | 436 +- .../disposition/DispositionTestSuite.java | 76 +- .../integration/dod/DoD5015TestSuite.java | 78 +- .../integration/dod/RM1147DODRMSiteTest.java | 352 +- .../dod/RM1194ExcludeDoDRecordTypesTest.java | 230 +- .../integration/event/CompleteEventsTest.java | 894 ++--- .../integration/event/EventTestSuite.java | 76 +- .../hold/AddRemoveFromHoldTest.java | 830 ++-- .../test/integration/hold/CreateHoldTest.java | 256 +- .../test/integration/hold/DeleteHoldTest.java | 426 +- .../test/integration/hold/HoldTestSuite.java | 80 +- .../integration/issue/IssueTestSuite.java | 114 +- .../test/integration/issue/RM1008Test.java | 718 ++-- .../test/integration/issue/RM1027Test.java | 234 +- .../test/integration/issue/RM1030Test.java | 310 +- .../test/integration/issue/RM1039Test.java | 372 +- .../test/integration/issue/RM1424Test.java | 238 +- .../test/integration/issue/RM1429Test.java | 142 +- .../test/integration/issue/RM1463Test.java | 136 +- .../test/integration/issue/RM1464Test.java | 136 +- .../test/integration/issue/RM1799Test.java | 186 +- .../test/integration/issue/RM1814Test.java | 168 +- .../test/integration/issue/RM1887Test.java | 164 +- .../test/integration/issue/RM1914Test.java | 278 +- .../test/integration/issue/RM2072Test.java | 364 +- .../test/integration/issue/RM3993Test.java | 36 +- .../test/integration/issue/RM452Test.java | 196 +- .../test/integration/issue/RM804Test.java | 380 +- .../test/integration/issue/RM978Test.java | 1736 ++++---- .../integration/issue/RM981SystemTest.java | 232 +- .../test/integration/issue/RM994Test.java | 252 +- .../integration/issue/rm3314/RM3314Test.java | 122 +- .../issue/rm3314/RM3314TestListener.java | 268 +- .../job/AutomaticDispositionTest.java | 264 +- .../test/integration/job/JobTestSuite.java | 76 +- .../record/CompleteRecordTest.java | 466 +-- .../integration/record/CreateRecordTest.java | 574 +-- .../record/HideInplaceRecordTest.java | 196 +- .../integration/record/LinkRecordTest.java | 312 +- .../record/MoveInplaceRecordTest.java | 294 +- .../integration/record/MoveRecordTest.java | 682 ++-- .../integration/record/RecordTestSuite.java | 90 +- .../integration/record/RejectRecordTest.java | 586 +-- .../integration/record/ViewRecordTest.java | 206 +- .../recordfolder/MoveRecordFolderTest.java | 904 ++--- .../recordfolder/RecordFolderTestSuite.java | 78 +- .../relationship/CreateRelationshipTest.java | 420 +- .../relationship/DeleteRelationshipTest.java | 520 +-- .../relationship/RelationshipTestSuite.java | 78 +- .../integration/report/HoldReportTest.java | 332 +- .../integration/report/ReportTestSuite.java | 76 +- .../CreateTransferFolderAsNonAdminUser.java | 314 +- .../FilingPermissionsOnTransferFolder.java | 384 +- .../NoPermissionsOnTransferFolder.java | 362 +- .../ReadPermissionsOnTransferFolder.java | 402 +- .../transfer/TransferTestSuite.java | 84 +- .../version/AdHocRecordableVersionsTest.java | 380 +- .../version/AutoRecordableVersionsTest.java | 340 +- .../integration/version/AutoVersionTest.java | 464 +-- .../version/DeclareAsRecordVersionTest.java | 416 +- .../version/DeleteRecordVersionTest.java | 1010 ++--- .../version/RecordableVersionsBaseTest.java | 804 ++-- .../integration/version/VersionTestSuite.java | 84 +- .../test/legacy/LegacyTestSuite.java | 100 +- .../test/legacy/action/ActionTestSuite.java | 88 +- .../legacy/action/CreateRecordActionTest.java | 146 +- .../legacy/action/FileReportActionTest.java | 214 +- .../test/legacy/action/FileToActionTest.java | 654 +-- .../legacy/action/HideRecordActionTest.java | 166 +- .../legacy/action/MoveRecordActionTest.java | 206 +- .../RecordableVersionConfigActionTest.java | 286 +- .../test/legacy/action/RejectActionTest.java | 230 +- .../capabilities/CapabilitiesTestSuite.java | 78 +- .../capabilities/CompositeCapabilityTest.java | 326 +- .../DeclarativeCapabilityTest.java | 986 ++--- .../jscript/JSONConversionComponentTest.java | 302 +- .../test/legacy/jscript/JScriptTestSuite.java | 78 +- .../legacy/security/MethodSecurityTest.java | 156 +- .../legacy/security/SecurityTestSuite.java | 78 +- .../service/CapabilityServiceImplTest.java | 270 +- .../CustomEMailMappingServiceImplTest.java | 290 +- .../service/DataSetServiceImplTest.java | 528 +-- .../service/DispositionServiceImplTest.java | 2046 +++++----- .../service/ExtendedActionServiceTest.java | 344 +- .../ExtendedSecurityServiceImplTest.java | 592 +-- .../FilePlanPermissionServiceImplTest.java | 2516 ++++++------ .../service/FilePlanRoleServiceImplTest.java | 444 +- .../service/FilePlanServiceImplTest.java | 1074 ++--- .../legacy/service/FreezeServiceImplTest.java | 472 +-- .../service/ModelSecurityServiceImplTest.java | 538 +-- .../RMCaveatConfigServiceImplTest.java | 30 +- .../legacy/service/RecordServiceImplTest.java | 1528 +++---- ...ecordsManagementActionServiceImplTest.java | 578 +-- ...RecordsManagementAdminServiceImplTest.java | 1864 ++++----- ...RecordsManagementAuditServiceImplTest.java | 1000 ++--- ...RecordsManagementEventServiceImplTest.java | 254 +- .../RecordsManagementQueryDAOImplTest.java | 162 +- ...ecordsManagementSearchServiceImplTest.java | 618 +-- .../RecordsManagementServiceImplTest.java | 1230 +++--- .../legacy/service/ReportServiceImplTest.java | 462 +-- .../legacy/service/ServiceBaseImplTest.java | 218 +- .../legacy/service/ServicesTestSuite.java | 120 +- .../service/VitalRecordServiceImplTest.java | 922 ++--- .../ActionDefinitionsRestApiTest.java | 220 +- .../legacy/webscript/AuditRestApiTest.java | 144 +- .../webscript/CapabilitiesRestApiTest.java | 222 +- .../legacy/webscript/DataSetRestApiTest.java | 184 +- .../webscript/DispositionRestApiTest.java | 876 ++-- .../webscript/EmailMapKeysRestApiTest.java | 138 +- .../legacy/webscript/EmailMapScriptTest.java | 204 +- .../legacy/webscript/EventRestApiTest.java | 484 +-- .../webscript/RMCaveatConfigScriptTest.java | 1850 ++++----- .../webscript/RMConstraintScriptTest.java | 200 +- .../webscript/RmAuthoritiesRestApiTest.java | 682 ++-- .../webscript/RmClassesRestApiTest.java | 292 +- .../webscript/RmPropertiesRestApiTest.java | 292 +- .../test/legacy/webscript/RmRestApiTest.java | 2326 +++++------ .../legacy/webscript/RoleRestApiTest.java | 734 ++-- .../SubstitutionSuggestionsRestApiTest.java | 186 +- .../legacy/webscript/WebScriptTestSuite.java | 102 +- .../test/system/DataLoadSystemTest.java | 622 +-- .../NotificationServiceHelperSystemTest.java | 298 +- .../test/util/BaseRMTestCase.java | 1958 ++++----- .../test/util/BaseRMWebScriptTestCase.java | 782 ++-- .../test/util/CommonRMTestUtils.java | 624 +-- .../test/util/GenerateCapabilityReport.java | 150 +- .../RetryingTransactionHelperBaseTest.java | 134 +- .../test/util/TestAction.java | 92 +- .../test/util/TestAction2.java | 80 +- .../test/util/TestActionParams.java | 80 +- .../test/util/TestActionPropertySubs.java | 204 +- .../test/util/TestDmAction.java | 86 +- .../test/util/TestModel.java | 68 +- .../test/util/TestService.java | 22 +- .../test/util/TestServiceImpl.java | 114 +- .../test/util/TestWebScriptRepoServer.java | 428 +- .../extension/rm-method-security.properties | 2 +- rm-server/test/resources/test-context.xml | 530 +-- rm-server/test/resources/test-filePlan.xml | 568 +-- rm-server/test/resources/test-job-context.xml | 34 +- rm-server/test/resources/test-model.xml | 136 +- .../test/resources/testCaveatConfig1.json | 16 +- .../test/resources/testCaveatConfig2.json | 54 +- rm-server/test/resources/testng.xml | 18 +- .../action/BaseActionUnitTest.java | 108 +- .../DeclareAsVersionRecordActionUnitTest.java | 586 +-- .../action/impl/FileReportActionUnitTest.java | 212 +- .../action/impl/UnlinkFromActionUnitTest.java | 286 +- ...tstrapImporterModuleComponentUnitTest.java | 188 +- ...butorsGroupBootstrapComponentUnitTest.java | 166 +- .../capability/RMEntryVoterUnitTest.java | 440 +- .../CapabilityDeclarativeConditionSuite.java | 80 +- ...dContainerCapabilityConditionUnitTest.java | 282 +- .../FrozenCapabilityConditionUnitTest.java | 464 +-- .../HoldCapabilityConditionUnitTest.java | 286 +- ...tNonRecordsMetadataCapabilityUnitTest.java | 130 +- ...cordsManagementTypeFormFilterUnitTest.java | 352 +- .../hold/HoldServiceImplUnitTest.java | 918 ++--- ...spositionLifecycleJobExecuterUnitTest.java | 490 +-- .../evaluator/FrozenEvaluatorUnitTest.java | 214 +- .../evaluator/TransferEvaluatorUnitTest.java | 342 +- ...tionaryBootstrapPostProcessorUnitTest.java | 192 +- .../aspect/VersionRecordAspectUnitTest.java | 180 +- .../patch/v22/PatchV22Suite.java | 78 +- .../v22/RMv22CapabilityPatchUnitTest.java | 248 +- ...emoveInPlaceRolesFromAllPatchUnitTest.java | 254 +- .../RecordMetadataBootstrapUnitTest.java | 124 +- .../record/RecordServiceImplUnitTest.java | 910 ++--- .../config/BaseRecordedVersionConfigTest.java | 106 +- .../config/RecordedVersionConfigGetTest.java | 254 +- .../config/RecordedVersionConfigPostTest.java | 208 +- .../hold/BaseHoldWebScriptUnitTest.java | 102 +- .../BaseHoldWebScriptWithContentUnitTest.java | 444 +- .../script/hold/HoldPostUnitTest.java | 200 +- .../script/hold/HoldPutUnitTest.java | 200 +- .../script/hold/HoldsGetUnitTest.java | 538 +-- ...FilePlanPermissionServiceImplUnitTest.java | 880 ++-- .../test/AllUnitTestSuite.java | 80 +- .../test/util/BaseUnitTest.java | 886 ++-- .../test/util/BaseWebScriptUnitTest.java | 538 +-- .../test/util/WebScriptExceptionMatcher.java | 158 +- .../ExtendedVersionableAspectUnitTest.java | 800 ++-- .../RecordableVersionServiceImplUnitTest.java | 1320 +++--- .../TestRecordableVersionServiceImpl.java | 122 +- .../DateParameterProcessorUnitTest.java | 244 +- 1025 files changed, 138019 insertions(+), 137990 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..2f5a361a05 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,29 @@ +# Automatically detect if no other rule applies. +* text=auto + +# Extensions known to be text files. +*.css text +*.editorConfig text +*.ftl text +*.gitattributes text +*.gitignore text +*.html text +*.importorder text +*.java text +*.js text +*.jshintrc text +*.json text +*.properties text +*.txt text +*.xml text + +# Alfresco content package. +*.acp binary + +# Image files. +*.gif binary +*.jpg binary +*.png binary + +# IntelliJ has a jar file as part of its config directory. +*.jar binary diff --git a/README.txt b/README.txt index 976bf6e927..8a5d91ad0b 100644 --- a/README.txt +++ b/README.txt @@ -1,51 +1,51 @@ -== Alfresco Records Management - Development Environment Setup == - -Prerequisites - - - Maven 3.0.4 (or higher) - - Eclipse Maven Plugin (m2e) - - See Maven setup instructions https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Maven_Setup - - -Initial Setup - - - Create a normal project using "create-project" - - Check out RM code into the "code" directory (eg "checkout https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD") - - Create the tomcat instances using "use-tomcat7" and "use-app-tomcat7" - - -Using Eclipse - - - Import projects as Maven projects ("Import > Maven > Existing Maven Projects") - - Browse to the code directory of your project and select "rm-server/pom.xml" and "rm-share/pom.xml". DO NOT select the parent "/pom.xml" - - Open the Ant view and add the build files for both modules ("build.xml") - - If you are not working on a Windows machine you need to change the value of a property called "mvn.exec". - To do this create a file called "build.local.properties" under the code directory and change the value in that new file. - - Run the "prepareEnv" target for rm-server which will prepare the development environment. This target must be run just once. - - Now "fullBuild" target can be run which will create the amp file, apply it to the war file and copy the war file to webapps folder. - - -Summary of Available Ant Targets - - - fullBuild : Creates the amp file and applies it to the war file - - incrementalBuild : Creates the jar file and copies the jar file with other files like css, js, ftl, etc. files - - -Summary of Available Internal Ant Targets - - - alfresco:amp : Creates the amp file using alfresco maven plugin - - alfresco:install : Installs the amp file to the war file - - assembleIconPackage : Assembles an icons package for the module - - configureSolr : Configures Solr4 for Alfresco - - copyDBDriver : Copies the DB driver - - copyDevContextFile : Copies the dev-context.xml file - - copyWarFileToTomcat : Copies the war file (amp applied) to the webapp folder - - copyWebDirectory : Copies the source/web folder - - deleteExplodedWar : Deletes the exploded war file - - deleteWarFile : Deletes the war file - - fetchSolr : Gets the the Solr artifact - - fetchWarFile : Gets the "original" war file - - install : Executes the "mvn install" command - - package : Executes the "mvn package" command - - prepareEnv : Prepares the development environment (must be run just once) +== Alfresco Records Management - Development Environment Setup == + +Prerequisites + + - Maven 3.0.4 (or higher) + - Eclipse Maven Plugin (m2e) + - See Maven setup instructions https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Maven_Setup + + +Initial Setup + + - Create a normal project using "create-project" + - Check out RM code into the "code" directory (eg "checkout https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD") + - Create the tomcat instances using "use-tomcat7" and "use-app-tomcat7" + + +Using Eclipse + + - Import projects as Maven projects ("Import > Maven > Existing Maven Projects") + - Browse to the code directory of your project and select "rm-server/pom.xml" and "rm-share/pom.xml". DO NOT select the parent "/pom.xml" + - Open the Ant view and add the build files for both modules ("build.xml") + - If you are not working on a Windows machine you need to change the value of a property called "mvn.exec". + To do this create a file called "build.local.properties" under the code directory and change the value in that new file. + - Run the "prepareEnv" target for rm-server which will prepare the development environment. This target must be run just once. + - Now "fullBuild" target can be run which will create the amp file, apply it to the war file and copy the war file to webapps folder. + + +Summary of Available Ant Targets + + - fullBuild : Creates the amp file and applies it to the war file + - incrementalBuild : Creates the jar file and copies the jar file with other files like css, js, ftl, etc. files + + +Summary of Available Internal Ant Targets + + - alfresco:amp : Creates the amp file using alfresco maven plugin + - alfresco:install : Installs the amp file to the war file + - assembleIconPackage : Assembles an icons package for the module + - configureSolr : Configures Solr4 for Alfresco + - copyDBDriver : Copies the DB driver + - copyDevContextFile : Copies the dev-context.xml file + - copyWarFileToTomcat : Copies the war file (amp applied) to the webapp folder + - copyWebDirectory : Copies the source/web folder + - deleteExplodedWar : Deletes the exploded war file + - deleteWarFile : Deletes the war file + - fetchSolr : Gets the the Solr artifact + - fetchWarFile : Gets the "original" war file + - install : Executes the "mvn install" command + - package : Executes the "mvn package" command + - prepareEnv : Prepares the development environment (must be run just once) - unitTest : Runs the unit tests \ No newline at end of file diff --git a/build.properties b/build.properties index 589c200fc0..c4a8e95baa 100644 --- a/build.properties +++ b/build.properties @@ -1,22 +1,22 @@ -# Do NOT change the values directly in this file. If you need to change the value of a property, -# create a file called "build.local.properties" in the same folder and change the value in that file. - -# The application war file properties -app.war.packaging=war - -# Executable properties -mvn.exec=${env.MAVEN_HOME}/bin/mvn.bat - -# Ant directory properties -ant.build.directory=target -ant.config.directory=config -ant.source.web.directory=source/web - -# Tomcat properties -app.tomcat.folder=${ant.build.directory}/../../../software/${app.tomcat} -app.tomcat.webapps=${app.tomcat.folder}/webapps - -# Application properties -app.folder=${app.tomcat.webapps}/${app.war.artifactId} -app.package=${app.war.artifactId}.${app.war.packaging} +# Do NOT change the values directly in this file. If you need to change the value of a property, +# create a file called "build.local.properties" in the same folder and change the value in that file. + +# The application war file properties +app.war.packaging=war + +# Executable properties +mvn.exec=${env.MAVEN_HOME}/bin/mvn.bat + +# Ant directory properties +ant.build.directory=target +ant.config.directory=config +ant.source.web.directory=source/web + +# Tomcat properties +app.tomcat.folder=${ant.build.directory}/../../../software/${app.tomcat} +app.tomcat.webapps=${app.tomcat.folder}/webapps + +# Application properties +app.folder=${app.tomcat.webapps}/${app.war.artifactId} +app.package=${app.war.artifactId}.${app.war.packaging} app.package.path=${app.tomcat.webapps}/${app.package} \ No newline at end of file diff --git a/build.xml b/build.xml index 89f8e66436..f85a2a725b 100644 --- a/build.xml +++ b/build.xml @@ -1,93 +1,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 37a07c0e80..f9872a4b4a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,321 +1,321 @@ - - 4.0.0 - org.alfresco - alfresco-rm-parent - pom - 2.3.1-SNAPSHOT - Alfresco Records Management - - http://www.alfresco.org/ - 2005 - - Alfresco Software - http://www.alfresco.org/ - - - - LGPL 3 - - - - https://svn.alfresco.com/repos/alfresco-open-mirror/modules/recordsmanagement/HEAD - https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD - https://fisheye.alfresco.com/changelog/alfresco-enterprise - - - JIRA - https://issues.alfresco.com/jira/browse/RM - - - Bamboo - https://bamboo.alfresco.com/bamboo/browse/RM - - - - 3.0.4 - - - - - alfresco-internal - https://artifacts.alfresco.com/nexus/content/groups/private - - - - - alfresco-public - https://artifacts.alfresco.com/nexus/content/groups/public - - - - - - alfresco-internal - https://artifacts.alfresco.com/nexus/content/repositories/internal-releases/ - - - alfresco-internal-snapshots - https://artifacts.alfresco.com/nexus/content/repositories/internal-snapshots/ - - - - - rm-server - rm-share - - - - 5.0.2 - - - org.postgresql.Driver - jdbc:postgresql:${db.name} - jdbc:postgresql:template1 - alfresco - alfresco - - - false - 1.7 - 1.8 - UTF-8 - -Xmx1024m -XX:MaxPermSize=256m -Duser.language=en -Dcom.sun.management.jmxremote - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.3.1 - - - enforce-java - - enforce - - - - - 1.7.0 - - - - - - - - org.alfresco.maven.plugin - alfresco-maven-plugin - true - - true - ${project.build.directory}/${project.build.finalName}-amp.amp - ${project.build.directory}/${webapp.id}.war - amp - - - - maven-war-plugin - - - - org.alfresco - ${webapp.id} - war - - - org.alfresco - ${project.artifactId} - amp - - - - - - - - - - - maven-clean-plugin - 2.5 - - - maven-compiler-plugin - 3.1 - - ${maven.build.sourceVersion} - ${maven.build.sourceVersion} - - - - default-testCompile - process-test-sources - - testCompile - - - ${maven.build.testSourceVersion} - ${maven.build.testSourceVersion} - - - - - - maven-deploy-plugin - 2.8.1 - - - maven-install-plugin - 2.5.1 - - - maven-resources-plugin - 2.6 - - - maven-site-plugin - 3.3 - - - maven-assembly-plugin - 2.4 - - - maven-dependency-plugin - 2.8 - - - maven-help-plugin - 2.2 - - - maven-release-plugin - 2.4.2 - - - maven-source-plugin - 2.2.1 - - - maven-failsafe-plugin - 2.16 - - - maven-surefire-plugin - 2.16 - - - true - alphabetical - - - ${db.url} - ${db.driver} - ${db.name} - ${db.username} - ${db.password} - ${basedir}/target/alf_test_data - - - - - maven-javadoc-plugin - 2.9.1 - - - maven-eclipse-plugin - 2.9 - - - maven-antrun-plugin - 1.7 - - - maven-jar-plugin - 2.4 - - - maven-war-plugin - 2.4 - - source/web - true - - - - org.mortbay.jetty - jetty-maven-plugin - 8.1.14.v20131031 - - source/web - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - - org.codehaus.plexus - plexus-archiver - 2.3 - - - - - org.codehaus.mojo - sql-maven-plugin - 1.5 - - - org.codehaus.mojo - versions-maven-plugin - 2.1 - - - org.codehaus.mojo - build-helper-maven-plugin - 1.8 - - - org.alfresco.maven.plugin - alfresco-maven-plugin - 1.1.1 - - - net.alchim31.maven - yuicompressor-maven-plugin - 1.3.2 - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - [1.0.0,) - - enforce - - - - - - - - - - - - - - + + 4.0.0 + org.alfresco + alfresco-rm-parent + pom + 2.3.1-SNAPSHOT + Alfresco Records Management + + http://www.alfresco.org/ + 2005 + + Alfresco Software + http://www.alfresco.org/ + + + + LGPL 3 + + + + https://svn.alfresco.com/repos/alfresco-open-mirror/modules/recordsmanagement/HEAD + https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD + https://fisheye.alfresco.com/changelog/alfresco-enterprise + + + JIRA + https://issues.alfresco.com/jira/browse/RM + + + Bamboo + https://bamboo.alfresco.com/bamboo/browse/RM + + + + 3.0.4 + + + + + alfresco-internal + https://artifacts.alfresco.com/nexus/content/groups/private + + + + + alfresco-public + https://artifacts.alfresco.com/nexus/content/groups/public + + + + + + alfresco-internal + https://artifacts.alfresco.com/nexus/content/repositories/internal-releases/ + + + alfresco-internal-snapshots + https://artifacts.alfresco.com/nexus/content/repositories/internal-snapshots/ + + + + + rm-server + rm-share + + + + 5.0.2 + + + org.postgresql.Driver + jdbc:postgresql:${db.name} + jdbc:postgresql:template1 + alfresco + alfresco + + + false + 1.7 + 1.8 + UTF-8 + -Xmx1024m -XX:MaxPermSize=256m -Duser.language=en -Dcom.sun.management.jmxremote + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.3.1 + + + enforce-java + + enforce + + + + + 1.7.0 + + + + + + + + org.alfresco.maven.plugin + alfresco-maven-plugin + true + + true + ${project.build.directory}/${project.build.finalName}-amp.amp + ${project.build.directory}/${webapp.id}.war + amp + + + + maven-war-plugin + + + + org.alfresco + ${webapp.id} + war + + + org.alfresco + ${project.artifactId} + amp + + + + + + + + + + + maven-clean-plugin + 2.5 + + + maven-compiler-plugin + 3.1 + + ${maven.build.sourceVersion} + ${maven.build.sourceVersion} + + + + default-testCompile + process-test-sources + + testCompile + + + ${maven.build.testSourceVersion} + ${maven.build.testSourceVersion} + + + + + + maven-deploy-plugin + 2.8.1 + + + maven-install-plugin + 2.5.1 + + + maven-resources-plugin + 2.6 + + + maven-site-plugin + 3.3 + + + maven-assembly-plugin + 2.4 + + + maven-dependency-plugin + 2.8 + + + maven-help-plugin + 2.2 + + + maven-release-plugin + 2.4.2 + + + maven-source-plugin + 2.2.1 + + + maven-failsafe-plugin + 2.16 + + + maven-surefire-plugin + 2.16 + + + true + alphabetical + + + ${db.url} + ${db.driver} + ${db.name} + ${db.username} + ${db.password} + ${basedir}/target/alf_test_data + + + + + maven-javadoc-plugin + 2.9.1 + + + maven-eclipse-plugin + 2.9 + + + maven-antrun-plugin + 1.7 + + + maven-jar-plugin + 2.4 + + + maven-war-plugin + 2.4 + + source/web + true + + + + org.mortbay.jetty + jetty-maven-plugin + 8.1.14.v20131031 + + source/web + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + + org.codehaus.plexus + plexus-archiver + 2.3 + + + + + org.codehaus.mojo + sql-maven-plugin + 1.5 + + + org.codehaus.mojo + versions-maven-plugin + 2.1 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + org.alfresco.maven.plugin + alfresco-maven-plugin + 1.1.1 + + + net.alchim31.maven + yuicompressor-maven-plugin + 1.3.2 + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + [1.0.0,) + + enforce + + + + + + + + + + + + + + diff --git a/rm-server/build.properties b/rm-server/build.properties index fa6182cc67..bac2d66928 100644 --- a/rm-server/build.properties +++ b/rm-server/build.properties @@ -1,8 +1,8 @@ -# Do NOT change the values directly in this file. If you need to change the value of a property, -# create a file called "build.local.properties" in the same folder and change the value in that file. - -# War file id for the alfresco application -app.war.artifactId=alfresco - -# Tomcat folder name used by the alfresco application +# Do NOT change the values directly in this file. If you need to change the value of a property, +# create a file called "build.local.properties" in the same folder and change the value in that file. + +# War file id for the alfresco application +app.war.artifactId=alfresco + +# Tomcat folder name used by the alfresco application app.tomcat=tomcat \ No newline at end of file diff --git a/rm-server/build.xml b/rm-server/build.xml index 38b8d1509c..88985931d2 100644 --- a/rm-server/build.xml +++ b/rm-server/build.xml @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/action-context.xml index 5ce959d53f..7a6053d037 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/action-context.xml @@ -1,66 +1,66 @@ - - - - - - - - - - alfresco.module.org_alfresco_module_rm.messages.actions - - - - - - - - - - - - - - {http://www.alfresco.org/model/content/1.0}content - - - - - - - - - - - - - - {http://www.alfresco.org/model/content/1.0}content - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + alfresco.module.org_alfresco_module_rm.messages.actions + + + + + + + + + + + + + + {http://www.alfresco.org/model/content/1.0}content + + + + + + + + + + + + + + {http://www.alfresco.org/model/content/1.0}content + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties index 627a3feef5..4c3a2f3d64 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties @@ -1,79 +1,79 @@ -# Enable ghosting of records on deletion -rm.ghosting.enabled=true - -# Notification configuration -rm.notification.role=RecordsManager -# NOTE: the notification subject can now be set within the usual I18N property files per notification template - -# -# Turn off imap server attachments if we are using RM. -# TODO : Longer term needs to have a query based, dynamic -# exclusion for RM sites. -# -imap.server.attachments.extraction.enabled=false - -# -# Enable auditing -# -audit.enabled=true -audit.rm.enabled=true - -# -# Extended permission service cache sizing -# -cache.writersSharedCache.maxItems=10000 -cache.writersSharedCache.cluster.type=fully-distributed - -# -# Indicates whether RM rules will be run as Admin or not by default -# -rm.rule.runasadmin=true - -# -# Auto-complete suggestion parameters -# -# The minimum size of fragment supplied that will trigger a search for suggestions for auto completion -rm.autocompletesuggestion.minfragmentsize=2 -# The maximum number of path suggestions to supply -rm.autocompletesuggestion.maxsuggestions.path=5 -# The maximum number of node suggestions to supply -rm.autocompletesuggestion.maxsuggestions.node=5 -# The maximum number of date suggestions to supply -rm.autocompletesuggestion.maxsuggestions.date=5 -# Comma separated list of types/aspects to be used by the node parameter autocomplete suggester -rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes=rma:record,cm:content - -# -# Global RM disposition lifecycle trigger cron job expression -# -rm.dispositionlifecycletrigger.cronexpression=0 0/5 * * * ? - -# -# Records contributors group -# -# if false then record contributor check is ignored and all users can contribute records from -# a collaboration site, if true then a user must be a member of the records contributor group -# in order for them to contribute a record from a collaboration site. Default value 'false'. -rm.record.contributors.group.enabled=false -# record contributors group, default value 'RECORD_CONTRIBUTORS' -rm.record.contributors.group.name=RECORD_CONTRIBUTORS - -# Indicates whether mandatory properties are checked before completing a record -# -rm.completerecord.mandatorypropertiescheck.enabled=true - -# -# Indicates whether the existing file plan is converted to a standard file plan during -# upgrade to V2.2, otherwise it will be converted to a DoD compliant file plan. -# -# Note that when converted to a standard file plan that DoD related record meta-data remains -# on the individual records and will not be visible in the UI, but can be assessed via -# deprecated model properties in the rma namespace. -# -rm.patch.v22.convertToStandardFilePlan=false - -# -# Extended auto-version behaviour. If true and other auto-version properties are satisfied, then -# a document will be auto-versioned when its type is changed. -# -version.store.enableAutoVersionOnTypeChange=false +# Enable ghosting of records on deletion +rm.ghosting.enabled=true + +# Notification configuration +rm.notification.role=RecordsManager +# NOTE: the notification subject can now be set within the usual I18N property files per notification template + +# +# Turn off imap server attachments if we are using RM. +# TODO : Longer term needs to have a query based, dynamic +# exclusion for RM sites. +# +imap.server.attachments.extraction.enabled=false + +# +# Enable auditing +# +audit.enabled=true +audit.rm.enabled=true + +# +# Extended permission service cache sizing +# +cache.writersSharedCache.maxItems=10000 +cache.writersSharedCache.cluster.type=fully-distributed + +# +# Indicates whether RM rules will be run as Admin or not by default +# +rm.rule.runasadmin=true + +# +# Auto-complete suggestion parameters +# +# The minimum size of fragment supplied that will trigger a search for suggestions for auto completion +rm.autocompletesuggestion.minfragmentsize=2 +# The maximum number of path suggestions to supply +rm.autocompletesuggestion.maxsuggestions.path=5 +# The maximum number of node suggestions to supply +rm.autocompletesuggestion.maxsuggestions.node=5 +# The maximum number of date suggestions to supply +rm.autocompletesuggestion.maxsuggestions.date=5 +# Comma separated list of types/aspects to be used by the node parameter autocomplete suggester +rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes=rma:record,cm:content + +# +# Global RM disposition lifecycle trigger cron job expression +# +rm.dispositionlifecycletrigger.cronexpression=0 0/5 * * * ? + +# +# Records contributors group +# +# if false then record contributor check is ignored and all users can contribute records from +# a collaboration site, if true then a user must be a member of the records contributor group +# in order for them to contribute a record from a collaboration site. Default value 'false'. +rm.record.contributors.group.enabled=false +# record contributors group, default value 'RECORD_CONTRIBUTORS' +rm.record.contributors.group.name=RECORD_CONTRIBUTORS + +# Indicates whether mandatory properties are checked before completing a record +# +rm.completerecord.mandatorypropertiescheck.enabled=true + +# +# Indicates whether the existing file plan is converted to a standard file plan during +# upgrade to V2.2, otherwise it will be converted to a DoD compliant file plan. +# +# Note that when converted to a standard file plan that DoD related record meta-data remains +# on the individual records and will not be visible in the UI, but can be assessed via +# deprecated model properties in the rma namespace. +# +rm.patch.v22.convertToStandardFilePlan=false + +# +# Extended auto-version behaviour. If true and other auto-version properties are satisfied, then +# a document will be auto-versioned when its type is changed. +# +version.store.enableAutoVersionOnTypeChange=false diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/audit/rm-audit.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/audit/rm-audit.xml index 6ceab3c551..7e8cfc0eb6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/audit/rm-audit.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/audit/rm-audit.xml @@ -1,90 +1,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml index cc6fe1f97e..4cbf4f39c7 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml @@ -1,254 +1,254 @@ - - - - - - - workspace - SpacesStore - rm_config_folder - Records Management - Records Management - Configuration information for the Records Management application. - - - - - - - - - - - workspace - SpacesStore - rm_event_config - Records management event configuration. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json|mimetype=text/plain|encoding=UTF-8 - rm_event_config.json - rm_event_config.json - - - - - - - - - workspace - SpacesStore - records_management_custom_model - Records Management Custom Model - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml|mimetype=text/plain|encoding=UTF-8 - recordsCustomModel.xml - recordsCustomModel.xml - {http://www.alfresco.org/model/rmcustom/1.0}rmcustom - Records Management Custom Model - Alfresco - 1.0 - true - - - - - - workspace - SpacesStore - rm_behavior_scripts - Records Management Behavior Scripts - Records Management Behavior Scripts - Scripts intended for execution in response to RM events. - - - - - - - - - - workspace - SpacesStore - Records management sample script. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js|mimetype=text/javascript|encoding=UTF-8 - onCreate_supersedes.js - onCreate_supersedes.js - - - - - - - - - workspace - SpacesStore - rm_scripts - Records Management Scripts - Records Management Scripts - Scripts specific to RM that can also be executed by RM rules. - - - - - - workspace - SpacesStore - records_management_email_templates - Records Management Email Templates - Records Management Email Templates - Email templates for records management. - - - - - - - - - - - - - - true - - Email template for notify records due for review job. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_ - notify-records-due-for-review-email.ftl - - notify-records-due-for-review-email.ftl - org_alfresco_module_rm_notificationTemplatePatch - - - - - - - - - - - - workspace - SpacesStore - record_superseded_template - Record superseded email template. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl|mimetype=text/plain|encoding=UTF-8 - record-superseded-email.ftl - record-superseded-email.ftl - org_alfresco_module_rm_notificationTemplatePatch - - - - - - - - - - - workspace - SpacesStore - record_rejected_template - Record rejected email template. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl|mimetype=text/plain|encoding=UTF-8 - record-rejected-email.ftl - record-rejected-email.ftl - org_alfresco_module_rm_notificationTemplatePatch - - - - - - - - - workspace - SpacesStore - rm_report_templates - Records Management Report Templates - Records Management Report Templates - Records management report templates. - - - - - - - - - - workspace - SpacesStore - rmr_destructionReport - Desruction report template. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl|mimetype=text/plain|encoding=UTF-8 - Destruction Report Template - report_rmr_destructionReport.html.ftl - - - - - - - - - - - workspace - SpacesStore - rmr_transferReport - Transfer report template. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl|mimetype=text/plain|encoding=UTF-8 - Transfer Report Template - report_rmr_transferReport.html.ftl - - - - - - - - - - - workspace - SpacesStore - rmr_holdReport - Hold report template. - contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl|mimetype=text/plain|encoding=UTF-8 - Hold Report Template - report_rmr_holdReport.html.ftl - - - - - - - - - - + + + + + + + workspace + SpacesStore + rm_config_folder + Records Management + Records Management + Configuration information for the Records Management application. + + + + + + + + + + + workspace + SpacesStore + rm_event_config + Records management event configuration. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json|mimetype=text/plain|encoding=UTF-8 + rm_event_config.json + rm_event_config.json + + + + + + + + + workspace + SpacesStore + records_management_custom_model + Records Management Custom Model + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml|mimetype=text/plain|encoding=UTF-8 + recordsCustomModel.xml + recordsCustomModel.xml + {http://www.alfresco.org/model/rmcustom/1.0}rmcustom + Records Management Custom Model + Alfresco + 1.0 + true + + + + + + workspace + SpacesStore + rm_behavior_scripts + Records Management Behavior Scripts + Records Management Behavior Scripts + Scripts intended for execution in response to RM events. + + + + + + + + + + workspace + SpacesStore + Records management sample script. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js|mimetype=text/javascript|encoding=UTF-8 + onCreate_supersedes.js + onCreate_supersedes.js + + + + + + + + + workspace + SpacesStore + rm_scripts + Records Management Scripts + Records Management Scripts + Scripts specific to RM that can also be executed by RM rules. + + + + + + workspace + SpacesStore + records_management_email_templates + Records Management Email Templates + Records Management Email Templates + Email templates for records management. + + + + + + + + + + + + + + true + + Email template for notify records due for review job. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_ + notify-records-due-for-review-email.ftl + + notify-records-due-for-review-email.ftl + org_alfresco_module_rm_notificationTemplatePatch + + + + + + + + + + + + workspace + SpacesStore + record_superseded_template + Record superseded email template. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl|mimetype=text/plain|encoding=UTF-8 + record-superseded-email.ftl + record-superseded-email.ftl + org_alfresco_module_rm_notificationTemplatePatch + + + + + + + + + + + workspace + SpacesStore + record_rejected_template + Record rejected email template. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl|mimetype=text/plain|encoding=UTF-8 + record-rejected-email.ftl + record-rejected-email.ftl + org_alfresco_module_rm_notificationTemplatePatch + + + + + + + + + workspace + SpacesStore + rm_report_templates + Records Management Report Templates + Records Management Report Templates + Records management report templates. + + + + + + + + + + workspace + SpacesStore + rmr_destructionReport + Desruction report template. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl|mimetype=text/plain|encoding=UTF-8 + Destruction Report Template + report_rmr_destructionReport.html.ftl + + + + + + + + + + + workspace + SpacesStore + rmr_transferReport + Transfer report template. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl|mimetype=text/plain|encoding=UTF-8 + Transfer Report Template + report_rmr_transferReport.html.ftl + + + + + + + + + + + workspace + SpacesStore + rmr_holdReport + Hold report template. + contentUrl=classpath:alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl|mimetype=text/plain|encoding=UTF-8 + Hold Report Template + report_rmr_holdReport.html.ftl + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl index acf23fce72..d0817176db 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl @@ -1,124 +1,124 @@ - - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - -
- - - - -
- - - - - -
- - -
- Records due for review. -
-
- ${date?datetime?string.full} -
-
-
-

Hi,

- -

The following records are now due for review:

- - <#if (args.records)??> - - <#list args.records as record> - - - - <#if record_has_next> - - - -
- - - - - -
- - - - - - - - - - - - -
${record.properties["rma:identifier"]!} ${record.name}
Click on this link to view the record:
- - ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${record.storeType}://${record.storeId}/${record.id} -
-
-
- - -

Sincerely,
- Alfresco ${productName!""}

-
-
-
-
 
-
- To find out more about Alfresco ${productName!""} visit http://www.alfresco.com -
-
 
-
- -
-
-
- + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + +
+ + +
+ Records due for review. +
+
+ ${date?datetime?string.full} +
+
+
+

Hi,

+ +

The following records are now due for review:

+ + <#if (args.records)??> + + <#list args.records as record> + + + + <#if record_has_next> + + + +
+ + + + + +
+ + + + + + + + + + + + +
${record.properties["rma:identifier"]!} ${record.name}
Click on this link to view the record:
+ + ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${record.storeType}://${record.storeId}/${record.id} +
+
+
+ + +

Sincerely,
+ Alfresco ${productName!""}

+
+
+
+
 
+
+ To find out more about Alfresco ${productName!""} visit http://www.alfresco.com +
+
 
+
+ +
+
+
+ \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js index 330a794f50..cee238a11e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/onCreate_supersedes.js @@ -1,15 +1,15 @@ -/** - * Main entrypoint for script. - * - * @method main - */ -function main() -{ - // Log debug message - logger.log("Record " + node.name + " has been superseded. Sending notification"); - - // Send notification - rmService.sendSupersededNotification(node); -} - -main(); +/** + * Main entrypoint for script. + * + * @method main + */ +function main() +{ + // Log debug message + logger.log("Record " + node.name + " has been superseded. Sending notification"); + + // Send notification + rmService.sendSupersededNotification(node); +} + +main(); diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl index 29bafa0511..e11b76580b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl @@ -1,120 +1,120 @@ - - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - -
- - - - -
- - - - - -
- - -
- Record has been rejected -
-
- ${args.rejectDate?datetime?string.full} -
-
-
-

Hello ${args.recordCreator},

- -

${args.rejectedPerson} has rejected the following record with this reason:

- -

${args.rejectReason}

- - - - - - -
- - - - - -
- - - - - - - - - - - - -
${args.recordId} ${args.recordName}
Click on this link to view the record:
- - ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${args.record.storeType}://${args.record.storeId}/${args.record.id} -
-
-
- -

Sincerely,
- Alfresco ${productName!""}

-
-
-
-
 
-
- To find out more about Alfresco ${productName!""} visit http://www.alfresco.com -
-
 
-
- -
-
-
- - + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + +
+ + +
+ Record has been rejected +
+
+ ${args.rejectDate?datetime?string.full} +
+
+
+

Hello ${args.recordCreator},

+ +

${args.rejectedPerson} has rejected the following record with this reason:

+ +

${args.rejectReason}

+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + +
${args.recordId} ${args.recordName}
Click on this link to view the record:
+ + ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${args.record.storeType}://${args.record.storeId}/${args.record.id} +
+
+
+ +

Sincerely,
+ Alfresco ${productName!""}

+
+
+
+
 
+
+ To find out more about Alfresco ${productName!""} visit http://www.alfresco.com +
+
 
+
+ +
+
+
+ + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl index e15b1024f3..65b726b210 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl @@ -1,118 +1,118 @@ - - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - -
- - - - -
- - - - - -
- - -
- Superseded record. -
-
- ${date?datetime?string.full} -
-
-
-

Hi,

- -

The following record been superseded:

- - - - - - -
- - - - - -
- - - - - - - - - - - - -
${args.record.properties["rma:identifier"]!} ${args.record.name}
Click on this link to view the record:
- - ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${args.record.storeType}://${args.record.storeId}/${args.record.id} -
-
-
- -

Sincerely,
- Alfresco ${productName!""}

-
-
-
-
 
-
- To find out more about Alfresco ${productName!""} visit http://www.alfresco.com -
-
 
-
- -
-
-
- - + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + +
+ + +
+ Superseded record. +
+
+ ${date?datetime?string.full} +
+
+
+

Hi,

+ +

The following record been superseded:

+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + +
${args.record.properties["rma:identifier"]!} ${args.record.name}
Click on this link to view the record:
+ + ${shareUrl}/page/site/${args.site}/document-details?nodeRef=${args.record.storeType}://${args.record.storeId}/${args.record.id} +
+
+
+ +

Sincerely,
+ Alfresco ${productName!""}

+
+
+
+
 
+
+ To find out more about Alfresco ${productName!""} visit http://www.alfresco.com +
+
 
+
+ +
+
+
+ + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml index 9e3244ce81..15fad5c368 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/recordsCustomModel.xml @@ -1,159 +1,159 @@ - - - - - - - - - Records Management Custom Model - Alfresco - 1.0 - - - - - - - - - - - - - - - - - - - - - - - listconstraint.rmc_smList.title - - - - - true - - - - - listconstraint.rmc_tlList.title - - - - - true - - - - - - - - - - Supplemental Marking List - d:text - false - true - - - - - - - - - - Records Management Custom Associations - - - - - Superseded By__Supersedes - - false - true - - - rma:record - false - true - - - - - Obsoleted By__Obsoletes - - false - true - - - rma:record - false - true - - - - - Next Version__Previous Version - - false - true - - - rma:record - false - true - - - - - Supporting Documentation__Supported Documentation - - false - true - - - rma:record - false - true - - - - - Cross-Reference - - false - true - - - rma:record - false - true - - - - - Rendition - - false - true - - - rma:record - false - true - - - - - - - - + + + + + + + + + Records Management Custom Model + Alfresco + 1.0 + + + + + + + + + + + + + + + + + + + + + + + listconstraint.rmc_smList.title + + + + + true + + + + + listconstraint.rmc_tlList.title + + + + + true + + + + + + + + + + Supplemental Marking List + d:text + false + true + + + + + + + + + + Records Management Custom Associations + + + + + Superseded By__Supersedes + + false + true + + + rma:record + false + true + + + + + Obsoleted By__Obsoletes + + false + true + + + rma:record + false + true + + + + + Next Version__Previous Version + + false + true + + + rma:record + false + true + + + + + Supporting Documentation__Supported Documentation + + false + true + + + rma:record + false + true + + + + + Cross-Reference + + false + true + + + rma:record + false + true + + + + + Rendition + + false + true + + + rma:record + false + true + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json index 6eb58eff72..3e2a07df1b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rmEventConfigBootstrap.json @@ -1,76 +1,76 @@ -{ - "events" : - [ - { - "eventType" : "rmEventType.simple", - "eventName" : "case_closed", - "eventDisplayLabel" : "rmevent.case_closed" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "abolished", - "eventDisplayLabel" : "rmevent.abolished" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "re_designated", - "eventDisplayLabel" : "rmevent.re_designated" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "no_longer_needed", - "eventDisplayLabel" : "rmevent.no_longer_needed" - }, - { - "eventType" : "rmEventType.superseded", - "eventName" : "superseded", - "eventDisplayLabel" : "rmevent.superseded" - }, - { - "eventType" : "rmEventType.versioned", - "eventName" : "versioned", - "eventDisplayLabel" : "rmevent.versioned" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "study_complete", - "eventDisplayLabel" : "rmevent.study_complete" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "training_complete", - "eventDisplayLabel" : "rmevent.training_complete" - }, - { - "eventType" : "rmEventType.crossReferencedRecordTransfered", - "eventName" : "related_record_trasfered_inactive_storage", - "eventDisplayLabel" : "rmevent.related_record_trasfered_inactive_storage" - }, - { - "eventType" : "rmEventType.obsolete", - "eventName" : "obsolete", - "eventDisplayLabel" : "rmevent.obsolete" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "all_allowances_granted_are_terminated", - "eventDisplayLabel" : "rmevent.all_allowances_granted_are_terminated" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "WGI_action_complete", - "eventDisplayLabel" : "rmevent.WGI_action_complete" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "separation", - "eventDisplayLabel" : "rmevent.separation" - }, - { - "eventType" : "rmEventType.simple", - "eventName" : "case_complete", - "eventDisplayLabel" : "rmevent.case_complete" - } - ] -} - +{ + "events" : + [ + { + "eventType" : "rmEventType.simple", + "eventName" : "case_closed", + "eventDisplayLabel" : "rmevent.case_closed" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "abolished", + "eventDisplayLabel" : "rmevent.abolished" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "re_designated", + "eventDisplayLabel" : "rmevent.re_designated" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "no_longer_needed", + "eventDisplayLabel" : "rmevent.no_longer_needed" + }, + { + "eventType" : "rmEventType.superseded", + "eventName" : "superseded", + "eventDisplayLabel" : "rmevent.superseded" + }, + { + "eventType" : "rmEventType.versioned", + "eventName" : "versioned", + "eventDisplayLabel" : "rmevent.versioned" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "study_complete", + "eventDisplayLabel" : "rmevent.study_complete" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "training_complete", + "eventDisplayLabel" : "rmevent.training_complete" + }, + { + "eventType" : "rmEventType.crossReferencedRecordTransfered", + "eventName" : "related_record_trasfered_inactive_storage", + "eventDisplayLabel" : "rmevent.related_record_trasfered_inactive_storage" + }, + { + "eventType" : "rmEventType.obsolete", + "eventName" : "obsolete", + "eventDisplayLabel" : "rmevent.obsolete" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "all_allowances_granted_are_terminated", + "eventDisplayLabel" : "rmevent.all_allowances_granted_are_terminated" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "WGI_action_complete", + "eventDisplayLabel" : "rmevent.WGI_action_complete" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "separation", + "eventDisplayLabel" : "rmevent.separation" + }, + { + "eventType" : "rmEventType.simple", + "eventName" : "case_complete", + "eventDisplayLabel" : "rmevent.case_complete" + } + ] +} + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rma_isClosed.js b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rma_isClosed.js index 1728d5c903..66fd2d7209 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rma_isClosed.js +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/rma_isClosed.js @@ -1,12 +1,12 @@ -/** - * Main entrypoint for script. - * This sample script simply echoes the name of the node with the changed property. - * - * @method main - */ -function main() -{ - logger.log("Sample RM script. No-op run on node " + node.name); -} - -main(); +/** + * Main entrypoint for script. + * This sample script simply echoes the name of the node with the changed property. + * + * @method main + */ +function main() +{ + logger.log("Sample RM script. No-op run on node " + node.name); +} + +main(); diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl index ef8c456a6d..1666a5af0f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl @@ -1,116 +1,116 @@ - - - - - - - - - -
- - - - -
- - - - - - - -
- - - - -
- - - - - -
- - -
- ${message("file.report.destruction.report")} -
-
-
- - - - - - - - - - - - - -
${message("file.report.destroyed")} <#if node.hasAspect("rma:record")>${message("file.report.record")}<#else>${message("file.report.record.folder")}:${node.properties["rma:identifier"]} ${node.properties.name}
${message("file.report.disposition.authority")}: - <#if node.properties["rma:recordSearchDispositionAuthority"]??> - ${node.properties["rma:recordSearchDispositionAuthority"]} - -
${message("file.report.disposition.instructions")}: - <#if node.properties["rma:recordSearchDispositionInstructions"]??> - ${node.properties["rma:recordSearchDispositionInstructions"]} - -
- <#if node.childAssociations["cm:contains"]??> -
- - - - - -
${message("file.report.destroyed.records")}:
- - - - -
- - <#list node.childAssociations["cm:contains"] as child> - - - - - -
- - - - - - -
${child.properties["rma:identifier"]} ${child.properties.name}
-
-
- -
-
-
-
- -
-
-
- + + + + + + + + + +
+ + + + +
+ + + + + + + +
+ + + + +
+ + + + + +
+ + +
+ ${message("file.report.destruction.report")} +
+
+
+ + + + + + + + + + + + + +
${message("file.report.destroyed")} <#if node.hasAspect("rma:record")>${message("file.report.record")}<#else>${message("file.report.record.folder")}:${node.properties["rma:identifier"]} ${node.properties.name}
${message("file.report.disposition.authority")}: + <#if node.properties["rma:recordSearchDispositionAuthority"]??> + ${node.properties["rma:recordSearchDispositionAuthority"]} + +
${message("file.report.disposition.instructions")}: + <#if node.properties["rma:recordSearchDispositionInstructions"]??> + ${node.properties["rma:recordSearchDispositionInstructions"]} + +
+ <#if node.childAssociations["cm:contains"]??> +
+ + + + + +
${message("file.report.destroyed.records")}:
+ + + + +
+ + <#list node.childAssociations["cm:contains"] as child> + + + + + +
+ + + + + + +
${child.properties["rma:identifier"]} ${child.properties.name}
+
+
+ +
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl index 331af6e0b2..e52cd56111 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl @@ -1,120 +1,120 @@ - - - - - - - - - -
- - - - -
- - - - - - - -
- - - - -
- - - - - -
- - -
- ${message("file.report.hold.report")} -
-
-
- - - - - - - - - - - - - - - - - - - - - -
${message("file.report.hold.name")}:${node.properties["cm:name"]}
${message("file.report.hold.description")}: - <#if node.properties["cm:description"]??> - ${node.properties["cm:description"]} - -
${message("file.report.hold.reason")}:${node.properties["rma:holdReason"]}
${message("file.report.createdby")}:${reportUser}
${message("file.report.createdon")}:${reportDate}
- <#if node.childAssociations["rma:frozenRecords"]??> -
- - - - - -
${message("file.report.hold.held")}:
- - - - -
- - <#list node.childAssociations["rma:frozenRecords"] as child> - - - - - -
- - - - - - -
${child.properties["rma:identifier"]} ${child.properties.name}
-
-
- -
-
-
-
- -
-
-
- + + + + + + + + + +
+ + + + +
+ + + + + + + +
+ + + + +
+ + + + + +
+ + +
+ ${message("file.report.hold.report")} +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
${message("file.report.hold.name")}:${node.properties["cm:name"]}
${message("file.report.hold.description")}: + <#if node.properties["cm:description"]??> + ${node.properties["cm:description"]} + +
${message("file.report.hold.reason")}:${node.properties["rma:holdReason"]}
${message("file.report.createdby")}:${reportUser}
${message("file.report.createdon")}:${reportDate}
+ <#if node.childAssociations["rma:frozenRecords"]??> +
+ + + + + +
${message("file.report.hold.held")}:
+ + + + +
+ + <#list node.childAssociations["rma:frozenRecords"] as child> + + + + + +
+ + + + + + +
${child.properties["rma:identifier"]} ${child.properties.name}
+
+
+ +
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl index 8b4bd71cbe..4350a7375b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl @@ -1,87 +1,87 @@ - - - <#assign isAccession=node.properties["rma:transferAccessionIndicator"]> - - <#if isAccession> - ${message("file.report.acession.report")} - <#else> - ${message("file.report.transfer.report")} - - - - - <#if isAccession> -

${message("file.report.acession.report")}

- <#else> -

${message("file.report.transfer.report")}

- - - - - - - - - - - - - - - - - - -
${message("file.report.transfer.date")}:${node.properties["cm:created"]?string(message("file.report.date.format"))?html}
${message("file.report.transfer.location")}: - <#if isAccession> - ${message("file.report.nara")} - <#else> - ${node.properties["rma:transferLocation"]?html} - -
${message("file.report.performed.by")}:${node.properties["cm:creator"]?html}
${message("file.report.disposition.authority")}:${properties["dispositionAuthority"]?html}
-

${message("file.report.transferred.items")}

-
- <#list properties.transferNodes as transferNode> - <#if transferNode.properties["isFolder"]> - <@generateTransferFolderHTML transferNode/> - <#else> - <@generateTransferRecordHTML transferNode/> - - -
- - - -<#macro generateTransferFolderHTML transferNode> - - ${transferNode.properties["name"]?html} - - (${message("file.report.unique.folder.identifier")}: ${transferNode.properties["identifier"]?html}) -
- <#list transferNode.properties["records"] as record> - <@generateTransferRecordHTML record/> - -
- - -<#macro generateTransferRecordHTML transferNode> -
- - ${transferNode.properties["name"]?html} - - (${message("file.report.unique.record.identifier")}: ${transferNode.properties["identifier"]?html}) - <#if transferNode.properties["isDeclared"]> - ${message("file.report.declared.by")} - ${transferNode.properties["declaredBy"]?html} - ${message("file.report.declared.on")} - ${transferNode.properties["declaredOn"]?string(message("file.report.date.format"))?html} - -
+ + + <#assign isAccession=node.properties["rma:transferAccessionIndicator"]> + + <#if isAccession> + ${message("file.report.acession.report")} + <#else> + ${message("file.report.transfer.report")} + + + + + <#if isAccession> +

${message("file.report.acession.report")}

+ <#else> +

${message("file.report.transfer.report")}

+ + + + + + + + + + + + + + + + + + +
${message("file.report.transfer.date")}:${node.properties["cm:created"]?string(message("file.report.date.format"))?html}
${message("file.report.transfer.location")}: + <#if isAccession> + ${message("file.report.nara")} + <#else> + ${node.properties["rma:transferLocation"]?html} + +
${message("file.report.performed.by")}:${node.properties["cm:creator"]?html}
${message("file.report.disposition.authority")}:${properties["dispositionAuthority"]?html}
+

${message("file.report.transferred.items")}

+
+ <#list properties.transferNodes as transferNode> + <#if transferNode.properties["isFolder"]> + <@generateTransferFolderHTML transferNode/> + <#else> + <@generateTransferRecordHTML transferNode/> + + +
+ + + +<#macro generateTransferFolderHTML transferNode> + + ${transferNode.properties["name"]?html} + + (${message("file.report.unique.folder.identifier")}: ${transferNode.properties["identifier"]?html}) +
+ <#list transferNode.properties["records"] as record> + <@generateTransferRecordHTML record/> + +
+ + +<#macro generateTransferRecordHTML transferNode> +
+ + ${transferNode.properties["name"]?html} + + (${message("file.report.unique.record.identifier")}: ${transferNode.properties["identifier"]?html}) + <#if transferNode.properties["isDeclared"]> + ${message("file.report.declared.by")} + ${transferNode.properties["declaredBy"]?html} + ${message("file.report.declared.on")} + ${transferNode.properties["declaredOn"]?string(message("file.report.date.format"))?html} + +
\ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/groups/rm-capability-groups-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/groups/rm-capability-groups-context.xml index dc769ec8ad..0e940d34ef 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/groups/rm-capability-groups-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/groups/rm-capability-groups-context.xml @@ -1,85 +1,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-audit-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-audit-context.xml index 89139b93b2..5548567780 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-audit-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-audit-context.xml @@ -1,73 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml index 408cbbf617..1d36a8a2d9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml @@ -1,227 +1,227 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-config-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-config-context.xml index 1cf4201a4e..5cc9dffd5b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-config-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-config-context.xml @@ -1,94 +1,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-disposition-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-disposition-context.xml index 5f4f44880b..3dc524bfe4 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-disposition-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-disposition-context.xml @@ -1,316 +1,316 @@ - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - FILE_PLAN_COMPONENT - - - - - - - - - - - - - - - - - - - - - RECORD - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - TRANSFER - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + FILE_PLAN_COMPONENT + + + + + + + + + + + + + + + + + + + + + RECORD + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + TRANSFER + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-event-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-event-context.xml index 3ed05e48aa..c9362ed9d6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-event-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-event-context.xml @@ -1,42 +1,42 @@ - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index b42957bd9f..e8eeae8602 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -1,97 +1,97 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FILE_PLAN - - - - - - - - - - - - - - - - RECORD_CATEGORY - DISPOSITION_SCHEDULE - - - - - - - - - - - - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FILE_PLAN + + + + + + + + + + + + + + + + RECORD_CATEGORY + DISPOSITION_SCHEDULE + + + + + + + + + + + + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml index 8db7ba051b..5a1cceb841 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml @@ -1,171 +1,171 @@ - - - - - - - - - - - - - FILE_PLAN - HOLD_CONTAINER - - - - - - - - - - - - - - - - - HOLD - - - - - - - - - - - - - - - - - HOLD - - - - - - - - - - - - - - - - - HOLD - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - HOLD - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - HOLD - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + FILE_PLAN + HOLD_CONTAINER + + + + + + + + + + + + + + + + + HOLD + + + + + + + + + + + + + + + + + HOLD + + + + + + + + + + + + + + + + + HOLD + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + HOLD + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + HOLD + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 fdb478b0a2..91a50ef89d 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 @@ -1,249 +1,249 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - - - - - - - FILE_PLAN - RECORD_CATEGORY - RECORD_FOLDER - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + + + + + + + FILE_PLAN + RECORD_CATEGORY + RECORD_FOLDER + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-record-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-record-context.xml index 8b82723be3..9ca62f1f72 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-record-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-record-context.xml @@ -1,389 +1,389 @@ - - - - - - - - - - - - - - - - - - - RECORD - RECORD_FOLDER - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + RECORD + RECORD_FOLDER + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-recordfolder-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-recordfolder-context.xml index 81658b0db5..f1f1734d21 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-recordfolder-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-recordfolder-context.xml @@ -1,227 +1,227 @@ - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-reference-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-reference-context.xml index 459b7790a2..2ddba0e1ea 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-reference-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-reference-context.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-rule-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-rule-context.xml index 3175faf8ed..1ad04ef1d7 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-rule-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-rule-context.xml @@ -1,20 +1,20 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml index 1d25bb38b2..2d390542d8 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml @@ -1,61 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml index 9b40dfe679..be126f3e62 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml @@ -1,1046 +1,1046 @@ - - - - - - - Reports - 0318 - Reports - Record series for reports - - - - - - - - - - - - - AIS Audit Records - 0318-01 - AIS Audit Records - Consisting of AIS Security Officer or Terminal Area Security Officer weekly audit records of audit actions performed on all AIS as required by applicable policy which are maintained by any JS/combatant command activity. - week|1 - true - - - - - - - - - N1-218-00-4 item 023 - Cut off monthly, hold 1 month, then destroy. - - - - - - - - cutoff - monthend|1 - - - - - destroy - month|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - - January AIS Audit Records - January AIS Audit Records - 0318-01-01 - week|1 - true - - - - - - - - - - - - - - - Unit Manning Documents - 0318-02 - Unit Manning Documents - Consisting of manpower document and monthly strength report forwarded to OSD and other activities which are maintained by personnel office as the official record copy. - - - - - - - - - N1-218-89-1 item 002 - Cut off every 3 months, hold 3 months, then destroy. - - - - - - - - cutoff - quarterend|1 - - - - - destroy - month|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - 1st Quarter Unit Manning Documents - 0318-02-01 - 1st Quarter Unit Manning Documents - - - - - - - - - - - - - - - Overtime Reports - 0318-03 - Overtime reports and related documents - Overtime reports and related documents which are maintained by JS/combatant controller as the official record copy. - - - - - - - - - N1-218-00-7 item 28 - Cut off at end of FY, hold 3 years, then destroy. - - - - - - - cutoff - fyend|1 - - - - - destroy - year|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - FY08 Overtime Reports - 0318-03-01 - FY08 Overtime Reports - - - - - - - - - - - - - - - Bi-Weekly Cost Reports - 0318-04 - Bi-Weekly Cost Reports - Bi-wekly cost reports which are maintained by JS/combatant command controler as the official record copy. - - - - - - - - - N1-218-00-7 item 2 - Cut off at end of CY, hold 2 years, then destroy. - - - - - - - cutoff - yearend|1 - - - - - destroy - year|2 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - CY08 Unit Manning Documents - 0318-04-01 - CY08 Unit Manning Documents - - - - - - - - - - - - - - - - Military Files - 0412 - Military Files - Record series for military files - - - - - - - - - - - - - Military Assignment Documents - 0412-01 - Military Assignment Documents - Policy matters pertaining to military assignments which are maintained by any JS/combatant command activity as the official record copy. - - - - - - - - - N1-218-00-3 item 30 - Cut off when superseded, hold 5 years, then destroy. - true - - - - - - - cutoff - superseded - - - - - destroy - year|5 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - - - - - - - - - Official Military Personnel Privilege Card Applications - 0412-02 - Official Military Personnel Privilege Card Applications - Consisting of: documents reflecting applications for priviege cards and ration cards, including Department of Defense Forms (DD Forms) 1172 (Application for Unifomed Services Identification and Privilege Card) and similar documents which are maintained by any JS/combatant command activity. - - - - - - - - - N1-218-00-3 item 20 - Cut off when no longer needed and destroy immediately. - - - - - - - cutoff - no_longer_needed - - - - - destroy - immediately|0 - - - - - - - - - - - - COL Bob Johnson - 0412-02-01 - COL Bob Johnson - - - - - PFC Alan Murphy - 0412-02-02 - PFC Alan Murphy - - - - - - - - - - - - - - - Personnel Security Program Records - 0412-03 - Personnel Security Program Records - Position sensitivity files including requests for information relating to the designation of sensitive and non-sensitive personnel positions in an agency and results of final actions taken consisting of approved requests which are maintained by any JS/combatant command activity - - - - - - - - - N1-218-00-4 item 017 - Cutoff when position is abolished, re-designated, or no longer needed, whichever is later. Destroy immediately after cutoff. - - - - - - - cutoff - - abolished - re_designated - no_longer_needed - - and - - - - - destroy - immediately|0 - - - - - - - - - - - - Commander's Administrative Assistant - 0412-03-01 - Commander's Administrative Assistant - - - - - Equal Opportunity Coordinator - 0412-03-02 - Equal Opportunity Coordinator - - - - - - - - - - - - - - - - Civilian Files - 0430 - Civilian Files - Record series for civilian files - - - - - - - - - - - - - Employee Performance File System Records - 0430-01 - Employee Performance File System Records - Consisting of: performance records superseded through an administrative, judicial, or quasi-judicial procedure which are maintained by any JS/combatant command activity - - - - - - - - - GRS 1 item 23b(1) - Cutoff when superseded. Destroy immediately after cutoff - true - - - - - - - cutoff - superseded - - - - - destroy - immediately|0 - - - - - - - - - - - - - - - - - - - Foreign Employee Award Files - 0430-02 - Foreign Employee Award Files - Decorations to foreign nationals and US citizens not employed by the US Government consisting of: case files of recommendations, decisions, awards announcements, board meeting minutes, and related documents which are maintained by any JS/combatant command activity - - - - - - - - N1-218-00-3 item 18 - Permanent. Cut off on completion of case, hold 2 years, then retire to offline storage. Transfer to federal records holding area 5 years after retirement to offline storage. Transfer to NARA 25 years after cutoff. - - - - - - - cutoff - case_complete - - - - - transfer - Retire to offline storage. - Offline Storage - year|2 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - transfer - Transfer to federal records holding area. - Federal Records Holding - year|5 - {http://www.alfresco.org/model/recordsmanagement/1.0}dispositionAsOf - - - - - accession - Transfer to NARA. - NARA - year|25 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - Christian Bohr - 0430-02-01 - Christian Bohr - - - - - Karl Planck - 0430-02-02 - Karl Planck - - - - - - - - - - - - - - - Case Files and Papers - 0430-03 - Case Files and Papers - Consisting of library containing information on personnel actions which are maintained by R&A Br and Deputy Chief Information Office - None - Disposal not authorized. Disposition pending NARA approval. - - - - - - - Gilbert Competency Hearing - 0430-03-01 - Gilbert Competency Hearing - - - - - - - - - - - - - - - Withholding of Within-Grade Increase (WGI) Records - 0430-04 - Withholding of Within-Grade Increase (WGI) Records - Files concerning an employee’s performance rating of record with work examples which establish less than fully successful performance, notice of withholding of WGI, employee's request for reconsideration of denied WGI, and decision concerning such a reconsideration request which are maintained by any JS/combatant command activity. - - - - - - - - - N1-218-00-3 item 16 - Cut off on completion of WGI action or on separation, whichever is earlier; hold 3 years, then destroy/delete. - - - - - - - cutoff - - WGI_action_complete - separation - - or - - - - - destroy - year|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - Gilbert WGI Records - 0430-04-01 - Gilbert WGI Records - - - - - - - - - - - - - - - Payroll Differential and Allowances - 0430-05 - Payroll Differential and Allowances - Consisting of: information to assist overseas civilian personnel offices to document employee eligibility for foreign post differential and foreign quarters and post allowances, including SF 1190 (Foreign Allowances Application, Grant, and Report) and similar information which are maintained by any JS/combatant command activity. - - - - - - - - - N1-218-00-3 item 3 - Cut off at end of Fiscal Year (FY) in which all allowances granted are terminated, hold 3 years, then destroy. - - - - - - - retain - all_allowances_granted_are_terminated - - - - - cutoff - fyend|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}dispositionAsOf - - - - - destroy - year|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - Martin Payroll Differential and Allowances - 0430-05-01 - Martin Payroll Differential and Allowances - - - - - - - - - - - - - - - - Miscellaneous Files - 0950 - Miscellaneous Files - Record series for miscellaneous files - - - - - - - - - - - - - Civilian Employee Training Program Records - 0950-01 - Civilian Employee Training Program Records - Decorations to foreign nationals and US citizens not employed by the US Government consisting of: case files of recommendations, decisions, awards announcements, board meeting minutes, and related documents which are maintained by any JS/combatant command activity - - - - - - - - GRS 1 item 29b - Cut off annually, hold 5 years, then destroy, or destroy when obsolete, whichever is earlier. - - - - - - - cutoff - year|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}dateFiled - - - - - destroy - year|5 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - obsolete - - - - - - - - - - - - Bob Prentice Training Records (2008) - 0950-01-01 - Bob Prentice Training Records (2008) - - - - - Beth Tanaka Training Records (2008) - 0950-01-02 - Beth Tanaka Training Records (2008) - - - - - Chuck Stevens Training Records (2008) - 0950-01-03 - Chuck Stevens Training Records (2008) - - - - - - - - - - - - - - - Purchase of Foreign Award Medals and Decorations - 0950-02 - Purchase of Foreign Award Medals and Decorations - Forms reflecting purchase of foreign award medals and decorations. - - - - - - - - - N1-218-00-3 item 11 - Cutoff when related record is transferred to inactive storage, hold 1 year, destroy. - true - - - - - - - cutoff - related_record_trasfered_inactive_storage - - - - - destroy - year|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - - - - - - - - Monthly Cockpit Crew Training - 0950-03 - Monthly Cockpit/Crew Training - Consisting of skills training/evaluation forms, e.g., AF Form 4031. - - - - - - - - - N1-218-00-3 item 13 - Cutoff after training is complete, hold 1 year, destroy. - - - - - - - cutoff - training_complete - - - - - destroy - year|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - January Cockpit Crew Training - 0950-03-01 - January Cockpit/Crew Training - - - - - February Cockpit Crew Training - 0950-03-02 - February Cockpit/Crew Training - - - - - - - - - - - - - - - Science Advisor Records - 0950-04 - Science Advisor Records - Consisting of: reports, studies, tasking orders, and similar records. Reports are usually informal and unpublished. Records may be generated at all activities - - - - - - - - - N1-218-00-10 item 44 - Cut off on completion of study, hold 5 years, then transfer to Inactive Storage. Transfer to NARA 25 years after cutoff. - - - - - - - cutoff - study_complete - - - - - transfer - Transfer to inactive storage. - Inactive Storage - year|5 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - accession - Transfer to NARA. - NARA - year|25 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - Phoenix Mars Mission - 0950-04-01 - Phoenix Mars Mission - - - - - - - - - - - - + + + + + + + Reports + 0318 + Reports + Record series for reports + + + + + + + + + + + + + AIS Audit Records + 0318-01 + AIS Audit Records + Consisting of AIS Security Officer or Terminal Area Security Officer weekly audit records of audit actions performed on all AIS as required by applicable policy which are maintained by any JS/combatant command activity. + week|1 + true + + + + + + + + + N1-218-00-4 item 023 + Cut off monthly, hold 1 month, then destroy. + + + + + + + + cutoff + monthend|1 + + + + + destroy + month|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + + January AIS Audit Records + January AIS Audit Records + 0318-01-01 + week|1 + true + + + + + + + + + + + + + + + Unit Manning Documents + 0318-02 + Unit Manning Documents + Consisting of manpower document and monthly strength report forwarded to OSD and other activities which are maintained by personnel office as the official record copy. + + + + + + + + + N1-218-89-1 item 002 + Cut off every 3 months, hold 3 months, then destroy. + + + + + + + + cutoff + quarterend|1 + + + + + destroy + month|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + 1st Quarter Unit Manning Documents + 0318-02-01 + 1st Quarter Unit Manning Documents + + + + + + + + + + + + + + + Overtime Reports + 0318-03 + Overtime reports and related documents + Overtime reports and related documents which are maintained by JS/combatant controller as the official record copy. + + + + + + + + + N1-218-00-7 item 28 + Cut off at end of FY, hold 3 years, then destroy. + + + + + + + cutoff + fyend|1 + + + + + destroy + year|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + FY08 Overtime Reports + 0318-03-01 + FY08 Overtime Reports + + + + + + + + + + + + + + + Bi-Weekly Cost Reports + 0318-04 + Bi-Weekly Cost Reports + Bi-wekly cost reports which are maintained by JS/combatant command controler as the official record copy. + + + + + + + + + N1-218-00-7 item 2 + Cut off at end of CY, hold 2 years, then destroy. + + + + + + + cutoff + yearend|1 + + + + + destroy + year|2 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + CY08 Unit Manning Documents + 0318-04-01 + CY08 Unit Manning Documents + + + + + + + + + + + + + + + + Military Files + 0412 + Military Files + Record series for military files + + + + + + + + + + + + + Military Assignment Documents + 0412-01 + Military Assignment Documents + Policy matters pertaining to military assignments which are maintained by any JS/combatant command activity as the official record copy. + + + + + + + + + N1-218-00-3 item 30 + Cut off when superseded, hold 5 years, then destroy. + true + + + + + + + cutoff + superseded + + + + + destroy + year|5 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + + + + + + + + + Official Military Personnel Privilege Card Applications + 0412-02 + Official Military Personnel Privilege Card Applications + Consisting of: documents reflecting applications for priviege cards and ration cards, including Department of Defense Forms (DD Forms) 1172 (Application for Unifomed Services Identification and Privilege Card) and similar documents which are maintained by any JS/combatant command activity. + + + + + + + + + N1-218-00-3 item 20 + Cut off when no longer needed and destroy immediately. + + + + + + + cutoff + no_longer_needed + + + + + destroy + immediately|0 + + + + + + + + + + + + COL Bob Johnson + 0412-02-01 + COL Bob Johnson + + + + + PFC Alan Murphy + 0412-02-02 + PFC Alan Murphy + + + + + + + + + + + + + + + Personnel Security Program Records + 0412-03 + Personnel Security Program Records + Position sensitivity files including requests for information relating to the designation of sensitive and non-sensitive personnel positions in an agency and results of final actions taken consisting of approved requests which are maintained by any JS/combatant command activity + + + + + + + + + N1-218-00-4 item 017 + Cutoff when position is abolished, re-designated, or no longer needed, whichever is later. Destroy immediately after cutoff. + + + + + + + cutoff + + abolished + re_designated + no_longer_needed + + and + + + + + destroy + immediately|0 + + + + + + + + + + + + Commander's Administrative Assistant + 0412-03-01 + Commander's Administrative Assistant + + + + + Equal Opportunity Coordinator + 0412-03-02 + Equal Opportunity Coordinator + + + + + + + + + + + + + + + + Civilian Files + 0430 + Civilian Files + Record series for civilian files + + + + + + + + + + + + + Employee Performance File System Records + 0430-01 + Employee Performance File System Records + Consisting of: performance records superseded through an administrative, judicial, or quasi-judicial procedure which are maintained by any JS/combatant command activity + + + + + + + + + GRS 1 item 23b(1) + Cutoff when superseded. Destroy immediately after cutoff + true + + + + + + + cutoff + superseded + + + + + destroy + immediately|0 + + + + + + + + + + + + + + + + + + + Foreign Employee Award Files + 0430-02 + Foreign Employee Award Files + Decorations to foreign nationals and US citizens not employed by the US Government consisting of: case files of recommendations, decisions, awards announcements, board meeting minutes, and related documents which are maintained by any JS/combatant command activity + + + + + + + + N1-218-00-3 item 18 + Permanent. Cut off on completion of case, hold 2 years, then retire to offline storage. Transfer to federal records holding area 5 years after retirement to offline storage. Transfer to NARA 25 years after cutoff. + + + + + + + cutoff + case_complete + + + + + transfer + Retire to offline storage. + Offline Storage + year|2 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + transfer + Transfer to federal records holding area. + Federal Records Holding + year|5 + {http://www.alfresco.org/model/recordsmanagement/1.0}dispositionAsOf + + + + + accession + Transfer to NARA. + NARA + year|25 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + Christian Bohr + 0430-02-01 + Christian Bohr + + + + + Karl Planck + 0430-02-02 + Karl Planck + + + + + + + + + + + + + + + Case Files and Papers + 0430-03 + Case Files and Papers + Consisting of library containing information on personnel actions which are maintained by R&A Br and Deputy Chief Information Office + None + Disposal not authorized. Disposition pending NARA approval. + + + + + + + Gilbert Competency Hearing + 0430-03-01 + Gilbert Competency Hearing + + + + + + + + + + + + + + + Withholding of Within-Grade Increase (WGI) Records + 0430-04 + Withholding of Within-Grade Increase (WGI) Records + Files concerning an employee’s performance rating of record with work examples which establish less than fully successful performance, notice of withholding of WGI, employee's request for reconsideration of denied WGI, and decision concerning such a reconsideration request which are maintained by any JS/combatant command activity. + + + + + + + + + N1-218-00-3 item 16 + Cut off on completion of WGI action or on separation, whichever is earlier; hold 3 years, then destroy/delete. + + + + + + + cutoff + + WGI_action_complete + separation + + or + + + + + destroy + year|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + Gilbert WGI Records + 0430-04-01 + Gilbert WGI Records + + + + + + + + + + + + + + + Payroll Differential and Allowances + 0430-05 + Payroll Differential and Allowances + Consisting of: information to assist overseas civilian personnel offices to document employee eligibility for foreign post differential and foreign quarters and post allowances, including SF 1190 (Foreign Allowances Application, Grant, and Report) and similar information which are maintained by any JS/combatant command activity. + + + + + + + + + N1-218-00-3 item 3 + Cut off at end of Fiscal Year (FY) in which all allowances granted are terminated, hold 3 years, then destroy. + + + + + + + retain + all_allowances_granted_are_terminated + + + + + cutoff + fyend|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}dispositionAsOf + + + + + destroy + year|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + Martin Payroll Differential and Allowances + 0430-05-01 + Martin Payroll Differential and Allowances + + + + + + + + + + + + + + + + Miscellaneous Files + 0950 + Miscellaneous Files + Record series for miscellaneous files + + + + + + + + + + + + + Civilian Employee Training Program Records + 0950-01 + Civilian Employee Training Program Records + Decorations to foreign nationals and US citizens not employed by the US Government consisting of: case files of recommendations, decisions, awards announcements, board meeting minutes, and related documents which are maintained by any JS/combatant command activity + + + + + + + + GRS 1 item 29b + Cut off annually, hold 5 years, then destroy, or destroy when obsolete, whichever is earlier. + + + + + + + cutoff + year|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}dateFiled + + + + + destroy + year|5 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + obsolete + + + + + + + + + + + + Bob Prentice Training Records (2008) + 0950-01-01 + Bob Prentice Training Records (2008) + + + + + Beth Tanaka Training Records (2008) + 0950-01-02 + Beth Tanaka Training Records (2008) + + + + + Chuck Stevens Training Records (2008) + 0950-01-03 + Chuck Stevens Training Records (2008) + + + + + + + + + + + + + + + Purchase of Foreign Award Medals and Decorations + 0950-02 + Purchase of Foreign Award Medals and Decorations + Forms reflecting purchase of foreign award medals and decorations. + + + + + + + + + N1-218-00-3 item 11 + Cutoff when related record is transferred to inactive storage, hold 1 year, destroy. + true + + + + + + + cutoff + related_record_trasfered_inactive_storage + + + + + destroy + year|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + + + + + + + + Monthly Cockpit Crew Training + 0950-03 + Monthly Cockpit/Crew Training + Consisting of skills training/evaluation forms, e.g., AF Form 4031. + + + + + + + + + N1-218-00-3 item 13 + Cutoff after training is complete, hold 1 year, destroy. + + + + + + + cutoff + training_complete + + + + + destroy + year|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + January Cockpit Crew Training + 0950-03-01 + January Cockpit/Crew Training + + + + + February Cockpit Crew Training + 0950-03-02 + February Cockpit/Crew Training + + + + + + + + + + + + + + + Science Advisor Records + 0950-04 + Science Advisor Records + Consisting of: reports, studies, tasking orders, and similar records. Reports are usually informal and unpublished. Records may be generated at all activities + + + + + + + + + N1-218-00-10 item 44 + Cut off on completion of study, hold 5 years, then transfer to Inactive Storage. Transfer to NARA 25 years after cutoff. + + + + + + + cutoff + study_complete + + + + + transfer + Transfer to inactive storage. + Inactive Storage + year|5 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + accession + Transfer to NARA. + NARA + year|25 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + Phoenix Mars Mission + 0950-04-01 + Phoenix Mars Mission + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-capabilities-classification-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-capabilities-classification-context.xml index 04f71c3fa5..38866ec77a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-capabilities-classification-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-capabilities-classification-context.xml @@ -1,82 +1,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-context.xml index 3253405897..5d1b5768c0 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015-context.xml @@ -1,61 +1,61 @@ - - - - - - - - - - alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml - - - - - alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model - - - - - - - - - - - - - - - - - - - - - - alfresco.module.org_alfresco_module_rm.dod5015.messages.dod5015 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml + + + + + alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model + + + + + + + + + + + + + + + + + + + + + + alfresco.module.org_alfresco_module_rm.dod5015.messages.dod5015 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml index 2073d53b71..502f565bf6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/dod5015Model.xml @@ -1,434 +1,434 @@ - - - - - - - - DOD 5015 Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - Image Formats - - - Binary Image Interchange Format (BIIF) - GIF 89a - Graphic Image Format (GIF) 87a - Joint Photographic Experts Group (JPEG) (all versions) - Portable Network Graphics (PNG) 1.0 - Tagged Image Interchange Format (TIFF) 4.0 - TIFF 5.0 - TIFF 6.0 - - - true - - - - - - - - - DOD5015 Site - rma:rmsite - - - - - - DOD5015 File Plan - rma:filePlan - - - - - Record Series - rma:recordCategory - - - - - - - - - - DOD5015 Record - - - - Publication Date - d:date - true - - - - Originator - d:text - true - - true - false - false - - - - - Originating Organization - d:text - true - - true - false - false - - - - - Media Type - d:text - false - - true - false - false - - - - - Format - d:text - false - - true - false - false - - - - - Date Received - d:date - false - - - - - Addressee - d:text - false - - true - false - false - - - - Other Addressee - d:text - false - - true - false - false - - - - - - - - - Scanned Record - - - Image Format - d:text - - true - false - false - - - - Image Format and Version - d:text - true - - true - false - false - - - - - - - Image Resolution X - d:int - true - - - Image Resolution Y - d:int - true - - - Scanned Bit Depth - d:int - false - - - - - - PDF Record - - - Producing Application - d:text - true - - true - false - false - - - - Producing Application Version - d:text - true - - - PDF Version - d:text - true - - true - false - false - - - - Creating Application - d:text - false - - true - false - false - - - - Document Security Settings - d:text - false - - true - false - false - - - - - - - Digital Photograph Record - - - Caption - d:text - true - - - Photographer - d:text - false - - true - false - false - - - - Copyright - d:text - false - - true - false - false - - - - Bit Depth - d:text - false - - true - false - false - - - - Image Size X - d:int - false - - - Image Size Y - d:int - false - - - Image Source - d:text - false - - true - false - false - - - - Compression - d:text - false - - true - false - false - - - - ICC/ICM Profile - d:text - false - - true - false - false - - - - EXIF Information - d:text - false - - true - false - false - - - - - - - Web Record - - - Web File Name - d:text - true - - true - false - false - - - - Web Platform - d:text - true - - true - false - false - - - - Web Site Name - d:text - true - - true - false - false - - - - Web Site URL - d:text - true - - true - false - false - - - - Capture Method - d:text - true - - true - false - false - - - - Capture Date - d:date - true - - - Contact - d:text - true - - true - false - false - - - - Content Management System - d:text - false - - true - false - false - - - - - - - + + + + + + + + DOD 5015 Model + Roy Wetherall + 1.0 + + + + + + + + + + + + + + + + + + + + + + Image Formats + + + Binary Image Interchange Format (BIIF) + GIF 89a + Graphic Image Format (GIF) 87a + Joint Photographic Experts Group (JPEG) (all versions) + Portable Network Graphics (PNG) 1.0 + Tagged Image Interchange Format (TIFF) 4.0 + TIFF 5.0 + TIFF 6.0 + + + true + + + + + + + + + DOD5015 Site + rma:rmsite + + + + + + DOD5015 File Plan + rma:filePlan + + + + + Record Series + rma:recordCategory + + + + + + + + + + DOD5015 Record + + + + Publication Date + d:date + true + + + + Originator + d:text + true + + true + false + false + + + + + Originating Organization + d:text + true + + true + false + false + + + + + Media Type + d:text + false + + true + false + false + + + + + Format + d:text + false + + true + false + false + + + + + Date Received + d:date + false + + + + + Addressee + d:text + false + + true + false + false + + + + Other Addressee + d:text + false + + true + false + false + + + + + + + + + Scanned Record + + + Image Format + d:text + + true + false + false + + + + Image Format and Version + d:text + true + + true + false + false + + + + + + + Image Resolution X + d:int + true + + + Image Resolution Y + d:int + true + + + Scanned Bit Depth + d:int + false + + + + + + PDF Record + + + Producing Application + d:text + true + + true + false + false + + + + Producing Application Version + d:text + true + + + PDF Version + d:text + true + + true + false + false + + + + Creating Application + d:text + false + + true + false + false + + + + Document Security Settings + d:text + false + + true + false + false + + + + + + + Digital Photograph Record + + + Caption + d:text + true + + + Photographer + d:text + false + + true + false + false + + + + Copyright + d:text + false + + true + false + false + + + + Bit Depth + d:text + false + + true + false + false + + + + Image Size X + d:int + false + + + Image Size Y + d:int + false + + + Image Source + d:text + false + + true + false + false + + + + Compression + d:text + false + + true + false + false + + + + ICC/ICM Profile + d:text + false + + true + false + false + + + + EXIF Information + d:text + false + + true + false + false + + + + + + + Web Record + + + Web File Name + d:text + true + + true + false + false + + + + Web Platform + d:text + true + + true + false + false + + + + Web Site Name + d:text + true + + true + false + false + + + + Web Site URL + d:text + true + + true + false + false + + + + Capture Method + d:text + true + + true + false + false + + + + Capture Date + d:date + true + + + Contact + d:text + true + + true + false + false + + + + Content Management System + d:text + false + + true + false + false + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model.properties index 49e1248577..0fa8cbc480 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=DOD5015 Content Model - -dod_dod5015.type.dod_site.title=DOD5015 Site -dod_dod5015.type.dod_site.description=DOD5015 Site - -dod_dod5015.type.dod_filePlan.title=DOD5015 File Plan -dod_dod5015.type.dod_filePlan.description=DOD5015 File Plan - -dod_dod5015.type.dod_recordSeries.title=Record Series (Deprecated) -dod_dod5015.type.dod_recordSeries.description=Record Series (Deprecated) - -dod_dod5015.aspect.dod_dod5015record.title=DOD5015 Record -dod_dod5015.aspect.dod_dod5015record.description=DOD5015 Record -dod_dod5015.property.dod_publicationDate.title=Publication Date -dod_dod5015.property.dod_publicationDate.decription=Publication Date -dod_dod5015.property.dod_originator.title=Originator -dod_dod5015.property.dod_originator.decription=Originator -dod_dod5015.property.dod_originatingOrganization.title=Originating Organization -dod_dod5015.property.dod_originatingOrganization.decription=Originating Organization -dod_dod5015.property.dod_mediaType.title=Media Type -dod_dod5015.property.dod_mediaType.decription=Media Type -dod_dod5015.property.dod_format.title=Format -dod_dod5015.property.dod_format.decription=Format -dod_dod5015.property.dod_dateReceived.title=Date Received -dod_dod5015.property.dod_dateReceived.decription=Date Received -dod_dod5015.property.dod_address.title=Addressee -dod_dod5015.property.dod_address.decription=Addressee -dod_dod5015.property.dod_otherAddress.title=Other Addressee -dod_dod5015.property.dod_otherAddress.decription=Other Addressee - -dod_dod5015.aspect.dod_scannedRecord.title=Scanned Record -dod_dod5015.aspect.dod_scannedRecord.description=Scanned Record -dod_dod5015.property.dod_scannedFormat.title=Image Format -dod_dod5015.property.dod_scannedFormat.description=Image Format -dod_dod5015.property.dod_scannedFormatVersion.title=Image Format and Version -dod_dod5015.property.dod_scannedFormatVersion.description=Image Format and Version -dod_dod5015.property.dod_resolutionX.title=Image Resolution X -dod_dod5015.property.dod_resolutionX.description=Image Resolution X -dod_dod5015.property.dod_resolutionY.title=Image Resolution Y -dod_dod5015.property.dod_resolutionY.description=Image Resolution Y -dod_dod5015.property.dod_scannedBitDepth.title=Scanned Bit Depth -dod_dod5015.property.dod_scannedBitDepth.description=Scanned Bit Depth - -dod_dod5015.aspect.dod_pdfRecord.title=PDF Record -dod_dod5015.aspect.dod_pdfRecord.description=PDF Record -dod_dod5015.property.dod_producingApplication.title=Producing Application -dod_dod5015.property.dod_producingApplication.description=Producing Application -dod_dod5015.property.dod_producingApplicationVersion.title=Producing Application Version -dod_dod5015.property.dod_producingApplicationVersion.description=Producing Application Version -dod_dod5015.property.dod_pdfVersion.title=PDF Version -dod_dod5015.property.dod_pdfVersion.description=PDF Version -dod_dod5015.property.dod_creatingApplication.title=Creating Application -dod_dod5015.property.dod_creatingApplication.description=Creating Application -dod_dod5015.property.dod_documentSecuritySettings.title=Document Security Settings -dod_dod5015.property.dod_documentSecuritySettings.description=Document Security Settings - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Digital Photograph Record -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Digital Photograph Record -dod_dod5015.property.dod_caption.title=Caption -dod_dod5015.property.dod_caption.description=Caption -dod_dod5015.property.dod_photographer.title=Photographer -dod_dod5015.property.dod_photographer.description=Photographer -dod_dod5015.property.dod_copyright.title=Copyright -dod_dod5015.property.dod_copyright.description=Copyright -dod_dod5015.property.dod_bitDepth.title=Bit Depth -dod_dod5015.property.dod_bitDepth.description=Bit Depth -dod_dod5015.property.dod_imageSizeX.title=Image Size X -dod_dod5015.property.dod_imageSizeX.description=Image Size X -dod_dod5015.property.dod_imageSizeY.title=Image Size Y -dod_dod5015.property.dod_imageSizeY.description=Image Size Y -dod_dod5015.property.dod_imageSource.title=Image Source -dod_dod5015.property.dod_imageSource.description=Image Source -dod_dod5015.property.dod_compression.title=Compression -dod_dod5015.property.dod_compression.description=Compression -dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM Profile -dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM Profile -dod_dod5015.property.dod_exifInformation.title=EXIF Information -dod_dod5015.property.dod_exifInformation.description=EXIF Information - -dod_dod5015.aspect.dod_webRecord.title=Web Record -dod_dod5015.aspect.dod_webRecord.description=Web Record -dod_dod5015.property.dod_webFileName.title=Web File Name -dod_dod5015.property.dod_webFileName.description=Web File Name -dod_dod5015.property.dod_webPlatform.title=Web Platform -dod_dod5015.property.dod_webPlatform.description=Web Platform -dod_dod5015.property.dod_webSiteName.title=Web Site Name -dod_dod5015.property.dod_webSiteName.description=Web Site Name -dod_dod5015.property.dod_webSiteURL.title=Web Site URL -dod_dod5015.property.dod_webSiteURL.description=Web Site URL -dod_dod5015.property.dod_captureMethod.title=Capture Method -dod_dod5015.property.dod_captureMethod.description=Capture Method -dod_dod5015.property.dod_captureDate.title=Capture Date -dod_dod5015.property.dod_captureDate.description=Capture Date -dod_dod5015.property.dod_contact.title=Contact -dod_dod5015.property.dod_contact.description=Contact -dod_dod5015.property.dod_contentManagementSystem.title=Content Management System -dod_dod5015.property.dod_contentManagementSystem.description=Content Management System - +dod_dod5015.description=DOD5015 Content Model + +dod_dod5015.type.dod_site.title=DOD5015 Site +dod_dod5015.type.dod_site.description=DOD5015 Site + +dod_dod5015.type.dod_filePlan.title=DOD5015 File Plan +dod_dod5015.type.dod_filePlan.description=DOD5015 File Plan + +dod_dod5015.type.dod_recordSeries.title=Record Series (Deprecated) +dod_dod5015.type.dod_recordSeries.description=Record Series (Deprecated) + +dod_dod5015.aspect.dod_dod5015record.title=DOD5015 Record +dod_dod5015.aspect.dod_dod5015record.description=DOD5015 Record +dod_dod5015.property.dod_publicationDate.title=Publication Date +dod_dod5015.property.dod_publicationDate.decription=Publication Date +dod_dod5015.property.dod_originator.title=Originator +dod_dod5015.property.dod_originator.decription=Originator +dod_dod5015.property.dod_originatingOrganization.title=Originating Organization +dod_dod5015.property.dod_originatingOrganization.decription=Originating Organization +dod_dod5015.property.dod_mediaType.title=Media Type +dod_dod5015.property.dod_mediaType.decription=Media Type +dod_dod5015.property.dod_format.title=Format +dod_dod5015.property.dod_format.decription=Format +dod_dod5015.property.dod_dateReceived.title=Date Received +dod_dod5015.property.dod_dateReceived.decription=Date Received +dod_dod5015.property.dod_address.title=Addressee +dod_dod5015.property.dod_address.decription=Addressee +dod_dod5015.property.dod_otherAddress.title=Other Addressee +dod_dod5015.property.dod_otherAddress.decription=Other Addressee + +dod_dod5015.aspect.dod_scannedRecord.title=Scanned Record +dod_dod5015.aspect.dod_scannedRecord.description=Scanned Record +dod_dod5015.property.dod_scannedFormat.title=Image Format +dod_dod5015.property.dod_scannedFormat.description=Image Format +dod_dod5015.property.dod_scannedFormatVersion.title=Image Format and Version +dod_dod5015.property.dod_scannedFormatVersion.description=Image Format and Version +dod_dod5015.property.dod_resolutionX.title=Image Resolution X +dod_dod5015.property.dod_resolutionX.description=Image Resolution X +dod_dod5015.property.dod_resolutionY.title=Image Resolution Y +dod_dod5015.property.dod_resolutionY.description=Image Resolution Y +dod_dod5015.property.dod_scannedBitDepth.title=Scanned Bit Depth +dod_dod5015.property.dod_scannedBitDepth.description=Scanned Bit Depth + +dod_dod5015.aspect.dod_pdfRecord.title=PDF Record +dod_dod5015.aspect.dod_pdfRecord.description=PDF Record +dod_dod5015.property.dod_producingApplication.title=Producing Application +dod_dod5015.property.dod_producingApplication.description=Producing Application +dod_dod5015.property.dod_producingApplicationVersion.title=Producing Application Version +dod_dod5015.property.dod_producingApplicationVersion.description=Producing Application Version +dod_dod5015.property.dod_pdfVersion.title=PDF Version +dod_dod5015.property.dod_pdfVersion.description=PDF Version +dod_dod5015.property.dod_creatingApplication.title=Creating Application +dod_dod5015.property.dod_creatingApplication.description=Creating Application +dod_dod5015.property.dod_documentSecuritySettings.title=Document Security Settings +dod_dod5015.property.dod_documentSecuritySettings.description=Document Security Settings + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Digital Photograph Record +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Digital Photograph Record +dod_dod5015.property.dod_caption.title=Caption +dod_dod5015.property.dod_caption.description=Caption +dod_dod5015.property.dod_photographer.title=Photographer +dod_dod5015.property.dod_photographer.description=Photographer +dod_dod5015.property.dod_copyright.title=Copyright +dod_dod5015.property.dod_copyright.description=Copyright +dod_dod5015.property.dod_bitDepth.title=Bit Depth +dod_dod5015.property.dod_bitDepth.description=Bit Depth +dod_dod5015.property.dod_imageSizeX.title=Image Size X +dod_dod5015.property.dod_imageSizeX.description=Image Size X +dod_dod5015.property.dod_imageSizeY.title=Image Size Y +dod_dod5015.property.dod_imageSizeY.description=Image Size Y +dod_dod5015.property.dod_imageSource.title=Image Source +dod_dod5015.property.dod_imageSource.description=Image Source +dod_dod5015.property.dod_compression.title=Compression +dod_dod5015.property.dod_compression.description=Compression +dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM Profile +dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM Profile +dod_dod5015.property.dod_exifInformation.title=EXIF Information +dod_dod5015.property.dod_exifInformation.description=EXIF Information + +dod_dod5015.aspect.dod_webRecord.title=Web Record +dod_dod5015.aspect.dod_webRecord.description=Web Record +dod_dod5015.property.dod_webFileName.title=Web File Name +dod_dod5015.property.dod_webFileName.description=Web File Name +dod_dod5015.property.dod_webPlatform.title=Web Platform +dod_dod5015.property.dod_webPlatform.description=Web Platform +dod_dod5015.property.dod_webSiteName.title=Web Site Name +dod_dod5015.property.dod_webSiteName.description=Web Site Name +dod_dod5015.property.dod_webSiteURL.title=Web Site URL +dod_dod5015.property.dod_webSiteURL.description=Web Site URL +dod_dod5015.property.dod_captureMethod.title=Capture Method +dod_dod5015.property.dod_captureMethod.description=Capture Method +dod_dod5015.property.dod_captureDate.title=Capture Date +dod_dod5015.property.dod_captureDate.description=Capture Date +dod_dod5015.property.dod_contact.title=Contact +dod_dod5015.property.dod_contact.description=Contact +dod_dod5015.property.dod_contentManagementSystem.title=Content Management System +dod_dod5015.property.dod_contentManagementSystem.description=Content Management System + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_de.properties index 14df792a4c..1846332772 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_de.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=DOD5015 Content Model - -dod_dod5015.type.dod_site.title=DOD5015 Site -dod_dod5015.type.dod_site.description=DOD5015 Site - -dod_dod5015.type.dod_filePlan.title=DOD5015 Ablageplan -dod_dod5015.type.dod_filePlan.description=DOD5015 Ablageplan - -dod_dod5015.type.dod_recordSeries.title=Record-Serien (abgelehnt) -dod_dod5015.type.dod_recordSeries.description=Record-Serien (abgelehnt) - -dod_dod5015.aspect.dod_dod5015record.title=DOD5015 Record -dod_dod5015.aspect.dod_dod5015record.description=DOD5015 Record -dod_dod5015.property.dod_publicationDate.title=Ver\u00f6ffentlichungsdatum -dod_dod5015.property.dod_publicationDate.decription=Ver\u00f6ffentlichungsdatum -dod_dod5015.property.dod_originator.title=Ersteller -dod_dod5015.property.dod_originator.decription=Ersteller -dod_dod5015.property.dod_originatingOrganization.title=Erstellende Organisation -dod_dod5015.property.dod_originatingOrganization.decription=Erstellende Organisation -dod_dod5015.property.dod_mediaType.title=Medientyp -dod_dod5015.property.dod_mediaType.decription=Medientyp -dod_dod5015.property.dod_format.title=Format -dod_dod5015.property.dod_format.decription=Format -dod_dod5015.property.dod_dateReceived.title=Eingangsdatum -dod_dod5015.property.dod_dateReceived.decription=Eingangsdatum -dod_dod5015.property.dod_address.title=Empf\u00e4nger -dod_dod5015.property.dod_address.decription=Empf\u00e4nger -dod_dod5015.property.dod_otherAddress.title=Anderer Empf\u00e4nger -dod_dod5015.property.dod_otherAddress.decription=Anderer Empf\u00e4nger - -dod_dod5015.aspect.dod_scannedRecord.title=Eingescannter Record -dod_dod5015.aspect.dod_scannedRecord.description=Eingescannter Record -dod_dod5015.property.dod_scannedFormat.title=Bildformat -dod_dod5015.property.dod_scannedFormat.description=Bildformat -dod_dod5015.property.dod_scannedFormatVersion.title=Bildformat und Version -dod_dod5015.property.dod_scannedFormatVersion.description=Bildformat und Version -dod_dod5015.property.dod_resolutionX.title=Bildaufl\u00f6sung X -dod_dod5015.property.dod_resolutionX.description=Bildaufl\u00f6sung X -dod_dod5015.property.dod_resolutionY.title=Bildaufl\u00f6sung Y -dod_dod5015.property.dod_resolutionY.description=Bildaufl\u00f6sung Y -dod_dod5015.property.dod_scannedBitDepth.title=Bittiefe des Scans -dod_dod5015.property.dod_scannedBitDepth.description=Bittiefe des Scans - -dod_dod5015.aspect.dod_pdfRecord.title=PDF-Record -dod_dod5015.aspect.dod_pdfRecord.description=PDF-Record -dod_dod5015.property.dod_producingApplication.title=Quellanwendung -dod_dod5015.property.dod_producingApplication.description=Quellanwendung -dod_dod5015.property.dod_producingApplicationVersion.title=Version der Quellanwendung -dod_dod5015.property.dod_producingApplicationVersion.description=Version der Quellanwendung -dod_dod5015.property.dod_pdfVersion.title=PDF-Version -dod_dod5015.property.dod_pdfVersion.description=PDF-Version -dod_dod5015.property.dod_creatingApplication.title=Quellsystem -dod_dod5015.property.dod_creatingApplication.description=Quellsystem -dod_dod5015.property.dod_documentSecuritySettings.title=Sicherheitseinstellungen des Dokuments -dod_dod5015.property.dod_documentSecuritySettings.description=Sicherheitseinstellungen des Dokuments - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Record - Digitales Bild -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Record - Digitales Bild -dod_dod5015.property.dod_caption.title=Beschriftung -dod_dod5015.property.dod_caption.description=Beschriftung -dod_dod5015.property.dod_photographer.title=Fotograf -dod_dod5015.property.dod_photographer.description=Fotograf -dod_dod5015.property.dod_copyright.title=Copyright -dod_dod5015.property.dod_copyright.description=Copyright -dod_dod5015.property.dod_bitDepth.title=Bittiefe -dod_dod5015.property.dod_bitDepth.description=Bittiefe -dod_dod5015.property.dod_imageSizeX.title=Bildgr\u00f6\u00dfe X -dod_dod5015.property.dod_imageSizeX.description=Bildgr\u00f6\u00dfe X -dod_dod5015.property.dod_imageSizeY.title=Bildgr\u00f6\u00dfe Y -dod_dod5015.property.dod_imageSizeY.description=Bildgr\u00f6\u00dfe Y -dod_dod5015.property.dod_imageSource.title=Bildquelle -dod_dod5015.property.dod_imageSource.description=Bildquelle -dod_dod5015.property.dod_compression.title=Komprimierung -dod_dod5015.property.dod_compression.description=Komprimierung -dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM-Profil -dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM-Profil -dod_dod5015.property.dod_exifInformation.title=EXIF-Informationen -dod_dod5015.property.dod_exifInformation.description=EXIF-Informationen - -dod_dod5015.aspect.dod_webRecord.title=Web-Record -dod_dod5015.aspect.dod_webRecord.description=Web-Record -dod_dod5015.property.dod_webFileName.title=Webdateiname -dod_dod5015.property.dod_webFileName.description=Webdateiname -dod_dod5015.property.dod_webPlatform.title=Webplattform -dod_dod5015.property.dod_webPlatform.description=Webplattform -dod_dod5015.property.dod_webSiteName.title=Website-Name -dod_dod5015.property.dod_webSiteName.description=Website-Name -dod_dod5015.property.dod_webSiteURL.title=Website-URL -dod_dod5015.property.dod_webSiteURL.description=Website-URL -dod_dod5015.property.dod_captureMethod.title=Erfassungsmethode -dod_dod5015.property.dod_captureMethod.description=Erfassungsmethode -dod_dod5015.property.dod_captureDate.title=Erfassungsdatum -dod_dod5015.property.dod_captureDate.description=Erfassungsdatum -dod_dod5015.property.dod_contact.title=Kontakt -dod_dod5015.property.dod_contact.description=Kontakt -dod_dod5015.property.dod_contentManagementSystem.title=Content Management System -dod_dod5015.property.dod_contentManagementSystem.description=Content Management System - +dod_dod5015.description=DOD5015 Content Model + +dod_dod5015.type.dod_site.title=DOD5015 Site +dod_dod5015.type.dod_site.description=DOD5015 Site + +dod_dod5015.type.dod_filePlan.title=DOD5015 Ablageplan +dod_dod5015.type.dod_filePlan.description=DOD5015 Ablageplan + +dod_dod5015.type.dod_recordSeries.title=Record-Serien (abgelehnt) +dod_dod5015.type.dod_recordSeries.description=Record-Serien (abgelehnt) + +dod_dod5015.aspect.dod_dod5015record.title=DOD5015 Record +dod_dod5015.aspect.dod_dod5015record.description=DOD5015 Record +dod_dod5015.property.dod_publicationDate.title=Ver\u00f6ffentlichungsdatum +dod_dod5015.property.dod_publicationDate.decription=Ver\u00f6ffentlichungsdatum +dod_dod5015.property.dod_originator.title=Ersteller +dod_dod5015.property.dod_originator.decription=Ersteller +dod_dod5015.property.dod_originatingOrganization.title=Erstellende Organisation +dod_dod5015.property.dod_originatingOrganization.decription=Erstellende Organisation +dod_dod5015.property.dod_mediaType.title=Medientyp +dod_dod5015.property.dod_mediaType.decription=Medientyp +dod_dod5015.property.dod_format.title=Format +dod_dod5015.property.dod_format.decription=Format +dod_dod5015.property.dod_dateReceived.title=Eingangsdatum +dod_dod5015.property.dod_dateReceived.decription=Eingangsdatum +dod_dod5015.property.dod_address.title=Empf\u00e4nger +dod_dod5015.property.dod_address.decription=Empf\u00e4nger +dod_dod5015.property.dod_otherAddress.title=Anderer Empf\u00e4nger +dod_dod5015.property.dod_otherAddress.decription=Anderer Empf\u00e4nger + +dod_dod5015.aspect.dod_scannedRecord.title=Eingescannter Record +dod_dod5015.aspect.dod_scannedRecord.description=Eingescannter Record +dod_dod5015.property.dod_scannedFormat.title=Bildformat +dod_dod5015.property.dod_scannedFormat.description=Bildformat +dod_dod5015.property.dod_scannedFormatVersion.title=Bildformat und Version +dod_dod5015.property.dod_scannedFormatVersion.description=Bildformat und Version +dod_dod5015.property.dod_resolutionX.title=Bildaufl\u00f6sung X +dod_dod5015.property.dod_resolutionX.description=Bildaufl\u00f6sung X +dod_dod5015.property.dod_resolutionY.title=Bildaufl\u00f6sung Y +dod_dod5015.property.dod_resolutionY.description=Bildaufl\u00f6sung Y +dod_dod5015.property.dod_scannedBitDepth.title=Bittiefe des Scans +dod_dod5015.property.dod_scannedBitDepth.description=Bittiefe des Scans + +dod_dod5015.aspect.dod_pdfRecord.title=PDF-Record +dod_dod5015.aspect.dod_pdfRecord.description=PDF-Record +dod_dod5015.property.dod_producingApplication.title=Quellanwendung +dod_dod5015.property.dod_producingApplication.description=Quellanwendung +dod_dod5015.property.dod_producingApplicationVersion.title=Version der Quellanwendung +dod_dod5015.property.dod_producingApplicationVersion.description=Version der Quellanwendung +dod_dod5015.property.dod_pdfVersion.title=PDF-Version +dod_dod5015.property.dod_pdfVersion.description=PDF-Version +dod_dod5015.property.dod_creatingApplication.title=Quellsystem +dod_dod5015.property.dod_creatingApplication.description=Quellsystem +dod_dod5015.property.dod_documentSecuritySettings.title=Sicherheitseinstellungen des Dokuments +dod_dod5015.property.dod_documentSecuritySettings.description=Sicherheitseinstellungen des Dokuments + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Record - Digitales Bild +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Record - Digitales Bild +dod_dod5015.property.dod_caption.title=Beschriftung +dod_dod5015.property.dod_caption.description=Beschriftung +dod_dod5015.property.dod_photographer.title=Fotograf +dod_dod5015.property.dod_photographer.description=Fotograf +dod_dod5015.property.dod_copyright.title=Copyright +dod_dod5015.property.dod_copyright.description=Copyright +dod_dod5015.property.dod_bitDepth.title=Bittiefe +dod_dod5015.property.dod_bitDepth.description=Bittiefe +dod_dod5015.property.dod_imageSizeX.title=Bildgr\u00f6\u00dfe X +dod_dod5015.property.dod_imageSizeX.description=Bildgr\u00f6\u00dfe X +dod_dod5015.property.dod_imageSizeY.title=Bildgr\u00f6\u00dfe Y +dod_dod5015.property.dod_imageSizeY.description=Bildgr\u00f6\u00dfe Y +dod_dod5015.property.dod_imageSource.title=Bildquelle +dod_dod5015.property.dod_imageSource.description=Bildquelle +dod_dod5015.property.dod_compression.title=Komprimierung +dod_dod5015.property.dod_compression.description=Komprimierung +dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM-Profil +dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM-Profil +dod_dod5015.property.dod_exifInformation.title=EXIF-Informationen +dod_dod5015.property.dod_exifInformation.description=EXIF-Informationen + +dod_dod5015.aspect.dod_webRecord.title=Web-Record +dod_dod5015.aspect.dod_webRecord.description=Web-Record +dod_dod5015.property.dod_webFileName.title=Webdateiname +dod_dod5015.property.dod_webFileName.description=Webdateiname +dod_dod5015.property.dod_webPlatform.title=Webplattform +dod_dod5015.property.dod_webPlatform.description=Webplattform +dod_dod5015.property.dod_webSiteName.title=Website-Name +dod_dod5015.property.dod_webSiteName.description=Website-Name +dod_dod5015.property.dod_webSiteURL.title=Website-URL +dod_dod5015.property.dod_webSiteURL.description=Website-URL +dod_dod5015.property.dod_captureMethod.title=Erfassungsmethode +dod_dod5015.property.dod_captureMethod.description=Erfassungsmethode +dod_dod5015.property.dod_captureDate.title=Erfassungsdatum +dod_dod5015.property.dod_captureDate.description=Erfassungsdatum +dod_dod5015.property.dod_contact.title=Kontakt +dod_dod5015.property.dod_contact.description=Kontakt +dod_dod5015.property.dod_contentManagementSystem.title=Content Management System +dod_dod5015.property.dod_contentManagementSystem.description=Content Management System + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_es.properties index b078119b7f..484926938a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_es.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=Modelo de contenido de DOD5015 - -dod_dod5015.type.dod_site.title=Sitio de DOD5015 -dod_dod5015.type.dod_site.description=Sitio de DOD5015 - -dod_dod5015.type.dod_filePlan.title=Plan de fichero DOD5015 -dod_dod5015.type.dod_filePlan.description=Plan de fichero DOD5015 - -dod_dod5015.type.dod_recordSeries.title=Serie de documentos de archivo (depreciada) -dod_dod5015.type.dod_recordSeries.description=Serie de documentos de archivo (depreciada) - -dod_dod5015.aspect.dod_dod5015record.title=Documento de archivo de DOD5015 -dod_dod5015.aspect.dod_dod5015record.description=Documento de archivo de DOD5015 -dod_dod5015.property.dod_publicationDate.title=Fecha de publicaci\u00f3n -dod_dod5015.property.dod_publicationDate.decription=Fecha de publicaci\u00f3n -dod_dod5015.property.dod_originator.title=Creador -dod_dod5015.property.dod_originator.decription=Creador -dod_dod5015.property.dod_originatingOrganization.title=Organizaci\u00f3n creadora -dod_dod5015.property.dod_originatingOrganization.decription=Organizaci\u00f3n creadora -dod_dod5015.property.dod_mediaType.title=Tipo de medio -dod_dod5015.property.dod_mediaType.decription=Tipo de medio -dod_dod5015.property.dod_format.title=Formato -dod_dod5015.property.dod_format.decription=Formato -dod_dod5015.property.dod_dateReceived.title=Fecha de recepci\u00f3n -dod_dod5015.property.dod_dateReceived.decription=Fecha de recepci\u00f3n -dod_dod5015.property.dod_address.title=Destinatario -dod_dod5015.property.dod_address.decription=Destinatario -dod_dod5015.property.dod_otherAddress.title=Otro destinatario -dod_dod5015.property.dod_otherAddress.decription=Otro destinatario - -dod_dod5015.aspect.dod_scannedRecord.title=Documento de archivo escaneado -dod_dod5015.aspect.dod_scannedRecord.description=Documento de archivo escaneado -dod_dod5015.property.dod_scannedFormat.title=Formato de imagen -dod_dod5015.property.dod_scannedFormat.description=Formato de imagen -dod_dod5015.property.dod_scannedFormatVersion.title=Formato de imagen y versi\u00f3n -dod_dod5015.property.dod_scannedFormatVersion.description=Formato de imagen y versi\u00f3n -dod_dod5015.property.dod_resolutionX.title=Resoluci\u00f3n de imagen X -dod_dod5015.property.dod_resolutionX.description=Resoluci\u00f3n de imagen X -dod_dod5015.property.dod_resolutionY.title=Resoluci\u00f3n de imagen Y -dod_dod5015.property.dod_resolutionY.description=Resoluci\u00f3n de imagen Y -dod_dod5015.property.dod_scannedBitDepth.title=Profundidad de bits de escaneado -dod_dod5015.property.dod_scannedBitDepth.description=Profundidad de bits de escaneado - -dod_dod5015.aspect.dod_pdfRecord.title=Documento de archivo PDF -dod_dod5015.aspect.dod_pdfRecord.description=Documento de archivo PDF -dod_dod5015.property.dod_producingApplication.title=Produciendo aplicaci\u00f3n -dod_dod5015.property.dod_producingApplication.description=Produciendo aplicaci\u00f3n -dod_dod5015.property.dod_producingApplicationVersion.title=Produciendo versi\u00f3n de la aplicaci\u00f3n -dod_dod5015.property.dod_producingApplicationVersion.description=Produciendo versi\u00f3n de la aplicaci\u00f3n -dod_dod5015.property.dod_pdfVersion.title=Versi\u00f3n PDF -dod_dod5015.property.dod_pdfVersion.description=Versi\u00f3n PDF -dod_dod5015.property.dod_creatingApplication.title=Creando aplicaci\u00f3n -dod_dod5015.property.dod_creatingApplication.description=Creando aplicaci\u00f3n -dod_dod5015.property.dod_documentSecuritySettings.title=Configuraci\u00f3n de seguridad del documento -dod_dod5015.property.dod_documentSecuritySettings.description=Configuraci\u00f3n de seguridad del documento - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Documento de archivo fotogr\u00e1fico digital -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Documento de archivo fotogr\u00e1fico digital -dod_dod5015.property.dod_caption.title=T\u00edtulo -dod_dod5015.property.dod_caption.description=T\u00edtulo -dod_dod5015.property.dod_photographer.title=Fot\u00f3grafo -dod_dod5015.property.dod_photographer.description=Fot\u00f3grafo -dod_dod5015.property.dod_copyright.title=Copyright -dod_dod5015.property.dod_copyright.description=Copyright -dod_dod5015.property.dod_bitDepth.title=Profundidad de bits -dod_dod5015.property.dod_bitDepth.description=Profundidad de bits -dod_dod5015.property.dod_imageSizeX.title=Tama\u00f1o de imagen X -dod_dod5015.property.dod_imageSizeX.description=Tama\u00f1o de imagen X -dod_dod5015.property.dod_imageSizeY.title=Tama\u00f1o de imagen Y -dod_dod5015.property.dod_imageSizeY.description=Tama\u00f1o de imagen Y -dod_dod5015.property.dod_imageSource.title=Procedencia de la imagen -dod_dod5015.property.dod_imageSource.description=Procedencia de la imagen -dod_dod5015.property.dod_compression.title=Compresi\u00f3n -dod_dod5015.property.dod_compression.description=Compresi\u00f3n -dod_dod5015.property.dod_iccIcmProfile.title=Perfil ICC/ICM -dod_dod5015.property.dod_iccIcmProfile.description=Perfil ICC/ICM -dod_dod5015.property.dod_exifInformation.title=Informaci\u00f3n EXIF -dod_dod5015.property.dod_exifInformation.description=Informaci\u00f3n EXIF - -dod_dod5015.aspect.dod_webRecord.title=Documento de archivo web -dod_dod5015.aspect.dod_webRecord.description=Documento de archivo web -dod_dod5015.property.dod_webFileName.title=Nombre del fichero web -dod_dod5015.property.dod_webFileName.description=Nombre del fichero web -dod_dod5015.property.dod_webPlatform.title=Plataforma web -dod_dod5015.property.dod_webPlatform.description=Plataforma web -dod_dod5015.property.dod_webSiteName.title=Nombre del sitio web -dod_dod5015.property.dod_webSiteName.description=Nombre del sitio web -dod_dod5015.property.dod_webSiteURL.title=URL del sitio web -dod_dod5015.property.dod_webSiteURL.description=URL del sitio web -dod_dod5015.property.dod_captureMethod.title=M\u00e9todo de captura -dod_dod5015.property.dod_captureMethod.description=M\u00e9todo de captura -dod_dod5015.property.dod_captureDate.title=Fecha de captura -dod_dod5015.property.dod_captureDate.description=Fecha de captura -dod_dod5015.property.dod_contact.title=Contacto -dod_dod5015.property.dod_contact.description=Contacto -dod_dod5015.property.dod_contentManagementSystem.title=Sistema de gesti\u00f3n de contenidos -dod_dod5015.property.dod_contentManagementSystem.description=Sistema de gesti\u00f3n de contenidos - +dod_dod5015.description=Modelo de contenido de DOD5015 + +dod_dod5015.type.dod_site.title=Sitio de DOD5015 +dod_dod5015.type.dod_site.description=Sitio de DOD5015 + +dod_dod5015.type.dod_filePlan.title=Plan de fichero DOD5015 +dod_dod5015.type.dod_filePlan.description=Plan de fichero DOD5015 + +dod_dod5015.type.dod_recordSeries.title=Serie de documentos de archivo (depreciada) +dod_dod5015.type.dod_recordSeries.description=Serie de documentos de archivo (depreciada) + +dod_dod5015.aspect.dod_dod5015record.title=Documento de archivo de DOD5015 +dod_dod5015.aspect.dod_dod5015record.description=Documento de archivo de DOD5015 +dod_dod5015.property.dod_publicationDate.title=Fecha de publicaci\u00f3n +dod_dod5015.property.dod_publicationDate.decription=Fecha de publicaci\u00f3n +dod_dod5015.property.dod_originator.title=Creador +dod_dod5015.property.dod_originator.decription=Creador +dod_dod5015.property.dod_originatingOrganization.title=Organizaci\u00f3n creadora +dod_dod5015.property.dod_originatingOrganization.decription=Organizaci\u00f3n creadora +dod_dod5015.property.dod_mediaType.title=Tipo de medio +dod_dod5015.property.dod_mediaType.decription=Tipo de medio +dod_dod5015.property.dod_format.title=Formato +dod_dod5015.property.dod_format.decription=Formato +dod_dod5015.property.dod_dateReceived.title=Fecha de recepci\u00f3n +dod_dod5015.property.dod_dateReceived.decription=Fecha de recepci\u00f3n +dod_dod5015.property.dod_address.title=Destinatario +dod_dod5015.property.dod_address.decription=Destinatario +dod_dod5015.property.dod_otherAddress.title=Otro destinatario +dod_dod5015.property.dod_otherAddress.decription=Otro destinatario + +dod_dod5015.aspect.dod_scannedRecord.title=Documento de archivo escaneado +dod_dod5015.aspect.dod_scannedRecord.description=Documento de archivo escaneado +dod_dod5015.property.dod_scannedFormat.title=Formato de imagen +dod_dod5015.property.dod_scannedFormat.description=Formato de imagen +dod_dod5015.property.dod_scannedFormatVersion.title=Formato de imagen y versi\u00f3n +dod_dod5015.property.dod_scannedFormatVersion.description=Formato de imagen y versi\u00f3n +dod_dod5015.property.dod_resolutionX.title=Resoluci\u00f3n de imagen X +dod_dod5015.property.dod_resolutionX.description=Resoluci\u00f3n de imagen X +dod_dod5015.property.dod_resolutionY.title=Resoluci\u00f3n de imagen Y +dod_dod5015.property.dod_resolutionY.description=Resoluci\u00f3n de imagen Y +dod_dod5015.property.dod_scannedBitDepth.title=Profundidad de bits de escaneado +dod_dod5015.property.dod_scannedBitDepth.description=Profundidad de bits de escaneado + +dod_dod5015.aspect.dod_pdfRecord.title=Documento de archivo PDF +dod_dod5015.aspect.dod_pdfRecord.description=Documento de archivo PDF +dod_dod5015.property.dod_producingApplication.title=Produciendo aplicaci\u00f3n +dod_dod5015.property.dod_producingApplication.description=Produciendo aplicaci\u00f3n +dod_dod5015.property.dod_producingApplicationVersion.title=Produciendo versi\u00f3n de la aplicaci\u00f3n +dod_dod5015.property.dod_producingApplicationVersion.description=Produciendo versi\u00f3n de la aplicaci\u00f3n +dod_dod5015.property.dod_pdfVersion.title=Versi\u00f3n PDF +dod_dod5015.property.dod_pdfVersion.description=Versi\u00f3n PDF +dod_dod5015.property.dod_creatingApplication.title=Creando aplicaci\u00f3n +dod_dod5015.property.dod_creatingApplication.description=Creando aplicaci\u00f3n +dod_dod5015.property.dod_documentSecuritySettings.title=Configuraci\u00f3n de seguridad del documento +dod_dod5015.property.dod_documentSecuritySettings.description=Configuraci\u00f3n de seguridad del documento + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Documento de archivo fotogr\u00e1fico digital +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Documento de archivo fotogr\u00e1fico digital +dod_dod5015.property.dod_caption.title=T\u00edtulo +dod_dod5015.property.dod_caption.description=T\u00edtulo +dod_dod5015.property.dod_photographer.title=Fot\u00f3grafo +dod_dod5015.property.dod_photographer.description=Fot\u00f3grafo +dod_dod5015.property.dod_copyright.title=Copyright +dod_dod5015.property.dod_copyright.description=Copyright +dod_dod5015.property.dod_bitDepth.title=Profundidad de bits +dod_dod5015.property.dod_bitDepth.description=Profundidad de bits +dod_dod5015.property.dod_imageSizeX.title=Tama\u00f1o de imagen X +dod_dod5015.property.dod_imageSizeX.description=Tama\u00f1o de imagen X +dod_dod5015.property.dod_imageSizeY.title=Tama\u00f1o de imagen Y +dod_dod5015.property.dod_imageSizeY.description=Tama\u00f1o de imagen Y +dod_dod5015.property.dod_imageSource.title=Procedencia de la imagen +dod_dod5015.property.dod_imageSource.description=Procedencia de la imagen +dod_dod5015.property.dod_compression.title=Compresi\u00f3n +dod_dod5015.property.dod_compression.description=Compresi\u00f3n +dod_dod5015.property.dod_iccIcmProfile.title=Perfil ICC/ICM +dod_dod5015.property.dod_iccIcmProfile.description=Perfil ICC/ICM +dod_dod5015.property.dod_exifInformation.title=Informaci\u00f3n EXIF +dod_dod5015.property.dod_exifInformation.description=Informaci\u00f3n EXIF + +dod_dod5015.aspect.dod_webRecord.title=Documento de archivo web +dod_dod5015.aspect.dod_webRecord.description=Documento de archivo web +dod_dod5015.property.dod_webFileName.title=Nombre del fichero web +dod_dod5015.property.dod_webFileName.description=Nombre del fichero web +dod_dod5015.property.dod_webPlatform.title=Plataforma web +dod_dod5015.property.dod_webPlatform.description=Plataforma web +dod_dod5015.property.dod_webSiteName.title=Nombre del sitio web +dod_dod5015.property.dod_webSiteName.description=Nombre del sitio web +dod_dod5015.property.dod_webSiteURL.title=URL del sitio web +dod_dod5015.property.dod_webSiteURL.description=URL del sitio web +dod_dod5015.property.dod_captureMethod.title=M\u00e9todo de captura +dod_dod5015.property.dod_captureMethod.description=M\u00e9todo de captura +dod_dod5015.property.dod_captureDate.title=Fecha de captura +dod_dod5015.property.dod_captureDate.description=Fecha de captura +dod_dod5015.property.dod_contact.title=Contacto +dod_dod5015.property.dod_contact.description=Contacto +dod_dod5015.property.dod_contentManagementSystem.title=Sistema de gesti\u00f3n de contenidos +dod_dod5015.property.dod_contentManagementSystem.description=Sistema de gesti\u00f3n de contenidos + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_fr.properties index b28bfbba96..6c59002dd6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_fr.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=Mod\u00e8le de contenu DOD5015 - -dod_dod5015.type.dod_site.title=Site DOD5015 -dod_dod5015.type.dod_site.description=Site DOD5015 - -dod_dod5015.type.dod_filePlan.title=Plan de classification DOD5015 -dod_dod5015.type.dod_filePlan.description=Plan de classification DOD5015 - -dod_dod5015.type.dod_recordSeries.title=S\u00e9rie de documents d'archives (\u00e0 \u00e9viter) -dod_dod5015.type.dod_recordSeries.description=S\u00e9rie de documents d'archives (\u00e0 \u00e9viter) - -dod_dod5015.aspect.dod_dod5015record.title=Document d'archives DOD5015 -dod_dod5015.aspect.dod_dod5015record.description=Document d'archives DOD5015 -dod_dod5015.property.dod_publicationDate.title=Date de publication -dod_dod5015.property.dod_publicationDate.decription=Date de publication -dod_dod5015.property.dod_originator.title=\u00c9metteur -dod_dod5015.property.dod_originator.decription=\u00c9metteur -dod_dod5015.property.dod_originatingOrganization.title=Organisation \u00e9mettrice -dod_dod5015.property.dod_originatingOrganization.decription=Organisation \u00e9mettrice -dod_dod5015.property.dod_mediaType.title=Type de support -dod_dod5015.property.dod_mediaType.decription=Type de support -dod_dod5015.property.dod_format.title=Format -dod_dod5015.property.dod_format.decription=Format -dod_dod5015.property.dod_dateReceived.title=Date de r\u00e9ception -dod_dod5015.property.dod_dateReceived.decription=Date de r\u00e9ception -dod_dod5015.property.dod_address.title=Destinataire -dod_dod5015.property.dod_address.decription=Destinataire -dod_dod5015.property.dod_otherAddress.title=Autre destinataire -dod_dod5015.property.dod_otherAddress.decription=Autre destinataire - -dod_dod5015.aspect.dod_scannedRecord.title=Document d'archives num\u00e9ris\u00e9 -dod_dod5015.aspect.dod_scannedRecord.description=Document d'archives num\u00e9ris\u00e9 -dod_dod5015.property.dod_scannedFormat.title=Format d'image -dod_dod5015.property.dod_scannedFormat.description=Format d'image -dod_dod5015.property.dod_scannedFormatVersion.title=Format et version d'image -dod_dod5015.property.dod_scannedFormatVersion.description=Format et version d'image -dod_dod5015.property.dod_resolutionX.title=R\u00e9solution d'image X -dod_dod5015.property.dod_resolutionX.description=R\u00e9solution d'image X -dod_dod5015.property.dod_resolutionY.title=R\u00e9solution d'image Y -dod_dod5015.property.dod_resolutionY.description=R\u00e9solution d'image Y -dod_dod5015.property.dod_scannedBitDepth.title=Profondeur de couleur num\u00e9ris\u00e9e -dod_dod5015.property.dod_scannedBitDepth.description=Profondeur de couleur num\u00e9ris\u00e9e - -dod_dod5015.aspect.dod_pdfRecord.title=Document d'archives PDF -dod_dod5015.aspect.dod_pdfRecord.description=Document d'archives PDF -dod_dod5015.property.dod_producingApplication.title=Application native -dod_dod5015.property.dod_producingApplication.description=Application native -dod_dod5015.property.dod_producingApplicationVersion.title=Version de l'application native -dod_dod5015.property.dod_producingApplicationVersion.description=Version de l'application native -dod_dod5015.property.dod_pdfVersion.title=Version PDF -dod_dod5015.property.dod_pdfVersion.description=Version PDF -dod_dod5015.property.dod_creatingApplication.title=Application native -dod_dod5015.property.dod_creatingApplication.description=Application native -dod_dod5015.property.dod_documentSecuritySettings.title=Param\u00e8tres de s\u00e9curit\u00e9 du document -dod_dod5015.property.dod_documentSecuritySettings.description=Param\u00e8tres de s\u00e9curit\u00e9 du document - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Photographie num\u00e9rique d'archives -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Photographie num\u00e9rique d'archives -dod_dod5015.property.dod_caption.title=L\u00e9gende -dod_dod5015.property.dod_caption.description=L\u00e9gende -dod_dod5015.property.dod_photographer.title=Photographe -dod_dod5015.property.dod_photographer.description=Photographe -dod_dod5015.property.dod_copyright.title=Copyright -dod_dod5015.property.dod_copyright.description=Copyright -dod_dod5015.property.dod_bitDepth.title=Profondeur de couleur -dod_dod5015.property.dod_bitDepth.description=Profondeur de couleur -dod_dod5015.property.dod_imageSizeX.title=Taille d'image X -dod_dod5015.property.dod_imageSizeX.description=Taille d'image X -dod_dod5015.property.dod_imageSizeY.title=Taille d'image Y -dod_dod5015.property.dod_imageSizeY.description=Taille d'image Y -dod_dod5015.property.dod_imageSource.title=Source de l'image -dod_dod5015.property.dod_imageSource.description=Source de l'image -dod_dod5015.property.dod_compression.title=Compression -dod_dod5015.property.dod_compression.description=Compression -dod_dod5015.property.dod_iccIcmProfile.title=Profil ICC/ICM -dod_dod5015.property.dod_iccIcmProfile.description=Profil ICC/ICM -dod_dod5015.property.dod_exifInformation.title=Informations EXIF -dod_dod5015.property.dod_exifInformation.description=Informations EXIF - -dod_dod5015.aspect.dod_webRecord.title=Document d'archives Web -dod_dod5015.aspect.dod_webRecord.description=Document d'archives Web -dod_dod5015.property.dod_webFileName.title=Nom de fichier Web -dod_dod5015.property.dod_webFileName.description=Nom de fichier Web -dod_dod5015.property.dod_webPlatform.title=Plate-forme Web -dod_dod5015.property.dod_webPlatform.description=Plate-forme Web -dod_dod5015.property.dod_webSiteName.title=Nom du site Web -dod_dod5015.property.dod_webSiteName.description=Nom du site Web -dod_dod5015.property.dod_webSiteURL.title=URL de site Web -dod_dod5015.property.dod_webSiteURL.description=URL de site Web -dod_dod5015.property.dod_captureMethod.title=M\u00e9thode de capture -dod_dod5015.property.dod_captureMethod.description=M\u00e9thode de capture -dod_dod5015.property.dod_captureDate.title=Date de capture -dod_dod5015.property.dod_captureDate.description=Date de capture -dod_dod5015.property.dod_contact.title=Contact -dod_dod5015.property.dod_contact.description=Contact -dod_dod5015.property.dod_contentManagementSystem.title=Syst\u00e8me de gestion de contenu -dod_dod5015.property.dod_contentManagementSystem.description=Syst\u00e8me de gestion de contenu - +dod_dod5015.description=Mod\u00e8le de contenu DOD5015 + +dod_dod5015.type.dod_site.title=Site DOD5015 +dod_dod5015.type.dod_site.description=Site DOD5015 + +dod_dod5015.type.dod_filePlan.title=Plan de classification DOD5015 +dod_dod5015.type.dod_filePlan.description=Plan de classification DOD5015 + +dod_dod5015.type.dod_recordSeries.title=S\u00e9rie de documents d'archives (\u00e0 \u00e9viter) +dod_dod5015.type.dod_recordSeries.description=S\u00e9rie de documents d'archives (\u00e0 \u00e9viter) + +dod_dod5015.aspect.dod_dod5015record.title=Document d'archives DOD5015 +dod_dod5015.aspect.dod_dod5015record.description=Document d'archives DOD5015 +dod_dod5015.property.dod_publicationDate.title=Date de publication +dod_dod5015.property.dod_publicationDate.decription=Date de publication +dod_dod5015.property.dod_originator.title=\u00c9metteur +dod_dod5015.property.dod_originator.decription=\u00c9metteur +dod_dod5015.property.dod_originatingOrganization.title=Organisation \u00e9mettrice +dod_dod5015.property.dod_originatingOrganization.decription=Organisation \u00e9mettrice +dod_dod5015.property.dod_mediaType.title=Type de support +dod_dod5015.property.dod_mediaType.decription=Type de support +dod_dod5015.property.dod_format.title=Format +dod_dod5015.property.dod_format.decription=Format +dod_dod5015.property.dod_dateReceived.title=Date de r\u00e9ception +dod_dod5015.property.dod_dateReceived.decription=Date de r\u00e9ception +dod_dod5015.property.dod_address.title=Destinataire +dod_dod5015.property.dod_address.decription=Destinataire +dod_dod5015.property.dod_otherAddress.title=Autre destinataire +dod_dod5015.property.dod_otherAddress.decription=Autre destinataire + +dod_dod5015.aspect.dod_scannedRecord.title=Document d'archives num\u00e9ris\u00e9 +dod_dod5015.aspect.dod_scannedRecord.description=Document d'archives num\u00e9ris\u00e9 +dod_dod5015.property.dod_scannedFormat.title=Format d'image +dod_dod5015.property.dod_scannedFormat.description=Format d'image +dod_dod5015.property.dod_scannedFormatVersion.title=Format et version d'image +dod_dod5015.property.dod_scannedFormatVersion.description=Format et version d'image +dod_dod5015.property.dod_resolutionX.title=R\u00e9solution d'image X +dod_dod5015.property.dod_resolutionX.description=R\u00e9solution d'image X +dod_dod5015.property.dod_resolutionY.title=R\u00e9solution d'image Y +dod_dod5015.property.dod_resolutionY.description=R\u00e9solution d'image Y +dod_dod5015.property.dod_scannedBitDepth.title=Profondeur de couleur num\u00e9ris\u00e9e +dod_dod5015.property.dod_scannedBitDepth.description=Profondeur de couleur num\u00e9ris\u00e9e + +dod_dod5015.aspect.dod_pdfRecord.title=Document d'archives PDF +dod_dod5015.aspect.dod_pdfRecord.description=Document d'archives PDF +dod_dod5015.property.dod_producingApplication.title=Application native +dod_dod5015.property.dod_producingApplication.description=Application native +dod_dod5015.property.dod_producingApplicationVersion.title=Version de l'application native +dod_dod5015.property.dod_producingApplicationVersion.description=Version de l'application native +dod_dod5015.property.dod_pdfVersion.title=Version PDF +dod_dod5015.property.dod_pdfVersion.description=Version PDF +dod_dod5015.property.dod_creatingApplication.title=Application native +dod_dod5015.property.dod_creatingApplication.description=Application native +dod_dod5015.property.dod_documentSecuritySettings.title=Param\u00e8tres de s\u00e9curit\u00e9 du document +dod_dod5015.property.dod_documentSecuritySettings.description=Param\u00e8tres de s\u00e9curit\u00e9 du document + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Photographie num\u00e9rique d'archives +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Photographie num\u00e9rique d'archives +dod_dod5015.property.dod_caption.title=L\u00e9gende +dod_dod5015.property.dod_caption.description=L\u00e9gende +dod_dod5015.property.dod_photographer.title=Photographe +dod_dod5015.property.dod_photographer.description=Photographe +dod_dod5015.property.dod_copyright.title=Copyright +dod_dod5015.property.dod_copyright.description=Copyright +dod_dod5015.property.dod_bitDepth.title=Profondeur de couleur +dod_dod5015.property.dod_bitDepth.description=Profondeur de couleur +dod_dod5015.property.dod_imageSizeX.title=Taille d'image X +dod_dod5015.property.dod_imageSizeX.description=Taille d'image X +dod_dod5015.property.dod_imageSizeY.title=Taille d'image Y +dod_dod5015.property.dod_imageSizeY.description=Taille d'image Y +dod_dod5015.property.dod_imageSource.title=Source de l'image +dod_dod5015.property.dod_imageSource.description=Source de l'image +dod_dod5015.property.dod_compression.title=Compression +dod_dod5015.property.dod_compression.description=Compression +dod_dod5015.property.dod_iccIcmProfile.title=Profil ICC/ICM +dod_dod5015.property.dod_iccIcmProfile.description=Profil ICC/ICM +dod_dod5015.property.dod_exifInformation.title=Informations EXIF +dod_dod5015.property.dod_exifInformation.description=Informations EXIF + +dod_dod5015.aspect.dod_webRecord.title=Document d'archives Web +dod_dod5015.aspect.dod_webRecord.description=Document d'archives Web +dod_dod5015.property.dod_webFileName.title=Nom de fichier Web +dod_dod5015.property.dod_webFileName.description=Nom de fichier Web +dod_dod5015.property.dod_webPlatform.title=Plate-forme Web +dod_dod5015.property.dod_webPlatform.description=Plate-forme Web +dod_dod5015.property.dod_webSiteName.title=Nom du site Web +dod_dod5015.property.dod_webSiteName.description=Nom du site Web +dod_dod5015.property.dod_webSiteURL.title=URL de site Web +dod_dod5015.property.dod_webSiteURL.description=URL de site Web +dod_dod5015.property.dod_captureMethod.title=M\u00e9thode de capture +dod_dod5015.property.dod_captureMethod.description=M\u00e9thode de capture +dod_dod5015.property.dod_captureDate.title=Date de capture +dod_dod5015.property.dod_captureDate.description=Date de capture +dod_dod5015.property.dod_contact.title=Contact +dod_dod5015.property.dod_contact.description=Contact +dod_dod5015.property.dod_contentManagementSystem.title=Syst\u00e8me de gestion de contenu +dod_dod5015.property.dod_contentManagementSystem.description=Syst\u00e8me de gestion de contenu + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_it.properties index f1960efdea..d3aec57ae7 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_it.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=Modello dei contenuti DOD5015 - -dod_dod5015.type.dod_site.title=Sito DOD5015 -dod_dod5015.type.dod_site.description=Sito DOD5015 - -dod_dod5015.type.dod_filePlan.title=Piano file DOD5015 -dod_dod5015.type.dod_filePlan.description=Piano file DOD5015 - -dod_dod5015.type.dod_recordSeries.title=Serie record (obsoleta) -dod_dod5015.type.dod_recordSeries.description=Serie record (obsoleta) - -dod_dod5015.aspect.dod_dod5015record.title=Record DOD5015 -dod_dod5015.aspect.dod_dod5015record.description=Record DOD5015 -dod_dod5015.property.dod_publicationDate.title=Data di pubblicazione -dod_dod5015.property.dod_publicationDate.decription=Data di pubblicazione -dod_dod5015.property.dod_originator.title=Iniziatore -dod_dod5015.property.dod_originator.decription=Iniziatore -dod_dod5015.property.dod_originatingOrganization.title=Organizzazione di origine -dod_dod5015.property.dod_originatingOrganization.decription=Organizzazione di origine -dod_dod5015.property.dod_mediaType.title=Tipo di supporto -dod_dod5015.property.dod_mediaType.decription=Tipo di supporto -dod_dod5015.property.dod_format.title=Formato -dod_dod5015.property.dod_format.decription=Formato -dod_dod5015.property.dod_dateReceived.title=Data di ricezione -dod_dod5015.property.dod_dateReceived.decription=Data di ricezione -dod_dod5015.property.dod_address.title=Destinatario -dod_dod5015.property.dod_address.decription=Destinatario -dod_dod5015.property.dod_otherAddress.title=Altro destinatario -dod_dod5015.property.dod_otherAddress.decription=Altro destinatario - -dod_dod5015.aspect.dod_scannedRecord.title=Record scansionato -dod_dod5015.aspect.dod_scannedRecord.description=Record scansionato -dod_dod5015.property.dod_scannedFormat.title=Formato immagine -dod_dod5015.property.dod_scannedFormat.description=Formato immagine -dod_dod5015.property.dod_scannedFormatVersion.title=Formato immagine e versione -dod_dod5015.property.dod_scannedFormatVersion.description=Formato immagine e versione -dod_dod5015.property.dod_resolutionX.title=Risoluzione immagine X -dod_dod5015.property.dod_resolutionX.description=Risoluzione immagine X -dod_dod5015.property.dod_resolutionY.title=Risoluzione immagine Y -dod_dod5015.property.dod_resolutionY.description=Risoluzione immagine Y -dod_dod5015.property.dod_scannedBitDepth.title=Profondit\u00e0 in bit scansionata -dod_dod5015.property.dod_scannedBitDepth.description=Profondit\u00e0 in bit scansionata - -dod_dod5015.aspect.dod_pdfRecord.title=Record PDF -dod_dod5015.aspect.dod_pdfRecord.description=Record PDF -dod_dod5015.property.dod_producingApplication.title=Generazione applicazione -dod_dod5015.property.dod_producingApplication.description=Generazione applicazione -dod_dod5015.property.dod_producingApplicationVersion.title=Generazione versione applicazione -dod_dod5015.property.dod_producingApplicationVersion.description=Generazione versione applicazione -dod_dod5015.property.dod_pdfVersion.title=Versione PDF -dod_dod5015.property.dod_pdfVersion.description=Versione PDF -dod_dod5015.property.dod_creatingApplication.title=Creazione applicazione -dod_dod5015.property.dod_creatingApplication.description=Creazione applicazione -dod_dod5015.property.dod_documentSecuritySettings.title=Impostazioni di protezione documento -dod_dod5015.property.dod_documentSecuritySettings.description=Impostazioni di protezione documento - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Record fotografia digitale -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Record fotografia digitale -dod_dod5015.property.dod_caption.title=Didascalia -dod_dod5015.property.dod_caption.description=Didascalia -dod_dod5015.property.dod_photographer.title=Fotografo -dod_dod5015.property.dod_photographer.description=Fotografo -dod_dod5015.property.dod_copyright.title=Copyright -dod_dod5015.property.dod_copyright.description=Copyright -dod_dod5015.property.dod_bitDepth.title=Profondit\u00e0 in bit -dod_dod5015.property.dod_bitDepth.description=Profondit\u00e0 in bit -dod_dod5015.property.dod_imageSizeX.title=Dimensioni immagine X -dod_dod5015.property.dod_imageSizeX.description=Dimensioni immagine X -dod_dod5015.property.dod_imageSizeY.title=Dimensioni immagine Y -dod_dod5015.property.dod_imageSizeY.description=Dimensioni immagine Y -dod_dod5015.property.dod_imageSource.title=Origine immagine -dod_dod5015.property.dod_imageSource.description=Origine immagine -dod_dod5015.property.dod_compression.title=Compressione -dod_dod5015.property.dod_compression.description=Compressione -dod_dod5015.property.dod_iccIcmProfile.title=Profilo ICC/ICM -dod_dod5015.property.dod_iccIcmProfile.description=Profilo ICC/ICM -dod_dod5015.property.dod_exifInformation.title=Informazioni EXIF -dod_dod5015.property.dod_exifInformation.description=Informazioni EXIF - -dod_dod5015.aspect.dod_webRecord.title=Record Web -dod_dod5015.aspect.dod_webRecord.description=Record Web -dod_dod5015.property.dod_webFileName.title=Nome file Web -dod_dod5015.property.dod_webFileName.description=Nome file Web -dod_dod5015.property.dod_webPlatform.title=Piattaforma Web -dod_dod5015.property.dod_webPlatform.description=Piattaforma Web -dod_dod5015.property.dod_webSiteName.title=Nome sito Web -dod_dod5015.property.dod_webSiteName.description=Nome sito Web -dod_dod5015.property.dod_webSiteURL.title=URL sito Web -dod_dod5015.property.dod_webSiteURL.description=URL sito Web -dod_dod5015.property.dod_captureMethod.title=Metodo di acquisizione -dod_dod5015.property.dod_captureMethod.description=Metodo di acquisizione -dod_dod5015.property.dod_captureDate.title=Data di acquisizione -dod_dod5015.property.dod_captureDate.description=Data di acquisizione -dod_dod5015.property.dod_contact.title=Contatto -dod_dod5015.property.dod_contact.description=Contatto -dod_dod5015.property.dod_contentManagementSystem.title=Sistema di gestione dei contenuti -dod_dod5015.property.dod_contentManagementSystem.description=Sistema di gestione dei contenuti - +dod_dod5015.description=Modello dei contenuti DOD5015 + +dod_dod5015.type.dod_site.title=Sito DOD5015 +dod_dod5015.type.dod_site.description=Sito DOD5015 + +dod_dod5015.type.dod_filePlan.title=Piano file DOD5015 +dod_dod5015.type.dod_filePlan.description=Piano file DOD5015 + +dod_dod5015.type.dod_recordSeries.title=Serie record (obsoleta) +dod_dod5015.type.dod_recordSeries.description=Serie record (obsoleta) + +dod_dod5015.aspect.dod_dod5015record.title=Record DOD5015 +dod_dod5015.aspect.dod_dod5015record.description=Record DOD5015 +dod_dod5015.property.dod_publicationDate.title=Data di pubblicazione +dod_dod5015.property.dod_publicationDate.decription=Data di pubblicazione +dod_dod5015.property.dod_originator.title=Iniziatore +dod_dod5015.property.dod_originator.decription=Iniziatore +dod_dod5015.property.dod_originatingOrganization.title=Organizzazione di origine +dod_dod5015.property.dod_originatingOrganization.decription=Organizzazione di origine +dod_dod5015.property.dod_mediaType.title=Tipo di supporto +dod_dod5015.property.dod_mediaType.decription=Tipo di supporto +dod_dod5015.property.dod_format.title=Formato +dod_dod5015.property.dod_format.decription=Formato +dod_dod5015.property.dod_dateReceived.title=Data di ricezione +dod_dod5015.property.dod_dateReceived.decription=Data di ricezione +dod_dod5015.property.dod_address.title=Destinatario +dod_dod5015.property.dod_address.decription=Destinatario +dod_dod5015.property.dod_otherAddress.title=Altro destinatario +dod_dod5015.property.dod_otherAddress.decription=Altro destinatario + +dod_dod5015.aspect.dod_scannedRecord.title=Record scansionato +dod_dod5015.aspect.dod_scannedRecord.description=Record scansionato +dod_dod5015.property.dod_scannedFormat.title=Formato immagine +dod_dod5015.property.dod_scannedFormat.description=Formato immagine +dod_dod5015.property.dod_scannedFormatVersion.title=Formato immagine e versione +dod_dod5015.property.dod_scannedFormatVersion.description=Formato immagine e versione +dod_dod5015.property.dod_resolutionX.title=Risoluzione immagine X +dod_dod5015.property.dod_resolutionX.description=Risoluzione immagine X +dod_dod5015.property.dod_resolutionY.title=Risoluzione immagine Y +dod_dod5015.property.dod_resolutionY.description=Risoluzione immagine Y +dod_dod5015.property.dod_scannedBitDepth.title=Profondit\u00e0 in bit scansionata +dod_dod5015.property.dod_scannedBitDepth.description=Profondit\u00e0 in bit scansionata + +dod_dod5015.aspect.dod_pdfRecord.title=Record PDF +dod_dod5015.aspect.dod_pdfRecord.description=Record PDF +dod_dod5015.property.dod_producingApplication.title=Generazione applicazione +dod_dod5015.property.dod_producingApplication.description=Generazione applicazione +dod_dod5015.property.dod_producingApplicationVersion.title=Generazione versione applicazione +dod_dod5015.property.dod_producingApplicationVersion.description=Generazione versione applicazione +dod_dod5015.property.dod_pdfVersion.title=Versione PDF +dod_dod5015.property.dod_pdfVersion.description=Versione PDF +dod_dod5015.property.dod_creatingApplication.title=Creazione applicazione +dod_dod5015.property.dod_creatingApplication.description=Creazione applicazione +dod_dod5015.property.dod_documentSecuritySettings.title=Impostazioni di protezione documento +dod_dod5015.property.dod_documentSecuritySettings.description=Impostazioni di protezione documento + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Record fotografia digitale +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Record fotografia digitale +dod_dod5015.property.dod_caption.title=Didascalia +dod_dod5015.property.dod_caption.description=Didascalia +dod_dod5015.property.dod_photographer.title=Fotografo +dod_dod5015.property.dod_photographer.description=Fotografo +dod_dod5015.property.dod_copyright.title=Copyright +dod_dod5015.property.dod_copyright.description=Copyright +dod_dod5015.property.dod_bitDepth.title=Profondit\u00e0 in bit +dod_dod5015.property.dod_bitDepth.description=Profondit\u00e0 in bit +dod_dod5015.property.dod_imageSizeX.title=Dimensioni immagine X +dod_dod5015.property.dod_imageSizeX.description=Dimensioni immagine X +dod_dod5015.property.dod_imageSizeY.title=Dimensioni immagine Y +dod_dod5015.property.dod_imageSizeY.description=Dimensioni immagine Y +dod_dod5015.property.dod_imageSource.title=Origine immagine +dod_dod5015.property.dod_imageSource.description=Origine immagine +dod_dod5015.property.dod_compression.title=Compressione +dod_dod5015.property.dod_compression.description=Compressione +dod_dod5015.property.dod_iccIcmProfile.title=Profilo ICC/ICM +dod_dod5015.property.dod_iccIcmProfile.description=Profilo ICC/ICM +dod_dod5015.property.dod_exifInformation.title=Informazioni EXIF +dod_dod5015.property.dod_exifInformation.description=Informazioni EXIF + +dod_dod5015.aspect.dod_webRecord.title=Record Web +dod_dod5015.aspect.dod_webRecord.description=Record Web +dod_dod5015.property.dod_webFileName.title=Nome file Web +dod_dod5015.property.dod_webFileName.description=Nome file Web +dod_dod5015.property.dod_webPlatform.title=Piattaforma Web +dod_dod5015.property.dod_webPlatform.description=Piattaforma Web +dod_dod5015.property.dod_webSiteName.title=Nome sito Web +dod_dod5015.property.dod_webSiteName.description=Nome sito Web +dod_dod5015.property.dod_webSiteURL.title=URL sito Web +dod_dod5015.property.dod_webSiteURL.description=URL sito Web +dod_dod5015.property.dod_captureMethod.title=Metodo di acquisizione +dod_dod5015.property.dod_captureMethod.description=Metodo di acquisizione +dod_dod5015.property.dod_captureDate.title=Data di acquisizione +dod_dod5015.property.dod_captureDate.description=Data di acquisizione +dod_dod5015.property.dod_contact.title=Contatto +dod_dod5015.property.dod_contact.description=Contatto +dod_dod5015.property.dod_contentManagementSystem.title=Sistema di gestione dei contenuti +dod_dod5015.property.dod_contentManagementSystem.description=Sistema di gestione dei contenuti + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_ja.properties index 9878f560cc..b3e892dda5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_ja.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=DOD5015\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb - -dod_dod5015.type.dod_site.title=DOD5015\u30b5\u30a4\u30c8 -dod_dod5015.type.dod_site.description=DOD5015\u30b5\u30a4\u30c8 - -dod_dod5015.type.dod_filePlan.title=DOD5015\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 -dod_dod5015.type.dod_filePlan.description=DOD5015\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 - -dod_dod5015.type.dod_recordSeries.title=\u30ec\u30b3\u30fc\u30c9\u30b7\u30ea\u30fc\u30ba\uff08\u975e\u63a8\u5968\uff09 -dod_dod5015.type.dod_recordSeries.description=\u30ec\u30b3\u30fc\u30c9\u30b7\u30ea\u30fc\u30ba\uff08\u975e\u63a8\u5968\uff09 - -dod_dod5015.aspect.dod_dod5015record.title=DOD5015\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.aspect.dod_dod5015record.description=DOD5015\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.property.dod_publicationDate.title=\u767a\u884c\u65e5 -dod_dod5015.property.dod_publicationDate.decription=\u767a\u884c\u65e5 -dod_dod5015.property.dod_originator.title=\u767a\u4fe1\u5143 -dod_dod5015.property.dod_originator.decription=\u767a\u4fe1\u5143 -dod_dod5015.property.dod_originatingOrganization.title=\u767a\u4fe1\u5143\u7d44\u7e54 -dod_dod5015.property.dod_originatingOrganization.decription=\u767a\u4fe1\u5143\u7d44\u7e54 -dod_dod5015.property.dod_mediaType.title=\u30e1\u30c7\u30a3\u30a2\u30bf\u30a4\u30d7 -dod_dod5015.property.dod_mediaType.decription=\u30e1\u30c7\u30a3\u30a2\u30bf\u30a4\u30d7 -dod_dod5015.property.dod_format.title=\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 -dod_dod5015.property.dod_format.decription=\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 -dod_dod5015.property.dod_dateReceived.title=\u53d7\u4fe1\u65e5 -dod_dod5015.property.dod_dateReceived.decription=\u53d7\u4fe1\u65e5 -dod_dod5015.property.dod_address.title=\u53d7\u4fe1\u8005 -dod_dod5015.property.dod_address.decription=\u53d7\u4fe1\u8005 -dod_dod5015.property.dod_otherAddress.title=\u305d\u306e\u4ed6\u306e\u53d7\u4fe1\u8005 -dod_dod5015.property.dod_otherAddress.decription=\u305d\u306e\u4ed6\u306e\u53d7\u4fe1\u8005 - -dod_dod5015.aspect.dod_scannedRecord.title=\u30b9\u30ad\u30e3\u30f3\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.aspect.dod_scannedRecord.description=\u30b9\u30ad\u30e3\u30f3\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.property.dod_scannedFormat.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 -dod_dod5015.property.dod_scannedFormat.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 -dod_dod5015.property.dod_scannedFormatVersion.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_scannedFormatVersion.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_resolutionX.title=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6X -dod_dod5015.property.dod_resolutionX.description=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6X -dod_dod5015.property.dod_resolutionY.title=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6Y -dod_dod5015.property.dod_resolutionY.description=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6Y -dod_dod5015.property.dod_scannedBitDepth.title=\u30b9\u30ad\u30e3\u30f3\u3057\u305f\u30d3\u30c3\u30c8\u6df1\u5ea6 -dod_dod5015.property.dod_scannedBitDepth.description=\u30b9\u30ad\u30e3\u30f3\u3057\u305f\u30d3\u30c3\u30c8\u6df1\u5ea6 - -dod_dod5015.aspect.dod_pdfRecord.title=PDF\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.aspect.dod_pdfRecord.description=PDF\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.property.dod_producingApplication.title=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_producingApplication.description=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_producingApplicationVersion.title=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_producingApplicationVersion.description=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_pdfVersion.title=PDF\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_pdfVersion.description=PDF\u30d0\u30fc\u30b8\u30e7\u30f3 -dod_dod5015.property.dod_creatingApplication.title=\u4f5c\u6210\u5143\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_creatingApplication.description=\u4f5c\u6210\u5143\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_documentSecuritySettings.title=\u6587\u66f8\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a -dod_dod5015.property.dod_documentSecuritySettings.description=\u6587\u66f8\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=\u30c7\u30b8\u30bf\u30eb\u5199\u771f\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.aspect.dod_digitalPhotographRecord.description=\u30c7\u30b8\u30bf\u30eb\u5199\u771f\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.property.dod_caption.title=\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_caption.description=\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3 -dod_dod5015.property.dod_photographer.title=\u5199\u771f\u5bb6 -dod_dod5015.property.dod_photographer.description=\u5199\u771f\u5bb6 -dod_dod5015.property.dod_copyright.title=\u8457\u4f5c\u6a29 -dod_dod5015.property.dod_copyright.description=\u8457\u4f5c\u6a29 -dod_dod5015.property.dod_bitDepth.title=\u30d3\u30c3\u30c8\u6df1\u5ea6 -dod_dod5015.property.dod_bitDepth.description=\u30d3\u30c3\u30c8\u6df1\u5ea6 -dod_dod5015.property.dod_imageSizeX.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baX -dod_dod5015.property.dod_imageSizeX.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baX -dod_dod5015.property.dod_imageSizeY.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baY -dod_dod5015.property.dod_imageSizeY.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baY -dod_dod5015.property.dod_imageSource.title=\u30a4\u30e1\u30fc\u30b8\u30bd\u30fc\u30b9 -dod_dod5015.property.dod_imageSource.description=\u30a4\u30e1\u30fc\u30b8\u30bd\u30fc\u30b9 -dod_dod5015.property.dod_compression.title=\u5727\u7e2e -dod_dod5015.property.dod_compression.description=\u5727\u7e2e -dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb -dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb -dod_dod5015.property.dod_exifInformation.title=EXIF\u60c5\u5831 -dod_dod5015.property.dod_exifInformation.description=EXIF\u60c5\u5831 - -dod_dod5015.aspect.dod_webRecord.title=Web\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.aspect.dod_webRecord.description=Web\u30ec\u30b3\u30fc\u30c9 -dod_dod5015.property.dod_webFileName.title=Web\u30d5\u30a1\u30a4\u30eb\u540d -dod_dod5015.property.dod_webFileName.description=Web\u30d5\u30a1\u30a4\u30eb\u540d -dod_dod5015.property.dod_webPlatform.title=Web\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0 -dod_dod5015.property.dod_webPlatform.description=Web\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0 -dod_dod5015.property.dod_webSiteName.title=Web\u30b5\u30a4\u30c8\u540d -dod_dod5015.property.dod_webSiteName.description=Web\u30b5\u30a4\u30c8\u540d -dod_dod5015.property.dod_webSiteURL.title=Web\u30b5\u30a4\u30c8URL -dod_dod5015.property.dod_webSiteURL.description=Web\u30b5\u30a4\u30c8URL -dod_dod5015.property.dod_captureMethod.title=\u30ad\u30e3\u30d7\u30c1\u30e3\u624b\u6cd5 -dod_dod5015.property.dod_captureMethod.description=\u30ad\u30e3\u30d7\u30c1\u30e3\u624b\u6cd5 -dod_dod5015.property.dod_captureDate.title=\u30ad\u30e3\u30d7\u30c1\u30e3\u65e5 -dod_dod5015.property.dod_captureDate.description=\u30ad\u30e3\u30d7\u30c1\u30e3\u65e5 -dod_dod5015.property.dod_contact.title=\u9023\u7d61\u5148 -dod_dod5015.property.dod_contact.description=\u9023\u7d61\u5148 -dod_dod5015.property.dod_contentManagementSystem.title=\u30b3\u30f3\u30c6\u30f3\u30c4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0 -dod_dod5015.property.dod_contentManagementSystem.description=\u30b3\u30f3\u30c6\u30f3\u30c4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0 - +dod_dod5015.description=DOD5015\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb + +dod_dod5015.type.dod_site.title=DOD5015\u30b5\u30a4\u30c8 +dod_dod5015.type.dod_site.description=DOD5015\u30b5\u30a4\u30c8 + +dod_dod5015.type.dod_filePlan.title=DOD5015\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 +dod_dod5015.type.dod_filePlan.description=DOD5015\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 + +dod_dod5015.type.dod_recordSeries.title=\u30ec\u30b3\u30fc\u30c9\u30b7\u30ea\u30fc\u30ba\uff08\u975e\u63a8\u5968\uff09 +dod_dod5015.type.dod_recordSeries.description=\u30ec\u30b3\u30fc\u30c9\u30b7\u30ea\u30fc\u30ba\uff08\u975e\u63a8\u5968\uff09 + +dod_dod5015.aspect.dod_dod5015record.title=DOD5015\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.aspect.dod_dod5015record.description=DOD5015\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.property.dod_publicationDate.title=\u767a\u884c\u65e5 +dod_dod5015.property.dod_publicationDate.decription=\u767a\u884c\u65e5 +dod_dod5015.property.dod_originator.title=\u767a\u4fe1\u5143 +dod_dod5015.property.dod_originator.decription=\u767a\u4fe1\u5143 +dod_dod5015.property.dod_originatingOrganization.title=\u767a\u4fe1\u5143\u7d44\u7e54 +dod_dod5015.property.dod_originatingOrganization.decription=\u767a\u4fe1\u5143\u7d44\u7e54 +dod_dod5015.property.dod_mediaType.title=\u30e1\u30c7\u30a3\u30a2\u30bf\u30a4\u30d7 +dod_dod5015.property.dod_mediaType.decription=\u30e1\u30c7\u30a3\u30a2\u30bf\u30a4\u30d7 +dod_dod5015.property.dod_format.title=\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 +dod_dod5015.property.dod_format.decription=\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 +dod_dod5015.property.dod_dateReceived.title=\u53d7\u4fe1\u65e5 +dod_dod5015.property.dod_dateReceived.decription=\u53d7\u4fe1\u65e5 +dod_dod5015.property.dod_address.title=\u53d7\u4fe1\u8005 +dod_dod5015.property.dod_address.decription=\u53d7\u4fe1\u8005 +dod_dod5015.property.dod_otherAddress.title=\u305d\u306e\u4ed6\u306e\u53d7\u4fe1\u8005 +dod_dod5015.property.dod_otherAddress.decription=\u305d\u306e\u4ed6\u306e\u53d7\u4fe1\u8005 + +dod_dod5015.aspect.dod_scannedRecord.title=\u30b9\u30ad\u30e3\u30f3\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.aspect.dod_scannedRecord.description=\u30b9\u30ad\u30e3\u30f3\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.property.dod_scannedFormat.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 +dod_dod5015.property.dod_scannedFormat.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 +dod_dod5015.property.dod_scannedFormatVersion.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_scannedFormatVersion.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_resolutionX.title=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6X +dod_dod5015.property.dod_resolutionX.description=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6X +dod_dod5015.property.dod_resolutionY.title=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6Y +dod_dod5015.property.dod_resolutionY.description=\u30a4\u30e1\u30fc\u30b8\u306e\u89e3\u50cf\u5ea6Y +dod_dod5015.property.dod_scannedBitDepth.title=\u30b9\u30ad\u30e3\u30f3\u3057\u305f\u30d3\u30c3\u30c8\u6df1\u5ea6 +dod_dod5015.property.dod_scannedBitDepth.description=\u30b9\u30ad\u30e3\u30f3\u3057\u305f\u30d3\u30c3\u30c8\u6df1\u5ea6 + +dod_dod5015.aspect.dod_pdfRecord.title=PDF\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.aspect.dod_pdfRecord.description=PDF\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.property.dod_producingApplication.title=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_producingApplication.description=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_producingApplicationVersion.title=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_producingApplicationVersion.description=\u88fd\u4f5c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_pdfVersion.title=PDF\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_pdfVersion.description=PDF\u30d0\u30fc\u30b8\u30e7\u30f3 +dod_dod5015.property.dod_creatingApplication.title=\u4f5c\u6210\u5143\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_creatingApplication.description=\u4f5c\u6210\u5143\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_documentSecuritySettings.title=\u6587\u66f8\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a +dod_dod5015.property.dod_documentSecuritySettings.description=\u6587\u66f8\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=\u30c7\u30b8\u30bf\u30eb\u5199\u771f\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.aspect.dod_digitalPhotographRecord.description=\u30c7\u30b8\u30bf\u30eb\u5199\u771f\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.property.dod_caption.title=\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_caption.description=\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3 +dod_dod5015.property.dod_photographer.title=\u5199\u771f\u5bb6 +dod_dod5015.property.dod_photographer.description=\u5199\u771f\u5bb6 +dod_dod5015.property.dod_copyright.title=\u8457\u4f5c\u6a29 +dod_dod5015.property.dod_copyright.description=\u8457\u4f5c\u6a29 +dod_dod5015.property.dod_bitDepth.title=\u30d3\u30c3\u30c8\u6df1\u5ea6 +dod_dod5015.property.dod_bitDepth.description=\u30d3\u30c3\u30c8\u6df1\u5ea6 +dod_dod5015.property.dod_imageSizeX.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baX +dod_dod5015.property.dod_imageSizeX.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baX +dod_dod5015.property.dod_imageSizeY.title=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baY +dod_dod5015.property.dod_imageSizeY.description=\u30a4\u30e1\u30fc\u30b8\u306e\u30b5\u30a4\u30baY +dod_dod5015.property.dod_imageSource.title=\u30a4\u30e1\u30fc\u30b8\u30bd\u30fc\u30b9 +dod_dod5015.property.dod_imageSource.description=\u30a4\u30e1\u30fc\u30b8\u30bd\u30fc\u30b9 +dod_dod5015.property.dod_compression.title=\u5727\u7e2e +dod_dod5015.property.dod_compression.description=\u5727\u7e2e +dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb +dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb +dod_dod5015.property.dod_exifInformation.title=EXIF\u60c5\u5831 +dod_dod5015.property.dod_exifInformation.description=EXIF\u60c5\u5831 + +dod_dod5015.aspect.dod_webRecord.title=Web\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.aspect.dod_webRecord.description=Web\u30ec\u30b3\u30fc\u30c9 +dod_dod5015.property.dod_webFileName.title=Web\u30d5\u30a1\u30a4\u30eb\u540d +dod_dod5015.property.dod_webFileName.description=Web\u30d5\u30a1\u30a4\u30eb\u540d +dod_dod5015.property.dod_webPlatform.title=Web\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0 +dod_dod5015.property.dod_webPlatform.description=Web\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0 +dod_dod5015.property.dod_webSiteName.title=Web\u30b5\u30a4\u30c8\u540d +dod_dod5015.property.dod_webSiteName.description=Web\u30b5\u30a4\u30c8\u540d +dod_dod5015.property.dod_webSiteURL.title=Web\u30b5\u30a4\u30c8URL +dod_dod5015.property.dod_webSiteURL.description=Web\u30b5\u30a4\u30c8URL +dod_dod5015.property.dod_captureMethod.title=\u30ad\u30e3\u30d7\u30c1\u30e3\u624b\u6cd5 +dod_dod5015.property.dod_captureMethod.description=\u30ad\u30e3\u30d7\u30c1\u30e3\u624b\u6cd5 +dod_dod5015.property.dod_captureDate.title=\u30ad\u30e3\u30d7\u30c1\u30e3\u65e5 +dod_dod5015.property.dod_captureDate.description=\u30ad\u30e3\u30d7\u30c1\u30e3\u65e5 +dod_dod5015.property.dod_contact.title=\u9023\u7d61\u5148 +dod_dod5015.property.dod_contact.description=\u9023\u7d61\u5148 +dod_dod5015.property.dod_contentManagementSystem.title=\u30b3\u30f3\u30c6\u30f3\u30c4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0 +dod_dod5015.property.dod_contentManagementSystem.description=\u30b3\u30f3\u30c6\u30f3\u30c4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0 + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_nl.properties index 9bcafada1f..123ebee205 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_nl.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=DOD5015-contentmodel - -dod_dod5015.type.dod_site.title=DOD5015-site -dod_dod5015.type.dod_site.description=DOD5015-site - -dod_dod5015.type.dod_filePlan.title=DOD5015-ordeningsplan -dod_dod5015.type.dod_filePlan.description=DOD5015-ordeningsplan - -dod_dod5015.type.dod_recordSeries.title=Recordreeks (afgekeurd) -dod_dod5015.type.dod_recordSeries.description=Recordreeks (afgekeurd) - -dod_dod5015.aspect.dod_dod5015record.title=DOD5015-record -dod_dod5015.aspect.dod_dod5015record.description=DOD5015-record -dod_dod5015.property.dod_publicationDate.title=Publicatiedatum -dod_dod5015.property.dod_publicationDate.decription=Publicatiedatum -dod_dod5015.property.dod_originator.title=Herkomst -dod_dod5015.property.dod_originator.decription=Herkomst -dod_dod5015.property.dod_originatingOrganization.title=Oorspronkelijke organisatie -dod_dod5015.property.dod_originatingOrganization.decription=Oorspronkelijke organisatie -dod_dod5015.property.dod_mediaType.title=Type medium -dod_dod5015.property.dod_mediaType.decription=Type medium -dod_dod5015.property.dod_format.title=Indeling -dod_dod5015.property.dod_format.decription=Indeling -dod_dod5015.property.dod_dateReceived.title=Datum ontvangen -dod_dod5015.property.dod_dateReceived.decription=Datum ontvangen -dod_dod5015.property.dod_address.title=Geadresseerde -dod_dod5015.property.dod_address.decription=Geadresseerde -dod_dod5015.property.dod_otherAddress.title=Andere geadresseerde -dod_dod5015.property.dod_otherAddress.decription=Andere geadresseerde - -dod_dod5015.aspect.dod_scannedRecord.title=Gescande record -dod_dod5015.aspect.dod_scannedRecord.description=Gescande record -dod_dod5015.property.dod_scannedFormat.title=Beeldindeling -dod_dod5015.property.dod_scannedFormat.description=Beeldindeling -dod_dod5015.property.dod_scannedFormatVersion.title=Beeldindeling en -versie -dod_dod5015.property.dod_scannedFormatVersion.description=Beeldindeling en -versie -dod_dod5015.property.dod_resolutionX.title=Beeldresolutie X -dod_dod5015.property.dod_resolutionX.description=Beeldresolutie X -dod_dod5015.property.dod_resolutionY.title=Beeldresolutie Y -dod_dod5015.property.dod_resolutionY.description=Beeldresolutie Y -dod_dod5015.property.dod_scannedBitDepth.title=Gescande bitdiepte -dod_dod5015.property.dod_scannedBitDepth.description=Gescande bitdiepte - -dod_dod5015.aspect.dod_pdfRecord.title=PDF-record -dod_dod5015.aspect.dod_pdfRecord.description=PDF-record -dod_dod5015.property.dod_producingApplication.title=Producerende applicatie -dod_dod5015.property.dod_producingApplication.description=Producerende applicatie -dod_dod5015.property.dod_producingApplicationVersion.title=Versie producerende applicatie -dod_dod5015.property.dod_producingApplicationVersion.description=Versie producerende applicatie -dod_dod5015.property.dod_pdfVersion.title=PDF-versie -dod_dod5015.property.dod_pdfVersion.description=PDF-versie -dod_dod5015.property.dod_creatingApplication.title=Producerende applicatie -dod_dod5015.property.dod_creatingApplication.description=Producerende applicatie -dod_dod5015.property.dod_documentSecuritySettings.title=Documentbeveiligingsinstellingen -dod_dod5015.property.dod_documentSecuritySettings.description=Documentbeveiligingsinstellingen - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=Digitale fotorecord -dod_dod5015.aspect.dod_digitalPhotographRecord.description=Digitale fotorecord -dod_dod5015.property.dod_caption.title=Bijschrift -dod_dod5015.property.dod_caption.description=Bijschrift -dod_dod5015.property.dod_photographer.title=Fotograaf -dod_dod5015.property.dod_photographer.description=Fotograaf -dod_dod5015.property.dod_copyright.title=Auteursrecht -dod_dod5015.property.dod_copyright.description=Auteursrecht -dod_dod5015.property.dod_bitDepth.title=Bitdiepte -dod_dod5015.property.dod_bitDepth.description=Bitdiepte -dod_dod5015.property.dod_imageSizeX.title=Beeldgrootte X -dod_dod5015.property.dod_imageSizeX.description=Beeldgrootte X -dod_dod5015.property.dod_imageSizeY.title=Beeldgrootte Y -dod_dod5015.property.dod_imageSizeY.description=Beeldgrootte Y -dod_dod5015.property.dod_imageSource.title=Beeldbron -dod_dod5015.property.dod_imageSource.description=Beeldbron -dod_dod5015.property.dod_compression.title=Compressie -dod_dod5015.property.dod_compression.description=Compressie -dod_dod5015.property.dod_iccIcmProfile.title=ICC-/ICM-profiel -dod_dod5015.property.dod_iccIcmProfile.description=ICC-/ICM-profiel -dod_dod5015.property.dod_exifInformation.title=EXIF-informatie -dod_dod5015.property.dod_exifInformation.description=EXIF-informatie - -dod_dod5015.aspect.dod_webRecord.title=Web-record -dod_dod5015.aspect.dod_webRecord.description=Web-record -dod_dod5015.property.dod_webFileName.title=Web-bestandsnaam -dod_dod5015.property.dod_webFileName.description=Web-bestandsnaam -dod_dod5015.property.dod_webPlatform.title=Web-platform -dod_dod5015.property.dod_webPlatform.description=Web-platform -dod_dod5015.property.dod_webSiteName.title=Websitenaam -dod_dod5015.property.dod_webSiteName.description=Websitenaam -dod_dod5015.property.dod_webSiteURL.title=Websiteadres -dod_dod5015.property.dod_webSiteURL.description=Websiteadres -dod_dod5015.property.dod_captureMethod.title=Methode van vastleggen -dod_dod5015.property.dod_captureMethod.description=Methode van vastleggen -dod_dod5015.property.dod_captureDate.title=Vastlegdatum -dod_dod5015.property.dod_captureDate.description=Vastlegdatum -dod_dod5015.property.dod_contact.title=Contact -dod_dod5015.property.dod_contact.description=Contact -dod_dod5015.property.dod_contentManagementSystem.title=Content Management System -dod_dod5015.property.dod_contentManagementSystem.description=Content Management System - +dod_dod5015.description=DOD5015-contentmodel + +dod_dod5015.type.dod_site.title=DOD5015-site +dod_dod5015.type.dod_site.description=DOD5015-site + +dod_dod5015.type.dod_filePlan.title=DOD5015-ordeningsplan +dod_dod5015.type.dod_filePlan.description=DOD5015-ordeningsplan + +dod_dod5015.type.dod_recordSeries.title=Recordreeks (afgekeurd) +dod_dod5015.type.dod_recordSeries.description=Recordreeks (afgekeurd) + +dod_dod5015.aspect.dod_dod5015record.title=DOD5015-record +dod_dod5015.aspect.dod_dod5015record.description=DOD5015-record +dod_dod5015.property.dod_publicationDate.title=Publicatiedatum +dod_dod5015.property.dod_publicationDate.decription=Publicatiedatum +dod_dod5015.property.dod_originator.title=Herkomst +dod_dod5015.property.dod_originator.decription=Herkomst +dod_dod5015.property.dod_originatingOrganization.title=Oorspronkelijke organisatie +dod_dod5015.property.dod_originatingOrganization.decription=Oorspronkelijke organisatie +dod_dod5015.property.dod_mediaType.title=Type medium +dod_dod5015.property.dod_mediaType.decription=Type medium +dod_dod5015.property.dod_format.title=Indeling +dod_dod5015.property.dod_format.decription=Indeling +dod_dod5015.property.dod_dateReceived.title=Datum ontvangen +dod_dod5015.property.dod_dateReceived.decription=Datum ontvangen +dod_dod5015.property.dod_address.title=Geadresseerde +dod_dod5015.property.dod_address.decription=Geadresseerde +dod_dod5015.property.dod_otherAddress.title=Andere geadresseerde +dod_dod5015.property.dod_otherAddress.decription=Andere geadresseerde + +dod_dod5015.aspect.dod_scannedRecord.title=Gescande record +dod_dod5015.aspect.dod_scannedRecord.description=Gescande record +dod_dod5015.property.dod_scannedFormat.title=Beeldindeling +dod_dod5015.property.dod_scannedFormat.description=Beeldindeling +dod_dod5015.property.dod_scannedFormatVersion.title=Beeldindeling en -versie +dod_dod5015.property.dod_scannedFormatVersion.description=Beeldindeling en -versie +dod_dod5015.property.dod_resolutionX.title=Beeldresolutie X +dod_dod5015.property.dod_resolutionX.description=Beeldresolutie X +dod_dod5015.property.dod_resolutionY.title=Beeldresolutie Y +dod_dod5015.property.dod_resolutionY.description=Beeldresolutie Y +dod_dod5015.property.dod_scannedBitDepth.title=Gescande bitdiepte +dod_dod5015.property.dod_scannedBitDepth.description=Gescande bitdiepte + +dod_dod5015.aspect.dod_pdfRecord.title=PDF-record +dod_dod5015.aspect.dod_pdfRecord.description=PDF-record +dod_dod5015.property.dod_producingApplication.title=Producerende applicatie +dod_dod5015.property.dod_producingApplication.description=Producerende applicatie +dod_dod5015.property.dod_producingApplicationVersion.title=Versie producerende applicatie +dod_dod5015.property.dod_producingApplicationVersion.description=Versie producerende applicatie +dod_dod5015.property.dod_pdfVersion.title=PDF-versie +dod_dod5015.property.dod_pdfVersion.description=PDF-versie +dod_dod5015.property.dod_creatingApplication.title=Producerende applicatie +dod_dod5015.property.dod_creatingApplication.description=Producerende applicatie +dod_dod5015.property.dod_documentSecuritySettings.title=Documentbeveiligingsinstellingen +dod_dod5015.property.dod_documentSecuritySettings.description=Documentbeveiligingsinstellingen + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=Digitale fotorecord +dod_dod5015.aspect.dod_digitalPhotographRecord.description=Digitale fotorecord +dod_dod5015.property.dod_caption.title=Bijschrift +dod_dod5015.property.dod_caption.description=Bijschrift +dod_dod5015.property.dod_photographer.title=Fotograaf +dod_dod5015.property.dod_photographer.description=Fotograaf +dod_dod5015.property.dod_copyright.title=Auteursrecht +dod_dod5015.property.dod_copyright.description=Auteursrecht +dod_dod5015.property.dod_bitDepth.title=Bitdiepte +dod_dod5015.property.dod_bitDepth.description=Bitdiepte +dod_dod5015.property.dod_imageSizeX.title=Beeldgrootte X +dod_dod5015.property.dod_imageSizeX.description=Beeldgrootte X +dod_dod5015.property.dod_imageSizeY.title=Beeldgrootte Y +dod_dod5015.property.dod_imageSizeY.description=Beeldgrootte Y +dod_dod5015.property.dod_imageSource.title=Beeldbron +dod_dod5015.property.dod_imageSource.description=Beeldbron +dod_dod5015.property.dod_compression.title=Compressie +dod_dod5015.property.dod_compression.description=Compressie +dod_dod5015.property.dod_iccIcmProfile.title=ICC-/ICM-profiel +dod_dod5015.property.dod_iccIcmProfile.description=ICC-/ICM-profiel +dod_dod5015.property.dod_exifInformation.title=EXIF-informatie +dod_dod5015.property.dod_exifInformation.description=EXIF-informatie + +dod_dod5015.aspect.dod_webRecord.title=Web-record +dod_dod5015.aspect.dod_webRecord.description=Web-record +dod_dod5015.property.dod_webFileName.title=Web-bestandsnaam +dod_dod5015.property.dod_webFileName.description=Web-bestandsnaam +dod_dod5015.property.dod_webPlatform.title=Web-platform +dod_dod5015.property.dod_webPlatform.description=Web-platform +dod_dod5015.property.dod_webSiteName.title=Websitenaam +dod_dod5015.property.dod_webSiteName.description=Websitenaam +dod_dod5015.property.dod_webSiteURL.title=Websiteadres +dod_dod5015.property.dod_webSiteURL.description=Websiteadres +dod_dod5015.property.dod_captureMethod.title=Methode van vastleggen +dod_dod5015.property.dod_captureMethod.description=Methode van vastleggen +dod_dod5015.property.dod_captureDate.title=Vastlegdatum +dod_dod5015.property.dod_captureDate.description=Vastlegdatum +dod_dod5015.property.dod_contact.title=Contact +dod_dod5015.property.dod_contact.description=Contact +dod_dod5015.property.dod_contentManagementSystem.title=Content Management System +dod_dod5015.property.dod_contentManagementSystem.description=Content Management System + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_zh_CN.properties index 660f640ae5..30dcfe4419 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015-model_zh_CN.properties @@ -1,98 +1,98 @@ -dod_dod5015.description=DOD5015 \u5185\u5bb9\u6a21\u578b - -dod_dod5015.type.dod_site.title=DOD5015 \u7ad9\u70b9 -dod_dod5015.type.dod_site.description=DOD5015 \u7ad9\u70b9 - -dod_dod5015.type.dod_filePlan.title=DOD5015 \u5f52\u7c7b\u65b9\u6848 -dod_dod5015.type.dod_filePlan.description=DOD5015 \u5f52\u7c7b\u65b9\u6848 - -dod_dod5015.type.dod_recordSeries.title=\u8bb0\u5f55\u7cfb\u5217\uff08\u5df2\u5f03\u7528\uff09 -dod_dod5015.type.dod_recordSeries.description=\u8bb0\u5f55\u7cfb\u5217\uff08\u5df2\u5f03\u7528\uff09 - -dod_dod5015.aspect.dod_dod5015record.title=DOD5015 \u8bb0\u5f55 -dod_dod5015.aspect.dod_dod5015record.description=DOD5015 \u8bb0\u5f55 -dod_dod5015.property.dod_publicationDate.title=\u53d1\u5e03\u65e5\u671f -dod_dod5015.property.dod_publicationDate.decription=\u53d1\u5e03\u65e5\u671f -dod_dod5015.property.dod_originator.title=\u5efa\u7acb\u8005 -dod_dod5015.property.dod_originator.decription=\u5efa\u7acb\u8005 -dod_dod5015.property.dod_originatingOrganization.title=\u8d77\u59cb\u7ec4\u7ec7 -dod_dod5015.property.dod_originatingOrganization.decription=\u8d77\u59cb\u7ec4\u7ec7 -dod_dod5015.property.dod_mediaType.title=\u5a92\u4f53\u7c7b\u578b -dod_dod5015.property.dod_mediaType.decription=\u5a92\u4f53\u7c7b\u578b -dod_dod5015.property.dod_format.title=\u683c\u5f0f -dod_dod5015.property.dod_format.decription=\u683c\u5f0f -dod_dod5015.property.dod_dateReceived.title=\u63a5\u6536\u65e5\u671f -dod_dod5015.property.dod_dateReceived.decription=\u63a5\u6536\u65e5\u671f -dod_dod5015.property.dod_address.title=\u6536\u4ef6\u4eba -dod_dod5015.property.dod_address.decription=\u6536\u4ef6\u4eba -dod_dod5015.property.dod_otherAddress.title=\u5176\u4ed6\u6536\u4ef6\u4eba -dod_dod5015.property.dod_otherAddress.decription=\u5176\u4ed6\u6536\u4ef6\u4eba - -dod_dod5015.aspect.dod_scannedRecord.title=\u626b\u63cf\u7684\u8bb0\u5f55 -dod_dod5015.aspect.dod_scannedRecord.description=\u626b\u63cf\u7684\u8bb0\u5f55 -dod_dod5015.property.dod_scannedFormat.title=\u56fe\u50cf\u683c\u5f0f -dod_dod5015.property.dod_scannedFormat.description=\u56fe\u50cf\u683c\u5f0f -dod_dod5015.property.dod_scannedFormatVersion.title=\u56fe\u50cf\u683c\u5f0f\u548c\u7248\u672c -dod_dod5015.property.dod_scannedFormatVersion.description=\u56fe\u50cf\u683c\u5f0f\u548c\u7248\u672c -dod_dod5015.property.dod_resolutionX.title=\u56fe\u50cf\u5206\u8fa8\u7387 X -dod_dod5015.property.dod_resolutionX.description=\u56fe\u50cf\u5206\u8fa8\u7387 X -dod_dod5015.property.dod_resolutionY.title=\u56fe\u50cf\u5206\u8fa8\u7387 Y -dod_dod5015.property.dod_resolutionY.description=\u56fe\u50cf\u5206\u8fa8\u7387 Y -dod_dod5015.property.dod_scannedBitDepth.title=\u626b\u63cf\u7684\u4f4d\u6df1 -dod_dod5015.property.dod_scannedBitDepth.description=\u626b\u63cf\u7684\u4f4d\u6df1 - -dod_dod5015.aspect.dod_pdfRecord.title=PDF \u8bb0\u5f55 -dod_dod5015.aspect.dod_pdfRecord.description=PDF \u8bb0\u5f55 -dod_dod5015.property.dod_producingApplication.title=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f -dod_dod5015.property.dod_producingApplication.description=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f -dod_dod5015.property.dod_producingApplicationVersion.title=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u7248\u672c -dod_dod5015.property.dod_producingApplicationVersion.description=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u7248\u672c -dod_dod5015.property.dod_pdfVersion.title=PDF \u7248\u672c -dod_dod5015.property.dod_pdfVersion.description=PDF \u7248\u672c -dod_dod5015.property.dod_creatingApplication.title=\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f -dod_dod5015.property.dod_creatingApplication.description=\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f -dod_dod5015.property.dod_documentSecuritySettings.title=\u6587\u6863\u5b89\u5168\u8bbe\u7f6e -dod_dod5015.property.dod_documentSecuritySettings.description=\u6587\u6863\u5b89\u5168\u8bbe\u7f6e - -dod_dod5015.aspect.dod_digitalPhotographRecord.title=\u6570\u7801\u7167\u7247\u8bb0\u5f55 -dod_dod5015.aspect.dod_digitalPhotographRecord.description=\u6570\u7801\u7167\u7247\u8bb0\u5f55 -dod_dod5015.property.dod_caption.title=\u6807\u9898 -dod_dod5015.property.dod_caption.description=\u6807\u9898 -dod_dod5015.property.dod_photographer.title=\u6444\u5f71\u5e08 -dod_dod5015.property.dod_photographer.description=\u6444\u5f71\u5e08 -dod_dod5015.property.dod_copyright.title=\u7248\u6743 -dod_dod5015.property.dod_copyright.description=\u7248\u6743 -dod_dod5015.property.dod_bitDepth.title=\u4f4d\u6df1 -dod_dod5015.property.dod_bitDepth.description=\u4f4d\u6df1 -dod_dod5015.property.dod_imageSizeX.title=\u56fe\u50cf\u5c3a\u5bf8 X -dod_dod5015.property.dod_imageSizeX.description=\u56fe\u50cf\u5c3a\u5bf8 X -dod_dod5015.property.dod_imageSizeY.title=\u56fe\u50cf\u5c3a\u5bf8 Y -dod_dod5015.property.dod_imageSizeY.description=\u56fe\u50cf\u5c3a\u5bf8 Y -dod_dod5015.property.dod_imageSource.title=\u56fe\u50cf\u6e90 -dod_dod5015.property.dod_imageSource.description=\u56fe\u50cf\u6e90 -dod_dod5015.property.dod_compression.title=\u538b\u7f29 -dod_dod5015.property.dod_compression.description=\u538b\u7f29 -dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM \u914d\u7f6e\u6587\u4ef6 -dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM \u914d\u7f6e\u6587\u4ef6 -dod_dod5015.property.dod_exifInformation.title=EXIF \u4fe1\u606f -dod_dod5015.property.dod_exifInformation.description=EXIF \u4fe1\u606f - -dod_dod5015.aspect.dod_webRecord.title=Web \u8bb0\u5f55 -dod_dod5015.aspect.dod_webRecord.description=Web \u8bb0\u5f55 -dod_dod5015.property.dod_webFileName.title=Web \u6587\u4ef6\u540d -dod_dod5015.property.dod_webFileName.description=Web \u6587\u4ef6\u540d -dod_dod5015.property.dod_webPlatform.title=Web \u5e73\u53f0 -dod_dod5015.property.dod_webPlatform.description=Web \u5e73\u53f0 -dod_dod5015.property.dod_webSiteName.title=\u7f51\u7ad9\u540d\u79f0 -dod_dod5015.property.dod_webSiteName.description=\u7f51\u7ad9\u540d\u79f0 -dod_dod5015.property.dod_webSiteURL.title=\u7f51\u7ad9 URL -dod_dod5015.property.dod_webSiteURL.description=\u7f51\u7ad9 URL -dod_dod5015.property.dod_captureMethod.title=\u6355\u6349\u65b9\u6cd5 -dod_dod5015.property.dod_captureMethod.description=\u6355\u6349\u65b9\u6cd5 -dod_dod5015.property.dod_captureDate.title=\u6355\u6349\u65e5\u671f -dod_dod5015.property.dod_captureDate.description=\u6355\u6349\u65e5\u671f -dod_dod5015.property.dod_contact.title=\u8054\u7cfb\u4eba -dod_dod5015.property.dod_contact.description=\u8054\u7cfb\u4eba -dod_dod5015.property.dod_contentManagementSystem.title=\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf -dod_dod5015.property.dod_contentManagementSystem.description=\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf - +dod_dod5015.description=DOD5015 \u5185\u5bb9\u6a21\u578b + +dod_dod5015.type.dod_site.title=DOD5015 \u7ad9\u70b9 +dod_dod5015.type.dod_site.description=DOD5015 \u7ad9\u70b9 + +dod_dod5015.type.dod_filePlan.title=DOD5015 \u5f52\u7c7b\u65b9\u6848 +dod_dod5015.type.dod_filePlan.description=DOD5015 \u5f52\u7c7b\u65b9\u6848 + +dod_dod5015.type.dod_recordSeries.title=\u8bb0\u5f55\u7cfb\u5217\uff08\u5df2\u5f03\u7528\uff09 +dod_dod5015.type.dod_recordSeries.description=\u8bb0\u5f55\u7cfb\u5217\uff08\u5df2\u5f03\u7528\uff09 + +dod_dod5015.aspect.dod_dod5015record.title=DOD5015 \u8bb0\u5f55 +dod_dod5015.aspect.dod_dod5015record.description=DOD5015 \u8bb0\u5f55 +dod_dod5015.property.dod_publicationDate.title=\u53d1\u5e03\u65e5\u671f +dod_dod5015.property.dod_publicationDate.decription=\u53d1\u5e03\u65e5\u671f +dod_dod5015.property.dod_originator.title=\u5efa\u7acb\u8005 +dod_dod5015.property.dod_originator.decription=\u5efa\u7acb\u8005 +dod_dod5015.property.dod_originatingOrganization.title=\u8d77\u59cb\u7ec4\u7ec7 +dod_dod5015.property.dod_originatingOrganization.decription=\u8d77\u59cb\u7ec4\u7ec7 +dod_dod5015.property.dod_mediaType.title=\u5a92\u4f53\u7c7b\u578b +dod_dod5015.property.dod_mediaType.decription=\u5a92\u4f53\u7c7b\u578b +dod_dod5015.property.dod_format.title=\u683c\u5f0f +dod_dod5015.property.dod_format.decription=\u683c\u5f0f +dod_dod5015.property.dod_dateReceived.title=\u63a5\u6536\u65e5\u671f +dod_dod5015.property.dod_dateReceived.decription=\u63a5\u6536\u65e5\u671f +dod_dod5015.property.dod_address.title=\u6536\u4ef6\u4eba +dod_dod5015.property.dod_address.decription=\u6536\u4ef6\u4eba +dod_dod5015.property.dod_otherAddress.title=\u5176\u4ed6\u6536\u4ef6\u4eba +dod_dod5015.property.dod_otherAddress.decription=\u5176\u4ed6\u6536\u4ef6\u4eba + +dod_dod5015.aspect.dod_scannedRecord.title=\u626b\u63cf\u7684\u8bb0\u5f55 +dod_dod5015.aspect.dod_scannedRecord.description=\u626b\u63cf\u7684\u8bb0\u5f55 +dod_dod5015.property.dod_scannedFormat.title=\u56fe\u50cf\u683c\u5f0f +dod_dod5015.property.dod_scannedFormat.description=\u56fe\u50cf\u683c\u5f0f +dod_dod5015.property.dod_scannedFormatVersion.title=\u56fe\u50cf\u683c\u5f0f\u548c\u7248\u672c +dod_dod5015.property.dod_scannedFormatVersion.description=\u56fe\u50cf\u683c\u5f0f\u548c\u7248\u672c +dod_dod5015.property.dod_resolutionX.title=\u56fe\u50cf\u5206\u8fa8\u7387 X +dod_dod5015.property.dod_resolutionX.description=\u56fe\u50cf\u5206\u8fa8\u7387 X +dod_dod5015.property.dod_resolutionY.title=\u56fe\u50cf\u5206\u8fa8\u7387 Y +dod_dod5015.property.dod_resolutionY.description=\u56fe\u50cf\u5206\u8fa8\u7387 Y +dod_dod5015.property.dod_scannedBitDepth.title=\u626b\u63cf\u7684\u4f4d\u6df1 +dod_dod5015.property.dod_scannedBitDepth.description=\u626b\u63cf\u7684\u4f4d\u6df1 + +dod_dod5015.aspect.dod_pdfRecord.title=PDF \u8bb0\u5f55 +dod_dod5015.aspect.dod_pdfRecord.description=PDF \u8bb0\u5f55 +dod_dod5015.property.dod_producingApplication.title=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f +dod_dod5015.property.dod_producingApplication.description=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f +dod_dod5015.property.dod_producingApplicationVersion.title=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u7248\u672c +dod_dod5015.property.dod_producingApplicationVersion.description=\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u7248\u672c +dod_dod5015.property.dod_pdfVersion.title=PDF \u7248\u672c +dod_dod5015.property.dod_pdfVersion.description=PDF \u7248\u672c +dod_dod5015.property.dod_creatingApplication.title=\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f +dod_dod5015.property.dod_creatingApplication.description=\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f +dod_dod5015.property.dod_documentSecuritySettings.title=\u6587\u6863\u5b89\u5168\u8bbe\u7f6e +dod_dod5015.property.dod_documentSecuritySettings.description=\u6587\u6863\u5b89\u5168\u8bbe\u7f6e + +dod_dod5015.aspect.dod_digitalPhotographRecord.title=\u6570\u7801\u7167\u7247\u8bb0\u5f55 +dod_dod5015.aspect.dod_digitalPhotographRecord.description=\u6570\u7801\u7167\u7247\u8bb0\u5f55 +dod_dod5015.property.dod_caption.title=\u6807\u9898 +dod_dod5015.property.dod_caption.description=\u6807\u9898 +dod_dod5015.property.dod_photographer.title=\u6444\u5f71\u5e08 +dod_dod5015.property.dod_photographer.description=\u6444\u5f71\u5e08 +dod_dod5015.property.dod_copyright.title=\u7248\u6743 +dod_dod5015.property.dod_copyright.description=\u7248\u6743 +dod_dod5015.property.dod_bitDepth.title=\u4f4d\u6df1 +dod_dod5015.property.dod_bitDepth.description=\u4f4d\u6df1 +dod_dod5015.property.dod_imageSizeX.title=\u56fe\u50cf\u5c3a\u5bf8 X +dod_dod5015.property.dod_imageSizeX.description=\u56fe\u50cf\u5c3a\u5bf8 X +dod_dod5015.property.dod_imageSizeY.title=\u56fe\u50cf\u5c3a\u5bf8 Y +dod_dod5015.property.dod_imageSizeY.description=\u56fe\u50cf\u5c3a\u5bf8 Y +dod_dod5015.property.dod_imageSource.title=\u56fe\u50cf\u6e90 +dod_dod5015.property.dod_imageSource.description=\u56fe\u50cf\u6e90 +dod_dod5015.property.dod_compression.title=\u538b\u7f29 +dod_dod5015.property.dod_compression.description=\u538b\u7f29 +dod_dod5015.property.dod_iccIcmProfile.title=ICC/ICM \u914d\u7f6e\u6587\u4ef6 +dod_dod5015.property.dod_iccIcmProfile.description=ICC/ICM \u914d\u7f6e\u6587\u4ef6 +dod_dod5015.property.dod_exifInformation.title=EXIF \u4fe1\u606f +dod_dod5015.property.dod_exifInformation.description=EXIF \u4fe1\u606f + +dod_dod5015.aspect.dod_webRecord.title=Web \u8bb0\u5f55 +dod_dod5015.aspect.dod_webRecord.description=Web \u8bb0\u5f55 +dod_dod5015.property.dod_webFileName.title=Web \u6587\u4ef6\u540d +dod_dod5015.property.dod_webFileName.description=Web \u6587\u4ef6\u540d +dod_dod5015.property.dod_webPlatform.title=Web \u5e73\u53f0 +dod_dod5015.property.dod_webPlatform.description=Web \u5e73\u53f0 +dod_dod5015.property.dod_webSiteName.title=\u7f51\u7ad9\u540d\u79f0 +dod_dod5015.property.dod_webSiteName.description=\u7f51\u7ad9\u540d\u79f0 +dod_dod5015.property.dod_webSiteURL.title=\u7f51\u7ad9 URL +dod_dod5015.property.dod_webSiteURL.description=\u7f51\u7ad9 URL +dod_dod5015.property.dod_captureMethod.title=\u6355\u6349\u65b9\u6cd5 +dod_dod5015.property.dod_captureMethod.description=\u6355\u6349\u65b9\u6cd5 +dod_dod5015.property.dod_captureDate.title=\u6355\u6349\u65e5\u671f +dod_dod5015.property.dod_captureDate.description=\u6355\u6349\u65e5\u671f +dod_dod5015.property.dod_contact.title=\u8054\u7cfb\u4eba +dod_dod5015.property.dod_contact.description=\u8054\u7cfb\u4eba +dod_dod5015.property.dod_contentManagementSystem.title=\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf +dod_dod5015.property.dod_contentManagementSystem.description=\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015.properties index ae0fd1111b..23d5952dfc 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Classified Records -capability.UpdateClassificationDates.title=Update Classification Dates -capability.CreateModifyDestroyClassificationGuides.title=Create Modify Destroy Classification Guides -capability.UpgradeDowngradeAndDeclassifyRecords.title=Upgrade Downgrade and Declassify Records -capability.UpdateExemptionCategories.title=Update Exemption Categories -capability.MapClassificationGuideMetadata.title=Map Classification Guide Metadata +# Classified Records Capabilities +capability.group.classifiedRecords.title=Classified Records +capability.UpdateClassificationDates.title=Update Classification Dates +capability.CreateModifyDestroyClassificationGuides.title=Create Modify Destroy Classification Guides +capability.UpgradeDowngradeAndDeclassifyRecords.title=Upgrade Downgrade and Declassify Records +capability.UpdateExemptionCategories.title=Update Exemption Categories +capability.MapClassificationGuideMetadata.title=Map Classification Guide Metadata capability.CreateModifyDestroyTimeframes.title=Create Modify Destroy Time Frames \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_de.properties index 7d3c29ba1d..88de8c3e0e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_de.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Klassifizierte Records -capability.UpdateClassificationDates.title=Klassifizierungsdaten aktualisieren -capability.CreateModifyDestroyClassificationGuides.title=Klassifizierungsleitfaden erstellen/\u00e4ndern/vernichten -capability.UpgradeDowngradeAndDeclassifyRecords.title=Records h\u00f6her-/herunterstufen und ihre Klassifizierung aufheben -capability.UpdateExemptionCategories.title=Ausnahmekategorien aktualisieren -capability.MapClassificationGuideMetadata.title=Metadaten f\u00fcr Klassifizierungsleitfaden zuordnen +# Classified Records Capabilities +capability.group.classifiedRecords.title=Klassifizierte Records +capability.UpdateClassificationDates.title=Klassifizierungsdaten aktualisieren +capability.CreateModifyDestroyClassificationGuides.title=Klassifizierungsleitfaden erstellen/\u00e4ndern/vernichten +capability.UpgradeDowngradeAndDeclassifyRecords.title=Records h\u00f6her-/herunterstufen und ihre Klassifizierung aufheben +capability.UpdateExemptionCategories.title=Ausnahmekategorien aktualisieren +capability.MapClassificationGuideMetadata.title=Metadaten f\u00fcr Klassifizierungsleitfaden zuordnen capability.CreateModifyDestroyTimeframes.title=Zeitrahmen erstellen/\u00e4ndern/vernichten \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_es.properties index d65adbd457..18a13ca2e5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_es.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Documentos de archivo clasificados -capability.UpdateClassificationDates.title=Actualizar fechas de clasificaci\u00f3n -capability.CreateModifyDestroyClassificationGuides.title=Crear Modificar Destruir gu\u00edas de clasificaci\u00f3n -capability.UpgradeDowngradeAndDeclassifyRecords.title=Actualizar, degradar y desclasificar documentos de archivo -capability.UpdateExemptionCategories.title=Actualizar categor\u00edas de exenci\u00f3n -capability.MapClassificationGuideMetadata.title=Asignar metadatos de gu\u00eda de clasificaci\u00f3n +# Classified Records Capabilities +capability.group.classifiedRecords.title=Documentos de archivo clasificados +capability.UpdateClassificationDates.title=Actualizar fechas de clasificaci\u00f3n +capability.CreateModifyDestroyClassificationGuides.title=Crear Modificar Destruir gu\u00edas de clasificaci\u00f3n +capability.UpgradeDowngradeAndDeclassifyRecords.title=Actualizar, degradar y desclasificar documentos de archivo +capability.UpdateExemptionCategories.title=Actualizar categor\u00edas de exenci\u00f3n +capability.MapClassificationGuideMetadata.title=Asignar metadatos de gu\u00eda de clasificaci\u00f3n capability.CreateModifyDestroyTimeframes.title=Crear Modificar Destruir plazos de tiempo \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_fr.properties index 5bc697184c..c20654908c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_fr.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Document d'archives class\u00e9s -capability.UpdateClassificationDates.title=Mettre \u00e0 jour les dates de classement -capability.CreateModifyDestroyClassificationGuides.title=Cr\u00e9er Modifier D\u00e9truire des guides de classement -capability.UpgradeDowngradeAndDeclassifyRecords.title=Mettre \u00e0 jour R\u00e9trograder et D\u00e9classer des documents d'archives -capability.UpdateExemptionCategories.title=Mettre \u00e0 jour les cat\u00e9gories d'exemption -capability.MapClassificationGuideMetadata.title=Mapper les m\u00e9tadonn\u00e9es de guides de classement +# Classified Records Capabilities +capability.group.classifiedRecords.title=Document d'archives class\u00e9s +capability.UpdateClassificationDates.title=Mettre \u00e0 jour les dates de classement +capability.CreateModifyDestroyClassificationGuides.title=Cr\u00e9er Modifier D\u00e9truire des guides de classement +capability.UpgradeDowngradeAndDeclassifyRecords.title=Mettre \u00e0 jour R\u00e9trograder et D\u00e9classer des documents d'archives +capability.UpdateExemptionCategories.title=Mettre \u00e0 jour les cat\u00e9gories d'exemption +capability.MapClassificationGuideMetadata.title=Mapper les m\u00e9tadonn\u00e9es de guides de classement capability.CreateModifyDestroyTimeframes.title=Cr\u00e9er Modifier D\u00e9truire des d\u00e9lais \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_it.properties index 9ff3738d63..26ade3f234 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_it.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Record classificati -capability.UpdateClassificationDates.title=Aggiorna date di classificazione -capability.CreateModifyDestroyClassificationGuides.title=Crea Modifica Elimina definitivamente guide di classificazione -capability.UpgradeDowngradeAndDeclassifyRecords.title=Aggiorna Downgrade e Declassifica record -capability.UpdateExemptionCategories.title=Aggiorna categorie di esenzione -capability.MapClassificationGuideMetadata.title=Esegui il mapping dei metadati della guida di classificazione +# Classified Records Capabilities +capability.group.classifiedRecords.title=Record classificati +capability.UpdateClassificationDates.title=Aggiorna date di classificazione +capability.CreateModifyDestroyClassificationGuides.title=Crea Modifica Elimina definitivamente guide di classificazione +capability.UpgradeDowngradeAndDeclassifyRecords.title=Aggiorna Downgrade e Declassifica record +capability.UpdateExemptionCategories.title=Aggiorna categorie di esenzione +capability.MapClassificationGuideMetadata.title=Esegui il mapping dei metadati della guida di classificazione capability.CreateModifyDestroyTimeframes.title=Crea Modifica Elimina definitivamente intervalli di tempo \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_ja.properties index de31d900f5..fdf2104d71 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_ja.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=\u5206\u985e\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 -capability.UpdateClassificationDates.title=\u5206\u985e\u65e5\u306e\u66f4\u65b0 -capability.CreateModifyDestroyClassificationGuides.title=\u5206\u985e\u30ac\u30a4\u30c9\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.UpgradeDowngradeAndDeclassifyRecords.title=\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u306e\u66f4\u65b0\u3068\u30ec\u30b3\u30fc\u30c9\u306e\u5206\u985e\u89e3\u9664 -capability.UpdateExemptionCategories.title=\u9664\u5916\u30ab\u30c6\u30b4\u30ea\u306e\u66f4\u65b0 -capability.MapClassificationGuideMetadata.title=\u5206\u985e\u30ac\u30a4\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30c3\u30d4\u30f3\u30b0 +# Classified Records Capabilities +capability.group.classifiedRecords.title=\u5206\u985e\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 +capability.UpdateClassificationDates.title=\u5206\u985e\u65e5\u306e\u66f4\u65b0 +capability.CreateModifyDestroyClassificationGuides.title=\u5206\u985e\u30ac\u30a4\u30c9\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.UpgradeDowngradeAndDeclassifyRecords.title=\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u306e\u66f4\u65b0\u3068\u30ec\u30b3\u30fc\u30c9\u306e\u5206\u985e\u89e3\u9664 +capability.UpdateExemptionCategories.title=\u9664\u5916\u30ab\u30c6\u30b4\u30ea\u306e\u66f4\u65b0 +capability.MapClassificationGuideMetadata.title=\u5206\u985e\u30ac\u30a4\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30c3\u30d4\u30f3\u30b0 capability.CreateModifyDestroyTimeframes.title=\u30bf\u30a4\u30e0\u30d5\u30ec\u30fc\u30e0\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_nl.properties index 3933dd2240..92c80ba122 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_nl.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=Niet geclassificeerde records -capability.UpdateClassificationDates.title=Classificatiedata bijwerken -capability.CreateModifyDestroyClassificationGuides.title=Classificatiegidsen maken aanpassen vernietigen -capability.UpgradeDowngradeAndDeclassifyRecords.title=Records upgraden, downgraden en declassificeren -capability.UpdateExemptionCategories.title=Uitzonderingscategorie\u00ebn bijwerken -capability.MapClassificationGuideMetadata.title=Metagegevens classificatiegids toewijzen +# Classified Records Capabilities +capability.group.classifiedRecords.title=Niet geclassificeerde records +capability.UpdateClassificationDates.title=Classificatiedata bijwerken +capability.CreateModifyDestroyClassificationGuides.title=Classificatiegidsen maken aanpassen vernietigen +capability.UpgradeDowngradeAndDeclassifyRecords.title=Records upgraden, downgraden en declassificeren +capability.UpdateExemptionCategories.title=Uitzonderingscategorie\u00ebn bijwerken +capability.MapClassificationGuideMetadata.title=Metagegevens classificatiegids toewijzen capability.CreateModifyDestroyTimeframes.title=Tijdsperiodes maken aanpassen vernietigen \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_zh_CN.properties index 6c5d96c46a..7a88064b24 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/dod5015/messages/dod5015_zh_CN.properties @@ -1,8 +1,8 @@ -# Classified Records Capabilities -capability.group.classifiedRecords.title=\u5206\u7c7b\u7684\u8bb0\u5f55 -capability.UpdateClassificationDates.title=\u66f4\u65b0\u5206\u7c7b\u65e5\u671f -capability.CreateModifyDestroyClassificationGuides.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5206\u7c7b\u6307\u5357 -capability.UpgradeDowngradeAndDeclassifyRecords.title=\u8bb0\u5f55\u7684\u5347\u7ea7\u3001\u964d\u7ea7\u4ee5\u53ca\u53d6\u6d88\u5206\u7c7b -capability.UpdateExemptionCategories.title=\u66f4\u65b0\u8c41\u514d\u7c7b\u522b -capability.MapClassificationGuideMetadata.title=\u6620\u5c04\u5206\u7c7b\u6307\u5357\u5143\u6570\u636e +# Classified Records Capabilities +capability.group.classifiedRecords.title=\u5206\u7c7b\u7684\u8bb0\u5f55 +capability.UpdateClassificationDates.title=\u66f4\u65b0\u5206\u7c7b\u65e5\u671f +capability.CreateModifyDestroyClassificationGuides.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5206\u7c7b\u6307\u5357 +capability.UpgradeDowngradeAndDeclassifyRecords.title=\u8bb0\u5f55\u7684\u5347\u7ea7\u3001\u964d\u7ea7\u4ee5\u53ca\u53d6\u6d88\u5206\u7c7b +capability.UpdateExemptionCategories.title=\u66f4\u65b0\u8c41\u514d\u7c7b\u522b +capability.MapClassificationGuideMetadata.title=\u6620\u5c04\u5206\u7c7b\u6307\u5357\u5143\u6570\u636e capability.CreateModifyDestroyTimeframes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u65f6\u95f4\u8303\u56f4 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml index 7e0ed6021b..bb492b5e0a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml @@ -1,285 +1,285 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.repo.security.permissions.impl.ExtendedPermissionService - - - - - - - - - - - - - - - - - - - - - org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.getAllPermission=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.getPermissions=ACL_NODE.0.sys:base.ReadPermissions - org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=ACL_NODE.0.sys:base.ReadPermissions - org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.hasPermission=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.getReaders=ACL_METHOD.ROLE_ADMINISTRATOR - org.alfresco.repo.security.permissions.impl.ExtendedPermissionService.getWriters=ACL_METHOD.ROLE_ADMINISTRATOR - org.alfresco.repo.security.permissions.impl.ExtendedPermissionService.getReadersAndWriters=ACL_METHOD.ROLE_ADMINISTRATOR - org.alfresco.service.cmr.security.PermissionService.deletePermissions=ACL_NODE.0.sys:base.ChangePermissions - org.alfresco.service.cmr.security.PermissionService.deletePermission=ACL_NODE.0.sys:base.ChangePermissions - org.alfresco.service.cmr.security.PermissionService.setPermission=ACL_NODE.0.sys:base.ChangePermissions - org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=ACL_NODE.0.sys:base.ChangePermissions - org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=ACL_ALLOW - org.alfresco.service.cmr.security.PermissionService.clearPermission=ACL_NODE.0.sys:base.ChangePermissions - org.alfresco.service.cmr.security.PermissionService.*=ACL_DENY - - - - - - - - - - - - - - org.alfresco.writersTransactionalCache - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${security.anyDenyDenies} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${rm.autocompletesuggestion.maxsuggestions.node} - - - - - - - - - ${rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes} - - - - - - - ${rm.autocompletesuggestion.maxsuggestions.date} - - - - - - - - - - - - - - - - - - - - - - false - - - - - ${rm.rule.runasadmin} - - - - - - - - - - - org.alfresco.repo.forms.FormService.getForm=ACL_ALLOW - org.alfresco.repo.forms.FormService.saveForm=ACL_ALLOW - org.alfresco.repo.forms.FormService.*=ACL_DENY - - - - - - - search - - - - - - - - - - - - ${spaces.store} - - - - - - true - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.repo.security.permissions.impl.ExtendedPermissionService + + + + + + + + + + + + + + + + + + + + + org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.getAllPermission=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.getPermissions=ACL_NODE.0.sys:base.ReadPermissions + org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=ACL_NODE.0.sys:base.ReadPermissions + org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.hasPermission=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.getReaders=ACL_METHOD.ROLE_ADMINISTRATOR + org.alfresco.repo.security.permissions.impl.ExtendedPermissionService.getWriters=ACL_METHOD.ROLE_ADMINISTRATOR + org.alfresco.repo.security.permissions.impl.ExtendedPermissionService.getReadersAndWriters=ACL_METHOD.ROLE_ADMINISTRATOR + org.alfresco.service.cmr.security.PermissionService.deletePermissions=ACL_NODE.0.sys:base.ChangePermissions + org.alfresco.service.cmr.security.PermissionService.deletePermission=ACL_NODE.0.sys:base.ChangePermissions + org.alfresco.service.cmr.security.PermissionService.setPermission=ACL_NODE.0.sys:base.ChangePermissions + org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=ACL_NODE.0.sys:base.ChangePermissions + org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=ACL_ALLOW + org.alfresco.service.cmr.security.PermissionService.clearPermission=ACL_NODE.0.sys:base.ChangePermissions + org.alfresco.service.cmr.security.PermissionService.*=ACL_DENY + + + + + + + + + + + + + + org.alfresco.writersTransactionalCache + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${security.anyDenyDenies} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${rm.autocompletesuggestion.maxsuggestions.node} + + + + + + + + + ${rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes} + + + + + + + ${rm.autocompletesuggestion.maxsuggestions.date} + + + + + + + + + + + + + + + + + + + + + + false + + + + + ${rm.rule.runasadmin} + + + + + + + + + + + org.alfresco.repo.forms.FormService.getForm=ACL_ALLOW + org.alfresco.repo.forms.FormService.saveForm=ACL_ALLOW + org.alfresco.repo.forms.FormService.*=ACL_DENY + + + + + + + search + + + + + + + + + + + + ${spaces.store} + + + + + + true + + + \ No newline at end of file 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 83e724394e..dbdb7913fc 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,59 +1,59 @@ -# -# Warnings -# -log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn -log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn - -# -# Module patches -# -log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info - -# -# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be -# removed to enhance performance. -# -log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=debug - -# -# RM permission debug -# -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider=debug -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug - -# -# RM Audit service debug -# -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug - -# -# Job debug -# -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug - -# -# Script logging level -# -log4j.logger.org.alfresco.repo.jscript.ScriptLogger=error - -# -# Behaviour debug -# -log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=info -log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=info - -# -# Patch debug -# -log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info -# -# RM Audit service debug -# -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug - -# -# Job debug -# -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug +# +# Warnings +# +log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn +log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn + +# +# Module patches +# +log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info + +# +# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be +# removed to enhance performance. +# +log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=debug + +# +# RM permission debug +# +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider=debug +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug + +# +# RM Audit service debug +# +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug + +# +# Job debug +# +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug + +# +# Script logging level +# +log4j.logger.org.alfresco.repo.jscript.ScriptLogger=error + +# +# Behaviour debug +# +log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=info +log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=info + +# +# Patch debug +# +log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info +# +# RM Audit service debug +# +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug + +# +# Job debug +# +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties index 5c6a7d4daf..aa68c0a14d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=The records management action {0} has not been defined. -rm.action.no-implicit-noderef=The records management action {0} couldn't be performed, because the action implementation doesn't provide an implicit nodeRef. -rm.action.record-not-declared=The disposition action {0} couldn't be performed, because the record isn't complete. (actionedUponNodeRef={1}) -rm.action.expected-record-level=The disposition action {0} couldn't be performed, because this isn't a record. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=The disposition action {0} couldn't be performed, because not all the records in the record folder are complete. (actionedUponNodeRef={1}) -rm.action.not-eligible=The disposition action {0} couldn't be performed, because the next disposition action on the record or record folder isn't eligible. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=The disposition action {0} couldn't be performed, because no disposition instructions could be found. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=The disposition action {0} couldn't be performed, because there's no available disposition life-cycle set. (nodeRef={1}) -rm.action.next-disp-not-set=The disposition action {0} couldn't be performed, because the next disposition action isn't set. (nodeRef={1}) -rm.action.not-next-disp=The disposition action {0} couldn't be performed, because this isn't the next disposition action for this record or record folder. (nodeRef={1}) -rm.action.not-record-folder=The disposition action {0} couldn't be performed, because this isn't a record folder. (nodeRef={1}) -rm.action.actioned-upon-not-record=The action {0} can't be performed because this isn't a record. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=The custom type can't be applied because it's not recognised. (customAspect={0}) -rm.action.event-no-disp-lc=The event {0} can't be completed, because it's not defined on the disposition lifecycle. -rm.action.undeclared-only-records=Only records can be completed. (nodeRef={0}) -rm.action.no-declare-mand-prop=The record can't be completed, because not all the records mandatory properties have been set. -rm.action.ghosted-prop-update=The content properties of a previously destroyed record can't be updated. -rm.action.valid-date-disp-asof=The disposition action as of date must be a valid date. -rm.action.disp-asof-lifecycle-applied=The disposition as of date for a record or record folder which has a lifecycle applied can't be edited. -rm.action.hold-edit-reason-none=The hold reason can't be edited, because no reason has been given. -rm.action.hold-edit-type=The hold reason can't be edited, because actioned upon node is not of type {0}. (nodeRef={1}) -rm.action.specify-avlid-date=The review as of date must be a valid date. -rm.action.review-details-only=Only the review details of vital records can be edited. -rm.action.freeze-no-reason=A record can't be hold without a reason. -rm.action.freeze-only-records-folders=Only records or record folders can be hold. -rm.action.no-open-record-folder=The record folder couldn't be opened because it's not defined as a record folder. (actionedUponNodeRef={0}) -rm.action.not-hold-type=The hold couldn't be relinquished, because the node isn't of type {0}. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=The mimetype message couldn't be read, because {0}. -rm.action.email-declared=The email couldn't be split, because the record is complete. (actionedUponNodeRef={0}) -rm.action.email-not-record=The email couldn't be split, because the node isn't a record. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=Couldn't create custom child association. -rm.action.node-already-transfer=The node is already being transferred. -rm.action.node-not-transfer=The node is not a transfer object. -rm.action.undo-not-last=The cut off can't be undone, because the last disposition action was not cut off. -rm.action.records_only_undeclared=Only records can be completed. -rm.action.event-not-undone=The event {0} can't be undone, because it's not defined on the disposition lifecycle. -rm.action.node-not-record-category=The disposition schedule could not be created, because the actioned upon node ({0}) was not a record category. -rm.action.parameter-not-supplied=The parameter ''{0}'' has not been supplied. +rm.action.not-defined=The records management action {0} has not been defined. +rm.action.no-implicit-noderef=The records management action {0} couldn't be performed, because the action implementation doesn't provide an implicit nodeRef. +rm.action.record-not-declared=The disposition action {0} couldn't be performed, because the record isn't complete. (actionedUponNodeRef={1}) +rm.action.expected-record-level=The disposition action {0} couldn't be performed, because this isn't a record. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=The disposition action {0} couldn't be performed, because not all the records in the record folder are complete. (actionedUponNodeRef={1}) +rm.action.not-eligible=The disposition action {0} couldn't be performed, because the next disposition action on the record or record folder isn't eligible. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=The disposition action {0} couldn't be performed, because no disposition instructions could be found. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=The disposition action {0} couldn't be performed, because there's no available disposition life-cycle set. (nodeRef={1}) +rm.action.next-disp-not-set=The disposition action {0} couldn't be performed, because the next disposition action isn't set. (nodeRef={1}) +rm.action.not-next-disp=The disposition action {0} couldn't be performed, because this isn't the next disposition action for this record or record folder. (nodeRef={1}) +rm.action.not-record-folder=The disposition action {0} couldn't be performed, because this isn't a record folder. (nodeRef={1}) +rm.action.actioned-upon-not-record=The action {0} can't be performed because this isn't a record. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=The custom type can't be applied because it's not recognised. (customAspect={0}) +rm.action.event-no-disp-lc=The event {0} can't be completed, because it's not defined on the disposition lifecycle. +rm.action.undeclared-only-records=Only records can be completed. (nodeRef={0}) +rm.action.no-declare-mand-prop=The record can't be completed, because not all the records mandatory properties have been set. +rm.action.ghosted-prop-update=The content properties of a previously destroyed record can't be updated. +rm.action.valid-date-disp-asof=The disposition action as of date must be a valid date. +rm.action.disp-asof-lifecycle-applied=The disposition as of date for a record or record folder which has a lifecycle applied can't be edited. +rm.action.hold-edit-reason-none=The hold reason can't be edited, because no reason has been given. +rm.action.hold-edit-type=The hold reason can't be edited, because actioned upon node is not of type {0}. (nodeRef={1}) +rm.action.specify-avlid-date=The review as of date must be a valid date. +rm.action.review-details-only=Only the review details of vital records can be edited. +rm.action.freeze-no-reason=A record can't be hold without a reason. +rm.action.freeze-only-records-folders=Only records or record folders can be hold. +rm.action.no-open-record-folder=The record folder couldn't be opened because it's not defined as a record folder. (actionedUponNodeRef={0}) +rm.action.not-hold-type=The hold couldn't be relinquished, because the node isn't of type {0}. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=The mimetype message couldn't be read, because {0}. +rm.action.email-declared=The email couldn't be split, because the record is complete. (actionedUponNodeRef={0}) +rm.action.email-not-record=The email couldn't be split, because the node isn't a record. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=Couldn't create custom child association. +rm.action.node-already-transfer=The node is already being transferred. +rm.action.node-not-transfer=The node is not a transfer object. +rm.action.undo-not-last=The cut off can't be undone, because the last disposition action was not cut off. +rm.action.records_only_undeclared=Only records can be completed. +rm.action.event-not-undone=The event {0} can't be undone, because it's not defined on the disposition lifecycle. +rm.action.node-not-record-category=The disposition schedule could not be created, because the actioned upon node ({0}) was not a record category. +rm.action.parameter-not-supplied=The parameter ''{0}'' has not been supplied. rm.action.delete-not-hold-type=The hold couldn't be deleted, because the node isn't of type {0}. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_de.properties index 5574216e55..354d508cf5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_de.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=Die Records Management Aktion {0} wurde nicht definiert. -rm.action.no-implicit-noderef=Die Records Management Aktion {0} konnte nicht durchgef\u00fchrt werden, da bei der Implementierung der Aktion keine implizite nodeRef bereitgestellt wird. -rm.action.record-not-declared=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da der Record unvollst\u00e4ndig ist. (actionedUponNodeRef={1}) -rm.action.expected-record-level=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record handelt. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da nicht alle Records im Record-Ordner abgeschlossen sind. (actionedUponNodeRef={1}) -rm.action.not-eligible=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da die n\u00e4chste Entsorgungsaktion f\u00fcr den Record bzw. den Record-Ordner nicht geeignet ist. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da keine Entsorgungsanweisungen gefunden wurden. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da kein verf\u00fcgbarer Entsorgungszyklus festgelegt wurde. (nodeRef={1}) -rm.action.next-disp-not-set=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da keine folgende Entsorgungsaktion festgelegt wurde. (nodeRef={1}) -rm.action.not-next-disp=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um die n\u00e4chste Entsorgungsaktion f\u00fcr den Record bzw. den Record-Ordner handelt. (nodeRef={1}) -rm.action.not-record-folder=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record-Ordner handelt. (nodeRef={1}) -rm.action.actioned-upon-not-record=Die Aktion {0} kann nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record handelt. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=Der benutzerdefinierte Typ kann nicht angewendet werden, da er nicht erkannt wird. (customAspect={0}) -rm.action.event-no-disp-lc=Das Ereignis {0} kann nicht abgeschlossen werden, da es nicht im Entsorgungszyklus definiert ist. -rm.action.undeclared-only-records=Nur Records k\u00f6nnen abgeschlossen werden. (nodeRef={0}) -rm.action.no-declare-mand-prop=Der Record kann nicht abgeschlossen werden, da nicht alle f\u00fcr die Records erforderlichen Eigenschaften festgelegt wurden. -rm.action.ghosted-prop-update=Die Inhaltseigenschaften eines zuvor vernichteten Record k\u00f6nnen nicht aktualisiert werden. -rm.action.valid-date-disp-asof=Das Startdatum der Entsorgungsaktion muss ein g\u00fcltiges Datum sein. -rm.action.disp-asof-lifecycle-applied=Das Startdatum der Entsorgung f\u00fcr einen Record oder Record-Ordner mit festgelegtem Entsorgungszyklus kann nicht bearbeitet werden. -rm.action.hold-edit-reason-none=Der Sperrgrund kann nicht bearbeitet werden, da kein Grund angegeben wurde. -rm.action.hold-edit-type=Der Sperrgrund kann nicht bearbeitet werden, da der bearbeitete Knoten nicht vom Typ {0} ist. (nodeRef={1}) -rm.action.specify-avlid-date=Das Startdatum der \u00dcberpr\u00fcfung muss ein g\u00fcltiges Datum sein. -rm.action.review-details-only=Nur die \u00dcberpr\u00fcfungsdetails besonders relevanter Records k\u00f6nnen bearbeitet werden. -rm.action.freeze-no-reason=Ein Record kann nicht ohne Grund gesperrt werden. -rm.action.freeze-only-records-folders=Nur Records oder Record-Ordner k\u00f6nnen gesperrt werden. -rm.action.no-open-record-folder=Der Record-Ordner konnte nicht ge\u00f6ffnet werden, da er nicht als Record-Ordner definiert ist. (actionedUponNodeRef={0}) -rm.action.not-hold-type=Die Sperrung konnte nicht aufgehoben werden, da der Knoten nicht vom Typ {0} ist. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=Die MimeType-Nachricht konnte nicht gelesen werden, da {0}. -rm.action.email-declared=Die E-Mail konnte nicht geteilt werden, da der Record abgeschlossen ist. (actionedUponNodeRef={0}) -rm.action.email-not-record=Die E-Mail konnte nicht geteilt werden, da der Knoten kein Record ist. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=Benutzerdefinierte Kindzuordnung konnte nicht erstellt werden. -rm.action.node-already-transfer=Der Knoten wird bereits \u00fcbertragen. -rm.action.node-not-transfer=Der Knoten ist kein \u00dcbertragungsobjekt. -rm.action.undo-not-last=Trennung kann nicht aufgehoben werden, da die letzte Entsorgungsaktion nicht getrennt wurde. -rm.action.records_only_undeclared=Nur Records k\u00f6nnen abgeschlossen werden. -rm.action.event-not-undone=Das Ereignis {0} kann nicht r\u00fcckg\u00e4ngig gemacht werden, da es nicht im Entsorgungszyklus definiert ist. -rm.action.node-not-record-category=Der Entsorgungsplan konnte nicht erstellt, werden, da es sich bei dem bearbeiteten Knoten ({0}) nicht um eine Record-Kategorie gehandelt hat. -rm.action.parameter-not-supplied=Der Parameter ''{0}'' wurde nicht angegeben. +rm.action.not-defined=Die Records Management Aktion {0} wurde nicht definiert. +rm.action.no-implicit-noderef=Die Records Management Aktion {0} konnte nicht durchgef\u00fchrt werden, da bei der Implementierung der Aktion keine implizite nodeRef bereitgestellt wird. +rm.action.record-not-declared=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da der Record unvollst\u00e4ndig ist. (actionedUponNodeRef={1}) +rm.action.expected-record-level=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record handelt. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da nicht alle Records im Record-Ordner abgeschlossen sind. (actionedUponNodeRef={1}) +rm.action.not-eligible=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da die n\u00e4chste Entsorgungsaktion f\u00fcr den Record bzw. den Record-Ordner nicht geeignet ist. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da keine Entsorgungsanweisungen gefunden wurden. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da kein verf\u00fcgbarer Entsorgungszyklus festgelegt wurde. (nodeRef={1}) +rm.action.next-disp-not-set=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da keine folgende Entsorgungsaktion festgelegt wurde. (nodeRef={1}) +rm.action.not-next-disp=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um die n\u00e4chste Entsorgungsaktion f\u00fcr den Record bzw. den Record-Ordner handelt. (nodeRef={1}) +rm.action.not-record-folder=Die Entsorgungsaktion {0} konnte nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record-Ordner handelt. (nodeRef={1}) +rm.action.actioned-upon-not-record=Die Aktion {0} kann nicht durchgef\u00fchrt werden, da es sich hierbei nicht um einen Record handelt. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=Der benutzerdefinierte Typ kann nicht angewendet werden, da er nicht erkannt wird. (customAspect={0}) +rm.action.event-no-disp-lc=Das Ereignis {0} kann nicht abgeschlossen werden, da es nicht im Entsorgungszyklus definiert ist. +rm.action.undeclared-only-records=Nur Records k\u00f6nnen abgeschlossen werden. (nodeRef={0}) +rm.action.no-declare-mand-prop=Der Record kann nicht abgeschlossen werden, da nicht alle f\u00fcr die Records erforderlichen Eigenschaften festgelegt wurden. +rm.action.ghosted-prop-update=Die Inhaltseigenschaften eines zuvor vernichteten Record k\u00f6nnen nicht aktualisiert werden. +rm.action.valid-date-disp-asof=Das Startdatum der Entsorgungsaktion muss ein g\u00fcltiges Datum sein. +rm.action.disp-asof-lifecycle-applied=Das Startdatum der Entsorgung f\u00fcr einen Record oder Record-Ordner mit festgelegtem Entsorgungszyklus kann nicht bearbeitet werden. +rm.action.hold-edit-reason-none=Der Sperrgrund kann nicht bearbeitet werden, da kein Grund angegeben wurde. +rm.action.hold-edit-type=Der Sperrgrund kann nicht bearbeitet werden, da der bearbeitete Knoten nicht vom Typ {0} ist. (nodeRef={1}) +rm.action.specify-avlid-date=Das Startdatum der \u00dcberpr\u00fcfung muss ein g\u00fcltiges Datum sein. +rm.action.review-details-only=Nur die \u00dcberpr\u00fcfungsdetails besonders relevanter Records k\u00f6nnen bearbeitet werden. +rm.action.freeze-no-reason=Ein Record kann nicht ohne Grund gesperrt werden. +rm.action.freeze-only-records-folders=Nur Records oder Record-Ordner k\u00f6nnen gesperrt werden. +rm.action.no-open-record-folder=Der Record-Ordner konnte nicht ge\u00f6ffnet werden, da er nicht als Record-Ordner definiert ist. (actionedUponNodeRef={0}) +rm.action.not-hold-type=Die Sperrung konnte nicht aufgehoben werden, da der Knoten nicht vom Typ {0} ist. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=Die MimeType-Nachricht konnte nicht gelesen werden, da {0}. +rm.action.email-declared=Die E-Mail konnte nicht geteilt werden, da der Record abgeschlossen ist. (actionedUponNodeRef={0}) +rm.action.email-not-record=Die E-Mail konnte nicht geteilt werden, da der Knoten kein Record ist. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=Benutzerdefinierte Kindzuordnung konnte nicht erstellt werden. +rm.action.node-already-transfer=Der Knoten wird bereits \u00fcbertragen. +rm.action.node-not-transfer=Der Knoten ist kein \u00dcbertragungsobjekt. +rm.action.undo-not-last=Trennung kann nicht aufgehoben werden, da die letzte Entsorgungsaktion nicht getrennt wurde. +rm.action.records_only_undeclared=Nur Records k\u00f6nnen abgeschlossen werden. +rm.action.event-not-undone=Das Ereignis {0} kann nicht r\u00fcckg\u00e4ngig gemacht werden, da es nicht im Entsorgungszyklus definiert ist. +rm.action.node-not-record-category=Der Entsorgungsplan konnte nicht erstellt, werden, da es sich bei dem bearbeiteten Knoten ({0}) nicht um eine Record-Kategorie gehandelt hat. +rm.action.parameter-not-supplied=Der Parameter ''{0}'' wurde nicht angegeben. rm.action.delete-not-hold-type=Der Sperrbereich konnte nicht gel\u00f6scht werden, da der Knoten nicht vom Typ {0} ist. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_es.properties index 75051cf559..8a31c7b8bd 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_es.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=No se ha definido la acci\u00f3n de gesti\u00f3n de documentos de archivo ''{0}''. -rm.action.no-implicit-noderef=No se pudo realizar la acci\u00f3n de gesti\u00f3n de documentos de archivo ''{0}'' porque la implementaci\u00f3n de la acci\u00f3n no proporciona ning\u00fan nodeRef impl\u00edcito. -rm.action.record-not-declared=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque el documento de archivo no est\u00e1 completo. (actionedUponNodeRef={1}) -rm.action.expected-record-level=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es un documento de archivo. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no todos los documentos de archivo de la carpeta de documentos de archivo est\u00e1n completos. (actionedUponNodeRef={1}) -rm.action.not-eligible=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque la pr\u00f3xima acci\u00f3n de disposici\u00f3n del documento de archivo o de la carpeta de documentos de archivo no re\u00fane los requisitos. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no se ha encontrado ninguna instrucci\u00f3n de disposici\u00f3n. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no hay ning\u00fan ciclo de vida de disposici\u00f3n disponible. (nodeRef={1}) -rm.action.next-disp-not-set=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque la pr\u00f3xima acci\u00f3n de disposici\u00f3n no est\u00e1 definida. (nodeRef={1}) -rm.action.not-next-disp=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es la pr\u00f3xima acci\u00f3n de disposici\u00f3n para este documento de archivo o carpeta de documentos de archivo. (nodeRef={1}) -rm.action.not-record-folder=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es una carpeta de documentos de archivo. (nodeRef={1}) -rm.action.actioned-upon-not-record=No se puede realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es un documento de archivo. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=El tipo personalizado no puede aplicarse porque no se reconoce. (customAspect={0}) -rm.action.event-no-disp-lc=No se puede completar el evento ''{0}'' porque no est\u00e1 definido en el ciclo de vida de la disposici\u00f3n. -rm.action.undeclared-only-records=Solo se pueden completar los documentos de archivo. (nodeRef={0}) -rm.action.no-declare-mand-prop=No se pueden completar los documentos de archivo porque no se han definido todas las propiedades obligatorias de los documentos de archivo. -rm.action.ghosted-prop-update=Las propiedades del contenido de un documento de archivo destruido anteriormente no se pueden actualizar. -rm.action.valid-date-disp-asof=La fecha de inicio de la acci\u00f3n de disposici\u00f3n debe ser una fecha v\u00e1lida. -rm.action.disp-asof-lifecycle-applied=La fecha de inicio de la disposici\u00f3n de un documento de archivo o carpeta de documentos de archivo que tiene un ciclo de vida aplicado no puede editarse. -rm.action.hold-edit-reason-none=La raz\u00f3n de bloqueo no puede editarse porque no se ha dado ninguna raz\u00f3n. -rm.action.hold-edit-type=La raz\u00f3n de bloqueo no puede editarse porque la acci\u00f3n en el nodo no es de tipo ''{0}''. (nodeRef={1}) -rm.action.specify-avlid-date=La fecha de inicio de la revisi\u00f3n debe ser una fecha v\u00e1lida. -rm.action.review-details-only=Solo se pueden editar los detalles de revisi\u00f3n de los documentos de archivo vitales. -rm.action.freeze-no-reason=No se puede congelar un documento de archivo sin ninguna raz\u00f3n. -rm.action.freeze-only-records-folders=Solo los documentos de archivo o carpetas de documentos de archivo pueden congelarse. -rm.action.no-open-record-folder=No se pudo abrir la carpeta de documentos de archivo porque no est\u00e1 definida como una carpeta de documentos de archivo. (actionedUponNodeRef={0}) -rm.action.not-hold-type=El bloqueo no puede eliminarse porque el nodo no es de tipo ''{0}''. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=No se pudo leer el mensaje de tipo MIME porque ''{0}''. -rm.action.email-declared=No se pudo dividir el correo electr\u00f3nico porque el documento de archivo est\u00e1 completo. (actionedUponNodeRef={0}) -rm.action.email-not-record=No se pudo dividir el correo electr\u00f3nico porque el nodo no es un documento de archivo. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=No se pudo crear la asociaci\u00f3n secundaria personalizada. -rm.action.node-already-transfer=El nodo ya se est\u00e1 transfiriendo. -rm.action.node-not-transfer=El nodo no es un objeto de transferencia. -rm.action.undo-not-last=La interrupci\u00f3n no puede deshacerse porque la \u00faltima acci\u00f3n de disposici\u00f3n no se interrumpi\u00f3. -rm.action.records_only_undeclared=Solo se pueden completar los documentos de archivo. -rm.action.event-not-undone=No se puede deshacer el evento ''{0}'' porque no est\u00e1 definido en el ciclo de vida de la disposici\u00f3n. -rm.action.node-not-record-category=La planificaci\u00f3n de disposici\u00f3n no se ha creado porque la acci\u00f3n en el nodo de tipo (''{0}'') no era una categor\u00eda de documento de archivo. -rm.action.parameter-not-supplied=El par\u00e1metro ''{0}'' no se ha suministrado. +rm.action.not-defined=No se ha definido la acci\u00f3n de gesti\u00f3n de documentos de archivo ''{0}''. +rm.action.no-implicit-noderef=No se pudo realizar la acci\u00f3n de gesti\u00f3n de documentos de archivo ''{0}'' porque la implementaci\u00f3n de la acci\u00f3n no proporciona ning\u00fan nodeRef impl\u00edcito. +rm.action.record-not-declared=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque el documento de archivo no est\u00e1 completo. (actionedUponNodeRef={1}) +rm.action.expected-record-level=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es un documento de archivo. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no todos los documentos de archivo de la carpeta de documentos de archivo est\u00e1n completos. (actionedUponNodeRef={1}) +rm.action.not-eligible=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque la pr\u00f3xima acci\u00f3n de disposici\u00f3n del documento de archivo o de la carpeta de documentos de archivo no re\u00fane los requisitos. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no se ha encontrado ninguna instrucci\u00f3n de disposici\u00f3n. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no hay ning\u00fan ciclo de vida de disposici\u00f3n disponible. (nodeRef={1}) +rm.action.next-disp-not-set=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque la pr\u00f3xima acci\u00f3n de disposici\u00f3n no est\u00e1 definida. (nodeRef={1}) +rm.action.not-next-disp=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es la pr\u00f3xima acci\u00f3n de disposici\u00f3n para este documento de archivo o carpeta de documentos de archivo. (nodeRef={1}) +rm.action.not-record-folder=No se pudo realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es una carpeta de documentos de archivo. (nodeRef={1}) +rm.action.actioned-upon-not-record=No se puede realizar la acci\u00f3n de disposici\u00f3n ''{0}'' porque no es un documento de archivo. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=El tipo personalizado no puede aplicarse porque no se reconoce. (customAspect={0}) +rm.action.event-no-disp-lc=No se puede completar el evento ''{0}'' porque no est\u00e1 definido en el ciclo de vida de la disposici\u00f3n. +rm.action.undeclared-only-records=Solo se pueden completar los documentos de archivo. (nodeRef={0}) +rm.action.no-declare-mand-prop=No se pueden completar los documentos de archivo porque no se han definido todas las propiedades obligatorias de los documentos de archivo. +rm.action.ghosted-prop-update=Las propiedades del contenido de un documento de archivo destruido anteriormente no se pueden actualizar. +rm.action.valid-date-disp-asof=La fecha de inicio de la acci\u00f3n de disposici\u00f3n debe ser una fecha v\u00e1lida. +rm.action.disp-asof-lifecycle-applied=La fecha de inicio de la disposici\u00f3n de un documento de archivo o carpeta de documentos de archivo que tiene un ciclo de vida aplicado no puede editarse. +rm.action.hold-edit-reason-none=La raz\u00f3n de bloqueo no puede editarse porque no se ha dado ninguna raz\u00f3n. +rm.action.hold-edit-type=La raz\u00f3n de bloqueo no puede editarse porque la acci\u00f3n en el nodo no es de tipo ''{0}''. (nodeRef={1}) +rm.action.specify-avlid-date=La fecha de inicio de la revisi\u00f3n debe ser una fecha v\u00e1lida. +rm.action.review-details-only=Solo se pueden editar los detalles de revisi\u00f3n de los documentos de archivo vitales. +rm.action.freeze-no-reason=No se puede congelar un documento de archivo sin ninguna raz\u00f3n. +rm.action.freeze-only-records-folders=Solo los documentos de archivo o carpetas de documentos de archivo pueden congelarse. +rm.action.no-open-record-folder=No se pudo abrir la carpeta de documentos de archivo porque no est\u00e1 definida como una carpeta de documentos de archivo. (actionedUponNodeRef={0}) +rm.action.not-hold-type=El bloqueo no puede eliminarse porque el nodo no es de tipo ''{0}''. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=No se pudo leer el mensaje de tipo MIME porque ''{0}''. +rm.action.email-declared=No se pudo dividir el correo electr\u00f3nico porque el documento de archivo est\u00e1 completo. (actionedUponNodeRef={0}) +rm.action.email-not-record=No se pudo dividir el correo electr\u00f3nico porque el nodo no es un documento de archivo. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=No se pudo crear la asociaci\u00f3n secundaria personalizada. +rm.action.node-already-transfer=El nodo ya se est\u00e1 transfiriendo. +rm.action.node-not-transfer=El nodo no es un objeto de transferencia. +rm.action.undo-not-last=La interrupci\u00f3n no puede deshacerse porque la \u00faltima acci\u00f3n de disposici\u00f3n no se interrumpi\u00f3. +rm.action.records_only_undeclared=Solo se pueden completar los documentos de archivo. +rm.action.event-not-undone=No se puede deshacer el evento ''{0}'' porque no est\u00e1 definido en el ciclo de vida de la disposici\u00f3n. +rm.action.node-not-record-category=La planificaci\u00f3n de disposici\u00f3n no se ha creado porque la acci\u00f3n en el nodo de tipo (''{0}'') no era una categor\u00eda de documento de archivo. +rm.action.parameter-not-supplied=El par\u00e1metro ''{0}'' no se ha suministrado. rm.action.delete-not-hold-type=El bloqueo no puede eliminarse porque el nodo no es de tipo {0}. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_fr.properties index 4240d1dbb5..747e53b0f4 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_fr.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=L''action de gestion des archives {0} n''a pas \u00e9t\u00e9 d\u00e9finie. -rm.action.no-implicit-noderef=L''action de gestion des archives {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''impl\u00e9mentation de l''action ne fournit pas une r\u00e9f\u00e9rence de n\u0153ud implicite. -rm.action.record-not-declared=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car le document d''archives n''est pas complet. (actionedUponNodeRef={1}) -rm.action.expected-record-level=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas un document d''archives. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car les documents d''archives dans le dossier d''archives ne sont pas tous complets. (actionedUponNodeRef={1}) -rm.action.not-eligible=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''\u00e9tape suivante du d\u00e9lai de conservation sur le document d''archives ou le dossier d''archives n''est pas \u00e9ligible. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car aucune instruction de disposition n''a \u00e9t\u00e9 trouv\u00e9e. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car aucun ensemble de cycles de vie de disposition n''est disponible. (nodeRef={1}) -rm.action.next-disp-not-set=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''\u00e9tape suivante du d\u00e9lai de conservation n''est pas d\u00e9finie. (nodeRef={1}) -rm.action.not-next-disp=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas de l''\u00e9tape suivante du d\u00e9lai de conservation pour ce document d''archives ou ce dossier d''archives. (nodeRef={1}) -rm.action.not-record-folder=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas d''un dossier d''archives. (nodeRef={1}) -rm.action.actioned-upon-not-record=L''action {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas d''un document d''archives. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=Le type personnalis\u00e9 ne peut pas \u00eatre appliqu\u00e9, car il n''est pas reconnu. (customAspect={0}) -rm.action.event-no-disp-lc=L''\u00e9v\u00e9nement {0} ne peut pas \u00eatre compl\u00e9t\u00e9, car il n''est pas d\u00e9fini dans les \u00e9tapes du d\u00e9lai de conservation. -rm.action.undeclared-only-records=Seuls les documents d''archives peuvent \u00eatre compl\u00e9t\u00e9s. (nodeRef={0}) -rm.action.no-declare-mand-prop=Le document d'archives ne peut pas \u00eatre compl\u00e9t\u00e9, car les propri\u00e9t\u00e9s obligatoires des documents d'archives ne sont pas toutes d\u00e9finies. -rm.action.ghosted-prop-update=Les propri\u00e9t\u00e9s de contenu d'un document d'archives d\u00e9truit ne peuvent pas \u00eatre mises \u00e0 jour. -rm.action.valid-date-disp-asof=La date de d\u00e9but d'action de disposition doit \u00eatre une date valide. -rm.action.disp-asof-lifecycle-applied=La date de d\u00e9but d'action de disposition d'un document d'archives ou d'un dossier d'archives auquel est appliqu\u00e9 un cycle de vie ne peut pas \u00eatre modifi\u00e9e. -rm.action.hold-edit-reason-none=Le motif de la suspension ne peut pas \u00eatre modifi\u00e9, car aucun motif n'a \u00e9t\u00e9 fourni. -rm.action.hold-edit-type=Le motif de la suspension ne peut pas \u00eatre modifi\u00e9, car l''action sur le n\u0153ud n''est pas de type {0}. (nodeRef={1}) -rm.action.specify-avlid-date=La date de d\u00e9but de la r\u00e9vision doit \u00eatre une date valide. -rm.action.review-details-only=Seules les informations de v\u00e9rification des documents d'archives essentiels peuvent \u00eatre modifi\u00e9es. -rm.action.freeze-no-reason=Un document d'archives ne peut pas \u00eatre suspendu sans motif. -rm.action.freeze-only-records-folders=Seuls des documents d'archives ou des dossiers d'archives peuvent \u00eatre suspendus. -rm.action.no-open-record-folder=Le dossier d''archives n''a pas pu \u00eatre ouvert, car il n''est pas d\u00e9fini comme dossier d''archives. (actionedUponNodeRef={0}) -rm.action.not-hold-type=La suspension n''a pas pu \u00eatre lev\u00e9e, car le n\u0153ud n''est pas de type {0}. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=Le message mimetype est illisible, car {0}. -rm.action.email-declared=L''e-mail ne peut pas \u00eatre partag\u00e9, car le document d''archives n''est pas complet. (actionedUponNodeRef={0}) -rm.action.email-not-record=L''e-mail n''a pas pu \u00eatre fractionn\u00e9, car le n\u0153ud n''est pas un document d''archives. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=Impossible de cr\u00e9er une association d'enfant personnalis\u00e9e. -rm.action.node-already-transfer=Le n\u0153ud est d\u00e9j\u00e0 en cours de transfert. -rm.action.node-not-transfer=Le n\u0153ud n'est pas un objet de transfert. -rm.action.undo-not-last=Impossible d'annuler le d\u00e9classement car la derni\u00e8re action de disposition n'\u00e9tait pas un d\u00e9classement. -rm.action.records_only_undeclared=Seuls les documents d'archives peuvent \u00eatre compl\u00e9t\u00e9s. -rm.action.event-not-undone=L''\u00e9v\u00e9nement {0} ne peut pas \u00eatre annul\u00e9, car il n''est pas d\u00e9fini dans les \u00e9tapes du d\u00e9lai de conservation. -rm.action.node-not-record-category=La r\u00e8gle de conservation n''a pu \u00eatre cr\u00e9\u00e9e car l''action sur le n\u0153ud ({0}) n''\u00e9tait pas une cat\u00e9gorie de document d''archives. -rm.action.parameter-not-supplied=Le param\u00e8tre ''{0}'' n''a pas \u00e9t\u00e9 fourni. +rm.action.not-defined=L''action de gestion des archives {0} n''a pas \u00e9t\u00e9 d\u00e9finie. +rm.action.no-implicit-noderef=L''action de gestion des archives {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''impl\u00e9mentation de l''action ne fournit pas une r\u00e9f\u00e9rence de n\u0153ud implicite. +rm.action.record-not-declared=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car le document d''archives n''est pas complet. (actionedUponNodeRef={1}) +rm.action.expected-record-level=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas un document d''archives. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car les documents d''archives dans le dossier d''archives ne sont pas tous complets. (actionedUponNodeRef={1}) +rm.action.not-eligible=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''\u00e9tape suivante du d\u00e9lai de conservation sur le document d''archives ou le dossier d''archives n''est pas \u00e9ligible. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car aucune instruction de disposition n''a \u00e9t\u00e9 trouv\u00e9e. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car aucun ensemble de cycles de vie de disposition n''est disponible. (nodeRef={1}) +rm.action.next-disp-not-set=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car l''\u00e9tape suivante du d\u00e9lai de conservation n''est pas d\u00e9finie. (nodeRef={1}) +rm.action.not-next-disp=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas de l''\u00e9tape suivante du d\u00e9lai de conservation pour ce document d''archives ou ce dossier d''archives. (nodeRef={1}) +rm.action.not-record-folder=L''action de disposition {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas d''un dossier d''archives. (nodeRef={1}) +rm.action.actioned-upon-not-record=L''action {0} n''a pas pu \u00eatre ex\u00e9cut\u00e9e, car il ne s''agit pas d''un document d''archives. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=Le type personnalis\u00e9 ne peut pas \u00eatre appliqu\u00e9, car il n''est pas reconnu. (customAspect={0}) +rm.action.event-no-disp-lc=L''\u00e9v\u00e9nement {0} ne peut pas \u00eatre compl\u00e9t\u00e9, car il n''est pas d\u00e9fini dans les \u00e9tapes du d\u00e9lai de conservation. +rm.action.undeclared-only-records=Seuls les documents d''archives peuvent \u00eatre compl\u00e9t\u00e9s. (nodeRef={0}) +rm.action.no-declare-mand-prop=Le document d'archives ne peut pas \u00eatre compl\u00e9t\u00e9, car les propri\u00e9t\u00e9s obligatoires des documents d'archives ne sont pas toutes d\u00e9finies. +rm.action.ghosted-prop-update=Les propri\u00e9t\u00e9s de contenu d'un document d'archives d\u00e9truit ne peuvent pas \u00eatre mises \u00e0 jour. +rm.action.valid-date-disp-asof=La date de d\u00e9but d'action de disposition doit \u00eatre une date valide. +rm.action.disp-asof-lifecycle-applied=La date de d\u00e9but d'action de disposition d'un document d'archives ou d'un dossier d'archives auquel est appliqu\u00e9 un cycle de vie ne peut pas \u00eatre modifi\u00e9e. +rm.action.hold-edit-reason-none=Le motif de la suspension ne peut pas \u00eatre modifi\u00e9, car aucun motif n'a \u00e9t\u00e9 fourni. +rm.action.hold-edit-type=Le motif de la suspension ne peut pas \u00eatre modifi\u00e9, car l''action sur le n\u0153ud n''est pas de type {0}. (nodeRef={1}) +rm.action.specify-avlid-date=La date de d\u00e9but de la r\u00e9vision doit \u00eatre une date valide. +rm.action.review-details-only=Seules les informations de v\u00e9rification des documents d'archives essentiels peuvent \u00eatre modifi\u00e9es. +rm.action.freeze-no-reason=Un document d'archives ne peut pas \u00eatre suspendu sans motif. +rm.action.freeze-only-records-folders=Seuls des documents d'archives ou des dossiers d'archives peuvent \u00eatre suspendus. +rm.action.no-open-record-folder=Le dossier d''archives n''a pas pu \u00eatre ouvert, car il n''est pas d\u00e9fini comme dossier d''archives. (actionedUponNodeRef={0}) +rm.action.not-hold-type=La suspension n''a pas pu \u00eatre lev\u00e9e, car le n\u0153ud n''est pas de type {0}. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=Le message mimetype est illisible, car {0}. +rm.action.email-declared=L''e-mail ne peut pas \u00eatre partag\u00e9, car le document d''archives n''est pas complet. (actionedUponNodeRef={0}) +rm.action.email-not-record=L''e-mail n''a pas pu \u00eatre fractionn\u00e9, car le n\u0153ud n''est pas un document d''archives. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=Impossible de cr\u00e9er une association d'enfant personnalis\u00e9e. +rm.action.node-already-transfer=Le n\u0153ud est d\u00e9j\u00e0 en cours de transfert. +rm.action.node-not-transfer=Le n\u0153ud n'est pas un objet de transfert. +rm.action.undo-not-last=Impossible d'annuler le d\u00e9classement car la derni\u00e8re action de disposition n'\u00e9tait pas un d\u00e9classement. +rm.action.records_only_undeclared=Seuls les documents d'archives peuvent \u00eatre compl\u00e9t\u00e9s. +rm.action.event-not-undone=L''\u00e9v\u00e9nement {0} ne peut pas \u00eatre annul\u00e9, car il n''est pas d\u00e9fini dans les \u00e9tapes du d\u00e9lai de conservation. +rm.action.node-not-record-category=La r\u00e8gle de conservation n''a pu \u00eatre cr\u00e9\u00e9e car l''action sur le n\u0153ud ({0}) n''\u00e9tait pas une cat\u00e9gorie de document d''archives. +rm.action.parameter-not-supplied=Le param\u00e8tre ''{0}'' n''a pas \u00e9t\u00e9 fourni. rm.action.delete-not-hold-type=La suspension n''a pas pu \u00eatre supprim\u00e9e, car le n\u0153ud n''est pas de type {0}. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_it.properties index 0f8f75422d..2349a06794 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_it.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=L''azione di gestione dei record {0} non \u00e8 stata definita. -rm.action.no-implicit-noderef=Non \u00e8 stato possibile eseguire l''azione di gestione dei record {0}, poich\u00e9 la sua implementazione non fornisce un nodeRef implicito. -rm.action.record-not-declared=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 il record \u00e8 incompleto. (actionedUponNodeRef={1}) -rm.action.expected-record-level=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce un record. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non tutti i record nella cartella di record sono completi. (actionedUponNodeRef={1}) -rm.action.not-eligible=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 l''azione di disposizione successiva sul record o sulla cartella di record non \u00e8 idonea. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non sono state trovate alcune istruzioni di disposizione. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non \u00e8 disponibile alcun set di ciclo di vita della disposizione. (nodeRef={1}) -rm.action.next-disp-not-set=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 l''azione di disposizione successiva non \u00e8 stata impostata. (nodeRef={1}) -rm.action.not-next-disp=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce l''azione di disposizione successiva per questo record o cartella di record. (nodeRef={1}) -rm.action.not-record-folder=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce una cartella di record. (nodeRef={1}) -rm.action.actioned-upon-not-record=Impossibile eseguire l''azione {0}, poich\u00e9 quest''ultima non costituisce un record. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=Impossibile applicare il tipo personalizzato poich\u00e9 non viene riconosciuto. (customAspect={0}) -rm.action.event-no-disp-lc=Impossibile completare l''evento {0}, poich\u00e9 non \u00e8 definito sul ciclo di vita della disposizione. -rm.action.undeclared-only-records=Solo i record possono essere completati. (nodeRef={0}) -rm.action.no-declare-mand-prop=Impossibile completare il record, poich\u00e9 non tutte le propriet\u00e0 obbligatorie di record sono state impostate. -rm.action.ghosted-prop-update=Impossibile aggiornare le propriet\u00e0 di contenuto di un record eliminato definitivamente in precedenza. -rm.action.valid-date-disp-asof=L'azione di disposizione in data deve corrispondere a una data valida. -rm.action.disp-asof-lifecycle-applied=Impossibile modificare la disposizione in data per un record o cartella di record per cui \u00e8 stato impostato un ciclo di vita. -rm.action.hold-edit-reason-none=Impossibile modificare il motivo sospensione, poich\u00e9 non \u00e8 stato fornito alcun motivo. -rm.action.hold-edit-type=Impossibile modificare il motivo sospensione, poich\u00e9 azionato su nodo non \u00e8 del tipo {0}. (nodeRef={1}) -rm.action.specify-avlid-date=La revisione in data deve corrispondere a una data valida. -rm.action.review-details-only=\u00c8 possibile modificare solamente i dettagli di revisione di record fondamentali. -rm.action.freeze-no-reason=Impossibile tenere in sospeso un record senza un motivo. -rm.action.freeze-only-records-folders=\u00c8 possibile tenere in sospeso solamente record o cartelle di record. -rm.action.no-open-record-folder=Non \u00e8 stato possibile aprire la cartella di record, poich\u00e9 non \u00e8 definita come cartella di record. (actionedUponNodeRef={0}) -rm.action.not-hold-type=Non \u00e8 stato possibile interrompere la sospensione, poich\u00e9 il nodo non \u00e8 del tipo {0}. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=Non \u00e8 stato possibile leggere il messaggio di tipo MIME, poich\u00e9 {0}. -rm.action.email-declared=Non \u00e8 stato possibile dividere l''e-mail, poich\u00e9 il record \u00e8 completo. (actionedUponNodeRef={0}) -rm.action.email-not-record=Non \u00e8 stato possibile dividere l''e-mail, poich\u00e9 il nodo non costituisce un record. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=Non \u00e8 stato possibile creare un'associazione secondaria personalizzata. -rm.action.node-already-transfer=Il nodo \u00e8 stato gi\u00e0 trasferito. -rm.action.node-not-transfer=Il nodo non \u00e8 un oggetto da trasferire. -rm.action.undo-not-last=Impossibile annullare il cut off, poich\u00e9 l'ultima azione di disposizione non \u00e8 stata interrotta. -rm.action.records_only_undeclared=Solo i record possono essere completati. -rm.action.event-not-undone=Impossibile annullare l''evento {0}, poich\u00e9 non \u00e8 definito sul ciclo di vita della disposizione. -rm.action.node-not-record-category=Non \u00e8 stato possibile creare la pianificazione della disposizione, poich\u00e9 azionato su nodo ({0}) non costituiva una categoria record. -rm.action.parameter-not-supplied=Il parametro ''{0}'' non \u00e8 stato fornito. +rm.action.not-defined=L''azione di gestione dei record {0} non \u00e8 stata definita. +rm.action.no-implicit-noderef=Non \u00e8 stato possibile eseguire l''azione di gestione dei record {0}, poich\u00e9 la sua implementazione non fornisce un nodeRef implicito. +rm.action.record-not-declared=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 il record \u00e8 incompleto. (actionedUponNodeRef={1}) +rm.action.expected-record-level=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce un record. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non tutti i record nella cartella di record sono completi. (actionedUponNodeRef={1}) +rm.action.not-eligible=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 l''azione di disposizione successiva sul record o sulla cartella di record non \u00e8 idonea. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non sono state trovate alcune istruzioni di disposizione. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 non \u00e8 disponibile alcun set di ciclo di vita della disposizione. (nodeRef={1}) +rm.action.next-disp-not-set=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 l''azione di disposizione successiva non \u00e8 stata impostata. (nodeRef={1}) +rm.action.not-next-disp=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce l''azione di disposizione successiva per questo record o cartella di record. (nodeRef={1}) +rm.action.not-record-folder=Non \u00e8 stato possibile eseguire l''azione di disposizione {0}, poich\u00e9 quest''ultima non costituisce una cartella di record. (nodeRef={1}) +rm.action.actioned-upon-not-record=Impossibile eseguire l''azione {0}, poich\u00e9 quest''ultima non costituisce un record. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=Impossibile applicare il tipo personalizzato poich\u00e9 non viene riconosciuto. (customAspect={0}) +rm.action.event-no-disp-lc=Impossibile completare l''evento {0}, poich\u00e9 non \u00e8 definito sul ciclo di vita della disposizione. +rm.action.undeclared-only-records=Solo i record possono essere completati. (nodeRef={0}) +rm.action.no-declare-mand-prop=Impossibile completare il record, poich\u00e9 non tutte le propriet\u00e0 obbligatorie di record sono state impostate. +rm.action.ghosted-prop-update=Impossibile aggiornare le propriet\u00e0 di contenuto di un record eliminato definitivamente in precedenza. +rm.action.valid-date-disp-asof=L'azione di disposizione in data deve corrispondere a una data valida. +rm.action.disp-asof-lifecycle-applied=Impossibile modificare la disposizione in data per un record o cartella di record per cui \u00e8 stato impostato un ciclo di vita. +rm.action.hold-edit-reason-none=Impossibile modificare il motivo sospensione, poich\u00e9 non \u00e8 stato fornito alcun motivo. +rm.action.hold-edit-type=Impossibile modificare il motivo sospensione, poich\u00e9 azionato su nodo non \u00e8 del tipo {0}. (nodeRef={1}) +rm.action.specify-avlid-date=La revisione in data deve corrispondere a una data valida. +rm.action.review-details-only=\u00c8 possibile modificare solamente i dettagli di revisione di record fondamentali. +rm.action.freeze-no-reason=Impossibile tenere in sospeso un record senza un motivo. +rm.action.freeze-only-records-folders=\u00c8 possibile tenere in sospeso solamente record o cartelle di record. +rm.action.no-open-record-folder=Non \u00e8 stato possibile aprire la cartella di record, poich\u00e9 non \u00e8 definita come cartella di record. (actionedUponNodeRef={0}) +rm.action.not-hold-type=Non \u00e8 stato possibile interrompere la sospensione, poich\u00e9 il nodo non \u00e8 del tipo {0}. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=Non \u00e8 stato possibile leggere il messaggio di tipo MIME, poich\u00e9 {0}. +rm.action.email-declared=Non \u00e8 stato possibile dividere l''e-mail, poich\u00e9 il record \u00e8 completo. (actionedUponNodeRef={0}) +rm.action.email-not-record=Non \u00e8 stato possibile dividere l''e-mail, poich\u00e9 il nodo non costituisce un record. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=Non \u00e8 stato possibile creare un'associazione secondaria personalizzata. +rm.action.node-already-transfer=Il nodo \u00e8 stato gi\u00e0 trasferito. +rm.action.node-not-transfer=Il nodo non \u00e8 un oggetto da trasferire. +rm.action.undo-not-last=Impossibile annullare il cut off, poich\u00e9 l'ultima azione di disposizione non \u00e8 stata interrotta. +rm.action.records_only_undeclared=Solo i record possono essere completati. +rm.action.event-not-undone=Impossibile annullare l''evento {0}, poich\u00e9 non \u00e8 definito sul ciclo di vita della disposizione. +rm.action.node-not-record-category=Non \u00e8 stato possibile creare la pianificazione della disposizione, poich\u00e9 azionato su nodo ({0}) non costituiva una categoria record. +rm.action.parameter-not-supplied=Il parametro ''{0}'' non \u00e8 stato fornito. rm.action.delete-not-hold-type=Non \u00e8 stato possibile cancellare la sospensione, poich\u00e9 il nodo non \u00e8 del tipo {0}. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_ja.properties index a7d9679b2b..6a1fcb0c73 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_ja.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30af\u30b7\u30e7\u30f3{0}\u306f\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 -rm.action.no-implicit-noderef=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u306b\u306f\u9593\u63a5\u7684\u306anodeRef\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 -rm.action.record-not-declared=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) -rm.action.expected-record-level=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) -rm.action.not-all-records-declared=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u4e00\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) -rm.action.not-eligible=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306e\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u5ec3\u68c4\u6307\u793a\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u4f7f\u7528\u53ef\u80fd\u306a\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30bb\u30c3\u30c8\u304c\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.next-disp-not-set=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.not-next-disp=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306e\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.not-record-folder=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.actioned-upon-not-record=\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=\u30ab\u30b9\u30bf\u30e0\u30bf\u30a4\u30d7\u304c\u8a8d\u8b58\u3055\u308c\u306a\u3044\u305f\u3081\u3001\u9069\u7528\u3067\u304d\u307e\u305b\u3093\u3002(customAspect={0}) -rm.action.event-no-disp-lc=\u30a4\u30d9\u30f3\u30c8{0}\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3002\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 -rm.action.undeclared-only-records=\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u304c\u5b8c\u4e86\u3067\u304d\u307e\u3059\u3002(nodeRef={0}) -rm.action.no-declare-mand-prop=\u30ec\u30b3\u30fc\u30c9\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3002\u4e00\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u5fc5\u9808\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 -rm.action.ghosted-prop-update=\u4ee5\u524d\u306b\u7834\u68c4\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002 -rm.action.valid-date-disp-asof=\u73fe\u6642\u70b9\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u6709\u52b9\u306a\u65e5\u4ed8\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 -rm.action.disp-asof-lifecycle-applied=\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u9069\u7528\u3057\u305f\u73fe\u6642\u70b9\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306e\u5ec3\u68c4\u306f\u3001\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002 -rm.action.hold-edit-reason-none=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306f\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002\u7406\u7531\u304c\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 -rm.action.hold-edit-type=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306f\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u884c\u3063\u305f\u30ce\u30fc\u30c9\u304c\u30bf\u30a4\u30d7{0}\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) -rm.action.specify-avlid-date=\u73fe\u6642\u70b9\u306e\u30ec\u30d3\u30e5\u30fc\u306f\u6709\u52b9\u306a\u65e5\u4ed8\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 -rm.action.review-details-only=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u8a73\u7d30\u306e\u307f\u304c\u7de8\u96c6\u3067\u304d\u307e\u3059\u3002 -rm.action.freeze-no-reason=\u30ec\u30b3\u30fc\u30c9\u306f\u7406\u7531\u304c\u306a\u3051\u308c\u3070\u30db\u30fc\u30eb\u30c9\u3067\u304d\u307e\u305b\u3093\u3002 -rm.action.freeze-only-records-folders=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306e\u307f\u304c\u30db\u30fc\u30eb\u30c9\u3067\u304d\u307e\u3059\u3002 -rm.action.no-open-record-folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u3051\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) -rm.action.not-hold-type=\u30db\u30fc\u30eb\u30c9\u3092\u653e\u68c4\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ce\u30fc\u30c9\u304c\u30bf\u30a4\u30d7{0}\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) -rm.action.no-read-mime-message=MIME\u30bf\u30a4\u30d7\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8aad\u307f\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002{0}\u306e\u305f\u3081\u3067\u3059\u3002 -rm.action.email-declared=E\u30e1\u30fc\u30eb\u3092\u5206\u5272\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) -rm.action.email-not-record=E\u30e1\u30fc\u30eb\u3092\u5206\u5272\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ce\u30fc\u30c9\u304c\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=\u30ab\u30b9\u30bf\u30e0\u5b50\u95a2\u9023\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 -rm.action.node-already-transfer=\u30ce\u30fc\u30c9\u306f\u3059\u3067\u306b\u8ee2\u9001\u3055\u308c\u3066\u3044\u308b\u3068\u3053\u308d\u3067\u3059\u3002 -rm.action.node-not-transfer=\u30ce\u30fc\u30c9\u306f\u8ee2\u9001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 -rm.action.undo-not-last=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u305b\u307e\u305b\u3093\u3002\u76f4\u524d\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u30ab\u30c3\u30c8\u30aa\u30d5\u3055\u308c\u3066\u3044\u306a\u304b\u3063\u305f\u305f\u3081\u3067\u3059\u3002 -rm.action.records_only_undeclared=\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u304c\u5b8c\u4e86\u3067\u304d\u307e\u3059\u3002 -rm.action.event-not-undone=\u30a4\u30d9\u30f3\u30c8{0}\u3092\u5143\u306b\u623b\u305b\u307e\u305b\u3093\u3002\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 -rm.action.node-not-record-category=\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u884c\u3063\u305f\u30ce\u30fc\u30c9 ({0}) \u304c\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 -rm.action.parameter-not-supplied=\u30d1\u30e9\u30e1\u30fc\u30bf ''{0}'' \u306f\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 +rm.action.not-defined=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30af\u30b7\u30e7\u30f3{0}\u306f\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 +rm.action.no-implicit-noderef=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u306b\u306f\u9593\u63a5\u7684\u306anodeRef\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 +rm.action.record-not-declared=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) +rm.action.expected-record-level=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) +rm.action.not-all-records-declared=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u4e00\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) +rm.action.not-eligible=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306e\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u5ec3\u68c4\u6307\u793a\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u4f7f\u7528\u53ef\u80fd\u306a\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30bb\u30c3\u30c8\u304c\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.next-disp-not-set=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.not-next-disp=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306e\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.not-record-folder=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.actioned-upon-not-record=\u30a2\u30af\u30b7\u30e7\u30f3{0}\u3092\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u308c\u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=\u30ab\u30b9\u30bf\u30e0\u30bf\u30a4\u30d7\u304c\u8a8d\u8b58\u3055\u308c\u306a\u3044\u305f\u3081\u3001\u9069\u7528\u3067\u304d\u307e\u305b\u3093\u3002(customAspect={0}) +rm.action.event-no-disp-lc=\u30a4\u30d9\u30f3\u30c8{0}\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3002\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 +rm.action.undeclared-only-records=\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u304c\u5b8c\u4e86\u3067\u304d\u307e\u3059\u3002(nodeRef={0}) +rm.action.no-declare-mand-prop=\u30ec\u30b3\u30fc\u30c9\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3002\u4e00\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u5fc5\u9808\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 +rm.action.ghosted-prop-update=\u4ee5\u524d\u306b\u7834\u68c4\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002 +rm.action.valid-date-disp-asof=\u73fe\u6642\u70b9\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u6709\u52b9\u306a\u65e5\u4ed8\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 +rm.action.disp-asof-lifecycle-applied=\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u9069\u7528\u3057\u305f\u73fe\u6642\u70b9\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306e\u5ec3\u68c4\u306f\u3001\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002 +rm.action.hold-edit-reason-none=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306f\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002\u7406\u7531\u304c\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 +rm.action.hold-edit-type=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306f\u7de8\u96c6\u3067\u304d\u307e\u305b\u3093\u3002\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u884c\u3063\u305f\u30ce\u30fc\u30c9\u304c\u30bf\u30a4\u30d7{0}\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={1}) +rm.action.specify-avlid-date=\u73fe\u6642\u70b9\u306e\u30ec\u30d3\u30e5\u30fc\u306f\u6709\u52b9\u306a\u65e5\u4ed8\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 +rm.action.review-details-only=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u8a73\u7d30\u306e\u307f\u304c\u7de8\u96c6\u3067\u304d\u307e\u3059\u3002 +rm.action.freeze-no-reason=\u30ec\u30b3\u30fc\u30c9\u306f\u7406\u7531\u304c\u306a\u3051\u308c\u3070\u30db\u30fc\u30eb\u30c9\u3067\u304d\u307e\u305b\u3093\u3002 +rm.action.freeze-only-records-folders=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306e\u307f\u304c\u30db\u30fc\u30eb\u30c9\u3067\u304d\u307e\u3059\u3002 +rm.action.no-open-record-folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u3051\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) +rm.action.not-hold-type=\u30db\u30fc\u30eb\u30c9\u3092\u653e\u68c4\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ce\u30fc\u30c9\u304c\u30bf\u30a4\u30d7{0}\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={1}) +rm.action.no-read-mime-message=MIME\u30bf\u30a4\u30d7\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8aad\u307f\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002{0}\u306e\u305f\u3081\u3067\u3059\u3002 +rm.action.email-declared=E\u30e1\u30fc\u30eb\u3092\u5206\u5272\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) +rm.action.email-not-record=E\u30e1\u30fc\u30eb\u3092\u5206\u5272\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ce\u30fc\u30c9\u304c\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u306a\u3044\u305f\u3081\u3067\u3059\u3002(actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=\u30ab\u30b9\u30bf\u30e0\u5b50\u95a2\u9023\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 +rm.action.node-already-transfer=\u30ce\u30fc\u30c9\u306f\u3059\u3067\u306b\u8ee2\u9001\u3055\u308c\u3066\u3044\u308b\u3068\u3053\u308d\u3067\u3059\u3002 +rm.action.node-not-transfer=\u30ce\u30fc\u30c9\u306f\u8ee2\u9001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 +rm.action.undo-not-last=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u305b\u307e\u305b\u3093\u3002\u76f4\u524d\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u30ab\u30c3\u30c8\u30aa\u30d5\u3055\u308c\u3066\u3044\u306a\u304b\u3063\u305f\u305f\u3081\u3067\u3059\u3002 +rm.action.records_only_undeclared=\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u304c\u5b8c\u4e86\u3067\u304d\u307e\u3059\u3002 +rm.action.event-not-undone=\u30a4\u30d9\u30f3\u30c8{0}\u3092\u5143\u306b\u623b\u305b\u307e\u305b\u3093\u3002\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002 +rm.action.node-not-record-category=\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u884c\u3063\u305f\u30ce\u30fc\u30c9 ({0}) \u304c\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 +rm.action.parameter-not-supplied=\u30d1\u30e9\u30e1\u30fc\u30bf ''{0}'' \u306f\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 rm.action.delete-not-hold-type=\u30ce\u30fc\u30c9\u304c\u30bf\u30a4\u30d7{0}\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30db\u30fc\u30eb\u30c9\u3092\u524a\u9664\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_nl.properties index cadbeb2df7..5910419c1e 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_nl.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=De Record Management-actie {0} is niet gedefinieerd. -rm.action.no-implicit-noderef=De Record Management-actie {0} kon niet worden uitgevoerd omdat de implementatie van de actie geen impliciete nodeRef geeft. -rm.action.record-not-declared=De archiveringsactie {0} kon niet worden uitgevoerd omdat de record niet afgerond is. (actionedUponNodeRef={1}) -rm.action.expected-record-level=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit geen record is. (actionedUponNodeRef={1}) -rm.action.not-all-records-declared=De archiveringsactie {0} kon niet worden uitgevoerd omdat niet alle records in de archiefmap afgerond zijn. (actionedUponNodeRef={1}) -rm.action.not-eligible=De archiveringsactie {0} kon niet worden uitgevoerd omdat de volgende archiveringsactie voor de record of de archiefmap niet in aanmerking komen. (actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=De archiveringsactie {0} kon niet worden uitgevoerd omdat er geen archiveringsinstructies zijn gevonden. (nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=De archiveringsactie {0} kon niet worden uitgevoerd omdat er geen archiveringscyclus is ingesteld. (nodeRef={1}) -rm.action.next-disp-not-set=De archiveringsactie {0} kon niet worden uitgevoerd omdat de volgende archiveringsactie niet is ingesteld. (nodeRef={1}) -rm.action.not-next-disp=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit niet de volgende archiveringsactie voor deze record of deze archiefmap is. (nodeRef={1}) -rm.action.not-record-folder=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit geen archiefmap is. (nodeRef={1}) -rm.action.actioned-upon-not-record=De actie {0} kan niet worden uitgevoerd omdat dit geen record is. (filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=Het aangepaste type kan niet worden toegepast omdat het niet wordt herkend. (customAspect={0}) -rm.action.event-no-disp-lc=De gebeurtenis {0} kan niet worden afgerond omdat zij niet is gedefinieerd in de archiveringscyclus. -rm.action.undeclared-only-records=Er kunnen alleen records worden afgerond. (nodeRef={0}) -rm.action.no-declare-mand-prop=De record kan niet worden afgerond omdat niet alle verplichte recordeigenschappen zijn ingesteld. -rm.action.ghosted-prop-update=De contenteigenschappen van een record die eerder is vernietigd, kunnen niet worden bijgewerkt. -rm.action.valid-date-disp-asof=De begindatum van de archiveringsactie moet een geldige datum zijn. -rm.action.disp-asof-lifecycle-applied=De begindatum van de archivering van een record of archiefmap waarvoor een levenscyclus is toegepast, kan niet worden bewerkt. -rm.action.hold-edit-reason-none=De reden van wachtstand kan niet worden bewerkt omdat er geen reden is opgegeven. -rm.action.hold-edit-type=De reden van wachtstand kan niet worden bewerkt omdat de gebruikte node niet het type {0} heeft. (nodeRef={1}) -rm.action.specify-avlid-date=De begindatum van de revisie moet een geldige datum zijn. -rm.action.review-details-only=Alleen de revisiegegevens van vitale records kunnen worden bewerkt. -rm.action.freeze-no-reason=Een record kan niet zonder reden in wachtstand worden geplaatst. -rm.action.freeze-only-records-folders=Alleen records of archiefmappen kunnen in wachtstand worden geplaatst. -rm.action.no-open-record-folder=De archiefmap kan niet worden geopend omdat hij niet als een archiefmap is gedefinieerd. (actionedUponNodeRef={0}) -rm.action.not-hold-type=De wachtstand kon niet worden afgewezen omdat de node niet type {0} heeft. (actionedUponNodeRef={1}) -rm.action.no-read-mime-message=Het MIME-bericht kon niet worden gelezen omdat {0}. -rm.action.email-declared=De e-mail kan niet worden opgesplitst omdat de record is afgerond. (actionedUponNodeRef={0}) -rm.action.email-not-record=De e-mail kan niet worden opgesplitst omdat de node geen record is. (actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=Kon geen aangepaste onderliggende koppeling maken. -rm.action.node-already-transfer=De node wordt al overgezet. -rm.action.node-not-transfer=De node is geen overzetobject. -rm.action.undo-not-last=Afsluiten kan niet ongedaan worden gemaakt omdat de laatste archiveringsactie niet was afgesloten. -rm.action.records_only_undeclared=Er kunnen alleen records worden afgerond. -rm.action.event-not-undone=De gebeurtenis {0} kan niet ongedaan worden gemaakt omdat zij niet in de archiveringscyclus is gedefinieerd. -rm.action.node-not-record-category=Het bewaarschema kon niet worden gemaakt omdat de gebruikte node ({0}) geen recordcategorie is. -rm.action.parameter-not-supplied=De parameter ''{0}'' is niet opgegeven. +rm.action.not-defined=De Record Management-actie {0} is niet gedefinieerd. +rm.action.no-implicit-noderef=De Record Management-actie {0} kon niet worden uitgevoerd omdat de implementatie van de actie geen impliciete nodeRef geeft. +rm.action.record-not-declared=De archiveringsactie {0} kon niet worden uitgevoerd omdat de record niet afgerond is. (actionedUponNodeRef={1}) +rm.action.expected-record-level=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit geen record is. (actionedUponNodeRef={1}) +rm.action.not-all-records-declared=De archiveringsactie {0} kon niet worden uitgevoerd omdat niet alle records in de archiefmap afgerond zijn. (actionedUponNodeRef={1}) +rm.action.not-eligible=De archiveringsactie {0} kon niet worden uitgevoerd omdat de volgende archiveringsactie voor de record of de archiefmap niet in aanmerking komen. (actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=De archiveringsactie {0} kon niet worden uitgevoerd omdat er geen archiveringsinstructies zijn gevonden. (nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=De archiveringsactie {0} kon niet worden uitgevoerd omdat er geen archiveringscyclus is ingesteld. (nodeRef={1}) +rm.action.next-disp-not-set=De archiveringsactie {0} kon niet worden uitgevoerd omdat de volgende archiveringsactie niet is ingesteld. (nodeRef={1}) +rm.action.not-next-disp=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit niet de volgende archiveringsactie voor deze record of deze archiefmap is. (nodeRef={1}) +rm.action.not-record-folder=De archiveringsactie {0} kon niet worden uitgevoerd omdat dit geen archiefmap is. (nodeRef={1}) +rm.action.actioned-upon-not-record=De actie {0} kan niet worden uitgevoerd omdat dit geen record is. (filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=Het aangepaste type kan niet worden toegepast omdat het niet wordt herkend. (customAspect={0}) +rm.action.event-no-disp-lc=De gebeurtenis {0} kan niet worden afgerond omdat zij niet is gedefinieerd in de archiveringscyclus. +rm.action.undeclared-only-records=Er kunnen alleen records worden afgerond. (nodeRef={0}) +rm.action.no-declare-mand-prop=De record kan niet worden afgerond omdat niet alle verplichte recordeigenschappen zijn ingesteld. +rm.action.ghosted-prop-update=De contenteigenschappen van een record die eerder is vernietigd, kunnen niet worden bijgewerkt. +rm.action.valid-date-disp-asof=De begindatum van de archiveringsactie moet een geldige datum zijn. +rm.action.disp-asof-lifecycle-applied=De begindatum van de archivering van een record of archiefmap waarvoor een levenscyclus is toegepast, kan niet worden bewerkt. +rm.action.hold-edit-reason-none=De reden van wachtstand kan niet worden bewerkt omdat er geen reden is opgegeven. +rm.action.hold-edit-type=De reden van wachtstand kan niet worden bewerkt omdat de gebruikte node niet het type {0} heeft. (nodeRef={1}) +rm.action.specify-avlid-date=De begindatum van de revisie moet een geldige datum zijn. +rm.action.review-details-only=Alleen de revisiegegevens van vitale records kunnen worden bewerkt. +rm.action.freeze-no-reason=Een record kan niet zonder reden in wachtstand worden geplaatst. +rm.action.freeze-only-records-folders=Alleen records of archiefmappen kunnen in wachtstand worden geplaatst. +rm.action.no-open-record-folder=De archiefmap kan niet worden geopend omdat hij niet als een archiefmap is gedefinieerd. (actionedUponNodeRef={0}) +rm.action.not-hold-type=De wachtstand kon niet worden afgewezen omdat de node niet type {0} heeft. (actionedUponNodeRef={1}) +rm.action.no-read-mime-message=Het MIME-bericht kon niet worden gelezen omdat {0}. +rm.action.email-declared=De e-mail kan niet worden opgesplitst omdat de record is afgerond. (actionedUponNodeRef={0}) +rm.action.email-not-record=De e-mail kan niet worden opgesplitst omdat de node geen record is. (actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=Kon geen aangepaste onderliggende koppeling maken. +rm.action.node-already-transfer=De node wordt al overgezet. +rm.action.node-not-transfer=De node is geen overzetobject. +rm.action.undo-not-last=Afsluiten kan niet ongedaan worden gemaakt omdat de laatste archiveringsactie niet was afgesloten. +rm.action.records_only_undeclared=Er kunnen alleen records worden afgerond. +rm.action.event-not-undone=De gebeurtenis {0} kan niet ongedaan worden gemaakt omdat zij niet in de archiveringscyclus is gedefinieerd. +rm.action.node-not-record-category=Het bewaarschema kon niet worden gemaakt omdat de gebruikte node ({0}) geen recordcategorie is. +rm.action.parameter-not-supplied=De parameter ''{0}'' is niet opgegeven. rm.action.delete-not-hold-type=De wachtstand kan niet worden verwijderd omdat de node niet van het type {0} is. (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_zh_CN.properties index 51b8dfdc2e..ef074b65b3 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/action-service_zh_CN.properties @@ -1,39 +1,39 @@ -rm.action.not-defined=\u5c1a\u672a\u5b9a\u4e49\u8bb0\u5f55\u7ba1\u7406\u64cd\u4f5c {0}\u3002 -rm.action.no-implicit-noderef=\u65e0\u6cd5\u6267\u884c\u8bb0\u5f55\u7ba1\u7406\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u64cd\u4f5c\u5b9e\u65bd\u65e0\u6cd5\u63d0\u4f9b\u9690\u5f0f nodeRef\u3002 -rm.action.record-not-declared=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8bb0\u5f55\u4e0d\u5b8c\u6574\u3002(actionedUponNodeRef={1}) -rm.action.expected-record-level=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u3002(actionedUponNodeRef={1}) -rm.action.not-all-records-declared=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u5e76\u975e\u8bb0\u5f55\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\u90fd\u5b8c\u6574\u3002(actionedUponNodeRef={1}) -rm.action.not-eligible=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u5bf9\u4e8e\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u4e0d\u5408\u6cd5\u3002(actionedUponNodeRef={1}) -rm.action.no-disposition-instructions=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u65e0\u6cd5\u627e\u5230\u5904\u7f6e\u8bf4\u660e\u3002(nodeRef={1}) -rm.action.no-disposition-lisfecycle-set=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u6ca1\u6709\u53ef\u7528\u7684\u5904\u7f6e\u751f\u547d\u5468\u671f\u8bbe\u7f6e\u3002(nodeRef={1}) -rm.action.next-disp-not-set=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u6ca1\u6709\u8bbe\u7f6e\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002(nodeRef={1}) -rm.action.not-next-disp=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u5e76\u975e\u8be5\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002(nodeRef={1}) -rm.action.not-record-folder=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(nodeRef={1}) -rm.action.actioned-upon-not-record=\u65e0\u6cd5\u6267\u884c\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u3002(filePlanComponet={1}) -rm.action.custom-aspect-not-recognised=\u56e0\u4e3a\u672a\u8bc6\u522b\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u6240\u4ee5\u65e0\u6cd5\u5e94\u7528\u3002(customAspect={0}) -rm.action.event-no-disp-lc=\u65e0\u6cd5\u5b8c\u6210\u4e8b\u4ef6 {0}\uff0c\u56e0\u4e3a\u5176\u672a\u5728\u5904\u7f6e\u751f\u547d\u5468\u671f\u4e0a\u5b9a\u4e49\u3002 -rm.action.undeclared-only-records=\u4ec5\u80fd\u5b8c\u6210\u8bb0\u5f55\u3002(nodeRef={0}) -rm.action.no-declare-mand-prop=\u65e0\u6cd5\u5b8c\u6210\u8bb0\u5f55\uff0c\u56e0\u4e3a\u5e76\u672a\u8bbe\u7f6e\u6240\u6709\u8bb0\u5f55\u5f3a\u5236\u5c5e\u6027\u3002 -rm.action.ghosted-prop-update=\u65e0\u6cd5\u66f4\u65b0\u4e4b\u524d\u9500\u6bc1\u7684\u8bb0\u5f55\u7684\u5185\u5bb9\u5c5e\u6027\u3002 -rm.action.valid-date-disp-asof=\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f\u5fc5\u987b\u4e3a\u6709\u6548\u65e5\u671f\u3002 -rm.action.disp-asof-lifecycle-applied=\u65e0\u6cd5\u7f16\u8f91\u5e94\u7528\u4e86\u751f\u547d\u5468\u671f\u7684\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u5904\u7f6e\u622a\u6b62\u65e5\u671f\u3002 -rm.action.hold-edit-reason-none=\u65e0\u6cd5\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0\uff0c\u56e0\u4e3a\u5c1a\u672a\u63d0\u4f9b\u539f\u56e0\u3002 -rm.action.hold-edit-type=\u65e0\u6cd5\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0\uff0c\u56e0\u4e3a\u5bf9\u8282\u70b9\u6267\u884c\u7684\u64cd\u4f5c\u5e76\u975e {0} \u7c7b\u578b\u3002(nodeRef={1}) -rm.action.specify-avlid-date=\u5ba1\u67e5\u622a\u6b62\u65e5\u671f\u5fc5\u987b\u4e3a\u6709\u6548\u65e5\u671f\u3002 -rm.action.review-details-only=\u53ea\u80fd\u7f16\u8f91\u6838\u5fc3\u8bb0\u5f55\u7684\u5ba1\u67e5\u8be6\u7ec6\u4fe1\u606f\u3002 -rm.action.freeze-no-reason=\u4e0d\u80fd\u5728\u6ca1\u6709\u539f\u56e0\u7684\u60c5\u51b5\u4e0b\u4fdd\u5b58\u8bb0\u5f55\u3002 -rm.action.freeze-only-records-folders=\u53ea\u80fd\u4fdd\u5b58\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -rm.action.no-open-record-folder=\u65e0\u6cd5\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u5e76\u672a\u5c06\u5176\u5b9a\u4e49\u4e3a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(actionedUponNodeRef={0}) -rm.action.not-hold-type=\u65e0\u6cd5\u653e\u5f03\u4fdd\u5b58\uff0c\u56e0\u4e3a\u8282\u70b9\u5e76\u975e {0} \u7c7b\u578b\u3002(actionedUponNodeRef={1}) -rm.action.no-read-mime-message=\u65e0\u6cd5\u8bfb\u53d6 mime \u7c7b\u578b\u6d88\u606f\uff0c\u539f\u56e0\u4e3a {0}\u3002 -rm.action.email-declared=\u65e0\u6cd5\u62c6\u5206\u7535\u5b50\u90ae\u4ef6\uff0c\u56e0\u4e3a\u8bb0\u5f55\u662f\u5b8c\u6574\u7684\u3002(actionedUponNodeRef={0}) -rm.action.email-not-record=\u65e0\u6cd5\u62c6\u5206\u7535\u5b50\u90ae\u4ef6\uff0c\u56e0\u4e3a\u8282\u70b9\u5e76\u975e\u8bb0\u5f55\u3002(actionedUponNodeRef={0}) -rm.action.email-create-child-assoc=\u65e0\u6cd5\u521b\u5efa\u81ea\u5b9a\u4e49\u5b50\u5173\u8054\u3002 -rm.action.node-already-transfer=\u5df2\u7ecf\u5728\u79fb\u4ea4\u8282\u70b9\u3002 -rm.action.node-not-transfer=\u8282\u70b9\u5e76\u975e\u79fb\u4ea4\u5bf9\u8c61\u3002 -rm.action.undo-not-last=\u65e0\u6cd5\u64a4\u6d88\u4e2d\u65ad\uff0c\u56e0\u4e3a\u6ca1\u6709\u4e2d\u65ad\u4e0a\u4e00\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002 -rm.action.records_only_undeclared=\u4ec5\u80fd\u5b8c\u6210\u8bb0\u5f55\u3002 -rm.action.event-not-undone=\u65e0\u6cd5\u64a4\u6d88\u4e8b\u4ef6 {0}\uff0c\u56e0\u4e3a\u5176\u672a\u5728\u5904\u7f6e\u751f\u547d\u5468\u671f\u4e0a\u5b9a\u4e49\u3002 -rm.action.node-not-record-category=\u65e0\u6cd5\u521b\u5efa\u5904\u7f6e\u8ba1\u5212\uff0c\u56e0\u4e3a\u5bf9\u8282\u70b9 ({0}) \u6267\u884c\u7684\u64cd\u4f5c\u5e76\u975e\u8bb0\u5f55\u7c7b\u522b\u3002 -rm.action.parameter-not-supplied=\u5c1a\u672a\u63d0\u4f9b\u53c2\u6570 ''{0}''\u3002 +rm.action.not-defined=\u5c1a\u672a\u5b9a\u4e49\u8bb0\u5f55\u7ba1\u7406\u64cd\u4f5c {0}\u3002 +rm.action.no-implicit-noderef=\u65e0\u6cd5\u6267\u884c\u8bb0\u5f55\u7ba1\u7406\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u64cd\u4f5c\u5b9e\u65bd\u65e0\u6cd5\u63d0\u4f9b\u9690\u5f0f nodeRef\u3002 +rm.action.record-not-declared=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8bb0\u5f55\u4e0d\u5b8c\u6574\u3002(actionedUponNodeRef={1}) +rm.action.expected-record-level=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u3002(actionedUponNodeRef={1}) +rm.action.not-all-records-declared=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u5e76\u975e\u8bb0\u5f55\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\u90fd\u5b8c\u6574\u3002(actionedUponNodeRef={1}) +rm.action.not-eligible=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u5bf9\u4e8e\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u4e0d\u5408\u6cd5\u3002(actionedUponNodeRef={1}) +rm.action.no-disposition-instructions=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u65e0\u6cd5\u627e\u5230\u5904\u7f6e\u8bf4\u660e\u3002(nodeRef={1}) +rm.action.no-disposition-lisfecycle-set=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u6ca1\u6709\u53ef\u7528\u7684\u5904\u7f6e\u751f\u547d\u5468\u671f\u8bbe\u7f6e\u3002(nodeRef={1}) +rm.action.next-disp-not-set=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u6ca1\u6709\u8bbe\u7f6e\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002(nodeRef={1}) +rm.action.not-next-disp=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u5e76\u975e\u8be5\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002(nodeRef={1}) +rm.action.not-record-folder=\u65e0\u6cd5\u6267\u884c\u5904\u7f6e\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(nodeRef={1}) +rm.action.actioned-upon-not-record=\u65e0\u6cd5\u6267\u884c\u64cd\u4f5c {0}\uff0c\u56e0\u4e3a\u8fd9\u4e0d\u662f\u8bb0\u5f55\u3002(filePlanComponet={1}) +rm.action.custom-aspect-not-recognised=\u56e0\u4e3a\u672a\u8bc6\u522b\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u6240\u4ee5\u65e0\u6cd5\u5e94\u7528\u3002(customAspect={0}) +rm.action.event-no-disp-lc=\u65e0\u6cd5\u5b8c\u6210\u4e8b\u4ef6 {0}\uff0c\u56e0\u4e3a\u5176\u672a\u5728\u5904\u7f6e\u751f\u547d\u5468\u671f\u4e0a\u5b9a\u4e49\u3002 +rm.action.undeclared-only-records=\u4ec5\u80fd\u5b8c\u6210\u8bb0\u5f55\u3002(nodeRef={0}) +rm.action.no-declare-mand-prop=\u65e0\u6cd5\u5b8c\u6210\u8bb0\u5f55\uff0c\u56e0\u4e3a\u5e76\u672a\u8bbe\u7f6e\u6240\u6709\u8bb0\u5f55\u5f3a\u5236\u5c5e\u6027\u3002 +rm.action.ghosted-prop-update=\u65e0\u6cd5\u66f4\u65b0\u4e4b\u524d\u9500\u6bc1\u7684\u8bb0\u5f55\u7684\u5185\u5bb9\u5c5e\u6027\u3002 +rm.action.valid-date-disp-asof=\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f\u5fc5\u987b\u4e3a\u6709\u6548\u65e5\u671f\u3002 +rm.action.disp-asof-lifecycle-applied=\u65e0\u6cd5\u7f16\u8f91\u5e94\u7528\u4e86\u751f\u547d\u5468\u671f\u7684\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u5904\u7f6e\u622a\u6b62\u65e5\u671f\u3002 +rm.action.hold-edit-reason-none=\u65e0\u6cd5\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0\uff0c\u56e0\u4e3a\u5c1a\u672a\u63d0\u4f9b\u539f\u56e0\u3002 +rm.action.hold-edit-type=\u65e0\u6cd5\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0\uff0c\u56e0\u4e3a\u5bf9\u8282\u70b9\u6267\u884c\u7684\u64cd\u4f5c\u5e76\u975e {0} \u7c7b\u578b\u3002(nodeRef={1}) +rm.action.specify-avlid-date=\u5ba1\u67e5\u622a\u6b62\u65e5\u671f\u5fc5\u987b\u4e3a\u6709\u6548\u65e5\u671f\u3002 +rm.action.review-details-only=\u53ea\u80fd\u7f16\u8f91\u6838\u5fc3\u8bb0\u5f55\u7684\u5ba1\u67e5\u8be6\u7ec6\u4fe1\u606f\u3002 +rm.action.freeze-no-reason=\u4e0d\u80fd\u5728\u6ca1\u6709\u539f\u56e0\u7684\u60c5\u51b5\u4e0b\u4fdd\u5b58\u8bb0\u5f55\u3002 +rm.action.freeze-only-records-folders=\u53ea\u80fd\u4fdd\u5b58\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +rm.action.no-open-record-folder=\u65e0\u6cd5\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u5e76\u672a\u5c06\u5176\u5b9a\u4e49\u4e3a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(actionedUponNodeRef={0}) +rm.action.not-hold-type=\u65e0\u6cd5\u653e\u5f03\u4fdd\u5b58\uff0c\u56e0\u4e3a\u8282\u70b9\u5e76\u975e {0} \u7c7b\u578b\u3002(actionedUponNodeRef={1}) +rm.action.no-read-mime-message=\u65e0\u6cd5\u8bfb\u53d6 mime \u7c7b\u578b\u6d88\u606f\uff0c\u539f\u56e0\u4e3a {0}\u3002 +rm.action.email-declared=\u65e0\u6cd5\u62c6\u5206\u7535\u5b50\u90ae\u4ef6\uff0c\u56e0\u4e3a\u8bb0\u5f55\u662f\u5b8c\u6574\u7684\u3002(actionedUponNodeRef={0}) +rm.action.email-not-record=\u65e0\u6cd5\u62c6\u5206\u7535\u5b50\u90ae\u4ef6\uff0c\u56e0\u4e3a\u8282\u70b9\u5e76\u975e\u8bb0\u5f55\u3002(actionedUponNodeRef={0}) +rm.action.email-create-child-assoc=\u65e0\u6cd5\u521b\u5efa\u81ea\u5b9a\u4e49\u5b50\u5173\u8054\u3002 +rm.action.node-already-transfer=\u5df2\u7ecf\u5728\u79fb\u4ea4\u8282\u70b9\u3002 +rm.action.node-not-transfer=\u8282\u70b9\u5e76\u975e\u79fb\u4ea4\u5bf9\u8c61\u3002 +rm.action.undo-not-last=\u65e0\u6cd5\u64a4\u6d88\u4e2d\u65ad\uff0c\u56e0\u4e3a\u6ca1\u6709\u4e2d\u65ad\u4e0a\u4e00\u4e2a\u5904\u7f6e\u64cd\u4f5c\u3002 +rm.action.records_only_undeclared=\u4ec5\u80fd\u5b8c\u6210\u8bb0\u5f55\u3002 +rm.action.event-not-undone=\u65e0\u6cd5\u64a4\u6d88\u4e8b\u4ef6 {0}\uff0c\u56e0\u4e3a\u5176\u672a\u5728\u5904\u7f6e\u751f\u547d\u5468\u671f\u4e0a\u5b9a\u4e49\u3002 +rm.action.node-not-record-category=\u65e0\u6cd5\u521b\u5efa\u5904\u7f6e\u8ba1\u5212\uff0c\u56e0\u4e3a\u5bf9\u8282\u70b9 ({0}) \u6267\u884c\u7684\u64cd\u4f5c\u5e76\u975e\u8bb0\u5f55\u7c7b\u522b\u3002 +rm.action.parameter-not-supplied=\u5c1a\u672a\u63d0\u4f9b\u53c2\u6570 ''{0}''\u3002 rm.action.delete-not-hold-type=\u65e0\u6cd5\u5220\u9664\u4fdd\u5b58\uff0c\u56e0\u4e3a\u8282\u70b9\u5e76\u975e {0} \u7c7b\u578b\u3002 (actionedUponNodeRef={1}) \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties index 94fbe11371..f58a1c4f8e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Classified by disposition schedule -isClassified.description=Has the records or record folders been classified by a disposition schedule. - -# Are cutoff -isCutoff.title=Cut Off -isCutoff.description=Records or record folders are cut off. - -# Are declared -isDeclared.title=Record completed -isDeclared.description=Is the record complete. - -# Is on hold -isFrozen.title=On Hold -isFrozen.description=Is the record or record folder on hold. - -# Are filed -isRecordFiled.title=Record filed -isRecordFiled.description=Is the record filed. - -# Are closed record folders -isRecordFolderClosed.title=Record folder closed -isRecordFolderClosed.description=Is the record folder closed. - -# Are vital -isVital.title=Vital record -isVital.description=Is the record or record folder vital. - -# Have Disposition Action -hasDispositionAction.title=Has disposition action -hasDispositionAction.description=Have the nodes got the specified associated disposition action at the specified relative position. - -# Are kind -isKind.title=Type of records management item -isKind.description=Are the nodes of a file plan component kind. -isKind.kind.display-label=Kind - -# Are Record Type -isRecordType.title=Has record type -isRecordType.description=Are the records of the specified type. - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=Declare as record -create-record.description=Declares document as a record. -create-record.file-plan.display-label=File plan -create-record.hide-record.display-label=Hide Record -# Declare As Version Record -declare-as-version-record.title=Declare version as record -declare-as-version-record.description=Declares new version of document as a version record. -declare-as-version-record.file-plan.display-label=File plan -# Complete record -declareRecord.title=Complete record -declareRecord.description=Completes a record. -# Reopens record -undeclareRecord.title=Reopen record -undeclareRecord.description=Reopens a record. -# Open record folder -openRecordFolder.title=Open record folder -openRecordFolder.description=Opens a record folder. -# Close record folder -closeRecordFolder.title=Close record folder -closeRecordFolder.description=Closes a record folder. -# Complete event -completeEvent.title=Complete event -completeEvent.description=Completes an event. -completeEvent.eventName.display-label=Event -# Freeze -freeze.title=Freeze -freeze.description=Freezes a record. -freeze.reason.display-label=Reason -# Unfreeze -unfreeze.title=Unfreeze -unfreeze.description=Unfreezes a record. -# File to -fileTo.title=File to -fileTo.description=Files a record to the specified record folder. -fileTo.path.display-label=Path to Record Folder -fileTo.createRecordPath.display-label=Create Record Path -# Copy to -copyTo.title=Copy to -copyTo.description=Copies a record to the specified record folder. -copyTo.path.display-label=Path to Record Folder -copyTo.createRecordPath.display-label=Create Record Path -# Move to -moveTo.title=Move to -moveTo.description=Moves a record to the specified record folder. -moveTo.path.display-label=Path to Record Folder -moveTo.createRecordPath.display-label=Create Record Path -# Link to -linkTo.title=Link to -linkTo.description=Links a record to the specified record folder. -linkTo.path.display-label=Path to Record Folder -linkTo.createRecordPath.display-label=Create Record Path -# Reject -reject.title=Reject -reject.description=Rejects a record and moves the document to its original location -reject.reason.display-label=Reject reason -# Request Information -requestInfo.title=Request information -requestInfo.description=Starts a workflow for requesting more information for a record -# Execute script -executeScript.title=Execute script -executeScript.description=Execute a script. -executeScript.script-ref.display-label=Script -# Send Email -sendEmail.title=Send email -sendEmail.description=Send an email -# Set Property -setPropertyValue.title=Set property value -setPropertyValue.description=Set a property value - -# Edit Hold Reason -editHoldReason.title=Edit hold reason -editHoldReason.description=Edit hold reason -# Relinquish Hold -relinquishHold.title=Relinquish hold -relinquishHold.description=Relinquish hold -# Edit Review As Of Date -editReviewAsOfDate.title=Edit review as of date -editReviewAsOfDate.description=Edit review as of date -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Edit disposition action as of date -editDispositionActionAsOfDate.description=Edit disposition action as of date -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=Broadcast vital record definition -broadcastVitalRecordDefinition.description=Broadcast vital record definition -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Broadcast disposition action definition update -broadcastDispositionActionDefinitionUpdate.description=Broadcast disposition action definition update -# Undo Event -undoEvent.title=Undo event -undoEvent.description=Undo event -# Transfer Complete -transferComplete.title=Transfer complete -transferComplete.description=Transfer complete -# Accession Complete -accessionComplete.title=Accession complete -accessionComplete.description=Accession complete -# Split Email -splitEmail.title=Split email -splitEmail.description=Split email -# Create Disposition Schedule -createDispositionSchedule.title=Create disposition schedule -createDispositionSchedule.description=Create disposition schedule -# File Destruction Report -fileDestructionReport.title=File destruction report -fileDestructionReport.description=File destruction report -# Cut off -cutoff.title=Cut off -cutoff.description=Cut off -# Destroy -destroy.title=Destroy -destroy.description=Destroy -# Reviewed -reviewed.title=Reviewed -reviewed.description=Reviewed -# Hide Record -hide-record.title=Hide record -hide-record.description=Hide record -# Transfer -transfer.title=Transfer -transfer.description=Transfer -# Uncut off -unCutoff.title=Undo cut off -unCutoff.description=Undo cut off -# Accession -accession.title=Accession -accession.description=Accession -# Retain -retain.title=Retain -retain.description=Retain -# Add Record Types -addRecordTypes.title=Add record types -addRecordTypes.description=Adds the selected type(s) to the record -# File report -fileReport.title=File report -fileReport.description=File report -# Delete Hold -deleteHold.title=Delete Hold -deleteHold.description=Delete hold -# Move DM record -move-dm-record.title=Move record -move-dm-record.description=Move record -# Unlink from -unlinkFrom.title=Unlink from -unlinkFrom.description=Unlink from - -# Recordable version config -recordable-version-config.title=Auto-Declare Options -recordable-version-config.description=Auto-Declare Options -recordable-version-config.version.display-label=Automatically declare versions as records - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Record Category -rm-ac-is-kind-kinds.record_folder=Record Folder -rm-ac-is-kind-kinds.record=Record - -rm-ac-disposition-action-relative-positions.next=Next -rm-ac-disposition-action-relative-positions.previous=Previous -rm-ac-disposition-action-relative-positions.any=Any - -ac-versions.none=Never -ac-versions.major_only=For major versions only +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Classified by disposition schedule +isClassified.description=Has the records or record folders been classified by a disposition schedule. + +# Are cutoff +isCutoff.title=Cut Off +isCutoff.description=Records or record folders are cut off. + +# Are declared +isDeclared.title=Record completed +isDeclared.description=Is the record complete. + +# Is on hold +isFrozen.title=On Hold +isFrozen.description=Is the record or record folder on hold. + +# Are filed +isRecordFiled.title=Record filed +isRecordFiled.description=Is the record filed. + +# Are closed record folders +isRecordFolderClosed.title=Record folder closed +isRecordFolderClosed.description=Is the record folder closed. + +# Are vital +isVital.title=Vital record +isVital.description=Is the record or record folder vital. + +# Have Disposition Action +hasDispositionAction.title=Has disposition action +hasDispositionAction.description=Have the nodes got the specified associated disposition action at the specified relative position. + +# Are kind +isKind.title=Type of records management item +isKind.description=Are the nodes of a file plan component kind. +isKind.kind.display-label=Kind + +# Are Record Type +isRecordType.title=Has record type +isRecordType.description=Are the records of the specified type. + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=Declare as record +create-record.description=Declares document as a record. +create-record.file-plan.display-label=File plan +create-record.hide-record.display-label=Hide Record +# Declare As Version Record +declare-as-version-record.title=Declare version as record +declare-as-version-record.description=Declares new version of document as a version record. +declare-as-version-record.file-plan.display-label=File plan +# Complete record +declareRecord.title=Complete record +declareRecord.description=Completes a record. +# Reopens record +undeclareRecord.title=Reopen record +undeclareRecord.description=Reopens a record. +# Open record folder +openRecordFolder.title=Open record folder +openRecordFolder.description=Opens a record folder. +# Close record folder +closeRecordFolder.title=Close record folder +closeRecordFolder.description=Closes a record folder. +# Complete event +completeEvent.title=Complete event +completeEvent.description=Completes an event. +completeEvent.eventName.display-label=Event +# Freeze +freeze.title=Freeze +freeze.description=Freezes a record. +freeze.reason.display-label=Reason +# Unfreeze +unfreeze.title=Unfreeze +unfreeze.description=Unfreezes a record. +# File to +fileTo.title=File to +fileTo.description=Files a record to the specified record folder. +fileTo.path.display-label=Path to Record Folder +fileTo.createRecordPath.display-label=Create Record Path +# Copy to +copyTo.title=Copy to +copyTo.description=Copies a record to the specified record folder. +copyTo.path.display-label=Path to Record Folder +copyTo.createRecordPath.display-label=Create Record Path +# Move to +moveTo.title=Move to +moveTo.description=Moves a record to the specified record folder. +moveTo.path.display-label=Path to Record Folder +moveTo.createRecordPath.display-label=Create Record Path +# Link to +linkTo.title=Link to +linkTo.description=Links a record to the specified record folder. +linkTo.path.display-label=Path to Record Folder +linkTo.createRecordPath.display-label=Create Record Path +# Reject +reject.title=Reject +reject.description=Rejects a record and moves the document to its original location +reject.reason.display-label=Reject reason +# Request Information +requestInfo.title=Request information +requestInfo.description=Starts a workflow for requesting more information for a record +# Execute script +executeScript.title=Execute script +executeScript.description=Execute a script. +executeScript.script-ref.display-label=Script +# Send Email +sendEmail.title=Send email +sendEmail.description=Send an email +# Set Property +setPropertyValue.title=Set property value +setPropertyValue.description=Set a property value + +# Edit Hold Reason +editHoldReason.title=Edit hold reason +editHoldReason.description=Edit hold reason +# Relinquish Hold +relinquishHold.title=Relinquish hold +relinquishHold.description=Relinquish hold +# Edit Review As Of Date +editReviewAsOfDate.title=Edit review as of date +editReviewAsOfDate.description=Edit review as of date +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Edit disposition action as of date +editDispositionActionAsOfDate.description=Edit disposition action as of date +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=Broadcast vital record definition +broadcastVitalRecordDefinition.description=Broadcast vital record definition +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Broadcast disposition action definition update +broadcastDispositionActionDefinitionUpdate.description=Broadcast disposition action definition update +# Undo Event +undoEvent.title=Undo event +undoEvent.description=Undo event +# Transfer Complete +transferComplete.title=Transfer complete +transferComplete.description=Transfer complete +# Accession Complete +accessionComplete.title=Accession complete +accessionComplete.description=Accession complete +# Split Email +splitEmail.title=Split email +splitEmail.description=Split email +# Create Disposition Schedule +createDispositionSchedule.title=Create disposition schedule +createDispositionSchedule.description=Create disposition schedule +# File Destruction Report +fileDestructionReport.title=File destruction report +fileDestructionReport.description=File destruction report +# Cut off +cutoff.title=Cut off +cutoff.description=Cut off +# Destroy +destroy.title=Destroy +destroy.description=Destroy +# Reviewed +reviewed.title=Reviewed +reviewed.description=Reviewed +# Hide Record +hide-record.title=Hide record +hide-record.description=Hide record +# Transfer +transfer.title=Transfer +transfer.description=Transfer +# Uncut off +unCutoff.title=Undo cut off +unCutoff.description=Undo cut off +# Accession +accession.title=Accession +accession.description=Accession +# Retain +retain.title=Retain +retain.description=Retain +# Add Record Types +addRecordTypes.title=Add record types +addRecordTypes.description=Adds the selected type(s) to the record +# File report +fileReport.title=File report +fileReport.description=File report +# Delete Hold +deleteHold.title=Delete Hold +deleteHold.description=Delete hold +# Move DM record +move-dm-record.title=Move record +move-dm-record.description=Move record +# Unlink from +unlinkFrom.title=Unlink from +unlinkFrom.description=Unlink from + +# Recordable version config +recordable-version-config.title=Auto-Declare Options +recordable-version-config.description=Auto-Declare Options +recordable-version-config.version.display-label=Automatically declare versions as records + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Record Category +rm-ac-is-kind-kinds.record_folder=Record Folder +rm-ac-is-kind-kinds.record=Record + +rm-ac-disposition-action-relative-positions.next=Next +rm-ac-disposition-action-relative-positions.previous=Previous +rm-ac-disposition-action-relative-positions.any=Any + +ac-versions.none=Never +ac-versions.major_only=For major versions only ac-versions.all=For all major and minor versions \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_de.properties index 1ced1969d1..990a902531 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_de.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Nach Entsorgungsplan klassifiziert -isClassified.description=Gibt an, ob die Records oder Record-Ordner durch einen Entsorgungsplan klassifiziert wurden. - -# Are cutoff -isCutoff.title=Trennen -isCutoff.description=Gibt an, ob die Records oder Record-Ordner getrennt sind. - -# Are declared -isDeclared.title=Record abgeschlossen -isDeclared.description=Gibt an, ob der Record vollst\u00e4ndig ist. - -# Is on hold -isFrozen.title=Gesperrt -isFrozen.description=Gibt an, ob der Record oder Record-Ordner gesperrt ist. - -# Are filed -isRecordFiled.title=Record abgelegt -isRecordFiled.description=Gibt an, ob der Record abgelegt ist. - -# Are closed record folders -isRecordFolderClosed.title=Record-Ordner geschlossen -isRecordFolderClosed.description=Gibt an, ob der Record-Ordner geschlossen ist. - -# Are vital -isVital.title=Besonders relevanter Record -isVital.description=Gibt an, ob der Record oder Record-Ordner besonders relevant ist. - -# Have Disposition Action -hasDispositionAction.title=Hat Entsorgungsaktion -hasDispositionAction.description=Gibt an, ob die Knoten \u00fcber die angegebene zugeordnete Entsorgungsaktion an der angegebenen relativen Position verf\u00fcgen. - -# Are kind -isKind.title=Typ des Records Management Elements -isKind.description=Gibt an, ob die Knoten vom Typ Ablageplan-Komponente sind. -isKind.kind.display-label=Art - -# Are Record Type -isRecordType.title=Gibt den Record-Typ an -isRecordType.description=Gibt an, ob die Records vom angegebenen Typ sind. - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=Als Record deklarieren -create-record.description=Deklariert das Dokument als Record. -create-record.file-plan.display-label=Ablageplan -create-record.hide-record.display-label=Record ausblenden -# Declare As Version Record -declare-as-version-record.title=Version als Record deklarieren -declare-as-version-record.description=Deklariert neue Version des Dokuments als Versions-Record. -declare-as-version-record.file-plan.display-label=Ablageplan -# Complete record -declareRecord.title=Record abschlie\u00dfen -declareRecord.description=Schlie\u00dft einen Record ab. -# Reopens record -undeclareRecord.title=Record neu \u00f6ffnen -undeclareRecord.description=\u00d6ffnet einen Record neu. -# Open record folder -openRecordFolder.title=Record-Ordner \u00f6ffnen -openRecordFolder.description=\u00d6ffnet einen Record-Ordner. -# Close record folder -closeRecordFolder.title=Record-Ordner schlie\u00dfen -closeRecordFolder.description=Schlie\u00dft einen Record-Ordner. -# Complete event -completeEvent.title=Ereignis abschlie\u00dfen -completeEvent.description=Schlie\u00dft ein Ereignis ab. -completeEvent.eventName.display-label=Ereignis -# Freeze -freeze.title=Fixieren -freeze.description=Fixiert einen Record. -freeze.reason.display-label=Grund -# Unfreeze -unfreeze.title=Fixierung aufheben -unfreeze.description=Hebt die Fixierung eines Record auf. -# File to -fileTo.title=Ablegen unter -fileTo.description=Legt einen Record in einem bestimmten Record-Ordner ab. -fileTo.path.display-label=Pfad zum Record-Ordner -fileTo.createRecordPath.display-label=Record-Pfad erstellen -# Copy to -copyTo.title=Kopieren nach -copyTo.description=Kopiert einen Record in einen bestimmten Record-Ordner. -copyTo.path.display-label=Pfad zum Record-Ordner -copyTo.createRecordPath.display-label=Record-Pfad erstellen -# Move to -moveTo.title=Verschieben nach -moveTo.description=Verschiebt einen Record in einen bestimmten Record-Ordner. -moveTo.path.display-label=Pfad zum Record-Ordner -moveTo.createRecordPath.display-label=Record-Pfad erstellen -# Link to -linkTo.title=Link zu -linkTo.description=Verkn\u00fcpft einen Record mit einem bestimmten Record-Ordner. -linkTo.path.display-label=Pfad zum Record-Ordner -linkTo.createRecordPath.display-label=Record-Pfad erstellen -# Reject -reject.title=Ablehnen -reject.description=Lehnt einen Record ab und verschiebt das Dokument an seinen urspr\u00fcnglichen Speicherort. -reject.reason.display-label=Ablehnungsgrund -# Request Information -requestInfo.title=Informationen anfordern -requestInfo.description=Startet einen Workflow zur Anforderung weiterer Informationen zu einem Record. -# Execute script -executeScript.title=Skript ausf\u00fchren -executeScript.description=F\u00fchrt ein Skript aus. -executeScript.script-ref.display-label=Skript -# Send Email -sendEmail.title=E-Mail senden -sendEmail.description=Sendet eine E-Mail -# Set Property -setPropertyValue.title=Wert einer Eigenschaft setzen -setPropertyValue.description=Setzt den Wert einer Eigenschaft - -# Edit Hold Reason -editHoldReason.title=Sperrgrund bearbeiten -editHoldReason.description=Sperrgrund bearbeiten -# Relinquish Hold -relinquishHold.title=Sperre aufheben -relinquishHold.description=Sperre aufheben -# Edit Review As Of Date -editReviewAsOfDate.title=Startdatum der \u00dcberpr\u00fcfung bearbeiten -editReviewAsOfDate.description=Startdatum der \u00dcberpr\u00fcfung bearbeiten -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Startdatum der Entsorgungsaktion bearbeiten -editDispositionActionAsOfDate.description=Startdatum der Entsorgungsaktion bearbeiten -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=Definition f\u00fcr besonders relevanten Record senden -broadcastVitalRecordDefinition.description=Definition f\u00fcr besonders relevanten Record senden -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Aktualisierung der Definition der Entsorgungsaktion senden -broadcastDispositionActionDefinitionUpdate.description=Aktualisierung der Definition der Entsorgungsaktion senden -# Undo Event -undoEvent.title=Ereignis r\u00fcckg\u00e4ngig machen -undoEvent.description=Ereignis r\u00fcckg\u00e4ngig machen -# Transfer Complete -transferComplete.title=\u00dcbertragung abgeschlossen -transferComplete.description=\u00dcbertragung abgeschlossen -# Accession Complete -accessionComplete.title=Aufnahme abgeschlossen -accessionComplete.description=Aufnahme abgeschlossen -# Split Email -splitEmail.title=E-Mail teilen -splitEmail.description=E-Mail teilen -# Create Disposition Schedule -createDispositionSchedule.title=Entsorgungsplan erstellen -createDispositionSchedule.description=Entsorgungsplan erstellen -# File Destruction Report -fileDestructionReport.title=Vernichtungsprotokoll ablegen -fileDestructionReport.description=Vernichtungsprotokoll ablegen -# Cut off -cutoff.title=Trennen -cutoff.description=Trennen -# Destroy -destroy.title=Vernichten -destroy.description=Vernichten -# Reviewed -reviewed.title=\u00dcberpr\u00fcft -reviewed.description=\u00dcberpr\u00fcft -# Hide Record -hide-record.title=Record ausblenden -hide-record.description=Record ausblenden -# Transfer -transfer.title=\u00dcbertragen -transfer.description=\u00dcbertragen -# Uncut off -unCutoff.title=Trennung aufheben -unCutoff.description=Trennung aufheben -# Accession -accession.title=Aufnahme -accession.description=Aufnahme -# Retain -retain.title=Aufbewahren -retain.description=Aufbewahren -# Add Record Types -addRecordTypes.title=Record-Typen hinzuf\u00fcgen -addRecordTypes.description=F\u00fcgt ausgew\u00e4hlte Typen zum Record hinzu -# File report -fileReport.title=Bericht ablegen -fileReport.description=Bericht ablegen -# Delete Hold -deleteHold.title=Sperrbereich l\u00f6schen -deleteHold.description=Sperrbereich l\u00f6schen -# Move DM record -move-dm-record.title=Record verschieben -move-dm-record.description=Record verschieben -# Unlink from -unlinkFrom.title=Verkn\u00fcpfung aufheben von -unlinkFrom.description=Verkn\u00fcpfung aufheben von - -# Recordable version config -recordable-version-config.title=Optionen f\u00fcr automatische Deklaration -recordable-version-config.description=Optionen f\u00fcr automatische Deklaration -recordable-version-config.version.display-label=Versionen automatisch als Record deklarieren - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Record-Kategorie -rm-ac-is-kind-kinds.record_folder=Record-Ordner -rm-ac-is-kind-kinds.record=Record - -rm-ac-disposition-action-relative-positions.next=Weiter -rm-ac-disposition-action-relative-positions.previous=Vorherige -rm-ac-disposition-action-relative-positions.any=Jede - -ac-versions.none=Nie -ac-versions.major_only=Nur f\u00fcr Hauptversionen -ac-versions.all=F\u00fcr alle Haupt- und Nebenversionen +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Nach Entsorgungsplan klassifiziert +isClassified.description=Gibt an, ob die Records oder Record-Ordner durch einen Entsorgungsplan klassifiziert wurden. + +# Are cutoff +isCutoff.title=Trennen +isCutoff.description=Gibt an, ob die Records oder Record-Ordner getrennt sind. + +# Are declared +isDeclared.title=Record abgeschlossen +isDeclared.description=Gibt an, ob der Record vollst\u00e4ndig ist. + +# Is on hold +isFrozen.title=Gesperrt +isFrozen.description=Gibt an, ob der Record oder Record-Ordner gesperrt ist. + +# Are filed +isRecordFiled.title=Record abgelegt +isRecordFiled.description=Gibt an, ob der Record abgelegt ist. + +# Are closed record folders +isRecordFolderClosed.title=Record-Ordner geschlossen +isRecordFolderClosed.description=Gibt an, ob der Record-Ordner geschlossen ist. + +# Are vital +isVital.title=Besonders relevanter Record +isVital.description=Gibt an, ob der Record oder Record-Ordner besonders relevant ist. + +# Have Disposition Action +hasDispositionAction.title=Hat Entsorgungsaktion +hasDispositionAction.description=Gibt an, ob die Knoten \u00fcber die angegebene zugeordnete Entsorgungsaktion an der angegebenen relativen Position verf\u00fcgen. + +# Are kind +isKind.title=Typ des Records Management Elements +isKind.description=Gibt an, ob die Knoten vom Typ Ablageplan-Komponente sind. +isKind.kind.display-label=Art + +# Are Record Type +isRecordType.title=Gibt den Record-Typ an +isRecordType.description=Gibt an, ob die Records vom angegebenen Typ sind. + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=Als Record deklarieren +create-record.description=Deklariert das Dokument als Record. +create-record.file-plan.display-label=Ablageplan +create-record.hide-record.display-label=Record ausblenden +# Declare As Version Record +declare-as-version-record.title=Version als Record deklarieren +declare-as-version-record.description=Deklariert neue Version des Dokuments als Versions-Record. +declare-as-version-record.file-plan.display-label=Ablageplan +# Complete record +declareRecord.title=Record abschlie\u00dfen +declareRecord.description=Schlie\u00dft einen Record ab. +# Reopens record +undeclareRecord.title=Record neu \u00f6ffnen +undeclareRecord.description=\u00d6ffnet einen Record neu. +# Open record folder +openRecordFolder.title=Record-Ordner \u00f6ffnen +openRecordFolder.description=\u00d6ffnet einen Record-Ordner. +# Close record folder +closeRecordFolder.title=Record-Ordner schlie\u00dfen +closeRecordFolder.description=Schlie\u00dft einen Record-Ordner. +# Complete event +completeEvent.title=Ereignis abschlie\u00dfen +completeEvent.description=Schlie\u00dft ein Ereignis ab. +completeEvent.eventName.display-label=Ereignis +# Freeze +freeze.title=Fixieren +freeze.description=Fixiert einen Record. +freeze.reason.display-label=Grund +# Unfreeze +unfreeze.title=Fixierung aufheben +unfreeze.description=Hebt die Fixierung eines Record auf. +# File to +fileTo.title=Ablegen unter +fileTo.description=Legt einen Record in einem bestimmten Record-Ordner ab. +fileTo.path.display-label=Pfad zum Record-Ordner +fileTo.createRecordPath.display-label=Record-Pfad erstellen +# Copy to +copyTo.title=Kopieren nach +copyTo.description=Kopiert einen Record in einen bestimmten Record-Ordner. +copyTo.path.display-label=Pfad zum Record-Ordner +copyTo.createRecordPath.display-label=Record-Pfad erstellen +# Move to +moveTo.title=Verschieben nach +moveTo.description=Verschiebt einen Record in einen bestimmten Record-Ordner. +moveTo.path.display-label=Pfad zum Record-Ordner +moveTo.createRecordPath.display-label=Record-Pfad erstellen +# Link to +linkTo.title=Link zu +linkTo.description=Verkn\u00fcpft einen Record mit einem bestimmten Record-Ordner. +linkTo.path.display-label=Pfad zum Record-Ordner +linkTo.createRecordPath.display-label=Record-Pfad erstellen +# Reject +reject.title=Ablehnen +reject.description=Lehnt einen Record ab und verschiebt das Dokument an seinen urspr\u00fcnglichen Speicherort. +reject.reason.display-label=Ablehnungsgrund +# Request Information +requestInfo.title=Informationen anfordern +requestInfo.description=Startet einen Workflow zur Anforderung weiterer Informationen zu einem Record. +# Execute script +executeScript.title=Skript ausf\u00fchren +executeScript.description=F\u00fchrt ein Skript aus. +executeScript.script-ref.display-label=Skript +# Send Email +sendEmail.title=E-Mail senden +sendEmail.description=Sendet eine E-Mail +# Set Property +setPropertyValue.title=Wert einer Eigenschaft setzen +setPropertyValue.description=Setzt den Wert einer Eigenschaft + +# Edit Hold Reason +editHoldReason.title=Sperrgrund bearbeiten +editHoldReason.description=Sperrgrund bearbeiten +# Relinquish Hold +relinquishHold.title=Sperre aufheben +relinquishHold.description=Sperre aufheben +# Edit Review As Of Date +editReviewAsOfDate.title=Startdatum der \u00dcberpr\u00fcfung bearbeiten +editReviewAsOfDate.description=Startdatum der \u00dcberpr\u00fcfung bearbeiten +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Startdatum der Entsorgungsaktion bearbeiten +editDispositionActionAsOfDate.description=Startdatum der Entsorgungsaktion bearbeiten +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=Definition f\u00fcr besonders relevanten Record senden +broadcastVitalRecordDefinition.description=Definition f\u00fcr besonders relevanten Record senden +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Aktualisierung der Definition der Entsorgungsaktion senden +broadcastDispositionActionDefinitionUpdate.description=Aktualisierung der Definition der Entsorgungsaktion senden +# Undo Event +undoEvent.title=Ereignis r\u00fcckg\u00e4ngig machen +undoEvent.description=Ereignis r\u00fcckg\u00e4ngig machen +# Transfer Complete +transferComplete.title=\u00dcbertragung abgeschlossen +transferComplete.description=\u00dcbertragung abgeschlossen +# Accession Complete +accessionComplete.title=Aufnahme abgeschlossen +accessionComplete.description=Aufnahme abgeschlossen +# Split Email +splitEmail.title=E-Mail teilen +splitEmail.description=E-Mail teilen +# Create Disposition Schedule +createDispositionSchedule.title=Entsorgungsplan erstellen +createDispositionSchedule.description=Entsorgungsplan erstellen +# File Destruction Report +fileDestructionReport.title=Vernichtungsprotokoll ablegen +fileDestructionReport.description=Vernichtungsprotokoll ablegen +# Cut off +cutoff.title=Trennen +cutoff.description=Trennen +# Destroy +destroy.title=Vernichten +destroy.description=Vernichten +# Reviewed +reviewed.title=\u00dcberpr\u00fcft +reviewed.description=\u00dcberpr\u00fcft +# Hide Record +hide-record.title=Record ausblenden +hide-record.description=Record ausblenden +# Transfer +transfer.title=\u00dcbertragen +transfer.description=\u00dcbertragen +# Uncut off +unCutoff.title=Trennung aufheben +unCutoff.description=Trennung aufheben +# Accession +accession.title=Aufnahme +accession.description=Aufnahme +# Retain +retain.title=Aufbewahren +retain.description=Aufbewahren +# Add Record Types +addRecordTypes.title=Record-Typen hinzuf\u00fcgen +addRecordTypes.description=F\u00fcgt ausgew\u00e4hlte Typen zum Record hinzu +# File report +fileReport.title=Bericht ablegen +fileReport.description=Bericht ablegen +# Delete Hold +deleteHold.title=Sperrbereich l\u00f6schen +deleteHold.description=Sperrbereich l\u00f6schen +# Move DM record +move-dm-record.title=Record verschieben +move-dm-record.description=Record verschieben +# Unlink from +unlinkFrom.title=Verkn\u00fcpfung aufheben von +unlinkFrom.description=Verkn\u00fcpfung aufheben von + +# Recordable version config +recordable-version-config.title=Optionen f\u00fcr automatische Deklaration +recordable-version-config.description=Optionen f\u00fcr automatische Deklaration +recordable-version-config.version.display-label=Versionen automatisch als Record deklarieren + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Record-Kategorie +rm-ac-is-kind-kinds.record_folder=Record-Ordner +rm-ac-is-kind-kinds.record=Record + +rm-ac-disposition-action-relative-positions.next=Weiter +rm-ac-disposition-action-relative-positions.previous=Vorherige +rm-ac-disposition-action-relative-positions.any=Jede + +ac-versions.none=Nie +ac-versions.major_only=Nur f\u00fcr Hauptversionen +ac-versions.all=F\u00fcr alle Haupt- und Nebenversionen diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_es.properties index 01b120e374..9126057bd5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_es.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Clasificado mediante esquema de disposici\u00f3n -isClassified.description=Los documentos de archivo o las carpetas de documentos de archivo se han clasificado mediante un esquema de disposici\u00f3n. - -# Are cutoff -isCutoff.title=Interrumpir -isCutoff.description=Los documentos de archivo o las carpetas de documentos de archivo est\u00e1n interrumpidos. - -# Are declared -isDeclared.title=Documento de archivo completado -isDeclared.description=El documento de archivo se ha completado. - -# Is on hold -isFrozen.title=En espera -isFrozen.description=El documento de archivo o la carpeta de documentos de archivo est\u00e1 en espera. - -# Are filed -isRecordFiled.title=Documento de archivo rellenado -isRecordFiled.description=El documento de archivo se ha rellenado. - -# Are closed record folders -isRecordFolderClosed.title=Carpeta de documentos de archivo cerrada -isRecordFolderClosed.description=La carpeta de documentos de archivo est\u00e1 cerrada. - -# Are vital -isVital.title=Documento de archivo vital -isVital.description=El documento de archivo o la carpeta de documentos de archivo es vital. - -# Have Disposition Action -hasDispositionAction.title=Tiene acci\u00f3n de disposici\u00f3n -hasDispositionAction.description=Hace que los nodos tengan la acci\u00f3n de disposici\u00f3n asociada especificada en la posici\u00f3n relativa especificada. - -# Are kind -isKind.title=Tipo de elemento de gesti\u00f3n de documentos de archivo -isKind.description=Son los nodos de una clase de componente del plan de ficheros. -isKind.kind.display-label=Clase - -# Are Record Type -isRecordType.title=Tiene tipo de documento de archivo -isRecordType.description=Los documentos de archivo son del tipo especificado. - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=Declarar como documento de archivo -create-record.description=Declara el documento como un documento de archivo. -create-record.file-plan.display-label=Plan de ficheros -create-record.hide-record.display-label=Ocultar documento de archivo -# Declare As Version Record -declare-as-version-record.title=Declarar versi\u00f3n como documento de archivo -declare-as-version-record.description=Declara la nueva versi\u00f3n del documento como documento de archivo versionado. -declare-as-version-record.file-plan.display-label=Plan de ficheros -# Complete record -declareRecord.title=Documento de archivo completo -declareRecord.description=Completa un documento de archivo. -# Reopens record -undeclareRecord.title=Reabrir documento de archivo -undeclareRecord.description=Reabre un documento de archivo. -# Open record folder -openRecordFolder.title=Abrir carpeta de documentos de archivo -openRecordFolder.description=Abre una carpeta de documentos de archivo. -# Close record folder -closeRecordFolder.title=Cerrar carpeta de documentos de archivo -closeRecordFolder.description=Cierra una carpeta de documentos de archivo. -# Complete event -completeEvent.title=Completar evento -completeEvent.description=Completa un evento. -completeEvent.eventName.display-label=Evento -# Freeze -freeze.title=Congelar -freeze.description=Congela un documento de archivo. -freeze.reason.display-label=Raz\u00f3n -# Unfreeze -unfreeze.title=Descongelar -unfreeze.description=Descongela un documento de archivo. -# File to -fileTo.title=Archivar en -fileTo.description=Archiva un documento de archivo en la carpeta de documentos de archivo especificada. -fileTo.path.display-label=Ruta a la carpeta de documentos de archivo -fileTo.createRecordPath.display-label=Crea una ruta a los documentos de archivo -# Copy to -copyTo.title=Copiar a -copyTo.description=Copia un documento de archivo en la carpeta de documentos de archivo especificada. -copyTo.path.display-label=Ruta a la carpeta de documentos de archivo -copyTo.createRecordPath.display-label=Crea una ruta a la carpeta de documentos de archivo -# Move to -moveTo.title=Mover a -moveTo.description=Mueve un documento de archivo en la carpeta de documentos de archivo especificada. -moveTo.path.display-label=Ruta a la carpeta de documentos de archivo -moveTo.createRecordPath.display-label=Crea una ruta a los documentos de archivo -# Link to -linkTo.title=Enlace a -linkTo.description=Enlaza un documento de archivo a la carpeta de documentos de archivo especificada. -linkTo.path.display-label=Ruta a la carpeta de documentos de archivo -linkTo.createRecordPath.display-label=Crea una ruta a la carpeta de documentos de archivo -# Reject -reject.title=Rechazar -reject.description=Rechaza un documento de archivo y mueve el documento a su ubicaci\u00f3n original -reject.reason.display-label=Rechaza la raz\u00f3n -# Request Information -requestInfo.title=Solicitar informaci\u00f3n -requestInfo.description=Inicia un flujo de trabajo para solicitar m\u00e1s informaci\u00f3n para un documento de archivo -# Execute script -executeScript.title=Ejecutar script -executeScript.description=Ejecuta un script. -executeScript.script-ref.display-label=Script -# Send Email -sendEmail.title=Enviar correo electr\u00f3nico -sendEmail.description=Env\u00eda un correo electr\u00f3nico -# Set Property -setPropertyValue.title=Establecer valor de la propiedad -setPropertyValue.description=Establece un valor de la propiedad - -# Edit Hold Reason -editHoldReason.title=Editar raz\u00f3n de bloqueo -editHoldReason.description=Edita la raz\u00f3n de bloqueo -# Relinquish Hold -relinquishHold.title=Eliminar bloqueo -relinquishHold.description=Elimina el bloqueo -# Edit Review As Of Date -editReviewAsOfDate.title=Editar fecha de inicio de revisi\u00f3n -editReviewAsOfDate.description=Edita la fecha de inicio de revisi\u00f3n -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Editar fecha de inicio de acci\u00f3n de disposici\u00f3n -editDispositionActionAsOfDate.description=Edita la fecha de inicio de acci\u00f3n de disposici\u00f3n -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=Difundir definici\u00f3n de documento de archivo vital -broadcastVitalRecordDefinition.description=Difunde la definici\u00f3n de documento de archivo vital -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Difundir definici\u00f3n de acciones de disposici\u00f3n -broadcastDispositionActionDefinitionUpdate.description=Difunde la definici\u00f3n de acciones de disposici\u00f3n -# Undo Event -undoEvent.title=Deshacer evento -undoEvent.description=Deshace el evento -# Transfer Complete -transferComplete.title=Transferencia completa -transferComplete.description=Transferencia completa -# Accession Complete -accessionComplete.title=Adhesi\u00f3n completa -accessionComplete.description=Adhesi\u00f3n completa -# Split Email -splitEmail.title=Separar correo electr\u00f3nico -splitEmail.description=Separa el correo electr\u00f3nico -# Create Disposition Schedule -createDispositionSchedule.title=Crear planificaci\u00f3n de disposici\u00f3n -createDispositionSchedule.description=Creaa la planificaci\u00f3n de disposici\u00f3n -# File Destruction Report -fileDestructionReport.title=Archivar informe de destrucci\u00f3n -fileDestructionReport.description=Archiva el informe de destrucci\u00f3n -# Cut off -cutoff.title=Interrumpir -cutoff.description=Interrumpir -# Destroy -destroy.title=Destruir -destroy.description=Destruir -# Reviewed -reviewed.title=Revisado -reviewed.description=Revisado -# Hide Record -hide-record.title=Ocultar documento de archivo -hide-record.description=Oculta el documento de archivo -# Transfer -transfer.title=Transferencia -transfer.description=Transferencia -# Uncut off -unCutoff.title=Deshacer interrupci\u00f3n -unCutoff.description=Deshace la interrupci\u00f3n -# Accession -accession.title=Adhesi\u00f3n -accession.description=Adhesi\u00f3n -# Retain -retain.title=Retener -retain.description=Retener -# Add Record Types -addRecordTypes.title=A\u00f1adir tipos de documento de archivo -addRecordTypes.description=A\u00f1ade los tipos seleccionados al documento de archivo -# File report -fileReport.title=Archivar informe -fileReport.description=Archiva el informe -# Delete Hold -deleteHold.title=Eliminar bloqueo -deleteHold.description=Elimina el bloqueo -# Move DM record -move-dm-record.title=Mover documento de archivo -move-dm-record.description=Mueve el documento de archivo -# Unlink from -unlinkFrom.title=Desvincular de -unlinkFrom.description=De donde se desvincula - -# Recordable version config -recordable-version-config.title=Opciones de declaraci\u00f3n autom\u00e1tica -recordable-version-config.description=Opciones de declaraci\u00f3n autom\u00e1tica -recordable-version-config.version.display-label=Declarar autom\u00e1ticamente versiones como documentos de archivo - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Categor\u00eda de documentos de archivo -rm-ac-is-kind-kinds.record_folder=Carpeta de documentos de archivo -rm-ac-is-kind-kinds.record=Documento de archivo - -rm-ac-disposition-action-relative-positions.next=Siguiente -rm-ac-disposition-action-relative-positions.previous=Anterior -rm-ac-disposition-action-relative-positions.any=Cualquiera - -ac-versions.none=Nunca -ac-versions.major_only=Solo para versiones mayores +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Clasificado mediante esquema de disposici\u00f3n +isClassified.description=Los documentos de archivo o las carpetas de documentos de archivo se han clasificado mediante un esquema de disposici\u00f3n. + +# Are cutoff +isCutoff.title=Interrumpir +isCutoff.description=Los documentos de archivo o las carpetas de documentos de archivo est\u00e1n interrumpidos. + +# Are declared +isDeclared.title=Documento de archivo completado +isDeclared.description=El documento de archivo se ha completado. + +# Is on hold +isFrozen.title=En espera +isFrozen.description=El documento de archivo o la carpeta de documentos de archivo est\u00e1 en espera. + +# Are filed +isRecordFiled.title=Documento de archivo rellenado +isRecordFiled.description=El documento de archivo se ha rellenado. + +# Are closed record folders +isRecordFolderClosed.title=Carpeta de documentos de archivo cerrada +isRecordFolderClosed.description=La carpeta de documentos de archivo est\u00e1 cerrada. + +# Are vital +isVital.title=Documento de archivo vital +isVital.description=El documento de archivo o la carpeta de documentos de archivo es vital. + +# Have Disposition Action +hasDispositionAction.title=Tiene acci\u00f3n de disposici\u00f3n +hasDispositionAction.description=Hace que los nodos tengan la acci\u00f3n de disposici\u00f3n asociada especificada en la posici\u00f3n relativa especificada. + +# Are kind +isKind.title=Tipo de elemento de gesti\u00f3n de documentos de archivo +isKind.description=Son los nodos de una clase de componente del plan de ficheros. +isKind.kind.display-label=Clase + +# Are Record Type +isRecordType.title=Tiene tipo de documento de archivo +isRecordType.description=Los documentos de archivo son del tipo especificado. + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=Declarar como documento de archivo +create-record.description=Declara el documento como un documento de archivo. +create-record.file-plan.display-label=Plan de ficheros +create-record.hide-record.display-label=Ocultar documento de archivo +# Declare As Version Record +declare-as-version-record.title=Declarar versi\u00f3n como documento de archivo +declare-as-version-record.description=Declara la nueva versi\u00f3n del documento como documento de archivo versionado. +declare-as-version-record.file-plan.display-label=Plan de ficheros +# Complete record +declareRecord.title=Documento de archivo completo +declareRecord.description=Completa un documento de archivo. +# Reopens record +undeclareRecord.title=Reabrir documento de archivo +undeclareRecord.description=Reabre un documento de archivo. +# Open record folder +openRecordFolder.title=Abrir carpeta de documentos de archivo +openRecordFolder.description=Abre una carpeta de documentos de archivo. +# Close record folder +closeRecordFolder.title=Cerrar carpeta de documentos de archivo +closeRecordFolder.description=Cierra una carpeta de documentos de archivo. +# Complete event +completeEvent.title=Completar evento +completeEvent.description=Completa un evento. +completeEvent.eventName.display-label=Evento +# Freeze +freeze.title=Congelar +freeze.description=Congela un documento de archivo. +freeze.reason.display-label=Raz\u00f3n +# Unfreeze +unfreeze.title=Descongelar +unfreeze.description=Descongela un documento de archivo. +# File to +fileTo.title=Archivar en +fileTo.description=Archiva un documento de archivo en la carpeta de documentos de archivo especificada. +fileTo.path.display-label=Ruta a la carpeta de documentos de archivo +fileTo.createRecordPath.display-label=Crea una ruta a los documentos de archivo +# Copy to +copyTo.title=Copiar a +copyTo.description=Copia un documento de archivo en la carpeta de documentos de archivo especificada. +copyTo.path.display-label=Ruta a la carpeta de documentos de archivo +copyTo.createRecordPath.display-label=Crea una ruta a la carpeta de documentos de archivo +# Move to +moveTo.title=Mover a +moveTo.description=Mueve un documento de archivo en la carpeta de documentos de archivo especificada. +moveTo.path.display-label=Ruta a la carpeta de documentos de archivo +moveTo.createRecordPath.display-label=Crea una ruta a los documentos de archivo +# Link to +linkTo.title=Enlace a +linkTo.description=Enlaza un documento de archivo a la carpeta de documentos de archivo especificada. +linkTo.path.display-label=Ruta a la carpeta de documentos de archivo +linkTo.createRecordPath.display-label=Crea una ruta a la carpeta de documentos de archivo +# Reject +reject.title=Rechazar +reject.description=Rechaza un documento de archivo y mueve el documento a su ubicaci\u00f3n original +reject.reason.display-label=Rechaza la raz\u00f3n +# Request Information +requestInfo.title=Solicitar informaci\u00f3n +requestInfo.description=Inicia un flujo de trabajo para solicitar m\u00e1s informaci\u00f3n para un documento de archivo +# Execute script +executeScript.title=Ejecutar script +executeScript.description=Ejecuta un script. +executeScript.script-ref.display-label=Script +# Send Email +sendEmail.title=Enviar correo electr\u00f3nico +sendEmail.description=Env\u00eda un correo electr\u00f3nico +# Set Property +setPropertyValue.title=Establecer valor de la propiedad +setPropertyValue.description=Establece un valor de la propiedad + +# Edit Hold Reason +editHoldReason.title=Editar raz\u00f3n de bloqueo +editHoldReason.description=Edita la raz\u00f3n de bloqueo +# Relinquish Hold +relinquishHold.title=Eliminar bloqueo +relinquishHold.description=Elimina el bloqueo +# Edit Review As Of Date +editReviewAsOfDate.title=Editar fecha de inicio de revisi\u00f3n +editReviewAsOfDate.description=Edita la fecha de inicio de revisi\u00f3n +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Editar fecha de inicio de acci\u00f3n de disposici\u00f3n +editDispositionActionAsOfDate.description=Edita la fecha de inicio de acci\u00f3n de disposici\u00f3n +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=Difundir definici\u00f3n de documento de archivo vital +broadcastVitalRecordDefinition.description=Difunde la definici\u00f3n de documento de archivo vital +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Difundir definici\u00f3n de acciones de disposici\u00f3n +broadcastDispositionActionDefinitionUpdate.description=Difunde la definici\u00f3n de acciones de disposici\u00f3n +# Undo Event +undoEvent.title=Deshacer evento +undoEvent.description=Deshace el evento +# Transfer Complete +transferComplete.title=Transferencia completa +transferComplete.description=Transferencia completa +# Accession Complete +accessionComplete.title=Adhesi\u00f3n completa +accessionComplete.description=Adhesi\u00f3n completa +# Split Email +splitEmail.title=Separar correo electr\u00f3nico +splitEmail.description=Separa el correo electr\u00f3nico +# Create Disposition Schedule +createDispositionSchedule.title=Crear planificaci\u00f3n de disposici\u00f3n +createDispositionSchedule.description=Creaa la planificaci\u00f3n de disposici\u00f3n +# File Destruction Report +fileDestructionReport.title=Archivar informe de destrucci\u00f3n +fileDestructionReport.description=Archiva el informe de destrucci\u00f3n +# Cut off +cutoff.title=Interrumpir +cutoff.description=Interrumpir +# Destroy +destroy.title=Destruir +destroy.description=Destruir +# Reviewed +reviewed.title=Revisado +reviewed.description=Revisado +# Hide Record +hide-record.title=Ocultar documento de archivo +hide-record.description=Oculta el documento de archivo +# Transfer +transfer.title=Transferencia +transfer.description=Transferencia +# Uncut off +unCutoff.title=Deshacer interrupci\u00f3n +unCutoff.description=Deshace la interrupci\u00f3n +# Accession +accession.title=Adhesi\u00f3n +accession.description=Adhesi\u00f3n +# Retain +retain.title=Retener +retain.description=Retener +# Add Record Types +addRecordTypes.title=A\u00f1adir tipos de documento de archivo +addRecordTypes.description=A\u00f1ade los tipos seleccionados al documento de archivo +# File report +fileReport.title=Archivar informe +fileReport.description=Archiva el informe +# Delete Hold +deleteHold.title=Eliminar bloqueo +deleteHold.description=Elimina el bloqueo +# Move DM record +move-dm-record.title=Mover documento de archivo +move-dm-record.description=Mueve el documento de archivo +# Unlink from +unlinkFrom.title=Desvincular de +unlinkFrom.description=De donde se desvincula + +# Recordable version config +recordable-version-config.title=Opciones de declaraci\u00f3n autom\u00e1tica +recordable-version-config.description=Opciones de declaraci\u00f3n autom\u00e1tica +recordable-version-config.version.display-label=Declarar autom\u00e1ticamente versiones como documentos de archivo + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Categor\u00eda de documentos de archivo +rm-ac-is-kind-kinds.record_folder=Carpeta de documentos de archivo +rm-ac-is-kind-kinds.record=Documento de archivo + +rm-ac-disposition-action-relative-positions.next=Siguiente +rm-ac-disposition-action-relative-positions.previous=Anterior +rm-ac-disposition-action-relative-positions.any=Cualquiera + +ac-versions.none=Nunca +ac-versions.major_only=Solo para versiones mayores ac-versions.all=Para todas las versiones mayores y menores \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_fr.properties index e616c312c6..fa70922289 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_fr.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Class\u00e9 par r\u00e8gle de conservation -isClassified.description=Ont les documents d'archives ou les dossiers d'archives \u00e9t\u00e9 class\u00e9s par une r\u00e8gle de conservation. - -# Are cutoff -isCutoff.title=D\u00e9classer -isCutoff.description=Les documents d'archives ou les dossiers d'archives sont d\u00e9class\u00e9s. - -# Are declared -isDeclared.title=Document d'archives termin\u00e9 -isDeclared.description=Est le document d'archives termin\u00e9. - -# Is on hold -isFrozen.title=Suspendu -isFrozen.description=Est le document d'archives ou le dossier d'archives suspendu. - -# Are filed -isRecordFiled.title=Document d'archives archiv\u00e9 -isRecordFiled.description=Est le document d'archives archiv\u00e9. - -# Are closed record folders -isRecordFolderClosed.title=Dossier d'archives ferm\u00e9 -isRecordFolderClosed.description=Est le dossier d'archives ferm\u00e9. - -# Are vital -isVital.title=Document d'archives essentiel -isVital.description=Est le document d'archives ou le dossier d'archives essentiel. - -# Have Disposition Action -hasDispositionAction.title=A une action de disposition -hasDispositionAction.description=Demandent aux noeuds d'avoir l'action de disposition associ\u00e9e d\u00e9finie \u00e0 la position relative d\u00e9finie. - -# Are kind -isKind.title=Type d'\u00e9l\u00e9ment de gestion des archives -isKind.description=Sont les noeuds d'un type de composant du plan de classification. -isKind.kind.display-label=Type - -# Are Record Type -isRecordType.title=Demande le type de document d'archives -isRecordType.description=Sont les documents d'archives du type d\u00e9fini. - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=D\u00e9clarer comme document d'archives -create-record.description=D\u00e9clare un document comme document d'archives -create-record.file-plan.display-label=Plan de classification -create-record.hide-record.display-label=Masquer le document d'archives -# Declare As Version Record -declare-as-version-record.title=D\u00e9clarer la version comme document d'archives -declare-as-version-record.description=D\u00e9clare la nouvelle version d'un document comme document d'archive versionn\u00e9. -declare-as-version-record.file-plan.display-label=Plan de classification -# Complete record -declareRecord.title=Compl\u00e9ter un document d'archives -declareRecord.description=Compl\u00e8te un document d'archives. -# Reopens record -undeclareRecord.title=Rouvrir un document d'archives -undeclareRecord.description=Rouvre un document d'archives. -# Open record folder -openRecordFolder.title=Ouvrir un dossier d'archives -openRecordFolder.description=Ouvre un dossier d'archives. -# Close record folder -closeRecordFolder.title=Fermer un dossier d'archives -closeRecordFolder.description=Ferme un dossier d'archives. -# Complete event -completeEvent.title=Compl\u00e9ter un \u00e9v\u00e9nement -completeEvent.description=Compl\u00e8te un \u00e9v\u00e9nement. -completeEvent.eventName.display-label=Ev\u00e9nement -# Freeze -freeze.title=Geler -freeze.description=G\u00e8le un document d'archives. -freeze.reason.display-label=Motif -# Unfreeze -unfreeze.title=D\u00e9geler -unfreeze.description=D\u00e9g\u00e8le un document d'archives. -# File to -fileTo.title=Archiver dans -fileTo.description=Archive un document d'archives dans le dossier d'archives d\u00e9fini. -fileTo.path.display-label=Chemin de dossier d'archives -fileTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives -# Copy to -copyTo.title=Copier vers... -copyTo.description=Copie un document d'archives vers le dossier d'archives d\u00e9fini. -copyTo.path.display-label=Chemin de dossier d'archives -copyTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives -# Move to -moveTo.title=D\u00e9placer vers... -moveTo.description=D\u00e9place un document d'archives vers le dossier d'archives d\u00e9fini. -moveTo.path.display-label=Chemin de dossier d'archives -moveTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives -# Link to -linkTo.title=Lier \u00e0 -linkTo.description=Lie un document d'archives vers le dossier d'archives d\u00e9fini. -linkTo.path.display-label=Chemin de dossier d'archives -linkTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives -# Reject -reject.title=Rejeter -reject.description=Rejette un document d'archives et place le document dans son emplacement d'origine -reject.reason.display-label=Motif du rejet -# Request Information -requestInfo.title=Demander des informations -requestInfo.description=D\u00e9marre un workflow pour demander plus d'informations sur un document d'archives -# Execute script -executeScript.title=Ex\u00e9cuter le script -executeScript.description=Ex\u00e9cuter un script. -executeScript.script-ref.display-label=Script -# Send Email -sendEmail.title=Envoyer un e-mail -sendEmail.description=Envoyer un e-mail -# Set Property -setPropertyValue.title=D\u00e9finir la valeur de la propri\u00e9t\u00e9 -setPropertyValue.description=D\u00e9finir une valeur de propri\u00e9t\u00e9 - -# Edit Hold Reason -editHoldReason.title=Modifier le motif de suspension -editHoldReason.description=Modifier le motif de suspension -# Relinquish Hold -relinquishHold.title=Lever la suspension -relinquishHold.description=Lever la suspension -# Edit Review As Of Date -editReviewAsOfDate.title=Modifier la date de d\u00e9but de la r\u00e9vision -editReviewAsOfDate.description=Modifier la date de d\u00e9but de la r\u00e9vision -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Modifier la date de d\u00e9but de l'action de disposition -editDispositionActionAsOfDate.description=Modifier la date de d\u00e9but de l'action de disposition -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=D\u00e9finition du document d'archives essentiel diffus\u00e9e -broadcastVitalRecordDefinition.description=D\u00e9finition du document d'archives essentiel diffus\u00e9e -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Mise \u00e0 jour de la d\u00e9finition de l'action de disposition diffus\u00e9e -broadcastDispositionActionDefinitionUpdate.description=Mise \u00e0 jour de la d\u00e9finition de l'action de disposition diffus\u00e9e -# Undo Event -undoEvent.title=Annuler l'\u00e9v\u00e9nement -undoEvent.description=Annuler l'\u00e9v\u00e9nement -# Transfer Complete -transferComplete.title=Transfert termin\u00e9 -transferComplete.description=Transfert termin\u00e9 -# Accession Complete -accessionComplete.title=Versement \u00e0 un autre organisme termin\u00e9 -accessionComplete.description=Versement \u00e0 un autre organisme termin\u00e9 -# Split Email -splitEmail.title=Partager l'e-mail -splitEmail.description=Partager l'e-mail -# Create Disposition Schedule -createDispositionSchedule.title=Cr\u00e9er une r\u00e8gle de conservation -createDispositionSchedule.description=Cr\u00e9er une r\u00e8gle de conservation -# File Destruction Report -fileDestructionReport.title=Rapport de destruction de fichier -fileDestructionReport.description=Rapport de destruction de fichier -# Cut off -cutoff.title=D\u00e9classer -cutoff.description=D\u00e9classer -# Destroy -destroy.title=D\u00e9truire -destroy.description=D\u00e9truire -# Reviewed -reviewed.title=V\u00e9rifi\u00e9 -reviewed.description=V\u00e9rifi\u00e9 -# Hide Record -hide-record.title=Masquer le document d'archives -hide-record.description=Masquer le document d'archives -# Transfer -transfer.title=Transf\u00e9rer -transfer.description=Transf\u00e9rer -# Uncut off -unCutoff.title=Annuler le d\u00e9classement -unCutoff.description=Annuler le d\u00e9classement -# Accession -accession.title=Versement \u00e0 un autre organisme -accession.description=Versement \u00e0 un autre organisme -# Retain -retain.title=Retenir -retain.description=Retenir -# Add Record Types -addRecordTypes.title=Ajouter des types de document d'archives -addRecordTypes.description=Ajoute le(s) type(s) s\u00e9lectionn\u00e9(s) au document d'archives -# File report -fileReport.title=Archiver le rapport -fileReport.description=Archiver le rapport -# Delete Hold -deleteHold.title=Supprimer la suspension -deleteHold.description=Supprimer la suspension -# Move DM record -move-dm-record.title=D\u00e9placer le document d'archives -move-dm-record.description=D\u00e9placer le document d'archives -# Unlink from -unlinkFrom.title=Supprimer le lien de -unlinkFrom.description=Supprimer le lien de - -# Recordable version config -recordable-version-config.title=Options de d\u00e9claration automatique -recordable-version-config.description=Options de d\u00e9claration automatique -recordable-version-config.version.display-label=D\u00e9clarer automatiquement les versions comme documents d'archives - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Cat\u00e9gorie de document d'archives -rm-ac-is-kind-kinds.record_folder=Dossier d'archives -rm-ac-is-kind-kinds.record=Document d'archives - -rm-ac-disposition-action-relative-positions.next=Suivant -rm-ac-disposition-action-relative-positions.previous=Pr\u00e9c\u00e9dent -rm-ac-disposition-action-relative-positions.any=N'importe lequel - -ac-versions.none=Jamais -ac-versions.major_only=Uniquement les versions majeures +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Class\u00e9 par r\u00e8gle de conservation +isClassified.description=Ont les documents d'archives ou les dossiers d'archives \u00e9t\u00e9 class\u00e9s par une r\u00e8gle de conservation. + +# Are cutoff +isCutoff.title=D\u00e9classer +isCutoff.description=Les documents d'archives ou les dossiers d'archives sont d\u00e9class\u00e9s. + +# Are declared +isDeclared.title=Document d'archives termin\u00e9 +isDeclared.description=Est le document d'archives termin\u00e9. + +# Is on hold +isFrozen.title=Suspendu +isFrozen.description=Est le document d'archives ou le dossier d'archives suspendu. + +# Are filed +isRecordFiled.title=Document d'archives archiv\u00e9 +isRecordFiled.description=Est le document d'archives archiv\u00e9. + +# Are closed record folders +isRecordFolderClosed.title=Dossier d'archives ferm\u00e9 +isRecordFolderClosed.description=Est le dossier d'archives ferm\u00e9. + +# Are vital +isVital.title=Document d'archives essentiel +isVital.description=Est le document d'archives ou le dossier d'archives essentiel. + +# Have Disposition Action +hasDispositionAction.title=A une action de disposition +hasDispositionAction.description=Demandent aux noeuds d'avoir l'action de disposition associ\u00e9e d\u00e9finie \u00e0 la position relative d\u00e9finie. + +# Are kind +isKind.title=Type d'\u00e9l\u00e9ment de gestion des archives +isKind.description=Sont les noeuds d'un type de composant du plan de classification. +isKind.kind.display-label=Type + +# Are Record Type +isRecordType.title=Demande le type de document d'archives +isRecordType.description=Sont les documents d'archives du type d\u00e9fini. + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=D\u00e9clarer comme document d'archives +create-record.description=D\u00e9clare un document comme document d'archives +create-record.file-plan.display-label=Plan de classification +create-record.hide-record.display-label=Masquer le document d'archives +# Declare As Version Record +declare-as-version-record.title=D\u00e9clarer la version comme document d'archives +declare-as-version-record.description=D\u00e9clare la nouvelle version d'un document comme document d'archive versionn\u00e9. +declare-as-version-record.file-plan.display-label=Plan de classification +# Complete record +declareRecord.title=Compl\u00e9ter un document d'archives +declareRecord.description=Compl\u00e8te un document d'archives. +# Reopens record +undeclareRecord.title=Rouvrir un document d'archives +undeclareRecord.description=Rouvre un document d'archives. +# Open record folder +openRecordFolder.title=Ouvrir un dossier d'archives +openRecordFolder.description=Ouvre un dossier d'archives. +# Close record folder +closeRecordFolder.title=Fermer un dossier d'archives +closeRecordFolder.description=Ferme un dossier d'archives. +# Complete event +completeEvent.title=Compl\u00e9ter un \u00e9v\u00e9nement +completeEvent.description=Compl\u00e8te un \u00e9v\u00e9nement. +completeEvent.eventName.display-label=Ev\u00e9nement +# Freeze +freeze.title=Geler +freeze.description=G\u00e8le un document d'archives. +freeze.reason.display-label=Motif +# Unfreeze +unfreeze.title=D\u00e9geler +unfreeze.description=D\u00e9g\u00e8le un document d'archives. +# File to +fileTo.title=Archiver dans +fileTo.description=Archive un document d'archives dans le dossier d'archives d\u00e9fini. +fileTo.path.display-label=Chemin de dossier d'archives +fileTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives +# Copy to +copyTo.title=Copier vers... +copyTo.description=Copie un document d'archives vers le dossier d'archives d\u00e9fini. +copyTo.path.display-label=Chemin de dossier d'archives +copyTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives +# Move to +moveTo.title=D\u00e9placer vers... +moveTo.description=D\u00e9place un document d'archives vers le dossier d'archives d\u00e9fini. +moveTo.path.display-label=Chemin de dossier d'archives +moveTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives +# Link to +linkTo.title=Lier \u00e0 +linkTo.description=Lie un document d'archives vers le dossier d'archives d\u00e9fini. +linkTo.path.display-label=Chemin de dossier d'archives +linkTo.createRecordPath.display-label=Cr\u00e9er un chemin d'acc\u00e8s du document d'archives +# Reject +reject.title=Rejeter +reject.description=Rejette un document d'archives et place le document dans son emplacement d'origine +reject.reason.display-label=Motif du rejet +# Request Information +requestInfo.title=Demander des informations +requestInfo.description=D\u00e9marre un workflow pour demander plus d'informations sur un document d'archives +# Execute script +executeScript.title=Ex\u00e9cuter le script +executeScript.description=Ex\u00e9cuter un script. +executeScript.script-ref.display-label=Script +# Send Email +sendEmail.title=Envoyer un e-mail +sendEmail.description=Envoyer un e-mail +# Set Property +setPropertyValue.title=D\u00e9finir la valeur de la propri\u00e9t\u00e9 +setPropertyValue.description=D\u00e9finir une valeur de propri\u00e9t\u00e9 + +# Edit Hold Reason +editHoldReason.title=Modifier le motif de suspension +editHoldReason.description=Modifier le motif de suspension +# Relinquish Hold +relinquishHold.title=Lever la suspension +relinquishHold.description=Lever la suspension +# Edit Review As Of Date +editReviewAsOfDate.title=Modifier la date de d\u00e9but de la r\u00e9vision +editReviewAsOfDate.description=Modifier la date de d\u00e9but de la r\u00e9vision +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Modifier la date de d\u00e9but de l'action de disposition +editDispositionActionAsOfDate.description=Modifier la date de d\u00e9but de l'action de disposition +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=D\u00e9finition du document d'archives essentiel diffus\u00e9e +broadcastVitalRecordDefinition.description=D\u00e9finition du document d'archives essentiel diffus\u00e9e +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Mise \u00e0 jour de la d\u00e9finition de l'action de disposition diffus\u00e9e +broadcastDispositionActionDefinitionUpdate.description=Mise \u00e0 jour de la d\u00e9finition de l'action de disposition diffus\u00e9e +# Undo Event +undoEvent.title=Annuler l'\u00e9v\u00e9nement +undoEvent.description=Annuler l'\u00e9v\u00e9nement +# Transfer Complete +transferComplete.title=Transfert termin\u00e9 +transferComplete.description=Transfert termin\u00e9 +# Accession Complete +accessionComplete.title=Versement \u00e0 un autre organisme termin\u00e9 +accessionComplete.description=Versement \u00e0 un autre organisme termin\u00e9 +# Split Email +splitEmail.title=Partager l'e-mail +splitEmail.description=Partager l'e-mail +# Create Disposition Schedule +createDispositionSchedule.title=Cr\u00e9er une r\u00e8gle de conservation +createDispositionSchedule.description=Cr\u00e9er une r\u00e8gle de conservation +# File Destruction Report +fileDestructionReport.title=Rapport de destruction de fichier +fileDestructionReport.description=Rapport de destruction de fichier +# Cut off +cutoff.title=D\u00e9classer +cutoff.description=D\u00e9classer +# Destroy +destroy.title=D\u00e9truire +destroy.description=D\u00e9truire +# Reviewed +reviewed.title=V\u00e9rifi\u00e9 +reviewed.description=V\u00e9rifi\u00e9 +# Hide Record +hide-record.title=Masquer le document d'archives +hide-record.description=Masquer le document d'archives +# Transfer +transfer.title=Transf\u00e9rer +transfer.description=Transf\u00e9rer +# Uncut off +unCutoff.title=Annuler le d\u00e9classement +unCutoff.description=Annuler le d\u00e9classement +# Accession +accession.title=Versement \u00e0 un autre organisme +accession.description=Versement \u00e0 un autre organisme +# Retain +retain.title=Retenir +retain.description=Retenir +# Add Record Types +addRecordTypes.title=Ajouter des types de document d'archives +addRecordTypes.description=Ajoute le(s) type(s) s\u00e9lectionn\u00e9(s) au document d'archives +# File report +fileReport.title=Archiver le rapport +fileReport.description=Archiver le rapport +# Delete Hold +deleteHold.title=Supprimer la suspension +deleteHold.description=Supprimer la suspension +# Move DM record +move-dm-record.title=D\u00e9placer le document d'archives +move-dm-record.description=D\u00e9placer le document d'archives +# Unlink from +unlinkFrom.title=Supprimer le lien de +unlinkFrom.description=Supprimer le lien de + +# Recordable version config +recordable-version-config.title=Options de d\u00e9claration automatique +recordable-version-config.description=Options de d\u00e9claration automatique +recordable-version-config.version.display-label=D\u00e9clarer automatiquement les versions comme documents d'archives + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Cat\u00e9gorie de document d'archives +rm-ac-is-kind-kinds.record_folder=Dossier d'archives +rm-ac-is-kind-kinds.record=Document d'archives + +rm-ac-disposition-action-relative-positions.next=Suivant +rm-ac-disposition-action-relative-positions.previous=Pr\u00e9c\u00e9dent +rm-ac-disposition-action-relative-positions.any=N'importe lequel + +ac-versions.none=Jamais +ac-versions.major_only=Uniquement les versions majeures ac-versions.all=Versions majeures et mineures \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_it.properties index 7be12306a2..8957065bd5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_it.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Classificato in base alla pianificazione della disposizione -isClassified.description=I record o le cartelle di record sono stati classificati in base alla pianificazione della disposizione? - -# Are cutoff -isCutoff.title=Cut off -isCutoff.description=Record o cartelle di record separati. - -# Are declared -isDeclared.title=Record completati -isDeclared.description=Il record \u00e8 completo - -# Is on hold -isFrozen.title=Sospeso -isFrozen.description=Il record o la cartella di record sono in sospeso - -# Are filed -isRecordFiled.title=Record archiviato -isRecordFiled.description=Il record \u00e8 archiviato - -# Are closed record folders -isRecordFolderClosed.title=Cartella di record chiusa -isRecordFolderClosed.description=La cartella di record \u00e8 chiusa - -# Are vital -isVital.title=Record fondamentale -isVital.description=Il record o la cartella di record sono fondamentali - -# Have Disposition Action -hasDispositionAction.title=Possiede l'azione di disposizione -hasDispositionAction.description=I nodi hanno ottenuto la relativa azione di disposizione specificata alla relativa posizione specificata - -# Are kind -isKind.title=Tipo di elemento di gestione dei record -isKind.description=I nodi sono del tipo componente piano file -isKind.kind.display-label=Tipo - -# Are Record Type -isRecordType.title=Possiede tipo di record -isRecordType.description=I record sono del tipo specificato - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=Dichiara come record -create-record.description=Dichiara documento come record. -create-record.file-plan.display-label=Piano file -create-record.hide-record.display-label=Nascondi record -# Declare As Version Record -declare-as-version-record.title=Dichiara versione come record -declare-as-version-record.description=Dichiara la nuova versione del documento come record versione. -declare-as-version-record.file-plan.display-label=Piano file -# Complete record -declareRecord.title=Completa record -declareRecord.description=Completa un record. -# Reopens record -undeclareRecord.title=Riapri record -undeclareRecord.description=Riapre un record. -# Open record folder -openRecordFolder.title=Apri cartella di record -openRecordFolder.description=Apre una cartella di record. -# Close record folder -closeRecordFolder.title=Chiudi cartella di record -closeRecordFolder.description=Chiude una cartella di record. -# Complete event -completeEvent.title=Completa evento -completeEvent.description=Completa un evento. -completeEvent.eventName.display-label=Evento -# Freeze -freeze.title=Blocca -freeze.description=Blocca un record. -freeze.reason.display-label=Motivo -# Unfreeze -unfreeze.title=Sblocca -unfreeze.description=Sblocca un record. -# File to -fileTo.title=Archivia in -fileTo.description=Archivia un record nella cartella di record specificata. -fileTo.path.display-label=Indirizza nella cartella di record -fileTo.createRecordPath.display-label=Crea percorso del record -# Copy to -copyTo.title=Copia in -copyTo.description=Copia un record nella cartella di record specificata. -copyTo.path.display-label=Indirizza nella cartella di record -copyTo.createRecordPath.display-label=Crea percorso del record -# Move to -moveTo.title=Sposta in -moveTo.description=Sposta un record nella cartella di record specificata. -moveTo.path.display-label=Indirizza nella cartella di record -moveTo.createRecordPath.display-label=Crea percorso del record -# Link to -linkTo.title=Collega a -linkTo.description=Collega un record alla cartella di record specificata. -linkTo.path.display-label=Indirizza nella cartella di record -linkTo.createRecordPath.display-label=Crea percorso del record -# Reject -reject.title=Respingi -reject.description=Respingi un record e sposta il documento nella sua posizione originale -reject.reason.display-label=Respingi motivo -# Request Information -requestInfo.title=Richiedi informazioni -requestInfo.description=Avvia un flusso di lavoro per richiedere pi\u00f9 informazioni per un record -# Execute script -executeScript.title=Esegui script -executeScript.description=Esegui uno script. -executeScript.script-ref.display-label=Script -# Send Email -sendEmail.title=Invia e-mail -sendEmail.description=Invia un'e-mail -# Set Property -setPropertyValue.title=Imposta valore di propriet\u00e0 -setPropertyValue.description=Imposta un valore di propriet\u00e0 - -# Edit Hold Reason -editHoldReason.title=Modifica motivo sospensione -editHoldReason.description=Modifica motivo sospensione -# Relinquish Hold -relinquishHold.title=Lascia sospensione -relinquishHold.description=Lascia sospensione -# Edit Review As Of Date -editReviewAsOfDate.title=Modifica revisiona in data -editReviewAsOfDate.description=Modifica revisiona in data -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Modifica azione di disposizione in data -editDispositionActionAsOfDate.description=Modifica azione di disposizione in data -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=Trasmetti definizione di record fondamentale -broadcastVitalRecordDefinition.description=Trasmetti definizione di record fondamentale -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Trasmetti aggiornamento definizione di azione di disposizione -broadcastDispositionActionDefinitionUpdate.description=Trasmetti aggiornamento definizione di azione di disposizione -# Undo Event -undoEvent.title=Annulla evento -undoEvent.description=Annulla evento -# Transfer Complete -transferComplete.title=Trasferimento completato -transferComplete.description=Trasferimento completato -# Accession Complete -accessionComplete.title=Inserimento completato -accessionComplete.description=Inserimento completato -# Split Email -splitEmail.title=Dividi e-mail -splitEmail.description=Dividi e-mail -# Create Disposition Schedule -createDispositionSchedule.title=Crea pianificazione della disposizione -createDispositionSchedule.description=Crea pianificazione della disposizione -# File Destruction Report -fileDestructionReport.title=Archivia report di eliminazione permanente -fileDestructionReport.description=Archivia report di eliminazione permanente -# Cut off -cutoff.title=Cut off -cutoff.description=Cut off -# Destroy -destroy.title=Elimina definitivamente -destroy.description=Elimina definitivamente -# Reviewed -reviewed.title=Rivisto -reviewed.description=Rivisto -# Hide Record -hide-record.title=Nascondi record -hide-record.description=Nascondi record -# Transfer -transfer.title=Trasferisci -transfer.description=Trasferisci -# Uncut off -unCutoff.title=Annulla cut off -unCutoff.description=Annulla cut off -# Accession -accession.title=Inserimento -accession.description=Inserimento -# Retain -retain.title=Mantieni -retain.description=Mantieni -# Add Record Types -addRecordTypes.title=Aggiungi tipi di record -addRecordTypes.description=Aggiunge i tipi selezionati al record -# File report -fileReport.title=Archivia Report -fileReport.description=Archivia Report -# Delete Hold -deleteHold.title=Annulla sospensione -deleteHold.description=Annulla sospensione -# Move DM record -move-dm-record.title=Sposta record -move-dm-record.description=Sposta record -# Unlink from -unlinkFrom.title=Scollega da -unlinkFrom.description=Scollega da - -# Recordable version config -recordable-version-config.title=Opzioni di dichiarazione automatica -recordable-version-config.description=Opzioni di dichiarazione automatica -recordable-version-config.version.display-label=Dichiara automaticamente versioni come record - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Categoria record -rm-ac-is-kind-kinds.record_folder=Cartella di record -rm-ac-is-kind-kinds.record=Record - -rm-ac-disposition-action-relative-positions.next=Successivo -rm-ac-disposition-action-relative-positions.previous=Precedente -rm-ac-disposition-action-relative-positions.any=Qualsiasi - -ac-versions.none=Mai -ac-versions.major_only=Solo per versioni maggiori +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Classificato in base alla pianificazione della disposizione +isClassified.description=I record o le cartelle di record sono stati classificati in base alla pianificazione della disposizione? + +# Are cutoff +isCutoff.title=Cut off +isCutoff.description=Record o cartelle di record separati. + +# Are declared +isDeclared.title=Record completati +isDeclared.description=Il record \u00e8 completo + +# Is on hold +isFrozen.title=Sospeso +isFrozen.description=Il record o la cartella di record sono in sospeso + +# Are filed +isRecordFiled.title=Record archiviato +isRecordFiled.description=Il record \u00e8 archiviato + +# Are closed record folders +isRecordFolderClosed.title=Cartella di record chiusa +isRecordFolderClosed.description=La cartella di record \u00e8 chiusa + +# Are vital +isVital.title=Record fondamentale +isVital.description=Il record o la cartella di record sono fondamentali + +# Have Disposition Action +hasDispositionAction.title=Possiede l'azione di disposizione +hasDispositionAction.description=I nodi hanno ottenuto la relativa azione di disposizione specificata alla relativa posizione specificata + +# Are kind +isKind.title=Tipo di elemento di gestione dei record +isKind.description=I nodi sono del tipo componente piano file +isKind.kind.display-label=Tipo + +# Are Record Type +isRecordType.title=Possiede tipo di record +isRecordType.description=I record sono del tipo specificato + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=Dichiara come record +create-record.description=Dichiara documento come record. +create-record.file-plan.display-label=Piano file +create-record.hide-record.display-label=Nascondi record +# Declare As Version Record +declare-as-version-record.title=Dichiara versione come record +declare-as-version-record.description=Dichiara la nuova versione del documento come record versione. +declare-as-version-record.file-plan.display-label=Piano file +# Complete record +declareRecord.title=Completa record +declareRecord.description=Completa un record. +# Reopens record +undeclareRecord.title=Riapri record +undeclareRecord.description=Riapre un record. +# Open record folder +openRecordFolder.title=Apri cartella di record +openRecordFolder.description=Apre una cartella di record. +# Close record folder +closeRecordFolder.title=Chiudi cartella di record +closeRecordFolder.description=Chiude una cartella di record. +# Complete event +completeEvent.title=Completa evento +completeEvent.description=Completa un evento. +completeEvent.eventName.display-label=Evento +# Freeze +freeze.title=Blocca +freeze.description=Blocca un record. +freeze.reason.display-label=Motivo +# Unfreeze +unfreeze.title=Sblocca +unfreeze.description=Sblocca un record. +# File to +fileTo.title=Archivia in +fileTo.description=Archivia un record nella cartella di record specificata. +fileTo.path.display-label=Indirizza nella cartella di record +fileTo.createRecordPath.display-label=Crea percorso del record +# Copy to +copyTo.title=Copia in +copyTo.description=Copia un record nella cartella di record specificata. +copyTo.path.display-label=Indirizza nella cartella di record +copyTo.createRecordPath.display-label=Crea percorso del record +# Move to +moveTo.title=Sposta in +moveTo.description=Sposta un record nella cartella di record specificata. +moveTo.path.display-label=Indirizza nella cartella di record +moveTo.createRecordPath.display-label=Crea percorso del record +# Link to +linkTo.title=Collega a +linkTo.description=Collega un record alla cartella di record specificata. +linkTo.path.display-label=Indirizza nella cartella di record +linkTo.createRecordPath.display-label=Crea percorso del record +# Reject +reject.title=Respingi +reject.description=Respingi un record e sposta il documento nella sua posizione originale +reject.reason.display-label=Respingi motivo +# Request Information +requestInfo.title=Richiedi informazioni +requestInfo.description=Avvia un flusso di lavoro per richiedere pi\u00f9 informazioni per un record +# Execute script +executeScript.title=Esegui script +executeScript.description=Esegui uno script. +executeScript.script-ref.display-label=Script +# Send Email +sendEmail.title=Invia e-mail +sendEmail.description=Invia un'e-mail +# Set Property +setPropertyValue.title=Imposta valore di propriet\u00e0 +setPropertyValue.description=Imposta un valore di propriet\u00e0 + +# Edit Hold Reason +editHoldReason.title=Modifica motivo sospensione +editHoldReason.description=Modifica motivo sospensione +# Relinquish Hold +relinquishHold.title=Lascia sospensione +relinquishHold.description=Lascia sospensione +# Edit Review As Of Date +editReviewAsOfDate.title=Modifica revisiona in data +editReviewAsOfDate.description=Modifica revisiona in data +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Modifica azione di disposizione in data +editDispositionActionAsOfDate.description=Modifica azione di disposizione in data +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=Trasmetti definizione di record fondamentale +broadcastVitalRecordDefinition.description=Trasmetti definizione di record fondamentale +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Trasmetti aggiornamento definizione di azione di disposizione +broadcastDispositionActionDefinitionUpdate.description=Trasmetti aggiornamento definizione di azione di disposizione +# Undo Event +undoEvent.title=Annulla evento +undoEvent.description=Annulla evento +# Transfer Complete +transferComplete.title=Trasferimento completato +transferComplete.description=Trasferimento completato +# Accession Complete +accessionComplete.title=Inserimento completato +accessionComplete.description=Inserimento completato +# Split Email +splitEmail.title=Dividi e-mail +splitEmail.description=Dividi e-mail +# Create Disposition Schedule +createDispositionSchedule.title=Crea pianificazione della disposizione +createDispositionSchedule.description=Crea pianificazione della disposizione +# File Destruction Report +fileDestructionReport.title=Archivia report di eliminazione permanente +fileDestructionReport.description=Archivia report di eliminazione permanente +# Cut off +cutoff.title=Cut off +cutoff.description=Cut off +# Destroy +destroy.title=Elimina definitivamente +destroy.description=Elimina definitivamente +# Reviewed +reviewed.title=Rivisto +reviewed.description=Rivisto +# Hide Record +hide-record.title=Nascondi record +hide-record.description=Nascondi record +# Transfer +transfer.title=Trasferisci +transfer.description=Trasferisci +# Uncut off +unCutoff.title=Annulla cut off +unCutoff.description=Annulla cut off +# Accession +accession.title=Inserimento +accession.description=Inserimento +# Retain +retain.title=Mantieni +retain.description=Mantieni +# Add Record Types +addRecordTypes.title=Aggiungi tipi di record +addRecordTypes.description=Aggiunge i tipi selezionati al record +# File report +fileReport.title=Archivia Report +fileReport.description=Archivia Report +# Delete Hold +deleteHold.title=Annulla sospensione +deleteHold.description=Annulla sospensione +# Move DM record +move-dm-record.title=Sposta record +move-dm-record.description=Sposta record +# Unlink from +unlinkFrom.title=Scollega da +unlinkFrom.description=Scollega da + +# Recordable version config +recordable-version-config.title=Opzioni di dichiarazione automatica +recordable-version-config.description=Opzioni di dichiarazione automatica +recordable-version-config.version.display-label=Dichiara automaticamente versioni come record + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Categoria record +rm-ac-is-kind-kinds.record_folder=Cartella di record +rm-ac-is-kind-kinds.record=Record + +rm-ac-disposition-action-relative-positions.next=Successivo +rm-ac-disposition-action-relative-positions.previous=Precedente +rm-ac-disposition-action-relative-positions.any=Qualsiasi + +ac-versions.none=Mai +ac-versions.major_only=Solo per versioni maggiori ac-versions.all=Per tutte le versioni maggiori e minori \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_ja.properties index 3b1339298c..22353ef9a1 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_ja.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306b\u3088\u308a\u5206\u985e\u6e08\u307f -isClassified.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306b\u3088\u308a\u5206\u985e\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 - -# Are cutoff -isCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 -isCutoff.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u30ab\u30c3\u30c8\u30aa\u30d5\u3055\u308c\u3066\u3044\u307e\u3059\u3002 - -# Are declared -isDeclared.title=\u30ec\u30b3\u30fc\u30c9\u5b8c\u4e86\u6e08\u307f -isDeclared.description=\u30ec\u30b3\u30fc\u30c9\u306f\u5b8c\u4e86\u3057\u3066\u3044\u307e\u3059\u304b\u3002 - -# Is on hold -isFrozen.title=\u30db\u30fc\u30eb\u30c9\u4e2d -isFrozen.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u30db\u30fc\u30eb\u30c9\u4e2d\u3067\u3059\u304b\u3002 - -# Are filed -isRecordFiled.title=\u30ec\u30b3\u30fc\u30c9\u6574\u7406\u4fdd\u7ba1\u6e08\u307f -isRecordFiled.description=\u30ec\u30b3\u30fc\u30c9\u306f\u6574\u7406\u4fdd\u7ba1\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 - -# Are closed record folders -isRecordFolderClosed.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u9589\u3058\u3089\u308c\u3066\u3044\u307e\u3059 -isRecordFolderClosed.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u9589\u3058\u3089\u308c\u3066\u3044\u307e\u3059\u304b\u3002 - -# Are vital -isVital.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 -isVital.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u5fc5\u9808\u3067\u3059\u304b\u3002 - -# Have Disposition Action -hasDispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308b\u304b -hasDispositionAction.description=\u95a2\u9023\u3059\u308b\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3068\u305d\u306e\u76f8\u5bfe\u4f4d\u7f6e\u304c\u30ce\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 - -# Are kind -isKind.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30a4\u30c6\u30e0\u306e\u30bf\u30a4\u30d7 -isKind.description=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30ce\u30fc\u30c9\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4e00\u7a2e\u3067\u3059\u304b\u3002 -isKind.kind.display-label=\u7a2e\u985e - -# Are Record Type -isRecordType.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u304c\u3042\u308b\u304b -isRecordType.description=\u6307\u5b9a\u3055\u308c\u305f\u30bf\u30a4\u30d7\u306e\u30ec\u30b3\u30fc\u30c9\u3067\u3059\u304b\u3002 - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b -create-record.description=\u6587\u66f8\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3057\u307e\u3059\u3002 -create-record.file-plan.display-label=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 -create-record.hide-record.display-label=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b -# Declare As Version Record -declare-as-version-record.title=\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b -declare-as-version-record.description=\u6587\u66f8\u306e\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30d0\u30fc\u30b8\u30e7\u30f3\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3057\u307e\u3059\u3002 -declare-as-version-record.file-plan.display-label=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 -# Complete record -declareRecord.title=\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 -declareRecord.description=\u30ec\u30b3\u30fc\u30c9\u3092\u5b8c\u4e86\u3057\u307e\u3059\u3002 -# Reopens record -undeclareRecord.title=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304f -undeclareRecord.description=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304d\u307e\u3059\u3002 -# Open record folder -openRecordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f -openRecordFolder.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304d\u307e\u3059\u3002 -# Close record folder -closeRecordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b -closeRecordFolder.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u307e\u3059\u3002 -# Complete event -completeEvent.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86 -completeEvent.description=\u30a4\u30d9\u30f3\u30c8\u3092\u5b8c\u4e86\u3057\u307e\u3059\u3002 -completeEvent.eventName.display-label=\u30a4\u30d9\u30f3\u30c8 -# Freeze -freeze.title=\u56fa\u5b9a -freeze.description=\u30ec\u30b3\u30fc\u30c9\u3092\u56fa\u5b9a\u3057\u307e\u3059\u3002 -freeze.reason.display-label=\u7406\u7531 -# Unfreeze -unfreeze.title=\u56fa\u5b9a\u89e3\u9664 -unfreeze.description=\u30ec\u30b3\u30fc\u30c9\u3092\u56fa\u5b9a\u89e3\u9664\u3057\u307e\u3059\u3002 -# File to -fileTo.title=\u6574\u7406\u4fdd\u7ba1\u5148 -fileTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u6574\u7406\u4fdd\u7ba1\u3057\u307e\u3059\u3002 -fileTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 -fileTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 -# Copy to -copyTo.title=\u30b3\u30d4\u30fc\u5148 -copyTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002 -copyTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 -copyTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 -# Move to -moveTo.title=\u79fb\u52d5\u5148 -moveTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002 -moveTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 -moveTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 -# Link to -linkTo.title=\u30ea\u30f3\u30af\u5148 -linkTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002 -linkTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 -linkTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 -# Reject -reject.title=\u5374\u4e0b -reject.description=\u30ec\u30b3\u30fc\u30c9\u3092\u5374\u4e0b\u3057\u3001\u6587\u66f8\u3092\u5143\u306e\u5834\u6240\u306b\u79fb\u52d5\u3057\u307e\u3059 -reject.reason.display-label=\u5374\u4e0b\u306e\u7406\u7531 -# Request Information -requestInfo.title=\u60c5\u5831\u306e\u30ea\u30af\u30a8\u30b9\u30c8 -requestInfo.description=\u30ec\u30b3\u30fc\u30c9\u306e\u8a73\u7d30\u60c5\u5831\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u305f\u3081\u306b\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u3092\u958b\u59cb\u3057\u307e\u3059 -# Execute script -executeScript.title=\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c -executeScript.description=\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 -executeScript.script-ref.display-label=\u30b9\u30af\u30ea\u30d7\u30c8 -# Send Email -sendEmail.title=E\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b -sendEmail.description=E\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b -# Set Property -setPropertyValue.title=\u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u3092\u8a2d\u5b9a\u3059\u308b -setPropertyValue.description=\u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u3092\u8a2d\u5b9a\u3059\u308b - -# Edit Hold Reason -editHoldReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306e\u7de8\u96c6 -editHoldReason.description=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306e\u7de8\u96c6 -# Relinquish Hold -relinquishHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u653e\u68c4 -relinquishHold.description=\u30db\u30fc\u30eb\u30c9\u306e\u653e\u68c4 -# Edit Review As Of Date -editReviewAsOfDate.title=\u73fe\u6642\u70b9\u3067\u30ec\u30d3\u30e5\u30fc\u3092\u7de8\u96c6\u3059\u308b -editReviewAsOfDate.description=\u73fe\u6642\u70b9\u3067\u30ec\u30d3\u30e5\u30fc\u3092\u7de8\u96c6\u3059\u308b -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=\u73fe\u6642\u70b9\u3067\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u7de8\u96c6\u3059\u308b -editDispositionActionAsOfDate.description=\u73fe\u6642\u70b9\u3067\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u7de8\u96c6\u3059\u308b -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b -broadcastVitalRecordDefinition.description=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u5b9a\u7fa9\u306e\u66f4\u65b0\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b -broadcastDispositionActionDefinitionUpdate.description=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u5b9a\u7fa9\u306e\u66f4\u65b0\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b -# Undo Event -undoEvent.title=\u30a4\u30d9\u30f3\u30c8\u3092\u5143\u306b\u623b\u3059 -undoEvent.description=\u30a4\u30d9\u30f3\u30c8\u3092\u5143\u306b\u623b\u3059 -# Transfer Complete -transferComplete.title=\u8ee2\u9001\u5b8c\u4e86 -transferComplete.description=\u8ee2\u9001\u5b8c\u4e86 -# Accession Complete -accessionComplete.title=\u53d7\u8afe\u5b8c\u4e86 -accessionComplete.description=\u53d7\u8afe\u5b8c\u4e86 -# Split Email -splitEmail.title=E\u30e1\u30fc\u30eb\u306e\u5206\u5272 -splitEmail.description=E\u30e1\u30fc\u30eb\u306e\u5206\u5272 -# Create Disposition Schedule -createDispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306e\u4f5c\u6210 -createDispositionSchedule.description=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306e\u4f5c\u6210 -# File Destruction Report -fileDestructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -fileDestructionReport.description=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -# Cut off -cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 -cutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5 -# Destroy -destroy.title=\u7834\u68c4 -destroy.description=\u7834\u68c4 -# Reviewed -reviewed.title=\u30ec\u30d3\u30e5\u30fc\u6e08\u307f -reviewed.description=\u30ec\u30d3\u30e5\u30fc\u6e08\u307f -# Hide Record -hide-record.title=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b -hide-record.description=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b -# Transfer -transfer.title=\u8ee2\u9001 -transfer.description=\u8ee2\u9001 -# Uncut off -unCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u3059 -unCutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u3059 -# Accession -accession.title=\u53d7\u8afe -accession.description=\u53d7\u8afe -# Retain -retain.title=\u7559\u4fdd -retain.description=\u7559\u4fdd -# Add Record Types -addRecordTypes.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306e\u8ffd\u52a0 -addRecordTypes.description=\u9078\u629e\u3057\u305f\u30bf\u30a4\u30d7\u3092\u30ec\u30b3\u30fc\u30c9\u306b\u8ffd\u52a0\u3059\u308b -# File report -fileReport.title=\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -fileReport.description=\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -# Delete Hold -deleteHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 -deleteHold.description=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 -# Move DM record -move-dm-record.title=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 -move-dm-record.description=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 -# Unlink from -unlinkFrom.title=\u30ea\u30f3\u30af\u306e\u89e3\u9664\u5143 -unlinkFrom.description=\u30ea\u30f3\u30af\u306e\u89e3\u9664\u5143 - -# Recordable version config -recordable-version-config.title=\u81ea\u52d5\u5ba3\u8a00\u30aa\u30d7\u30b7\u30e7\u30f3 -recordable-version-config.description=\u81ea\u52d5\u5ba3\u8a00\u30aa\u30d7\u30b7\u30e7\u30f3 -recordable-version-config.version.display-label=\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u81ea\u52d5\u7684\u306b\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea -rm-ac-is-kind-kinds.record_folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rm-ac-is-kind-kinds.record=\u30ec\u30b3\u30fc\u30c9 - -rm-ac-disposition-action-relative-positions.next=\u6b21\u3078 -rm-ac-disposition-action-relative-positions.previous=\u524d\u3078 -rm-ac-disposition-action-relative-positions.any=\u4efb\u610f - -ac-versions.none=\u5ba3\u8a00\u3057\u306a\u3044 -ac-versions.major_only=\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u307f +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306b\u3088\u308a\u5206\u985e\u6e08\u307f +isClassified.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306b\u3088\u308a\u5206\u985e\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 + +# Are cutoff +isCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 +isCutoff.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u30ab\u30c3\u30c8\u30aa\u30d5\u3055\u308c\u3066\u3044\u307e\u3059\u3002 + +# Are declared +isDeclared.title=\u30ec\u30b3\u30fc\u30c9\u5b8c\u4e86\u6e08\u307f +isDeclared.description=\u30ec\u30b3\u30fc\u30c9\u306f\u5b8c\u4e86\u3057\u3066\u3044\u307e\u3059\u304b\u3002 + +# Is on hold +isFrozen.title=\u30db\u30fc\u30eb\u30c9\u4e2d +isFrozen.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u30db\u30fc\u30eb\u30c9\u4e2d\u3067\u3059\u304b\u3002 + +# Are filed +isRecordFiled.title=\u30ec\u30b3\u30fc\u30c9\u6574\u7406\u4fdd\u7ba1\u6e08\u307f +isRecordFiled.description=\u30ec\u30b3\u30fc\u30c9\u306f\u6574\u7406\u4fdd\u7ba1\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 + +# Are closed record folders +isRecordFolderClosed.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u9589\u3058\u3089\u308c\u3066\u3044\u307e\u3059 +isRecordFolderClosed.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u9589\u3058\u3089\u308c\u3066\u3044\u307e\u3059\u304b\u3002 + +# Are vital +isVital.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 +isVital.description=\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306f\u5fc5\u9808\u3067\u3059\u304b\u3002 + +# Have Disposition Action +hasDispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308b\u304b +hasDispositionAction.description=\u95a2\u9023\u3059\u308b\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3068\u305d\u306e\u76f8\u5bfe\u4f4d\u7f6e\u304c\u30ce\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304b\u3002 + +# Are kind +isKind.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30a2\u30a4\u30c6\u30e0\u306e\u30bf\u30a4\u30d7 +isKind.description=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30ce\u30fc\u30c9\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4e00\u7a2e\u3067\u3059\u304b\u3002 +isKind.kind.display-label=\u7a2e\u985e + +# Are Record Type +isRecordType.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u304c\u3042\u308b\u304b +isRecordType.description=\u6307\u5b9a\u3055\u308c\u305f\u30bf\u30a4\u30d7\u306e\u30ec\u30b3\u30fc\u30c9\u3067\u3059\u304b\u3002 + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b +create-record.description=\u6587\u66f8\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3057\u307e\u3059\u3002 +create-record.file-plan.display-label=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 +create-record.hide-record.display-label=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b +# Declare As Version Record +declare-as-version-record.title=\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b +declare-as-version-record.description=\u6587\u66f8\u306e\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30d0\u30fc\u30b8\u30e7\u30f3\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3057\u307e\u3059\u3002 +declare-as-version-record.file-plan.display-label=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3 +# Complete record +declareRecord.title=\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 +declareRecord.description=\u30ec\u30b3\u30fc\u30c9\u3092\u5b8c\u4e86\u3057\u307e\u3059\u3002 +# Reopens record +undeclareRecord.title=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304f +undeclareRecord.description=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304d\u307e\u3059\u3002 +# Open record folder +openRecordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f +openRecordFolder.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304d\u307e\u3059\u3002 +# Close record folder +closeRecordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b +closeRecordFolder.description=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u307e\u3059\u3002 +# Complete event +completeEvent.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86 +completeEvent.description=\u30a4\u30d9\u30f3\u30c8\u3092\u5b8c\u4e86\u3057\u307e\u3059\u3002 +completeEvent.eventName.display-label=\u30a4\u30d9\u30f3\u30c8 +# Freeze +freeze.title=\u56fa\u5b9a +freeze.description=\u30ec\u30b3\u30fc\u30c9\u3092\u56fa\u5b9a\u3057\u307e\u3059\u3002 +freeze.reason.display-label=\u7406\u7531 +# Unfreeze +unfreeze.title=\u56fa\u5b9a\u89e3\u9664 +unfreeze.description=\u30ec\u30b3\u30fc\u30c9\u3092\u56fa\u5b9a\u89e3\u9664\u3057\u307e\u3059\u3002 +# File to +fileTo.title=\u6574\u7406\u4fdd\u7ba1\u5148 +fileTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u6574\u7406\u4fdd\u7ba1\u3057\u307e\u3059\u3002 +fileTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 +fileTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 +# Copy to +copyTo.title=\u30b3\u30d4\u30fc\u5148 +copyTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002 +copyTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 +copyTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 +# Move to +moveTo.title=\u79fb\u52d5\u5148 +moveTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002 +moveTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 +moveTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 +# Link to +linkTo.title=\u30ea\u30f3\u30af\u5148 +linkTo.description=\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u306b\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002 +linkTo.path.display-label=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3078\u306e\u30d1\u30b9 +linkTo.createRecordPath.display-label=\u30ec\u30b3\u30fc\u30c9\u30d1\u30b9\u306e\u4f5c\u6210 +# Reject +reject.title=\u5374\u4e0b +reject.description=\u30ec\u30b3\u30fc\u30c9\u3092\u5374\u4e0b\u3057\u3001\u6587\u66f8\u3092\u5143\u306e\u5834\u6240\u306b\u79fb\u52d5\u3057\u307e\u3059 +reject.reason.display-label=\u5374\u4e0b\u306e\u7406\u7531 +# Request Information +requestInfo.title=\u60c5\u5831\u306e\u30ea\u30af\u30a8\u30b9\u30c8 +requestInfo.description=\u30ec\u30b3\u30fc\u30c9\u306e\u8a73\u7d30\u60c5\u5831\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u305f\u3081\u306b\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u3092\u958b\u59cb\u3057\u307e\u3059 +# Execute script +executeScript.title=\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c +executeScript.description=\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 +executeScript.script-ref.display-label=\u30b9\u30af\u30ea\u30d7\u30c8 +# Send Email +sendEmail.title=E\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b +sendEmail.description=E\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b +# Set Property +setPropertyValue.title=\u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u3092\u8a2d\u5b9a\u3059\u308b +setPropertyValue.description=\u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u3092\u8a2d\u5b9a\u3059\u308b + +# Edit Hold Reason +editHoldReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306e\u7de8\u96c6 +editHoldReason.description=\u30db\u30fc\u30eb\u30c9\u7406\u7531\u306e\u7de8\u96c6 +# Relinquish Hold +relinquishHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u653e\u68c4 +relinquishHold.description=\u30db\u30fc\u30eb\u30c9\u306e\u653e\u68c4 +# Edit Review As Of Date +editReviewAsOfDate.title=\u73fe\u6642\u70b9\u3067\u30ec\u30d3\u30e5\u30fc\u3092\u7de8\u96c6\u3059\u308b +editReviewAsOfDate.description=\u73fe\u6642\u70b9\u3067\u30ec\u30d3\u30e5\u30fc\u3092\u7de8\u96c6\u3059\u308b +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=\u73fe\u6642\u70b9\u3067\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u7de8\u96c6\u3059\u308b +editDispositionActionAsOfDate.description=\u73fe\u6642\u70b9\u3067\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u7de8\u96c6\u3059\u308b +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b +broadcastVitalRecordDefinition.description=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u5b9a\u7fa9\u306e\u66f4\u65b0\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b +broadcastDispositionActionDefinitionUpdate.description=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u5b9a\u7fa9\u306e\u66f4\u65b0\u3092\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u3059\u308b +# Undo Event +undoEvent.title=\u30a4\u30d9\u30f3\u30c8\u3092\u5143\u306b\u623b\u3059 +undoEvent.description=\u30a4\u30d9\u30f3\u30c8\u3092\u5143\u306b\u623b\u3059 +# Transfer Complete +transferComplete.title=\u8ee2\u9001\u5b8c\u4e86 +transferComplete.description=\u8ee2\u9001\u5b8c\u4e86 +# Accession Complete +accessionComplete.title=\u53d7\u8afe\u5b8c\u4e86 +accessionComplete.description=\u53d7\u8afe\u5b8c\u4e86 +# Split Email +splitEmail.title=E\u30e1\u30fc\u30eb\u306e\u5206\u5272 +splitEmail.description=E\u30e1\u30fc\u30eb\u306e\u5206\u5272 +# Create Disposition Schedule +createDispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306e\u4f5c\u6210 +createDispositionSchedule.description=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306e\u4f5c\u6210 +# File Destruction Report +fileDestructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +fileDestructionReport.description=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +# Cut off +cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 +cutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5 +# Destroy +destroy.title=\u7834\u68c4 +destroy.description=\u7834\u68c4 +# Reviewed +reviewed.title=\u30ec\u30d3\u30e5\u30fc\u6e08\u307f +reviewed.description=\u30ec\u30d3\u30e5\u30fc\u6e08\u307f +# Hide Record +hide-record.title=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b +hide-record.description=\u30ec\u30b3\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b +# Transfer +transfer.title=\u8ee2\u9001 +transfer.description=\u8ee2\u9001 +# Uncut off +unCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u3059 +unCutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5\u3092\u5143\u306b\u623b\u3059 +# Accession +accession.title=\u53d7\u8afe +accession.description=\u53d7\u8afe +# Retain +retain.title=\u7559\u4fdd +retain.description=\u7559\u4fdd +# Add Record Types +addRecordTypes.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306e\u8ffd\u52a0 +addRecordTypes.description=\u9078\u629e\u3057\u305f\u30bf\u30a4\u30d7\u3092\u30ec\u30b3\u30fc\u30c9\u306b\u8ffd\u52a0\u3059\u308b +# File report +fileReport.title=\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +fileReport.description=\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +# Delete Hold +deleteHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 +deleteHold.description=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 +# Move DM record +move-dm-record.title=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 +move-dm-record.description=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 +# Unlink from +unlinkFrom.title=\u30ea\u30f3\u30af\u306e\u89e3\u9664\u5143 +unlinkFrom.description=\u30ea\u30f3\u30af\u306e\u89e3\u9664\u5143 + +# Recordable version config +recordable-version-config.title=\u81ea\u52d5\u5ba3\u8a00\u30aa\u30d7\u30b7\u30e7\u30f3 +recordable-version-config.description=\u81ea\u52d5\u5ba3\u8a00\u30aa\u30d7\u30b7\u30e7\u30f3 +recordable-version-config.version.display-label=\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u81ea\u52d5\u7684\u306b\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea +rm-ac-is-kind-kinds.record_folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rm-ac-is-kind-kinds.record=\u30ec\u30b3\u30fc\u30c9 + +rm-ac-disposition-action-relative-positions.next=\u6b21\u3078 +rm-ac-disposition-action-relative-positions.previous=\u524d\u3078 +rm-ac-disposition-action-relative-positions.any=\u4efb\u610f + +ac-versions.none=\u5ba3\u8a00\u3057\u306a\u3044 +ac-versions.major_only=\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u307f ac-versions.all=\u3059\u3079\u3066\u306e\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u30de\u30a4\u30ca\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_nl.properties index 96670bb10c..120f080bf3 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_nl.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=Geclassificeerd op beschikkingsschema -isClassified.description=De records of archiefmappen zijn geclassificeerd op basis van een beschikkingsschema - -# Are cutoff -isCutoff.title=Afsluiten -isCutoff.description=Records of archiefmappen zijn afgesloten. - -# Are declared -isDeclared.title=Record afgerond -isDeclared.description=De record is afgerond - -# Is on hold -isFrozen.title=In wachtstand -isFrozen.description=De record of de archiefmap bevindt zich in de wachtstand - -# Are filed -isRecordFiled.title=Record gearchiveerd -isRecordFiled.description=De record is gearchiveerd - -# Are closed record folders -isRecordFolderClosed.title=Archiefmap gesloten -isRecordFolderClosed.description=De archiefmap is gesloten - -# Are vital -isVital.title=Vitale record -isVital.description=De record of de archiefmap is vitaal - -# Have Disposition Action -hasDispositionAction.title=Heeft beschikkingsactie -hasDispositionAction.description=De nodes hebben de opgegeven gekoppelde beschikkingsactie op de opgegeven relatieve positie - -# Are kind -isKind.title=Type onderdeel Record Management -isKind.description=De nodes zijn van een type ordeningsplancomponent -isKind.kind.display-label=Type - -# Are Record Type -isRecordType.title=Heeft recordtype -isRecordType.description=De records zijn van het opgegeven type - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=Declareren als record -create-record.description=Hiermee wordt een document gedeclareerd als een record. -create-record.file-plan.display-label=Ordeningsplan -create-record.hide-record.display-label=Record verbergen -# Declare As Version Record -declare-as-version-record.title=Versie declareren als record -declare-as-version-record.description=Hiermee wordt een nieuwe versie van een document gedeclareerd als een versierecord. -declare-as-version-record.file-plan.display-label=Ordeningsplan -# Complete record -declareRecord.title=Record afronden -declareRecord.description=Hiermee wordt een record afgerond. -# Reopens record -undeclareRecord.title=Record heropenen -undeclareRecord.description=Hiermee wordt een record heropend. -# Open record folder -openRecordFolder.title=Archiefmap openen -openRecordFolder.description=Hiermee wordt een archiefmap geopend. -# Close record folder -closeRecordFolder.title=Archiefmap sluiten -closeRecordFolder.description=Hiermee wordt een archiefmap afgesloten. -# Complete event -completeEvent.title=Gebeurtenis afronden -completeEvent.description=Hiermee wordt een gebeurtenis afgerond. -completeEvent.eventName.display-label=Gebeurtenis -# Freeze -freeze.title=Bevriezen -freeze.description=Hiermee wordt een record bevroren. -freeze.reason.display-label=Reden -# Unfreeze -unfreeze.title=Bevriezen opheffen -unfreeze.description=Hiermee wordt de bevriezing van een record opgeheven. -# File to -fileTo.title=Archiveren in -fileTo.description=Hiermee wordt een record gearchiveerd in de opgegeven archiefmap. -fileTo.path.display-label=Pad naar archiefmap -fileTo.createRecordPath.display-label=Recordpad maken -# Copy to -copyTo.title=Kopi\u00ebren naar -copyTo.description=Hiermee wordt een record gekopieerd naar de opgegeven archiefmap. -copyTo.path.display-label=Pad naar archiefmap -copyTo.createRecordPath.display-label=Recordpad maken -# Move to -moveTo.title=Verplaatsen naar -moveTo.description=Hiermee wordt een record verplaatst naar de opgegeven archiefmap. -moveTo.path.display-label=Pad naar archiefmap -moveTo.createRecordPath.display-label=Recordpad maken -# Link to -linkTo.title=Koppelen naar -linkTo.description=Hiermee wordt een record gekoppeld naar de opgegeven archiefmap. -linkTo.path.display-label=Pad naar archiefmap -linkTo.createRecordPath.display-label=Recordpad maken -# Reject -reject.title=Afwijzen -reject.description=Hiermee wordt een record afgewezen en wordt het document naar de originele locatie verplaatst. -reject.reason.display-label=Reden voor afwijzing -# Request Information -requestInfo.title=Informatie aanvragen -requestInfo.description=Hiermee wordt een werkstroom gestart voor het aanvragen van meer informatie over een record. -# Execute script -executeScript.title=Script uitvoeren -executeScript.description=Hiermee wordt een script uitgevoerd. -executeScript.script-ref.display-label=Script -# Send Email -sendEmail.title=E-mail verzenden -sendEmail.description=Verzend een e-mail. -# Set Property -setPropertyValue.title=Eigenschapwaarde instellen -setPropertyValue.description=Stel een eigenschapwaarde in - -# Edit Hold Reason -editHoldReason.title=Reden van wachtstand bewerken -editHoldReason.description=Reden van wachtstand bewerken -# Relinquish Hold -relinquishHold.title=Wachtstand afwijzen -relinquishHold.description=Wachtstand afwijzen -# Edit Review As Of Date -editReviewAsOfDate.title=Begindatum revisie bewerken -editReviewAsOfDate.description=Begindatum revisie bewerken -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=Begindatum beschikkingsactie bewerken -editDispositionActionAsOfDate.description=Begindatum beschikkingsactie bewerken -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=Definitie vitale record uitzenden -broadcastVitalRecordDefinition.description=Definitie vitale record uitzenden -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=Update van definitie beschikkingsactie uitzenden -broadcastDispositionActionDefinitionUpdate.description=Update van definitie beschikkingsactie uitzenden -# Undo Event -undoEvent.title=Gebeurtenis ongedaan maken -undoEvent.description=Gebeurtenis ongedaan maken -# Transfer Complete -transferComplete.title=Overzetten afgerond -transferComplete.description=Overzetten afgerond -# Accession Complete -accessionComplete.title=Overdracht afgerond -accessionComplete.description=Overdracht afgerond -# Split Email -splitEmail.title=E-mail opsplitsen -splitEmail.description=E-mail opsplitsen -# Create Disposition Schedule -createDispositionSchedule.title=Beschikkingsschema maken -createDispositionSchedule.description=Beschikkingsschema maken -# File Destruction Report -fileDestructionReport.title=Vernietigingsrapport archiveren -fileDestructionReport.description=Vernietigingsrapport archiveren -# Cut off -cutoff.title=Afsluiten -cutoff.description=Afsluiten -# Destroy -destroy.title=Vernietigen -destroy.description=Vernietigen -# Reviewed -reviewed.title=Gereviseerd -reviewed.description=Gereviseerd -# Hide Record -hide-record.title=Record verbergen -hide-record.description=Record verbergen -# Transfer -transfer.title=Overzetten -transfer.description=Overzetten -# Uncut off -unCutoff.title=Afsluiten ongedaan maken -unCutoff.description=Afsluiten ongedaan maken -# Accession -accession.title=Overdracht -accession.description=Overdracht -# Retain -retain.title=Behouden -retain.description=Behouden -# Add Record Types -addRecordTypes.title=Recordtypes toevoegen -addRecordTypes.description=Hiermee worden de geselecteerde types aan de record toegevoegd. -# File report -fileReport.title=Rapport archiveren -fileReport.description=Rapport archiveren -# Delete Hold -deleteHold.title=Wachtstand verwijderen -deleteHold.description=Wachtstand verwijderen -# Move DM record -move-dm-record.title=Record verplaatsen -move-dm-record.description=Record verplaatsen -# Unlink from -unlinkFrom.title=Koppeling opheffen met -unlinkFrom.description=Koppeling opheffen met - -# Recordable version config -recordable-version-config.title=Opties voor automatisch declareren -recordable-version-config.description=Opties voor automatisch declareren -recordable-version-config.version.display-label=Versies automatisch declareren als records - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=Recordcategorie -rm-ac-is-kind-kinds.record_folder=Archiefmap -rm-ac-is-kind-kinds.record=Record - -rm-ac-disposition-action-relative-positions.next=Volgende -rm-ac-disposition-action-relative-positions.previous=Vorige -rm-ac-disposition-action-relative-positions.any=Willekeurig - -ac-versions.none=Nooit -ac-versions.major_only=Alleen voor primaire versies +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=Geclassificeerd op beschikkingsschema +isClassified.description=De records of archiefmappen zijn geclassificeerd op basis van een beschikkingsschema + +# Are cutoff +isCutoff.title=Afsluiten +isCutoff.description=Records of archiefmappen zijn afgesloten. + +# Are declared +isDeclared.title=Record afgerond +isDeclared.description=De record is afgerond + +# Is on hold +isFrozen.title=In wachtstand +isFrozen.description=De record of de archiefmap bevindt zich in de wachtstand + +# Are filed +isRecordFiled.title=Record gearchiveerd +isRecordFiled.description=De record is gearchiveerd + +# Are closed record folders +isRecordFolderClosed.title=Archiefmap gesloten +isRecordFolderClosed.description=De archiefmap is gesloten + +# Are vital +isVital.title=Vitale record +isVital.description=De record of de archiefmap is vitaal + +# Have Disposition Action +hasDispositionAction.title=Heeft beschikkingsactie +hasDispositionAction.description=De nodes hebben de opgegeven gekoppelde beschikkingsactie op de opgegeven relatieve positie + +# Are kind +isKind.title=Type onderdeel Record Management +isKind.description=De nodes zijn van een type ordeningsplancomponent +isKind.kind.display-label=Type + +# Are Record Type +isRecordType.title=Heeft recordtype +isRecordType.description=De records zijn van het opgegeven type + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=Declareren als record +create-record.description=Hiermee wordt een document gedeclareerd als een record. +create-record.file-plan.display-label=Ordeningsplan +create-record.hide-record.display-label=Record verbergen +# Declare As Version Record +declare-as-version-record.title=Versie declareren als record +declare-as-version-record.description=Hiermee wordt een nieuwe versie van een document gedeclareerd als een versierecord. +declare-as-version-record.file-plan.display-label=Ordeningsplan +# Complete record +declareRecord.title=Record afronden +declareRecord.description=Hiermee wordt een record afgerond. +# Reopens record +undeclareRecord.title=Record heropenen +undeclareRecord.description=Hiermee wordt een record heropend. +# Open record folder +openRecordFolder.title=Archiefmap openen +openRecordFolder.description=Hiermee wordt een archiefmap geopend. +# Close record folder +closeRecordFolder.title=Archiefmap sluiten +closeRecordFolder.description=Hiermee wordt een archiefmap afgesloten. +# Complete event +completeEvent.title=Gebeurtenis afronden +completeEvent.description=Hiermee wordt een gebeurtenis afgerond. +completeEvent.eventName.display-label=Gebeurtenis +# Freeze +freeze.title=Bevriezen +freeze.description=Hiermee wordt een record bevroren. +freeze.reason.display-label=Reden +# Unfreeze +unfreeze.title=Bevriezen opheffen +unfreeze.description=Hiermee wordt de bevriezing van een record opgeheven. +# File to +fileTo.title=Archiveren in +fileTo.description=Hiermee wordt een record gearchiveerd in de opgegeven archiefmap. +fileTo.path.display-label=Pad naar archiefmap +fileTo.createRecordPath.display-label=Recordpad maken +# Copy to +copyTo.title=Kopi\u00ebren naar +copyTo.description=Hiermee wordt een record gekopieerd naar de opgegeven archiefmap. +copyTo.path.display-label=Pad naar archiefmap +copyTo.createRecordPath.display-label=Recordpad maken +# Move to +moveTo.title=Verplaatsen naar +moveTo.description=Hiermee wordt een record verplaatst naar de opgegeven archiefmap. +moveTo.path.display-label=Pad naar archiefmap +moveTo.createRecordPath.display-label=Recordpad maken +# Link to +linkTo.title=Koppelen naar +linkTo.description=Hiermee wordt een record gekoppeld naar de opgegeven archiefmap. +linkTo.path.display-label=Pad naar archiefmap +linkTo.createRecordPath.display-label=Recordpad maken +# Reject +reject.title=Afwijzen +reject.description=Hiermee wordt een record afgewezen en wordt het document naar de originele locatie verplaatst. +reject.reason.display-label=Reden voor afwijzing +# Request Information +requestInfo.title=Informatie aanvragen +requestInfo.description=Hiermee wordt een werkstroom gestart voor het aanvragen van meer informatie over een record. +# Execute script +executeScript.title=Script uitvoeren +executeScript.description=Hiermee wordt een script uitgevoerd. +executeScript.script-ref.display-label=Script +# Send Email +sendEmail.title=E-mail verzenden +sendEmail.description=Verzend een e-mail. +# Set Property +setPropertyValue.title=Eigenschapwaarde instellen +setPropertyValue.description=Stel een eigenschapwaarde in + +# Edit Hold Reason +editHoldReason.title=Reden van wachtstand bewerken +editHoldReason.description=Reden van wachtstand bewerken +# Relinquish Hold +relinquishHold.title=Wachtstand afwijzen +relinquishHold.description=Wachtstand afwijzen +# Edit Review As Of Date +editReviewAsOfDate.title=Begindatum revisie bewerken +editReviewAsOfDate.description=Begindatum revisie bewerken +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=Begindatum beschikkingsactie bewerken +editDispositionActionAsOfDate.description=Begindatum beschikkingsactie bewerken +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=Definitie vitale record uitzenden +broadcastVitalRecordDefinition.description=Definitie vitale record uitzenden +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=Update van definitie beschikkingsactie uitzenden +broadcastDispositionActionDefinitionUpdate.description=Update van definitie beschikkingsactie uitzenden +# Undo Event +undoEvent.title=Gebeurtenis ongedaan maken +undoEvent.description=Gebeurtenis ongedaan maken +# Transfer Complete +transferComplete.title=Overzetten afgerond +transferComplete.description=Overzetten afgerond +# Accession Complete +accessionComplete.title=Overdracht afgerond +accessionComplete.description=Overdracht afgerond +# Split Email +splitEmail.title=E-mail opsplitsen +splitEmail.description=E-mail opsplitsen +# Create Disposition Schedule +createDispositionSchedule.title=Beschikkingsschema maken +createDispositionSchedule.description=Beschikkingsschema maken +# File Destruction Report +fileDestructionReport.title=Vernietigingsrapport archiveren +fileDestructionReport.description=Vernietigingsrapport archiveren +# Cut off +cutoff.title=Afsluiten +cutoff.description=Afsluiten +# Destroy +destroy.title=Vernietigen +destroy.description=Vernietigen +# Reviewed +reviewed.title=Gereviseerd +reviewed.description=Gereviseerd +# Hide Record +hide-record.title=Record verbergen +hide-record.description=Record verbergen +# Transfer +transfer.title=Overzetten +transfer.description=Overzetten +# Uncut off +unCutoff.title=Afsluiten ongedaan maken +unCutoff.description=Afsluiten ongedaan maken +# Accession +accession.title=Overdracht +accession.description=Overdracht +# Retain +retain.title=Behouden +retain.description=Behouden +# Add Record Types +addRecordTypes.title=Recordtypes toevoegen +addRecordTypes.description=Hiermee worden de geselecteerde types aan de record toegevoegd. +# File report +fileReport.title=Rapport archiveren +fileReport.description=Rapport archiveren +# Delete Hold +deleteHold.title=Wachtstand verwijderen +deleteHold.description=Wachtstand verwijderen +# Move DM record +move-dm-record.title=Record verplaatsen +move-dm-record.description=Record verplaatsen +# Unlink from +unlinkFrom.title=Koppeling opheffen met +unlinkFrom.description=Koppeling opheffen met + +# Recordable version config +recordable-version-config.title=Opties voor automatisch declareren +recordable-version-config.description=Opties voor automatisch declareren +recordable-version-config.version.display-label=Versies automatisch declareren als records + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=Recordcategorie +rm-ac-is-kind-kinds.record_folder=Archiefmap +rm-ac-is-kind-kinds.record=Record + +rm-ac-disposition-action-relative-positions.next=Volgende +rm-ac-disposition-action-relative-positions.previous=Vorige +rm-ac-disposition-action-relative-positions.any=Willekeurig + +ac-versions.none=Nooit +ac-versions.major_only=Alleen voor primaire versies ac-versions.all=Voor alle primaire en secundaire versies \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_zh_CN.properties index 577dabe9c4..16a5657328 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions_zh_CN.properties @@ -1,211 +1,211 @@ -# -# i18n for Records Management Action Conditions -# -# Are classified -isClassified.title=\u6309\u5904\u7f6e\u8ba1\u5212\u5206\u7c7b -isClassified.description=\u6309\u5904\u7f6e\u8ba1\u5212\u5c06\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u5206\u7c7b\u3002 - -# Are cutoff -isCutoff.title=\u4e2d\u65ad -isCutoff.description=\u5df2\u4e2d\u65ad\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 - -# Are declared -isDeclared.title=\u8bb0\u5f55\u5df2\u5b8c\u6210 -isDeclared.description=\u8bb0\u5f55\u662f\u5426\u5b8c\u6574\u3002 - -# Is on hold -isFrozen.title=\u4fdd\u5b58\u4e2d -isFrozen.description=\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u5728\u4fdd\u5b58\u4e2d\u3002 - -# Are filed -isRecordFiled.title=\u8bb0\u5f55\u5df2\u7acb\u5377 -isRecordFiled.description=\u8bb0\u5f55\u662f\u5426\u7acb\u5377\u3002 - -# Are closed record folders -isRecordFolderClosed.title=\u8bb0\u5f55\u6587\u4ef6\u5939\u5df2\u5173\u95ed -isRecordFolderClosed.description=\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u5df2\u5173\u95ed\u3002 - -# Are vital -isVital.title=\u6838\u5fc3\u8bb0\u5f55 -isVital.description=\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u4e3a\u91cd\u8981\u3002 - -# Have Disposition Action -hasDispositionAction.title=\u5177\u6709\u5904\u7f6e\u64cd\u4f5c -hasDispositionAction.description=\u8282\u70b9\u5728\u6307\u5b9a\u7684\u76f8\u5bf9\u4f4d\u7f6e\u662f\u5426\u6709\u6307\u5b9a\u7684\u76f8\u5173\u5904\u7f6e\u64cd\u4f5c\u3002 - -# Are kind -isKind.title=\u8bb0\u5f55\u7ba1\u7406\u9879\u76ee\u7684\u7c7b\u578b -isKind.description=\u662f\u5426\u4e3a\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6\u7c7b\u578b\u7684\u8282\u70b9\u3002 -isKind.kind.display-label=\u7c7b\u578b - -# Are Record Type -isRecordType.title=\u5177\u6709\u8bb0\u5f55\u7c7b\u578b -isRecordType.description=\u662f\u5426\u4e3a\u6307\u5b9a\u7c7b\u578b\u7684\u8bb0\u5f55\u3002 - - -# -# i18n for Records Management Actions -# -# Declare As Record -create-record.title=\u58f0\u660e\u4e3a\u8bb0\u5f55 -create-record.description=\u5c06\u6587\u6863\u58f0\u660e\u4e3a\u8bb0\u5f55\u3002 -create-record.file-plan.display-label=\u5f52\u7c7b\u65b9\u6848 -create-record.hide-record.display-label=\u9690\u85cf\u8bb0\u5f55 -# Declare As Version Record -declare-as-version-record.title=\u58f0\u660e\u7248\u672c\u4e3a\u8bb0\u5f55 -declare-as-version-record.description=\u58f0\u660e\u65b0\u7248\u672c\u6587\u6863\u4e3a\u7248\u672c\u8bb0\u5f55\u3002 -declare-as-version-record.file-plan.display-label=\u5f52\u7c7b\u65b9\u6848 -# Complete record -declareRecord.title=\u5b8c\u6210\u8bb0\u5f55 -declareRecord.description=\u5b8c\u6210\u8bb0\u5f55\u3002 -# Reopens record -undeclareRecord.title=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55 -undeclareRecord.description=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55\u3002 -# Open record folder -openRecordFolder.title=\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939 -openRecordFolder.description=\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -# Close record folder -closeRecordFolder.title=\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939 -closeRecordFolder.description=\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -# Complete event -completeEvent.title=\u5b8c\u6210\u4e8b\u4ef6 -completeEvent.description=\u5b8c\u6210\u4e8b\u4ef6\u3002 -completeEvent.eventName.display-label=\u4e8b\u4ef6 -# Freeze -freeze.title=\u4fdd\u5b58 -freeze.description=\u4fdd\u5b58\u8bb0\u5f55\u3002 -freeze.reason.display-label=\u539f\u56e0 -# Unfreeze -unfreeze.title=\u53d6\u6d88\u4fdd\u5b58 -unfreeze.description=\u53d6\u6d88\u4fdd\u5b58\u8bb0\u5f55\u3002 -# File to -fileTo.title=\u7acb\u5377\u81f3 -fileTo.description=\u5c06\u8bb0\u5f55\u7acb\u5377\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -fileTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 -fileTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 -# Copy to -copyTo.title=\u590d\u5236\u5230 -copyTo.description=\u5c06\u8bb0\u5f55\u590d\u5236\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -copyTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 -copyTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 -# Move to -moveTo.title=\u79fb\u52a8\u5230 -moveTo.description=\u5c06\u8bb0\u5f55\u79fb\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -moveTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 -moveTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 -# Link to -linkTo.title=\u94fe\u63a5\u5230 -linkTo.description=\u5c06\u8bb0\u5f55\u94fe\u63a5\u5230\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -linkTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 -linkTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 -# Reject -reject.title=\u62d2\u7edd -reject.description=\u62d2\u7edd\u8bb0\u5f55\u5e76\u5c06\u6587\u6863\u79fb\u52a8\u81f3\u5176\u539f\u59cb\u4f4d\u7f6e -reject.reason.display-label=\u62d2\u7edd\u539f\u56e0 -# Request Information -requestInfo.title=\u8bf7\u6c42\u4fe1\u606f -requestInfo.description=\u5f00\u59cb\u8bf7\u6c42\u8bb0\u5f55\u7684\u66f4\u591a\u4fe1\u606f\u7684\u5de5\u4f5c\u6d41\u7a0b -# Execute script -executeScript.title=\u6267\u884c\u811a\u672c -executeScript.description=\u6267\u884c\u811a\u672c\u3002 -executeScript.script-ref.display-label=\u811a\u672c -# Send Email -sendEmail.title=\u53d1\u9001\u7535\u5b50\u90ae\u4ef6 -sendEmail.description=\u53d1\u9001\u7535\u5b50\u90ae\u4ef6 -# Set Property -setPropertyValue.title=\u8bbe\u7f6e\u5c5e\u6027\u503c -setPropertyValue.description=\u8bbe\u7f6e\u5c5e\u6027\u503c - -# Edit Hold Reason -editHoldReason.title=\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0 -editHoldReason.description=\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0 -# Relinquish Hold -relinquishHold.title=\u653e\u5f03\u4fdd\u5b58 -relinquishHold.description=\u653e\u5f03\u4fdd\u5b58 -# Edit Review As Of Date -editReviewAsOfDate.title=\u7f16\u8f91\u5ba1\u67e5\u622a\u6b62\u65e5\u671f -editReviewAsOfDate.description=\u7f16\u8f91\u5ba1\u67e5\u622a\u6b62\u65e5\u671f -# Edit Disposition Action As Of Date -editDispositionActionAsOfDate.title=\u7f16\u8f91\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f -editDispositionActionAsOfDate.description=\u7f16\u8f91\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f -# Broadcast Vital Record Definition -broadcastVitalRecordDefinition.title=\u5e7f\u64ad\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 -broadcastVitalRecordDefinition.description=\u5e7f\u64ad\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 -# Broadcast Disposition Action Definition Update -broadcastDispositionActionDefinitionUpdate.title=\u5e7f\u64ad\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\u66f4\u65b0 -broadcastDispositionActionDefinitionUpdate.description=\u5e7f\u64ad\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\u66f4\u65b0 -# Undo Event -undoEvent.title=\u64a4\u6d88\u4e8b\u4ef6 -undoEvent.description=\u64a4\u6d88\u4e8b\u4ef6 -# Transfer Complete -transferComplete.title=\u79fb\u4ea4\u5b8c\u6210 -transferComplete.description=\u79fb\u4ea4\u5b8c\u6210 -# Accession Complete -accessionComplete.title=\u5165\u7ba1\u5b8c\u6210 -accessionComplete.description=\u5165\u7ba1\u5b8c\u6210 -# Split Email -splitEmail.title=\u62c6\u5206\u7535\u5b50\u90ae\u4ef6 -splitEmail.description=\u62c6\u5206\u7535\u5b50\u90ae\u4ef6 -# Create Disposition Schedule -createDispositionSchedule.title=\u521b\u5efa\u5904\u7f6e\u8ba1\u5212 -createDispositionSchedule.description=\u521b\u5efa\u5904\u7f6e\u8ba1\u5212 -# File Destruction Report -fileDestructionReport.title=\u7acb\u5377\u9500\u6bc1\u62a5\u544a -fileDestructionReport.description=\u7acb\u5377\u9500\u6bc1\u62a5\u544a -# Cut off -cutoff.title=\u4e2d\u65ad -cutoff.description=\u4e2d\u65ad -# Destroy -destroy.title=\u9500\u6bc1 -destroy.description=\u9500\u6bc1 -# Reviewed -reviewed.title=\u5df2\u5ba1\u67e5 -reviewed.description=\u5df2\u5ba1\u67e5 -# Hide Record -hide-record.title=\u9690\u85cf\u8bb0\u5f55 -hide-record.description=\u9690\u85cf\u8bb0\u5f55 -# Transfer -transfer.title=\u79fb\u4ea4 -transfer.description=\u79fb\u4ea4 -# Uncut off -unCutoff.title=\u64a4\u6d88\u4e2d\u65ad -unCutoff.description=\u64a4\u6d88\u4e2d\u65ad -# Accession -accession.title=\u5165\u7ba1 -accession.description=\u5165\u7ba1 -# Retain -retain.title=\u4fdd\u7559 -retain.description=\u4fdd\u7559 -# Add Record Types -addRecordTypes.title=\u6dfb\u52a0\u8bb0\u5f55\u7c7b\u578b -addRecordTypes.description=\u5c06\u6240\u9009\u7c7b\u578b\u6dfb\u52a0\u81f3\u8bb0\u5f55 -# File report -fileReport.title=\u7acb\u5377\u62a5\u544a -fileReport.description=\u7acb\u5377\u62a5\u544a -# Delete Hold -deleteHold.title=\u5220\u9664\u4fdd\u5b58 -deleteHold.description=\u5220\u9664\u4fdd\u5b58 -# Move DM record -move-dm-record.title=\u79fb\u52a8\u8bb0\u5f55 -move-dm-record.description=\u79fb\u52a8\u8bb0\u5f55 -# Unlink from -unlinkFrom.title=\u53d6\u6d88\u94fe\u63a5 -unlinkFrom.description=\u53d6\u6d88\u94fe\u63a5 - -# Recordable version config -recordable-version-config.title=\u81ea\u52a8\u58f0\u660e\u9009\u9879 -recordable-version-config.description=\u81ea\u52a8\u58f0\u660e\u9009\u9879 -recordable-version-config.version.display-label=\u81ea\u52a8\u58f0\u660e\u7248\u672c\u4e3a\u8bb0\u5f55 - -# Action parameter constraints -rm-ac-is-kind-kinds.record_category=\u8bb0\u5f55\u7c7b\u522b -rm-ac-is-kind-kinds.record_folder=\u8bb0\u5f55\u6587\u4ef6\u5939 -rm-ac-is-kind-kinds.record=\u8bb0\u5f55 - -rm-ac-disposition-action-relative-positions.next=\u4e0b\u4e00\u6b65 -rm-ac-disposition-action-relative-positions.previous=\u4e0a\u4e00\u6b65 -rm-ac-disposition-action-relative-positions.any=\u4efb\u4f55 - -ac-versions.none=\u4ece\u4e0d -ac-versions.major_only=\u4ec5\u9002\u7528\u4e8e\u4e3b\u8981\u7248\u672c +# +# i18n for Records Management Action Conditions +# +# Are classified +isClassified.title=\u6309\u5904\u7f6e\u8ba1\u5212\u5206\u7c7b +isClassified.description=\u6309\u5904\u7f6e\u8ba1\u5212\u5c06\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u5206\u7c7b\u3002 + +# Are cutoff +isCutoff.title=\u4e2d\u65ad +isCutoff.description=\u5df2\u4e2d\u65ad\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 + +# Are declared +isDeclared.title=\u8bb0\u5f55\u5df2\u5b8c\u6210 +isDeclared.description=\u8bb0\u5f55\u662f\u5426\u5b8c\u6574\u3002 + +# Is on hold +isFrozen.title=\u4fdd\u5b58\u4e2d +isFrozen.description=\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u5728\u4fdd\u5b58\u4e2d\u3002 + +# Are filed +isRecordFiled.title=\u8bb0\u5f55\u5df2\u7acb\u5377 +isRecordFiled.description=\u8bb0\u5f55\u662f\u5426\u7acb\u5377\u3002 + +# Are closed record folders +isRecordFolderClosed.title=\u8bb0\u5f55\u6587\u4ef6\u5939\u5df2\u5173\u95ed +isRecordFolderClosed.description=\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u5df2\u5173\u95ed\u3002 + +# Are vital +isVital.title=\u6838\u5fc3\u8bb0\u5f55 +isVital.description=\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939\u662f\u5426\u4e3a\u91cd\u8981\u3002 + +# Have Disposition Action +hasDispositionAction.title=\u5177\u6709\u5904\u7f6e\u64cd\u4f5c +hasDispositionAction.description=\u8282\u70b9\u5728\u6307\u5b9a\u7684\u76f8\u5bf9\u4f4d\u7f6e\u662f\u5426\u6709\u6307\u5b9a\u7684\u76f8\u5173\u5904\u7f6e\u64cd\u4f5c\u3002 + +# Are kind +isKind.title=\u8bb0\u5f55\u7ba1\u7406\u9879\u76ee\u7684\u7c7b\u578b +isKind.description=\u662f\u5426\u4e3a\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6\u7c7b\u578b\u7684\u8282\u70b9\u3002 +isKind.kind.display-label=\u7c7b\u578b + +# Are Record Type +isRecordType.title=\u5177\u6709\u8bb0\u5f55\u7c7b\u578b +isRecordType.description=\u662f\u5426\u4e3a\u6307\u5b9a\u7c7b\u578b\u7684\u8bb0\u5f55\u3002 + + +# +# i18n for Records Management Actions +# +# Declare As Record +create-record.title=\u58f0\u660e\u4e3a\u8bb0\u5f55 +create-record.description=\u5c06\u6587\u6863\u58f0\u660e\u4e3a\u8bb0\u5f55\u3002 +create-record.file-plan.display-label=\u5f52\u7c7b\u65b9\u6848 +create-record.hide-record.display-label=\u9690\u85cf\u8bb0\u5f55 +# Declare As Version Record +declare-as-version-record.title=\u58f0\u660e\u7248\u672c\u4e3a\u8bb0\u5f55 +declare-as-version-record.description=\u58f0\u660e\u65b0\u7248\u672c\u6587\u6863\u4e3a\u7248\u672c\u8bb0\u5f55\u3002 +declare-as-version-record.file-plan.display-label=\u5f52\u7c7b\u65b9\u6848 +# Complete record +declareRecord.title=\u5b8c\u6210\u8bb0\u5f55 +declareRecord.description=\u5b8c\u6210\u8bb0\u5f55\u3002 +# Reopens record +undeclareRecord.title=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55 +undeclareRecord.description=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55\u3002 +# Open record folder +openRecordFolder.title=\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939 +openRecordFolder.description=\u6253\u5f00\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +# Close record folder +closeRecordFolder.title=\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939 +closeRecordFolder.description=\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +# Complete event +completeEvent.title=\u5b8c\u6210\u4e8b\u4ef6 +completeEvent.description=\u5b8c\u6210\u4e8b\u4ef6\u3002 +completeEvent.eventName.display-label=\u4e8b\u4ef6 +# Freeze +freeze.title=\u4fdd\u5b58 +freeze.description=\u4fdd\u5b58\u8bb0\u5f55\u3002 +freeze.reason.display-label=\u539f\u56e0 +# Unfreeze +unfreeze.title=\u53d6\u6d88\u4fdd\u5b58 +unfreeze.description=\u53d6\u6d88\u4fdd\u5b58\u8bb0\u5f55\u3002 +# File to +fileTo.title=\u7acb\u5377\u81f3 +fileTo.description=\u5c06\u8bb0\u5f55\u7acb\u5377\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +fileTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 +fileTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 +# Copy to +copyTo.title=\u590d\u5236\u5230 +copyTo.description=\u5c06\u8bb0\u5f55\u590d\u5236\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +copyTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 +copyTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 +# Move to +moveTo.title=\u79fb\u52a8\u5230 +moveTo.description=\u5c06\u8bb0\u5f55\u79fb\u81f3\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +moveTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 +moveTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 +# Link to +linkTo.title=\u94fe\u63a5\u5230 +linkTo.description=\u5c06\u8bb0\u5f55\u94fe\u63a5\u5230\u6307\u5b9a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +linkTo.path.display-label=\u8bb0\u5f55\u6587\u4ef6\u5939\u7684\u8def\u5f84 +linkTo.createRecordPath.display-label=\u521b\u5efa\u8bb0\u5f55\u8def\u5f84 +# Reject +reject.title=\u62d2\u7edd +reject.description=\u62d2\u7edd\u8bb0\u5f55\u5e76\u5c06\u6587\u6863\u79fb\u52a8\u81f3\u5176\u539f\u59cb\u4f4d\u7f6e +reject.reason.display-label=\u62d2\u7edd\u539f\u56e0 +# Request Information +requestInfo.title=\u8bf7\u6c42\u4fe1\u606f +requestInfo.description=\u5f00\u59cb\u8bf7\u6c42\u8bb0\u5f55\u7684\u66f4\u591a\u4fe1\u606f\u7684\u5de5\u4f5c\u6d41\u7a0b +# Execute script +executeScript.title=\u6267\u884c\u811a\u672c +executeScript.description=\u6267\u884c\u811a\u672c\u3002 +executeScript.script-ref.display-label=\u811a\u672c +# Send Email +sendEmail.title=\u53d1\u9001\u7535\u5b50\u90ae\u4ef6 +sendEmail.description=\u53d1\u9001\u7535\u5b50\u90ae\u4ef6 +# Set Property +setPropertyValue.title=\u8bbe\u7f6e\u5c5e\u6027\u503c +setPropertyValue.description=\u8bbe\u7f6e\u5c5e\u6027\u503c + +# Edit Hold Reason +editHoldReason.title=\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0 +editHoldReason.description=\u7f16\u8f91\u4fdd\u5b58\u539f\u56e0 +# Relinquish Hold +relinquishHold.title=\u653e\u5f03\u4fdd\u5b58 +relinquishHold.description=\u653e\u5f03\u4fdd\u5b58 +# Edit Review As Of Date +editReviewAsOfDate.title=\u7f16\u8f91\u5ba1\u67e5\u622a\u6b62\u65e5\u671f +editReviewAsOfDate.description=\u7f16\u8f91\u5ba1\u67e5\u622a\u6b62\u65e5\u671f +# Edit Disposition Action As Of Date +editDispositionActionAsOfDate.title=\u7f16\u8f91\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f +editDispositionActionAsOfDate.description=\u7f16\u8f91\u5904\u7f6e\u64cd\u4f5c\u622a\u6b62\u65e5\u671f +# Broadcast Vital Record Definition +broadcastVitalRecordDefinition.title=\u5e7f\u64ad\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 +broadcastVitalRecordDefinition.description=\u5e7f\u64ad\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 +# Broadcast Disposition Action Definition Update +broadcastDispositionActionDefinitionUpdate.title=\u5e7f\u64ad\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\u66f4\u65b0 +broadcastDispositionActionDefinitionUpdate.description=\u5e7f\u64ad\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\u66f4\u65b0 +# Undo Event +undoEvent.title=\u64a4\u6d88\u4e8b\u4ef6 +undoEvent.description=\u64a4\u6d88\u4e8b\u4ef6 +# Transfer Complete +transferComplete.title=\u79fb\u4ea4\u5b8c\u6210 +transferComplete.description=\u79fb\u4ea4\u5b8c\u6210 +# Accession Complete +accessionComplete.title=\u5165\u7ba1\u5b8c\u6210 +accessionComplete.description=\u5165\u7ba1\u5b8c\u6210 +# Split Email +splitEmail.title=\u62c6\u5206\u7535\u5b50\u90ae\u4ef6 +splitEmail.description=\u62c6\u5206\u7535\u5b50\u90ae\u4ef6 +# Create Disposition Schedule +createDispositionSchedule.title=\u521b\u5efa\u5904\u7f6e\u8ba1\u5212 +createDispositionSchedule.description=\u521b\u5efa\u5904\u7f6e\u8ba1\u5212 +# File Destruction Report +fileDestructionReport.title=\u7acb\u5377\u9500\u6bc1\u62a5\u544a +fileDestructionReport.description=\u7acb\u5377\u9500\u6bc1\u62a5\u544a +# Cut off +cutoff.title=\u4e2d\u65ad +cutoff.description=\u4e2d\u65ad +# Destroy +destroy.title=\u9500\u6bc1 +destroy.description=\u9500\u6bc1 +# Reviewed +reviewed.title=\u5df2\u5ba1\u67e5 +reviewed.description=\u5df2\u5ba1\u67e5 +# Hide Record +hide-record.title=\u9690\u85cf\u8bb0\u5f55 +hide-record.description=\u9690\u85cf\u8bb0\u5f55 +# Transfer +transfer.title=\u79fb\u4ea4 +transfer.description=\u79fb\u4ea4 +# Uncut off +unCutoff.title=\u64a4\u6d88\u4e2d\u65ad +unCutoff.description=\u64a4\u6d88\u4e2d\u65ad +# Accession +accession.title=\u5165\u7ba1 +accession.description=\u5165\u7ba1 +# Retain +retain.title=\u4fdd\u7559 +retain.description=\u4fdd\u7559 +# Add Record Types +addRecordTypes.title=\u6dfb\u52a0\u8bb0\u5f55\u7c7b\u578b +addRecordTypes.description=\u5c06\u6240\u9009\u7c7b\u578b\u6dfb\u52a0\u81f3\u8bb0\u5f55 +# File report +fileReport.title=\u7acb\u5377\u62a5\u544a +fileReport.description=\u7acb\u5377\u62a5\u544a +# Delete Hold +deleteHold.title=\u5220\u9664\u4fdd\u5b58 +deleteHold.description=\u5220\u9664\u4fdd\u5b58 +# Move DM record +move-dm-record.title=\u79fb\u52a8\u8bb0\u5f55 +move-dm-record.description=\u79fb\u52a8\u8bb0\u5f55 +# Unlink from +unlinkFrom.title=\u53d6\u6d88\u94fe\u63a5 +unlinkFrom.description=\u53d6\u6d88\u94fe\u63a5 + +# Recordable version config +recordable-version-config.title=\u81ea\u52a8\u58f0\u660e\u9009\u9879 +recordable-version-config.description=\u81ea\u52a8\u58f0\u660e\u9009\u9879 +recordable-version-config.version.display-label=\u81ea\u52a8\u58f0\u660e\u7248\u672c\u4e3a\u8bb0\u5f55 + +# Action parameter constraints +rm-ac-is-kind-kinds.record_category=\u8bb0\u5f55\u7c7b\u522b +rm-ac-is-kind-kinds.record_folder=\u8bb0\u5f55\u6587\u4ef6\u5939 +rm-ac-is-kind-kinds.record=\u8bb0\u5f55 + +rm-ac-disposition-action-relative-positions.next=\u4e0b\u4e00\u6b65 +rm-ac-disposition-action-relative-positions.previous=\u4e0a\u4e00\u6b65 +rm-ac-disposition-action-relative-positions.any=\u4efb\u4f55 + +ac-versions.none=\u4ece\u4e0d +ac-versions.major_only=\u4ec5\u9002\u7528\u4e8e\u4e3b\u8981\u7248\u672c ac-versions.all=\u9002\u7528\u4e8e\u6240\u6709\u4e3b\u8981\u548c\u6b21\u8981\u7248\u672c \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service.properties index 2e837c01a4..071e972a8f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=The customization service has not been started. -rm.admin.not-customisable=The class {0} is not customizable. -rm.admin.invalid-custom-aspect=The custom aspect {0} for customisable class {1} couldn't be found. -rm.admin.property-already-exists=Property {0} already exists. -rm.admin.cannot-apply-constraint=Cannot apply constraint {0} to property {1} with datatype {2}. (expected: dataType = TEXT) -rm.admin.prop-exist=The custom property {0} can't be found. -rm.admin.custom-prop-exist=The custom model does not contain the property {0}. -rm.admin.unknown-aspect=Unknown aspect {0}. -rm.admin.constraint-exists=The constraint {0} already exists. -rm.admin.contraint-cannot-find=The definition for constraint {0} can't be found. -rm.admin.unexpected_type_constraint=Unexpected type {0} for constraint {1}. The expected is {2}. -rm.admin.custom-model-not-found=The custom model {0} can't be found. -rm.admin.custom-model-no-content=The custom model has no content. (nodeRef={0}) -rm.admin.error-write-custom-model=Error writing custom model content. (nodeRef={0}). -rm.admin.error-client-id=Error generating the client id, because it's already in use. (clientid={0}) +rm.admin.service-not-init=The customization service has not been started. +rm.admin.not-customisable=The class {0} is not customizable. +rm.admin.invalid-custom-aspect=The custom aspect {0} for customisable class {1} couldn't be found. +rm.admin.property-already-exists=Property {0} already exists. +rm.admin.cannot-apply-constraint=Cannot apply constraint {0} to property {1} with datatype {2}. (expected: dataType = TEXT) +rm.admin.prop-exist=The custom property {0} can't be found. +rm.admin.custom-prop-exist=The custom model does not contain the property {0}. +rm.admin.unknown-aspect=Unknown aspect {0}. +rm.admin.constraint-exists=The constraint {0} already exists. +rm.admin.contraint-cannot-find=The definition for constraint {0} can't be found. +rm.admin.unexpected_type_constraint=Unexpected type {0} for constraint {1}. The expected is {2}. +rm.admin.custom-model-not-found=The custom model {0} can't be found. +rm.admin.custom-model-no-content=The custom model has no content. (nodeRef={0}) +rm.admin.error-write-custom-model=Error writing custom model content. (nodeRef={0}). +rm.admin.error-client-id=Error generating the client id, because it's already in use. (clientid={0}) rm.admin.error-split-id=Unable to split id {0}, because separator {1} is not present. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_de.properties index 4e94f1a10c..805ac0199f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_de.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=Der Anpassungsservice wurde nicht gestartet. -rm.admin.not-customisable=Die Klasse {0} kann nicht angepasst werden. -rm.admin.invalid-custom-aspect=Der benutzerdefinierte Aspekt {0} f\u00fcr die anpassbare Klasse {1} wurde nicht gefunden. -rm.admin.property-already-exists=Eigenschaft {0} bereits vorhanden. -rm.admin.cannot-apply-constraint=Randbedingung {0} kann nicht auf Eigenschaft {1} mit Datentyp {2} angewendet werden. (erwartet: Datentyp = TEXT) -rm.admin.prop-exist=Benutzerdefinierte Eigenschaft {0} wurde nicht gefunden. -rm.admin.custom-prop-exist=Das benutzerdefinierte Modell enth\u00e4lt nicht die Eigenschaft {0}. -rm.admin.unknown-aspect=Unbekannter Aspekt {0}. -rm.admin.constraint-exists=Randbedingung {0} bereits vorhanden. -rm.admin.contraint-cannot-find=Die Definition f\u00fcr Randbedingung {0} wurde nicht gefunden. -rm.admin.unexpected_type_constraint=Unerwarteter Typ {0} f\u00fcr Randbedingung {1}. Erwartet wird {2}. -rm.admin.custom-model-not-found=Benutzerdefiniertes Modell {0} wurde nicht gefunden. -rm.admin.custom-model-no-content=Benutzerdefiniertes Modell hat keinen Inhalt. (nodeRef={0}) -rm.admin.error-write-custom-model=Beim Schreiben von benutzerdefiniertem Modellinhalt ist ein Fehler aufgetreten. (nodeRef={0}). -rm.admin.error-client-id=Beim Generieren der Client-ID ist ein Fehler aufgetreten, da diese bereits verwendet wird. (clientid={0}) +rm.admin.service-not-init=Der Anpassungsservice wurde nicht gestartet. +rm.admin.not-customisable=Die Klasse {0} kann nicht angepasst werden. +rm.admin.invalid-custom-aspect=Der benutzerdefinierte Aspekt {0} f\u00fcr die anpassbare Klasse {1} wurde nicht gefunden. +rm.admin.property-already-exists=Eigenschaft {0} bereits vorhanden. +rm.admin.cannot-apply-constraint=Randbedingung {0} kann nicht auf Eigenschaft {1} mit Datentyp {2} angewendet werden. (erwartet: Datentyp = TEXT) +rm.admin.prop-exist=Benutzerdefinierte Eigenschaft {0} wurde nicht gefunden. +rm.admin.custom-prop-exist=Das benutzerdefinierte Modell enth\u00e4lt nicht die Eigenschaft {0}. +rm.admin.unknown-aspect=Unbekannter Aspekt {0}. +rm.admin.constraint-exists=Randbedingung {0} bereits vorhanden. +rm.admin.contraint-cannot-find=Die Definition f\u00fcr Randbedingung {0} wurde nicht gefunden. +rm.admin.unexpected_type_constraint=Unerwarteter Typ {0} f\u00fcr Randbedingung {1}. Erwartet wird {2}. +rm.admin.custom-model-not-found=Benutzerdefiniertes Modell {0} wurde nicht gefunden. +rm.admin.custom-model-no-content=Benutzerdefiniertes Modell hat keinen Inhalt. (nodeRef={0}) +rm.admin.error-write-custom-model=Beim Schreiben von benutzerdefiniertem Modellinhalt ist ein Fehler aufgetreten. (nodeRef={0}). +rm.admin.error-client-id=Beim Generieren der Client-ID ist ein Fehler aufgetreten, da diese bereits verwendet wird. (clientid={0}) rm.admin.error-split-id=ID {0} kann nicht getrennt werden, da das Trennzeichen {1} nicht vorhanden ist. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties index 9c79eaf9e1..64776c8dad 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=No se ha iniciado el servicio de personalizaci\u00f3n. -rm.admin.not-customisable=La clase ''{0}'' no es personalizable. -rm.admin.invalid-custom-aspect=No se ha podido encontrar el aspecto personalizado ''{0}'' para la clase personalizable ''{1}''. -rm.admin.property-already-exists=La propiedad ''{0}'' ya existe. -rm.admin.cannot-apply-constraint=No se puede aplicar la restricci\u00f3n ''{0}'' a la propiedad ''{1}'' con el tipo de datos ''{2}''. (previsto: tipo de datos = TEXT) -rm.admin.prop-exist=No se puede encontrar la propiedad personalizada ''{0}''. -rm.admin.custom-prop-exist=El modelo personalizado no contiene la propiedad ''{0}''. -rm.admin.unknown-aspect=Aspecto desconocido ''{0}''. -rm.admin.constraint-exists=La restricci\u00f3n ''{0}'' ya existe. -rm.admin.contraint-cannot-find=No se puede encontrar la definici\u00f3n para la restricci\u00f3n ''{0}''. -rm.admin.unexpected_type_constraint=Tipo inesperado ''{0}'' para la restricci\u00f3n ''{1}''. Lo esperado es ''{2}''. -rm.admin.custom-model-not-found=No se puede encontrar el modelo personalizado ''{0}''. -rm.admin.custom-model-no-content=El modelo personalizado no tiene contenido (nodeRef={0}) -rm.admin.error-write-custom-model=Error al escribir contenido de modelo personalizado. (nodeRef={0}) -rm.admin.error-client-id=Error al generar el identificador del cliente porque ya est\u00e1 en uso. (clientid={0}) +rm.admin.service-not-init=No se ha iniciado el servicio de personalizaci\u00f3n. +rm.admin.not-customisable=La clase ''{0}'' no es personalizable. +rm.admin.invalid-custom-aspect=No se ha podido encontrar el aspecto personalizado ''{0}'' para la clase personalizable ''{1}''. +rm.admin.property-already-exists=La propiedad ''{0}'' ya existe. +rm.admin.cannot-apply-constraint=No se puede aplicar la restricci\u00f3n ''{0}'' a la propiedad ''{1}'' con el tipo de datos ''{2}''. (previsto: tipo de datos = TEXT) +rm.admin.prop-exist=No se puede encontrar la propiedad personalizada ''{0}''. +rm.admin.custom-prop-exist=El modelo personalizado no contiene la propiedad ''{0}''. +rm.admin.unknown-aspect=Aspecto desconocido ''{0}''. +rm.admin.constraint-exists=La restricci\u00f3n ''{0}'' ya existe. +rm.admin.contraint-cannot-find=No se puede encontrar la definici\u00f3n para la restricci\u00f3n ''{0}''. +rm.admin.unexpected_type_constraint=Tipo inesperado ''{0}'' para la restricci\u00f3n ''{1}''. Lo esperado es ''{2}''. +rm.admin.custom-model-not-found=No se puede encontrar el modelo personalizado ''{0}''. +rm.admin.custom-model-no-content=El modelo personalizado no tiene contenido (nodeRef={0}) +rm.admin.error-write-custom-model=Error al escribir contenido de modelo personalizado. (nodeRef={0}) +rm.admin.error-client-id=Error al generar el identificador del cliente porque ya est\u00e1 en uso. (clientid={0}) rm.admin.error-split-id=No se puede separar el identificador ''{0}'', porque el separador ''{1}'' no est\u00e1 presente. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_fr.properties index 6c11c13c2d..f44ceb76e3 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_fr.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=Le service de personnalisation n'a pas \u00e9t\u00e9 d\u00e9marr\u00e9. -rm.admin.not-customisable=La classe {0} n''est pas personnalisable. -rm.admin.invalid-custom-aspect=L''aspect personnalis\u00e9 {0} pour la classe personnalisable {1} est introuvable. -rm.admin.property-already-exists=La propri\u00e9t\u00e9 {0} existe d\u00e9j\u00e0. -rm.admin.cannot-apply-constraint=Impossible d''appliquer la contrainte {0} \u00e0 la propri\u00e9t\u00e9 {1} avec le datatype {2}. (attendu\u00a0: dataType = TEXT) -rm.admin.prop-exist=La m\u00e9tadonn\u00e9e personnalis\u00e9e {0} est introuvable. -rm.admin.custom-prop-exist=Le mod\u00e8le personnalis\u00e9 ne contient pas la propri\u00e9t\u00e9 {0}. -rm.admin.unknown-aspect=Aspect {0} inconnu. -rm.admin.constraint-exists=La contrainte {0} existe d\u00e9j\u00e0. -rm.admin.contraint-cannot-find=La d\u00e9finition de la contrainte {0} est introuvable. -rm.admin.unexpected_type_constraint=Type {0} inattendu pour la contrainte {1}. Attendu\u00a0: {2} -rm.admin.custom-model-not-found=Le mod\u00e8le personnalis\u00e9 {0} est introuvable. -rm.admin.custom-model-no-content=Le mod\u00e8le personnalis\u00e9 n''a pas de contenu. (nodeRef={0}) -rm.admin.error-write-custom-model=Erreur lors de l''\u00e9criture du contenu du mod\u00e8le personnalis\u00e9. (nodeRef={0}). -rm.admin.error-client-id=Erreur lors de la g\u00e9n\u00e9ration de l''ID client car il est d\u00e9j\u00e0 en cours d''utilisation. (clientid={0}) +rm.admin.service-not-init=Le service de personnalisation n'a pas \u00e9t\u00e9 d\u00e9marr\u00e9. +rm.admin.not-customisable=La classe {0} n''est pas personnalisable. +rm.admin.invalid-custom-aspect=L''aspect personnalis\u00e9 {0} pour la classe personnalisable {1} est introuvable. +rm.admin.property-already-exists=La propri\u00e9t\u00e9 {0} existe d\u00e9j\u00e0. +rm.admin.cannot-apply-constraint=Impossible d''appliquer la contrainte {0} \u00e0 la propri\u00e9t\u00e9 {1} avec le datatype {2}. (attendu\u00a0: dataType = TEXT) +rm.admin.prop-exist=La m\u00e9tadonn\u00e9e personnalis\u00e9e {0} est introuvable. +rm.admin.custom-prop-exist=Le mod\u00e8le personnalis\u00e9 ne contient pas la propri\u00e9t\u00e9 {0}. +rm.admin.unknown-aspect=Aspect {0} inconnu. +rm.admin.constraint-exists=La contrainte {0} existe d\u00e9j\u00e0. +rm.admin.contraint-cannot-find=La d\u00e9finition de la contrainte {0} est introuvable. +rm.admin.unexpected_type_constraint=Type {0} inattendu pour la contrainte {1}. Attendu\u00a0: {2} +rm.admin.custom-model-not-found=Le mod\u00e8le personnalis\u00e9 {0} est introuvable. +rm.admin.custom-model-no-content=Le mod\u00e8le personnalis\u00e9 n''a pas de contenu. (nodeRef={0}) +rm.admin.error-write-custom-model=Erreur lors de l''\u00e9criture du contenu du mod\u00e8le personnalis\u00e9. (nodeRef={0}). +rm.admin.error-client-id=Erreur lors de la g\u00e9n\u00e9ration de l''ID client car il est d\u00e9j\u00e0 en cours d''utilisation. (clientid={0}) rm.admin.error-split-id=Impossible de fractionner l''ID {0} car le s\u00e9parateur {1} n''est pas pr\u00e9sent. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_it.properties index a590c881e5..7b3eddda32 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_it.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=Il servizio di personalizzazione non \u00e8 stato avviato. -rm.admin.not-customisable=Non \u00e8 possibile personalizzare la classe {0}. -rm.admin.invalid-custom-aspect=Non \u00e8 stato possibile trovare l''aspetto personalizzato {0} per la classe personalizzata {1}. -rm.admin.property-already-exists=La propriet\u00e0 {0} \u00e8 gi\u00e0 esistente. -rm.admin.cannot-apply-constraint=Impossibile applicare il vincolo {0} alla propriet\u00e0 {1} con il tipo di dati {2}. (expected: dataType = TEXT) -rm.admin.prop-exist=Impossibile trovare la propriet\u00e0 personalizzata {0}. -rm.admin.custom-prop-exist=Il modello personalizzato non contiene la propriet\u00e0 {0}. -rm.admin.unknown-aspect=Aspetto {0} sconosciuto. -rm.admin.constraint-exists=Il vincolo {0} \u00e8 gi\u00e0 esistente. -rm.admin.contraint-cannot-find=Impossibile trovare la definizione di vincolo {0}. -rm.admin.unexpected_type_constraint=Tipo {0} inaspettato per vincolo {1}. Ci\u00f2 che si aspetta \u00e8 {2}. -rm.admin.custom-model-not-found=Impossibile trovare il modello personalizzato {0}. -rm.admin.custom-model-no-content=Il modello personalizzato non ha contenuti. (nodeRef={0}) -rm.admin.error-write-custom-model=Errore nella scrittura dei contenuti del modello personalizzato. (nodeRef={0}) -rm.admin.error-client-id=Errore nella generazione dell''ID client, poich\u00e9 gi\u00e0 in uso. (clientid={0}) +rm.admin.service-not-init=Il servizio di personalizzazione non \u00e8 stato avviato. +rm.admin.not-customisable=Non \u00e8 possibile personalizzare la classe {0}. +rm.admin.invalid-custom-aspect=Non \u00e8 stato possibile trovare l''aspetto personalizzato {0} per la classe personalizzata {1}. +rm.admin.property-already-exists=La propriet\u00e0 {0} \u00e8 gi\u00e0 esistente. +rm.admin.cannot-apply-constraint=Impossibile applicare il vincolo {0} alla propriet\u00e0 {1} con il tipo di dati {2}. (expected: dataType = TEXT) +rm.admin.prop-exist=Impossibile trovare la propriet\u00e0 personalizzata {0}. +rm.admin.custom-prop-exist=Il modello personalizzato non contiene la propriet\u00e0 {0}. +rm.admin.unknown-aspect=Aspetto {0} sconosciuto. +rm.admin.constraint-exists=Il vincolo {0} \u00e8 gi\u00e0 esistente. +rm.admin.contraint-cannot-find=Impossibile trovare la definizione di vincolo {0}. +rm.admin.unexpected_type_constraint=Tipo {0} inaspettato per vincolo {1}. Ci\u00f2 che si aspetta \u00e8 {2}. +rm.admin.custom-model-not-found=Impossibile trovare il modello personalizzato {0}. +rm.admin.custom-model-no-content=Il modello personalizzato non ha contenuti. (nodeRef={0}) +rm.admin.error-write-custom-model=Errore nella scrittura dei contenuti del modello personalizzato. (nodeRef={0}) +rm.admin.error-client-id=Errore nella generazione dell''ID client, poich\u00e9 gi\u00e0 in uso. (clientid={0}) rm.admin.error-split-id=Impossibile dividere l''ID {0}, poich\u00e9 non \u00e8 presente il separatore {1}. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_ja.properties index 5112339525..cfdc8c7021 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_ja.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u30b5\u30fc\u30d3\u30b9\u306f\u958b\u59cb\u3057\u3066\u3044\u307e\u305b\u3093\u3002 -rm.admin.not-customisable=\u30af\u30e9\u30b9 {0} \u306f\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u4e0d\u53ef\u3067\u3059\u3002 -rm.admin.invalid-custom-aspect=\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u53ef\u80fd\u306a\u30af\u30e9\u30b9 {1} \u5411\u3051\u306e\u30ab\u30b9\u30bf\u30e0\u30a2\u30b9\u30da\u30af\u30c8 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002 -rm.admin.property-already-exists=\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u306f\u3059\u3067\u306b\u5b58\u5728\u3057\u307e\u3059\u3002 -rm.admin.cannot-apply-constraint=\u5236\u7d04 {0} \u3092\u30d7\u30ed\u30d1\u30c6\u30a3 {1}\uff08\u30c7\u30fc\u30bf\u30bf\u30a4\u30d7 {2}\uff09\u306b\u9069\u7528\u3067\u304d\u307e\u305b\u3093\u3002(expected: dataType = TEXT) -rm.admin.prop-exist=\u30ab\u30b9\u30bf\u30e0\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 -rm.admin.custom-prop-exist=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306b\u306f\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002 -rm.admin.unknown-aspect=\u4e0d\u660e\u306a\u30a2\u30b9\u30da\u30af\u30c8 {0}\u3002 -rm.admin.constraint-exists=\u5236\u7d04 {0} \u306f\u3059\u3067\u306b\u5b58\u5728\u3057\u307e\u3059\u3002 -rm.admin.contraint-cannot-find=\u5236\u7d04\u306e\u5b9a\u7fa9 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 -rm.admin.unexpected_type_constraint=\u5236\u7d04 {1} \u306b\u5bfe\u3057\u3066\u4e88\u671f\u305b\u306c\u30bf\u30a4\u30d7 {0} \u3067\u3059\u3002{2} \u306f\u4e88\u671f\u3055\u308c\u308b\u30bf\u30a4\u30d7\u3067\u3059\u3002 -rm.admin.custom-model-not-found=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 -rm.admin.custom-model-no-content=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306b\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u3042\u308a\u307e\u305b\u3093\u3002(nodeRef={0}) -rm.admin.error-write-custom-model=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002(nodeRef={0}). -rm.admin.error-client-id=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\u306f\u4f7f\u7528\u4e2d\u306e\u305f\u3081\u3001\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002(clientid={0}) +rm.admin.service-not-init=\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u30b5\u30fc\u30d3\u30b9\u306f\u958b\u59cb\u3057\u3066\u3044\u307e\u305b\u3093\u3002 +rm.admin.not-customisable=\u30af\u30e9\u30b9 {0} \u306f\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u4e0d\u53ef\u3067\u3059\u3002 +rm.admin.invalid-custom-aspect=\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u53ef\u80fd\u306a\u30af\u30e9\u30b9 {1} \u5411\u3051\u306e\u30ab\u30b9\u30bf\u30e0\u30a2\u30b9\u30da\u30af\u30c8 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002 +rm.admin.property-already-exists=\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u306f\u3059\u3067\u306b\u5b58\u5728\u3057\u307e\u3059\u3002 +rm.admin.cannot-apply-constraint=\u5236\u7d04 {0} \u3092\u30d7\u30ed\u30d1\u30c6\u30a3 {1}\uff08\u30c7\u30fc\u30bf\u30bf\u30a4\u30d7 {2}\uff09\u306b\u9069\u7528\u3067\u304d\u307e\u305b\u3093\u3002(expected: dataType = TEXT) +rm.admin.prop-exist=\u30ab\u30b9\u30bf\u30e0\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 +rm.admin.custom-prop-exist=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306b\u306f\u30d7\u30ed\u30d1\u30c6\u30a3 {0} \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002 +rm.admin.unknown-aspect=\u4e0d\u660e\u306a\u30a2\u30b9\u30da\u30af\u30c8 {0}\u3002 +rm.admin.constraint-exists=\u5236\u7d04 {0} \u306f\u3059\u3067\u306b\u5b58\u5728\u3057\u307e\u3059\u3002 +rm.admin.contraint-cannot-find=\u5236\u7d04\u306e\u5b9a\u7fa9 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 +rm.admin.unexpected_type_constraint=\u5236\u7d04 {1} \u306b\u5bfe\u3057\u3066\u4e88\u671f\u305b\u306c\u30bf\u30a4\u30d7 {0} \u3067\u3059\u3002{2} \u306f\u4e88\u671f\u3055\u308c\u308b\u30bf\u30a4\u30d7\u3067\u3059\u3002 +rm.admin.custom-model-not-found=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 +rm.admin.custom-model-no-content=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306b\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u3042\u308a\u307e\u305b\u3093\u3002(nodeRef={0}) +rm.admin.error-write-custom-model=\u30ab\u30b9\u30bf\u30e0\u30e2\u30c7\u30eb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002(nodeRef={0}). +rm.admin.error-client-id=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\u306f\u4f7f\u7528\u4e2d\u306e\u305f\u3081\u3001\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002(clientid={0}) rm.admin.error-split-id=\u30bb\u30d1\u30ec\u30fc\u30bf {1} \u304c\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001ID {0} \u3092\u5206\u5272\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_nl.properties index f8bad865ee..41e0b8fdf9 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_nl.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=De aanpassingsservice is niet gestart. -rm.admin.not-customisable=De klasse {0} kan niet worden aangepast. -rm.admin.invalid-custom-aspect=Het aangepaste aspect {0} voor aanpasbare klasse {1} kan niet worden gevonden. -rm.admin.property-already-exists=Eigenschap {0} bestaat al. -rm.admin.cannot-apply-constraint=Kan beperking {0} niet toepassen op eigenschap {1} met gegevenstype {2}. (verwacht: dataType = TEXT) -rm.admin.prop-exist=De aangepaste eigenschap {0} kan niet worden gevonden. -rm.admin.custom-prop-exist=Het aangepaste model bevat de eigenschap {0} niet. -rm.admin.unknown-aspect=Onbekend aspect {0}. -rm.admin.constraint-exists=De beperking {0} bestaat al. -rm.admin.contraint-cannot-find=De definitie voor beperking {0} kan niet worden gevonden. -rm.admin.unexpected_type_constraint=Onverwacht type {0} voor beperking {1}. Het verwachte type is {2}. -rm.admin.custom-model-not-found=Het aangepaste model {0} kan niet worden gevonden. -rm.admin.custom-model-no-content=Het aangepaste model heeft geen inhoud. (nodeRef={0}) -rm.admin.error-write-custom-model=Fout bij schrijven van aangepaste modelcontent. (nodeRef={0}). -rm.admin.error-client-id=Fout bij genereren van client-id omdat deze al in gebruik is. (clientid={0}) +rm.admin.service-not-init=De aanpassingsservice is niet gestart. +rm.admin.not-customisable=De klasse {0} kan niet worden aangepast. +rm.admin.invalid-custom-aspect=Het aangepaste aspect {0} voor aanpasbare klasse {1} kan niet worden gevonden. +rm.admin.property-already-exists=Eigenschap {0} bestaat al. +rm.admin.cannot-apply-constraint=Kan beperking {0} niet toepassen op eigenschap {1} met gegevenstype {2}. (verwacht: dataType = TEXT) +rm.admin.prop-exist=De aangepaste eigenschap {0} kan niet worden gevonden. +rm.admin.custom-prop-exist=Het aangepaste model bevat de eigenschap {0} niet. +rm.admin.unknown-aspect=Onbekend aspect {0}. +rm.admin.constraint-exists=De beperking {0} bestaat al. +rm.admin.contraint-cannot-find=De definitie voor beperking {0} kan niet worden gevonden. +rm.admin.unexpected_type_constraint=Onverwacht type {0} voor beperking {1}. Het verwachte type is {2}. +rm.admin.custom-model-not-found=Het aangepaste model {0} kan niet worden gevonden. +rm.admin.custom-model-no-content=Het aangepaste model heeft geen inhoud. (nodeRef={0}) +rm.admin.error-write-custom-model=Fout bij schrijven van aangepaste modelcontent. (nodeRef={0}). +rm.admin.error-client-id=Fout bij genereren van client-id omdat deze al in gebruik is. (clientid={0}) rm.admin.error-split-id=Kan id {0} niet opsplitsen omdat scheiding {1} niet aanwezig is. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_zh_CN.properties index e3262abbb7..bdd1206bf9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_zh_CN.properties @@ -1,16 +1,16 @@ -rm.admin.service-not-init=\u5c1a\u672a\u542f\u52a8\u81ea\u5b9a\u4e49\u670d\u52a1\u3002 -rm.admin.not-customisable=\u7c7b\u522b {0} \u4e0d\u53ef\u81ea\u5b9a\u4e49\u3002 -rm.admin.invalid-custom-aspect=\u65e0\u6cd5\u627e\u5230\u53ef\u81ea\u5b9a\u4e49\u7c7b\u522b {1} \u7684\u81ea\u5b9a\u4e49\u5207\u9762 {0}\u3002 -rm.admin.property-already-exists=\u5c5e\u6027 {0} \u5df2\u5b58\u5728\u3002 -rm.admin.cannot-apply-constraint=\u65e0\u6cd5\u5c06\u7ea6\u675f {0} \u5e94\u7528\u4e8e\u6570\u636e\u7c7b\u578b\u4e3a {2} \u7684\u5c5e\u6027 {1}\u3002\uff08\u9884\u671f\uff1adataType = TEXT\uff09 -rm.admin.prop-exist=\u65e0\u6cd5\u627e\u5230\u81ea\u5b9a\u4e49\u5c5e\u6027 {0}\u3002 -rm.admin.custom-prop-exist=\u81ea\u5b9a\u4e49\u6a21\u578b\u4e0d\u5305\u542b\u5c5e\u6027 {0}\u3002 -rm.admin.unknown-aspect=\u672a\u77e5\u5207\u9762 {0}\u3002 -rm.admin.constraint-exists=\u7ea6\u675f {0} \u5df2\u5b58\u5728\u3002 -rm.admin.contraint-cannot-find=\u65e0\u6cd5\u627e\u5230\u7ea6\u675f {0} \u7684\u5b9a\u4e49\u3002 -rm.admin.unexpected_type_constraint=\u7ea6\u675f {1} \u7684\u610f\u5916\u7c7b\u578b {0}\u3002\u9884\u671f\u4e3a {2}\u3002 -rm.admin.custom-model-not-found=\u65e0\u6cd5\u627e\u5230\u81ea\u5b9a\u4e49\u6a21\u578b {0}\u3002 -rm.admin.custom-model-no-content=\u81ea\u5b9a\u4e49\u6a21\u578b\u6ca1\u6709\u5185\u5bb9\u3002(nodeRef={0}) -rm.admin.error-write-custom-model=\u5199\u5165\u81ea\u5b9a\u4e49\u6a21\u578b\u5185\u5bb9\u65f6\u51fa\u9519\u3002(nodeRef={0})\u3002 -rm.admin.error-client-id=\u751f\u6210\u5ba2\u6237\u7aef ID \u65f6\u51fa\u9519\uff0c\u56e0\u4e3a\u8be5 ID \u5df2\u5728\u4f7f\u7528\u4e2d\u3002(clientid={0}) +rm.admin.service-not-init=\u5c1a\u672a\u542f\u52a8\u81ea\u5b9a\u4e49\u670d\u52a1\u3002 +rm.admin.not-customisable=\u7c7b\u522b {0} \u4e0d\u53ef\u81ea\u5b9a\u4e49\u3002 +rm.admin.invalid-custom-aspect=\u65e0\u6cd5\u627e\u5230\u53ef\u81ea\u5b9a\u4e49\u7c7b\u522b {1} \u7684\u81ea\u5b9a\u4e49\u5207\u9762 {0}\u3002 +rm.admin.property-already-exists=\u5c5e\u6027 {0} \u5df2\u5b58\u5728\u3002 +rm.admin.cannot-apply-constraint=\u65e0\u6cd5\u5c06\u7ea6\u675f {0} \u5e94\u7528\u4e8e\u6570\u636e\u7c7b\u578b\u4e3a {2} \u7684\u5c5e\u6027 {1}\u3002\uff08\u9884\u671f\uff1adataType = TEXT\uff09 +rm.admin.prop-exist=\u65e0\u6cd5\u627e\u5230\u81ea\u5b9a\u4e49\u5c5e\u6027 {0}\u3002 +rm.admin.custom-prop-exist=\u81ea\u5b9a\u4e49\u6a21\u578b\u4e0d\u5305\u542b\u5c5e\u6027 {0}\u3002 +rm.admin.unknown-aspect=\u672a\u77e5\u5207\u9762 {0}\u3002 +rm.admin.constraint-exists=\u7ea6\u675f {0} \u5df2\u5b58\u5728\u3002 +rm.admin.contraint-cannot-find=\u65e0\u6cd5\u627e\u5230\u7ea6\u675f {0} \u7684\u5b9a\u4e49\u3002 +rm.admin.unexpected_type_constraint=\u7ea6\u675f {1} \u7684\u610f\u5916\u7c7b\u578b {0}\u3002\u9884\u671f\u4e3a {2}\u3002 +rm.admin.custom-model-not-found=\u65e0\u6cd5\u627e\u5230\u81ea\u5b9a\u4e49\u6a21\u578b {0}\u3002 +rm.admin.custom-model-no-content=\u81ea\u5b9a\u4e49\u6a21\u578b\u6ca1\u6709\u5185\u5bb9\u3002(nodeRef={0}) +rm.admin.error-write-custom-model=\u5199\u5165\u81ea\u5b9a\u4e49\u6a21\u578b\u5185\u5bb9\u65f6\u51fa\u9519\u3002(nodeRef={0})\u3002 +rm.admin.error-client-id=\u751f\u6210\u5ba2\u6237\u7aef ID \u65f6\u51fa\u9519\uff0c\u56e0\u4e3a\u8be5 ID \u5df2\u5728\u4f7f\u7528\u4e2d\u3002(clientid={0}) rm.admin.error-split-id=\u65e0\u6cd5\u62c6\u5206 ID {0}\uff0c\u56e0\u4e3a\u5206\u9694\u7b26 {1} \u4e0d\u5b58\u5728\u3002 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties index 7604e39f3b..f5cd13d5a1 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=Updated Metadata -rm.audit.created-object=Created Object -rm.audit.delete-object=Delete Object -rm.audit.login-succeeded=Login Succeeded -rm.audit.login-failed=Login Failed -rm.audit.create-person=Create Person -rm.audit.linkTo=Link To -rm.audit.moveTo=Move To -rm.audit.copyTo=Copy To -rm.audit.fileTo=File To -rm.audit.audit-start=Audit Start -rm.audit.audit-stop=Audit Stop -rm.audit.audit-clear=Audit Clear -rm.audit.audit-view=Audit View -rm.audit.trail-file-fail=Can't generate audit report. -rm.audit.audit-report=Audit Report +rm.audit.updated-metadata=Updated Metadata +rm.audit.created-object=Created Object +rm.audit.delete-object=Delete Object +rm.audit.login-succeeded=Login Succeeded +rm.audit.login-failed=Login Failed +rm.audit.create-person=Create Person +rm.audit.linkTo=Link To +rm.audit.moveTo=Move To +rm.audit.copyTo=Copy To +rm.audit.fileTo=File To +rm.audit.audit-start=Audit Start +rm.audit.audit-stop=Audit Stop +rm.audit.audit-clear=Audit Clear +rm.audit.audit-view=Audit View +rm.audit.trail-file-fail=Can't generate audit report. +rm.audit.audit-report=Audit Report recordable-version-config=Auto-Declare Options \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_de.properties index 16bbceb073..9aff723c81 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_de.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=Metadaten aktualisiert -rm.audit.created-object=Objekt erstellt -rm.audit.delete-object=Objekt gel\u00f6scht -rm.audit.login-succeeded=Anmeldung erfolgreich -rm.audit.login-failed=Anmeldung fehlgeschlagen -rm.audit.create-person=Person erstellen -rm.audit.linkTo=Link zu -rm.audit.moveTo=Verschieben nach -rm.audit.copyTo=Kopieren nach -rm.audit.fileTo=Ablegen unter -rm.audit.audit-start=Audit starten -rm.audit.audit-stop=Audit stoppen -rm.audit.audit-clear=Audit l\u00f6schen -rm.audit.audit-view=Audit anzeigen -rm.audit.trail-file-fail=Audit-Bericht kann nicht erstellt werden. -rm.audit.audit-report=Audit-Bericht +rm.audit.updated-metadata=Metadaten aktualisiert +rm.audit.created-object=Objekt erstellt +rm.audit.delete-object=Objekt gel\u00f6scht +rm.audit.login-succeeded=Anmeldung erfolgreich +rm.audit.login-failed=Anmeldung fehlgeschlagen +rm.audit.create-person=Person erstellen +rm.audit.linkTo=Link zu +rm.audit.moveTo=Verschieben nach +rm.audit.copyTo=Kopieren nach +rm.audit.fileTo=Ablegen unter +rm.audit.audit-start=Audit starten +rm.audit.audit-stop=Audit stoppen +rm.audit.audit-clear=Audit l\u00f6schen +rm.audit.audit-view=Audit anzeigen +rm.audit.trail-file-fail=Audit-Bericht kann nicht erstellt werden. +rm.audit.audit-report=Audit-Bericht recordable-version-config=Optionen f\u00fcr automatische Deklaration \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_es.properties index 7a2961f53f..cd7b84ec5c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_es.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=Metadatos actualizados -rm.audit.created-object=Objeto creado -rm.audit.delete-object=Eliminar objeto -rm.audit.login-succeeded=Sesi\u00f3n iniciada correctamente -rm.audit.login-failed=Error al iniciar sesi\u00f3n -rm.audit.create-person=Crear persona -rm.audit.linkTo=Enlace a -rm.audit.moveTo=Mover a -rm.audit.copyTo=Copiar a -rm.audit.fileTo=Archivar en -rm.audit.audit-start=Iniciar auditor\u00eda -rm.audit.audit-stop=Detener auditor\u00eda -rm.audit.audit-clear=Limpiar auditor\u00eda -rm.audit.audit-view=Ver auditor\u00eda -rm.audit.trail-file-fail=No se puede generar el informe de auditor\u00eda. -rm.audit.audit-report=Informe de auditor\u00eda +rm.audit.updated-metadata=Metadatos actualizados +rm.audit.created-object=Objeto creado +rm.audit.delete-object=Eliminar objeto +rm.audit.login-succeeded=Sesi\u00f3n iniciada correctamente +rm.audit.login-failed=Error al iniciar sesi\u00f3n +rm.audit.create-person=Crear persona +rm.audit.linkTo=Enlace a +rm.audit.moveTo=Mover a +rm.audit.copyTo=Copiar a +rm.audit.fileTo=Archivar en +rm.audit.audit-start=Iniciar auditor\u00eda +rm.audit.audit-stop=Detener auditor\u00eda +rm.audit.audit-clear=Limpiar auditor\u00eda +rm.audit.audit-view=Ver auditor\u00eda +rm.audit.trail-file-fail=No se puede generar el informe de auditor\u00eda. +rm.audit.audit-report=Informe de auditor\u00eda recordable-version-config=Opciones de declaraci\u00f3n autom\u00e1tica \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_fr.properties index 0b773ba071..8d287c23a5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_fr.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=M\u00e9tadonn\u00e9es mises \u00e0 jour -rm.audit.created-object=Objet cr\u00e9\u00e9 -rm.audit.delete-object=Supprimer l'objet -rm.audit.login-succeeded=La connexion a abouti -rm.audit.login-failed=La connexion a \u00e9chou\u00e9 -rm.audit.create-person=Cr\u00e9er une personne -rm.audit.linkTo=Lier \u00e0 -rm.audit.moveTo=D\u00e9placer vers... -rm.audit.copyTo=Copier vers... -rm.audit.fileTo=Archiver dans -rm.audit.audit-start=Audit d\u00e9marr\u00e9 -rm.audit.audit-stop=Audit arr\u00eat\u00e9 -rm.audit.audit-clear=Audit supprim\u00e9 -rm.audit.audit-view=Audit affich\u00e9 -rm.audit.trail-file-fail=Impossible de g\u00e9n\u00e9rer un rapport d'audit. -rm.audit.audit-report=Rapport d'audit +rm.audit.updated-metadata=M\u00e9tadonn\u00e9es mises \u00e0 jour +rm.audit.created-object=Objet cr\u00e9\u00e9 +rm.audit.delete-object=Supprimer l'objet +rm.audit.login-succeeded=La connexion a abouti +rm.audit.login-failed=La connexion a \u00e9chou\u00e9 +rm.audit.create-person=Cr\u00e9er une personne +rm.audit.linkTo=Lier \u00e0 +rm.audit.moveTo=D\u00e9placer vers... +rm.audit.copyTo=Copier vers... +rm.audit.fileTo=Archiver dans +rm.audit.audit-start=Audit d\u00e9marr\u00e9 +rm.audit.audit-stop=Audit arr\u00eat\u00e9 +rm.audit.audit-clear=Audit supprim\u00e9 +rm.audit.audit-view=Audit affich\u00e9 +rm.audit.trail-file-fail=Impossible de g\u00e9n\u00e9rer un rapport d'audit. +rm.audit.audit-report=Rapport d'audit recordable-version-config=Options de d\u00e9claration automatique \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_it.properties index 217ec94e36..e4363c6e85 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_it.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=Metadati aggiornati -rm.audit.created-object=Oggetto creato -rm.audit.delete-object=Elimina oggetto -rm.audit.login-succeeded=Accesso riuscito -rm.audit.login-failed=Accesso non riuscito -rm.audit.create-person=Crea persona -rm.audit.linkTo=Collega a -rm.audit.moveTo=Sposta in -rm.audit.copyTo=Copia in -rm.audit.fileTo=Archivia in -rm.audit.audit-start=Avvio audit -rm.audit.audit-stop=Interruzione audit -rm.audit.audit-clear=Cancellazione audit -rm.audit.audit-view=Visualizzazione audit -rm.audit.trail-file-fail=Impossibile generare il report dell'audit -rm.audit.audit-report=Report audit +rm.audit.updated-metadata=Metadati aggiornati +rm.audit.created-object=Oggetto creato +rm.audit.delete-object=Elimina oggetto +rm.audit.login-succeeded=Accesso riuscito +rm.audit.login-failed=Accesso non riuscito +rm.audit.create-person=Crea persona +rm.audit.linkTo=Collega a +rm.audit.moveTo=Sposta in +rm.audit.copyTo=Copia in +rm.audit.fileTo=Archivia in +rm.audit.audit-start=Avvio audit +rm.audit.audit-stop=Interruzione audit +rm.audit.audit-clear=Cancellazione audit +rm.audit.audit-view=Visualizzazione audit +rm.audit.trail-file-fail=Impossibile generare il report dell'audit +rm.audit.audit-report=Report audit recordable-version-config=Opzioni di dichiarazione automatica \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_ja.properties index c4a591879a..72bcbf7bb1 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_ja.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=\u66f4\u65b0\u6e08\u307f\u30e1\u30bf\u30c7\u30fc\u30bf -rm.audit.created-object=\u4f5c\u6210\u6e08\u307f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 -rm.audit.delete-object=\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u524a\u9664 -rm.audit.login-succeeded=\u30ed\u30b0\u30a4\u30f3\u6210\u529f -rm.audit.login-failed=\u30ed\u30b0\u30a4\u30f3\u5931\u6557 -rm.audit.create-person=\u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210 -rm.audit.linkTo=\u30ea\u30f3\u30af\u5148 -rm.audit.moveTo=\u79fb\u52d5\u5148 -rm.audit.copyTo=\u30b3\u30d4\u30fc\u5148 -rm.audit.fileTo=\u6574\u7406\u4fdd\u7ba1\u5148 -rm.audit.audit-start=\u76e3\u67fb\u958b\u59cb -rm.audit.audit-stop=\u76e3\u67fb\u505c\u6b62 -rm.audit.audit-clear=\u76e3\u67fb\u6d88\u53bb -rm.audit.audit-view=\u76e3\u67fb\u8868\u793a -rm.audit.trail-file-fail=\u76e3\u67fb\u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.audit.audit-report=\u76e3\u67fb\u30ec\u30dd\u30fc\u30c8 +rm.audit.updated-metadata=\u66f4\u65b0\u6e08\u307f\u30e1\u30bf\u30c7\u30fc\u30bf +rm.audit.created-object=\u4f5c\u6210\u6e08\u307f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 +rm.audit.delete-object=\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u524a\u9664 +rm.audit.login-succeeded=\u30ed\u30b0\u30a4\u30f3\u6210\u529f +rm.audit.login-failed=\u30ed\u30b0\u30a4\u30f3\u5931\u6557 +rm.audit.create-person=\u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210 +rm.audit.linkTo=\u30ea\u30f3\u30af\u5148 +rm.audit.moveTo=\u79fb\u52d5\u5148 +rm.audit.copyTo=\u30b3\u30d4\u30fc\u5148 +rm.audit.fileTo=\u6574\u7406\u4fdd\u7ba1\u5148 +rm.audit.audit-start=\u76e3\u67fb\u958b\u59cb +rm.audit.audit-stop=\u76e3\u67fb\u505c\u6b62 +rm.audit.audit-clear=\u76e3\u67fb\u6d88\u53bb +rm.audit.audit-view=\u76e3\u67fb\u8868\u793a +rm.audit.trail-file-fail=\u76e3\u67fb\u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.audit.audit-report=\u76e3\u67fb\u30ec\u30dd\u30fc\u30c8 recordable-version-config=\u81ea\u52d5\u5ba3\u8a00\u30aa\u30d7\u30b7\u30e7\u30f3 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_nl.properties index 9c746e6266..1bd71e3997 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_nl.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=Bijgewerkte metagegevens -rm.audit.created-object=Object gemaakt -rm.audit.delete-object=Object verwijderen -rm.audit.login-succeeded=Aanmelden gelukt -rm.audit.login-failed=Aanmelden mislukt -rm.audit.create-person=Persoon maken -rm.audit.linkTo=Koppelen naar -rm.audit.moveTo=Verplaatsen naar -rm.audit.copyTo=Kopi\u00ebren naar -rm.audit.fileTo=Archiveren in -rm.audit.audit-start=Audit starten -rm.audit.audit-stop=Audit stoppen -rm.audit.audit-clear=Audit wissen -rm.audit.audit-view=Audit bekijken -rm.audit.trail-file-fail=Kan geen auditrapport maken. -rm.audit.audit-report=Auditrapport +rm.audit.updated-metadata=Bijgewerkte metagegevens +rm.audit.created-object=Object gemaakt +rm.audit.delete-object=Object verwijderen +rm.audit.login-succeeded=Aanmelden gelukt +rm.audit.login-failed=Aanmelden mislukt +rm.audit.create-person=Persoon maken +rm.audit.linkTo=Koppelen naar +rm.audit.moveTo=Verplaatsen naar +rm.audit.copyTo=Kopi\u00ebren naar +rm.audit.fileTo=Archiveren in +rm.audit.audit-start=Audit starten +rm.audit.audit-stop=Audit stoppen +rm.audit.audit-clear=Audit wissen +rm.audit.audit-view=Audit bekijken +rm.audit.trail-file-fail=Kan geen auditrapport maken. +rm.audit.audit-report=Auditrapport recordable-version-config=Opties voor automatisch declareren \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_zh_CN.properties index 871f195dcf..75c1f59a94 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/audit-service_zh_CN.properties @@ -1,17 +1,17 @@ -rm.audit.updated-metadata=\u66f4\u65b0\u7684\u5143\u6570\u636e -rm.audit.created-object=\u521b\u5efa\u7684\u5bf9\u8c61 -rm.audit.delete-object=\u5220\u9664\u5bf9\u8c61 -rm.audit.login-succeeded=\u767b\u5f55\u6210\u529f -rm.audit.login-failed=\u767b\u5f55\u5931\u8d25 -rm.audit.create-person=\u521b\u5efa\u4eba\u5458 -rm.audit.linkTo=\u94fe\u63a5\u5230 -rm.audit.moveTo=\u79fb\u52a8\u5230 -rm.audit.copyTo=\u590d\u5236\u5230 -rm.audit.fileTo=\u7acb\u5377\u81f3 -rm.audit.audit-start=\u5f00\u59cb\u5ba1\u8ba1 -rm.audit.audit-stop=\u505c\u6b62\u5ba1\u8ba1 -rm.audit.audit-clear=\u6e05\u9664\u5ba1\u8ba1 -rm.audit.audit-view=\u67e5\u770b\u5ba1\u8ba1 -rm.audit.trail-file-fail=\u65e0\u6cd5\u751f\u6210\u5ba1\u8ba1\u62a5\u544a\u3002 -rm.audit.audit-report=\u5ba1\u8ba1\u62a5\u544a +rm.audit.updated-metadata=\u66f4\u65b0\u7684\u5143\u6570\u636e +rm.audit.created-object=\u521b\u5efa\u7684\u5bf9\u8c61 +rm.audit.delete-object=\u5220\u9664\u5bf9\u8c61 +rm.audit.login-succeeded=\u767b\u5f55\u6210\u529f +rm.audit.login-failed=\u767b\u5f55\u5931\u8d25 +rm.audit.create-person=\u521b\u5efa\u4eba\u5458 +rm.audit.linkTo=\u94fe\u63a5\u5230 +rm.audit.moveTo=\u79fb\u52a8\u5230 +rm.audit.copyTo=\u590d\u5236\u5230 +rm.audit.fileTo=\u7acb\u5377\u81f3 +rm.audit.audit-start=\u5f00\u59cb\u5ba1\u8ba1 +rm.audit.audit-stop=\u505c\u6b62\u5ba1\u8ba1 +rm.audit.audit-clear=\u6e05\u9664\u5ba1\u8ba1 +rm.audit.audit-view=\u67e5\u770b\u5ba1\u8ba1 +rm.audit.trail-file-fail=\u65e0\u6cd5\u751f\u6210\u5ba1\u8ba1\u62a5\u544a\u3002 +rm.audit.audit-report=\u5ba1\u8ba1\u62a5\u544a recordable-version-config=\u81ea\u52a8\u58f0\u660e\u9009\u9879 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties index 6ad06364f6..58474a91ba 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Records -capability.DeclareRecords.title=Complete Records -capability.ViewRecords.title=View Records -capability.UndeclareRecords.title=Reopen Records -capability.CreateRecords.title=Create Records -capability.RequestRecordInformation.title=Request Record Information -capability.RejectRecords.title=Reject Records -capability.FileUnfiledRecords.title=File Unfiled Records -capability.LinkToRecords.title=Link Records -capability.DeleteLinks.title=Unlink Records - -# Metadata Control -capability.group.metadataControl.title=Metadata Control -capability.EditRecordMetadata.title=Edit Record Metadata -capability.EditDeclaredRecordMetadata.title=Edit Completed Record Metadata -capability.EditNonRecordMetadata.title=Edit Non Record Metadata -capability.MoveRecords.title=Move Records - -# Folder Control -capability.group.folderControl.title=Folder Control -capability.CreateModifyDestroyFolders.title=Create Modify Destroy Folders -capability.CloseFolders.title=Close Folders -capability.ReOpenFolders.title=Re-Open Folders -capability.DeclareRecordsInClosedFolders.title=Complete Records in Closed Folders - -# Vital Records -capability.group.vitalRecords.title=Vital Records -capability.UpdateVitalRecordCycleInformation.title=Update Vital Record Cycle Information -capability.CycleVitalRecords.title=Cycle Vital Records -capability.PlanningReviewCycles.title=Planning Review Cycles - -# References and Links -capability.group.references.title=References -capability.ChangeOrDeleteReferences.title=Change or Delete References - -# Events -capability.group.events.title=Events -capability.CreateModifyDestroyEvents.title=Create Modify Destroy Events -capability.AddModifyEventDates.title=Add Modify Event Dates - -# Cutoff -capability.group.cutoff.title=Cut Off -capability.ApproveRecordsScheduledForCutoff.title=Approve Records Scheduled for Cut Off -capability.CreateModifyRecordsInCutoffFolders.title=Create Modify Records in Cut Off Folders - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Disposition and Transfers -capability.UpdateTriggerDates.title=Update Trigger Dates -capability.ManuallyChangeDispositionDates.title=Manually Change Disposition Dates -capability.AuthorizeNominatedTransfers.title=Authorize Nominated Transfers -capability.AuthorizeAllTransfers.title=Authorize All Transfers -capability.DestroyRecordsScheduledForDestruction.title=Destroy Record or Record Folder Scheduled for Destruction -capability.DestroyRecords.title=Destroy Records -capability.DeleteRecords.title=Delete Records -capability.TriggerAnEvent.title=Trigger An Event -capability.FileDestructionReport.title=File Destruction Report -capability.FileTransferReport.title=File Transfer Report -capability.EndRetention.title=End Retention - -# Hold Controls -capability.group.holdControls.title=Hold Controls -capability.ExtendRetentionPeriodOrFreeze.title=Extend Retention Period or Freeze -capability.Unfreeze.title=Unfreeze -capability.ViewUpdateReasonsForFreeze.title=View Update Reasons for Freeze -capability.CreateHold.title=Create Hold -capability.AddToHold.title=Add to Hold -capability.RemoveFromHold.title=Remove from Hold -capability.FileHoldReport.title=File Hold Report -capability.DeleteHold.title=Delete Hold -capability.EditHold.title=Edit Hold - -# Audit -capability.group.audit.title=Audit -capability.DeclareAuditAsRecord.title=Declare Audit as Record -capability.EnableDisableAuditByTypes.title=Enable Disable Audit by Types -capability.DeleteAudit.title=Delete Audit -capability.SelectAuditMetadata.title=Select Audit Metadata -capability.AccessAudit.title=Access Audit -capability.ExportAudit.title=Export Audit - -# Security -capability.group.security.title=Security -capability.CreateModifyDestroyRoles.title=Create Modify Destroy Roles -capability.CreateModifyDestroyUsersAndGroups.title=Create Modify Destroy Users and Groups -capability.PasswordControl.title=Password Control -capability.DisplayRightsReport.title=Display Rights Report -capability.ManageAccessControls.title=Group and User Role Assignment -capability.ManageAccessRights.title=Manage Permissions - -# Configuration -capability.group.config.title=Configuration -capability.CreateModifyDestroyFileplanMetadata.title=Create Modify Destroy File Plan Metadata -capability.CreateModifyDestroyFileplanTypes.title=Create Modify Destroy File Plan Types -capability.CreateModifyDestroyRecordTypes.title=Create Modify Destroy Record Types -capability.CreateAndAssociateSelectionLists.title=Create and Associate Selection Lists -capability.EditSelectionLists.title=Edit Selection Lists -capability.CreateModifyDestroyReferenceTypes.title=Create Modify Destroy Reference Types -capability.AttachRulesToMetadataProperties.title=Attach Rules to Metadata Properties -capability.MakeOptionalParametersMandatory.title=Make Optional Parameters Mandatory -capability.MapEmailMetadata.title=Map Email Metadata - -# Rules -capability.group.rules.title=Rules +# Records +capability.group.records.title=Records +capability.DeclareRecords.title=Complete Records +capability.ViewRecords.title=View Records +capability.UndeclareRecords.title=Reopen Records +capability.CreateRecords.title=Create Records +capability.RequestRecordInformation.title=Request Record Information +capability.RejectRecords.title=Reject Records +capability.FileUnfiledRecords.title=File Unfiled Records +capability.LinkToRecords.title=Link Records +capability.DeleteLinks.title=Unlink Records + +# Metadata Control +capability.group.metadataControl.title=Metadata Control +capability.EditRecordMetadata.title=Edit Record Metadata +capability.EditDeclaredRecordMetadata.title=Edit Completed Record Metadata +capability.EditNonRecordMetadata.title=Edit Non Record Metadata +capability.MoveRecords.title=Move Records + +# Folder Control +capability.group.folderControl.title=Folder Control +capability.CreateModifyDestroyFolders.title=Create Modify Destroy Folders +capability.CloseFolders.title=Close Folders +capability.ReOpenFolders.title=Re-Open Folders +capability.DeclareRecordsInClosedFolders.title=Complete Records in Closed Folders + +# Vital Records +capability.group.vitalRecords.title=Vital Records +capability.UpdateVitalRecordCycleInformation.title=Update Vital Record Cycle Information +capability.CycleVitalRecords.title=Cycle Vital Records +capability.PlanningReviewCycles.title=Planning Review Cycles + +# References and Links +capability.group.references.title=References +capability.ChangeOrDeleteReferences.title=Change or Delete References + +# Events +capability.group.events.title=Events +capability.CreateModifyDestroyEvents.title=Create Modify Destroy Events +capability.AddModifyEventDates.title=Add Modify Event Dates + +# Cutoff +capability.group.cutoff.title=Cut Off +capability.ApproveRecordsScheduledForCutoff.title=Approve Records Scheduled for Cut Off +capability.CreateModifyRecordsInCutoffFolders.title=Create Modify Records in Cut Off Folders + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Disposition and Transfers +capability.UpdateTriggerDates.title=Update Trigger Dates +capability.ManuallyChangeDispositionDates.title=Manually Change Disposition Dates +capability.AuthorizeNominatedTransfers.title=Authorize Nominated Transfers +capability.AuthorizeAllTransfers.title=Authorize All Transfers +capability.DestroyRecordsScheduledForDestruction.title=Destroy Record or Record Folder Scheduled for Destruction +capability.DestroyRecords.title=Destroy Records +capability.DeleteRecords.title=Delete Records +capability.TriggerAnEvent.title=Trigger An Event +capability.FileDestructionReport.title=File Destruction Report +capability.FileTransferReport.title=File Transfer Report +capability.EndRetention.title=End Retention + +# Hold Controls +capability.group.holdControls.title=Hold Controls +capability.ExtendRetentionPeriodOrFreeze.title=Extend Retention Period or Freeze +capability.Unfreeze.title=Unfreeze +capability.ViewUpdateReasonsForFreeze.title=View Update Reasons for Freeze +capability.CreateHold.title=Create Hold +capability.AddToHold.title=Add to Hold +capability.RemoveFromHold.title=Remove from Hold +capability.FileHoldReport.title=File Hold Report +capability.DeleteHold.title=Delete Hold +capability.EditHold.title=Edit Hold + +# Audit +capability.group.audit.title=Audit +capability.DeclareAuditAsRecord.title=Declare Audit as Record +capability.EnableDisableAuditByTypes.title=Enable Disable Audit by Types +capability.DeleteAudit.title=Delete Audit +capability.SelectAuditMetadata.title=Select Audit Metadata +capability.AccessAudit.title=Access Audit +capability.ExportAudit.title=Export Audit + +# Security +capability.group.security.title=Security +capability.CreateModifyDestroyRoles.title=Create Modify Destroy Roles +capability.CreateModifyDestroyUsersAndGroups.title=Create Modify Destroy Users and Groups +capability.PasswordControl.title=Password Control +capability.DisplayRightsReport.title=Display Rights Report +capability.ManageAccessControls.title=Group and User Role Assignment +capability.ManageAccessRights.title=Manage Permissions + +# Configuration +capability.group.config.title=Configuration +capability.CreateModifyDestroyFileplanMetadata.title=Create Modify Destroy File Plan Metadata +capability.CreateModifyDestroyFileplanTypes.title=Create Modify Destroy File Plan Types +capability.CreateModifyDestroyRecordTypes.title=Create Modify Destroy Record Types +capability.CreateAndAssociateSelectionLists.title=Create and Associate Selection Lists +capability.EditSelectionLists.title=Edit Selection Lists +capability.CreateModifyDestroyReferenceTypes.title=Create Modify Destroy Reference Types +capability.AttachRulesToMetadataProperties.title=Attach Rules to Metadata Properties +capability.MakeOptionalParametersMandatory.title=Make Optional Parameters Mandatory +capability.MapEmailMetadata.title=Map Email Metadata + +# Rules +capability.group.rules.title=Rules capability.ManageRules.title=Manage Rules \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_de.properties index 10ba7fe0a7..aee1ce5ba2 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_de.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Records -capability.DeclareRecords.title=Records abschlie\u00dfen -capability.ViewRecords.title=Records anzeigen -capability.UndeclareRecords.title=Records erneut \u00f6ffnen -capability.CreateRecords.title=Records erstellen -capability.RequestRecordInformation.title=Record-Informationen anfordern -capability.RejectRecords.title=Records ablehnen -capability.FileUnfiledRecords.title=Nicht abgelegte Records ablegen -capability.LinkToRecords.title=Records verkn\u00fcpfen -capability.DeleteLinks.title=Verkn\u00fcpfung zu Records aufheben - -# Metadata Control -capability.group.metadataControl.title=Metadaten-Steuerung -capability.EditRecordMetadata.title=Record-Metadaten bearbeiten -capability.EditDeclaredRecordMetadata.title=Metadaten von abgeschlossenem Record bearbeiten -capability.EditNonRecordMetadata.title=Record-fremde Metadaten bearbeiten -capability.MoveRecords.title=Records verschieben - -# Folder Control -capability.group.folderControl.title=Ordnersteuerung -capability.CreateModifyDestroyFolders.title=Ordner erstellen/\u00e4ndern/vernichten -capability.CloseFolders.title=Ordner schlie\u00dfen -capability.ReOpenFolders.title=Ordner erneut \u00f6ffnen -capability.DeclareRecordsInClosedFolders.title=Records in geschlossenen Ordnern abschlie\u00dfen - -# Vital Records -capability.group.vitalRecords.title=Besonders relevante Records -capability.UpdateVitalRecordCycleInformation.title=Zyklusinformationen besonders relevanter Records aktualisieren -capability.CycleVitalRecords.title=Zyklus besonders relevanter Records -capability.PlanningReviewCycles.title=\u00dcberpr\u00fcfungszyklen planen - -# References and Links -capability.group.references.title=Referenzen -capability.ChangeOrDeleteReferences.title=Referenzen \u00e4ndern oder l\u00f6schen - -# Events -capability.group.events.title=Ereignisse -capability.CreateModifyDestroyEvents.title=Ereignisse erstellen/\u00e4ndern/vernichten -capability.AddModifyEventDates.title=Ereignisdaten hinzuf\u00fcgen/\u00e4ndern - -# Cutoff -capability.group.cutoff.title=Trennen -capability.ApproveRecordsScheduledForCutoff.title=F\u00fcr Trennung geplante Records genehmigen -capability.CreateModifyRecordsInCutoffFolders.title=Records in getrennten Ordnern erstellen/\u00e4ndern - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Entsorgung und \u00dcbertragungen -capability.UpdateTriggerDates.title=Triggerdaten aktualisieren -capability.ManuallyChangeDispositionDates.title=Entsorgungsdaten manuell \u00e4ndern -capability.AuthorizeNominatedTransfers.title=Nominierte \u00dcbertragungen autorisieren -capability.AuthorizeAllTransfers.title=Alle \u00dcbertragungen autorisieren -capability.DestroyRecordsScheduledForDestruction.title=Zur Vernichtung vorgesehenen Record oder Record-Ordner vernichten -capability.DestroyRecords.title=Records vernichten -capability.DeleteRecords.title=Records l\u00f6schen -capability.TriggerAnEvent.title=Ereignis ausl\u00f6sen -capability.FileDestructionReport.title=Vernichtungsprotokoll ablegen -capability.FileTransferReport.title=\u00dcbertragungsbericht ablegen -capability.EndRetention.title=Aufbewahrung beenden - -# Hold Controls -capability.group.holdControls.title=Sperrsteuerung -capability.ExtendRetentionPeriodOrFreeze.title=Aufbewahrungsfrist verl\u00e4ngern oder fixieren -capability.Unfreeze.title=Fixierung aufheben -capability.ViewUpdateReasonsForFreeze.title=Aktualisierungsgrund f\u00fcr Fixierung anzeigen -capability.CreateHold.title=Sperrbereich erstellen -capability.AddToHold.title=Zum Sperrbereich hinzuf\u00fcgen -capability.RemoveFromHold.title=Vom Sperrbereich entfernen -capability.FileHoldReport.title=Sperrbericht ablegen -capability.DeleteHold.title=Sperrbereich l\u00f6schen -capability.EditHold.title=Sperrbereich bearbeiten - -# Audit -capability.group.audit.title=Audit -capability.DeclareAuditAsRecord.title=Audit als Record deklarieren -capability.EnableDisableAuditByTypes.title=Audit nach Typen aktivieren/deaktivieren -capability.DeleteAudit.title=Audit l\u00f6schen -capability.SelectAuditMetadata.title=Audit-Metadaten ausw\u00e4hlen -capability.AccessAudit.title=Auf Audit zugreifen -capability.ExportAudit.title=Audit exportieren - -# Security -capability.group.security.title=Sicherheit -capability.CreateModifyDestroyRoles.title=Rollen erstellen/\u00e4ndern/vernichten -capability.CreateModifyDestroyUsersAndGroups.title=Benutzer und Gruppen erstellen/\u00e4ndern/vernichten -capability.PasswordControl.title=Passwortsteuerung -capability.DisplayRightsReport.title=Rechtebericht anzeigen -capability.ManageAccessControls.title=Zuweisung von Gruppen- und Benutzerrollen -capability.ManageAccessRights.title=Berechtigungen verwalten - -# Configuration -capability.group.config.title=Konfiguration -capability.CreateModifyDestroyFileplanMetadata.title=Ablageplan-Metadaten erstellen/\u00e4ndern/vernichten -capability.CreateModifyDestroyFileplanTypes.title=Ablageplan-Typen erstellen/\u00e4ndern/vernichten -capability.CreateModifyDestroyRecordTypes.title=Record-Typen erstellen/\u00e4ndern/vernichten -capability.CreateAndAssociateSelectionLists.title=Auswahllisten erstellen und zuordnen -capability.EditSelectionLists.title=Auswahllisten bearbeiten -capability.CreateModifyDestroyReferenceTypes.title=Referenztypen erstellen/\u00e4ndern/vernichten -capability.AttachRulesToMetadataProperties.title=Regeln an Metadaten-Eigenschaften anh\u00e4ngen -capability.MakeOptionalParametersMandatory.title=Optionale Parameter als erforderlich festlegen -capability.MapEmailMetadata.title=E-Mail-Metadaten zuordnen - -# Rules -capability.group.rules.title=Regeln +# Records +capability.group.records.title=Records +capability.DeclareRecords.title=Records abschlie\u00dfen +capability.ViewRecords.title=Records anzeigen +capability.UndeclareRecords.title=Records erneut \u00f6ffnen +capability.CreateRecords.title=Records erstellen +capability.RequestRecordInformation.title=Record-Informationen anfordern +capability.RejectRecords.title=Records ablehnen +capability.FileUnfiledRecords.title=Nicht abgelegte Records ablegen +capability.LinkToRecords.title=Records verkn\u00fcpfen +capability.DeleteLinks.title=Verkn\u00fcpfung zu Records aufheben + +# Metadata Control +capability.group.metadataControl.title=Metadaten-Steuerung +capability.EditRecordMetadata.title=Record-Metadaten bearbeiten +capability.EditDeclaredRecordMetadata.title=Metadaten von abgeschlossenem Record bearbeiten +capability.EditNonRecordMetadata.title=Record-fremde Metadaten bearbeiten +capability.MoveRecords.title=Records verschieben + +# Folder Control +capability.group.folderControl.title=Ordnersteuerung +capability.CreateModifyDestroyFolders.title=Ordner erstellen/\u00e4ndern/vernichten +capability.CloseFolders.title=Ordner schlie\u00dfen +capability.ReOpenFolders.title=Ordner erneut \u00f6ffnen +capability.DeclareRecordsInClosedFolders.title=Records in geschlossenen Ordnern abschlie\u00dfen + +# Vital Records +capability.group.vitalRecords.title=Besonders relevante Records +capability.UpdateVitalRecordCycleInformation.title=Zyklusinformationen besonders relevanter Records aktualisieren +capability.CycleVitalRecords.title=Zyklus besonders relevanter Records +capability.PlanningReviewCycles.title=\u00dcberpr\u00fcfungszyklen planen + +# References and Links +capability.group.references.title=Referenzen +capability.ChangeOrDeleteReferences.title=Referenzen \u00e4ndern oder l\u00f6schen + +# Events +capability.group.events.title=Ereignisse +capability.CreateModifyDestroyEvents.title=Ereignisse erstellen/\u00e4ndern/vernichten +capability.AddModifyEventDates.title=Ereignisdaten hinzuf\u00fcgen/\u00e4ndern + +# Cutoff +capability.group.cutoff.title=Trennen +capability.ApproveRecordsScheduledForCutoff.title=F\u00fcr Trennung geplante Records genehmigen +capability.CreateModifyRecordsInCutoffFolders.title=Records in getrennten Ordnern erstellen/\u00e4ndern + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Entsorgung und \u00dcbertragungen +capability.UpdateTriggerDates.title=Triggerdaten aktualisieren +capability.ManuallyChangeDispositionDates.title=Entsorgungsdaten manuell \u00e4ndern +capability.AuthorizeNominatedTransfers.title=Nominierte \u00dcbertragungen autorisieren +capability.AuthorizeAllTransfers.title=Alle \u00dcbertragungen autorisieren +capability.DestroyRecordsScheduledForDestruction.title=Zur Vernichtung vorgesehenen Record oder Record-Ordner vernichten +capability.DestroyRecords.title=Records vernichten +capability.DeleteRecords.title=Records l\u00f6schen +capability.TriggerAnEvent.title=Ereignis ausl\u00f6sen +capability.FileDestructionReport.title=Vernichtungsprotokoll ablegen +capability.FileTransferReport.title=\u00dcbertragungsbericht ablegen +capability.EndRetention.title=Aufbewahrung beenden + +# Hold Controls +capability.group.holdControls.title=Sperrsteuerung +capability.ExtendRetentionPeriodOrFreeze.title=Aufbewahrungsfrist verl\u00e4ngern oder fixieren +capability.Unfreeze.title=Fixierung aufheben +capability.ViewUpdateReasonsForFreeze.title=Aktualisierungsgrund f\u00fcr Fixierung anzeigen +capability.CreateHold.title=Sperrbereich erstellen +capability.AddToHold.title=Zum Sperrbereich hinzuf\u00fcgen +capability.RemoveFromHold.title=Vom Sperrbereich entfernen +capability.FileHoldReport.title=Sperrbericht ablegen +capability.DeleteHold.title=Sperrbereich l\u00f6schen +capability.EditHold.title=Sperrbereich bearbeiten + +# Audit +capability.group.audit.title=Audit +capability.DeclareAuditAsRecord.title=Audit als Record deklarieren +capability.EnableDisableAuditByTypes.title=Audit nach Typen aktivieren/deaktivieren +capability.DeleteAudit.title=Audit l\u00f6schen +capability.SelectAuditMetadata.title=Audit-Metadaten ausw\u00e4hlen +capability.AccessAudit.title=Auf Audit zugreifen +capability.ExportAudit.title=Audit exportieren + +# Security +capability.group.security.title=Sicherheit +capability.CreateModifyDestroyRoles.title=Rollen erstellen/\u00e4ndern/vernichten +capability.CreateModifyDestroyUsersAndGroups.title=Benutzer und Gruppen erstellen/\u00e4ndern/vernichten +capability.PasswordControl.title=Passwortsteuerung +capability.DisplayRightsReport.title=Rechtebericht anzeigen +capability.ManageAccessControls.title=Zuweisung von Gruppen- und Benutzerrollen +capability.ManageAccessRights.title=Berechtigungen verwalten + +# Configuration +capability.group.config.title=Konfiguration +capability.CreateModifyDestroyFileplanMetadata.title=Ablageplan-Metadaten erstellen/\u00e4ndern/vernichten +capability.CreateModifyDestroyFileplanTypes.title=Ablageplan-Typen erstellen/\u00e4ndern/vernichten +capability.CreateModifyDestroyRecordTypes.title=Record-Typen erstellen/\u00e4ndern/vernichten +capability.CreateAndAssociateSelectionLists.title=Auswahllisten erstellen und zuordnen +capability.EditSelectionLists.title=Auswahllisten bearbeiten +capability.CreateModifyDestroyReferenceTypes.title=Referenztypen erstellen/\u00e4ndern/vernichten +capability.AttachRulesToMetadataProperties.title=Regeln an Metadaten-Eigenschaften anh\u00e4ngen +capability.MakeOptionalParametersMandatory.title=Optionale Parameter als erforderlich festlegen +capability.MapEmailMetadata.title=E-Mail-Metadaten zuordnen + +# Rules +capability.group.rules.title=Regeln capability.ManageRules.title=Regeln verwalten \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_es.properties index 697490e3fa..5ac196f77b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_es.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Documentos de archivo -capability.DeclareRecords.title=Documentos de archivo completo -capability.ViewRecords.title=Ver documentos de archivo -capability.UndeclareRecords.title=Reabrir documentos de archivo -capability.CreateRecords.title=Crear documentos de archivo -capability.RequestRecordInformation.title=Solicitar informaci\u00f3n sobre documento de archivo -capability.RejectRecords.title=Rechazar documentos de archivo -capability.FileUnfiledRecords.title=Archivar documentos de archivo no archivados -capability.LinkToRecords.title=Enlazar documentos de archivo -capability.DeleteLinks.title=Desvincular documentos de archivo - -# Metadata Control -capability.group.metadataControl.title=Control de metadatos -capability.EditRecordMetadata.title=Editar metadatos de documento de archivo -capability.EditDeclaredRecordMetadata.title=Editar metadatos de documento de archivo completados -capability.EditNonRecordMetadata.title=Editar metadatos que no son de documentos de archivo -capability.MoveRecords.title=Mover documentos de archivo - -# Folder Control -capability.group.folderControl.title=Control de carpetas -capability.CreateModifyDestroyFolders.title=Crear Modificar Destruir carpetas -capability.CloseFolders.title=Cerrar carpetas -capability.ReOpenFolders.title=Reabrir carpetas -capability.DeclareRecordsInClosedFolders.title=Completar documentos de archivo en carpetas cerradas - -# Vital Records -capability.group.vitalRecords.title=Documentos de archivo vitales -capability.UpdateVitalRecordCycleInformation.title=Actualizar informaci\u00f3n de ciclo de documentos de archivo vitales -capability.CycleVitalRecords.title=Documentos de archivo vitales de ciclo -capability.PlanningReviewCycles.title=Planificaci\u00f3n de ciclos de revisi\u00f3n - -# References and Links -capability.group.references.title=Referencias -capability.ChangeOrDeleteReferences.title=Cambiar o eliminar referencias - -# Events -capability.group.events.title=Eventos -capability.CreateModifyDestroyEvents.title=Crear Modificar Destruir eventos -capability.AddModifyEventDates.title=Agregar o modificar fechas de ventos - -# Cutoff -capability.group.cutoff.title=Interrumpir -capability.ApproveRecordsScheduledForCutoff.title=Aprobar documentos de archivo planificados para interrupci\u00f3n -capability.CreateModifyRecordsInCutoffFolders.title=Crear o modificar documentos de archivo en carpetas de interrupci\u00f3n - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Disposici\u00f3n y transferencias -capability.UpdateTriggerDates.title=Actualizar fechas de ejecuci\u00f3n -capability.ManuallyChangeDispositionDates.title=Cambiar manualmente fechas de disposici\u00f3n -capability.AuthorizeNominatedTransfers.title=Autorizar transferencias nominadas -capability.AuthorizeAllTransfers.title=Autorizar todas las transferencias -capability.DestroyRecordsScheduledForDestruction.title=Destruir documento de archivo o carpeta de documentos de archivo planificada para destrucci\u00f3n -capability.DestroyRecords.title=Destruir documentos de archivo -capability.DeleteRecords.title=Eliminar documentos de archivo -capability.TriggerAnEvent.title=Ejecutar un evento -capability.FileDestructionReport.title=Archivar informe de destrucci\u00f3n -capability.FileTransferReport.title=Archivar informe de transferencia -capability.EndRetention.title=Terminar retenci\u00f3n - -# Hold Controls -capability.group.holdControls.title=Bloquear controles -capability.ExtendRetentionPeriodOrFreeze.title=Extender periodo de retenci\u00f3n o congelar -capability.Unfreeze.title=Descongelar -capability.ViewUpdateReasonsForFreeze.title=Ver razones actualizadas de congelaci\u00f3n -capability.CreateHold.title=Crear bloqueo -capability.AddToHold.title=A\u00f1adir a bloqueo -capability.RemoveFromHold.title=Eliminar de bloqueo -capability.FileHoldReport.title=Archivar informe de bloqueo -capability.DeleteHold.title=Eliminar bloqueo -capability.EditHold.title=Editar bloqueo - -# Audit -capability.group.audit.title=Auditor\u00eda -capability.DeclareAuditAsRecord.title=Declarar auditor\u00eda como documento de archivo -capability.EnableDisableAuditByTypes.title=Activar o desactivar auditor\u00eda por tipos -capability.DeleteAudit.title=Eliminar auditor\u00eda -capability.SelectAuditMetadata.title=Seleccionar metadatos de auditor\u00eda -capability.AccessAudit.title=Acceder a auditor\u00eda -capability.ExportAudit.title=Exportar auditor\u00eda - -# Security -capability.group.security.title=Seguridad -capability.CreateModifyDestroyRoles.title=Crear Modificar Destruir roles -capability.CreateModifyDestroyUsersAndGroups.title=Crear Modificar Destruir usuarios y grupos -capability.PasswordControl.title=Control de contrase\u00f1a -capability.DisplayRightsReport.title=Informe de derechos de presentaci\u00f3n -capability.ManageAccessControls.title=Asignaci\u00f3n de rol de usuario y grupo -capability.ManageAccessRights.title=Administrar permisos - -# Configuration -capability.group.config.title=Configuraci\u00f3n -capability.CreateModifyDestroyFileplanMetadata.title=Crear Modificar Destruir metadatos de plan de ficheros -capability.CreateModifyDestroyFileplanTypes.title=Crear Modificar Destruir tipos de plan de ficheros -capability.CreateModifyDestroyRecordTypes.title=Crear Modificar Destruir tipos de documento de archivo -capability.CreateAndAssociateSelectionLists.title=Crear y asociar listas de selecci\u00f3n -capability.EditSelectionLists.title=Editar listas de selecci\u00f3n -capability.CreateModifyDestroyReferenceTypes.title=Crear Modificar Destruir tipos de referencia -capability.AttachRulesToMetadataProperties.title=Vincular reglas a las propiedades de metadatos -capability.MakeOptionalParametersMandatory.title=Establecer como obligatorios los par\u00e1metros opcionales -capability.MapEmailMetadata.title=Asignar metadatos de correo electr\u00f3nico - -# Rules -capability.group.rules.title=Reglas +# Records +capability.group.records.title=Documentos de archivo +capability.DeclareRecords.title=Documentos de archivo completo +capability.ViewRecords.title=Ver documentos de archivo +capability.UndeclareRecords.title=Reabrir documentos de archivo +capability.CreateRecords.title=Crear documentos de archivo +capability.RequestRecordInformation.title=Solicitar informaci\u00f3n sobre documento de archivo +capability.RejectRecords.title=Rechazar documentos de archivo +capability.FileUnfiledRecords.title=Archivar documentos de archivo no archivados +capability.LinkToRecords.title=Enlazar documentos de archivo +capability.DeleteLinks.title=Desvincular documentos de archivo + +# Metadata Control +capability.group.metadataControl.title=Control de metadatos +capability.EditRecordMetadata.title=Editar metadatos de documento de archivo +capability.EditDeclaredRecordMetadata.title=Editar metadatos de documento de archivo completados +capability.EditNonRecordMetadata.title=Editar metadatos que no son de documentos de archivo +capability.MoveRecords.title=Mover documentos de archivo + +# Folder Control +capability.group.folderControl.title=Control de carpetas +capability.CreateModifyDestroyFolders.title=Crear Modificar Destruir carpetas +capability.CloseFolders.title=Cerrar carpetas +capability.ReOpenFolders.title=Reabrir carpetas +capability.DeclareRecordsInClosedFolders.title=Completar documentos de archivo en carpetas cerradas + +# Vital Records +capability.group.vitalRecords.title=Documentos de archivo vitales +capability.UpdateVitalRecordCycleInformation.title=Actualizar informaci\u00f3n de ciclo de documentos de archivo vitales +capability.CycleVitalRecords.title=Documentos de archivo vitales de ciclo +capability.PlanningReviewCycles.title=Planificaci\u00f3n de ciclos de revisi\u00f3n + +# References and Links +capability.group.references.title=Referencias +capability.ChangeOrDeleteReferences.title=Cambiar o eliminar referencias + +# Events +capability.group.events.title=Eventos +capability.CreateModifyDestroyEvents.title=Crear Modificar Destruir eventos +capability.AddModifyEventDates.title=Agregar o modificar fechas de ventos + +# Cutoff +capability.group.cutoff.title=Interrumpir +capability.ApproveRecordsScheduledForCutoff.title=Aprobar documentos de archivo planificados para interrupci\u00f3n +capability.CreateModifyRecordsInCutoffFolders.title=Crear o modificar documentos de archivo en carpetas de interrupci\u00f3n + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Disposici\u00f3n y transferencias +capability.UpdateTriggerDates.title=Actualizar fechas de ejecuci\u00f3n +capability.ManuallyChangeDispositionDates.title=Cambiar manualmente fechas de disposici\u00f3n +capability.AuthorizeNominatedTransfers.title=Autorizar transferencias nominadas +capability.AuthorizeAllTransfers.title=Autorizar todas las transferencias +capability.DestroyRecordsScheduledForDestruction.title=Destruir documento de archivo o carpeta de documentos de archivo planificada para destrucci\u00f3n +capability.DestroyRecords.title=Destruir documentos de archivo +capability.DeleteRecords.title=Eliminar documentos de archivo +capability.TriggerAnEvent.title=Ejecutar un evento +capability.FileDestructionReport.title=Archivar informe de destrucci\u00f3n +capability.FileTransferReport.title=Archivar informe de transferencia +capability.EndRetention.title=Terminar retenci\u00f3n + +# Hold Controls +capability.group.holdControls.title=Bloquear controles +capability.ExtendRetentionPeriodOrFreeze.title=Extender periodo de retenci\u00f3n o congelar +capability.Unfreeze.title=Descongelar +capability.ViewUpdateReasonsForFreeze.title=Ver razones actualizadas de congelaci\u00f3n +capability.CreateHold.title=Crear bloqueo +capability.AddToHold.title=A\u00f1adir a bloqueo +capability.RemoveFromHold.title=Eliminar de bloqueo +capability.FileHoldReport.title=Archivar informe de bloqueo +capability.DeleteHold.title=Eliminar bloqueo +capability.EditHold.title=Editar bloqueo + +# Audit +capability.group.audit.title=Auditor\u00eda +capability.DeclareAuditAsRecord.title=Declarar auditor\u00eda como documento de archivo +capability.EnableDisableAuditByTypes.title=Activar o desactivar auditor\u00eda por tipos +capability.DeleteAudit.title=Eliminar auditor\u00eda +capability.SelectAuditMetadata.title=Seleccionar metadatos de auditor\u00eda +capability.AccessAudit.title=Acceder a auditor\u00eda +capability.ExportAudit.title=Exportar auditor\u00eda + +# Security +capability.group.security.title=Seguridad +capability.CreateModifyDestroyRoles.title=Crear Modificar Destruir roles +capability.CreateModifyDestroyUsersAndGroups.title=Crear Modificar Destruir usuarios y grupos +capability.PasswordControl.title=Control de contrase\u00f1a +capability.DisplayRightsReport.title=Informe de derechos de presentaci\u00f3n +capability.ManageAccessControls.title=Asignaci\u00f3n de rol de usuario y grupo +capability.ManageAccessRights.title=Administrar permisos + +# Configuration +capability.group.config.title=Configuraci\u00f3n +capability.CreateModifyDestroyFileplanMetadata.title=Crear Modificar Destruir metadatos de plan de ficheros +capability.CreateModifyDestroyFileplanTypes.title=Crear Modificar Destruir tipos de plan de ficheros +capability.CreateModifyDestroyRecordTypes.title=Crear Modificar Destruir tipos de documento de archivo +capability.CreateAndAssociateSelectionLists.title=Crear y asociar listas de selecci\u00f3n +capability.EditSelectionLists.title=Editar listas de selecci\u00f3n +capability.CreateModifyDestroyReferenceTypes.title=Crear Modificar Destruir tipos de referencia +capability.AttachRulesToMetadataProperties.title=Vincular reglas a las propiedades de metadatos +capability.MakeOptionalParametersMandatory.title=Establecer como obligatorios los par\u00e1metros opcionales +capability.MapEmailMetadata.title=Asignar metadatos de correo electr\u00f3nico + +# Rules +capability.group.rules.title=Reglas capability.ManageRules.title=Gestionar reglas \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_fr.properties index d910940654..996bf2dc8a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_fr.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Documents d'archives -capability.DeclareRecords.title=Compl\u00e9ter des documents d'archives -capability.ViewRecords.title=Afficher des documents d'archives -capability.UndeclareRecords.title=Rouvrir des documents d'archives -capability.CreateRecords.title=Cr\u00e9er des documents d'archives -capability.RequestRecordInformation.title=Demander des informations sur un document d'archives -capability.RejectRecords.title=Rejeter des documents d'archives -capability.FileUnfiledRecords.title=Classer des documents d'archives non class\u00e9s -capability.LinkToRecords.title=Lier des documents d'archives -capability.DeleteLinks.title=Supprimer le lien des enregistrements - -# Metadata Control -capability.group.metadataControl.title=Contr\u00f4le des m\u00e9tadonn\u00e9es -capability.EditRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document d'archives -capability.EditDeclaredRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document d'archives compl\u00e9t\u00e9 -capability.EditNonRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document qui n'est pas un document d'archives -capability.MoveRecords.title=D\u00e9placer des documents d'archives - -# Folder Control -capability.group.folderControl.title=Contr\u00f4le de dossiers -capability.CreateModifyDestroyFolders.title=Cr\u00e9er Modifier D\u00e9truire Dossiers -capability.CloseFolders.title=Fermer des dossiers -capability.ReOpenFolders.title=Rouvrir des dossiers -capability.DeclareRecordsInClosedFolders.title=Compl\u00e9ter des documents d'archives dans des dossiers ferm\u00e9s - -# Vital Records -capability.group.vitalRecords.title=Documents d'archives essentiels -capability.UpdateVitalRecordCycleInformation.title=Actualiser les informations concernant le cycle des documents d'archives essentiels -capability.CycleVitalRecords.title=Cycle des documents d'archives essentiels -capability.PlanningReviewCycles.title=Planifier les cycles de r\u00e9vision - -# References and Links -capability.group.references.title=R\u00e9f\u00e9rences -capability.ChangeOrDeleteReferences.title=Modifier ou supprimer des r\u00e9f\u00e9rences - -# Events -capability.group.events.title=Ev\u00e9nements -capability.CreateModifyDestroyEvents.title=Cr\u00e9er Modifier D\u00e9truire Ev\u00e9nements -capability.AddModifyEventDates.title=Ajouter Modifier Dates d'\u00e9v\u00e9nements - -# Cutoff -capability.group.cutoff.title=D\u00e9classer -capability.ApproveRecordsScheduledForCutoff.title=Approuver les documents d'archives planifi\u00e9s pour un d\u00e9classement -capability.CreateModifyRecordsInCutoffFolders.title=Cr\u00e9er Modifier des documents d'archives dans des dossiers d\u00e9class\u00e9s - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Disposition et transferts -capability.UpdateTriggerDates.title=Actualiser les dates de d\u00e9clenchement -capability.ManuallyChangeDispositionDates.title=Modifier manuellement les dates de disposition -capability.AuthorizeNominatedTransfers.title=Autoriser les transferts nominatifs -capability.AuthorizeAllTransfers.title=Autoriser tous les transferts -capability.DestroyRecordsScheduledForDestruction.title=D\u00e9truire un document ou un dossier d'archives dont la destruction est planifi\u00e9e -capability.DestroyRecords.title=D\u00e9truire des documents d'archives -capability.DeleteRecords.title=Supprimer des documents d'archives -capability.TriggerAnEvent.title=D\u00e9clencher un \u00e9v\u00e9nement -capability.FileDestructionReport.title=Rapport de destruction de fichier -capability.FileTransferReport.title=Rapport de transfert de fichier -capability.EndRetention.title=Mettre fin \u00e0 la r\u00e9tention - -# Hold Controls -capability.group.holdControls.title=Suspendre les contr\u00f4les -capability.ExtendRetentionPeriodOrFreeze.title=Prolonger la p\u00e9riode de r\u00e9tention ou le gel -capability.Unfreeze.title=D\u00e9geler -capability.ViewUpdateReasonsForFreeze.title=Voir les motifs d'actualisation d'un gel -capability.CreateHold.title=Cr\u00e9er une suspension -capability.AddToHold.title=Ajouter \u00e0 la suspension -capability.RemoveFromHold.title=Supprimer de la suspension -capability.FileHoldReport.title=Archiver le rapport de suspension -capability.DeleteHold.title=Supprimer la suspension -capability.EditHold.title=Modifier la suspension - -# Audit -capability.group.audit.title=Audit -capability.DeclareAuditAsRecord.title=D\u00e9clarer l'audit en tant que document d'archives -capability.EnableDisableAuditByTypes.title=Activer D\u00e9sactiver l'audit par types -capability.DeleteAudit.title=Supprimer un audit -capability.SelectAuditMetadata.title=S\u00e9lectionner les m\u00e9tadonn\u00e9es d'un audit -capability.AccessAudit.title=Acc\u00e9der \u00e0 un audit -capability.ExportAudit.title=Exporter l'audit - -# Security -capability.group.security.title=S\u00e9curit\u00e9 -capability.CreateModifyDestroyRoles.title=Cr\u00e9er Modifier D\u00e9truire des r\u00f4les -capability.CreateModifyDestroyUsersAndGroups.title=Cr\u00e9er Modifier D\u00e9truire des utilisateurs et des groupes -capability.PasswordControl.title=Contr\u00f4le des mots de passe -capability.DisplayRightsReport.title=Afficher le rapport sur les droits -capability.ManageAccessControls.title=Affectation de r\u00f4les aux groupes et utilisateurs -capability.ManageAccessRights.title=G\u00e9rer les permissions - -# Configuration -capability.group.config.title=Configuration -capability.CreateModifyDestroyFileplanMetadata.title=Cr\u00e9er Modifier D\u00e9truire des m\u00e9tadonn\u00e9es de plan de classification -capability.CreateModifyDestroyFileplanTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de plan de classification -capability.CreateModifyDestroyRecordTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de document d'archives -capability.CreateAndAssociateSelectionLists.title=Cr\u00e9er et associer des listes de s\u00e9lections -capability.EditSelectionLists.title=Modifier des listes de s\u00e9lections -capability.CreateModifyDestroyReferenceTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de r\u00e9f\u00e9rence -capability.AttachRulesToMetadataProperties.title=Attacher des r\u00e8gles aux propri\u00e9t\u00e9s des m\u00e9tadonn\u00e9es -capability.MakeOptionalParametersMandatory.title=Rendre obligatoires des param\u00e8tres facultatifs -capability.MapEmailMetadata.title=Mapper des m\u00e9tadonn\u00e9es d'e-mail - -# Rules -capability.group.rules.title=R\u00e8gles +# Records +capability.group.records.title=Documents d'archives +capability.DeclareRecords.title=Compl\u00e9ter des documents d'archives +capability.ViewRecords.title=Afficher des documents d'archives +capability.UndeclareRecords.title=Rouvrir des documents d'archives +capability.CreateRecords.title=Cr\u00e9er des documents d'archives +capability.RequestRecordInformation.title=Demander des informations sur un document d'archives +capability.RejectRecords.title=Rejeter des documents d'archives +capability.FileUnfiledRecords.title=Classer des documents d'archives non class\u00e9s +capability.LinkToRecords.title=Lier des documents d'archives +capability.DeleteLinks.title=Supprimer le lien des enregistrements + +# Metadata Control +capability.group.metadataControl.title=Contr\u00f4le des m\u00e9tadonn\u00e9es +capability.EditRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document d'archives +capability.EditDeclaredRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document d'archives compl\u00e9t\u00e9 +capability.EditNonRecordMetadata.title=Modifier les m\u00e9tadonn\u00e9es d'un document qui n'est pas un document d'archives +capability.MoveRecords.title=D\u00e9placer des documents d'archives + +# Folder Control +capability.group.folderControl.title=Contr\u00f4le de dossiers +capability.CreateModifyDestroyFolders.title=Cr\u00e9er Modifier D\u00e9truire Dossiers +capability.CloseFolders.title=Fermer des dossiers +capability.ReOpenFolders.title=Rouvrir des dossiers +capability.DeclareRecordsInClosedFolders.title=Compl\u00e9ter des documents d'archives dans des dossiers ferm\u00e9s + +# Vital Records +capability.group.vitalRecords.title=Documents d'archives essentiels +capability.UpdateVitalRecordCycleInformation.title=Actualiser les informations concernant le cycle des documents d'archives essentiels +capability.CycleVitalRecords.title=Cycle des documents d'archives essentiels +capability.PlanningReviewCycles.title=Planifier les cycles de r\u00e9vision + +# References and Links +capability.group.references.title=R\u00e9f\u00e9rences +capability.ChangeOrDeleteReferences.title=Modifier ou supprimer des r\u00e9f\u00e9rences + +# Events +capability.group.events.title=Ev\u00e9nements +capability.CreateModifyDestroyEvents.title=Cr\u00e9er Modifier D\u00e9truire Ev\u00e9nements +capability.AddModifyEventDates.title=Ajouter Modifier Dates d'\u00e9v\u00e9nements + +# Cutoff +capability.group.cutoff.title=D\u00e9classer +capability.ApproveRecordsScheduledForCutoff.title=Approuver les documents d'archives planifi\u00e9s pour un d\u00e9classement +capability.CreateModifyRecordsInCutoffFolders.title=Cr\u00e9er Modifier des documents d'archives dans des dossiers d\u00e9class\u00e9s + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Disposition et transferts +capability.UpdateTriggerDates.title=Actualiser les dates de d\u00e9clenchement +capability.ManuallyChangeDispositionDates.title=Modifier manuellement les dates de disposition +capability.AuthorizeNominatedTransfers.title=Autoriser les transferts nominatifs +capability.AuthorizeAllTransfers.title=Autoriser tous les transferts +capability.DestroyRecordsScheduledForDestruction.title=D\u00e9truire un document ou un dossier d'archives dont la destruction est planifi\u00e9e +capability.DestroyRecords.title=D\u00e9truire des documents d'archives +capability.DeleteRecords.title=Supprimer des documents d'archives +capability.TriggerAnEvent.title=D\u00e9clencher un \u00e9v\u00e9nement +capability.FileDestructionReport.title=Rapport de destruction de fichier +capability.FileTransferReport.title=Rapport de transfert de fichier +capability.EndRetention.title=Mettre fin \u00e0 la r\u00e9tention + +# Hold Controls +capability.group.holdControls.title=Suspendre les contr\u00f4les +capability.ExtendRetentionPeriodOrFreeze.title=Prolonger la p\u00e9riode de r\u00e9tention ou le gel +capability.Unfreeze.title=D\u00e9geler +capability.ViewUpdateReasonsForFreeze.title=Voir les motifs d'actualisation d'un gel +capability.CreateHold.title=Cr\u00e9er une suspension +capability.AddToHold.title=Ajouter \u00e0 la suspension +capability.RemoveFromHold.title=Supprimer de la suspension +capability.FileHoldReport.title=Archiver le rapport de suspension +capability.DeleteHold.title=Supprimer la suspension +capability.EditHold.title=Modifier la suspension + +# Audit +capability.group.audit.title=Audit +capability.DeclareAuditAsRecord.title=D\u00e9clarer l'audit en tant que document d'archives +capability.EnableDisableAuditByTypes.title=Activer D\u00e9sactiver l'audit par types +capability.DeleteAudit.title=Supprimer un audit +capability.SelectAuditMetadata.title=S\u00e9lectionner les m\u00e9tadonn\u00e9es d'un audit +capability.AccessAudit.title=Acc\u00e9der \u00e0 un audit +capability.ExportAudit.title=Exporter l'audit + +# Security +capability.group.security.title=S\u00e9curit\u00e9 +capability.CreateModifyDestroyRoles.title=Cr\u00e9er Modifier D\u00e9truire des r\u00f4les +capability.CreateModifyDestroyUsersAndGroups.title=Cr\u00e9er Modifier D\u00e9truire des utilisateurs et des groupes +capability.PasswordControl.title=Contr\u00f4le des mots de passe +capability.DisplayRightsReport.title=Afficher le rapport sur les droits +capability.ManageAccessControls.title=Affectation de r\u00f4les aux groupes et utilisateurs +capability.ManageAccessRights.title=G\u00e9rer les permissions + +# Configuration +capability.group.config.title=Configuration +capability.CreateModifyDestroyFileplanMetadata.title=Cr\u00e9er Modifier D\u00e9truire des m\u00e9tadonn\u00e9es de plan de classification +capability.CreateModifyDestroyFileplanTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de plan de classification +capability.CreateModifyDestroyRecordTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de document d'archives +capability.CreateAndAssociateSelectionLists.title=Cr\u00e9er et associer des listes de s\u00e9lections +capability.EditSelectionLists.title=Modifier des listes de s\u00e9lections +capability.CreateModifyDestroyReferenceTypes.title=Cr\u00e9er Modifier D\u00e9truire des types de r\u00e9f\u00e9rence +capability.AttachRulesToMetadataProperties.title=Attacher des r\u00e8gles aux propri\u00e9t\u00e9s des m\u00e9tadonn\u00e9es +capability.MakeOptionalParametersMandatory.title=Rendre obligatoires des param\u00e8tres facultatifs +capability.MapEmailMetadata.title=Mapper des m\u00e9tadonn\u00e9es d'e-mail + +# Rules +capability.group.rules.title=R\u00e8gles capability.ManageRules.title=G\u00e9rer les r\u00e8gles \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_it.properties index 330dd2d888..d9a754f239 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_it.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Record -capability.DeclareRecords.title=Completa record -capability.ViewRecords.title=Visualizza record -capability.UndeclareRecords.title=Riapri record -capability.CreateRecords.title=Crea record -capability.RequestRecordInformation.title=Richiedi informazioni record -capability.RejectRecords.title=Respingi record -capability.FileUnfiledRecords.title=Archivia record non archiviati -capability.LinkToRecords.title=Collega record -capability.DeleteLinks.title=Scollega record - -# Metadata Control -capability.group.metadataControl.title=Controllo metadati -capability.EditRecordMetadata.title=Modifica metadati del record -capability.EditDeclaredRecordMetadata.title=Modifica metadati del record completati -capability.EditNonRecordMetadata.title=Modifica metadati del non record -capability.MoveRecords.title=Sposta record - -# Folder Control -capability.group.folderControl.title=Controllo cartelle -capability.CreateModifyDestroyFolders.title=Crea Modifica Elimina definitivamente cartelle -capability.CloseFolders.title=Chiudi cartelle -capability.ReOpenFolders.title=Riapri cartelle -capability.DeclareRecordsInClosedFolders.title=Completa record nelle cartelle chiuse - -# Vital Records -capability.group.vitalRecords.title=Record fondamentali -capability.UpdateVitalRecordCycleInformation.title=Aggiorna informazioni ciclo di record fondamentale -capability.CycleVitalRecords.title=Record fondamentali del ciclo -capability.PlanningReviewCycles.title=Pianificazione cicli di revisione - -# References and Links -capability.group.references.title=Riferimenti -capability.ChangeOrDeleteReferences.title=Cambia o elimina riferimenti - -# Events -capability.group.events.title=Eventi -capability.CreateModifyDestroyEvents.title=Crea Modifica Elimina definitivamente eventi -capability.AddModifyEventDates.title=Aggiungi Modifica date eventi - -# Cutoff -capability.group.cutoff.title=Cut off -capability.ApproveRecordsScheduledForCutoff.title=Approva record per cui \u00e8 stato pianificato il cut off -capability.CreateModifyRecordsInCutoffFolders.title=Crea Modifica record nelle cartelle di cut off - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Disposizione e trasferimenti -capability.UpdateTriggerDates.title=Aggiorna date di attivazione -capability.ManuallyChangeDispositionDates.title=Cambia manualmente le date di disposizione -capability.AuthorizeNominatedTransfers.title=Autorizza trasferimenti nominati -capability.AuthorizeAllTransfers.title=Autorizza tutti i trasferimenti -capability.DestroyRecordsScheduledForDestruction.title=Elimina definitivamente record o cartella di record per cui \u00e8 stata pianificata l'eliminazione permanente -capability.DestroyRecords.title=Elimina definitivamente record -capability.DeleteRecords.title=Elimina record -capability.TriggerAnEvent.title=Attiva un evento -capability.FileDestructionReport.title=Archivia report di eliminazione permanente -capability.FileTransferReport.title=Archivia report di trasferimento -capability.EndRetention.title=Termina conservazione - -# Hold Controls -capability.group.holdControls.title=Sospendi controlli -capability.ExtendRetentionPeriodOrFreeze.title=Estendi periodo di conservazione o blocca -capability.Unfreeze.title=Sblocca -capability.ViewUpdateReasonsForFreeze.title=Visualizza Aggiorna motivi blocco -capability.CreateHold.title=Crea sospensione -capability.AddToHold.title=Aggiungi a sospesi -capability.RemoveFromHold.title=Rimuovi da sospesi -capability.FileHoldReport.title=Archivia report di sospensione -capability.DeleteHold.title=Annulla sospensione -capability.EditHold.title=Modifica sospensione - -# Audit -capability.group.audit.title=Audit -capability.DeclareAuditAsRecord.title=Dichiara audit come record -capability.EnableDisableAuditByTypes.title=Abilita Disabilita audit per tipo -capability.DeleteAudit.title=Elimina audit -capability.SelectAuditMetadata.title=Seleziona metadati di audit -capability.AccessAudit.title=Accedi audit -capability.ExportAudit.title=Esporta audit - -# Security -capability.group.security.title=Sicurezza -capability.CreateModifyDestroyRoles.title=Crea Modifica Elimina definitivamente ruoli -capability.CreateModifyDestroyUsersAndGroups.title=Crea Modifica Elimina definitivamente utenti e gruppi -capability.PasswordControl.title=Controllo password -capability.DisplayRightsReport.title=Mostra report diritti -capability.ManageAccessControls.title=Assegnazione gruppo e ruolo utente -capability.ManageAccessRights.title=Gestisci permessi - -# Configuration -capability.group.config.title=Configurazione -capability.CreateModifyDestroyFileplanMetadata.title=Crea Modifica Elimina definitivamente metadati di piano file -capability.CreateModifyDestroyFileplanTypes.title=Crea Modifica Elimina definitivamente tipi di piano file -capability.CreateModifyDestroyRecordTypes.title=Crea Modifica Elimina definitivamente tipi di record -capability.CreateAndAssociateSelectionLists.title=Crea e associa elenchi di selezione -capability.EditSelectionLists.title=Modifica elenchi di selezione -capability.CreateModifyDestroyReferenceTypes.title=Crea Modifica Elimina definitivamente tipi di riferimento -capability.AttachRulesToMetadataProperties.title=Allega regole a propriet\u00e0 di metadati -capability.MakeOptionalParametersMandatory.title=Rendi obbligatori i parametri opzionali -capability.MapEmailMetadata.title=Esegui il mapping dei metadati di e-mail - -# Rules -capability.group.rules.title=Regole +# Records +capability.group.records.title=Record +capability.DeclareRecords.title=Completa record +capability.ViewRecords.title=Visualizza record +capability.UndeclareRecords.title=Riapri record +capability.CreateRecords.title=Crea record +capability.RequestRecordInformation.title=Richiedi informazioni record +capability.RejectRecords.title=Respingi record +capability.FileUnfiledRecords.title=Archivia record non archiviati +capability.LinkToRecords.title=Collega record +capability.DeleteLinks.title=Scollega record + +# Metadata Control +capability.group.metadataControl.title=Controllo metadati +capability.EditRecordMetadata.title=Modifica metadati del record +capability.EditDeclaredRecordMetadata.title=Modifica metadati del record completati +capability.EditNonRecordMetadata.title=Modifica metadati del non record +capability.MoveRecords.title=Sposta record + +# Folder Control +capability.group.folderControl.title=Controllo cartelle +capability.CreateModifyDestroyFolders.title=Crea Modifica Elimina definitivamente cartelle +capability.CloseFolders.title=Chiudi cartelle +capability.ReOpenFolders.title=Riapri cartelle +capability.DeclareRecordsInClosedFolders.title=Completa record nelle cartelle chiuse + +# Vital Records +capability.group.vitalRecords.title=Record fondamentali +capability.UpdateVitalRecordCycleInformation.title=Aggiorna informazioni ciclo di record fondamentale +capability.CycleVitalRecords.title=Record fondamentali del ciclo +capability.PlanningReviewCycles.title=Pianificazione cicli di revisione + +# References and Links +capability.group.references.title=Riferimenti +capability.ChangeOrDeleteReferences.title=Cambia o elimina riferimenti + +# Events +capability.group.events.title=Eventi +capability.CreateModifyDestroyEvents.title=Crea Modifica Elimina definitivamente eventi +capability.AddModifyEventDates.title=Aggiungi Modifica date eventi + +# Cutoff +capability.group.cutoff.title=Cut off +capability.ApproveRecordsScheduledForCutoff.title=Approva record per cui \u00e8 stato pianificato il cut off +capability.CreateModifyRecordsInCutoffFolders.title=Crea Modifica record nelle cartelle di cut off + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Disposizione e trasferimenti +capability.UpdateTriggerDates.title=Aggiorna date di attivazione +capability.ManuallyChangeDispositionDates.title=Cambia manualmente le date di disposizione +capability.AuthorizeNominatedTransfers.title=Autorizza trasferimenti nominati +capability.AuthorizeAllTransfers.title=Autorizza tutti i trasferimenti +capability.DestroyRecordsScheduledForDestruction.title=Elimina definitivamente record o cartella di record per cui \u00e8 stata pianificata l'eliminazione permanente +capability.DestroyRecords.title=Elimina definitivamente record +capability.DeleteRecords.title=Elimina record +capability.TriggerAnEvent.title=Attiva un evento +capability.FileDestructionReport.title=Archivia report di eliminazione permanente +capability.FileTransferReport.title=Archivia report di trasferimento +capability.EndRetention.title=Termina conservazione + +# Hold Controls +capability.group.holdControls.title=Sospendi controlli +capability.ExtendRetentionPeriodOrFreeze.title=Estendi periodo di conservazione o blocca +capability.Unfreeze.title=Sblocca +capability.ViewUpdateReasonsForFreeze.title=Visualizza Aggiorna motivi blocco +capability.CreateHold.title=Crea sospensione +capability.AddToHold.title=Aggiungi a sospesi +capability.RemoveFromHold.title=Rimuovi da sospesi +capability.FileHoldReport.title=Archivia report di sospensione +capability.DeleteHold.title=Annulla sospensione +capability.EditHold.title=Modifica sospensione + +# Audit +capability.group.audit.title=Audit +capability.DeclareAuditAsRecord.title=Dichiara audit come record +capability.EnableDisableAuditByTypes.title=Abilita Disabilita audit per tipo +capability.DeleteAudit.title=Elimina audit +capability.SelectAuditMetadata.title=Seleziona metadati di audit +capability.AccessAudit.title=Accedi audit +capability.ExportAudit.title=Esporta audit + +# Security +capability.group.security.title=Sicurezza +capability.CreateModifyDestroyRoles.title=Crea Modifica Elimina definitivamente ruoli +capability.CreateModifyDestroyUsersAndGroups.title=Crea Modifica Elimina definitivamente utenti e gruppi +capability.PasswordControl.title=Controllo password +capability.DisplayRightsReport.title=Mostra report diritti +capability.ManageAccessControls.title=Assegnazione gruppo e ruolo utente +capability.ManageAccessRights.title=Gestisci permessi + +# Configuration +capability.group.config.title=Configurazione +capability.CreateModifyDestroyFileplanMetadata.title=Crea Modifica Elimina definitivamente metadati di piano file +capability.CreateModifyDestroyFileplanTypes.title=Crea Modifica Elimina definitivamente tipi di piano file +capability.CreateModifyDestroyRecordTypes.title=Crea Modifica Elimina definitivamente tipi di record +capability.CreateAndAssociateSelectionLists.title=Crea e associa elenchi di selezione +capability.EditSelectionLists.title=Modifica elenchi di selezione +capability.CreateModifyDestroyReferenceTypes.title=Crea Modifica Elimina definitivamente tipi di riferimento +capability.AttachRulesToMetadataProperties.title=Allega regole a propriet\u00e0 di metadati +capability.MakeOptionalParametersMandatory.title=Rendi obbligatori i parametri opzionali +capability.MapEmailMetadata.title=Esegui il mapping dei metadati di e-mail + +# Rules +capability.group.rules.title=Regole capability.ManageRules.title=Gestisci regole \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_ja.properties index 211f9b0ddc..bfc47aa258 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_ja.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=\u30ec\u30b3\u30fc\u30c9 -capability.DeclareRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u5b8c\u4e86 -capability.ViewRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u8868\u793a -capability.UndeclareRecords.title=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304f -capability.CreateRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210 -capability.RequestRecordInformation.title=\u30ec\u30b3\u30fc\u30c9\u60c5\u5831\u306e\u30ea\u30af\u30a8\u30b9\u30c8 -capability.RejectRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u5374\u4e0b -capability.FileUnfiledRecords.title=\u672a\u6574\u7406\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u6574\u7406\u4fdd\u7ba1 -capability.LinkToRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u30ea\u30f3\u30af -capability.DeleteLinks.title=\u30ec\u30b3\u30fc\u30c9\u306e\u30ea\u30f3\u30af\u306e\u89e3\u9664 - -# Metadata Control -capability.group.metadataControl.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb -capability.EditRecordMetadata.title=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 -capability.EditDeclaredRecordMetadata.title=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 -capability.EditNonRecordMetadata.title=\u975e\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 -capability.MoveRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 - -# Folder Control -capability.group.folderControl.title=\u30d5\u30a9\u30eb\u30c0\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb -capability.CreateModifyDestroyFolders.title=\u30d5\u30a9\u30eb\u30c0\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.CloseFolders.title=\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b -capability.ReOpenFolders.title=\u30d5\u30a9\u30eb\u30c0\u3092\u518d\u5ea6\u958b\u304f -capability.DeclareRecordsInClosedFolders.title=\u9589\u3058\u305f\u30d5\u30a9\u30eb\u30c0\u306e\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 - -# Vital Records -capability.group.vitalRecords.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 -capability.UpdateVitalRecordCycleInformation.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30b5\u30a4\u30af\u30eb\u60c5\u5831\u306e\u66f4\u65b0 -capability.CycleVitalRecords.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30b5\u30a4\u30af\u30eb -capability.PlanningReviewCycles.title=\u30ec\u30d3\u30e5\u30fc\u30b5\u30a4\u30af\u30eb\u306e\u30d7\u30e9\u30f3\u30cb\u30f3\u30b0 - -# References and Links -capability.group.references.title=\u53c2\u7167 -capability.ChangeOrDeleteReferences.title=\u53c2\u7167\u306e\u5909\u66f4\u307e\u305f\u306f\u524a\u9664 - -# Events -capability.group.events.title=\u30a4\u30d9\u30f3\u30c8 -capability.CreateModifyDestroyEvents.title=\u30a4\u30d9\u30f3\u30c8\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.AddModifyEventDates.title=\u30a4\u30d9\u30f3\u30c8\u65e5\u4ed8\u306e\u8ffd\u52a0/\u5909\u66f4 - -# Cutoff -capability.group.cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 -capability.ApproveRecordsScheduledForCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f\u30ec\u30b3\u30fc\u30c9\u306e\u627f\u8a8d -capability.CreateModifyRecordsInCutoffFolders.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u30d5\u30a9\u30eb\u30c0\u306e\u4fee\u6b63\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210 - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=\u5ec3\u68c4\u3068\u8ee2\u9001 -capability.UpdateTriggerDates.title=\u30c8\u30ea\u30ac\u30fc\u65e5\u306e\u66f4\u65b0 -capability.ManuallyChangeDispositionDates.title=\u5ec3\u68c4\u65e5\u306e\u624b\u52d5\u5909\u66f4 -capability.AuthorizeNominatedTransfers.title=\u63a8\u5968\u3055\u308c\u305f\u8ee2\u9001\u3092\u627f\u8a8d\u3059\u308b -capability.AuthorizeAllTransfers.title=\u3059\u3079\u3066\u306e\u8ee2\u9001\u3092\u627f\u8a8d\u3059\u308b -capability.DestroyRecordsScheduledForDestruction.title=\u5ec3\u68c4\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u7834\u68c4\u3059\u308b -capability.DestroyRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u7834\u68c4 -capability.DeleteRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u524a\u9664 -capability.TriggerAnEvent.title=\u30a4\u30d9\u30f3\u30c8\u306e\u30c8\u30ea\u30ac\u30fc -capability.FileDestructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -capability.FileTransferReport.title=\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 -capability.EndRetention.title=\u4fdd\u6301\u306e\u7d42\u4e86 - -# Hold Controls -capability.group.holdControls.title=\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u30db\u30fc\u30eb\u30c9 -capability.ExtendRetentionPeriodOrFreeze.title=\u4fdd\u6301\u671f\u9593\u306e\u5ef6\u9577\u307e\u305f\u306f\u56fa\u5b9a -capability.Unfreeze.title=\u56fa\u5b9a\u89e3\u9664 -capability.ViewUpdateReasonsForFreeze.title=\u66f4\u65b0\u3055\u308c\u305f\u56fa\u5b9a\u306e\u7406\u7531\u3092\u8868\u793a -capability.CreateHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u4f5c\u6210 -capability.AddToHold.title=\u30db\u30fc\u30eb\u30c9\u306b\u8ffd\u52a0 -capability.RemoveFromHold.title=\u30db\u30fc\u30eb\u30c9\u304b\u3089\u89e3\u9664 -capability.FileHoldReport.title=\u30d5\u30a1\u30a4\u30eb\u30db\u30fc\u30eb\u30c9\u30ec\u30dd\u30fc\u30c8 -capability.DeleteHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 -capability.EditHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u7de8\u96c6 - -# Audit -capability.group.audit.title=\u76e3\u67fb -capability.DeclareAuditAsRecord.title=\u76e3\u67fb\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b -capability.EnableDisableAuditByTypes.title=\u76e3\u67fb\u3092\u30bf\u30a4\u30d7\u5225\u306b\u6709\u52b9\u5316/\u7121\u52b9\u5316\u3059\u308b -capability.DeleteAudit.title=\u76e3\u67fb\u306e\u524a\u9664 -capability.SelectAuditMetadata.title=\u76e3\u67fb\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u9078\u629e -capability.AccessAudit.title=\u76e3\u67fb\u306b\u30a2\u30af\u30bb\u30b9 -capability.ExportAudit.title=\u76e3\u67fb\u306e\u30a8\u30af\u30b9\u30dd\u30fc\u30c8 - -# Security -capability.group.security.title=\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3 -capability.CreateModifyDestroyRoles.title=\u5f79\u5272\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.CreateModifyDestroyUsersAndGroups.title=\u30e6\u30fc\u30b6\u30fc\u3068\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.PasswordControl.title=\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb -capability.DisplayRightsReport.title=\u6a29\u5229\u30ec\u30dd\u30fc\u30c8\u306e\u8868\u793a -capability.ManageAccessControls.title=\u30b0\u30eb\u30fc\u30d7\u3068\u30e6\u30fc\u30b6\u30fc\u30ed\u30fc\u30eb\u306e\u5272\u308a\u5f53\u3066 -capability.ManageAccessRights.title=\u6a29\u9650\u306e\u7ba1\u7406 - -# Configuration -capability.group.config.title=\u8a2d\u5b9a -capability.CreateModifyDestroyFileplanMetadata.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.CreateModifyDestroyFileplanTypes.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.CreateModifyDestroyRecordTypes.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.CreateAndAssociateSelectionLists.title=\u30bb\u30af\u30b7\u30e7\u30f3\u30ea\u30b9\u30c8\u306e\u4f5c\u6210\u3068\u95a2\u9023\u4ed8\u3051 -capability.EditSelectionLists.title=\u30bb\u30af\u30b7\u30e7\u30f3\u30ea\u30b9\u30c8\u306e\u7de8\u96c6 -capability.CreateModifyDestroyReferenceTypes.title=\u53c2\u7167\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 -capability.AttachRulesToMetadataProperties.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u30eb\u30fc\u30eb\u3092\u9069\u7528 -capability.MakeOptionalParametersMandatory.title=\u30aa\u30d7\u30b7\u30e7\u30f3\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5fc5\u9808\u306b\u3059\u308b -capability.MapEmailMetadata.title=E\u30e1\u30fc\u30eb\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30c3\u30d4\u30f3\u30b0 - -# Rules -capability.group.rules.title=\u30eb\u30fc\u30eb +# Records +capability.group.records.title=\u30ec\u30b3\u30fc\u30c9 +capability.DeclareRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u5b8c\u4e86 +capability.ViewRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u8868\u793a +capability.UndeclareRecords.title=\u30ec\u30b3\u30fc\u30c9\u3092\u518d\u5ea6\u958b\u304f +capability.CreateRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210 +capability.RequestRecordInformation.title=\u30ec\u30b3\u30fc\u30c9\u60c5\u5831\u306e\u30ea\u30af\u30a8\u30b9\u30c8 +capability.RejectRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u5374\u4e0b +capability.FileUnfiledRecords.title=\u672a\u6574\u7406\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u6574\u7406\u4fdd\u7ba1 +capability.LinkToRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u30ea\u30f3\u30af +capability.DeleteLinks.title=\u30ec\u30b3\u30fc\u30c9\u306e\u30ea\u30f3\u30af\u306e\u89e3\u9664 + +# Metadata Control +capability.group.metadataControl.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb +capability.EditRecordMetadata.title=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 +capability.EditDeclaredRecordMetadata.title=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 +capability.EditNonRecordMetadata.title=\u975e\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u7de8\u96c6 +capability.MoveRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5 + +# Folder Control +capability.group.folderControl.title=\u30d5\u30a9\u30eb\u30c0\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb +capability.CreateModifyDestroyFolders.title=\u30d5\u30a9\u30eb\u30c0\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.CloseFolders.title=\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b +capability.ReOpenFolders.title=\u30d5\u30a9\u30eb\u30c0\u3092\u518d\u5ea6\u958b\u304f +capability.DeclareRecordsInClosedFolders.title=\u9589\u3058\u305f\u30d5\u30a9\u30eb\u30c0\u306e\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 + +# Vital Records +capability.group.vitalRecords.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 +capability.UpdateVitalRecordCycleInformation.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30b5\u30a4\u30af\u30eb\u60c5\u5831\u306e\u66f4\u65b0 +capability.CycleVitalRecords.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30b5\u30a4\u30af\u30eb +capability.PlanningReviewCycles.title=\u30ec\u30d3\u30e5\u30fc\u30b5\u30a4\u30af\u30eb\u306e\u30d7\u30e9\u30f3\u30cb\u30f3\u30b0 + +# References and Links +capability.group.references.title=\u53c2\u7167 +capability.ChangeOrDeleteReferences.title=\u53c2\u7167\u306e\u5909\u66f4\u307e\u305f\u306f\u524a\u9664 + +# Events +capability.group.events.title=\u30a4\u30d9\u30f3\u30c8 +capability.CreateModifyDestroyEvents.title=\u30a4\u30d9\u30f3\u30c8\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.AddModifyEventDates.title=\u30a4\u30d9\u30f3\u30c8\u65e5\u4ed8\u306e\u8ffd\u52a0/\u5909\u66f4 + +# Cutoff +capability.group.cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 +capability.ApproveRecordsScheduledForCutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f\u30ec\u30b3\u30fc\u30c9\u306e\u627f\u8a8d +capability.CreateModifyRecordsInCutoffFolders.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u30d5\u30a9\u30eb\u30c0\u306e\u4fee\u6b63\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210 + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=\u5ec3\u68c4\u3068\u8ee2\u9001 +capability.UpdateTriggerDates.title=\u30c8\u30ea\u30ac\u30fc\u65e5\u306e\u66f4\u65b0 +capability.ManuallyChangeDispositionDates.title=\u5ec3\u68c4\u65e5\u306e\u624b\u52d5\u5909\u66f4 +capability.AuthorizeNominatedTransfers.title=\u63a8\u5968\u3055\u308c\u305f\u8ee2\u9001\u3092\u627f\u8a8d\u3059\u308b +capability.AuthorizeAllTransfers.title=\u3059\u3079\u3066\u306e\u8ee2\u9001\u3092\u627f\u8a8d\u3059\u308b +capability.DestroyRecordsScheduledForDestruction.title=\u5ec3\u68c4\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f\u306e\u30ec\u30b3\u30fc\u30c9\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u7834\u68c4\u3059\u308b +capability.DestroyRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u7834\u68c4 +capability.DeleteRecords.title=\u30ec\u30b3\u30fc\u30c9\u306e\u524a\u9664 +capability.TriggerAnEvent.title=\u30a4\u30d9\u30f3\u30c8\u306e\u30c8\u30ea\u30ac\u30fc +capability.FileDestructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +capability.FileTransferReport.title=\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8\u306e\u6574\u7406\u4fdd\u7ba1 +capability.EndRetention.title=\u4fdd\u6301\u306e\u7d42\u4e86 + +# Hold Controls +capability.group.holdControls.title=\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u30db\u30fc\u30eb\u30c9 +capability.ExtendRetentionPeriodOrFreeze.title=\u4fdd\u6301\u671f\u9593\u306e\u5ef6\u9577\u307e\u305f\u306f\u56fa\u5b9a +capability.Unfreeze.title=\u56fa\u5b9a\u89e3\u9664 +capability.ViewUpdateReasonsForFreeze.title=\u66f4\u65b0\u3055\u308c\u305f\u56fa\u5b9a\u306e\u7406\u7531\u3092\u8868\u793a +capability.CreateHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u4f5c\u6210 +capability.AddToHold.title=\u30db\u30fc\u30eb\u30c9\u306b\u8ffd\u52a0 +capability.RemoveFromHold.title=\u30db\u30fc\u30eb\u30c9\u304b\u3089\u89e3\u9664 +capability.FileHoldReport.title=\u30d5\u30a1\u30a4\u30eb\u30db\u30fc\u30eb\u30c9\u30ec\u30dd\u30fc\u30c8 +capability.DeleteHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u524a\u9664 +capability.EditHold.title=\u30db\u30fc\u30eb\u30c9\u306e\u7de8\u96c6 + +# Audit +capability.group.audit.title=\u76e3\u67fb +capability.DeclareAuditAsRecord.title=\u76e3\u67fb\u3092\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5ba3\u8a00\u3059\u308b +capability.EnableDisableAuditByTypes.title=\u76e3\u67fb\u3092\u30bf\u30a4\u30d7\u5225\u306b\u6709\u52b9\u5316/\u7121\u52b9\u5316\u3059\u308b +capability.DeleteAudit.title=\u76e3\u67fb\u306e\u524a\u9664 +capability.SelectAuditMetadata.title=\u76e3\u67fb\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u9078\u629e +capability.AccessAudit.title=\u76e3\u67fb\u306b\u30a2\u30af\u30bb\u30b9 +capability.ExportAudit.title=\u76e3\u67fb\u306e\u30a8\u30af\u30b9\u30dd\u30fc\u30c8 + +# Security +capability.group.security.title=\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3 +capability.CreateModifyDestroyRoles.title=\u5f79\u5272\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.CreateModifyDestroyUsersAndGroups.title=\u30e6\u30fc\u30b6\u30fc\u3068\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.PasswordControl.title=\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb +capability.DisplayRightsReport.title=\u6a29\u5229\u30ec\u30dd\u30fc\u30c8\u306e\u8868\u793a +capability.ManageAccessControls.title=\u30b0\u30eb\u30fc\u30d7\u3068\u30e6\u30fc\u30b6\u30fc\u30ed\u30fc\u30eb\u306e\u5272\u308a\u5f53\u3066 +capability.ManageAccessRights.title=\u6a29\u9650\u306e\u7ba1\u7406 + +# Configuration +capability.group.config.title=\u8a2d\u5b9a +capability.CreateModifyDestroyFileplanMetadata.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.CreateModifyDestroyFileplanTypes.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.CreateModifyDestroyRecordTypes.title=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.CreateAndAssociateSelectionLists.title=\u30bb\u30af\u30b7\u30e7\u30f3\u30ea\u30b9\u30c8\u306e\u4f5c\u6210\u3068\u95a2\u9023\u4ed8\u3051 +capability.EditSelectionLists.title=\u30bb\u30af\u30b7\u30e7\u30f3\u30ea\u30b9\u30c8\u306e\u7de8\u96c6 +capability.CreateModifyDestroyReferenceTypes.title=\u53c2\u7167\u30bf\u30a4\u30d7\u306e\u4f5c\u6210/\u5909\u66f4/\u7834\u68c4 +capability.AttachRulesToMetadataProperties.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u30eb\u30fc\u30eb\u3092\u9069\u7528 +capability.MakeOptionalParametersMandatory.title=\u30aa\u30d7\u30b7\u30e7\u30f3\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5fc5\u9808\u306b\u3059\u308b +capability.MapEmailMetadata.title=E\u30e1\u30fc\u30eb\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30c3\u30d4\u30f3\u30b0 + +# Rules +capability.group.rules.title=\u30eb\u30fc\u30eb capability.ManageRules.title=\u30eb\u30fc\u30eb\u306e\u7ba1\u7406 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_nl.properties index df0e74c718..1ca4a85bde 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_nl.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=Records -capability.DeclareRecords.title=Records afronden -capability.ViewRecords.title=Records bekijken -capability.UndeclareRecords.title=Records heropenen -capability.CreateRecords.title=Records maken -capability.RequestRecordInformation.title=Recordgegevens opvragen -capability.RejectRecords.title=Records afwijzen -capability.FileUnfiledRecords.title=Niet gearchiveerde records archiveren -capability.LinkToRecords.title=Records koppelen -capability.DeleteLinks.title=Recordkoppeling opheffen - -# Metadata Control -capability.group.metadataControl.title=Metagegevensbeheer -capability.EditRecordMetadata.title=Metagegevens van record bewerken -capability.EditDeclaredRecordMetadata.title=Metagegevens van afgeronde record bewerken -capability.EditNonRecordMetadata.title=Metagegevens zonder record bewerken -capability.MoveRecords.title=Records verplaatsen - -# Folder Control -capability.group.folderControl.title=Mapbeheer -capability.CreateModifyDestroyFolders.title=Mappen maken aanpassen vernietigen -capability.CloseFolders.title=Mappen sluiten -capability.ReOpenFolders.title=Mappen heropenen -capability.DeclareRecordsInClosedFolders.title=Records in gesloten mappen afronden - -# Vital Records -capability.group.vitalRecords.title=Vitale records -capability.UpdateVitalRecordCycleInformation.title=Cyclusgegevens van vitale record bijwerken -capability.CycleVitalRecords.title=Cyclus vitale records -capability.PlanningReviewCycles.title=Planning revisiecycli - -# References and Links -capability.group.references.title=Verwijzingen -capability.ChangeOrDeleteReferences.title=Verwijzingen veranderen of verwijderen - -# Events -capability.group.events.title=Gebeurtenissen -capability.CreateModifyDestroyEvents.title=Gebeurtenissen maken aanpassen vernietigen -capability.AddModifyEventDates.title=Datums van gebeurtenis wijzigen toevoegen - -# Cutoff -capability.group.cutoff.title=Afsluiten -capability.ApproveRecordsScheduledForCutoff.title=Records goedkeuren die zijn ingepland voor afsluiten -capability.CreateModifyRecordsInCutoffFolders.title=Veranderingsrecords in afsluitmappen maken - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=Beschikking en overzettingen -capability.UpdateTriggerDates.title=Triggerdatums bijwerken -capability.ManuallyChangeDispositionDates.title=Beschikkingsdatums handmatig wijzigen -capability.AuthorizeNominatedTransfers.title=Genomineerde overzettingen autoriseren -capability.AuthorizeAllTransfers.title=Alle overzettingen autoriseren -capability.DestroyRecordsScheduledForDestruction.title=Record of archiefmap vernietigen die is ingepland voor vernietiging -capability.DestroyRecords.title=Records vernietigen -capability.DeleteRecords.title=Records verwijderen -capability.TriggerAnEvent.title=Een gebeurtenis triggeren -capability.FileDestructionReport.title=Vernietigingsrapport archiveren -capability.FileTransferReport.title=Overzetrapport archiveren -capability.EndRetention.title=Retentie be\u00ebindigen - -# Hold Controls -capability.group.holdControls.title=Wachtstandbeheer -capability.ExtendRetentionPeriodOrFreeze.title=Retentieperiode of bevriezen verlengen -capability.Unfreeze.title=Bevriezen opheffen -capability.ViewUpdateReasonsForFreeze.title=Redenen voor bevriezen bijwerken bekijken -capability.CreateHold.title=Wachtstand maken -capability.AddToHold.title=Toevoegen aan wachtstand -capability.RemoveFromHold.title=Verwijderen uit wachtstand -capability.FileHoldReport.title=Wachtstandrapport archiveren -capability.DeleteHold.title=Wachtstand verwijderen -capability.EditHold.title=Wachtstand bewerken - -# Audit -capability.group.audit.title=Audit -capability.DeclareAuditAsRecord.title=Audit declareren als record -capability.EnableDisableAuditByTypes.title=Audit op type uitschakelen inschakelen -capability.DeleteAudit.title=Audit verwijderen -capability.SelectAuditMetadata.title=Metagegevens van audit selecteren -capability.AccessAudit.title=Audit openen -capability.ExportAudit.title=Audit exporteren - -# Security -capability.group.security.title=Beveiliging -capability.CreateModifyDestroyRoles.title=Rollen maken aanpassen vernietigen -capability.CreateModifyDestroyUsersAndGroups.title=Gebruikers en groepen maken aanpassen vernietigen -capability.PasswordControl.title=Wachtwoordbeheer -capability.DisplayRightsReport.title=Rechtenrapport weergeven -capability.ManageAccessControls.title=Groeps- en gebruikersroltoewijzing -capability.ManageAccessRights.title=Rechten beheren - -# Configuration -capability.group.config.title=Configuratie -capability.CreateModifyDestroyFileplanMetadata.title=Metagegevens voor ordeningsplan maken aanpassen vernietigen -capability.CreateModifyDestroyFileplanTypes.title=Ordeningsplantypes maken aanpassen vernietigen -capability.CreateModifyDestroyRecordTypes.title=Recordtypes maken aanpassen vernietigen -capability.CreateAndAssociateSelectionLists.title=Selectielijsten maken en toewijzen -capability.EditSelectionLists.title=Selectielijsten bewerken -capability.CreateModifyDestroyReferenceTypes.title=Verwijzingstypes maken aanpassen vernietigen -capability.AttachRulesToMetadataProperties.title=Regels aan metagegevenseigenschappen koppelen -capability.MakeOptionalParametersMandatory.title=Optionele parameters verplicht maken -capability.MapEmailMetadata.title=Metagegevens e-mail toewijzen - -# Rules -capability.group.rules.title=Regels +# Records +capability.group.records.title=Records +capability.DeclareRecords.title=Records afronden +capability.ViewRecords.title=Records bekijken +capability.UndeclareRecords.title=Records heropenen +capability.CreateRecords.title=Records maken +capability.RequestRecordInformation.title=Recordgegevens opvragen +capability.RejectRecords.title=Records afwijzen +capability.FileUnfiledRecords.title=Niet gearchiveerde records archiveren +capability.LinkToRecords.title=Records koppelen +capability.DeleteLinks.title=Recordkoppeling opheffen + +# Metadata Control +capability.group.metadataControl.title=Metagegevensbeheer +capability.EditRecordMetadata.title=Metagegevens van record bewerken +capability.EditDeclaredRecordMetadata.title=Metagegevens van afgeronde record bewerken +capability.EditNonRecordMetadata.title=Metagegevens zonder record bewerken +capability.MoveRecords.title=Records verplaatsen + +# Folder Control +capability.group.folderControl.title=Mapbeheer +capability.CreateModifyDestroyFolders.title=Mappen maken aanpassen vernietigen +capability.CloseFolders.title=Mappen sluiten +capability.ReOpenFolders.title=Mappen heropenen +capability.DeclareRecordsInClosedFolders.title=Records in gesloten mappen afronden + +# Vital Records +capability.group.vitalRecords.title=Vitale records +capability.UpdateVitalRecordCycleInformation.title=Cyclusgegevens van vitale record bijwerken +capability.CycleVitalRecords.title=Cyclus vitale records +capability.PlanningReviewCycles.title=Planning revisiecycli + +# References and Links +capability.group.references.title=Verwijzingen +capability.ChangeOrDeleteReferences.title=Verwijzingen veranderen of verwijderen + +# Events +capability.group.events.title=Gebeurtenissen +capability.CreateModifyDestroyEvents.title=Gebeurtenissen maken aanpassen vernietigen +capability.AddModifyEventDates.title=Datums van gebeurtenis wijzigen toevoegen + +# Cutoff +capability.group.cutoff.title=Afsluiten +capability.ApproveRecordsScheduledForCutoff.title=Records goedkeuren die zijn ingepland voor afsluiten +capability.CreateModifyRecordsInCutoffFolders.title=Veranderingsrecords in afsluitmappen maken + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=Beschikking en overzettingen +capability.UpdateTriggerDates.title=Triggerdatums bijwerken +capability.ManuallyChangeDispositionDates.title=Beschikkingsdatums handmatig wijzigen +capability.AuthorizeNominatedTransfers.title=Genomineerde overzettingen autoriseren +capability.AuthorizeAllTransfers.title=Alle overzettingen autoriseren +capability.DestroyRecordsScheduledForDestruction.title=Record of archiefmap vernietigen die is ingepland voor vernietiging +capability.DestroyRecords.title=Records vernietigen +capability.DeleteRecords.title=Records verwijderen +capability.TriggerAnEvent.title=Een gebeurtenis triggeren +capability.FileDestructionReport.title=Vernietigingsrapport archiveren +capability.FileTransferReport.title=Overzetrapport archiveren +capability.EndRetention.title=Retentie be\u00ebindigen + +# Hold Controls +capability.group.holdControls.title=Wachtstandbeheer +capability.ExtendRetentionPeriodOrFreeze.title=Retentieperiode of bevriezen verlengen +capability.Unfreeze.title=Bevriezen opheffen +capability.ViewUpdateReasonsForFreeze.title=Redenen voor bevriezen bijwerken bekijken +capability.CreateHold.title=Wachtstand maken +capability.AddToHold.title=Toevoegen aan wachtstand +capability.RemoveFromHold.title=Verwijderen uit wachtstand +capability.FileHoldReport.title=Wachtstandrapport archiveren +capability.DeleteHold.title=Wachtstand verwijderen +capability.EditHold.title=Wachtstand bewerken + +# Audit +capability.group.audit.title=Audit +capability.DeclareAuditAsRecord.title=Audit declareren als record +capability.EnableDisableAuditByTypes.title=Audit op type uitschakelen inschakelen +capability.DeleteAudit.title=Audit verwijderen +capability.SelectAuditMetadata.title=Metagegevens van audit selecteren +capability.AccessAudit.title=Audit openen +capability.ExportAudit.title=Audit exporteren + +# Security +capability.group.security.title=Beveiliging +capability.CreateModifyDestroyRoles.title=Rollen maken aanpassen vernietigen +capability.CreateModifyDestroyUsersAndGroups.title=Gebruikers en groepen maken aanpassen vernietigen +capability.PasswordControl.title=Wachtwoordbeheer +capability.DisplayRightsReport.title=Rechtenrapport weergeven +capability.ManageAccessControls.title=Groeps- en gebruikersroltoewijzing +capability.ManageAccessRights.title=Rechten beheren + +# Configuration +capability.group.config.title=Configuratie +capability.CreateModifyDestroyFileplanMetadata.title=Metagegevens voor ordeningsplan maken aanpassen vernietigen +capability.CreateModifyDestroyFileplanTypes.title=Ordeningsplantypes maken aanpassen vernietigen +capability.CreateModifyDestroyRecordTypes.title=Recordtypes maken aanpassen vernietigen +capability.CreateAndAssociateSelectionLists.title=Selectielijsten maken en toewijzen +capability.EditSelectionLists.title=Selectielijsten bewerken +capability.CreateModifyDestroyReferenceTypes.title=Verwijzingstypes maken aanpassen vernietigen +capability.AttachRulesToMetadataProperties.title=Regels aan metagegevenseigenschappen koppelen +capability.MakeOptionalParametersMandatory.title=Optionele parameters verplicht maken +capability.MapEmailMetadata.title=Metagegevens e-mail toewijzen + +# Rules +capability.group.rules.title=Regels capability.ManageRules.title=Regels beheren \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_zh_CN.properties index ff101b77f7..c430f0dde0 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service_zh_CN.properties @@ -1,105 +1,105 @@ -# Records -capability.group.records.title=\u8bb0\u5f55 -capability.DeclareRecords.title=\u5b8c\u6210\u8bb0\u5f55 -capability.ViewRecords.title=\u67e5\u770b\u8bb0\u5f55 -capability.UndeclareRecords.title=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55 -capability.CreateRecords.title=\u521b\u5efa\u8bb0\u5f55 -capability.RequestRecordInformation.title=\u8bf7\u6c42\u8bb0\u5f55\u4fe1\u606f -capability.RejectRecords.title=\u62d2\u7edd\u8bb0\u5f55 -capability.FileUnfiledRecords.title=\u5bf9\u672a\u7acb\u5377\u7684\u8bb0\u5f55\u7acb\u5377 -capability.LinkToRecords.title=\u94fe\u63a5\u8bb0\u5f55 -capability.DeleteLinks.title=\u53d6\u6d88\u8bb0\u5f55\u7684\u94fe\u63a5 - -# Metadata Control -capability.group.metadataControl.title=\u5143\u6570\u636e\u63a7\u5236 -capability.EditRecordMetadata.title=\u7f16\u8f91\u8bb0\u5f55\u5143\u6570\u636e -capability.EditDeclaredRecordMetadata.title=\u7f16\u8f91\u5b8c\u6210\u7684\u8bb0\u5f55\u5143\u6570\u636e -capability.EditNonRecordMetadata.title=\u7f16\u8f91\u975e\u8bb0\u5f55\u5143\u6570\u636e -capability.MoveRecords.title=\u79fb\u52a8\u8bb0\u5f55 - -# Folder Control -capability.group.folderControl.title=\u6587\u4ef6\u5939\u63a7\u5236 -capability.CreateModifyDestroyFolders.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u6587\u4ef6\u5939 -capability.CloseFolders.title=\u5173\u95ed\u6587\u4ef6\u5939 -capability.ReOpenFolders.title=\u91cd\u65b0\u6253\u5f00\u6587\u4ef6\u5939 -capability.DeclareRecordsInClosedFolders.title=\u5b8c\u6210\u5df2\u5173\u95ed\u6587\u4ef6\u5939\u4e2d\u7684\u8bb0\u5f55 - -# Vital Records -capability.group.vitalRecords.title=\u6838\u5fc3\u8bb0\u5f55 -capability.UpdateVitalRecordCycleInformation.title=\u66f4\u65b0\u6838\u5fc3\u8bb0\u5f55\u5468\u671f\u4fe1\u606f -capability.CycleVitalRecords.title=\u5468\u671f\u6838\u5fc3\u8bb0\u5f55 -capability.PlanningReviewCycles.title=\u8ba1\u5212\u5ba1\u67e5\u5468\u671f - -# References and Links -capability.group.references.title=\u53c2\u8003 -capability.ChangeOrDeleteReferences.title=\u66f4\u6539\u6216\u5220\u9664\u53c2\u8003 - -# Events -capability.group.events.title=\u4e8b\u4ef6 -capability.CreateModifyDestroyEvents.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u4e8b\u4ef6 -capability.AddModifyEventDates.title=\u6dfb\u52a0\u4fee\u6539\u4e8b\u4ef6\u65e5\u671f - -# Cutoff -capability.group.cutoff.title=\u4e2d\u65ad -capability.ApproveRecordsScheduledForCutoff.title=\u6279\u51c6\u8ba1\u5212\u8981\u4e2d\u65ad\u7684\u8bb0\u5f55 -capability.CreateModifyRecordsInCutoffFolders.title=\u5728\u4e2d\u65ad\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4fee\u6539\u8bb0\u5f55 - -# Disposition and Transfers -capability.group.dispositionAndTransfers.title=\u5904\u7f6e\u548c\u79fb\u4ea4 -capability.UpdateTriggerDates.title=\u66f4\u65b0\u89e6\u53d1\u65e5\u671f -capability.ManuallyChangeDispositionDates.title=\u624b\u52a8\u66f4\u6539\u5904\u7f6e\u65e5\u671f -capability.AuthorizeNominatedTransfers.title=\u6388\u6743\u6307\u5b9a\u79fb\u4ea4 -capability.AuthorizeAllTransfers.title=\u6388\u6743\u6240\u6709\u79fb\u4ea4 -capability.DestroyRecordsScheduledForDestruction.title=\u9500\u6bc1\u8ba1\u5212\u8981\u9500\u6bc1\u7684\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939 -capability.DestroyRecords.title=\u9500\u6bc1\u8bb0\u5f55 -capability.DeleteRecords.title=\u5220\u9664\u8bb0\u5f55 -capability.TriggerAnEvent.title=\u89e6\u53d1\u4e8b\u4ef6 -capability.FileDestructionReport.title=\u7acb\u5377\u9500\u6bc1\u62a5\u544a -capability.FileTransferReport.title=\u7acb\u5377\u79fb\u4ea4\u62a5\u544a -capability.EndRetention.title=\u7ed3\u675f\u4fdd\u7559 - -# Hold Controls -capability.group.holdControls.title=\u4fdd\u5b58\u63a7\u5236 -capability.ExtendRetentionPeriodOrFreeze.title=\u5ef6\u957f\u4fdd\u7559\u671f\u95f4\u6216\u4fdd\u5b58 -capability.Unfreeze.title=\u53d6\u6d88\u4fdd\u5b58 -capability.ViewUpdateReasonsForFreeze.title=\u67e5\u770b\u4fdd\u5b58\u7684\u66f4\u65b0\u539f\u56e0 -capability.CreateHold.title=\u521b\u5efa\u4fdd\u5b58 -capability.AddToHold.title=\u52a0\u5165\u4fdd\u5b58 -capability.RemoveFromHold.title=\u89e3\u9664\u4fdd\u5b58 -capability.FileHoldReport.title=\u7acb\u5377\u4fdd\u5b58\u62a5\u544a -capability.DeleteHold.title=\u5220\u9664\u4fdd\u5b58 -capability.EditHold.title=\u7f16\u8f91\u4fdd\u5b58 - -# Audit -capability.group.audit.title=\u5ba1\u8ba1 -capability.DeclareAuditAsRecord.title=\u5c06\u5ba1\u8ba1\u58f0\u660e\u4e3a\u8bb0\u5f55 -capability.EnableDisableAuditByTypes.title=\u6309\u7c7b\u578b\u542f\u7528\u3001\u7981\u7528\u5ba1\u8ba1 -capability.DeleteAudit.title=\u5220\u9664\u5ba1\u8ba1 -capability.SelectAuditMetadata.title=\u9009\u62e9\u5ba1\u8ba1\u5143\u6570\u636e -capability.AccessAudit.title=\u8bbf\u95ee\u5ba1\u8ba1 -capability.ExportAudit.title=\u5bfc\u51fa\u5ba1\u8ba1 - -# Security -capability.group.security.title=\u5b89\u5168\u6027 -capability.CreateModifyDestroyRoles.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u89d2\u8272 -capability.CreateModifyDestroyUsersAndGroups.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u7528\u6237\u548c\u7ec4 -capability.PasswordControl.title=\u5bc6\u7801\u63a7\u5236 -capability.DisplayRightsReport.title=\u663e\u793a\u6743\u9650\u62a5\u544a -capability.ManageAccessControls.title=\u7ec4\u548c\u7528\u6237\u89d2\u8272\u5206\u914d -capability.ManageAccessRights.title=\u7ba1\u7406\u6743\u9650 - -# Configuration -capability.group.config.title=\u914d\u7f6e -capability.CreateModifyDestroyFileplanMetadata.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5f52\u7c7b\u65b9\u6848\u5143\u6570\u636e -capability.CreateModifyDestroyFileplanTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5f52\u7c7b\u65b9\u6848\u7c7b\u578b -capability.CreateModifyDestroyRecordTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u8bb0\u5f55\u7c7b\u578b -capability.CreateAndAssociateSelectionLists.title=\u521b\u5efa\u548c\u5173\u8054\u9009\u62e9\u5217\u8868 -capability.EditSelectionLists.title=\u7f16\u8f91\u9009\u62e9\u5217\u8868 -capability.CreateModifyDestroyReferenceTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u53c2\u8003\u7c7b\u578b -capability.AttachRulesToMetadataProperties.title=\u5c06\u89c4\u5219\u9644\u52a0\u81f3\u5143\u6570\u636e\u5c5e\u6027 -capability.MakeOptionalParametersMandatory.title=\u5c06\u53ef\u9009\u53c2\u6570\u53d8\u4e3a\u5fc5\u8981\u53c2\u6570 -capability.MapEmailMetadata.title=\u6620\u5c04\u7535\u5b50\u90ae\u4ef6\u5143\u6570\u636e - -# Rules -capability.group.rules.title=\u89c4\u5219 +# Records +capability.group.records.title=\u8bb0\u5f55 +capability.DeclareRecords.title=\u5b8c\u6210\u8bb0\u5f55 +capability.ViewRecords.title=\u67e5\u770b\u8bb0\u5f55 +capability.UndeclareRecords.title=\u91cd\u65b0\u6253\u5f00\u8bb0\u5f55 +capability.CreateRecords.title=\u521b\u5efa\u8bb0\u5f55 +capability.RequestRecordInformation.title=\u8bf7\u6c42\u8bb0\u5f55\u4fe1\u606f +capability.RejectRecords.title=\u62d2\u7edd\u8bb0\u5f55 +capability.FileUnfiledRecords.title=\u5bf9\u672a\u7acb\u5377\u7684\u8bb0\u5f55\u7acb\u5377 +capability.LinkToRecords.title=\u94fe\u63a5\u8bb0\u5f55 +capability.DeleteLinks.title=\u53d6\u6d88\u8bb0\u5f55\u7684\u94fe\u63a5 + +# Metadata Control +capability.group.metadataControl.title=\u5143\u6570\u636e\u63a7\u5236 +capability.EditRecordMetadata.title=\u7f16\u8f91\u8bb0\u5f55\u5143\u6570\u636e +capability.EditDeclaredRecordMetadata.title=\u7f16\u8f91\u5b8c\u6210\u7684\u8bb0\u5f55\u5143\u6570\u636e +capability.EditNonRecordMetadata.title=\u7f16\u8f91\u975e\u8bb0\u5f55\u5143\u6570\u636e +capability.MoveRecords.title=\u79fb\u52a8\u8bb0\u5f55 + +# Folder Control +capability.group.folderControl.title=\u6587\u4ef6\u5939\u63a7\u5236 +capability.CreateModifyDestroyFolders.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u6587\u4ef6\u5939 +capability.CloseFolders.title=\u5173\u95ed\u6587\u4ef6\u5939 +capability.ReOpenFolders.title=\u91cd\u65b0\u6253\u5f00\u6587\u4ef6\u5939 +capability.DeclareRecordsInClosedFolders.title=\u5b8c\u6210\u5df2\u5173\u95ed\u6587\u4ef6\u5939\u4e2d\u7684\u8bb0\u5f55 + +# Vital Records +capability.group.vitalRecords.title=\u6838\u5fc3\u8bb0\u5f55 +capability.UpdateVitalRecordCycleInformation.title=\u66f4\u65b0\u6838\u5fc3\u8bb0\u5f55\u5468\u671f\u4fe1\u606f +capability.CycleVitalRecords.title=\u5468\u671f\u6838\u5fc3\u8bb0\u5f55 +capability.PlanningReviewCycles.title=\u8ba1\u5212\u5ba1\u67e5\u5468\u671f + +# References and Links +capability.group.references.title=\u53c2\u8003 +capability.ChangeOrDeleteReferences.title=\u66f4\u6539\u6216\u5220\u9664\u53c2\u8003 + +# Events +capability.group.events.title=\u4e8b\u4ef6 +capability.CreateModifyDestroyEvents.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u4e8b\u4ef6 +capability.AddModifyEventDates.title=\u6dfb\u52a0\u4fee\u6539\u4e8b\u4ef6\u65e5\u671f + +# Cutoff +capability.group.cutoff.title=\u4e2d\u65ad +capability.ApproveRecordsScheduledForCutoff.title=\u6279\u51c6\u8ba1\u5212\u8981\u4e2d\u65ad\u7684\u8bb0\u5f55 +capability.CreateModifyRecordsInCutoffFolders.title=\u5728\u4e2d\u65ad\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4fee\u6539\u8bb0\u5f55 + +# Disposition and Transfers +capability.group.dispositionAndTransfers.title=\u5904\u7f6e\u548c\u79fb\u4ea4 +capability.UpdateTriggerDates.title=\u66f4\u65b0\u89e6\u53d1\u65e5\u671f +capability.ManuallyChangeDispositionDates.title=\u624b\u52a8\u66f4\u6539\u5904\u7f6e\u65e5\u671f +capability.AuthorizeNominatedTransfers.title=\u6388\u6743\u6307\u5b9a\u79fb\u4ea4 +capability.AuthorizeAllTransfers.title=\u6388\u6743\u6240\u6709\u79fb\u4ea4 +capability.DestroyRecordsScheduledForDestruction.title=\u9500\u6bc1\u8ba1\u5212\u8981\u9500\u6bc1\u7684\u8bb0\u5f55\u6216\u8bb0\u5f55\u6587\u4ef6\u5939 +capability.DestroyRecords.title=\u9500\u6bc1\u8bb0\u5f55 +capability.DeleteRecords.title=\u5220\u9664\u8bb0\u5f55 +capability.TriggerAnEvent.title=\u89e6\u53d1\u4e8b\u4ef6 +capability.FileDestructionReport.title=\u7acb\u5377\u9500\u6bc1\u62a5\u544a +capability.FileTransferReport.title=\u7acb\u5377\u79fb\u4ea4\u62a5\u544a +capability.EndRetention.title=\u7ed3\u675f\u4fdd\u7559 + +# Hold Controls +capability.group.holdControls.title=\u4fdd\u5b58\u63a7\u5236 +capability.ExtendRetentionPeriodOrFreeze.title=\u5ef6\u957f\u4fdd\u7559\u671f\u95f4\u6216\u4fdd\u5b58 +capability.Unfreeze.title=\u53d6\u6d88\u4fdd\u5b58 +capability.ViewUpdateReasonsForFreeze.title=\u67e5\u770b\u4fdd\u5b58\u7684\u66f4\u65b0\u539f\u56e0 +capability.CreateHold.title=\u521b\u5efa\u4fdd\u5b58 +capability.AddToHold.title=\u52a0\u5165\u4fdd\u5b58 +capability.RemoveFromHold.title=\u89e3\u9664\u4fdd\u5b58 +capability.FileHoldReport.title=\u7acb\u5377\u4fdd\u5b58\u62a5\u544a +capability.DeleteHold.title=\u5220\u9664\u4fdd\u5b58 +capability.EditHold.title=\u7f16\u8f91\u4fdd\u5b58 + +# Audit +capability.group.audit.title=\u5ba1\u8ba1 +capability.DeclareAuditAsRecord.title=\u5c06\u5ba1\u8ba1\u58f0\u660e\u4e3a\u8bb0\u5f55 +capability.EnableDisableAuditByTypes.title=\u6309\u7c7b\u578b\u542f\u7528\u3001\u7981\u7528\u5ba1\u8ba1 +capability.DeleteAudit.title=\u5220\u9664\u5ba1\u8ba1 +capability.SelectAuditMetadata.title=\u9009\u62e9\u5ba1\u8ba1\u5143\u6570\u636e +capability.AccessAudit.title=\u8bbf\u95ee\u5ba1\u8ba1 +capability.ExportAudit.title=\u5bfc\u51fa\u5ba1\u8ba1 + +# Security +capability.group.security.title=\u5b89\u5168\u6027 +capability.CreateModifyDestroyRoles.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u89d2\u8272 +capability.CreateModifyDestroyUsersAndGroups.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u7528\u6237\u548c\u7ec4 +capability.PasswordControl.title=\u5bc6\u7801\u63a7\u5236 +capability.DisplayRightsReport.title=\u663e\u793a\u6743\u9650\u62a5\u544a +capability.ManageAccessControls.title=\u7ec4\u548c\u7528\u6237\u89d2\u8272\u5206\u914d +capability.ManageAccessRights.title=\u7ba1\u7406\u6743\u9650 + +# Configuration +capability.group.config.title=\u914d\u7f6e +capability.CreateModifyDestroyFileplanMetadata.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5f52\u7c7b\u65b9\u6848\u5143\u6570\u636e +capability.CreateModifyDestroyFileplanTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u5f52\u7c7b\u65b9\u6848\u7c7b\u578b +capability.CreateModifyDestroyRecordTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u8bb0\u5f55\u7c7b\u578b +capability.CreateAndAssociateSelectionLists.title=\u521b\u5efa\u548c\u5173\u8054\u9009\u62e9\u5217\u8868 +capability.EditSelectionLists.title=\u7f16\u8f91\u9009\u62e9\u5217\u8868 +capability.CreateModifyDestroyReferenceTypes.title=\u521b\u5efa\u4fee\u6539\u9500\u6bc1\u53c2\u8003\u7c7b\u578b +capability.AttachRulesToMetadataProperties.title=\u5c06\u89c4\u5219\u9644\u52a0\u81f3\u5143\u6570\u636e\u5c5e\u6027 +capability.MakeOptionalParametersMandatory.title=\u5c06\u53ef\u9009\u53c2\u6570\u53d8\u4e3a\u5fc5\u8981\u53c2\u6570 +capability.MapEmailMetadata.title=\u6620\u5c04\u7535\u5b50\u90ae\u4ef6\u5143\u6570\u636e + +# Rules +capability.group.rules.title=\u89c4\u5219 capability.ManageRules.title=\u7ba1\u7406\u89c4\u5219 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service.properties index 4adb771e20..5ba8e758ce 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Records due for Review Notification -notification.superseded.subject=Record Superseded Notification +notification.dueforreview.subject=Records due for Review Notification +notification.superseded.subject=Record Superseded Notification notification.rejected.subject=Record Rejected Notification \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_de.properties index d4fd2a292f..516e806803 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_de.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Benachrichtigung bei Records mit f\u00e4lliger \u00dcberpr\u00fcfung -notification.superseded.subject=Benachrichtigung bei abgel\u00f6stem Record +notification.dueforreview.subject=Benachrichtigung bei Records mit f\u00e4lliger \u00dcberpr\u00fcfung +notification.superseded.subject=Benachrichtigung bei abgel\u00f6stem Record notification.rejected.subject=Benachrichtigung bei abgelehntem Record \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_es.properties index b48cd5681c..dc443b8c59 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_es.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Documentos de archivo pendientes de notificaci\u00f3n de revisi\u00f3n -notification.superseded.subject=Notificaci\u00f3n de documento de archivo reemplazada +notification.dueforreview.subject=Documentos de archivo pendientes de notificaci\u00f3n de revisi\u00f3n +notification.superseded.subject=Notificaci\u00f3n de documento de archivo reemplazada notification.rejected.subject=Notificaci\u00f3n de documento de archivo rechazada \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_fr.properties index 73845f54b1..f342374560 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_fr.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Documents d'archives arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification -notification.superseded.subject=Le document d'archives a remplac\u00e9 la notification +notification.dueforreview.subject=Documents d'archives arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification +notification.superseded.subject=Le document d'archives a remplac\u00e9 la notification notification.rejected.subject=Le document d'archives a rejet\u00e9 la notification \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_it.properties index f66191bcba..860d0b3493 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_it.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Notifica record da revisionare -notification.superseded.subject=Notifica record sostituito +notification.dueforreview.subject=Notifica record da revisionare +notification.superseded.subject=Notifica record sostituito notification.rejected.subject=Notifica record respinto \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_ja.properties index b1986f835e..0483702dde 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_ja.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u901a\u77e5\u671f\u9650 -notification.superseded.subject=\u30ec\u30b3\u30fc\u30c9\u306e\u4ee3\u66ff\u901a\u77e5 +notification.dueforreview.subject=\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u901a\u77e5\u671f\u9650 +notification.superseded.subject=\u30ec\u30b3\u30fc\u30c9\u306e\u4ee3\u66ff\u901a\u77e5 notification.rejected.subject=\u30ec\u30b3\u30fc\u30c9\u306e\u5374\u4e0b\u901a\u77e5 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_nl.properties index 278210cbba..4faef1f017 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_nl.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=Melding Records gereed voor revisie -notification.superseded.subject=Melding Record vervangen +notification.dueforreview.subject=Melding Records gereed voor revisie +notification.superseded.subject=Melding Record vervangen notification.rejected.subject=Melding Record geweigerd \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_zh_CN.properties index 3ec73c184a..b6a0599398 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/notification-service_zh_CN.properties @@ -1,3 +1,3 @@ -notification.dueforreview.subject=\u8bb0\u5f55\u5ba1\u67e5\u5230\u671f\u901a\u77e5 -notification.superseded.subject=\u8bb0\u5f55\u88ab\u53d6\u4ee3\u901a\u77e5 +notification.dueforreview.subject=\u8bb0\u5f55\u5ba1\u67e5\u5230\u671f\u901a\u77e5 +notification.superseded.subject=\u8bb0\u5f55\u88ab\u53d6\u4ee3\u901a\u77e5 notification.rejected.subject=\u8bb0\u5f55\u88ab\u62d2\u7edd\u901a\u77e5 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties index 70f6712de5..f53f066f9d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=Content can't be added to a record container. Use record folders to file content. -rm.service.update-disposition-action-def=The disposition action definition can't be updated, because an update is being published. -rm.service.set-id=The identifier property value of the object {0} is read-only so can't be set. -rm.service.path-node=Unable to get path. (nodeRef={0}) -rm.service.invalid-rm-node=Invalid records management node, because aspect {0} is not present. -rm.service.no-root=Unable to find records management root. -rm.service.dup-root=Can't create the records management root, because there's one already exists in this hierarchy. -rm.service.root-type=Can't create the records management root, because type {0} is not a sub-type of rm:recordsManagementRootContainer. -rm.service.container-parent-type=Can't create records management container, because parent was not sub-type of rm:recordsManagement (parentType={0}) -rm.service.container-type=Can't create records management container, because type {0} is not a sub-type of rm:recordsManagementContainer. -rm.service.container-expected=Node reference to a rm:recordsManagementContainer node expected. -rm.service.record-folder-expected=Node reference to a rm:recordFolder node expected. -rm.service.parent-record-folder-root=Can't create a record folder, because the parent is a records management root. -rm.service.parent-record-folder-type=Can't create record folder, because the parent was not sub-type of rm:recordsManagementContainer. (parentType={0}) -rm.service.record-folder-type=Can't create record folder, because the provided type is not a sub-type of rm:recordFolder. (type={0}) -rm.service.not-record=The node {0} is not a record. -rm.service.vital-def-missing=Vital record definition aspect is not present on node. (nodeRef={0}) -rm.service.close-record-folder-not-folder=The record folder couldn't be closed because it's not defined as a record folder.(nodeRef={0}) -rm.service.node-has-aspect=The node {0} has already the aspect {1}. -rm.service.final-version=Final +rm.service.error-add-content-container=Content can't be added to a record container. Use record folders to file content. +rm.service.update-disposition-action-def=The disposition action definition can't be updated, because an update is being published. +rm.service.set-id=The identifier property value of the object {0} is read-only so can't be set. +rm.service.path-node=Unable to get path. (nodeRef={0}) +rm.service.invalid-rm-node=Invalid records management node, because aspect {0} is not present. +rm.service.no-root=Unable to find records management root. +rm.service.dup-root=Can't create the records management root, because there's one already exists in this hierarchy. +rm.service.root-type=Can't create the records management root, because type {0} is not a sub-type of rm:recordsManagementRootContainer. +rm.service.container-parent-type=Can't create records management container, because parent was not sub-type of rm:recordsManagement (parentType={0}) +rm.service.container-type=Can't create records management container, because type {0} is not a sub-type of rm:recordsManagementContainer. +rm.service.container-expected=Node reference to a rm:recordsManagementContainer node expected. +rm.service.record-folder-expected=Node reference to a rm:recordFolder node expected. +rm.service.parent-record-folder-root=Can't create a record folder, because the parent is a records management root. +rm.service.parent-record-folder-type=Can't create record folder, because the parent was not sub-type of rm:recordsManagementContainer. (parentType={0}) +rm.service.record-folder-type=Can't create record folder, because the provided type is not a sub-type of rm:recordFolder. (type={0}) +rm.service.not-record=The node {0} is not a record. +rm.service.vital-def-missing=Vital record definition aspect is not present on node. (nodeRef={0}) +rm.service.close-record-folder-not-folder=The record folder couldn't be closed because it's not defined as a record folder.(nodeRef={0}) +rm.service.node-has-aspect=The node {0} has already the aspect {1}. +rm.service.final-version=Final rm.service.final-version-description=The final archived record version \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_de.properties index bf286e2463..e7768fcf2f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_de.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=Inhalt kann einem Record-Container nicht hinzugef\u00fcgt werden. Verwenden Sie Record-Ordner zur Inhaltsablage. -rm.service.update-disposition-action-def=Die Definition der Entsorgungsaktion kann nicht aktualisiert werden, da derzeit eine Aktualisierung ver\u00f6ffentlicht wird. -rm.service.set-id=Der ID-Eigenschaftenwert des Objekts {0} ist schreibgesch\u00fctzt; er kann also nicht festgelegt werden. -rm.service.path-node=Pfad kann nicht ermittelt werden. (nodeRef={0}) -rm.service.invalid-rm-node=Records Management Knoten ung\u00fcltig, da Aspekt {0} nicht vorhanden ist. -rm.service.no-root=Records Management Root kann nicht gefunden werden. -rm.service.dup-root=Records Management Root kann nicht erstellt werden, da bereits eine in dieser Hierarchie vorhanden ist. -rm.service.root-type=Records Management Root kann nicht erstellt werden, da Typ {0} kein Subtyp von rm:recordsManagementRootContainer ist. -rm.service.container-parent-type=Records Management Container kann nicht erstellt werden, da Elternobjekt kein Subtyp von rm:recordsManagement (parentType={0}) ist. -rm.service.container-type=Records Management Container kann nicht erstellt werden, da Typ {0} kein Subtyp von rm:recordsManagementContainer ist. -rm.service.container-expected=Knotenreferenz zu einem rm:recordsManagementContainer-Knoten erwartet. -rm.service.record-folder-expected=Knotenreferenz zu einem rm:recordFolder-Knoten erwartet. -rm.service.parent-record-folder-root=Record-Ordner kann nicht erstellt werden, da es sich bei dem Elternobjekt um eine Records Management Root handelt. -rm.service.parent-record-folder-type=Record-Ordner kann nicht erstellt werden, da das Elternobjekt kein Subtyp von rm:recordsManagementContainer ist. (parentType={0}) -rm.service.record-folder-type=Record-Ordner kann nicht erstellt werden, da der angegebene Typ kein Subtyp von rm:recordFolder ist. (type={0}) -rm.service.not-record=Knoten {0} ist kein Record. -rm.service.vital-def-missing=Definitionsaspekt von besonders relevantem Record ist auf dem Knoten nicht vorhanden. (nodeRef={0}) -rm.service.close-record-folder-not-folder=Der Record-Ordner konnte nicht geschlossen werden, da er nicht als Record-Ordner definiert ist. (nodeRef={0}) -rm.service.node-has-aspect=Der Knoten {0} hat bereits den Aspekt {1}. -rm.service.final-version=Endg\u00fcltig +rm.service.error-add-content-container=Inhalt kann einem Record-Container nicht hinzugef\u00fcgt werden. Verwenden Sie Record-Ordner zur Inhaltsablage. +rm.service.update-disposition-action-def=Die Definition der Entsorgungsaktion kann nicht aktualisiert werden, da derzeit eine Aktualisierung ver\u00f6ffentlicht wird. +rm.service.set-id=Der ID-Eigenschaftenwert des Objekts {0} ist schreibgesch\u00fctzt; er kann also nicht festgelegt werden. +rm.service.path-node=Pfad kann nicht ermittelt werden. (nodeRef={0}) +rm.service.invalid-rm-node=Records Management Knoten ung\u00fcltig, da Aspekt {0} nicht vorhanden ist. +rm.service.no-root=Records Management Root kann nicht gefunden werden. +rm.service.dup-root=Records Management Root kann nicht erstellt werden, da bereits eine in dieser Hierarchie vorhanden ist. +rm.service.root-type=Records Management Root kann nicht erstellt werden, da Typ {0} kein Subtyp von rm:recordsManagementRootContainer ist. +rm.service.container-parent-type=Records Management Container kann nicht erstellt werden, da Elternobjekt kein Subtyp von rm:recordsManagement (parentType={0}) ist. +rm.service.container-type=Records Management Container kann nicht erstellt werden, da Typ {0} kein Subtyp von rm:recordsManagementContainer ist. +rm.service.container-expected=Knotenreferenz zu einem rm:recordsManagementContainer-Knoten erwartet. +rm.service.record-folder-expected=Knotenreferenz zu einem rm:recordFolder-Knoten erwartet. +rm.service.parent-record-folder-root=Record-Ordner kann nicht erstellt werden, da es sich bei dem Elternobjekt um eine Records Management Root handelt. +rm.service.parent-record-folder-type=Record-Ordner kann nicht erstellt werden, da das Elternobjekt kein Subtyp von rm:recordsManagementContainer ist. (parentType={0}) +rm.service.record-folder-type=Record-Ordner kann nicht erstellt werden, da der angegebene Typ kein Subtyp von rm:recordFolder ist. (type={0}) +rm.service.not-record=Knoten {0} ist kein Record. +rm.service.vital-def-missing=Definitionsaspekt von besonders relevantem Record ist auf dem Knoten nicht vorhanden. (nodeRef={0}) +rm.service.close-record-folder-not-folder=Der Record-Ordner konnte nicht geschlossen werden, da er nicht als Record-Ordner definiert ist. (nodeRef={0}) +rm.service.node-has-aspect=Der Knoten {0} hat bereits den Aspekt {1}. +rm.service.final-version=Endg\u00fcltig rm.service.final-version-description=Die endg\u00fcltige archivierte Version des Records \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_es.properties index 445a34aa97..44d5f1068a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_es.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=No se puede agregar contenido a un contenedor de documentos de archivo. Utilice carpetas de documentos de archivo para archivar contenido. -rm.service.update-disposition-action-def=No se puede actualizar la definici\u00f3n de acciones de disposici\u00f3n porque se est\u00e1 publicando una actualizaci\u00f3n. -rm.service.set-id=No se puede establecer el valor de la propiedad identificadora {0} porque es de solo lectura. -rm.service.path-node=No se puede obtener ruta. (nodeRef={0}) -rm.service.invalid-rm-node=El nodo de gesti\u00f3n de documentos de archivo no es v\u00e1lido porque el aspecto {0} no est\u00e1 presente. -rm.service.no-root=No se puede encontrar una ra\u00edz de gesti\u00f3n de documentos de archivo. -rm.service.dup-root=No se puede crear una ra\u00edz de gesti\u00f3n de documentos de archivo porque ya existe una en esta jerarqu\u00eda. -rm.service.root-type=No se puede crear una ra\u00edz de gesti\u00f3n de documentos de archivo porque el tipo {0} no es un subtipo de rm:recordsManagementRootContainer. -rm.service.container-parent-type=No se puede crear un contenedor de gesti\u00f3n de documentos de archivo porque el padre no era un subtipo de rm:recordsManagement (parentType={0}). -rm.service.container-type=No se puede crear un contenedor de gesti\u00f3n de documentos de archivo porque el tipo {0} no es un subtipo de rm:recordsManagementContainer. -rm.service.container-expected=Se espera un nodo de referencia en un nodo rm:recordsManagementContainer. -rm.service.record-folder-expected=Se espera un nodo de referencia en un nodo rm:recordFolder. -rm.service.parent-record-folder-root=No se puede crear una carpeta de documentos de archivo porque el padre es una ra\u00edz de gesti\u00f3n de documentos de archivo. -rm.service.parent-record-folder-type=No se puede crear una carpeta de documentos de archivo porque el padre no era un subtipo de rm:recordsManagementContainer. (parentType={0}) -rm.service.record-folder-type=No se puede crear una carpeta de documentos de archivo porque el tipo proporcionado no es un subtipo de rm:recordFolder. (type={0}) -rm.service.not-record=El nodo {0} no es un documento de archivo. -rm.service.vital-def-missing=El aspecto de definici\u00f3n de documento de archivo vital no est\u00e1 presenta en el nodo. (nodeRef={0}) -rm.service.close-record-folder-not-folder=No se pudo cerrar la carpeta de documentos de archivo porque no est\u00e1 definida como una carpeta de documentos de archivo.(nodeRef={0}) -rm.service.node-has-aspect=El nodo {0} ya tiene el aspecto {1}. -rm.service.final-version=Final +rm.service.error-add-content-container=No se puede agregar contenido a un contenedor de documentos de archivo. Utilice carpetas de documentos de archivo para archivar contenido. +rm.service.update-disposition-action-def=No se puede actualizar la definici\u00f3n de acciones de disposici\u00f3n porque se est\u00e1 publicando una actualizaci\u00f3n. +rm.service.set-id=No se puede establecer el valor de la propiedad identificadora {0} porque es de solo lectura. +rm.service.path-node=No se puede obtener ruta. (nodeRef={0}) +rm.service.invalid-rm-node=El nodo de gesti\u00f3n de documentos de archivo no es v\u00e1lido porque el aspecto {0} no est\u00e1 presente. +rm.service.no-root=No se puede encontrar una ra\u00edz de gesti\u00f3n de documentos de archivo. +rm.service.dup-root=No se puede crear una ra\u00edz de gesti\u00f3n de documentos de archivo porque ya existe una en esta jerarqu\u00eda. +rm.service.root-type=No se puede crear una ra\u00edz de gesti\u00f3n de documentos de archivo porque el tipo {0} no es un subtipo de rm:recordsManagementRootContainer. +rm.service.container-parent-type=No se puede crear un contenedor de gesti\u00f3n de documentos de archivo porque el padre no era un subtipo de rm:recordsManagement (parentType={0}). +rm.service.container-type=No se puede crear un contenedor de gesti\u00f3n de documentos de archivo porque el tipo {0} no es un subtipo de rm:recordsManagementContainer. +rm.service.container-expected=Se espera un nodo de referencia en un nodo rm:recordsManagementContainer. +rm.service.record-folder-expected=Se espera un nodo de referencia en un nodo rm:recordFolder. +rm.service.parent-record-folder-root=No se puede crear una carpeta de documentos de archivo porque el padre es una ra\u00edz de gesti\u00f3n de documentos de archivo. +rm.service.parent-record-folder-type=No se puede crear una carpeta de documentos de archivo porque el padre no era un subtipo de rm:recordsManagementContainer. (parentType={0}) +rm.service.record-folder-type=No se puede crear una carpeta de documentos de archivo porque el tipo proporcionado no es un subtipo de rm:recordFolder. (type={0}) +rm.service.not-record=El nodo {0} no es un documento de archivo. +rm.service.vital-def-missing=El aspecto de definici\u00f3n de documento de archivo vital no est\u00e1 presenta en el nodo. (nodeRef={0}) +rm.service.close-record-folder-not-folder=No se pudo cerrar la carpeta de documentos de archivo porque no est\u00e1 definida como una carpeta de documentos de archivo.(nodeRef={0}) +rm.service.node-has-aspect=El nodo {0} ya tiene el aspecto {1}. +rm.service.final-version=Final rm.service.final-version-description=La versi\u00f3n final del documento de archivo archivado \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_fr.properties index 495b595c4c..5688a1d7c4 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_fr.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=Le contenu n'a pu \u00eatre ajout\u00e9 \u00e0 un conteneur de documents d'archives. Utilisez des dossiers d'archives pour archiver le contenu. -rm.service.update-disposition-action-def=Impossible de mettre \u00e0 jour la d\u00e9finition de l'action de disposition car une mise \u00e0 jour est en train d'\u00eatre publi\u00e9e. -rm.service.set-id=La valeur identifier property de l''objet {0}.est en lecture seule et ne peut donc \u00eatre d\u00e9finie. -rm.service.path-node=Impossible d''obtenir le chemin. (nodeRef={0}) -rm.service.invalid-rm-node=N\u0153ud non valide de gestion des archives car l''aspect {0} n''est pas pr\u00e9sent. -rm.service.no-root=Impossible de trouver la racine du site de gestion des archives. -rm.service.dup-root=Impossible de cr\u00e9er la racine du site de gestion des archives car il en existe d\u00e9j\u00e0 une dans cette hi\u00e9rarchie. -rm.service.root-type=Impossible de cr\u00e9er la racine du site de gestion des archives car le type {0} n''est pas un sous-type de rm:recordsManagementRootContainer. -rm.service.container-parent-type=Impossible de cr\u00e9er le conteneur de gestion des archives car le parent n''\u00e9tait pas un sous-type de rm:recordsManagement (parentType={0}) -rm.service.container-type=Impossible de cr\u00e9er le conteneur de gestion des archives car le type {0} n''est pas un sous-type de rm:recordsManagementContainer. -rm.service.container-expected=La r\u00e9f\u00e9rence \u00e0 un n\u0153ud rm:recordsManagementContainer \u00e9tait attendue. -rm.service.record-folder-expected=La r\u00e9f\u00e9rence \u00e0 un n\u0153ud rm:recordFolder \u00e9tait attendue. -rm.service.parent-record-folder-root=Impossible de cr\u00e9er un dossier d'archives car le parent est une racine du site de gestion des archives. -rm.service.parent-record-folder-type=Impossible de cr\u00e9er un dossier d''archives car le parent n''\u00e9tait pas un sous-type de rm:recordsManagementContainer. (parentType={0}) -rm.service.record-folder-type=Impossible de cr\u00e9er un dossier d''archives car le type fourni n''est pas un sous-type de rm:recordFolder. (type={0}) -rm.service.not-record=Le n\u0153ud {0} n''est pas un document d''archives. -rm.service.vital-def-missing=L''aspect de d\u00e9finition de document d''archives essentiel n''est pas pr\u00e9sent sur le n\u0153ud. (nodeRef={0}) -rm.service.close-record-folder-not-folder=Le dossier d''archives n''a pas pu \u00eatre ferm\u00e9, car il n''est pas d\u00e9fini comme dossier d''archives.(nodeRef={0}) -rm.service.node-has-aspect=Le n\u0153ud {0} a d\u00e9j\u00e0 l''aspect {1}. -rm.service.final-version=Finale +rm.service.error-add-content-container=Le contenu n'a pu \u00eatre ajout\u00e9 \u00e0 un conteneur de documents d'archives. Utilisez des dossiers d'archives pour archiver le contenu. +rm.service.update-disposition-action-def=Impossible de mettre \u00e0 jour la d\u00e9finition de l'action de disposition car une mise \u00e0 jour est en train d'\u00eatre publi\u00e9e. +rm.service.set-id=La valeur identifier property de l''objet {0}.est en lecture seule et ne peut donc \u00eatre d\u00e9finie. +rm.service.path-node=Impossible d''obtenir le chemin. (nodeRef={0}) +rm.service.invalid-rm-node=N\u0153ud non valide de gestion des archives car l''aspect {0} n''est pas pr\u00e9sent. +rm.service.no-root=Impossible de trouver la racine du site de gestion des archives. +rm.service.dup-root=Impossible de cr\u00e9er la racine du site de gestion des archives car il en existe d\u00e9j\u00e0 une dans cette hi\u00e9rarchie. +rm.service.root-type=Impossible de cr\u00e9er la racine du site de gestion des archives car le type {0} n''est pas un sous-type de rm:recordsManagementRootContainer. +rm.service.container-parent-type=Impossible de cr\u00e9er le conteneur de gestion des archives car le parent n''\u00e9tait pas un sous-type de rm:recordsManagement (parentType={0}) +rm.service.container-type=Impossible de cr\u00e9er le conteneur de gestion des archives car le type {0} n''est pas un sous-type de rm:recordsManagementContainer. +rm.service.container-expected=La r\u00e9f\u00e9rence \u00e0 un n\u0153ud rm:recordsManagementContainer \u00e9tait attendue. +rm.service.record-folder-expected=La r\u00e9f\u00e9rence \u00e0 un n\u0153ud rm:recordFolder \u00e9tait attendue. +rm.service.parent-record-folder-root=Impossible de cr\u00e9er un dossier d'archives car le parent est une racine du site de gestion des archives. +rm.service.parent-record-folder-type=Impossible de cr\u00e9er un dossier d''archives car le parent n''\u00e9tait pas un sous-type de rm:recordsManagementContainer. (parentType={0}) +rm.service.record-folder-type=Impossible de cr\u00e9er un dossier d''archives car le type fourni n''est pas un sous-type de rm:recordFolder. (type={0}) +rm.service.not-record=Le n\u0153ud {0} n''est pas un document d''archives. +rm.service.vital-def-missing=L''aspect de d\u00e9finition de document d''archives essentiel n''est pas pr\u00e9sent sur le n\u0153ud. (nodeRef={0}) +rm.service.close-record-folder-not-folder=Le dossier d''archives n''a pas pu \u00eatre ferm\u00e9, car il n''est pas d\u00e9fini comme dossier d''archives.(nodeRef={0}) +rm.service.node-has-aspect=Le n\u0153ud {0} a d\u00e9j\u00e0 l''aspect {1}. +rm.service.final-version=Finale rm.service.final-version-description=Version finale du document archiv\u00e9 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_it.properties index bcbc46434d..2a0b13e1e9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_it.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=Impossibile aggiungere il contenuto a un contenitore di record. Utilizza le cartelle di record per archiviare il contenuto. -rm.service.update-disposition-action-def=Impossibile aggiornare la definizione dell'azione di disposizione, poich\u00e9 \u00e8 stato pubblicato un aggiornamento. -rm.service.set-id=Impossibile impostare il valore identificativo della propriet\u00e0 dell''oggetto {0} perch\u00e9 di sola lettura. -rm.service.path-node=Impossibile ottenere il percorso. (nodeRef={0}) -rm.service.invalid-rm-node=Nodo di gestione dei record non valido, poich\u00e9 non \u00e8 presente l''aspetto {0}. -rm.service.no-root=Impossibile trovare radice di gestione dei record. -rm.service.dup-root=Impossibile creare la radice di gestione dei record, poich\u00e9 ne esiste gi\u00e0 una all'interno della gerarchia. -rm.service.root-type=Impossibile creare la radice di gestione dei record, poich\u00e9 il tipo {0} non \u00e8 un sottotipo di rm:recordsManagementRootContainer. -rm.service.container-parent-type=Impossibile creare il contenitore di gestione dei record, poich\u00e9 quello superiore non \u00e8 un sottotipo di rm:recordsManagement (parentType={0}) -rm.service.container-type=Impossibile creare il contenitore di gestione dei record, poich\u00e9 il tipo {0} non \u00e8 un sottotipo di rm:recordsManagementContainer. -rm.service.container-expected=Riferimento nodo a un nodo rm:recordsManagementContainer previsto. -rm.service.record-folder-expected=Riferimento nodo a un nodo rm:recordFolder previsto. -rm.service.parent-record-folder-root=Impossibile creare una cartella di record, poich\u00e9 quella superiore \u00e8 una radice di gestione dei record. -rm.service.parent-record-folder-type=Impossibile creare una cartella di record, poich\u00e9 quella superiore non \u00e8 un sottotipo di rm:recordsManagementContainer. (parentType={0}) -rm.service.record-folder-type=Impossibile creare una cartella di record, poich\u00e9 il tipo fornito non \u00e8 un sottotipo di rm:recordFolder. (type={0}) -rm.service.not-record=Il nodo {0} non \u00e8 un record. -rm.service.vital-def-missing=L''aspetto di definizione di record fondamentale non \u00e8 presente su nodo. (nodeRef={0}) -rm.service.close-record-folder-not-folder=Non \u00e8 stato possibile chiudere la cartella di record, poich\u00e9 non \u00e8 definita come cartella di record.(nodeRef={0}) -rm.service.node-has-aspect=Il nodo {0} presenta gi\u00e0 l''aspetto {1}. -rm.service.final-version=Finale +rm.service.error-add-content-container=Impossibile aggiungere il contenuto a un contenitore di record. Utilizza le cartelle di record per archiviare il contenuto. +rm.service.update-disposition-action-def=Impossibile aggiornare la definizione dell'azione di disposizione, poich\u00e9 \u00e8 stato pubblicato un aggiornamento. +rm.service.set-id=Impossibile impostare il valore identificativo della propriet\u00e0 dell''oggetto {0} perch\u00e9 di sola lettura. +rm.service.path-node=Impossibile ottenere il percorso. (nodeRef={0}) +rm.service.invalid-rm-node=Nodo di gestione dei record non valido, poich\u00e9 non \u00e8 presente l''aspetto {0}. +rm.service.no-root=Impossibile trovare radice di gestione dei record. +rm.service.dup-root=Impossibile creare la radice di gestione dei record, poich\u00e9 ne esiste gi\u00e0 una all'interno della gerarchia. +rm.service.root-type=Impossibile creare la radice di gestione dei record, poich\u00e9 il tipo {0} non \u00e8 un sottotipo di rm:recordsManagementRootContainer. +rm.service.container-parent-type=Impossibile creare il contenitore di gestione dei record, poich\u00e9 quello superiore non \u00e8 un sottotipo di rm:recordsManagement (parentType={0}) +rm.service.container-type=Impossibile creare il contenitore di gestione dei record, poich\u00e9 il tipo {0} non \u00e8 un sottotipo di rm:recordsManagementContainer. +rm.service.container-expected=Riferimento nodo a un nodo rm:recordsManagementContainer previsto. +rm.service.record-folder-expected=Riferimento nodo a un nodo rm:recordFolder previsto. +rm.service.parent-record-folder-root=Impossibile creare una cartella di record, poich\u00e9 quella superiore \u00e8 una radice di gestione dei record. +rm.service.parent-record-folder-type=Impossibile creare una cartella di record, poich\u00e9 quella superiore non \u00e8 un sottotipo di rm:recordsManagementContainer. (parentType={0}) +rm.service.record-folder-type=Impossibile creare una cartella di record, poich\u00e9 il tipo fornito non \u00e8 un sottotipo di rm:recordFolder. (type={0}) +rm.service.not-record=Il nodo {0} non \u00e8 un record. +rm.service.vital-def-missing=L''aspetto di definizione di record fondamentale non \u00e8 presente su nodo. (nodeRef={0}) +rm.service.close-record-folder-not-folder=Non \u00e8 stato possibile chiudere la cartella di record, poich\u00e9 non \u00e8 definita come cartella di record.(nodeRef={0}) +rm.service.node-has-aspect=Il nodo {0} presenta gi\u00e0 l''aspetto {1}. +rm.service.final-version=Finale rm.service.final-version-description=Versione del record archiviata finale \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_ja.properties index fca3a7c66f..c83bae3098 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_ja.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30c6\u30ca\u30fc\u306b\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3002 \u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u6574\u7406\u4fdd\u7ba1\u3057\u307e\u3059\u3002 -rm.service.update-disposition-action-def=\u66f4\u65b0\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\u3092\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.set-id=\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 {0} \u306e ID \u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u306f\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306a\u306e\u3067\u3001\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.path-node=\u30d1\u30b9\u3092\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3002 (nodeRef={0}) -rm.service.invalid-rm-node=\u30a2\u30b9\u30da\u30af\u30c8 {0} \u304c\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001\u7121\u52b9\u306a\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30ce\u30fc\u30c9\u3067\u3059\u3002 -rm.service.no-root=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 -rm.service.dup-root=\u3053\u306e\u968e\u5c64\u306b\u3059\u3067\u306b\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u304c\u5b58\u5728\u3059\u308b\u305f\u3081\u3001\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.root-type=\u30bf\u30a4\u30d7 {0} \u306f\u3001rm:recordsManagementRootContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.container-parent-type=\u89aa\u304c rm:recordsManagement (parentType={0}) \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.container-type=\u30bf\u30a4\u30d7 {0} \u306f\u3001rm:recordsManagementContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.container-expected=rm:recordsManagementContainer \u30ce\u30fc\u30c9\u3078\u306e\u30ce\u30fc\u30c9\u53c2\u7167\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u3002 -rm.service.record-folder-expected=rm:recordFolder \u30ce\u30fc\u30c9\u3078\u306e\u30ce\u30fc\u30c9\u53c2\u7167\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u3002 -rm.service.parent-record-folder-root=\u89aa\u304c\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u306a\u306e\u3067\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 -rm.service.parent-record-folder-type=\u89aa\u304c rm:recordsManagementContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 (parentType={0}) -rm.service.record-folder-type=\u6307\u5b9a\u3055\u308c\u305f\u30bf\u30a4\u30d7\u304c rm:recordFolder \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 (type={0}) -rm.service.not-record=\u30ce\u30fc\u30c9 {0} \u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 -rm.service.vital-def-missing=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u30a2\u30b9\u30da\u30af\u30c8\u304c\u30ce\u30fc\u30c9\u306b\u5b58\u5728\u3057\u307e\u305b\u3093\u3002 (nodeRef={0}) -rm.service.close-record-folder-not-folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={0}) -rm.service.node-has-aspect=\u30ce\u30fc\u30c9 {0} \u306b\u306f\u3059\u3067\u306b\u30a2\u30b9\u30da\u30af\u30c8 {1} \u304c\u3042\u308a\u307e\u3059\u3002 -rm.service.final-version=\u6700\u7d42\u7248 +rm.service.error-add-content-container=\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30c6\u30ca\u30fc\u306b\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3002 \u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u6574\u7406\u4fdd\u7ba1\u3057\u307e\u3059\u3002 +rm.service.update-disposition-action-def=\u66f4\u65b0\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\u3092\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.set-id=\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 {0} \u306e ID \u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u306f\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306a\u306e\u3067\u3001\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.path-node=\u30d1\u30b9\u3092\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3002 (nodeRef={0}) +rm.service.invalid-rm-node=\u30a2\u30b9\u30da\u30af\u30c8 {0} \u304c\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001\u7121\u52b9\u306a\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30ce\u30fc\u30c9\u3067\u3059\u3002 +rm.service.no-root=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002 +rm.service.dup-root=\u3053\u306e\u968e\u5c64\u306b\u3059\u3067\u306b\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u304c\u5b58\u5728\u3059\u308b\u305f\u3081\u3001\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.root-type=\u30bf\u30a4\u30d7 {0} \u306f\u3001rm:recordsManagementRootContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.container-parent-type=\u89aa\u304c rm:recordsManagement (parentType={0}) \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.container-type=\u30bf\u30a4\u30d7 {0} \u306f\u3001rm:recordsManagementContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.container-expected=rm:recordsManagementContainer \u30ce\u30fc\u30c9\u3078\u306e\u30ce\u30fc\u30c9\u53c2\u7167\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u3002 +rm.service.record-folder-expected=rm:recordFolder \u30ce\u30fc\u30c9\u3078\u306e\u30ce\u30fc\u30c9\u53c2\u7167\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u3002 +rm.service.parent-record-folder-root=\u89aa\u304c\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u306a\u306e\u3067\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 +rm.service.parent-record-folder-type=\u89aa\u304c rm:recordsManagementContainer \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 (parentType={0}) +rm.service.record-folder-type=\u6307\u5b9a\u3055\u308c\u305f\u30bf\u30a4\u30d7\u304c rm:recordFolder \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002 (type={0}) +rm.service.not-record=\u30ce\u30fc\u30c9 {0} \u306f\u30ec\u30b3\u30fc\u30c9\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 +rm.service.vital-def-missing=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9\u30a2\u30b9\u30da\u30af\u30c8\u304c\u30ce\u30fc\u30c9\u306b\u5b58\u5728\u3057\u307e\u305b\u3093\u3002 (nodeRef={0}) +rm.service.close-record-folder-not-folder=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3092\u9589\u3058\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(nodeRef={0}) +rm.service.node-has-aspect=\u30ce\u30fc\u30c9 {0} \u306b\u306f\u3059\u3067\u306b\u30a2\u30b9\u30da\u30af\u30c8 {1} \u304c\u3042\u308a\u307e\u3059\u3002 +rm.service.final-version=\u6700\u7d42\u7248 rm.service.final-version-description=\u30a2\u30fc\u30ab\u30a4\u30d6\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u306e\u6700\u7d42\u30d0\u30fc\u30b8\u30e7\u30f3 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_nl.properties index de6709175f..5a2599ab96 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_nl.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=Content kan niet aan een recordcontainer worden toegevoegd. Gebruik archiefmappen voor archiveren van content. -rm.service.update-disposition-action-def=De definitie van de beschikkingsactie kan niet worden bijgewerkt omdat er een update wordt gepubliceerd. -rm.service.set-id=De waarde voor de identificatie-eigenschap van het object {0} is alleen-lezen en kan dus niet worden ingesteld. -rm.service.path-node=Kan pad niet ophalen. (nodeRef={0}) -rm.service.invalid-rm-node=Ongeldige node voor Record Management omdat aspect {0} niet aanwezig is. -rm.service.no-root=Kan Record Management-oorsprong niet vinden. -rm.service.dup-root=Kan geen Record Management-oorsprong maken omdat er al een bestaat in deze hi\u00ebrarchie. -rm.service.root-type=Kan de Record Management-oorsprong niet maken omdat type {0} geen subtype is van rm:recordsManagementRootContainer. -rm.service.container-parent-type=Kan Record Management-container niet maken omdat de bovenliggende geen subtype was van rm:recordsManagement (parentType={0}) -rm.service.container-type=Kan de Record Management-container niet maken omdat type {0} geen subtype is van rm:recordsManagementContainer. -rm.service.container-expected=Nodeverwijzing naar een rm:recordsManagementContainer node verwacht. -rm.service.record-folder-expected=Nodeverwijzing naar een rm:recordFolder node verwacht. -rm.service.parent-record-folder-root=Kan geen archiefmap maken omdat de bovenliggende map een Record Management-oorsprong is. -rm.service.parent-record-folder-type=Kan geen archiefmap maken omdat de bovenliggende geen subtype was van rm:recordsManagementContainer. (parentType={0}) -rm.service.record-folder-type=Kan geen archiefmap maken omdat het geleverde type geen subtype is van rm:recordFolder. (type={0}) -rm.service.not-record=De node {0} is geen record. -rm.service.vital-def-missing=Definitie-aspect van vitale record is niet aanwezig op node. (nodeRef={0}) -rm.service.close-record-folder-not-folder=De archiefmap kan niet worden gesloten omdat hij niet als een archiefmap is gedefinieerd.(nodeRef={0}) -rm.service.node-has-aspect=De node {0} heeft al het aspect {1}. -rm.service.final-version=Definitief +rm.service.error-add-content-container=Content kan niet aan een recordcontainer worden toegevoegd. Gebruik archiefmappen voor archiveren van content. +rm.service.update-disposition-action-def=De definitie van de beschikkingsactie kan niet worden bijgewerkt omdat er een update wordt gepubliceerd. +rm.service.set-id=De waarde voor de identificatie-eigenschap van het object {0} is alleen-lezen en kan dus niet worden ingesteld. +rm.service.path-node=Kan pad niet ophalen. (nodeRef={0}) +rm.service.invalid-rm-node=Ongeldige node voor Record Management omdat aspect {0} niet aanwezig is. +rm.service.no-root=Kan Record Management-oorsprong niet vinden. +rm.service.dup-root=Kan geen Record Management-oorsprong maken omdat er al een bestaat in deze hi\u00ebrarchie. +rm.service.root-type=Kan de Record Management-oorsprong niet maken omdat type {0} geen subtype is van rm:recordsManagementRootContainer. +rm.service.container-parent-type=Kan Record Management-container niet maken omdat de bovenliggende geen subtype was van rm:recordsManagement (parentType={0}) +rm.service.container-type=Kan de Record Management-container niet maken omdat type {0} geen subtype is van rm:recordsManagementContainer. +rm.service.container-expected=Nodeverwijzing naar een rm:recordsManagementContainer node verwacht. +rm.service.record-folder-expected=Nodeverwijzing naar een rm:recordFolder node verwacht. +rm.service.parent-record-folder-root=Kan geen archiefmap maken omdat de bovenliggende map een Record Management-oorsprong is. +rm.service.parent-record-folder-type=Kan geen archiefmap maken omdat de bovenliggende geen subtype was van rm:recordsManagementContainer. (parentType={0}) +rm.service.record-folder-type=Kan geen archiefmap maken omdat het geleverde type geen subtype is van rm:recordFolder. (type={0}) +rm.service.not-record=De node {0} is geen record. +rm.service.vital-def-missing=Definitie-aspect van vitale record is niet aanwezig op node. (nodeRef={0}) +rm.service.close-record-folder-not-folder=De archiefmap kan niet worden gesloten omdat hij niet als een archiefmap is gedefinieerd.(nodeRef={0}) +rm.service.node-has-aspect=De node {0} heeft al het aspect {1}. +rm.service.final-version=Definitief rm.service.final-version-description=De definitieve gearchiveerde recordversie \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_zh_CN.properties index 3bd7fcb8c2..0817b4b608 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service_zh_CN.properties @@ -1,21 +1,21 @@ -rm.service.error-add-content-container=\u65e0\u6cd5\u5c06\u5185\u5bb9\u6dfb\u52a0\u81f3\u8bb0\u5f55\u5bb9\u5668\u3002\u4f7f\u7528\u8bb0\u5f55\u6587\u4ef6\u5939\u7acb\u5377\u5185\u5bb9\u3002 -rm.service.update-disposition-action-def=\u65e0\u6cd5\u66f4\u65b0\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\uff0c\u56e0\u4e3a\u6b63\u5728\u53d1\u5e03\u66f4\u65b0\u3002 -rm.service.set-id=\u5bf9\u8c61 {0} \u7684\u6807\u8bc6\u7b26\u5c5e\u6027\u503c\u4e3a\u53ea\u8bfb\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u8bbe\u7f6e\u3002 -rm.service.path-node=\u65e0\u6cd5\u83b7\u53d6\u8def\u5f84\u3002(nodeRef={0}) -rm.service.invalid-rm-node=\u8bb0\u5f55\u7ba1\u7406\u8282\u70b9\u65e0\u6548\uff0c\u56e0\u4e3a\u5207\u9762 {0} \u4e0d\u5b58\u5728\u3002 -rm.service.no-root=\u65e0\u6cd5\u627e\u5230\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 -rm.service.dup-root=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u6839\uff0c\u56e0\u4e3a\u5728\u8be5\u5c42\u6b21\u7ed3\u6784\u4e2d\u5df2\u7ecf\u5b58\u5728\u4e00\u4e2a\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 -rm.service.root-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u6839\uff0c\u56e0\u4e3a\u7c7b\u578b {0} \u5e76\u975e rm:recordsManagementRootContainer \u7684\u5b50\u7c7b\u578b\u3002 -rm.service.container-parent-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668\uff0c\u56e0\u4e3a\u7236\u9879\u5e76\u975e rm:recordsManagement (parentType={0}) \u7684\u5b50\u7c7b\u578b -rm.service.container-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668\uff0c\u56e0\u4e3a\u7c7b\u578b {0} \u5e76\u975e rm:recordsManagementContainer \u7684\u5b50\u7c7b\u578b\u3002 -rm.service.container-expected=\u9884\u671f\u6709\u5bf9\u4e8e rm:recordsManagementContainer \u8282\u70b9\u7684\u8282\u70b9\u53c2\u8003\u3002 -rm.service.record-folder-expected=\u9884\u671f\u6709\u5bf9\u4e8e rm:recordFolder \u8282\u70b9\u7684\u8282\u70b9\u53c2\u8003\u3002 -rm.service.parent-record-folder-root=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u7236\u9879\u4e3a\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 -rm.service.parent-record-folder-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u7236\u9879\u5e76\u975e rm:recordsManagementContainer \u7684\u5b50\u7c7b\u578b\u3002(parentType={0}) -rm.service.record-folder-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u63d0\u4f9b\u7684\u7c7b\u578b\u5e76\u975e rm:recordFolder \u7684\u5b50\u7c7b\u578b\u3002(type={0}) -rm.service.not-record=\u8282\u70b9 {0} \u5e76\u975e\u8bb0\u5f55\u3002 -rm.service.vital-def-missing=\u8282\u70b9\u4e0a\u4e0d\u5b58\u5728\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49\u5207\u9762\u3002(nodeRef={0}) -rm.service.close-record-folder-not-folder=\u65e0\u6cd5\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u5e76\u672a\u5c06\u5176\u5b9a\u4e49\u4e3a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(nodeRef={0}) -rm.service.node-has-aspect=\u8282\u70b9 {0} \u5df2\u6709\u5207\u9762 {1}\u3002 -rm.service.final-version=\u6700\u7ec8 +rm.service.error-add-content-container=\u65e0\u6cd5\u5c06\u5185\u5bb9\u6dfb\u52a0\u81f3\u8bb0\u5f55\u5bb9\u5668\u3002\u4f7f\u7528\u8bb0\u5f55\u6587\u4ef6\u5939\u7acb\u5377\u5185\u5bb9\u3002 +rm.service.update-disposition-action-def=\u65e0\u6cd5\u66f4\u65b0\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49\uff0c\u56e0\u4e3a\u6b63\u5728\u53d1\u5e03\u66f4\u65b0\u3002 +rm.service.set-id=\u5bf9\u8c61 {0} \u7684\u6807\u8bc6\u7b26\u5c5e\u6027\u503c\u4e3a\u53ea\u8bfb\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u8bbe\u7f6e\u3002 +rm.service.path-node=\u65e0\u6cd5\u83b7\u53d6\u8def\u5f84\u3002(nodeRef={0}) +rm.service.invalid-rm-node=\u8bb0\u5f55\u7ba1\u7406\u8282\u70b9\u65e0\u6548\uff0c\u56e0\u4e3a\u5207\u9762 {0} \u4e0d\u5b58\u5728\u3002 +rm.service.no-root=\u65e0\u6cd5\u627e\u5230\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 +rm.service.dup-root=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u6839\uff0c\u56e0\u4e3a\u5728\u8be5\u5c42\u6b21\u7ed3\u6784\u4e2d\u5df2\u7ecf\u5b58\u5728\u4e00\u4e2a\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 +rm.service.root-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u6839\uff0c\u56e0\u4e3a\u7c7b\u578b {0} \u5e76\u975e rm:recordsManagementRootContainer \u7684\u5b50\u7c7b\u578b\u3002 +rm.service.container-parent-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668\uff0c\u56e0\u4e3a\u7236\u9879\u5e76\u975e rm:recordsManagement (parentType={0}) \u7684\u5b50\u7c7b\u578b +rm.service.container-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668\uff0c\u56e0\u4e3a\u7c7b\u578b {0} \u5e76\u975e rm:recordsManagementContainer \u7684\u5b50\u7c7b\u578b\u3002 +rm.service.container-expected=\u9884\u671f\u6709\u5bf9\u4e8e rm:recordsManagementContainer \u8282\u70b9\u7684\u8282\u70b9\u53c2\u8003\u3002 +rm.service.record-folder-expected=\u9884\u671f\u6709\u5bf9\u4e8e rm:recordFolder \u8282\u70b9\u7684\u8282\u70b9\u53c2\u8003\u3002 +rm.service.parent-record-folder-root=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u7236\u9879\u4e3a\u8bb0\u5f55\u7ba1\u7406\u6839\u3002 +rm.service.parent-record-folder-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u7236\u9879\u5e76\u975e rm:recordsManagementContainer \u7684\u5b50\u7c7b\u578b\u3002(parentType={0}) +rm.service.record-folder-type=\u65e0\u6cd5\u521b\u5efa\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u63d0\u4f9b\u7684\u7c7b\u578b\u5e76\u975e rm:recordFolder \u7684\u5b50\u7c7b\u578b\u3002(type={0}) +rm.service.not-record=\u8282\u70b9 {0} \u5e76\u975e\u8bb0\u5f55\u3002 +rm.service.vital-def-missing=\u8282\u70b9\u4e0a\u4e0d\u5b58\u5728\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49\u5207\u9762\u3002(nodeRef={0}) +rm.service.close-record-folder-not-folder=\u65e0\u6cd5\u5173\u95ed\u8bb0\u5f55\u6587\u4ef6\u5939\uff0c\u56e0\u4e3a\u5e76\u672a\u5c06\u5176\u5b9a\u4e49\u4e3a\u8bb0\u5f55\u6587\u4ef6\u5939\u3002(nodeRef={0}) +rm.service.node-has-aspect=\u8282\u70b9 {0} \u5df2\u6709\u5207\u9762 {1}\u3002 +rm.service.final-version=\u6700\u7ec8 rm.service.final-version-description=\u6700\u7ec8\u5b58\u6863\u7684\u8bb0\u5f55\u7248\u672c \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties index b735ab01ee..911edd0680 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Records Management Content Model - -rma_recordsmanagement.type.rma_rmsite.title=Records Management Site -rma_recordsmanagement.type.rma_rmsite.description=Specialized Site for Records Management - -rma_recordsmanagement.type.rma_caveatConfig.title=Caveat Config -rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat Config - -rma_recordsmanagement.type.rma_emailConfig.title=Email Configuration -rma_recordsmanagement.type.rma_emailConfig.decription=Email Configuration - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Records Management Container -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Records Management Container - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Records Management Root Container -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Records Management Root Container - -rma_recordsmanagement.type.rma_dispositionSchedule.title=Disposition Schedule -rma_recordsmanagement.type.rma_dispositionSchedule.decription=Disposition Schedule - -rma_recordsmanagement.property.rma_dispositionAuthority.title=Disposition Authority -rma_recordsmanagement.property.rma_dispositionAuthority.decription=Disposition Authority - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Disposition Instructions -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Disposition Instructions - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Record Level Disposition -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Record Level Disposition - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Disposition Actions -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Disposition Actions - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Disposition Action Definition -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Disposition Action Definition -rma_recordsmanagement.property.rma_dispositionActionName.title=Disposition Action Name -rma_recordsmanagement.property.rma_dispositionActionName.decription=Disposition Action Name -rma_recordsmanagement.property.rma_dispositionDescription.title=Disposition Description -rma_recordsmanagement.property.rma_dispositionDescription.decription=Disposition Description -rma_recordsmanagement.property.rma_dispositionLocation.title=Disposition Location -rma_recordsmanagement.property.rma_dispositionLocation.decription=Disposition Location -rma_recordsmanagement.property.rma_dispositionPeriod.title=Disposition Period -rma_recordsmanagement.property.rma_dispositionPeriod.decription=Disposition Period -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Disposition Period Property -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Disposition Period Property -rma_recordsmanagement.property.rma_dispositionEvent.title=Disposition Event -rma_recordsmanagement.property.rma_dispositionEvent.decription=Disposition Event -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Disposition Event Combination -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Disposition Event Combination - -rma_recordsmanagement.type.rma_recordFolder.title=Record Folder -rma_recordsmanagement.type.rma_recordFolder.decription=Record Folder -rma_recordsmanagement.property.rma_isClosed.title=Record -rma_recordsmanagement.property.rma_isClosed.decription=Record - -rma_recordsmanagement.type.rma_recordCategory.title=Record Category -rma_recordsmanagement.type.rma_recordCategory.decription=Record Category - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Non-Electronic Document -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Non-Electronic Document -rma_recordsmanagement.property.rma_physicalSize.title=Physical Size -rma_recordsmanagement.property.rma_physicalSize.decription=The size of the document measured in linear meters. -rma_recordsmanagement.property.rma_numberOfCopies.title=Number Of Copies -rma_recordsmanagement.property.rma_numberOfCopies.description=The number of copies of the document. -rma_recordsmanagement.property.rma_storageLocation.title=Storage Location -rma_recordsmanagement.property.rma_storageLocation.decription=The physical storage location of the record. -rma_recordsmanagement.property.rma_shelf.title=Shelf -rma_recordsmanagement.property.rma_shelf.decription=The shelf the record resides on. -rma_recordsmanagement.property.rma_box.title=Box -rma_recordsmanagement.property.rma_box.description=The box the record resides in. -rma_recordsmanagement.property.rma_file.title=File -rma_recordsmanagement.property.rma_file.decription=The file the record resides in. - -rma_recordsmanagement.type.rma_dispositionAction.title=Disposition Action -rma_recordsmanagement.type.rma_dispositionAction.decription=Disposition Action -rma_recordsmanagement.property.rma_dispositionActionId.title=Disposition Action Id -rma_recordsmanagement.property.rma_dispositionActionId.decription=Disposition Action Id -rma_recordsmanagement.property.rma_dispositionAction.title=Disposition Action -rma_recordsmanagement.property.rma_dispositionAction.decription=Disposition Action -rma_recordsmanagement.property.rma_dispositionAsOf.title=Disposition Action -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Disposition Action -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Disposition Events Eligible -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Disposition Events Eligible -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Disposition Action Started At -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Disposition Action Started At -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Disposition Action Started By -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Disposition Action Started By -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Disposition Action Completed At -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Disposition Action Completed At -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Disposition Action Completed By -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Disposition Action Completed By -rma_recordsmanagement.association.rma_eventExecutions.title=Event executions -rma_recordsmanagement.association.rma_eventExecutions.decription=Event executions - -rma_recordsmanagement.type.rma_eventExecution.title=Event Execution -rma_recordsmanagement.type.rma_eventExecution.decription=Event Execution -rma_recordsmanagement.property.rma_eventExecutionName.title=Event Name -rma_recordsmanagement.property.rma_eventExecutionName.decription=Event Name -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Event automatic -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Event automatic -rma_recordsmanagement.property.rma_eventExecutionComplete.title=Event complete -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Event complete -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Event completed by -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Event completed by -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Event completed at -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Event completed at - -rma_recordsmanagement.type.rma_hold.title=Hold -rma_recordsmanagement.type.rma_hold.decription=Hold -rma_recordsmanagement.property.rma_holdReason.title=Hold Reason -rma_recordsmanagement.property.rma_holdReason.decription=Hold Reason -rma_recordsmanagement.association.rma_frozenRecords.title=Held Records -rma_recordsmanagement.association.rma_frozenRecords.decription=Held Records - -rma_recordsmanagement.type.rma_transfer.title=Transfer -rma_recordsmanagement.type.rma_transfer.decription=Transfer -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Transfer Accession Indicator -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Transfer Accession Indicator -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Transfer PDF Indicator -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Transfer PDF Indicator -rma_recordsmanagement.property.rma_transferLocation.title=Transfer PDF -rma_recordsmanagement.property.rma_transferLocation.decription=Transfer PDF -rma_recordsmanagement.association.rma_transferred.title=Transferred -rma_recordsmanagement.association.rma_transferred.decription=Transferred - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=File Plan Component -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=File Plan Component -rma_recordsmanagement.property.rma_rootNodeRef.title=Root node -rma_recordsmanagement.property.rma_rootNodeRef.decription=Root node - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Records Management Root -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Records Management Root -rma_recordsmanagement.association.rma_holds.title=Holds -rma_recordsmanagement.association.rma_holds.decription=Holds -rma_recordsmanagement.association.rma_transfers.title=Transfers -rma_recordsmanagement.association.rma_transfers.decription=Transfers - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Completed Record -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Completed Record -rma_recordsmanagement.property.rma_declaredAt.title=Date Completed -rma_recordsmanagement.property.rma_declaredAt.decription=Date Completed -rma_recordsmanagement.property.rma_declaredBy.title=Completed By -rma_recordsmanagement.property.rma_declaredBy.decription=Completed By - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Record component identifier -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Record component identifier -rma_recordsmanagement.property.rma_identifier.title=Identifier -rma_recordsmanagement.property.rma_identifier.decription=Unique record identifier -rma_recordsmanagement.property.rma_dbUniquenessId.title=Database uniqueness -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Database uniqueness - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Vital Record Definition -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Vital Record Definition - -rma_recordsmanagement.property.rma_reviewPeriod.title=Review Period -rma_recordsmanagement.property.rma_reviewPeriod.decription=Review Period -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Vital Record Indicator -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Vital Record Indicator - -rma_recordsmanagement.aspect.rma_record.title=Record -rma_recordsmanagement.aspect.rma_record.decription=Record -rma_recordsmanagement.property.rma_dateFiled.title=Date Filed -rma_recordsmanagement.property.rma_dateFiled.decription=Date Filed -rma_recordsmanagement.property.rma_origionalName=Original Name - -rma_recordsmanagement.aspect.rma_recordMetaData.title=Record Meta-data -rma_recordsmanagement.aspect.rma_recordMetaData.description=Marker aspect for record meta-data - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Common Records Details -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Meta-data common to all record types -rma_recordsmanagement.property.rma_location.title=Location -rma_recordsmanagement.property.rma_location.decription=Location - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Vital Record -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vital Record -rma_recordsmanagement.property.rma_reviewAsOf.title=Next Review -rma_recordsmanagement.property.rma_reviewAsOf.decription=Next Review -rma_recordsmanagement.property.rma_notificationIssued.title=Indicates that a due for review notification has been issued for this record -rma_recordsmanagement.property.rma_notificationIssued.decription=Indicates that a due for review notification has been issued for this record - -rma_recordsmanagement.aspect.rma_scheduled.title=Scheduled -rma_recordsmanagement.aspect.rma_scheduled.decription=Scheduled -rma_recordsmanagement.association.rma_dispositionSchedule.title=Disposition Schedule -rma_recordsmanagement.association.rma_dispositionSchedule.decription=Disposition Schedule - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Disposition Lifecycle -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Disposition Lifecycle -rma_recordsmanagement.association.rma_nextDispositionAction.title=Next disposition action -rma_recordsmanagement.association.rma_nextDispositionAction.decription=Next disposition action -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Disposition Action History -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Disposition Action History - -rma_recordsmanagement.aspect.rma_cutOff.title=Cut Off -rma_recordsmanagement.aspect.rma_cutOff.decription=Cut Off -rma_recordsmanagement.property.rma_cutOffDate.title=Cut Off Date -rma_recordsmanagement.property.rma_cutOffDate.decription=Cut Off Date - -rma_recordsmanagement.aspect.rma_transferred.title=Transferred -rma_recordsmanagement.aspect.rma_transferred.decription=Transferred - -rma_recordsmanagement.aspect.rma_ascended.title=Ascended -rma_recordsmanagement.aspect.rma_ascended.decription=Ascended - -rma_recordsmanagement.aspect.rma_frozen.title=On Hold -rma_recordsmanagement.aspect.rma_frozen.decription=On Hold -rma_recordsmanagement.property.rma_frozenAt.title=Held At -rma_recordsmanagement.property.rma_frozenAt.decription=Held At -rma_recordsmanagement.property.rma_frozenBy.title=Held By -rma_recordsmanagement.property.rma_frozenBy.decription=Held By - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Caveat Configuration Root -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Caveat Configuration Root -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat Configuration -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat Configuration - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Email Config Root -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Email Config Root -rma_recordsmanagement.association.rma_emailConfigAssoc.title=Email Configuration -rma_recordsmanagement.association.rma_emailConfigAssoc.description=Email Configuration - -rma_recordsmanagement.aspect.rma_recordSearch.title=Record Search -rma_recordsmanagement.aspect.rma_recordSearch.decription=Rolled up search information to support Records Management search -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Has Disposition Schedule -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indicates whether the item has an associated disposition schedule -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Disposition Action Name -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=The name of the next disposition action -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Disposition Action Of -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=The date at which the next disposition action becomes eligible -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Disposition Period -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Disposition Period -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Disposition Period Expression -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Disposition Period Expression -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Disposition Events Eligible -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Disposition Events Eligible -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Disposition Events -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Disposition Events -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Disposition Authority -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Disposition Authority -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Disposition Instructions -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Disposition Instructions -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Hold Reason -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Hold Reason -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Vital Record Review Period -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Vital Record Review Period -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Review Period Expression -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Review Period Expression - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Versioned Record -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Versioned Record - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Unpublished Update -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Unpublished Update -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Unpublished Update -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indicates whether there is an unpublished update -rma_recordsmanagement.property.rma_updateTo.title=Update To -rma_recordsmanagement.property.rma_updateTo.description=Destination of the update -rma_recordsmanagement.property.rma_updatedProperties.title=Updated Properties -rma_recordsmanagement.property.rma_updatedProperties.description=The updated properties -rma_recordsmanagement.property.rma_publishInProgress.title=Publish In Progress -rma_recordsmanagement.property.rma_publishInProgress.description=Indicates whether a publish is currently in progress - -rma_recordsmanagement.aspect.dod_ghosted.title=Metadata Only Record -rma_recordsmanagement.aspect.dod_ghosted.description=Metadata only record - -listconstraint.rmc_tlList.title=Transfer Locations +rma_recordsmanagement.description=Records Management Content Model + +rma_recordsmanagement.type.rma_rmsite.title=Records Management Site +rma_recordsmanagement.type.rma_rmsite.description=Specialized Site for Records Management + +rma_recordsmanagement.type.rma_caveatConfig.title=Caveat Config +rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat Config + +rma_recordsmanagement.type.rma_emailConfig.title=Email Configuration +rma_recordsmanagement.type.rma_emailConfig.decription=Email Configuration + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Records Management Container +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Records Management Container + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Records Management Root Container +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Records Management Root Container + +rma_recordsmanagement.type.rma_dispositionSchedule.title=Disposition Schedule +rma_recordsmanagement.type.rma_dispositionSchedule.decription=Disposition Schedule + +rma_recordsmanagement.property.rma_dispositionAuthority.title=Disposition Authority +rma_recordsmanagement.property.rma_dispositionAuthority.decription=Disposition Authority + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Disposition Instructions +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Disposition Instructions + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Record Level Disposition +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Record Level Disposition + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Disposition Actions +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Disposition Actions + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Disposition Action Definition +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Disposition Action Definition +rma_recordsmanagement.property.rma_dispositionActionName.title=Disposition Action Name +rma_recordsmanagement.property.rma_dispositionActionName.decription=Disposition Action Name +rma_recordsmanagement.property.rma_dispositionDescription.title=Disposition Description +rma_recordsmanagement.property.rma_dispositionDescription.decription=Disposition Description +rma_recordsmanagement.property.rma_dispositionLocation.title=Disposition Location +rma_recordsmanagement.property.rma_dispositionLocation.decription=Disposition Location +rma_recordsmanagement.property.rma_dispositionPeriod.title=Disposition Period +rma_recordsmanagement.property.rma_dispositionPeriod.decription=Disposition Period +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Disposition Period Property +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Disposition Period Property +rma_recordsmanagement.property.rma_dispositionEvent.title=Disposition Event +rma_recordsmanagement.property.rma_dispositionEvent.decription=Disposition Event +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Disposition Event Combination +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Disposition Event Combination + +rma_recordsmanagement.type.rma_recordFolder.title=Record Folder +rma_recordsmanagement.type.rma_recordFolder.decription=Record Folder +rma_recordsmanagement.property.rma_isClosed.title=Record +rma_recordsmanagement.property.rma_isClosed.decription=Record + +rma_recordsmanagement.type.rma_recordCategory.title=Record Category +rma_recordsmanagement.type.rma_recordCategory.decription=Record Category + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Non-Electronic Document +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Non-Electronic Document +rma_recordsmanagement.property.rma_physicalSize.title=Physical Size +rma_recordsmanagement.property.rma_physicalSize.decription=The size of the document measured in linear meters. +rma_recordsmanagement.property.rma_numberOfCopies.title=Number Of Copies +rma_recordsmanagement.property.rma_numberOfCopies.description=The number of copies of the document. +rma_recordsmanagement.property.rma_storageLocation.title=Storage Location +rma_recordsmanagement.property.rma_storageLocation.decription=The physical storage location of the record. +rma_recordsmanagement.property.rma_shelf.title=Shelf +rma_recordsmanagement.property.rma_shelf.decription=The shelf the record resides on. +rma_recordsmanagement.property.rma_box.title=Box +rma_recordsmanagement.property.rma_box.description=The box the record resides in. +rma_recordsmanagement.property.rma_file.title=File +rma_recordsmanagement.property.rma_file.decription=The file the record resides in. + +rma_recordsmanagement.type.rma_dispositionAction.title=Disposition Action +rma_recordsmanagement.type.rma_dispositionAction.decription=Disposition Action +rma_recordsmanagement.property.rma_dispositionActionId.title=Disposition Action Id +rma_recordsmanagement.property.rma_dispositionActionId.decription=Disposition Action Id +rma_recordsmanagement.property.rma_dispositionAction.title=Disposition Action +rma_recordsmanagement.property.rma_dispositionAction.decription=Disposition Action +rma_recordsmanagement.property.rma_dispositionAsOf.title=Disposition Action +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Disposition Action +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Disposition Events Eligible +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Disposition Events Eligible +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Disposition Action Started At +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Disposition Action Started At +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Disposition Action Started By +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Disposition Action Started By +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Disposition Action Completed At +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Disposition Action Completed At +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Disposition Action Completed By +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Disposition Action Completed By +rma_recordsmanagement.association.rma_eventExecutions.title=Event executions +rma_recordsmanagement.association.rma_eventExecutions.decription=Event executions + +rma_recordsmanagement.type.rma_eventExecution.title=Event Execution +rma_recordsmanagement.type.rma_eventExecution.decription=Event Execution +rma_recordsmanagement.property.rma_eventExecutionName.title=Event Name +rma_recordsmanagement.property.rma_eventExecutionName.decription=Event Name +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Event automatic +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Event automatic +rma_recordsmanagement.property.rma_eventExecutionComplete.title=Event complete +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Event complete +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Event completed by +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Event completed by +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Event completed at +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Event completed at + +rma_recordsmanagement.type.rma_hold.title=Hold +rma_recordsmanagement.type.rma_hold.decription=Hold +rma_recordsmanagement.property.rma_holdReason.title=Hold Reason +rma_recordsmanagement.property.rma_holdReason.decription=Hold Reason +rma_recordsmanagement.association.rma_frozenRecords.title=Held Records +rma_recordsmanagement.association.rma_frozenRecords.decription=Held Records + +rma_recordsmanagement.type.rma_transfer.title=Transfer +rma_recordsmanagement.type.rma_transfer.decription=Transfer +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Transfer Accession Indicator +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Transfer Accession Indicator +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Transfer PDF Indicator +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Transfer PDF Indicator +rma_recordsmanagement.property.rma_transferLocation.title=Transfer PDF +rma_recordsmanagement.property.rma_transferLocation.decription=Transfer PDF +rma_recordsmanagement.association.rma_transferred.title=Transferred +rma_recordsmanagement.association.rma_transferred.decription=Transferred + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=File Plan Component +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=File Plan Component +rma_recordsmanagement.property.rma_rootNodeRef.title=Root node +rma_recordsmanagement.property.rma_rootNodeRef.decription=Root node + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Records Management Root +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Records Management Root +rma_recordsmanagement.association.rma_holds.title=Holds +rma_recordsmanagement.association.rma_holds.decription=Holds +rma_recordsmanagement.association.rma_transfers.title=Transfers +rma_recordsmanagement.association.rma_transfers.decription=Transfers + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Completed Record +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Completed Record +rma_recordsmanagement.property.rma_declaredAt.title=Date Completed +rma_recordsmanagement.property.rma_declaredAt.decription=Date Completed +rma_recordsmanagement.property.rma_declaredBy.title=Completed By +rma_recordsmanagement.property.rma_declaredBy.decription=Completed By + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Record component identifier +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Record component identifier +rma_recordsmanagement.property.rma_identifier.title=Identifier +rma_recordsmanagement.property.rma_identifier.decription=Unique record identifier +rma_recordsmanagement.property.rma_dbUniquenessId.title=Database uniqueness +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Database uniqueness + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Vital Record Definition +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Vital Record Definition + +rma_recordsmanagement.property.rma_reviewPeriod.title=Review Period +rma_recordsmanagement.property.rma_reviewPeriod.decription=Review Period +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Vital Record Indicator +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Vital Record Indicator + +rma_recordsmanagement.aspect.rma_record.title=Record +rma_recordsmanagement.aspect.rma_record.decription=Record +rma_recordsmanagement.property.rma_dateFiled.title=Date Filed +rma_recordsmanagement.property.rma_dateFiled.decription=Date Filed +rma_recordsmanagement.property.rma_origionalName=Original Name + +rma_recordsmanagement.aspect.rma_recordMetaData.title=Record Meta-data +rma_recordsmanagement.aspect.rma_recordMetaData.description=Marker aspect for record meta-data + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Common Records Details +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Meta-data common to all record types +rma_recordsmanagement.property.rma_location.title=Location +rma_recordsmanagement.property.rma_location.decription=Location + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Vital Record +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vital Record +rma_recordsmanagement.property.rma_reviewAsOf.title=Next Review +rma_recordsmanagement.property.rma_reviewAsOf.decription=Next Review +rma_recordsmanagement.property.rma_notificationIssued.title=Indicates that a due for review notification has been issued for this record +rma_recordsmanagement.property.rma_notificationIssued.decription=Indicates that a due for review notification has been issued for this record + +rma_recordsmanagement.aspect.rma_scheduled.title=Scheduled +rma_recordsmanagement.aspect.rma_scheduled.decription=Scheduled +rma_recordsmanagement.association.rma_dispositionSchedule.title=Disposition Schedule +rma_recordsmanagement.association.rma_dispositionSchedule.decription=Disposition Schedule + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Disposition Lifecycle +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Disposition Lifecycle +rma_recordsmanagement.association.rma_nextDispositionAction.title=Next disposition action +rma_recordsmanagement.association.rma_nextDispositionAction.decription=Next disposition action +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Disposition Action History +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Disposition Action History + +rma_recordsmanagement.aspect.rma_cutOff.title=Cut Off +rma_recordsmanagement.aspect.rma_cutOff.decription=Cut Off +rma_recordsmanagement.property.rma_cutOffDate.title=Cut Off Date +rma_recordsmanagement.property.rma_cutOffDate.decription=Cut Off Date + +rma_recordsmanagement.aspect.rma_transferred.title=Transferred +rma_recordsmanagement.aspect.rma_transferred.decription=Transferred + +rma_recordsmanagement.aspect.rma_ascended.title=Ascended +rma_recordsmanagement.aspect.rma_ascended.decription=Ascended + +rma_recordsmanagement.aspect.rma_frozen.title=On Hold +rma_recordsmanagement.aspect.rma_frozen.decription=On Hold +rma_recordsmanagement.property.rma_frozenAt.title=Held At +rma_recordsmanagement.property.rma_frozenAt.decription=Held At +rma_recordsmanagement.property.rma_frozenBy.title=Held By +rma_recordsmanagement.property.rma_frozenBy.decription=Held By + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Caveat Configuration Root +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Caveat Configuration Root +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat Configuration +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat Configuration + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Email Config Root +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Email Config Root +rma_recordsmanagement.association.rma_emailConfigAssoc.title=Email Configuration +rma_recordsmanagement.association.rma_emailConfigAssoc.description=Email Configuration + +rma_recordsmanagement.aspect.rma_recordSearch.title=Record Search +rma_recordsmanagement.aspect.rma_recordSearch.decription=Rolled up search information to support Records Management search +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Has Disposition Schedule +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indicates whether the item has an associated disposition schedule +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Disposition Action Name +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=The name of the next disposition action +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Disposition Action Of +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=The date at which the next disposition action becomes eligible +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Disposition Period +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Disposition Period +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Disposition Period Expression +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Disposition Period Expression +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Disposition Events Eligible +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Disposition Events Eligible +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Disposition Events +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Disposition Events +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Disposition Authority +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Disposition Authority +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Disposition Instructions +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Disposition Instructions +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Hold Reason +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Hold Reason +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Vital Record Review Period +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Vital Record Review Period +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Review Period Expression +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Review Period Expression + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Versioned Record +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Versioned Record + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Unpublished Update +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Unpublished Update +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Unpublished Update +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indicates whether there is an unpublished update +rma_recordsmanagement.property.rma_updateTo.title=Update To +rma_recordsmanagement.property.rma_updateTo.description=Destination of the update +rma_recordsmanagement.property.rma_updatedProperties.title=Updated Properties +rma_recordsmanagement.property.rma_updatedProperties.description=The updated properties +rma_recordsmanagement.property.rma_publishInProgress.title=Publish In Progress +rma_recordsmanagement.property.rma_publishInProgress.description=Indicates whether a publish is currently in progress + +rma_recordsmanagement.aspect.dod_ghosted.title=Metadata Only Record +rma_recordsmanagement.aspect.dod_ghosted.description=Metadata only record + +listconstraint.rmc_tlList.title=Transfer Locations listconstraint.rmc_smList.title=Supplemental Markings \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties index 53ecbac3fc..aaa1b7ba53 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Content Model f\u00fcr Records Management - -rma_recordsmanagement.type.rma_rmsite.title=Records Management Site -rma_recordsmanagement.type.rma_rmsite.description=Spezielle Site f\u00fcr Records Management - -rma_recordsmanagement.type.rma_caveatConfig.title=Caveat-Konfig. -rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat-Konfig. - -rma_recordsmanagement.type.rma_emailConfig.title=E-Mail-Konfiguration -rma_recordsmanagement.type.rma_emailConfig.decription=E-Mail-Konfiguration - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Records Management Container -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Records Management Container - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Records Management Root-Container -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Records Management Root-Container - -rma_recordsmanagement.type.rma_dispositionSchedule.title=Entsorgungsplan -rma_recordsmanagement.type.rma_dispositionSchedule.decription=Entsorgungsplan - -rma_recordsmanagement.property.rma_dispositionAuthority.title=Entsorgungsinstanz -rma_recordsmanagement.property.rma_dispositionAuthority.decription=Entsorgungsinstanz - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Entsorgungsanweisungen -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Entsorgungsanweisungen - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Entsorgung auf Record-Ebene -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Entsorgung auf Record-Ebene - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Entsorgungsaktionen -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Entsorgungsaktionen - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definition der Entsorgungsaktion -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definition der Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionActionName.title=Name der Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionActionName.decription=Name der Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionDescription.title=Entsorgungsbeschreibung -rma_recordsmanagement.property.rma_dispositionDescription.decription=Entsorgungsbeschreibung -rma_recordsmanagement.property.rma_dispositionLocation.title=Entsorgungsort -rma_recordsmanagement.property.rma_dispositionLocation.decription=Entsorgungsort -rma_recordsmanagement.property.rma_dispositionPeriod.title=Entsorgungszeitraum -rma_recordsmanagement.property.rma_dispositionPeriod.decription=Entsorgungszeitraum -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Eigenschaft des Entsorgungszeitraums -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Eigenschaft des Entsorgungszeitraums -rma_recordsmanagement.property.rma_dispositionEvent.title=Entsorgungsereignis -rma_recordsmanagement.property.rma_dispositionEvent.decription=Entsorgungsereignis -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Entsorgungsereigniskombination -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Entsorgungsereigniskombination - -rma_recordsmanagement.type.rma_recordFolder.title=Record-Ordner -rma_recordsmanagement.type.rma_recordFolder.decription=Record-Ordner -rma_recordsmanagement.property.rma_isClosed.title=Record -rma_recordsmanagement.property.rma_isClosed.decription=Record - -rma_recordsmanagement.type.rma_recordCategory.title=Record-Kategorie -rma_recordsmanagement.type.rma_recordCategory.decription=Record-Kategorie - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Nicht elektronisches Dokument -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Nicht elektronisches Dokument -rma_recordsmanagement.property.rma_physicalSize.title=Physikalische Gr\u00f6\u00dfe -rma_recordsmanagement.property.rma_physicalSize.decription=Die Gr\u00f6\u00dfe des Dokuments wird in laufenden Metern gemessen. -rma_recordsmanagement.property.rma_numberOfCopies.title=Anzahl der Kopien -rma_recordsmanagement.property.rma_numberOfCopies.description=Die Anzahl der Kopien des Dokuments. -rma_recordsmanagement.property.rma_storageLocation.title=Speicherort -rma_recordsmanagement.property.rma_storageLocation.decription=Der physische Speicherort des Record. -rma_recordsmanagement.property.rma_shelf.title=Regal -rma_recordsmanagement.property.rma_shelf.decription=Das Regal, in dem sich der Record befindet. -rma_recordsmanagement.property.rma_box.title=Box -rma_recordsmanagement.property.rma_box.description=Die Box, in der sich der Record befindet. -rma_recordsmanagement.property.rma_file.title=Datei -rma_recordsmanagement.property.rma_file.decription=Die Datei, in der sich der Record befindet. - -rma_recordsmanagement.type.rma_dispositionAction.title=Entsorgungsaktion -rma_recordsmanagement.type.rma_dispositionAction.decription=Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionActionId.title=ID der Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionActionId.decription=ID der Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionAction.title=Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionAction.decription=Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionAsOf.title=Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Entsorgungsaktion -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Erlaubte Entsorgungsereignisse -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Erlaubte Entsorgungsereignisse -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Entsorgungsaktion gestartet um -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Entsorgungsaktion gestartet um -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Entsorgungsaktion gestartet von -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Entsorgungsaktion gestartet von -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Entsorgungsaktion abgeschlossen um -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Entsorgungsaktion abgeschlossen um -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Entsorgungsaktion abgeschlossen von -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Entsorgungsaktion abgeschlossen von -rma_recordsmanagement.association.rma_eventExecutions.title=Ereignisausf\u00fchrungen -rma_recordsmanagement.association.rma_eventExecutions.decription=Ereignisausf\u00fchrungen - -rma_recordsmanagement.type.rma_eventExecution.title=Ereignisausf\u00fchrung -rma_recordsmanagement.type.rma_eventExecution.decription=Ereignisausf\u00fchrung -rma_recordsmanagement.property.rma_eventExecutionName.title=Ereignisname -rma_recordsmanagement.property.rma_eventExecutionName.decription=Ereignisname -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Automatisches Ereignis -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Automatisches Ereignis -rma_recordsmanagement.property.rma_eventExecutionComplete.title=Abgeschlossenes Ereignis -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Abgeschlossenes Ereignis -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Ereignis abgeschlossen von -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Ereignis abgeschlossen von -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Ereignis abgeschlossen um -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Ereignis abgeschlossen um - -rma_recordsmanagement.type.rma_hold.title=Sperrbereich -rma_recordsmanagement.type.rma_hold.decription=Sperrbereich -rma_recordsmanagement.property.rma_holdReason.title=Sperrgrund -rma_recordsmanagement.property.rma_holdReason.decription=Sperrgrund -rma_recordsmanagement.association.rma_frozenRecords.title=Gesperrte Records -rma_recordsmanagement.association.rma_frozenRecords.decription=Gesperrte Records - -rma_recordsmanagement.type.rma_transfer.title=\u00dcbertragung -rma_recordsmanagement.type.rma_transfer.decription=\u00dcbertragung -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Anzeige bei \u00dcbertragung zur Aufnahme -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Anzeige bei \u00dcbertragung zur Aufnahme -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Anzeige bei PDF-\u00dcbertragung -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Anzeige bei PDF-\u00dcbertragung -rma_recordsmanagement.property.rma_transferLocation.title=PDF \u00fcbertragen -rma_recordsmanagement.property.rma_transferLocation.decription=PDF \u00fcbertragen -rma_recordsmanagement.association.rma_transferred.title=\u00dcbertragen -rma_recordsmanagement.association.rma_transferred.decription=\u00dcbertragen - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=Ablageplan-Komponente -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Ablageplan-Komponente -rma_recordsmanagement.property.rma_rootNodeRef.title=Root-Knoten -rma_recordsmanagement.property.rma_rootNodeRef.decription=Root-Knoten - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Records Management Root -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Records Management Root -rma_recordsmanagement.association.rma_holds.title=Sperren -rma_recordsmanagement.association.rma_holds.decription=Sperren -rma_recordsmanagement.association.rma_transfers.title=\u00dcbertragungen -rma_recordsmanagement.association.rma_transfers.decription=\u00dcbertragungen - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Abgeschlossener Record -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Abgeschlossener Record -rma_recordsmanagement.property.rma_declaredAt.title=Abschlussdatum -rma_recordsmanagement.property.rma_declaredAt.decription=Abschlussdatum -rma_recordsmanagement.property.rma_declaredBy.title=Abgeschlossen von -rma_recordsmanagement.property.rma_declaredBy.decription=Abgeschlossen von - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=ID der Record-Komponente -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=ID der Record-Komponente -rma_recordsmanagement.property.rma_identifier.title=ID -rma_recordsmanagement.property.rma_identifier.decription=Eindeutige Record-ID -rma_recordsmanagement.property.rma_dbUniquenessId.title=Eindeutigkeit der Datenbank -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Eindeutigkeit der Datenbank - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definition f\u00fcr besonders relevanten Record -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definition f\u00fcr besonders relevanten Record - -rma_recordsmanagement.property.rma_reviewPeriod.title=\u00dcberpr\u00fcfungszeitraum -rma_recordsmanagement.property.rma_reviewPeriod.decription=\u00dcberpr\u00fcfungszeitraum -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Kennzeichen f\u00fcr besonders relevante Records -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Kennzeichen f\u00fcr besonders relevante Records - -rma_recordsmanagement.aspect.rma_record.title=Record -rma_recordsmanagement.aspect.rma_record.decription=Record -rma_recordsmanagement.property.rma_dateFiled.title=Ablagedatum -rma_recordsmanagement.property.rma_dateFiled.decription=Ablagedatum -rma_recordsmanagement.property.rma_origionalName=Originalname - -rma_recordsmanagement.aspect.rma_recordMetaData.title=Record-Metadaten -rma_recordsmanagement.aspect.rma_recordMetaData.description=Markeraspekt f\u00fcr Record-Metadaten - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Gemeinsame Record-Details -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Gemeinsame Metadaten aller Record-Typen -rma_recordsmanagement.property.rma_location.title=Ort -rma_recordsmanagement.property.rma_location.decription=Ort - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Besonders relevanter Record -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Besonders relevanter Record -rma_recordsmanagement.property.rma_reviewAsOf.title=N\u00e4chste \u00dcberpr\u00fcfung -rma_recordsmanagement.property.rma_reviewAsOf.decription=N\u00e4chste \u00dcberpr\u00fcfung -rma_recordsmanagement.property.rma_notificationIssued.title=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. -rma_recordsmanagement.property.rma_notificationIssued.decription=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. - -rma_recordsmanagement.aspect.rma_scheduled.title=Geplant -rma_recordsmanagement.aspect.rma_scheduled.decription=Geplant -rma_recordsmanagement.association.rma_dispositionSchedule.title=Entsorgungsplan -rma_recordsmanagement.association.rma_dispositionSchedule.decription=Entsorgungsplan - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Entsorgungszyklus -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Entsorgungszyklus -rma_recordsmanagement.association.rma_nextDispositionAction.title=N\u00e4chste Entsorgungsaktion -rma_recordsmanagement.association.rma_nextDispositionAction.decription=N\u00e4chste Entsorgungsaktion -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Entsorgungsaktionsverlauf -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Entsorgungsaktionsverlauf - -rma_recordsmanagement.aspect.rma_cutOff.title=Getrennt -rma_recordsmanagement.aspect.rma_cutOff.decription=Getrennt -rma_recordsmanagement.property.rma_cutOffDate.title=Trenndatum -rma_recordsmanagement.property.rma_cutOffDate.decription=Trenndatum - -rma_recordsmanagement.aspect.rma_transferred.title=\u00dcbertragen -rma_recordsmanagement.aspect.rma_transferred.decription=\u00dcbertragen - -rma_recordsmanagement.aspect.rma_ascended.title=In Archiv aufgenommen -rma_recordsmanagement.aspect.rma_ascended.decription=In Archiv aufgenommen - -rma_recordsmanagement.aspect.rma_frozen.title=Gesperrt -rma_recordsmanagement.aspect.rma_frozen.decription=Gesperrt -rma_recordsmanagement.property.rma_frozenAt.title=Gehalten in -rma_recordsmanagement.property.rma_frozenAt.decription=Gehalten in -rma_recordsmanagement.property.rma_frozenBy.title=Gehalten von -rma_recordsmanagement.property.rma_frozenBy.decription=Gehalten von - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Root von Caveat-Konfiguration -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Root von Caveat-Konfiguration -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat-Konfiguration -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat-Konfiguration - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=E-Mail-Konfigurations-Root -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=E-Mail-Konfigurations-Root -rma_recordsmanagement.association.rma_emailConfigAssoc.title=E-Mail-Konfiguration -rma_recordsmanagement.association.rma_emailConfigAssoc.description=E-Mail-Konfiguration - -rma_recordsmanagement.aspect.rma_recordSearch.title=Record-Suche -rma_recordsmanagement.aspect.rma_recordSearch.decription=Komprimierte Suchinformation zur Unterst\u00fctzung der Records Management Suche. -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Mit Entsorgungsplan -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Gibt an, ob das Element \u00fcber einen zugeordneten Entsorgungsplan verf\u00fcgt. -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Name der Entsorgungsaktion -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Der Name der n\u00e4chsten Entsorgungsaktion. -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Start der Entsorgungsaktion -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=Das Datum, ab dem die n\u00e4chste Entsorgungsaktion geeignet wird. -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Entsorgungszeitraum -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Entsorgungszeitraum -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Ausdruck f\u00fcr Entsorgungszeitraum -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Ausdruck f\u00fcr Entsorgungszeitraum -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Erlaubte Entsorgungsereignisse -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Erlaubte Entsorgungsereignisse -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Entsorgungsereignisse -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Entsorgungsereignisse -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Entsorgungsinstanz -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Entsorgungsinstanz -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Entsorgungsanweisungen -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Entsorgungsanweisungen -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Sperrgrund -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Sperrgrund -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u00dcberpr\u00fcfungszeitraum f\u00fcr besonders relevante Records -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u00dcberpr\u00fcfungszeitraum f\u00fcr besonders relevante Records -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Ausdruck f\u00fcr \u00dcberpr\u00fcfungszeitraum -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Ausdruck f\u00fcr \u00dcberpr\u00fcfungszeitraum - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Versionierter Record -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Versionierter Record - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Nicht ver\u00f6ffentlichte Aktualisierung -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Nicht ver\u00f6ffentlichte Aktualisierung -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Nicht ver\u00f6ffentlichte Aktualisierung -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Gibt an, ob eine nicht ver\u00f6ffentlichte Aktualisierung vorhanden ist. -rma_recordsmanagement.property.rma_updateTo.title=Aktualisieren auf -rma_recordsmanagement.property.rma_updateTo.description=Das Ziel der Aktualisierung. -rma_recordsmanagement.property.rma_updatedProperties.title=Aktualisierte Eigenschaften -rma_recordsmanagement.property.rma_updatedProperties.description=Die aktualisierten Eigenschaften. -rma_recordsmanagement.property.rma_publishInProgress.title=Laufende Ver\u00f6ffentlichung -rma_recordsmanagement.property.rma_publishInProgress.description=Gibt an, ob derzeit eine Ver\u00f6ffentlichung durchgef\u00fchrt wird. - -rma_recordsmanagement.aspect.dod_ghosted.title=Nur Metadaten enthaltender Record -rma_recordsmanagement.aspect.dod_ghosted.description=Nur Metadaten enthaltender Record - -listconstraint.rmc_tlList.title=Speicherorte \u00fcbertragen +rma_recordsmanagement.description=Content Model f\u00fcr Records Management + +rma_recordsmanagement.type.rma_rmsite.title=Records Management Site +rma_recordsmanagement.type.rma_rmsite.description=Spezielle Site f\u00fcr Records Management + +rma_recordsmanagement.type.rma_caveatConfig.title=Caveat-Konfig. +rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat-Konfig. + +rma_recordsmanagement.type.rma_emailConfig.title=E-Mail-Konfiguration +rma_recordsmanagement.type.rma_emailConfig.decription=E-Mail-Konfiguration + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Records Management Container +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Records Management Container + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Records Management Root-Container +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Records Management Root-Container + +rma_recordsmanagement.type.rma_dispositionSchedule.title=Entsorgungsplan +rma_recordsmanagement.type.rma_dispositionSchedule.decription=Entsorgungsplan + +rma_recordsmanagement.property.rma_dispositionAuthority.title=Entsorgungsinstanz +rma_recordsmanagement.property.rma_dispositionAuthority.decription=Entsorgungsinstanz + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Entsorgungsanweisungen +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Entsorgungsanweisungen + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Entsorgung auf Record-Ebene +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Entsorgung auf Record-Ebene + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Entsorgungsaktionen +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Entsorgungsaktionen + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definition der Entsorgungsaktion +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definition der Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionActionName.title=Name der Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionActionName.decription=Name der Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionDescription.title=Entsorgungsbeschreibung +rma_recordsmanagement.property.rma_dispositionDescription.decription=Entsorgungsbeschreibung +rma_recordsmanagement.property.rma_dispositionLocation.title=Entsorgungsort +rma_recordsmanagement.property.rma_dispositionLocation.decription=Entsorgungsort +rma_recordsmanagement.property.rma_dispositionPeriod.title=Entsorgungszeitraum +rma_recordsmanagement.property.rma_dispositionPeriod.decription=Entsorgungszeitraum +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Eigenschaft des Entsorgungszeitraums +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Eigenschaft des Entsorgungszeitraums +rma_recordsmanagement.property.rma_dispositionEvent.title=Entsorgungsereignis +rma_recordsmanagement.property.rma_dispositionEvent.decription=Entsorgungsereignis +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Entsorgungsereigniskombination +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Entsorgungsereigniskombination + +rma_recordsmanagement.type.rma_recordFolder.title=Record-Ordner +rma_recordsmanagement.type.rma_recordFolder.decription=Record-Ordner +rma_recordsmanagement.property.rma_isClosed.title=Record +rma_recordsmanagement.property.rma_isClosed.decription=Record + +rma_recordsmanagement.type.rma_recordCategory.title=Record-Kategorie +rma_recordsmanagement.type.rma_recordCategory.decription=Record-Kategorie + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Nicht elektronisches Dokument +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Nicht elektronisches Dokument +rma_recordsmanagement.property.rma_physicalSize.title=Physikalische Gr\u00f6\u00dfe +rma_recordsmanagement.property.rma_physicalSize.decription=Die Gr\u00f6\u00dfe des Dokuments wird in laufenden Metern gemessen. +rma_recordsmanagement.property.rma_numberOfCopies.title=Anzahl der Kopien +rma_recordsmanagement.property.rma_numberOfCopies.description=Die Anzahl der Kopien des Dokuments. +rma_recordsmanagement.property.rma_storageLocation.title=Speicherort +rma_recordsmanagement.property.rma_storageLocation.decription=Der physische Speicherort des Record. +rma_recordsmanagement.property.rma_shelf.title=Regal +rma_recordsmanagement.property.rma_shelf.decription=Das Regal, in dem sich der Record befindet. +rma_recordsmanagement.property.rma_box.title=Box +rma_recordsmanagement.property.rma_box.description=Die Box, in der sich der Record befindet. +rma_recordsmanagement.property.rma_file.title=Datei +rma_recordsmanagement.property.rma_file.decription=Die Datei, in der sich der Record befindet. + +rma_recordsmanagement.type.rma_dispositionAction.title=Entsorgungsaktion +rma_recordsmanagement.type.rma_dispositionAction.decription=Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionActionId.title=ID der Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionActionId.decription=ID der Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionAction.title=Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionAction.decription=Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionAsOf.title=Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Entsorgungsaktion +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Erlaubte Entsorgungsereignisse +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Erlaubte Entsorgungsereignisse +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Entsorgungsaktion gestartet um +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Entsorgungsaktion gestartet um +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Entsorgungsaktion gestartet von +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Entsorgungsaktion gestartet von +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Entsorgungsaktion abgeschlossen um +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Entsorgungsaktion abgeschlossen um +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Entsorgungsaktion abgeschlossen von +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Entsorgungsaktion abgeschlossen von +rma_recordsmanagement.association.rma_eventExecutions.title=Ereignisausf\u00fchrungen +rma_recordsmanagement.association.rma_eventExecutions.decription=Ereignisausf\u00fchrungen + +rma_recordsmanagement.type.rma_eventExecution.title=Ereignisausf\u00fchrung +rma_recordsmanagement.type.rma_eventExecution.decription=Ereignisausf\u00fchrung +rma_recordsmanagement.property.rma_eventExecutionName.title=Ereignisname +rma_recordsmanagement.property.rma_eventExecutionName.decription=Ereignisname +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Automatisches Ereignis +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Automatisches Ereignis +rma_recordsmanagement.property.rma_eventExecutionComplete.title=Abgeschlossenes Ereignis +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Abgeschlossenes Ereignis +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Ereignis abgeschlossen von +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Ereignis abgeschlossen von +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Ereignis abgeschlossen um +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Ereignis abgeschlossen um + +rma_recordsmanagement.type.rma_hold.title=Sperrbereich +rma_recordsmanagement.type.rma_hold.decription=Sperrbereich +rma_recordsmanagement.property.rma_holdReason.title=Sperrgrund +rma_recordsmanagement.property.rma_holdReason.decription=Sperrgrund +rma_recordsmanagement.association.rma_frozenRecords.title=Gesperrte Records +rma_recordsmanagement.association.rma_frozenRecords.decription=Gesperrte Records + +rma_recordsmanagement.type.rma_transfer.title=\u00dcbertragung +rma_recordsmanagement.type.rma_transfer.decription=\u00dcbertragung +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Anzeige bei \u00dcbertragung zur Aufnahme +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Anzeige bei \u00dcbertragung zur Aufnahme +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Anzeige bei PDF-\u00dcbertragung +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Anzeige bei PDF-\u00dcbertragung +rma_recordsmanagement.property.rma_transferLocation.title=PDF \u00fcbertragen +rma_recordsmanagement.property.rma_transferLocation.decription=PDF \u00fcbertragen +rma_recordsmanagement.association.rma_transferred.title=\u00dcbertragen +rma_recordsmanagement.association.rma_transferred.decription=\u00dcbertragen + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=Ablageplan-Komponente +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Ablageplan-Komponente +rma_recordsmanagement.property.rma_rootNodeRef.title=Root-Knoten +rma_recordsmanagement.property.rma_rootNodeRef.decription=Root-Knoten + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Records Management Root +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Records Management Root +rma_recordsmanagement.association.rma_holds.title=Sperren +rma_recordsmanagement.association.rma_holds.decription=Sperren +rma_recordsmanagement.association.rma_transfers.title=\u00dcbertragungen +rma_recordsmanagement.association.rma_transfers.decription=\u00dcbertragungen + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Abgeschlossener Record +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Abgeschlossener Record +rma_recordsmanagement.property.rma_declaredAt.title=Abschlussdatum +rma_recordsmanagement.property.rma_declaredAt.decription=Abschlussdatum +rma_recordsmanagement.property.rma_declaredBy.title=Abgeschlossen von +rma_recordsmanagement.property.rma_declaredBy.decription=Abgeschlossen von + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=ID der Record-Komponente +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=ID der Record-Komponente +rma_recordsmanagement.property.rma_identifier.title=ID +rma_recordsmanagement.property.rma_identifier.decription=Eindeutige Record-ID +rma_recordsmanagement.property.rma_dbUniquenessId.title=Eindeutigkeit der Datenbank +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Eindeutigkeit der Datenbank + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definition f\u00fcr besonders relevanten Record +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definition f\u00fcr besonders relevanten Record + +rma_recordsmanagement.property.rma_reviewPeriod.title=\u00dcberpr\u00fcfungszeitraum +rma_recordsmanagement.property.rma_reviewPeriod.decription=\u00dcberpr\u00fcfungszeitraum +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Kennzeichen f\u00fcr besonders relevante Records +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Kennzeichen f\u00fcr besonders relevante Records + +rma_recordsmanagement.aspect.rma_record.title=Record +rma_recordsmanagement.aspect.rma_record.decription=Record +rma_recordsmanagement.property.rma_dateFiled.title=Ablagedatum +rma_recordsmanagement.property.rma_dateFiled.decription=Ablagedatum +rma_recordsmanagement.property.rma_origionalName=Originalname + +rma_recordsmanagement.aspect.rma_recordMetaData.title=Record-Metadaten +rma_recordsmanagement.aspect.rma_recordMetaData.description=Markeraspekt f\u00fcr Record-Metadaten + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Gemeinsame Record-Details +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Gemeinsame Metadaten aller Record-Typen +rma_recordsmanagement.property.rma_location.title=Ort +rma_recordsmanagement.property.rma_location.decription=Ort + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Besonders relevanter Record +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Besonders relevanter Record +rma_recordsmanagement.property.rma_reviewAsOf.title=N\u00e4chste \u00dcberpr\u00fcfung +rma_recordsmanagement.property.rma_reviewAsOf.decription=N\u00e4chste \u00dcberpr\u00fcfung +rma_recordsmanagement.property.rma_notificationIssued.title=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. +rma_recordsmanagement.property.rma_notificationIssued.decription=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. + +rma_recordsmanagement.aspect.rma_scheduled.title=Geplant +rma_recordsmanagement.aspect.rma_scheduled.decription=Geplant +rma_recordsmanagement.association.rma_dispositionSchedule.title=Entsorgungsplan +rma_recordsmanagement.association.rma_dispositionSchedule.decription=Entsorgungsplan + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Entsorgungszyklus +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Entsorgungszyklus +rma_recordsmanagement.association.rma_nextDispositionAction.title=N\u00e4chste Entsorgungsaktion +rma_recordsmanagement.association.rma_nextDispositionAction.decription=N\u00e4chste Entsorgungsaktion +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Entsorgungsaktionsverlauf +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Entsorgungsaktionsverlauf + +rma_recordsmanagement.aspect.rma_cutOff.title=Getrennt +rma_recordsmanagement.aspect.rma_cutOff.decription=Getrennt +rma_recordsmanagement.property.rma_cutOffDate.title=Trenndatum +rma_recordsmanagement.property.rma_cutOffDate.decription=Trenndatum + +rma_recordsmanagement.aspect.rma_transferred.title=\u00dcbertragen +rma_recordsmanagement.aspect.rma_transferred.decription=\u00dcbertragen + +rma_recordsmanagement.aspect.rma_ascended.title=In Archiv aufgenommen +rma_recordsmanagement.aspect.rma_ascended.decription=In Archiv aufgenommen + +rma_recordsmanagement.aspect.rma_frozen.title=Gesperrt +rma_recordsmanagement.aspect.rma_frozen.decription=Gesperrt +rma_recordsmanagement.property.rma_frozenAt.title=Gehalten in +rma_recordsmanagement.property.rma_frozenAt.decription=Gehalten in +rma_recordsmanagement.property.rma_frozenBy.title=Gehalten von +rma_recordsmanagement.property.rma_frozenBy.decription=Gehalten von + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Root von Caveat-Konfiguration +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Root von Caveat-Konfiguration +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat-Konfiguration +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat-Konfiguration + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=E-Mail-Konfigurations-Root +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=E-Mail-Konfigurations-Root +rma_recordsmanagement.association.rma_emailConfigAssoc.title=E-Mail-Konfiguration +rma_recordsmanagement.association.rma_emailConfigAssoc.description=E-Mail-Konfiguration + +rma_recordsmanagement.aspect.rma_recordSearch.title=Record-Suche +rma_recordsmanagement.aspect.rma_recordSearch.decription=Komprimierte Suchinformation zur Unterst\u00fctzung der Records Management Suche. +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Mit Entsorgungsplan +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Gibt an, ob das Element \u00fcber einen zugeordneten Entsorgungsplan verf\u00fcgt. +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Name der Entsorgungsaktion +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Der Name der n\u00e4chsten Entsorgungsaktion. +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Start der Entsorgungsaktion +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=Das Datum, ab dem die n\u00e4chste Entsorgungsaktion geeignet wird. +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Entsorgungszeitraum +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Entsorgungszeitraum +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Ausdruck f\u00fcr Entsorgungszeitraum +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Ausdruck f\u00fcr Entsorgungszeitraum +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Erlaubte Entsorgungsereignisse +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Erlaubte Entsorgungsereignisse +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Entsorgungsereignisse +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Entsorgungsereignisse +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Entsorgungsinstanz +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Entsorgungsinstanz +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Entsorgungsanweisungen +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Entsorgungsanweisungen +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Sperrgrund +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Sperrgrund +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u00dcberpr\u00fcfungszeitraum f\u00fcr besonders relevante Records +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u00dcberpr\u00fcfungszeitraum f\u00fcr besonders relevante Records +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Ausdruck f\u00fcr \u00dcberpr\u00fcfungszeitraum +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Ausdruck f\u00fcr \u00dcberpr\u00fcfungszeitraum + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Versionierter Record +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Versionierter Record + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Nicht ver\u00f6ffentlichte Aktualisierung +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Nicht ver\u00f6ffentlichte Aktualisierung +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Nicht ver\u00f6ffentlichte Aktualisierung +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Gibt an, ob eine nicht ver\u00f6ffentlichte Aktualisierung vorhanden ist. +rma_recordsmanagement.property.rma_updateTo.title=Aktualisieren auf +rma_recordsmanagement.property.rma_updateTo.description=Das Ziel der Aktualisierung. +rma_recordsmanagement.property.rma_updatedProperties.title=Aktualisierte Eigenschaften +rma_recordsmanagement.property.rma_updatedProperties.description=Die aktualisierten Eigenschaften. +rma_recordsmanagement.property.rma_publishInProgress.title=Laufende Ver\u00f6ffentlichung +rma_recordsmanagement.property.rma_publishInProgress.description=Gibt an, ob derzeit eine Ver\u00f6ffentlichung durchgef\u00fchrt wird. + +rma_recordsmanagement.aspect.dod_ghosted.title=Nur Metadaten enthaltender Record +rma_recordsmanagement.aspect.dod_ghosted.description=Nur Metadaten enthaltender Record + +listconstraint.rmc_tlList.title=Speicherorte \u00fcbertragen listconstraint.rmc_smList.title=Zus\u00e4tzliche Markierungen \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties index acce0fc05d..94e539b653 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Modelo de contenido de gesti\u00f3n de documentos de archivo - -rma_recordsmanagement.type.rma_rmsite.title=Sitio de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.type.rma_rmsite.description=Sitio especializado para gesti\u00f3n de documentos de archivo - -rma_recordsmanagement.type.rma_caveatConfig.title=Configuraci\u00f3n de advertencia -rma_recordsmanagement.type.rma_caveatConfig.decription=Configuraci\u00f3n de advertencia - -rma_recordsmanagement.type.rma_emailConfig.title=Configuraci\u00f3n de correo electr\u00f3nico -rma_recordsmanagement.type.rma_emailConfig.decription=Configuraci\u00f3n de correo electr\u00f3nico - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Contenedor de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Contenedor de gesti\u00f3n de documentos de archivo - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Contenedor ra\u00edz de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Contenedor ra\u00edz de gesti\u00f3n de documentos de archivo - -rma_recordsmanagement.type.rma_dispositionSchedule.title=Planificaci\u00f3n de disposici\u00f3n -rma_recordsmanagement.type.rma_dispositionSchedule.decription=Planificaci\u00f3n de disposici\u00f3n - -rma_recordsmanagement.property.rma_dispositionAuthority.title=Autoridad de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionAuthority.decription=Autoridad de disposici\u00f3n - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Instrucciones de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Instrucciones de disposici\u00f3n - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposici\u00f3n de nivel de documento de archivo -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposici\u00f3n de nivel de documento de archivo - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Acciones de disposici\u00f3n -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Acciones de disposici\u00f3n - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definici\u00f3n de acciones de disposici\u00f3n -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definici\u00f3n de acciones de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionActionName.title=Nombre de acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionActionName.decription=Nombre de acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionDescription.title=Descripci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionDescription.decription=Descripci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionLocation.title=Ubicaci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionLocation.decription=Ubicaci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionPeriod.title=Per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionPeriod.decription=Per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propiedad de per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propiedad de per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionEvent.title=Evento de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionEvent.decription=Evento de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinaci\u00f3n de evento de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinaci\u00f3n de evento de disposici\u00f3n - -rma_recordsmanagement.type.rma_recordFolder.title=Carpeta de documentos de archivo -rma_recordsmanagement.type.rma_recordFolder.decription=Carpeta de documentos de archivo -rma_recordsmanagement.property.rma_isClosed.title=Documento de archivo -rma_recordsmanagement.property.rma_isClosed.decription=Documento de archivo - -rma_recordsmanagement.type.rma_recordCategory.title=Categor\u00eda de documentos de archivo -rma_recordsmanagement.type.rma_recordCategory.decription=Categor\u00eda de documentos de archivo - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Documento no electr\u00f3nico -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Documento no electr\u00f3nico -rma_recordsmanagement.property.rma_physicalSize.title=Tama\u00f1o f\u00edsico -rma_recordsmanagement.property.rma_physicalSize.decription=El tama\u00f1o del documento en metros lineales. -rma_recordsmanagement.property.rma_numberOfCopies.title=N\u00famero de copias -rma_recordsmanagement.property.rma_numberOfCopies.description=El n\u00famero de copias del documento. -rma_recordsmanagement.property.rma_storageLocation.title=Ubicaci\u00f3n de almacenamiento -rma_recordsmanagement.property.rma_storageLocation.decription=La ubicaci\u00f3n f\u00edsica de almacenamiento del documento de archivo. -rma_recordsmanagement.property.rma_shelf.title=Estanter\u00eda -rma_recordsmanagement.property.rma_shelf.decription=La estanter\u00eda en la que reside el documento de archivo. -rma_recordsmanagement.property.rma_box.title=Caja -rma_recordsmanagement.property.rma_box.description=La caja en la que reside el documento de archivo. -rma_recordsmanagement.property.rma_file.title=Fichero -rma_recordsmanagement.property.rma_file.decription=El fichero en el que reside el documento de archivo. - -rma_recordsmanagement.type.rma_dispositionAction.title=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.type.rma_dispositionAction.decription=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionActionId.title=Id de acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionActionId.decription=Id de acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionAction.title=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionAction.decription=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionAsOf.title=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Eventos de disposici\u00f3n que re\u00fanen los requisitos -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Eventos de disposici\u00f3n que re\u00fanen los requisitos -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Acci\u00f3n de disposici\u00f3n iniciada en -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Acci\u00f3n de disposici\u00f3n iniciada en -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Acci\u00f3n de disposici\u00f3n iniciada por -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Acci\u00f3n de disposici\u00f3n iniciada por -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Acci\u00f3n de disposici\u00f3n completada en -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Acci\u00f3n de disposici\u00f3n completada en -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Acci\u00f3n de disposici\u00f3n completada por -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Acci\u00f3n de disposici\u00f3n completada por -rma_recordsmanagement.association.rma_eventExecutions.title=Ejecuciones de evento -rma_recordsmanagement.association.rma_eventExecutions.decription=Ejecuciones de evento - -rma_recordsmanagement.type.rma_eventExecution.title=Ejecuci\u00f3n de evento -rma_recordsmanagement.type.rma_eventExecution.decription=Ejecuci\u00f3n de evento -rma_recordsmanagement.property.rma_eventExecutionName.title=Nombre de evento -rma_recordsmanagement.property.rma_eventExecutionName.decription=Nombre de evento -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Evento autom\u00e1tico -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Evento autom\u00e1tico -rma_recordsmanagement.property.rma_eventExecutionComplete.title=Evento completo -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Evento completo -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Evento completado por -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Evento completado por -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Evento completado en -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Evento completado en - -rma_recordsmanagement.type.rma_hold.title=Bloqueo -rma_recordsmanagement.type.rma_hold.decription=Bloqueo -rma_recordsmanagement.property.rma_holdReason.title=Raz\u00f3n de bloqueo -rma_recordsmanagement.property.rma_holdReason.decription=Raz\u00f3n de bloqueo -rma_recordsmanagement.association.rma_frozenRecords.title=Documentos de archivo bloqueados -rma_recordsmanagement.association.rma_frozenRecords.decription=Documentos de archivo bloqueados - -rma_recordsmanagement.type.rma_transfer.title=Transferencia -rma_recordsmanagement.type.rma_transfer.decription=Transferencia -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Indicador de adhesi\u00f3n y transferencia -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Indicador de adhesi\u00f3n y transferencia -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Indicador de transferencia de PDF -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Indicador de transferencia de PDF -rma_recordsmanagement.property.rma_transferLocation.title=Transferencia de PDF -rma_recordsmanagement.property.rma_transferLocation.decription=Transferencia de PDF -rma_recordsmanagement.association.rma_transferred.title=Transferido -rma_recordsmanagement.association.rma_transferred.decription=Transferido - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=Componente del plan de ficheros -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Componente del plan de ficheros -rma_recordsmanagement.property.rma_rootNodeRef.title=Nodo ra\u00edz -rma_recordsmanagement.property.rma_rootNodeRef.decription=Nodo ra\u00edz - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Ra\u00edz de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Ra\u00edz de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.association.rma_holds.title=Bloqueos -rma_recordsmanagement.association.rma_holds.decription=Bloqueos -rma_recordsmanagement.association.rma_transfers.title=Transferencias -rma_recordsmanagement.association.rma_transfers.decription=Transferencias - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Documento de archivo completado -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Documento de archivo completado -rma_recordsmanagement.property.rma_declaredAt.title=Fecha de finalizaci\u00f3n -rma_recordsmanagement.property.rma_declaredAt.decription=Fecha de finalizaci\u00f3n -rma_recordsmanagement.property.rma_declaredBy.title=Completado por -rma_recordsmanagement.property.rma_declaredBy.decription=Completado por - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificador de componente de documento de archivo -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificador de componente de documento de archivo -rma_recordsmanagement.property.rma_identifier.title=Identificador -rma_recordsmanagement.property.rma_identifier.decription=Identificador \u00fanico de documento de archivo -rma_recordsmanagement.property.rma_dbUniquenessId.title=Singularidad de la base de datos -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Singularidad de la base de datos - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definici\u00f3n de documento de archivo vital -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definici\u00f3n de documento de archivo vital - -rma_recordsmanagement.property.rma_reviewPeriod.title=Per\u00edodo de revisi\u00f3n -rma_recordsmanagement.property.rma_reviewPeriod.decription=Per\u00edodo de revisi\u00f3n -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicador de documento de archivo vital -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicador de documento de archivo vital - -rma_recordsmanagement.aspect.rma_record.title=Documento de archivo -rma_recordsmanagement.aspect.rma_record.decription=Documento de archivo -rma_recordsmanagement.property.rma_dateFiled.title=Fecha de archivado -rma_recordsmanagement.property.rma_dateFiled.decription=Fecha de archivado -rma_recordsmanagement.property.rma_origionalName=Nombre original - -rma_recordsmanagement.aspect.rma_recordMetaData.title=Metadatos del documento de archivo -rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspecto de marcador para metadatos del documento de archivo - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Detalles de documento de archivo com\u00fan -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Metadatos comunes para todos los tipos de documento de archivo -rma_recordsmanagement.property.rma_location.title=Ubicaci\u00f3n -rma_recordsmanagement.property.rma_location.decription=Ubicaci\u00f3n - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Documento de archivo vital -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Documento de archivo vital -rma_recordsmanagement.property.rma_reviewAsOf.title=Pr\u00f3xima revisi\u00f3n -rma_recordsmanagement.property.rma_reviewAsOf.decription=Pr\u00f3xima revisi\u00f3n -rma_recordsmanagement.property.rma_notificationIssued.title=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo -rma_recordsmanagement.property.rma_notificationIssued.decription=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo - -rma_recordsmanagement.aspect.rma_scheduled.title=Planificado -rma_recordsmanagement.aspect.rma_scheduled.decription=Planificado -rma_recordsmanagement.association.rma_dispositionSchedule.title=Planificaci\u00f3n de disposici\u00f3n -rma_recordsmanagement.association.rma_dispositionSchedule.decription=Planificaci\u00f3n de disposici\u00f3n - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Ciclo de vida de disposici\u00f3n -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Ciclo de vida de disposici\u00f3n -rma_recordsmanagement.association.rma_nextDispositionAction.title=Pr\u00f3xima acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.association.rma_nextDispositionAction.decription=Pr\u00f3xima acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Historial de acciones de disposici\u00f3n -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Historial de acciones de disposici\u00f3n - -rma_recordsmanagement.aspect.rma_cutOff.title=Interrumpir -rma_recordsmanagement.aspect.rma_cutOff.decription=Interrumpir -rma_recordsmanagement.property.rma_cutOffDate.title=Fecha de interrupci\u00f3n -rma_recordsmanagement.property.rma_cutOffDate.decription=Fecha de interrupci\u00f3n - -rma_recordsmanagement.aspect.rma_transferred.title=Transferido -rma_recordsmanagement.aspect.rma_transferred.decription=Transferido - -rma_recordsmanagement.aspect.rma_ascended.title=Ascendido -rma_recordsmanagement.aspect.rma_ascended.decription=Ascendido - -rma_recordsmanagement.aspect.rma_frozen.title=En espera -rma_recordsmanagement.aspect.rma_frozen.decription=En espera -rma_recordsmanagement.property.rma_frozenAt.title=Bloqueado en -rma_recordsmanagement.property.rma_frozenAt.decription=Bloqueado en -rma_recordsmanagement.property.rma_frozenBy.title=Bloqueado por -rma_recordsmanagement.property.rma_frozenBy.decription=Bloqueado por - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Ra\u00edz de configuraci\u00f3n de advertencia -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Ra\u00edz de configuraci\u00f3n de advertencia -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configuraci\u00f3n de advertencia -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configuraci\u00f3n de advertencia - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Ra\u00edz de configuraci\u00f3n de correo electr\u00f3nico -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Ra\u00edz de configuraci\u00f3n de correo electr\u00f3nico -rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configuraci\u00f3n de correo electr\u00f3nico -rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configuraci\u00f3n de correo electr\u00f3nico - -rma_recordsmanagement.aspect.rma_recordSearch.title=B\u00fasqueda de documentos de archivo -rma_recordsmanagement.aspect.rma_recordSearch.decription=Informaci\u00f3n de b\u00fasqueda acumulada para b\u00fasqueda de gesti\u00f3n de documentos de archivo -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Tiene planificaci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indica si el elemento tiene planificaci\u00f3n de disposici\u00f3n asociada -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nombre de acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=El nombre de la pr\u00f3xima acci\u00f3n de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Acci\u00f3n de disposici\u00f3n de -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La fecha en la cual la pr\u00f3xima acci\u00f3n de disposici\u00f3n reunir\u00e1 los requisitos -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Expresi\u00f3n de per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Expresi\u00f3n de per\u00edodo de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Eventos de disposici\u00f3n que re\u00fanen los requisitos -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Eventos de disposici\u00f3n que re\u00fanen los requisitos -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Eventos de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Eventos de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Autoridad de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Autoridad de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Instrucciones de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Instrucciones de disposici\u00f3n -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Raz\u00f3n de bloqueo -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Raz\u00f3n de bloqueo -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Per\u00edodo de revisi\u00f3n de documento de archivo vital -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Per\u00edodo de revisi\u00f3n de documento de archivo vital -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Expresi\u00f3n de per\u00edodo de revisi\u00f3n -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Expresi\u00f3n de per\u00edodo de revisi\u00f3n - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Documento de archivo versionado -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Documento de archivo versionado - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Actualizaci\u00f3n sin publicar -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Actualizaci\u00f3n sin publicar -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Actualizaci\u00f3n sin publicar -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indica si existe una actualizaci\u00f3n sin publicar -rma_recordsmanagement.property.rma_updateTo.title=Actualizar a -rma_recordsmanagement.property.rma_updateTo.description=Destino de la actualizaci\u00f3n -rma_recordsmanagement.property.rma_updatedProperties.title=Propiedades actualizadas -rma_recordsmanagement.property.rma_updatedProperties.description=Las propiedades actualizadas -rma_recordsmanagement.property.rma_publishInProgress.title=Publicaci\u00f3n en curso -rma_recordsmanagement.property.rma_publishInProgress.description=Indica si una publicaci\u00f3n se encuentra en curso - -rma_recordsmanagement.aspect.dod_ghosted.title=Documento de archivo solo de metadatos -rma_recordsmanagement.aspect.dod_ghosted.description=Documento de archivo solo de metadatos - -listconstraint.rmc_tlList.title=Ubicaciones de la transferencia +rma_recordsmanagement.description=Modelo de contenido de gesti\u00f3n de documentos de archivo + +rma_recordsmanagement.type.rma_rmsite.title=Sitio de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.type.rma_rmsite.description=Sitio especializado para gesti\u00f3n de documentos de archivo + +rma_recordsmanagement.type.rma_caveatConfig.title=Configuraci\u00f3n de advertencia +rma_recordsmanagement.type.rma_caveatConfig.decription=Configuraci\u00f3n de advertencia + +rma_recordsmanagement.type.rma_emailConfig.title=Configuraci\u00f3n de correo electr\u00f3nico +rma_recordsmanagement.type.rma_emailConfig.decription=Configuraci\u00f3n de correo electr\u00f3nico + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Contenedor de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Contenedor de gesti\u00f3n de documentos de archivo + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Contenedor ra\u00edz de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Contenedor ra\u00edz de gesti\u00f3n de documentos de archivo + +rma_recordsmanagement.type.rma_dispositionSchedule.title=Planificaci\u00f3n de disposici\u00f3n +rma_recordsmanagement.type.rma_dispositionSchedule.decription=Planificaci\u00f3n de disposici\u00f3n + +rma_recordsmanagement.property.rma_dispositionAuthority.title=Autoridad de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionAuthority.decription=Autoridad de disposici\u00f3n + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Instrucciones de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Instrucciones de disposici\u00f3n + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposici\u00f3n de nivel de documento de archivo +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposici\u00f3n de nivel de documento de archivo + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Acciones de disposici\u00f3n +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Acciones de disposici\u00f3n + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definici\u00f3n de acciones de disposici\u00f3n +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definici\u00f3n de acciones de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionActionName.title=Nombre de acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionActionName.decription=Nombre de acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionDescription.title=Descripci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionDescription.decription=Descripci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionLocation.title=Ubicaci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionLocation.decription=Ubicaci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionPeriod.title=Per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionPeriod.decription=Per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propiedad de per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propiedad de per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionEvent.title=Evento de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionEvent.decription=Evento de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinaci\u00f3n de evento de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinaci\u00f3n de evento de disposici\u00f3n + +rma_recordsmanagement.type.rma_recordFolder.title=Carpeta de documentos de archivo +rma_recordsmanagement.type.rma_recordFolder.decription=Carpeta de documentos de archivo +rma_recordsmanagement.property.rma_isClosed.title=Documento de archivo +rma_recordsmanagement.property.rma_isClosed.decription=Documento de archivo + +rma_recordsmanagement.type.rma_recordCategory.title=Categor\u00eda de documentos de archivo +rma_recordsmanagement.type.rma_recordCategory.decription=Categor\u00eda de documentos de archivo + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Documento no electr\u00f3nico +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Documento no electr\u00f3nico +rma_recordsmanagement.property.rma_physicalSize.title=Tama\u00f1o f\u00edsico +rma_recordsmanagement.property.rma_physicalSize.decription=El tama\u00f1o del documento en metros lineales. +rma_recordsmanagement.property.rma_numberOfCopies.title=N\u00famero de copias +rma_recordsmanagement.property.rma_numberOfCopies.description=El n\u00famero de copias del documento. +rma_recordsmanagement.property.rma_storageLocation.title=Ubicaci\u00f3n de almacenamiento +rma_recordsmanagement.property.rma_storageLocation.decription=La ubicaci\u00f3n f\u00edsica de almacenamiento del documento de archivo. +rma_recordsmanagement.property.rma_shelf.title=Estanter\u00eda +rma_recordsmanagement.property.rma_shelf.decription=La estanter\u00eda en la que reside el documento de archivo. +rma_recordsmanagement.property.rma_box.title=Caja +rma_recordsmanagement.property.rma_box.description=La caja en la que reside el documento de archivo. +rma_recordsmanagement.property.rma_file.title=Fichero +rma_recordsmanagement.property.rma_file.decription=El fichero en el que reside el documento de archivo. + +rma_recordsmanagement.type.rma_dispositionAction.title=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.type.rma_dispositionAction.decription=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionActionId.title=Id de acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionActionId.decription=Id de acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionAction.title=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionAction.decription=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionAsOf.title=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Eventos de disposici\u00f3n que re\u00fanen los requisitos +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Eventos de disposici\u00f3n que re\u00fanen los requisitos +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Acci\u00f3n de disposici\u00f3n iniciada en +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Acci\u00f3n de disposici\u00f3n iniciada en +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Acci\u00f3n de disposici\u00f3n iniciada por +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Acci\u00f3n de disposici\u00f3n iniciada por +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Acci\u00f3n de disposici\u00f3n completada en +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Acci\u00f3n de disposici\u00f3n completada en +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Acci\u00f3n de disposici\u00f3n completada por +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Acci\u00f3n de disposici\u00f3n completada por +rma_recordsmanagement.association.rma_eventExecutions.title=Ejecuciones de evento +rma_recordsmanagement.association.rma_eventExecutions.decription=Ejecuciones de evento + +rma_recordsmanagement.type.rma_eventExecution.title=Ejecuci\u00f3n de evento +rma_recordsmanagement.type.rma_eventExecution.decription=Ejecuci\u00f3n de evento +rma_recordsmanagement.property.rma_eventExecutionName.title=Nombre de evento +rma_recordsmanagement.property.rma_eventExecutionName.decription=Nombre de evento +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Evento autom\u00e1tico +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Evento autom\u00e1tico +rma_recordsmanagement.property.rma_eventExecutionComplete.title=Evento completo +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Evento completo +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Evento completado por +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Evento completado por +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Evento completado en +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Evento completado en + +rma_recordsmanagement.type.rma_hold.title=Bloqueo +rma_recordsmanagement.type.rma_hold.decription=Bloqueo +rma_recordsmanagement.property.rma_holdReason.title=Raz\u00f3n de bloqueo +rma_recordsmanagement.property.rma_holdReason.decription=Raz\u00f3n de bloqueo +rma_recordsmanagement.association.rma_frozenRecords.title=Documentos de archivo bloqueados +rma_recordsmanagement.association.rma_frozenRecords.decription=Documentos de archivo bloqueados + +rma_recordsmanagement.type.rma_transfer.title=Transferencia +rma_recordsmanagement.type.rma_transfer.decription=Transferencia +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Indicador de adhesi\u00f3n y transferencia +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Indicador de adhesi\u00f3n y transferencia +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Indicador de transferencia de PDF +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Indicador de transferencia de PDF +rma_recordsmanagement.property.rma_transferLocation.title=Transferencia de PDF +rma_recordsmanagement.property.rma_transferLocation.decription=Transferencia de PDF +rma_recordsmanagement.association.rma_transferred.title=Transferido +rma_recordsmanagement.association.rma_transferred.decription=Transferido + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=Componente del plan de ficheros +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Componente del plan de ficheros +rma_recordsmanagement.property.rma_rootNodeRef.title=Nodo ra\u00edz +rma_recordsmanagement.property.rma_rootNodeRef.decription=Nodo ra\u00edz + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Ra\u00edz de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Ra\u00edz de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.association.rma_holds.title=Bloqueos +rma_recordsmanagement.association.rma_holds.decription=Bloqueos +rma_recordsmanagement.association.rma_transfers.title=Transferencias +rma_recordsmanagement.association.rma_transfers.decription=Transferencias + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Documento de archivo completado +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Documento de archivo completado +rma_recordsmanagement.property.rma_declaredAt.title=Fecha de finalizaci\u00f3n +rma_recordsmanagement.property.rma_declaredAt.decription=Fecha de finalizaci\u00f3n +rma_recordsmanagement.property.rma_declaredBy.title=Completado por +rma_recordsmanagement.property.rma_declaredBy.decription=Completado por + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificador de componente de documento de archivo +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificador de componente de documento de archivo +rma_recordsmanagement.property.rma_identifier.title=Identificador +rma_recordsmanagement.property.rma_identifier.decription=Identificador \u00fanico de documento de archivo +rma_recordsmanagement.property.rma_dbUniquenessId.title=Singularidad de la base de datos +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Singularidad de la base de datos + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definici\u00f3n de documento de archivo vital +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definici\u00f3n de documento de archivo vital + +rma_recordsmanagement.property.rma_reviewPeriod.title=Per\u00edodo de revisi\u00f3n +rma_recordsmanagement.property.rma_reviewPeriod.decription=Per\u00edodo de revisi\u00f3n +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicador de documento de archivo vital +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicador de documento de archivo vital + +rma_recordsmanagement.aspect.rma_record.title=Documento de archivo +rma_recordsmanagement.aspect.rma_record.decription=Documento de archivo +rma_recordsmanagement.property.rma_dateFiled.title=Fecha de archivado +rma_recordsmanagement.property.rma_dateFiled.decription=Fecha de archivado +rma_recordsmanagement.property.rma_origionalName=Nombre original + +rma_recordsmanagement.aspect.rma_recordMetaData.title=Metadatos del documento de archivo +rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspecto de marcador para metadatos del documento de archivo + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Detalles de documento de archivo com\u00fan +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Metadatos comunes para todos los tipos de documento de archivo +rma_recordsmanagement.property.rma_location.title=Ubicaci\u00f3n +rma_recordsmanagement.property.rma_location.decription=Ubicaci\u00f3n + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Documento de archivo vital +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Documento de archivo vital +rma_recordsmanagement.property.rma_reviewAsOf.title=Pr\u00f3xima revisi\u00f3n +rma_recordsmanagement.property.rma_reviewAsOf.decription=Pr\u00f3xima revisi\u00f3n +rma_recordsmanagement.property.rma_notificationIssued.title=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo +rma_recordsmanagement.property.rma_notificationIssued.decription=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo + +rma_recordsmanagement.aspect.rma_scheduled.title=Planificado +rma_recordsmanagement.aspect.rma_scheduled.decription=Planificado +rma_recordsmanagement.association.rma_dispositionSchedule.title=Planificaci\u00f3n de disposici\u00f3n +rma_recordsmanagement.association.rma_dispositionSchedule.decription=Planificaci\u00f3n de disposici\u00f3n + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Ciclo de vida de disposici\u00f3n +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Ciclo de vida de disposici\u00f3n +rma_recordsmanagement.association.rma_nextDispositionAction.title=Pr\u00f3xima acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.association.rma_nextDispositionAction.decription=Pr\u00f3xima acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Historial de acciones de disposici\u00f3n +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Historial de acciones de disposici\u00f3n + +rma_recordsmanagement.aspect.rma_cutOff.title=Interrumpir +rma_recordsmanagement.aspect.rma_cutOff.decription=Interrumpir +rma_recordsmanagement.property.rma_cutOffDate.title=Fecha de interrupci\u00f3n +rma_recordsmanagement.property.rma_cutOffDate.decription=Fecha de interrupci\u00f3n + +rma_recordsmanagement.aspect.rma_transferred.title=Transferido +rma_recordsmanagement.aspect.rma_transferred.decription=Transferido + +rma_recordsmanagement.aspect.rma_ascended.title=Ascendido +rma_recordsmanagement.aspect.rma_ascended.decription=Ascendido + +rma_recordsmanagement.aspect.rma_frozen.title=En espera +rma_recordsmanagement.aspect.rma_frozen.decription=En espera +rma_recordsmanagement.property.rma_frozenAt.title=Bloqueado en +rma_recordsmanagement.property.rma_frozenAt.decription=Bloqueado en +rma_recordsmanagement.property.rma_frozenBy.title=Bloqueado por +rma_recordsmanagement.property.rma_frozenBy.decription=Bloqueado por + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Ra\u00edz de configuraci\u00f3n de advertencia +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Ra\u00edz de configuraci\u00f3n de advertencia +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configuraci\u00f3n de advertencia +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configuraci\u00f3n de advertencia + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Ra\u00edz de configuraci\u00f3n de correo electr\u00f3nico +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Ra\u00edz de configuraci\u00f3n de correo electr\u00f3nico +rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configuraci\u00f3n de correo electr\u00f3nico +rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configuraci\u00f3n de correo electr\u00f3nico + +rma_recordsmanagement.aspect.rma_recordSearch.title=B\u00fasqueda de documentos de archivo +rma_recordsmanagement.aspect.rma_recordSearch.decription=Informaci\u00f3n de b\u00fasqueda acumulada para b\u00fasqueda de gesti\u00f3n de documentos de archivo +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Tiene planificaci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indica si el elemento tiene planificaci\u00f3n de disposici\u00f3n asociada +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nombre de acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=El nombre de la pr\u00f3xima acci\u00f3n de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Acci\u00f3n de disposici\u00f3n de +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La fecha en la cual la pr\u00f3xima acci\u00f3n de disposici\u00f3n reunir\u00e1 los requisitos +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Expresi\u00f3n de per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Expresi\u00f3n de per\u00edodo de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Eventos de disposici\u00f3n que re\u00fanen los requisitos +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Eventos de disposici\u00f3n que re\u00fanen los requisitos +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Eventos de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Eventos de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Autoridad de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Autoridad de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Instrucciones de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Instrucciones de disposici\u00f3n +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Raz\u00f3n de bloqueo +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Raz\u00f3n de bloqueo +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Per\u00edodo de revisi\u00f3n de documento de archivo vital +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Per\u00edodo de revisi\u00f3n de documento de archivo vital +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Expresi\u00f3n de per\u00edodo de revisi\u00f3n +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Expresi\u00f3n de per\u00edodo de revisi\u00f3n + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Documento de archivo versionado +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Documento de archivo versionado + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Actualizaci\u00f3n sin publicar +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Actualizaci\u00f3n sin publicar +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Actualizaci\u00f3n sin publicar +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indica si existe una actualizaci\u00f3n sin publicar +rma_recordsmanagement.property.rma_updateTo.title=Actualizar a +rma_recordsmanagement.property.rma_updateTo.description=Destino de la actualizaci\u00f3n +rma_recordsmanagement.property.rma_updatedProperties.title=Propiedades actualizadas +rma_recordsmanagement.property.rma_updatedProperties.description=Las propiedades actualizadas +rma_recordsmanagement.property.rma_publishInProgress.title=Publicaci\u00f3n en curso +rma_recordsmanagement.property.rma_publishInProgress.description=Indica si una publicaci\u00f3n se encuentra en curso + +rma_recordsmanagement.aspect.dod_ghosted.title=Documento de archivo solo de metadatos +rma_recordsmanagement.aspect.dod_ghosted.description=Documento de archivo solo de metadatos + +listconstraint.rmc_tlList.title=Ubicaciones de la transferencia listconstraint.rmc_smList.title=Marcas complementarias \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties index 1af89e8b8b..3eac7bb3ca 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Mod\u00e8le de contenu de gestion des archives - -rma_recordsmanagement.type.rma_rmsite.title=Site de gestion des archives -rma_recordsmanagement.type.rma_rmsite.description=Site sp\u00e9cialis\u00e9 pour la gestion des archives - -rma_recordsmanagement.type.rma_caveatConfig.title=Configuration de mise en garde -rma_recordsmanagement.type.rma_caveatConfig.decription=Configuration de mise en garde - -rma_recordsmanagement.type.rma_emailConfig.title=Configuration du courriel -rma_recordsmanagement.type.rma_emailConfig.decription=Configuration du courriel - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Conteneur de gestion des archives -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Conteneur de gestion des archives - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Conteneur de la racine du site de gestion des archives -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Conteneur de la racine du site de gestion des archives - -rma_recordsmanagement.type.rma_dispositionSchedule.title=R\u00e8gle de conservation -rma_recordsmanagement.type.rma_dispositionSchedule.decription=R\u00e8gle de conservation - -rma_recordsmanagement.property.rma_dispositionAuthority.title=D\u00e9tenteur principal -rma_recordsmanagement.property.rma_dispositionAuthority.decription=D\u00e9tenteur principal - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Instructions de disposition -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Instructions de disposition - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposition au niveau du document d'archives -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposition au niveau du document d'archives - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Actions de disposition -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Actions de disposition - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=D\u00e9finition de l'action de disposition -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=D\u00e9finition de l'action de disposition -rma_recordsmanagement.property.rma_dispositionActionName.title=Nom de l'action de disposition -rma_recordsmanagement.property.rma_dispositionActionName.decription=Nom de l'action de disposition -rma_recordsmanagement.property.rma_dispositionDescription.title=Description de la disposition -rma_recordsmanagement.property.rma_dispositionDescription.decription=Description de la disposition -rma_recordsmanagement.property.rma_dispositionLocation.title=Emplacement de la disposition -rma_recordsmanagement.property.rma_dispositionLocation.decription=Emplacement de la disposition -rma_recordsmanagement.property.rma_dispositionPeriod.title=P\u00e9riode de la disposition -rma_recordsmanagement.property.rma_dispositionPeriod.decription=P\u00e9riode de la disposition -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propri\u00e9t\u00e9 de la p\u00e9riode de disposition -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propri\u00e9t\u00e9 de la p\u00e9riode de disposition -rma_recordsmanagement.property.rma_dispositionEvent.title=\u00c9v\u00e9nement de disposition -rma_recordsmanagement.property.rma_dispositionEvent.decription=\u00c9v\u00e9nement de disposition -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinaison d'\u00e9v\u00e9nements de disposition -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinaison d'\u00e9v\u00e9nements de disposition - -rma_recordsmanagement.type.rma_recordFolder.title=Dossier d'archives -rma_recordsmanagement.type.rma_recordFolder.decription=Dossier d'archives -rma_recordsmanagement.property.rma_isClosed.title=Document d'archives -rma_recordsmanagement.property.rma_isClosed.decription=Document d'archives - -rma_recordsmanagement.type.rma_recordCategory.title=Cat\u00e9gorie de document d'archives -rma_recordsmanagement.type.rma_recordCategory.decription=Cat\u00e9gorie de document d'archives - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Document non \u00e9lectronique -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Document non \u00e9lectronique -rma_recordsmanagement.property.rma_physicalSize.title=Taille physique -rma_recordsmanagement.property.rma_physicalSize.decription=Taille du document mesur\u00e9e en m\u00e8tres lin\u00e9aires. -rma_recordsmanagement.property.rma_numberOfCopies.title=Nombre de copies -rma_recordsmanagement.property.rma_numberOfCopies.description=Nombre de copies du document. -rma_recordsmanagement.property.rma_storageLocation.title=Emplacement de stockage -rma_recordsmanagement.property.rma_storageLocation.decription=Emplacement de stockage physique du document d'archives. -rma_recordsmanagement.property.rma_shelf.title=\u00c9tag\u00e8re -rma_recordsmanagement.property.rma_shelf.decription=\u00c9tag\u00e8re o\u00f9 se trouve le document d'archives. -rma_recordsmanagement.property.rma_box.title=Bo\u00eete -rma_recordsmanagement.property.rma_box.description=Bo\u00eete o\u00f9 se trouve le document d'archives. -rma_recordsmanagement.property.rma_file.title=Fichier -rma_recordsmanagement.property.rma_file.decription=Fichier du document d'archives. - -rma_recordsmanagement.type.rma_dispositionAction.title=Action de disposition -rma_recordsmanagement.type.rma_dispositionAction.decription=Action de disposition -rma_recordsmanagement.property.rma_dispositionActionId.title=Identifiant de l'action de disposition -rma_recordsmanagement.property.rma_dispositionActionId.decription=Identifiant de l'action de disposition -rma_recordsmanagement.property.rma_dispositionAction.title=Action de disposition -rma_recordsmanagement.property.rma_dispositionAction.decription=Action de disposition -rma_recordsmanagement.property.rma_dispositionAsOf.title=Action de disposition -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Action de disposition -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u00c9v\u00e9nements de disposition \u00e9ligibles -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u00c9v\u00e9nements de disposition \u00e9ligibles -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Action de disposition d\u00e9marr\u00e9e \u00e0 -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Action de disposition d\u00e9marr\u00e9e \u00e0 -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Action de disposition d\u00e9marr\u00e9e par -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Action de disposition d\u00e9marr\u00e9e par -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Action de disposition termin\u00e9e \u00e0 -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Action de disposition termin\u00e9e \u00e0 -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Action de disposition termin\u00e9e par -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Action de disposition termin\u00e9e par -rma_recordsmanagement.association.rma_eventExecutions.title=Ex\u00e9cutions de l'\u00e9v\u00e9nement -rma_recordsmanagement.association.rma_eventExecutions.decription=Ex\u00e9cutions de l'\u00e9v\u00e9nement - -rma_recordsmanagement.type.rma_eventExecution.title=Ex\u00e9cution de l'\u00e9v\u00e9nement -rma_recordsmanagement.type.rma_eventExecution.decription=Ex\u00e9cution de l'\u00e9v\u00e9nement -rma_recordsmanagement.property.rma_eventExecutionName.title=Nom d'\u00e9v\u00e9nement -rma_recordsmanagement.property.rma_eventExecutionName.decription=Nom d'\u00e9v\u00e9nement -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u00c9v\u00e9nement automatique -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u00c9v\u00e9nement automatique -rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u00c9v\u00e9nement termin\u00e9 -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u00c9v\u00e9nement termin\u00e9 -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u00c9v\u00e9nement termin\u00e9 par -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u00c9v\u00e9nement termin\u00e9 par -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u00c9v\u00e9nement termin\u00e9 \u00e0 -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u00c9v\u00e9nement termin\u00e9 \u00e0 - -rma_recordsmanagement.type.rma_hold.title=Suspendre -rma_recordsmanagement.type.rma_hold.decription=Suspendre -rma_recordsmanagement.property.rma_holdReason.title=Motif de suspension -rma_recordsmanagement.property.rma_holdReason.decription=Motif de suspension -rma_recordsmanagement.association.rma_frozenRecords.title=Documents d'archives suspendus -rma_recordsmanagement.association.rma_frozenRecords.decription=Documents d'archives suspendus - -rma_recordsmanagement.type.rma_transfer.title=Transf\u00e9rer -rma_recordsmanagement.type.rma_transfer.decription=Transf\u00e9rer -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Transf\u00e9rer l'indicateur de versement \u00e0 un autre organisme -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Transf\u00e9rer l'indicateur de versement \u00e0 un autre organisme -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Transf\u00e9rer l'indicateur PDF -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Transf\u00e9rer l'indicateur PDF -rma_recordsmanagement.property.rma_transferLocation.title=Transf\u00e9rer le PDF -rma_recordsmanagement.property.rma_transferLocation.decription=Transf\u00e9rer le PDF -rma_recordsmanagement.association.rma_transferred.title=Transf\u00e9r\u00e9 -rma_recordsmanagement.association.rma_transferred.decription=Transf\u00e9r\u00e9 - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=Composant du plan de classification -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Composant du plan de classification -rma_recordsmanagement.property.rma_rootNodeRef.title=N\u0153ud racine -rma_recordsmanagement.property.rma_rootNodeRef.decription=N\u0153ud racine - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Racine du site de gestion des archives -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Racine du site de gestion des archives -rma_recordsmanagement.association.rma_holds.title=Suspensions -rma_recordsmanagement.association.rma_holds.decription=Suspensions -rma_recordsmanagement.association.rma_transfers.title=Transferts -rma_recordsmanagement.association.rma_transfers.decription=Transferts - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Document d'archives complet -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Document d'archives complet -rma_recordsmanagement.property.rma_declaredAt.title=Date d'ach\u00e8vement -rma_recordsmanagement.property.rma_declaredAt.decription=Date d'ach\u00e8vement -rma_recordsmanagement.property.rma_declaredBy.title=Compl\u00e9t\u00e9 par -rma_recordsmanagement.property.rma_declaredBy.decription=Compl\u00e9t\u00e9 par - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identifiant de composant de document d'archives -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identifiant de composant de document d'archives -rma_recordsmanagement.property.rma_identifier.title=Identifiant -rma_recordsmanagement.property.rma_identifier.decription=Identifiant unique de document d'archives -rma_recordsmanagement.property.rma_dbUniquenessId.title=Unicit\u00e9 de base de donn\u00e9es -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Unicit\u00e9 de base de donn\u00e9es - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=D\u00e9finition du document d'archives essentiel -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=D\u00e9finition du document d'archives essentiel - -rma_recordsmanagement.property.rma_reviewPeriod.title=P\u00e9riode de r\u00e9vision -rma_recordsmanagement.property.rma_reviewPeriod.decription=P\u00e9riode de r\u00e9vision -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Identifiant de document d'archives essentiel -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Identifiant de document d'archives essentiel - -rma_recordsmanagement.aspect.rma_record.title=Document d'archives -rma_recordsmanagement.aspect.rma_record.decription=Document d'archives -rma_recordsmanagement.property.rma_dateFiled.title=Date de versement au site des archives -rma_recordsmanagement.property.rma_dateFiled.decription=Date de versement au site des archives -rma_recordsmanagement.property.rma_origionalName=Nom d'origine - -rma_recordsmanagement.aspect.rma_recordMetaData.title=M\u00e9tadonn\u00e9es du document d'archives -rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspect du marqueur de m\u00e9tadonn\u00e9es de document d'archives - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=D\u00e9tails des documents d'archives communs -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=M\u00e9tadonn\u00e9es communes \u00e0 tous les types de document d'archives -rma_recordsmanagement.property.rma_location.title=Emplacement -rma_recordsmanagement.property.rma_location.decription=Emplacement - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Document d'archives essentiel -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Document d'archives essentiel -rma_recordsmanagement.property.rma_reviewAsOf.title=V\u00e9rification suivante -rma_recordsmanagement.property.rma_reviewAsOf.decription=V\u00e9rification suivante -rma_recordsmanagement.property.rma_notificationIssued.title=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives -rma_recordsmanagement.property.rma_notificationIssued.decription=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives - -rma_recordsmanagement.aspect.rma_scheduled.title=Planifi\u00e9 -rma_recordsmanagement.aspect.rma_scheduled.decription=Planifi\u00e9 -rma_recordsmanagement.association.rma_dispositionSchedule.title=R\u00e8gle de conservation -rma_recordsmanagement.association.rma_dispositionSchedule.decription=R\u00e8gle de conservation - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u00c9tapes du d\u00e9lai de conservation -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u00c9tapes du d\u00e9lai de conservation -rma_recordsmanagement.association.rma_nextDispositionAction.title=\u00c9tape suivante du d\u00e9lai de conservation -rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u00c9tape suivante du d\u00e9lai de conservation -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Historique des actions de disposition -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Historique des actions de disposition - -rma_recordsmanagement.aspect.rma_cutOff.title=D\u00e9classer -rma_recordsmanagement.aspect.rma_cutOff.decription=D\u00e9classer -rma_recordsmanagement.property.rma_cutOffDate.title=Date de d\u00e9classement -rma_recordsmanagement.property.rma_cutOffDate.decription=Date de d\u00e9classement - -rma_recordsmanagement.aspect.rma_transferred.title=Transf\u00e9r\u00e9 -rma_recordsmanagement.aspect.rma_transferred.decription=Transf\u00e9r\u00e9 - -rma_recordsmanagement.aspect.rma_ascended.title=Mont\u00e9 -rma_recordsmanagement.aspect.rma_ascended.decription=Mont\u00e9 - -rma_recordsmanagement.aspect.rma_frozen.title=Suspendu -rma_recordsmanagement.aspect.rma_frozen.decription=Suspendu -rma_recordsmanagement.property.rma_frozenAt.title=Suspendu \u00e0 -rma_recordsmanagement.property.rma_frozenAt.decription=Suspendu \u00e0 -rma_recordsmanagement.property.rma_frozenBy.title=Suspendu par -rma_recordsmanagement.property.rma_frozenBy.decription=Suspendu par - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Racine de configuration des avertissements -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Racine de configuration des avertissements -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configuration des avertissements -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configuration des avertissements - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Racine de configuration d'e-mail -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Racine de configuration d'e-mail -rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configuration du courriel -rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configuration du courriel - -rma_recordsmanagement.aspect.rma_recordSearch.title=Recherche de document d'archives -rma_recordsmanagement.aspect.rma_recordSearch.decription=Informations de recherches cumul\u00e9es pour prendre en charge la recherche dans la gestion des archives -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=A une r\u00e8gle de conservation -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indique si une r\u00e8gle de conservation est associ\u00e9e \u00e0 l'\u00e9l\u00e9ment. -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nom de l'action de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Le nom de l'\u00e9tape suivante du d\u00e9lai de conservation -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Action de disposition de -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La date \u00e0 laquelle l'\u00e9tape suivante du d\u00e9lai de conservation devient \u00e9ligible -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=P\u00e9riode de la disposition -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=P\u00e9riode de la disposition -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Expression de la p\u00e9riode de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Expression de la p\u00e9riode de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u00c9v\u00e9nements de disposition \u00e9ligibles -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u00c9v\u00e9nements de disposition \u00e9ligibles -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u00c9v\u00e9nements de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u00c9v\u00e9nements de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=D\u00e9tenteur principal -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=D\u00e9tenteur principal -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Instructions de disposition -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Instructions de disposition -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Motif de suspension -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Motif de suspension -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=P\u00e9riode de v\u00e9rification du document d'archives essentiel -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=P\u00e9riode de v\u00e9rification du document d'archives essentiel -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Expression de p\u00e9riode de r\u00e9vision -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Expression de p\u00e9riode de r\u00e9vision - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Document d'archives versionn\u00e9 -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Document d'archives versionn\u00e9 - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Mise \u00e0 jour non publi\u00e9e -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Mise \u00e0 jour non publi\u00e9e -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Mise \u00e0 jour non publi\u00e9e -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indique s'il existe une mise \u00e0 jour non publi\u00e9e -rma_recordsmanagement.property.rma_updateTo.title=Mettre \u00e0 jour vers -rma_recordsmanagement.property.rma_updateTo.description=Destination de la mise \u00e0 jour -rma_recordsmanagement.property.rma_updatedProperties.title=Propri\u00e9t\u00e9s mises \u00e0 jour -rma_recordsmanagement.property.rma_updatedProperties.description=Les propri\u00e9t\u00e9s mises \u00e0 jour -rma_recordsmanagement.property.rma_publishInProgress.title=Publication en cours -rma_recordsmanagement.property.rma_publishInProgress.description=Indique si une publication est en cours - -rma_recordsmanagement.aspect.dod_ghosted.title=M\u00e9tadonn\u00e9es d'archives seulement -rma_recordsmanagement.aspect.dod_ghosted.description=M\u00e9tadonn\u00e9es d'archives seulement - -listconstraint.rmc_tlList.title=Transf\u00e9rer les emplacements +rma_recordsmanagement.description=Mod\u00e8le de contenu de gestion des archives + +rma_recordsmanagement.type.rma_rmsite.title=Site de gestion des archives +rma_recordsmanagement.type.rma_rmsite.description=Site sp\u00e9cialis\u00e9 pour la gestion des archives + +rma_recordsmanagement.type.rma_caveatConfig.title=Configuration de mise en garde +rma_recordsmanagement.type.rma_caveatConfig.decription=Configuration de mise en garde + +rma_recordsmanagement.type.rma_emailConfig.title=Configuration du courriel +rma_recordsmanagement.type.rma_emailConfig.decription=Configuration du courriel + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Conteneur de gestion des archives +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Conteneur de gestion des archives + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Conteneur de la racine du site de gestion des archives +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Conteneur de la racine du site de gestion des archives + +rma_recordsmanagement.type.rma_dispositionSchedule.title=R\u00e8gle de conservation +rma_recordsmanagement.type.rma_dispositionSchedule.decription=R\u00e8gle de conservation + +rma_recordsmanagement.property.rma_dispositionAuthority.title=D\u00e9tenteur principal +rma_recordsmanagement.property.rma_dispositionAuthority.decription=D\u00e9tenteur principal + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Instructions de disposition +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Instructions de disposition + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposition au niveau du document d'archives +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposition au niveau du document d'archives + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Actions de disposition +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Actions de disposition + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=D\u00e9finition de l'action de disposition +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=D\u00e9finition de l'action de disposition +rma_recordsmanagement.property.rma_dispositionActionName.title=Nom de l'action de disposition +rma_recordsmanagement.property.rma_dispositionActionName.decription=Nom de l'action de disposition +rma_recordsmanagement.property.rma_dispositionDescription.title=Description de la disposition +rma_recordsmanagement.property.rma_dispositionDescription.decription=Description de la disposition +rma_recordsmanagement.property.rma_dispositionLocation.title=Emplacement de la disposition +rma_recordsmanagement.property.rma_dispositionLocation.decription=Emplacement de la disposition +rma_recordsmanagement.property.rma_dispositionPeriod.title=P\u00e9riode de la disposition +rma_recordsmanagement.property.rma_dispositionPeriod.decription=P\u00e9riode de la disposition +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propri\u00e9t\u00e9 de la p\u00e9riode de disposition +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propri\u00e9t\u00e9 de la p\u00e9riode de disposition +rma_recordsmanagement.property.rma_dispositionEvent.title=\u00c9v\u00e9nement de disposition +rma_recordsmanagement.property.rma_dispositionEvent.decription=\u00c9v\u00e9nement de disposition +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinaison d'\u00e9v\u00e9nements de disposition +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinaison d'\u00e9v\u00e9nements de disposition + +rma_recordsmanagement.type.rma_recordFolder.title=Dossier d'archives +rma_recordsmanagement.type.rma_recordFolder.decription=Dossier d'archives +rma_recordsmanagement.property.rma_isClosed.title=Document d'archives +rma_recordsmanagement.property.rma_isClosed.decription=Document d'archives + +rma_recordsmanagement.type.rma_recordCategory.title=Cat\u00e9gorie de document d'archives +rma_recordsmanagement.type.rma_recordCategory.decription=Cat\u00e9gorie de document d'archives + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Document non \u00e9lectronique +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Document non \u00e9lectronique +rma_recordsmanagement.property.rma_physicalSize.title=Taille physique +rma_recordsmanagement.property.rma_physicalSize.decription=Taille du document mesur\u00e9e en m\u00e8tres lin\u00e9aires. +rma_recordsmanagement.property.rma_numberOfCopies.title=Nombre de copies +rma_recordsmanagement.property.rma_numberOfCopies.description=Nombre de copies du document. +rma_recordsmanagement.property.rma_storageLocation.title=Emplacement de stockage +rma_recordsmanagement.property.rma_storageLocation.decription=Emplacement de stockage physique du document d'archives. +rma_recordsmanagement.property.rma_shelf.title=\u00c9tag\u00e8re +rma_recordsmanagement.property.rma_shelf.decription=\u00c9tag\u00e8re o\u00f9 se trouve le document d'archives. +rma_recordsmanagement.property.rma_box.title=Bo\u00eete +rma_recordsmanagement.property.rma_box.description=Bo\u00eete o\u00f9 se trouve le document d'archives. +rma_recordsmanagement.property.rma_file.title=Fichier +rma_recordsmanagement.property.rma_file.decription=Fichier du document d'archives. + +rma_recordsmanagement.type.rma_dispositionAction.title=Action de disposition +rma_recordsmanagement.type.rma_dispositionAction.decription=Action de disposition +rma_recordsmanagement.property.rma_dispositionActionId.title=Identifiant de l'action de disposition +rma_recordsmanagement.property.rma_dispositionActionId.decription=Identifiant de l'action de disposition +rma_recordsmanagement.property.rma_dispositionAction.title=Action de disposition +rma_recordsmanagement.property.rma_dispositionAction.decription=Action de disposition +rma_recordsmanagement.property.rma_dispositionAsOf.title=Action de disposition +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Action de disposition +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u00c9v\u00e9nements de disposition \u00e9ligibles +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u00c9v\u00e9nements de disposition \u00e9ligibles +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Action de disposition d\u00e9marr\u00e9e \u00e0 +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Action de disposition d\u00e9marr\u00e9e \u00e0 +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Action de disposition d\u00e9marr\u00e9e par +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Action de disposition d\u00e9marr\u00e9e par +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Action de disposition termin\u00e9e \u00e0 +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Action de disposition termin\u00e9e \u00e0 +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Action de disposition termin\u00e9e par +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Action de disposition termin\u00e9e par +rma_recordsmanagement.association.rma_eventExecutions.title=Ex\u00e9cutions de l'\u00e9v\u00e9nement +rma_recordsmanagement.association.rma_eventExecutions.decription=Ex\u00e9cutions de l'\u00e9v\u00e9nement + +rma_recordsmanagement.type.rma_eventExecution.title=Ex\u00e9cution de l'\u00e9v\u00e9nement +rma_recordsmanagement.type.rma_eventExecution.decription=Ex\u00e9cution de l'\u00e9v\u00e9nement +rma_recordsmanagement.property.rma_eventExecutionName.title=Nom d'\u00e9v\u00e9nement +rma_recordsmanagement.property.rma_eventExecutionName.decription=Nom d'\u00e9v\u00e9nement +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u00c9v\u00e9nement automatique +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u00c9v\u00e9nement automatique +rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u00c9v\u00e9nement termin\u00e9 +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u00c9v\u00e9nement termin\u00e9 +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u00c9v\u00e9nement termin\u00e9 par +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u00c9v\u00e9nement termin\u00e9 par +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u00c9v\u00e9nement termin\u00e9 \u00e0 +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u00c9v\u00e9nement termin\u00e9 \u00e0 + +rma_recordsmanagement.type.rma_hold.title=Suspendre +rma_recordsmanagement.type.rma_hold.decription=Suspendre +rma_recordsmanagement.property.rma_holdReason.title=Motif de suspension +rma_recordsmanagement.property.rma_holdReason.decription=Motif de suspension +rma_recordsmanagement.association.rma_frozenRecords.title=Documents d'archives suspendus +rma_recordsmanagement.association.rma_frozenRecords.decription=Documents d'archives suspendus + +rma_recordsmanagement.type.rma_transfer.title=Transf\u00e9rer +rma_recordsmanagement.type.rma_transfer.decription=Transf\u00e9rer +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Transf\u00e9rer l'indicateur de versement \u00e0 un autre organisme +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Transf\u00e9rer l'indicateur de versement \u00e0 un autre organisme +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Transf\u00e9rer l'indicateur PDF +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Transf\u00e9rer l'indicateur PDF +rma_recordsmanagement.property.rma_transferLocation.title=Transf\u00e9rer le PDF +rma_recordsmanagement.property.rma_transferLocation.decription=Transf\u00e9rer le PDF +rma_recordsmanagement.association.rma_transferred.title=Transf\u00e9r\u00e9 +rma_recordsmanagement.association.rma_transferred.decription=Transf\u00e9r\u00e9 + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=Composant du plan de classification +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Composant du plan de classification +rma_recordsmanagement.property.rma_rootNodeRef.title=N\u0153ud racine +rma_recordsmanagement.property.rma_rootNodeRef.decription=N\u0153ud racine + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Racine du site de gestion des archives +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Racine du site de gestion des archives +rma_recordsmanagement.association.rma_holds.title=Suspensions +rma_recordsmanagement.association.rma_holds.decription=Suspensions +rma_recordsmanagement.association.rma_transfers.title=Transferts +rma_recordsmanagement.association.rma_transfers.decription=Transferts + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Document d'archives complet +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Document d'archives complet +rma_recordsmanagement.property.rma_declaredAt.title=Date d'ach\u00e8vement +rma_recordsmanagement.property.rma_declaredAt.decription=Date d'ach\u00e8vement +rma_recordsmanagement.property.rma_declaredBy.title=Compl\u00e9t\u00e9 par +rma_recordsmanagement.property.rma_declaredBy.decription=Compl\u00e9t\u00e9 par + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identifiant de composant de document d'archives +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identifiant de composant de document d'archives +rma_recordsmanagement.property.rma_identifier.title=Identifiant +rma_recordsmanagement.property.rma_identifier.decription=Identifiant unique de document d'archives +rma_recordsmanagement.property.rma_dbUniquenessId.title=Unicit\u00e9 de base de donn\u00e9es +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Unicit\u00e9 de base de donn\u00e9es + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=D\u00e9finition du document d'archives essentiel +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=D\u00e9finition du document d'archives essentiel + +rma_recordsmanagement.property.rma_reviewPeriod.title=P\u00e9riode de r\u00e9vision +rma_recordsmanagement.property.rma_reviewPeriod.decription=P\u00e9riode de r\u00e9vision +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Identifiant de document d'archives essentiel +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Identifiant de document d'archives essentiel + +rma_recordsmanagement.aspect.rma_record.title=Document d'archives +rma_recordsmanagement.aspect.rma_record.decription=Document d'archives +rma_recordsmanagement.property.rma_dateFiled.title=Date de versement au site des archives +rma_recordsmanagement.property.rma_dateFiled.decription=Date de versement au site des archives +rma_recordsmanagement.property.rma_origionalName=Nom d'origine + +rma_recordsmanagement.aspect.rma_recordMetaData.title=M\u00e9tadonn\u00e9es du document d'archives +rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspect du marqueur de m\u00e9tadonn\u00e9es de document d'archives + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=D\u00e9tails des documents d'archives communs +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=M\u00e9tadonn\u00e9es communes \u00e0 tous les types de document d'archives +rma_recordsmanagement.property.rma_location.title=Emplacement +rma_recordsmanagement.property.rma_location.decription=Emplacement + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Document d'archives essentiel +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Document d'archives essentiel +rma_recordsmanagement.property.rma_reviewAsOf.title=V\u00e9rification suivante +rma_recordsmanagement.property.rma_reviewAsOf.decription=V\u00e9rification suivante +rma_recordsmanagement.property.rma_notificationIssued.title=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives +rma_recordsmanagement.property.rma_notificationIssued.decription=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives + +rma_recordsmanagement.aspect.rma_scheduled.title=Planifi\u00e9 +rma_recordsmanagement.aspect.rma_scheduled.decription=Planifi\u00e9 +rma_recordsmanagement.association.rma_dispositionSchedule.title=R\u00e8gle de conservation +rma_recordsmanagement.association.rma_dispositionSchedule.decription=R\u00e8gle de conservation + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u00c9tapes du d\u00e9lai de conservation +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u00c9tapes du d\u00e9lai de conservation +rma_recordsmanagement.association.rma_nextDispositionAction.title=\u00c9tape suivante du d\u00e9lai de conservation +rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u00c9tape suivante du d\u00e9lai de conservation +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Historique des actions de disposition +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Historique des actions de disposition + +rma_recordsmanagement.aspect.rma_cutOff.title=D\u00e9classer +rma_recordsmanagement.aspect.rma_cutOff.decription=D\u00e9classer +rma_recordsmanagement.property.rma_cutOffDate.title=Date de d\u00e9classement +rma_recordsmanagement.property.rma_cutOffDate.decription=Date de d\u00e9classement + +rma_recordsmanagement.aspect.rma_transferred.title=Transf\u00e9r\u00e9 +rma_recordsmanagement.aspect.rma_transferred.decription=Transf\u00e9r\u00e9 + +rma_recordsmanagement.aspect.rma_ascended.title=Mont\u00e9 +rma_recordsmanagement.aspect.rma_ascended.decription=Mont\u00e9 + +rma_recordsmanagement.aspect.rma_frozen.title=Suspendu +rma_recordsmanagement.aspect.rma_frozen.decription=Suspendu +rma_recordsmanagement.property.rma_frozenAt.title=Suspendu \u00e0 +rma_recordsmanagement.property.rma_frozenAt.decription=Suspendu \u00e0 +rma_recordsmanagement.property.rma_frozenBy.title=Suspendu par +rma_recordsmanagement.property.rma_frozenBy.decription=Suspendu par + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Racine de configuration des avertissements +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Racine de configuration des avertissements +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configuration des avertissements +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configuration des avertissements + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Racine de configuration d'e-mail +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Racine de configuration d'e-mail +rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configuration du courriel +rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configuration du courriel + +rma_recordsmanagement.aspect.rma_recordSearch.title=Recherche de document d'archives +rma_recordsmanagement.aspect.rma_recordSearch.decription=Informations de recherches cumul\u00e9es pour prendre en charge la recherche dans la gestion des archives +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=A une r\u00e8gle de conservation +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indique si une r\u00e8gle de conservation est associ\u00e9e \u00e0 l'\u00e9l\u00e9ment. +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nom de l'action de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Le nom de l'\u00e9tape suivante du d\u00e9lai de conservation +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Action de disposition de +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La date \u00e0 laquelle l'\u00e9tape suivante du d\u00e9lai de conservation devient \u00e9ligible +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=P\u00e9riode de la disposition +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=P\u00e9riode de la disposition +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Expression de la p\u00e9riode de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Expression de la p\u00e9riode de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u00c9v\u00e9nements de disposition \u00e9ligibles +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u00c9v\u00e9nements de disposition \u00e9ligibles +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u00c9v\u00e9nements de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u00c9v\u00e9nements de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=D\u00e9tenteur principal +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=D\u00e9tenteur principal +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Instructions de disposition +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Instructions de disposition +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Motif de suspension +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Motif de suspension +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=P\u00e9riode de v\u00e9rification du document d'archives essentiel +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=P\u00e9riode de v\u00e9rification du document d'archives essentiel +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Expression de p\u00e9riode de r\u00e9vision +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Expression de p\u00e9riode de r\u00e9vision + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Document d'archives versionn\u00e9 +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Document d'archives versionn\u00e9 + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Mise \u00e0 jour non publi\u00e9e +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Mise \u00e0 jour non publi\u00e9e +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Mise \u00e0 jour non publi\u00e9e +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indique s'il existe une mise \u00e0 jour non publi\u00e9e +rma_recordsmanagement.property.rma_updateTo.title=Mettre \u00e0 jour vers +rma_recordsmanagement.property.rma_updateTo.description=Destination de la mise \u00e0 jour +rma_recordsmanagement.property.rma_updatedProperties.title=Propri\u00e9t\u00e9s mises \u00e0 jour +rma_recordsmanagement.property.rma_updatedProperties.description=Les propri\u00e9t\u00e9s mises \u00e0 jour +rma_recordsmanagement.property.rma_publishInProgress.title=Publication en cours +rma_recordsmanagement.property.rma_publishInProgress.description=Indique si une publication est en cours + +rma_recordsmanagement.aspect.dod_ghosted.title=M\u00e9tadonn\u00e9es d'archives seulement +rma_recordsmanagement.aspect.dod_ghosted.description=M\u00e9tadonn\u00e9es d'archives seulement + +listconstraint.rmc_tlList.title=Transf\u00e9rer les emplacements listconstraint.rmc_smList.title=Marquages compl\u00e9mentaires \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties index 51dc095648..b4a0b8ad76 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Modello dei contenuti di gestione dei record - -rma_recordsmanagement.type.rma_rmsite.title=Sito di gestione dei record -rma_recordsmanagement.type.rma_rmsite.description=Sito specializzato per la gestione dei record - -rma_recordsmanagement.type.rma_caveatConfig.title=Config avvertenza -rma_recordsmanagement.type.rma_caveatConfig.decription=Config avvertenza - -rma_recordsmanagement.type.rma_emailConfig.title=Configurazione e-mail -rma_recordsmanagement.type.rma_emailConfig.decription=Configurazione e-mail - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Contenitore gestione dei record -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Contenitore gestione dei record - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Contenitore radice di gestione dei record -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Contenitore radice di gestione dei record - -rma_recordsmanagement.type.rma_dispositionSchedule.title=Pianificazione della disposizione -rma_recordsmanagement.type.rma_dispositionSchedule.decription=Pianificazione della disposizione - -rma_recordsmanagement.property.rma_dispositionAuthority.title=Autorit\u00e0 di disposizione -rma_recordsmanagement.property.rma_dispositionAuthority.decription=Autorit\u00e0 di disposizione - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Istruzioni di disposizione -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Istruzioni di disposizione - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposizione livello record -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposizione livello record - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Azioni di disposizione -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Azioni di disposizione - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definizione di azione di disposizione -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definizione di azione di disposizione -rma_recordsmanagement.property.rma_dispositionActionName.title=Nome dell'azione di disposizione -rma_recordsmanagement.property.rma_dispositionActionName.decription=Nome dell'azione di disposizione -rma_recordsmanagement.property.rma_dispositionDescription.title=Descrizione disposizione -rma_recordsmanagement.property.rma_dispositionDescription.decription=Descrizione disposizione -rma_recordsmanagement.property.rma_dispositionLocation.title=Posizione disposizione -rma_recordsmanagement.property.rma_dispositionLocation.decription=Posizione disposizione -rma_recordsmanagement.property.rma_dispositionPeriod.title=Periodo della disposizione -rma_recordsmanagement.property.rma_dispositionPeriod.decription=Periodo della disposizione -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propriet\u00e0 del periodo della disposizione -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propriet\u00e0 del periodo della disposizione -rma_recordsmanagement.property.rma_dispositionEvent.title=Evento di disposizione -rma_recordsmanagement.property.rma_dispositionEvent.decription=Evento di disposizione -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinazione evento di disposizione -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinazione evento di disposizione - -rma_recordsmanagement.type.rma_recordFolder.title=Cartella di record -rma_recordsmanagement.type.rma_recordFolder.decription=Cartella di record -rma_recordsmanagement.property.rma_isClosed.title=Record -rma_recordsmanagement.property.rma_isClosed.decription=Record - -rma_recordsmanagement.type.rma_recordCategory.title=Categoria record -rma_recordsmanagement.type.rma_recordCategory.decription=Categoria record - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Documento non elettronico -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Documento non elettronico -rma_recordsmanagement.property.rma_physicalSize.title=Dimensioni fisiche -rma_recordsmanagement.property.rma_physicalSize.decription=Le dimensioni del documento misurate in metri lineari. -rma_recordsmanagement.property.rma_numberOfCopies.title=Numero di copie -rma_recordsmanagement.property.rma_numberOfCopies.description=Il numero di copie del documento. -rma_recordsmanagement.property.rma_storageLocation.title=Posizione di archiviazione -rma_recordsmanagement.property.rma_storageLocation.decription=La posizione fisica di archiviazione del record. -rma_recordsmanagement.property.rma_shelf.title=Ripiano -rma_recordsmanagement.property.rma_shelf.decription=Il ripiano sul quale \u00e8 collocato il record. -rma_recordsmanagement.property.rma_box.title=Casella -rma_recordsmanagement.property.rma_box.description=La casella dove \u00e8 collocato il record. -rma_recordsmanagement.property.rma_file.title=File -rma_recordsmanagement.property.rma_file.decription=Il file dove \u00e8 collocato il record. - -rma_recordsmanagement.type.rma_dispositionAction.title=Azione di disposizione -rma_recordsmanagement.type.rma_dispositionAction.decription=Azione di disposizione -rma_recordsmanagement.property.rma_dispositionActionId.title=ID azione di disposizione -rma_recordsmanagement.property.rma_dispositionActionId.decription=ID azione di disposizione -rma_recordsmanagement.property.rma_dispositionAction.title=Azione di disposizione -rma_recordsmanagement.property.rma_dispositionAction.decription=Azione di disposizione -rma_recordsmanagement.property.rma_dispositionAsOf.title=Azione di disposizione -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Azione di disposizione -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Eventi di disposizione idonei -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Eventi di disposizione idonei -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Azione di disposizione iniziata alle ore -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Azione di disposizione iniziata alle ore -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Azione di disposizione iniziata da -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Azione di disposizione iniziata da -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Azione di disposizione completata alle ore -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Azione di disposizione completata alle ore -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Azione di disposizione completata da -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Azione di disposizione completata da -rma_recordsmanagement.association.rma_eventExecutions.title=Esecuzioni evento -rma_recordsmanagement.association.rma_eventExecutions.decription=Esecuzioni evento - -rma_recordsmanagement.type.rma_eventExecution.title=Esecuzione evento -rma_recordsmanagement.type.rma_eventExecution.decription=Esecuzione evento -rma_recordsmanagement.property.rma_eventExecutionName.title=Nome evento -rma_recordsmanagement.property.rma_eventExecutionName.decription=Nome evento -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Evento automatico -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Evento automatico -rma_recordsmanagement.property.rma_eventExecutionComplete.title=Evento completato -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Evento completato -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Evento completato da -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Evento completato da -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Evento completato alle ore -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Evento completato alle ore - -rma_recordsmanagement.type.rma_hold.title=Sospensione -rma_recordsmanagement.type.rma_hold.decription=Sospensione -rma_recordsmanagement.property.rma_holdReason.title=Motivo sospensione -rma_recordsmanagement.property.rma_holdReason.decription=Motivo sospensione -rma_recordsmanagement.association.rma_frozenRecords.title=Record sospesi -rma_recordsmanagement.association.rma_frozenRecords.decription=Record sospesi - -rma_recordsmanagement.type.rma_transfer.title=Trasferimento -rma_recordsmanagement.type.rma_transfer.decription=Trasferimento -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Trasferisci indicatore di inserimento -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Trasferisci indicatore di inserimento -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Trasferisci indicatore PDF -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Trasferisci indicatore PDF -rma_recordsmanagement.property.rma_transferLocation.title=Trasferisci PDF -rma_recordsmanagement.property.rma_transferLocation.decription=Trasferisci PDF -rma_recordsmanagement.association.rma_transferred.title=Trasferito -rma_recordsmanagement.association.rma_transferred.decription=Trasferito - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=Componente piano file -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Componente piano file -rma_recordsmanagement.property.rma_rootNodeRef.title=Nodo radice -rma_recordsmanagement.property.rma_rootNodeRef.decription=Nodo radice - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Radice di gestione dei record -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Radice di gestione dei record -rma_recordsmanagement.association.rma_holds.title=Sospende -rma_recordsmanagement.association.rma_holds.decription=Sospende -rma_recordsmanagement.association.rma_transfers.title=Trasferisce -rma_recordsmanagement.association.rma_transfers.decription=Trasferisce - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Record completato -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Record completato -rma_recordsmanagement.property.rma_declaredAt.title=Data completamento -rma_recordsmanagement.property.rma_declaredAt.decription=Data completamento -rma_recordsmanagement.property.rma_declaredBy.title=Completato da -rma_recordsmanagement.property.rma_declaredBy.decription=Completato da - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificatore componente record -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificatore componente record -rma_recordsmanagement.property.rma_identifier.title=Identificativo -rma_recordsmanagement.property.rma_identifier.decription=Identificatore record univoco -rma_recordsmanagement.property.rma_dbUniquenessId.title=Unicit\u00e0 database -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Unicit\u00e0 database - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definizione di record fondamentale -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definizione di record fondamentale - -rma_recordsmanagement.property.rma_reviewPeriod.title=Periodo di revisione -rma_recordsmanagement.property.rma_reviewPeriod.decription=Periodo di revisione -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicatore record fondamentale -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicatore record fondamentale - -rma_recordsmanagement.aspect.rma_record.title=Record -rma_recordsmanagement.aspect.rma_record.decription=Record -rma_recordsmanagement.property.rma_dateFiled.title=Data di archiviazione -rma_recordsmanagement.property.rma_dateFiled.decription=Data di archiviazione -rma_recordsmanagement.property.rma_origionalName=Nome originale - -rma_recordsmanagement.aspect.rma_recordMetaData.title=Metadati record -rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspetto indicatore per metadati di record - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Dettagli record comuni -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Metadati comuni a tutti i tipi di record -rma_recordsmanagement.property.rma_location.title=Posizione -rma_recordsmanagement.property.rma_location.decription=Posizione - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Record fondamentale -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Record fondamentale -rma_recordsmanagement.property.rma_reviewAsOf.title=Prossima revisione -rma_recordsmanagement.property.rma_reviewAsOf.decription=Prossima revisione -rma_recordsmanagement.property.rma_notificationIssued.title=Indica che \u00e8 stata rilasciata una notifica di revisione per questo record -rma_recordsmanagement.property.rma_notificationIssued.decription=Indica che \u00e8 stata rilasciata una notifica di revisione per questo record - -rma_recordsmanagement.aspect.rma_scheduled.title=Pianificato -rma_recordsmanagement.aspect.rma_scheduled.decription=Pianificato -rma_recordsmanagement.association.rma_dispositionSchedule.title=Pianificazione della disposizione -rma_recordsmanagement.association.rma_dispositionSchedule.decription=Pianificazione della disposizione - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Ciclo di vita della disposizione -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Ciclo di vita della disposizione -rma_recordsmanagement.association.rma_nextDispositionAction.title=Prossima azione di disposizione -rma_recordsmanagement.association.rma_nextDispositionAction.decription=Prossima azione di disposizione -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Cronologia azioni di disposizione -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Cronologia azioni di disposizione - -rma_recordsmanagement.aspect.rma_cutOff.title=Cut off -rma_recordsmanagement.aspect.rma_cutOff.decription=Cut off -rma_recordsmanagement.property.rma_cutOffDate.title=Data cut off -rma_recordsmanagement.property.rma_cutOffDate.decription=Data cut off - -rma_recordsmanagement.aspect.rma_transferred.title=Trasferito -rma_recordsmanagement.aspect.rma_transferred.decription=Trasferito - -rma_recordsmanagement.aspect.rma_ascended.title=Asceso -rma_recordsmanagement.aspect.rma_ascended.decription=Asceso - -rma_recordsmanagement.aspect.rma_frozen.title=Sospeso -rma_recordsmanagement.aspect.rma_frozen.decription=Sospeso -rma_recordsmanagement.property.rma_frozenAt.title=Sospeso presso -rma_recordsmanagement.property.rma_frozenAt.decription=Sospeso presso -rma_recordsmanagement.property.rma_frozenBy.title=Sospeso da -rma_recordsmanagement.property.rma_frozenBy.decription=Sospeso da - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Radice di configurazione avvertenza -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Radice di configurazione avvertenza -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configurazione avvertenza -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configurazione avvertenza - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Radice Config E-mail -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Radice Config E-mail -rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configurazione e-mail -rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configurazione e-mail - -rma_recordsmanagement.aspect.rma_recordSearch.title=Ricerca record -rma_recordsmanagement.aspect.rma_recordSearch.decription=Eseguito il rollup delle informazioni di ricerca per supportare la ricerca di Gestione dei record -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Possiede una pianificazione della disposizione -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indica se una pianificazione della disposizione \u00e8 stata associata ad un certo elemento -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nome dell'azione di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Il nome della prossima azione di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Azione di disposizione di -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La data in cui la prossima azione di disposizione diventa idonea -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Periodo della disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Periodo della disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Espressione del periodo della disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Espressione del periodo della disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Eventi di disposizione idonei -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Eventi di disposizione idonei -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Eventi di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Eventi di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Autorit\u00e0 di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Autorit\u00e0 di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Istruzioni di disposizione -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Istruzioni di disposizione -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Motivo sospensione -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Motivo sospensione -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Periodo di revisione record fondamentale -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Periodo di revisione record fondamentale -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Espressione periodo di revisione -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Espressione periodo di revisione - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Record con versione -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Record con versione - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Aggiornamento non pubblicato -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Aggiornamento non pubblicato -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Aggiornamento non pubblicato -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indica se \u00e8 presente un aggiornamento non pubblicato -rma_recordsmanagement.property.rma_updateTo.title=Aggiornamento a -rma_recordsmanagement.property.rma_updateTo.description=Destinazione dell'aggiornamento -rma_recordsmanagement.property.rma_updatedProperties.title=Propriet\u00e0 aggiornate -rma_recordsmanagement.property.rma_updatedProperties.description=Le propriet\u00e0 aggiornate -rma_recordsmanagement.property.rma_publishInProgress.title=Pubblicazione in corso -rma_recordsmanagement.property.rma_publishInProgress.description=Indica se \u00e8 in corso una pubblicazione - -rma_recordsmanagement.aspect.dod_ghosted.title=Record di soli metadati -rma_recordsmanagement.aspect.dod_ghosted.description=Record di soli metadati - -listconstraint.rmc_tlList.title=Posizioni di trasferimento +rma_recordsmanagement.description=Modello dei contenuti di gestione dei record + +rma_recordsmanagement.type.rma_rmsite.title=Sito di gestione dei record +rma_recordsmanagement.type.rma_rmsite.description=Sito specializzato per la gestione dei record + +rma_recordsmanagement.type.rma_caveatConfig.title=Config avvertenza +rma_recordsmanagement.type.rma_caveatConfig.decription=Config avvertenza + +rma_recordsmanagement.type.rma_emailConfig.title=Configurazione e-mail +rma_recordsmanagement.type.rma_emailConfig.decription=Configurazione e-mail + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Contenitore gestione dei record +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Contenitore gestione dei record + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Contenitore radice di gestione dei record +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Contenitore radice di gestione dei record + +rma_recordsmanagement.type.rma_dispositionSchedule.title=Pianificazione della disposizione +rma_recordsmanagement.type.rma_dispositionSchedule.decription=Pianificazione della disposizione + +rma_recordsmanagement.property.rma_dispositionAuthority.title=Autorit\u00e0 di disposizione +rma_recordsmanagement.property.rma_dispositionAuthority.decription=Autorit\u00e0 di disposizione + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Istruzioni di disposizione +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Istruzioni di disposizione + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Disposizione livello record +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Disposizione livello record + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Azioni di disposizione +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Azioni di disposizione + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definizione di azione di disposizione +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definizione di azione di disposizione +rma_recordsmanagement.property.rma_dispositionActionName.title=Nome dell'azione di disposizione +rma_recordsmanagement.property.rma_dispositionActionName.decription=Nome dell'azione di disposizione +rma_recordsmanagement.property.rma_dispositionDescription.title=Descrizione disposizione +rma_recordsmanagement.property.rma_dispositionDescription.decription=Descrizione disposizione +rma_recordsmanagement.property.rma_dispositionLocation.title=Posizione disposizione +rma_recordsmanagement.property.rma_dispositionLocation.decription=Posizione disposizione +rma_recordsmanagement.property.rma_dispositionPeriod.title=Periodo della disposizione +rma_recordsmanagement.property.rma_dispositionPeriod.decription=Periodo della disposizione +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Propriet\u00e0 del periodo della disposizione +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Propriet\u00e0 del periodo della disposizione +rma_recordsmanagement.property.rma_dispositionEvent.title=Evento di disposizione +rma_recordsmanagement.property.rma_dispositionEvent.decription=Evento di disposizione +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinazione evento di disposizione +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinazione evento di disposizione + +rma_recordsmanagement.type.rma_recordFolder.title=Cartella di record +rma_recordsmanagement.type.rma_recordFolder.decription=Cartella di record +rma_recordsmanagement.property.rma_isClosed.title=Record +rma_recordsmanagement.property.rma_isClosed.decription=Record + +rma_recordsmanagement.type.rma_recordCategory.title=Categoria record +rma_recordsmanagement.type.rma_recordCategory.decription=Categoria record + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Documento non elettronico +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Documento non elettronico +rma_recordsmanagement.property.rma_physicalSize.title=Dimensioni fisiche +rma_recordsmanagement.property.rma_physicalSize.decription=Le dimensioni del documento misurate in metri lineari. +rma_recordsmanagement.property.rma_numberOfCopies.title=Numero di copie +rma_recordsmanagement.property.rma_numberOfCopies.description=Il numero di copie del documento. +rma_recordsmanagement.property.rma_storageLocation.title=Posizione di archiviazione +rma_recordsmanagement.property.rma_storageLocation.decription=La posizione fisica di archiviazione del record. +rma_recordsmanagement.property.rma_shelf.title=Ripiano +rma_recordsmanagement.property.rma_shelf.decription=Il ripiano sul quale \u00e8 collocato il record. +rma_recordsmanagement.property.rma_box.title=Casella +rma_recordsmanagement.property.rma_box.description=La casella dove \u00e8 collocato il record. +rma_recordsmanagement.property.rma_file.title=File +rma_recordsmanagement.property.rma_file.decription=Il file dove \u00e8 collocato il record. + +rma_recordsmanagement.type.rma_dispositionAction.title=Azione di disposizione +rma_recordsmanagement.type.rma_dispositionAction.decription=Azione di disposizione +rma_recordsmanagement.property.rma_dispositionActionId.title=ID azione di disposizione +rma_recordsmanagement.property.rma_dispositionActionId.decription=ID azione di disposizione +rma_recordsmanagement.property.rma_dispositionAction.title=Azione di disposizione +rma_recordsmanagement.property.rma_dispositionAction.decription=Azione di disposizione +rma_recordsmanagement.property.rma_dispositionAsOf.title=Azione di disposizione +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Azione di disposizione +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=Eventi di disposizione idonei +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=Eventi di disposizione idonei +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Azione di disposizione iniziata alle ore +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Azione di disposizione iniziata alle ore +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Azione di disposizione iniziata da +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Azione di disposizione iniziata da +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Azione di disposizione completata alle ore +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Azione di disposizione completata alle ore +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Azione di disposizione completata da +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Azione di disposizione completata da +rma_recordsmanagement.association.rma_eventExecutions.title=Esecuzioni evento +rma_recordsmanagement.association.rma_eventExecutions.decription=Esecuzioni evento + +rma_recordsmanagement.type.rma_eventExecution.title=Esecuzione evento +rma_recordsmanagement.type.rma_eventExecution.decription=Esecuzione evento +rma_recordsmanagement.property.rma_eventExecutionName.title=Nome evento +rma_recordsmanagement.property.rma_eventExecutionName.decription=Nome evento +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Evento automatico +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Evento automatico +rma_recordsmanagement.property.rma_eventExecutionComplete.title=Evento completato +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Evento completato +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Evento completato da +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Evento completato da +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Evento completato alle ore +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Evento completato alle ore + +rma_recordsmanagement.type.rma_hold.title=Sospensione +rma_recordsmanagement.type.rma_hold.decription=Sospensione +rma_recordsmanagement.property.rma_holdReason.title=Motivo sospensione +rma_recordsmanagement.property.rma_holdReason.decription=Motivo sospensione +rma_recordsmanagement.association.rma_frozenRecords.title=Record sospesi +rma_recordsmanagement.association.rma_frozenRecords.decription=Record sospesi + +rma_recordsmanagement.type.rma_transfer.title=Trasferimento +rma_recordsmanagement.type.rma_transfer.decription=Trasferimento +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Trasferisci indicatore di inserimento +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Trasferisci indicatore di inserimento +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Trasferisci indicatore PDF +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Trasferisci indicatore PDF +rma_recordsmanagement.property.rma_transferLocation.title=Trasferisci PDF +rma_recordsmanagement.property.rma_transferLocation.decription=Trasferisci PDF +rma_recordsmanagement.association.rma_transferred.title=Trasferito +rma_recordsmanagement.association.rma_transferred.decription=Trasferito + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=Componente piano file +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Componente piano file +rma_recordsmanagement.property.rma_rootNodeRef.title=Nodo radice +rma_recordsmanagement.property.rma_rootNodeRef.decription=Nodo radice + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Radice di gestione dei record +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Radice di gestione dei record +rma_recordsmanagement.association.rma_holds.title=Sospende +rma_recordsmanagement.association.rma_holds.decription=Sospende +rma_recordsmanagement.association.rma_transfers.title=Trasferisce +rma_recordsmanagement.association.rma_transfers.decription=Trasferisce + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Record completato +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Record completato +rma_recordsmanagement.property.rma_declaredAt.title=Data completamento +rma_recordsmanagement.property.rma_declaredAt.decription=Data completamento +rma_recordsmanagement.property.rma_declaredBy.title=Completato da +rma_recordsmanagement.property.rma_declaredBy.decription=Completato da + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificatore componente record +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificatore componente record +rma_recordsmanagement.property.rma_identifier.title=Identificativo +rma_recordsmanagement.property.rma_identifier.decription=Identificatore record univoco +rma_recordsmanagement.property.rma_dbUniquenessId.title=Unicit\u00e0 database +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Unicit\u00e0 database + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definizione di record fondamentale +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definizione di record fondamentale + +rma_recordsmanagement.property.rma_reviewPeriod.title=Periodo di revisione +rma_recordsmanagement.property.rma_reviewPeriod.decription=Periodo di revisione +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicatore record fondamentale +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicatore record fondamentale + +rma_recordsmanagement.aspect.rma_record.title=Record +rma_recordsmanagement.aspect.rma_record.decription=Record +rma_recordsmanagement.property.rma_dateFiled.title=Data di archiviazione +rma_recordsmanagement.property.rma_dateFiled.decription=Data di archiviazione +rma_recordsmanagement.property.rma_origionalName=Nome originale + +rma_recordsmanagement.aspect.rma_recordMetaData.title=Metadati record +rma_recordsmanagement.aspect.rma_recordMetaData.description=Aspetto indicatore per metadati di record + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Dettagli record comuni +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Metadati comuni a tutti i tipi di record +rma_recordsmanagement.property.rma_location.title=Posizione +rma_recordsmanagement.property.rma_location.decription=Posizione + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Record fondamentale +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Record fondamentale +rma_recordsmanagement.property.rma_reviewAsOf.title=Prossima revisione +rma_recordsmanagement.property.rma_reviewAsOf.decription=Prossima revisione +rma_recordsmanagement.property.rma_notificationIssued.title=Indica che \u00e8 stata rilasciata una notifica di revisione per questo record +rma_recordsmanagement.property.rma_notificationIssued.decription=Indica che \u00e8 stata rilasciata una notifica di revisione per questo record + +rma_recordsmanagement.aspect.rma_scheduled.title=Pianificato +rma_recordsmanagement.aspect.rma_scheduled.decription=Pianificato +rma_recordsmanagement.association.rma_dispositionSchedule.title=Pianificazione della disposizione +rma_recordsmanagement.association.rma_dispositionSchedule.decription=Pianificazione della disposizione + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Ciclo di vita della disposizione +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Ciclo di vita della disposizione +rma_recordsmanagement.association.rma_nextDispositionAction.title=Prossima azione di disposizione +rma_recordsmanagement.association.rma_nextDispositionAction.decription=Prossima azione di disposizione +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Cronologia azioni di disposizione +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Cronologia azioni di disposizione + +rma_recordsmanagement.aspect.rma_cutOff.title=Cut off +rma_recordsmanagement.aspect.rma_cutOff.decription=Cut off +rma_recordsmanagement.property.rma_cutOffDate.title=Data cut off +rma_recordsmanagement.property.rma_cutOffDate.decription=Data cut off + +rma_recordsmanagement.aspect.rma_transferred.title=Trasferito +rma_recordsmanagement.aspect.rma_transferred.decription=Trasferito + +rma_recordsmanagement.aspect.rma_ascended.title=Asceso +rma_recordsmanagement.aspect.rma_ascended.decription=Asceso + +rma_recordsmanagement.aspect.rma_frozen.title=Sospeso +rma_recordsmanagement.aspect.rma_frozen.decription=Sospeso +rma_recordsmanagement.property.rma_frozenAt.title=Sospeso presso +rma_recordsmanagement.property.rma_frozenAt.decription=Sospeso presso +rma_recordsmanagement.property.rma_frozenBy.title=Sospeso da +rma_recordsmanagement.property.rma_frozenBy.decription=Sospeso da + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Radice di configurazione avvertenza +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Radice di configurazione avvertenza +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Configurazione avvertenza +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Configurazione avvertenza + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Radice Config E-mail +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Radice Config E-mail +rma_recordsmanagement.association.rma_emailConfigAssoc.title=Configurazione e-mail +rma_recordsmanagement.association.rma_emailConfigAssoc.description=Configurazione e-mail + +rma_recordsmanagement.aspect.rma_recordSearch.title=Ricerca record +rma_recordsmanagement.aspect.rma_recordSearch.decription=Eseguito il rollup delle informazioni di ricerca per supportare la ricerca di Gestione dei record +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Possiede una pianificazione della disposizione +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Indica se una pianificazione della disposizione \u00e8 stata associata ad un certo elemento +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Nome dell'azione di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=Il nome della prossima azione di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Azione di disposizione di +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=La data in cui la prossima azione di disposizione diventa idonea +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Periodo della disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Periodo della disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Espressione del periodo della disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Espressione del periodo della disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=Eventi di disposizione idonei +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=Eventi di disposizione idonei +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Eventi di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Eventi di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Autorit\u00e0 di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Autorit\u00e0 di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Istruzioni di disposizione +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Istruzioni di disposizione +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Motivo sospensione +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Motivo sospensione +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Periodo di revisione record fondamentale +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Periodo di revisione record fondamentale +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Espressione periodo di revisione +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Espressione periodo di revisione + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Record con versione +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Record con versione + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Aggiornamento non pubblicato +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Aggiornamento non pubblicato +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Aggiornamento non pubblicato +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Indica se \u00e8 presente un aggiornamento non pubblicato +rma_recordsmanagement.property.rma_updateTo.title=Aggiornamento a +rma_recordsmanagement.property.rma_updateTo.description=Destinazione dell'aggiornamento +rma_recordsmanagement.property.rma_updatedProperties.title=Propriet\u00e0 aggiornate +rma_recordsmanagement.property.rma_updatedProperties.description=Le propriet\u00e0 aggiornate +rma_recordsmanagement.property.rma_publishInProgress.title=Pubblicazione in corso +rma_recordsmanagement.property.rma_publishInProgress.description=Indica se \u00e8 in corso una pubblicazione + +rma_recordsmanagement.aspect.dod_ghosted.title=Record di soli metadati +rma_recordsmanagement.aspect.dod_ghosted.description=Record di soli metadati + +listconstraint.rmc_tlList.title=Posizioni di trasferimento listconstraint.rmc_smList.title=Contrassegni supplementari \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties index 6bb063eebe..ee8cb1667a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb - -rma_recordsmanagement.type.rma_rmsite.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b5\u30a4\u30c8 -rma_recordsmanagement.type.rma_rmsite.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u7528\u306e\u5c02\u9580\u30b5\u30a4\u30c8 - -rma_recordsmanagement.type.rma_caveatConfig.title=\u8b66\u544a\u8a2d\u5b9a -rma_recordsmanagement.type.rma_caveatConfig.decription=\u8b66\u544a\u8a2d\u5b9a - -rma_recordsmanagement.type.rma_emailConfig.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a -rma_recordsmanagement.type.rma_emailConfig.decription=E\u30e1\u30fc\u30eb\u8a2d\u5b9a - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u30b3\u30f3\u30c6\u30ca\u30fc -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u30b3\u30f3\u30c6\u30ca\u30fc - -rma_recordsmanagement.type.rma_dispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb -rma_recordsmanagement.type.rma_dispositionSchedule.decription=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb - -rma_recordsmanagement.property.rma_dispositionAuthority.title=\u5ec3\u68c4\u6a29\u9650 -rma_recordsmanagement.property.rma_dispositionAuthority.decription=\u5ec3\u68c4\u6a29\u9650 - -rma_recordsmanagement.property.rma_dispositionInstructions.title=\u5ec3\u68c4\u6307\u793a -rma_recordsmanagement.property.rma_dispositionInstructions.decription=\u5ec3\u68c4\u6307\u793a - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=\u30ec\u30b3\u30fc\u30c9\u30ec\u30d9\u30eb\u5ec3\u68c4 -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=\u30ec\u30b3\u30fc\u30c9\u30ec\u30d9\u30eb\u5ec3\u68c4 - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9 -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9 -rma_recordsmanagement.property.rma_dispositionActionName.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d -rma_recordsmanagement.property.rma_dispositionActionName.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d -rma_recordsmanagement.property.rma_dispositionDescription.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u8aac\u660e -rma_recordsmanagement.property.rma_dispositionDescription.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u8aac\u660e -rma_recordsmanagement.property.rma_dispositionLocation.title=\u5ec3\u68c4\u5834\u6240 -rma_recordsmanagement.property.rma_dispositionLocation.decription=\u5ec3\u68c4\u5834\u6240 -rma_recordsmanagement.property.rma_dispositionPeriod.title=\u5ec3\u68c4\u671f\u9593 -rma_recordsmanagement.property.rma_dispositionPeriod.decription=\u5ec3\u68c4\u671f\u9593 -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=\u5ec3\u68c4\u671f\u9593\u306e\u30d7\u30ed\u30d1\u30c6\u30a3 -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=\u5ec3\u68c4\u671f\u9593\u306e\u30d7\u30ed\u30d1\u30c6\u30a3 -rma_recordsmanagement.property.rma_dispositionEvent.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 -rma_recordsmanagement.property.rma_dispositionEvent.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 -rma_recordsmanagement.property.rma_dispositionEventCombination.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u306e\u7d44\u307f\u5408\u308f\u305b -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u306e\u7d44\u307f\u5408\u308f\u305b - -rma_recordsmanagement.type.rma_recordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rma_recordsmanagement.type.rma_recordFolder.decription=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rma_recordsmanagement.property.rma_isClosed.title=\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.property.rma_isClosed.decription=\u30ec\u30b3\u30fc\u30c9 - -rma_recordsmanagement.type.rma_recordCategory.title=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea -rma_recordsmanagement.type.rma_recordCategory.decription=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=\u975e\u96fb\u5b50\u6587\u66f8 -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=\u975e\u96fb\u5b50\u6587\u66f8 -rma_recordsmanagement.property.rma_physicalSize.title=\u7269\u7406\u7684\u306a\u30b5\u30a4\u30ba -rma_recordsmanagement.property.rma_physicalSize.decription=\u6587\u66f8\u306e\u30b5\u30a4\u30ba\u306f\u30ea\u30cb\u30a2\u30e1\u30fc\u30bf\u30fc\u3067\u8a08\u6e2c\u3055\u308c\u307e\u3059\u3002 -rma_recordsmanagement.property.rma_numberOfCopies.title=\u30b3\u30d4\u30fc\u6570 -rma_recordsmanagement.property.rma_numberOfCopies.description=\u6587\u66f8\u306e\u30b3\u30d4\u30fc\u6570\u3067\u3059\u3002 -rma_recordsmanagement.property.rma_storageLocation.title=\u4fdd\u7ba1\u5834\u6240 -rma_recordsmanagement.property.rma_storageLocation.decription=\u30ec\u30b3\u30fc\u30c9\u306e\u7269\u7406\u7684\u306a\u4fdd\u7ba1\u5834\u6240\u3067\u3059\u3002 -rma_recordsmanagement.property.rma_shelf.title=\u68da -rma_recordsmanagement.property.rma_shelf.decription=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u68da\u3067\u3059\u3002 -rma_recordsmanagement.property.rma_box.title=\u7bb1 -rma_recordsmanagement.property.rma_box.description=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u7bb1\u3067\u3059\u3002 -rma_recordsmanagement.property.rma_file.title=\u6574\u7406\u4fdd\u7ba1 -rma_recordsmanagement.property.rma_file.decription=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002 - -rma_recordsmanagement.type.rma_dispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.type.rma_dispositionAction.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_dispositionActionId.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3ID -rma_recordsmanagement.property.rma_dispositionActionId.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3ID -rma_recordsmanagement.property.rma_dispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_dispositionAction.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_dispositionAsOf.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_dispositionAsOf.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u65e5\u6642 -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u65e5\u6642 -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u8005 -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u8005 -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u65e5\u6642 -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u65e5\u6642 -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u8005 -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u8005 -rma_recordsmanagement.association.rma_eventExecutions.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c -rma_recordsmanagement.association.rma_eventExecutions.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c - -rma_recordsmanagement.type.rma_eventExecution.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c -rma_recordsmanagement.type.rma_eventExecution.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c -rma_recordsmanagement.property.rma_eventExecutionName.title=\u30a4\u30d9\u30f3\u30c8\u540d -rma_recordsmanagement.property.rma_eventExecutionName.decription=\u30a4\u30d9\u30f3\u30c8\u540d -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u30a4\u30d9\u30f3\u30c8\u306e\u81ea\u52d5\u5316 -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u81ea\u52d5\u5316 -rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u30a4\u30d9\u30f3\u30c8\u5b8c\u4e86 -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u30a4\u30d9\u30f3\u30c8\u5b8c\u4e86 -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u8005 -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u8005 -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u65e5\u6642 -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u65e5\u6642 - -rma_recordsmanagement.type.rma_hold.title=\u30db\u30fc\u30eb\u30c9 -rma_recordsmanagement.type.rma_hold.decription=\u30db\u30fc\u30eb\u30c9 -rma_recordsmanagement.property.rma_holdReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531 -rma_recordsmanagement.property.rma_holdReason.decription=\u30db\u30fc\u30eb\u30c9\u7406\u7531 -rma_recordsmanagement.association.rma_frozenRecords.title=\u30db\u30fc\u30eb\u30c9\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.association.rma_frozenRecords.decription=\u30db\u30fc\u30eb\u30c9\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 - -rma_recordsmanagement.type.rma_transfer.title=\u8ee2\u9001 -rma_recordsmanagement.type.rma_transfer.decription=\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=\u53d7\u8afe\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=\u53d7\u8afe\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferPDFIndicator.title=PDF\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=PDF\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferLocation.title=PDF\u306e\u8ee2\u9001 -rma_recordsmanagement.property.rma_transferLocation.decription=PDF\u306e\u8ee2\u9001 -rma_recordsmanagement.association.rma_transferred.title=\u8ee2\u9001\u6e08\u307f -rma_recordsmanagement.association.rma_transferred.decription=\u8ee2\u9001\u6e08\u307f - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 -rma_recordsmanagement.property.rma_rootNodeRef.title=\u30eb\u30fc\u30c8\u30ce\u30fc\u30c9 -rma_recordsmanagement.property.rma_rootNodeRef.decription=\u30eb\u30fc\u30c8\u30ce\u30fc\u30c9 - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8 -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8 -rma_recordsmanagement.association.rma_holds.title=\u30db\u30fc\u30eb\u30c9 -rma_recordsmanagement.association.rma_holds.decription=\u30db\u30fc\u30eb\u30c9 -rma_recordsmanagement.association.rma_transfers.title=\u8ee2\u9001 -rma_recordsmanagement.association.rma_transfers.decription=\u8ee2\u9001 - -rma_recordsmanagement.aspect.rma_declaredRecord.title=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.aspect.rma_declaredRecord.decription=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.property.rma_declaredAt.title=\u5b8c\u4e86\u65e5 -rma_recordsmanagement.property.rma_declaredAt.decription=\u5b8c\u4e86\u65e5 -rma_recordsmanagement.property.rma_declaredBy.title=\u5b8c\u4e86\u8005 -rma_recordsmanagement.property.rma_declaredBy.decription=\u5b8c\u4e86\u8005 - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID -rma_recordsmanagement.property.rma_identifier.title=ID -rma_recordsmanagement.property.rma_identifier.decription=\u4e00\u610f\u306e\u30ec\u30b3\u30fc\u30c9ID -rma_recordsmanagement.property.rma_dbUniquenessId.title=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e00\u610f\u6027 -rma_recordsmanagement.property.rma_dbUniquenessId.decription=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e00\u610f\u6027 - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9 -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9 - -rma_recordsmanagement.property.rma_reviewPeriod.title=\u30ec\u30d3\u30e5\u30fc\u671f\u9593 -rma_recordsmanagement.property.rma_reviewPeriod.decription=\u30ec\u30d3\u30e5\u30fc\u671f\u9593 -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc - -rma_recordsmanagement.aspect.rma_record.title=\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.aspect.rma_record.decription=\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.property.rma_dateFiled.title=\u6574\u7406\u4fdd\u7ba1\u65e5 -rma_recordsmanagement.property.rma_dateFiled.decription=\u6574\u7406\u4fdd\u7ba1\u65e5 -rma_recordsmanagement.property.rma_origionalName=\u5143\u306e\u540d\u524d - -rma_recordsmanagement.aspect.rma_recordMetaData.title=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf -rma_recordsmanagement.aspect.rma_recordMetaData.description=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30fc\u30ab\u30fc\u30a2\u30b9\u30da\u30af\u30c8 - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=\u5171\u901a\u306a\u30ec\u30b3\u30fc\u30c9\u306e\u8a73\u7d30 -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306b\u5171\u901a\u306a\u30e1\u30bf\u30c7\u30fc\u30bf -rma_recordsmanagement.property.rma_location.title=\u5834\u6240 -rma_recordsmanagement.property.rma_location.decription=\u5834\u6240 - -rma_recordsmanagement.aspect.rma_vitalRecord.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.property.rma_reviewAsOf.title=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc -rma_recordsmanagement.property.rma_reviewAsOf.decription=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc -rma_recordsmanagement.property.rma_notificationIssued.title=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 -rma_recordsmanagement.property.rma_notificationIssued.decription=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 - -rma_recordsmanagement.aspect.rma_scheduled.title=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f -rma_recordsmanagement.aspect.rma_scheduled.decription=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f -rma_recordsmanagement.association.rma_dispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb -rma_recordsmanagement.association.rma_dispositionSchedule.decription=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb -rma_recordsmanagement.association.rma_nextDispositionAction.title=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.association.rma_dispositionActionHistory.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5c65\u6b74 -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5c65\u6b74 - -rma_recordsmanagement.aspect.rma_cutOff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 -rma_recordsmanagement.aspect.rma_cutOff.decription=\u30ab\u30c3\u30c8\u30aa\u30d5 -rma_recordsmanagement.property.rma_cutOffDate.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u65e5 -rma_recordsmanagement.property.rma_cutOffDate.decription=\u30ab\u30c3\u30c8\u30aa\u30d5\u65e5 - -rma_recordsmanagement.aspect.rma_transferred.title=\u8ee2\u9001\u6e08\u307f -rma_recordsmanagement.aspect.rma_transferred.decription=\u8ee2\u9001\u6e08\u307f - -rma_recordsmanagement.aspect.rma_ascended.title=\u6607\u9806\u6e08\u307f -rma_recordsmanagement.aspect.rma_ascended.decription=\u6607\u9806\u6e08\u307f - -rma_recordsmanagement.aspect.rma_frozen.title=\u30db\u30fc\u30eb\u30c9\u4e2d -rma_recordsmanagement.aspect.rma_frozen.decription=\u30db\u30fc\u30eb\u30c9\u4e2d -rma_recordsmanagement.property.rma_frozenAt.title=\u30db\u30fc\u30eb\u30c9\u65e5\u6642 -rma_recordsmanagement.property.rma_frozenAt.decription=\u30db\u30fc\u30eb\u30c9\u65e5\u6642 -rma_recordsmanagement.property.rma_frozenBy.title=\u30db\u30fc\u30eb\u30c9 -rma_recordsmanagement.property.rma_frozenBy.decription=\u30db\u30fc\u30eb\u30c9 - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=\u8b66\u544a\u8a2d\u5b9a\u30eb\u30fc\u30c8 -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=\u8b66\u544a\u8a2d\u5b9a\u30eb\u30fc\u30c8 -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=\u8b66\u544a\u8a2d\u5b9a -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=\u8b66\u544a\u8a2d\u5b9a - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a\u30eb\u30fc\u30c8 -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=E\u30e1\u30fc\u30eb\u8a2d\u5b9a\u30eb\u30fc\u30c8 -rma_recordsmanagement.association.rma_emailConfigAssoc.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a -rma_recordsmanagement.association.rma_emailConfigAssoc.description=E\u30e1\u30fc\u30eb\u8a2d\u5b9a - -rma_recordsmanagement.aspect.rma_recordSearch.title=\u30ec\u30b3\u30fc\u30c9\u691c\u7d22 -rma_recordsmanagement.aspect.rma_recordSearch.decription=\u691c\u7d22\u60c5\u5831\u3092\u4e0a\u65b9\u306b\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u691c\u7d22\u3092\u884c\u3046 -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u304c\u3042\u308b -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=\u95a2\u9023\u3059\u308b\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u304c\u30a2\u30a4\u30c6\u30e0\u306b\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u308b\u65e5 -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=\u5ec3\u68c4\u671f\u9593 -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=\u5ec3\u68c4\u671f\u9593 -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=\u5ec3\u68c4\u671f\u9593\u306e\u8868\u73fe -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=\u5ec3\u68c4\u671f\u9593\u306e\u8868\u73fe -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=\u5ec3\u68c4\u6a29\u9650 -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=\u5ec3\u68c4\u6a29\u9650 -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=\u5ec3\u68c4\u6307\u793a -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=\u5ec3\u68c4\u6307\u793a -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531 -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=\u30db\u30fc\u30eb\u30c9\u7406\u7531 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9593 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9593 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=\u30ec\u30d3\u30e5\u30fc\u671f\u9593\u306e\u8868\u73fe -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=\u30ec\u30d3\u30e5\u30fc\u671f\u9593\u306e\u8868\u73fe - -rma_recordsmanagement.aspect.rma_versionedRecord.title=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.aspect.rma_versionedRecord.decription=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=\u975e\u516c\u958b\u306e\u66f4\u65b0 -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=\u975e\u516c\u958b\u306e\u66f4\u65b0 -rma_recordsmanagement.property.rma_unpublishedUpdate.title=\u975e\u516c\u958b\u306e\u66f4\u65b0 -rma_recordsmanagement.property.rma_unpublishedUpdate.description=\u975e\u516c\u958b\u306e\u66f4\u65b0\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 -rma_recordsmanagement.property.rma_updateTo.title=\u66f4\u65b0\u5148 -rma_recordsmanagement.property.rma_updateTo.description=\u66f4\u65b0\u5148 -rma_recordsmanagement.property.rma_updatedProperties.title=\u66f4\u65b0\u6e08\u307f\u30d7\u30ed\u30d1\u30c6\u30a3 -rma_recordsmanagement.property.rma_updatedProperties.description=\u66f4\u65b0\u6e08\u307f\u30d7\u30ed\u30d1\u30c6\u30a3 -rma_recordsmanagement.property.rma_publishInProgress.title=\u516c\u958b\u4e2d -rma_recordsmanagement.property.rma_publishInProgress.description=\u73fe\u5728\u3001\u516c\u958b\u4e2d\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 - -rma_recordsmanagement.aspect.dod_ghosted.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u307f\u306e\u30ec\u30b3\u30fc\u30c9 -rma_recordsmanagement.aspect.dod_ghosted.description=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u307f\u306e\u30ec\u30b3\u30fc\u30c9 - -listconstraint.rmc_tlList.title=\u8ee2\u9001\u5834\u6240 +rma_recordsmanagement.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb + +rma_recordsmanagement.type.rma_rmsite.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b5\u30a4\u30c8 +rma_recordsmanagement.type.rma_rmsite.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u7528\u306e\u5c02\u9580\u30b5\u30a4\u30c8 + +rma_recordsmanagement.type.rma_caveatConfig.title=\u8b66\u544a\u8a2d\u5b9a +rma_recordsmanagement.type.rma_caveatConfig.decription=\u8b66\u544a\u8a2d\u5b9a + +rma_recordsmanagement.type.rma_emailConfig.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a +rma_recordsmanagement.type.rma_emailConfig.decription=E\u30e1\u30fc\u30eb\u8a2d\u5b9a + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30b3\u30f3\u30c6\u30ca\u30fc + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u30b3\u30f3\u30c6\u30ca\u30fc +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8\u30b3\u30f3\u30c6\u30ca\u30fc + +rma_recordsmanagement.type.rma_dispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb +rma_recordsmanagement.type.rma_dispositionSchedule.decription=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb + +rma_recordsmanagement.property.rma_dispositionAuthority.title=\u5ec3\u68c4\u6a29\u9650 +rma_recordsmanagement.property.rma_dispositionAuthority.decription=\u5ec3\u68c4\u6a29\u9650 + +rma_recordsmanagement.property.rma_dispositionInstructions.title=\u5ec3\u68c4\u6307\u793a +rma_recordsmanagement.property.rma_dispositionInstructions.decription=\u5ec3\u68c4\u6307\u793a + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=\u30ec\u30b3\u30fc\u30c9\u30ec\u30d9\u30eb\u5ec3\u68c4 +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=\u30ec\u30b3\u30fc\u30c9\u30ec\u30d9\u30eb\u5ec3\u68c4 + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9 +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9 +rma_recordsmanagement.property.rma_dispositionActionName.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d +rma_recordsmanagement.property.rma_dispositionActionName.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d +rma_recordsmanagement.property.rma_dispositionDescription.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u8aac\u660e +rma_recordsmanagement.property.rma_dispositionDescription.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u8aac\u660e +rma_recordsmanagement.property.rma_dispositionLocation.title=\u5ec3\u68c4\u5834\u6240 +rma_recordsmanagement.property.rma_dispositionLocation.decription=\u5ec3\u68c4\u5834\u6240 +rma_recordsmanagement.property.rma_dispositionPeriod.title=\u5ec3\u68c4\u671f\u9593 +rma_recordsmanagement.property.rma_dispositionPeriod.decription=\u5ec3\u68c4\u671f\u9593 +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=\u5ec3\u68c4\u671f\u9593\u306e\u30d7\u30ed\u30d1\u30c6\u30a3 +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=\u5ec3\u68c4\u671f\u9593\u306e\u30d7\u30ed\u30d1\u30c6\u30a3 +rma_recordsmanagement.property.rma_dispositionEvent.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 +rma_recordsmanagement.property.rma_dispositionEvent.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 +rma_recordsmanagement.property.rma_dispositionEventCombination.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u306e\u7d44\u307f\u5408\u308f\u305b +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u306e\u7d44\u307f\u5408\u308f\u305b + +rma_recordsmanagement.type.rma_recordFolder.title=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rma_recordsmanagement.type.rma_recordFolder.decription=\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rma_recordsmanagement.property.rma_isClosed.title=\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.property.rma_isClosed.decription=\u30ec\u30b3\u30fc\u30c9 + +rma_recordsmanagement.type.rma_recordCategory.title=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea +rma_recordsmanagement.type.rma_recordCategory.decription=\u30ec\u30b3\u30fc\u30c9\u30ab\u30c6\u30b4\u30ea + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=\u975e\u96fb\u5b50\u6587\u66f8 +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=\u975e\u96fb\u5b50\u6587\u66f8 +rma_recordsmanagement.property.rma_physicalSize.title=\u7269\u7406\u7684\u306a\u30b5\u30a4\u30ba +rma_recordsmanagement.property.rma_physicalSize.decription=\u6587\u66f8\u306e\u30b5\u30a4\u30ba\u306f\u30ea\u30cb\u30a2\u30e1\u30fc\u30bf\u30fc\u3067\u8a08\u6e2c\u3055\u308c\u307e\u3059\u3002 +rma_recordsmanagement.property.rma_numberOfCopies.title=\u30b3\u30d4\u30fc\u6570 +rma_recordsmanagement.property.rma_numberOfCopies.description=\u6587\u66f8\u306e\u30b3\u30d4\u30fc\u6570\u3067\u3059\u3002 +rma_recordsmanagement.property.rma_storageLocation.title=\u4fdd\u7ba1\u5834\u6240 +rma_recordsmanagement.property.rma_storageLocation.decription=\u30ec\u30b3\u30fc\u30c9\u306e\u7269\u7406\u7684\u306a\u4fdd\u7ba1\u5834\u6240\u3067\u3059\u3002 +rma_recordsmanagement.property.rma_shelf.title=\u68da +rma_recordsmanagement.property.rma_shelf.decription=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u68da\u3067\u3059\u3002 +rma_recordsmanagement.property.rma_box.title=\u7bb1 +rma_recordsmanagement.property.rma_box.description=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u7bb1\u3067\u3059\u3002 +rma_recordsmanagement.property.rma_file.title=\u6574\u7406\u4fdd\u7ba1 +rma_recordsmanagement.property.rma_file.decription=\u30ec\u30b3\u30fc\u30c9\u3092\u4fdd\u7ba1\u3057\u3066\u304a\u304f\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002 + +rma_recordsmanagement.type.rma_dispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.type.rma_dispositionAction.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_dispositionActionId.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3ID +rma_recordsmanagement.property.rma_dispositionActionId.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3ID +rma_recordsmanagement.property.rma_dispositionAction.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_dispositionAction.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_dispositionAsOf.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_dispositionAsOf.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u65e5\u6642 +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u65e5\u6642 +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u8005 +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u958b\u59cb\u8005 +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u65e5\u6642 +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u65e5\u6642 +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u8005 +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u8005 +rma_recordsmanagement.association.rma_eventExecutions.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c +rma_recordsmanagement.association.rma_eventExecutions.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c + +rma_recordsmanagement.type.rma_eventExecution.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c +rma_recordsmanagement.type.rma_eventExecution.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b9f\u884c +rma_recordsmanagement.property.rma_eventExecutionName.title=\u30a4\u30d9\u30f3\u30c8\u540d +rma_recordsmanagement.property.rma_eventExecutionName.decription=\u30a4\u30d9\u30f3\u30c8\u540d +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u30a4\u30d9\u30f3\u30c8\u306e\u81ea\u52d5\u5316 +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u81ea\u52d5\u5316 +rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u30a4\u30d9\u30f3\u30c8\u5b8c\u4e86 +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u30a4\u30d9\u30f3\u30c8\u5b8c\u4e86 +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u8005 +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u8005 +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u65e5\u6642 +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u30a4\u30d9\u30f3\u30c8\u306e\u5b8c\u4e86\u65e5\u6642 + +rma_recordsmanagement.type.rma_hold.title=\u30db\u30fc\u30eb\u30c9 +rma_recordsmanagement.type.rma_hold.decription=\u30db\u30fc\u30eb\u30c9 +rma_recordsmanagement.property.rma_holdReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531 +rma_recordsmanagement.property.rma_holdReason.decription=\u30db\u30fc\u30eb\u30c9\u7406\u7531 +rma_recordsmanagement.association.rma_frozenRecords.title=\u30db\u30fc\u30eb\u30c9\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.association.rma_frozenRecords.decription=\u30db\u30fc\u30eb\u30c9\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 + +rma_recordsmanagement.type.rma_transfer.title=\u8ee2\u9001 +rma_recordsmanagement.type.rma_transfer.decription=\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=\u53d7\u8afe\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=\u53d7\u8afe\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferPDFIndicator.title=PDF\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=PDF\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc\u306e\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferLocation.title=PDF\u306e\u8ee2\u9001 +rma_recordsmanagement.property.rma_transferLocation.decription=PDF\u306e\u8ee2\u9001 +rma_recordsmanagement.association.rma_transferred.title=\u8ee2\u9001\u6e08\u307f +rma_recordsmanagement.association.rma_transferred.decription=\u8ee2\u9001\u6e08\u307f + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=\u30d5\u30a1\u30a4\u30eb\u30d7\u30e9\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 +rma_recordsmanagement.property.rma_rootNodeRef.title=\u30eb\u30fc\u30c8\u30ce\u30fc\u30c9 +rma_recordsmanagement.property.rma_rootNodeRef.decription=\u30eb\u30fc\u30c8\u30ce\u30fc\u30c9 + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8 +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30eb\u30fc\u30c8 +rma_recordsmanagement.association.rma_holds.title=\u30db\u30fc\u30eb\u30c9 +rma_recordsmanagement.association.rma_holds.decription=\u30db\u30fc\u30eb\u30c9 +rma_recordsmanagement.association.rma_transfers.title=\u8ee2\u9001 +rma_recordsmanagement.association.rma_transfers.decription=\u8ee2\u9001 + +rma_recordsmanagement.aspect.rma_declaredRecord.title=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.aspect.rma_declaredRecord.decription=\u5b8c\u4e86\u6e08\u307f\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.property.rma_declaredAt.title=\u5b8c\u4e86\u65e5 +rma_recordsmanagement.property.rma_declaredAt.decription=\u5b8c\u4e86\u65e5 +rma_recordsmanagement.property.rma_declaredBy.title=\u5b8c\u4e86\u8005 +rma_recordsmanagement.property.rma_declaredBy.decription=\u5b8c\u4e86\u8005 + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=\u30ec\u30b3\u30fc\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID +rma_recordsmanagement.property.rma_identifier.title=ID +rma_recordsmanagement.property.rma_identifier.decription=\u4e00\u610f\u306e\u30ec\u30b3\u30fc\u30c9ID +rma_recordsmanagement.property.rma_dbUniquenessId.title=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e00\u610f\u6027 +rma_recordsmanagement.property.rma_dbUniquenessId.decription=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e00\u610f\u6027 + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9 +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9 + +rma_recordsmanagement.property.rma_reviewPeriod.title=\u30ec\u30d3\u30e5\u30fc\u671f\u9593 +rma_recordsmanagement.property.rma_reviewPeriod.decription=\u30ec\u30d3\u30e5\u30fc\u671f\u9593 +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u30a4\u30f3\u30b8\u30b1\u30fc\u30bf\u30fc + +rma_recordsmanagement.aspect.rma_record.title=\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.aspect.rma_record.decription=\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.property.rma_dateFiled.title=\u6574\u7406\u4fdd\u7ba1\u65e5 +rma_recordsmanagement.property.rma_dateFiled.decription=\u6574\u7406\u4fdd\u7ba1\u65e5 +rma_recordsmanagement.property.rma_origionalName=\u5143\u306e\u540d\u524d + +rma_recordsmanagement.aspect.rma_recordMetaData.title=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf +rma_recordsmanagement.aspect.rma_recordMetaData.description=\u30ec\u30b3\u30fc\u30c9\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30de\u30fc\u30ab\u30fc\u30a2\u30b9\u30da\u30af\u30c8 + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=\u5171\u901a\u306a\u30ec\u30b3\u30fc\u30c9\u306e\u8a73\u7d30 +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7\u306b\u5171\u901a\u306a\u30e1\u30bf\u30c7\u30fc\u30bf +rma_recordsmanagement.property.rma_location.title=\u5834\u6240 +rma_recordsmanagement.property.rma_location.decription=\u5834\u6240 + +rma_recordsmanagement.aspect.rma_vitalRecord.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.property.rma_reviewAsOf.title=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc +rma_recordsmanagement.property.rma_reviewAsOf.decription=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc +rma_recordsmanagement.property.rma_notificationIssued.title=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 +rma_recordsmanagement.property.rma_notificationIssued.decription=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 + +rma_recordsmanagement.aspect.rma_scheduled.title=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f +rma_recordsmanagement.aspect.rma_scheduled.decription=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f +rma_recordsmanagement.association.rma_dispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb +rma_recordsmanagement.association.rma_dispositionSchedule.decription=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u5ec3\u68c4\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb +rma_recordsmanagement.association.rma_nextDispositionAction.title=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.association.rma_dispositionActionHistory.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5c65\u6b74 +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5c65\u6b74 + +rma_recordsmanagement.aspect.rma_cutOff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 +rma_recordsmanagement.aspect.rma_cutOff.decription=\u30ab\u30c3\u30c8\u30aa\u30d5 +rma_recordsmanagement.property.rma_cutOffDate.title=\u30ab\u30c3\u30c8\u30aa\u30d5\u65e5 +rma_recordsmanagement.property.rma_cutOffDate.decription=\u30ab\u30c3\u30c8\u30aa\u30d5\u65e5 + +rma_recordsmanagement.aspect.rma_transferred.title=\u8ee2\u9001\u6e08\u307f +rma_recordsmanagement.aspect.rma_transferred.decription=\u8ee2\u9001\u6e08\u307f + +rma_recordsmanagement.aspect.rma_ascended.title=\u6607\u9806\u6e08\u307f +rma_recordsmanagement.aspect.rma_ascended.decription=\u6607\u9806\u6e08\u307f + +rma_recordsmanagement.aspect.rma_frozen.title=\u30db\u30fc\u30eb\u30c9\u4e2d +rma_recordsmanagement.aspect.rma_frozen.decription=\u30db\u30fc\u30eb\u30c9\u4e2d +rma_recordsmanagement.property.rma_frozenAt.title=\u30db\u30fc\u30eb\u30c9\u65e5\u6642 +rma_recordsmanagement.property.rma_frozenAt.decription=\u30db\u30fc\u30eb\u30c9\u65e5\u6642 +rma_recordsmanagement.property.rma_frozenBy.title=\u30db\u30fc\u30eb\u30c9 +rma_recordsmanagement.property.rma_frozenBy.decription=\u30db\u30fc\u30eb\u30c9 + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=\u8b66\u544a\u8a2d\u5b9a\u30eb\u30fc\u30c8 +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=\u8b66\u544a\u8a2d\u5b9a\u30eb\u30fc\u30c8 +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=\u8b66\u544a\u8a2d\u5b9a +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=\u8b66\u544a\u8a2d\u5b9a + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a\u30eb\u30fc\u30c8 +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=E\u30e1\u30fc\u30eb\u8a2d\u5b9a\u30eb\u30fc\u30c8 +rma_recordsmanagement.association.rma_emailConfigAssoc.title=E\u30e1\u30fc\u30eb\u8a2d\u5b9a +rma_recordsmanagement.association.rma_emailConfigAssoc.description=E\u30e1\u30fc\u30eb\u8a2d\u5b9a + +rma_recordsmanagement.aspect.rma_recordSearch.title=\u30ec\u30b3\u30fc\u30c9\u691c\u7d22 +rma_recordsmanagement.aspect.rma_recordSearch.decription=\u691c\u7d22\u60c5\u5831\u3092\u4e0a\u65b9\u306b\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u691c\u7d22\u3092\u884c\u3046 +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u304c\u3042\u308b +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=\u95a2\u9023\u3059\u308b\u5ec3\u68c4\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u304c\u30a2\u30a4\u30c6\u30e0\u306b\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u540d\u524d +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3 +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=\u6b21\u56de\u306e\u5ec3\u68c4\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u308b\u65e5 +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=\u5ec3\u68c4\u671f\u9593 +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=\u5ec3\u68c4\u671f\u9593 +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=\u5ec3\u68c4\u671f\u9593\u306e\u8868\u73fe +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=\u5ec3\u68c4\u671f\u9593\u306e\u8868\u73fe +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8\u304c\u8a31\u53ef\u6e08\u307f +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u5ec3\u68c4\u30a4\u30d9\u30f3\u30c8 +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=\u5ec3\u68c4\u6a29\u9650 +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=\u5ec3\u68c4\u6a29\u9650 +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=\u5ec3\u68c4\u6307\u793a +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=\u5ec3\u68c4\u6307\u793a +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=\u30db\u30fc\u30eb\u30c9\u7406\u7531 +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=\u30db\u30fc\u30eb\u30c9\u7406\u7531 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9593 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9593 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=\u30ec\u30d3\u30e5\u30fc\u671f\u9593\u306e\u8868\u73fe +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=\u30ec\u30d3\u30e5\u30fc\u671f\u9593\u306e\u8868\u73fe + +rma_recordsmanagement.aspect.rma_versionedRecord.title=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.aspect.rma_versionedRecord.decription=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9 + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=\u975e\u516c\u958b\u306e\u66f4\u65b0 +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=\u975e\u516c\u958b\u306e\u66f4\u65b0 +rma_recordsmanagement.property.rma_unpublishedUpdate.title=\u975e\u516c\u958b\u306e\u66f4\u65b0 +rma_recordsmanagement.property.rma_unpublishedUpdate.description=\u975e\u516c\u958b\u306e\u66f4\u65b0\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 +rma_recordsmanagement.property.rma_updateTo.title=\u66f4\u65b0\u5148 +rma_recordsmanagement.property.rma_updateTo.description=\u66f4\u65b0\u5148 +rma_recordsmanagement.property.rma_updatedProperties.title=\u66f4\u65b0\u6e08\u307f\u30d7\u30ed\u30d1\u30c6\u30a3 +rma_recordsmanagement.property.rma_updatedProperties.description=\u66f4\u65b0\u6e08\u307f\u30d7\u30ed\u30d1\u30c6\u30a3 +rma_recordsmanagement.property.rma_publishInProgress.title=\u516c\u958b\u4e2d +rma_recordsmanagement.property.rma_publishInProgress.description=\u73fe\u5728\u3001\u516c\u958b\u4e2d\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u793a\u3059 + +rma_recordsmanagement.aspect.dod_ghosted.title=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u307f\u306e\u30ec\u30b3\u30fc\u30c9 +rma_recordsmanagement.aspect.dod_ghosted.description=\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u307f\u306e\u30ec\u30b3\u30fc\u30c9 + +listconstraint.rmc_tlList.title=\u8ee2\u9001\u5834\u6240 listconstraint.rmc_smList.title=\u88dc\u8db3\u30de\u30fc\u30ad\u30f3\u30b0 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties index e5371903e6..2f5a74961f 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=Contentmodel Record Management - -rma_recordsmanagement.type.rma_rmsite.title=Locatie Record Management -rma_recordsmanagement.type.rma_rmsite.description=Gespecialiseerde locatie voor Record Management - -rma_recordsmanagement.type.rma_caveatConfig.title=Caveat-configuratie -rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat-configuratie - -rma_recordsmanagement.type.rma_emailConfig.title=E-mailconfiguratie -rma_recordsmanagement.type.rma_emailConfig.decription=E-mailconfiguratie - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=Container Record Management -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Container Record Management - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Oorsprongcontainer Record Management -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Oorsprongcontainer Record Management - -rma_recordsmanagement.type.rma_dispositionSchedule.title=Bewaarschema -rma_recordsmanagement.type.rma_dispositionSchedule.decription=Bewaarschema - -rma_recordsmanagement.property.rma_dispositionAuthority.title=Archiveringsautoriteit -rma_recordsmanagement.property.rma_dispositionAuthority.decription=Archiveringsautoriteit - -rma_recordsmanagement.property.rma_dispositionInstructions.title=Archiveringsinstructies -rma_recordsmanagement.property.rma_dispositionInstructions.decription=Archiveringsinstructies - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=Archivering recordniveau -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Archivering recordniveau - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Archiveringsacties -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Archiveringsacties - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definitie archiveringsactie -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definitie archiveringsactie -rma_recordsmanagement.property.rma_dispositionActionName.title=Naam archiveringsactie -rma_recordsmanagement.property.rma_dispositionActionName.decription=Naam archiveringsactie -rma_recordsmanagement.property.rma_dispositionDescription.title=Beschrijving archivering -rma_recordsmanagement.property.rma_dispositionDescription.decription=Beschrijving archivering -rma_recordsmanagement.property.rma_dispositionLocation.title=Archiveringslocatie -rma_recordsmanagement.property.rma_dispositionLocation.decription=Archiveringslocatie -rma_recordsmanagement.property.rma_dispositionPeriod.title=Archiveringstermijn -rma_recordsmanagement.property.rma_dispositionPeriod.decription=Archiveringstermijn -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Eigenschap archiveringstermijn -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Eigenschap archiveringstermijn -rma_recordsmanagement.property.rma_dispositionEvent.title=Archiveringsgebeurtenis -rma_recordsmanagement.property.rma_dispositionEvent.decription=Archiveringsgebeurtenis -rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinatie archiveringsgebeurtenis -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinatie archiveringsgebeurtenis - -rma_recordsmanagement.type.rma_recordFolder.title=Archiefmap -rma_recordsmanagement.type.rma_recordFolder.decription=Archiefmap -rma_recordsmanagement.property.rma_isClosed.title=Record -rma_recordsmanagement.property.rma_isClosed.decription=Record - -rma_recordsmanagement.type.rma_recordCategory.title=Recordcategorie -rma_recordsmanagement.type.rma_recordCategory.decription=Recordcategorie - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=Niet-elektronisch document -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Niet-elektronisch document -rma_recordsmanagement.property.rma_physicalSize.title=Fysieke grootte -rma_recordsmanagement.property.rma_physicalSize.decription=De grootte van het document gemeten in lineaire meters. -rma_recordsmanagement.property.rma_numberOfCopies.title=Aantal exemplaren -rma_recordsmanagement.property.rma_numberOfCopies.description=Het aantal exemplaren van het document. -rma_recordsmanagement.property.rma_storageLocation.title=Opslaglocatie -rma_recordsmanagement.property.rma_storageLocation.decription=De fysieke opslaglocatie van de record. -rma_recordsmanagement.property.rma_shelf.title=Plank -rma_recordsmanagement.property.rma_shelf.decription=De plank waarop de record wordt bewaard. -rma_recordsmanagement.property.rma_box.title=Doos -rma_recordsmanagement.property.rma_box.description=De doos waarin de record wordt bewaard. -rma_recordsmanagement.property.rma_file.title=Bestand -rma_recordsmanagement.property.rma_file.decription=Het bestand waarin de record wordt bewaard. - -rma_recordsmanagement.type.rma_dispositionAction.title=Archiveringsactie -rma_recordsmanagement.type.rma_dispositionAction.decription=Archiveringsactie -rma_recordsmanagement.property.rma_dispositionActionId.title=Id archiveringsactie -rma_recordsmanagement.property.rma_dispositionActionId.decription=Id archiveringsactie -rma_recordsmanagement.property.rma_dispositionAction.title=Archiveringsactie -rma_recordsmanagement.property.rma_dispositionAction.decription=Archiveringsactie -rma_recordsmanagement.property.rma_dispositionAsOf.title=Archiveringsactie -rma_recordsmanagement.property.rma_dispositionAsOf.decription=Archiveringsactie -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=In aanmerking komende archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=In aanmerking komende archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Archiveringsactie gestart op -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Archiveringsactie gestart op -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Archiveringsactie gestart door -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Archiveringsactie gestart door -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Archiveringsactie afgerond op -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Archiveringsactie afgerond op -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Archiveringsactie afgerond door -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Archiveringsactie afgerond door -rma_recordsmanagement.association.rma_eventExecutions.title=Gebeurtenisuitvoeringen -rma_recordsmanagement.association.rma_eventExecutions.decription=Gebeurtenisuitvoeringen - -rma_recordsmanagement.type.rma_eventExecution.title=Gebeurtenisuitvoering -rma_recordsmanagement.type.rma_eventExecution.decription=Gebeurtenisuitvoering -rma_recordsmanagement.property.rma_eventExecutionName.title=Gebeurtenisnaam -rma_recordsmanagement.property.rma_eventExecutionName.decription=Gebeurtenisnaam -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Gebeurtenis automatisch -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Gebeurtenis automatisch -rma_recordsmanagement.property.rma_eventExecutionComplete.title=Gebeurtenis afgerond -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Gebeurtenis afgerond -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Gebeurtenis afgerond door -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Gebeurtenis afgerond door -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Gebeurtenis afgerond op -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Gebeurtenis afgerond op - -rma_recordsmanagement.type.rma_hold.title=Wachtstand -rma_recordsmanagement.type.rma_hold.decription=Wachtstand -rma_recordsmanagement.property.rma_holdReason.title=Reden van wachtstand -rma_recordsmanagement.property.rma_holdReason.decription=Reden van wachtstand -rma_recordsmanagement.association.rma_frozenRecords.title=Records in wachtstand -rma_recordsmanagement.association.rma_frozenRecords.decription=Records in wachtstand - -rma_recordsmanagement.type.rma_transfer.title=Overzetten -rma_recordsmanagement.type.rma_transfer.decription=Overzetten -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Indicator voor overzettingsoverdracht -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Indicator voor overzettingsoverdracht -rma_recordsmanagement.property.rma_transferPDFIndicator.title=Indicator PDF overzetten -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Indicator PDF overzetten -rma_recordsmanagement.property.rma_transferLocation.title=PDF overzetten -rma_recordsmanagement.property.rma_transferLocation.decription=PDF overzetten -rma_recordsmanagement.association.rma_transferred.title=Overgezet -rma_recordsmanagement.association.rma_transferred.decription=Overgezet - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=Onderdeel ordeningsplan -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Onderdeel ordeningsplan -rma_recordsmanagement.property.rma_rootNodeRef.title=Oorsprongnode -rma_recordsmanagement.property.rma_rootNodeRef.decription=Oorsprongnode - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Oorsprong Record Management -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Oorsprong Record Management -rma_recordsmanagement.association.rma_holds.title=Wachtstanden -rma_recordsmanagement.association.rma_holds.decription=Wachtstanden -rma_recordsmanagement.association.rma_transfers.title=Overzettingen -rma_recordsmanagement.association.rma_transfers.decription=Overzettingen - -rma_recordsmanagement.aspect.rma_declaredRecord.title=Afgeronde record -rma_recordsmanagement.aspect.rma_declaredRecord.decription=Afgeronde record -rma_recordsmanagement.property.rma_declaredAt.title=Datum afgerond -rma_recordsmanagement.property.rma_declaredAt.decription=Datum afgerond -rma_recordsmanagement.property.rma_declaredBy.title=Afgerond door -rma_recordsmanagement.property.rma_declaredBy.decription=Afgerond door - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificatie recordonderdeel -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificatie recordonderdeel -rma_recordsmanagement.property.rma_identifier.title=Identificatie -rma_recordsmanagement.property.rma_identifier.decription=Unieke identificatie record -rma_recordsmanagement.property.rma_dbUniquenessId.title=Uniekheid database -rma_recordsmanagement.property.rma_dbUniquenessId.decription=Uniekheid database - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definitie vitale record -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definitie vitale record - -rma_recordsmanagement.property.rma_reviewPeriod.title=Revisieperiode -rma_recordsmanagement.property.rma_reviewPeriod.decription=Revisieperiode -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicator vitale record -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicator vitale record - -rma_recordsmanagement.aspect.rma_record.title=Record -rma_recordsmanagement.aspect.rma_record.decription=Record -rma_recordsmanagement.property.rma_dateFiled.title=Datum gearchiveerd -rma_recordsmanagement.property.rma_dateFiled.decription=Datum gearchiveerd -rma_recordsmanagement.property.rma_origionalName=Oorspronkelijke naam - -rma_recordsmanagement.aspect.rma_recordMetaData.title=Metagegevens record -rma_recordsmanagement.aspect.rma_recordMetaData.description=Markeraspect voor metagegevens van record - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Algemene recordgegevens -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Algemene metagegevens voor alle recordtypes -rma_recordsmanagement.property.rma_location.title=Locatie -rma_recordsmanagement.property.rma_location.decription=Locatie - -rma_recordsmanagement.aspect.rma_vitalRecord.title=Vitale record -rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vitale record -rma_recordsmanagement.property.rma_reviewAsOf.title=Volgende revisie -rma_recordsmanagement.property.rma_reviewAsOf.decription=Volgende revisie -rma_recordsmanagement.property.rma_notificationIssued.title=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record -rma_recordsmanagement.property.rma_notificationIssued.decription=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record - -rma_recordsmanagement.aspect.rma_scheduled.title=Gepland -rma_recordsmanagement.aspect.rma_scheduled.decription=Gepland -rma_recordsmanagement.association.rma_dispositionSchedule.title=Bewaarschema -rma_recordsmanagement.association.rma_dispositionSchedule.decription=Bewaarschema - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Archiveringscyclus -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Archiveringscyclus -rma_recordsmanagement.association.rma_nextDispositionAction.title=Volgende archiveringsactie -rma_recordsmanagement.association.rma_nextDispositionAction.decription=Volgende archiveringsactie -rma_recordsmanagement.association.rma_dispositionActionHistory.title=Geschiedenis archiveringsactie -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Geschiedenis archiveringsactie - -rma_recordsmanagement.aspect.rma_cutOff.title=Afsluiten -rma_recordsmanagement.aspect.rma_cutOff.decription=Afsluiten -rma_recordsmanagement.property.rma_cutOffDate.title=Datum voor afsluiten -rma_recordsmanagement.property.rma_cutOffDate.decription=Datum voor afsluiten - -rma_recordsmanagement.aspect.rma_transferred.title=Overgezet -rma_recordsmanagement.aspect.rma_transferred.decription=Overgezet - -rma_recordsmanagement.aspect.rma_ascended.title=Opgelopen -rma_recordsmanagement.aspect.rma_ascended.decription=Opgelopen - -rma_recordsmanagement.aspect.rma_frozen.title=In wachtstand -rma_recordsmanagement.aspect.rma_frozen.decription=In wachtstand -rma_recordsmanagement.property.rma_frozenAt.title=In wachtstand in -rma_recordsmanagement.property.rma_frozenAt.decription=In wachtstand in -rma_recordsmanagement.property.rma_frozenBy.title=In wachtstand door -rma_recordsmanagement.property.rma_frozenBy.decription=In wachtstand door - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Oorsprong Caveat-configuratie -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Oorsprong Caveat-configuratie -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat-configuratie -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat-configuratie - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Oorsprong e-mailconfiguratie -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Oorsprong e-mailconfiguratie -rma_recordsmanagement.association.rma_emailConfigAssoc.title=E-mailconfiguratie -rma_recordsmanagement.association.rma_emailConfigAssoc.description=E-mailconfiguratie - -rma_recordsmanagement.aspect.rma_recordSearch.title=Record zoeken -rma_recordsmanagement.aspect.rma_recordSearch.decription=Toegevoegde zoekinformatie ter ondersteuning van Record Management-zoekopdracht -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Heeft bewaarschema -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Geeft aan of er een bewaarschema aan het onderdeel is gekoppeld -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Naam archiveringsactie -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=De naam van de volgende archiveringsactie -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Archiveringsactie van -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=De datum waarop de volgende archiveringsactie in aanmerking komt -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Archiveringstermijn -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Archiveringstermijn -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Uitdrukking van archiveringstermijn -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Uitdrukking van archiveringstermijn -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=In aanmerking komende archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=In aanmerking komende archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Archiveringsgebeurtenissen -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Archiveringsautoriteit -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Archiveringsautoriteit -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Archiveringsinstructies -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Archiveringsinstructies -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Reden van wachtstand -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Reden van wachtstand -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Revisieperiode vitale record -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Revisieperiode vitale record -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Uitdrukking van revisieperiode -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Uitdrukking van revisieperiode - -rma_recordsmanagement.aspect.rma_versionedRecord.title=Record met versiebeheer -rma_recordsmanagement.aspect.rma_versionedRecord.decription=Record met versiebeheer - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Ongepubliceerde update -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Ongepubliceerde update -rma_recordsmanagement.property.rma_unpublishedUpdate.title=Ongepubliceerde update -rma_recordsmanagement.property.rma_unpublishedUpdate.description=Geeft aan of er een ongepubliceerde update is -rma_recordsmanagement.property.rma_updateTo.title=Bijwerken naar -rma_recordsmanagement.property.rma_updateTo.description=Bestemming van de update -rma_recordsmanagement.property.rma_updatedProperties.title=Bijgewerkte eigenschappen -rma_recordsmanagement.property.rma_updatedProperties.description=De bijgewerkte eigenschappen -rma_recordsmanagement.property.rma_publishInProgress.title=Publicatie bezig -rma_recordsmanagement.property.rma_publishInProgress.description=Geeft aan of er momenteel een publicatie wordt uitgevoerd - -rma_recordsmanagement.aspect.dod_ghosted.title=Record met alleen metadata -rma_recordsmanagement.aspect.dod_ghosted.description=Record met alleen metadata - -listconstraint.rmc_tlList.title=Overzetlocaties +rma_recordsmanagement.description=Contentmodel Record Management + +rma_recordsmanagement.type.rma_rmsite.title=Locatie Record Management +rma_recordsmanagement.type.rma_rmsite.description=Gespecialiseerde locatie voor Record Management + +rma_recordsmanagement.type.rma_caveatConfig.title=Caveat-configuratie +rma_recordsmanagement.type.rma_caveatConfig.decription=Caveat-configuratie + +rma_recordsmanagement.type.rma_emailConfig.title=E-mailconfiguratie +rma_recordsmanagement.type.rma_emailConfig.decription=E-mailconfiguratie + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=Container Record Management +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=Container Record Management + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=Oorsprongcontainer Record Management +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=Oorsprongcontainer Record Management + +rma_recordsmanagement.type.rma_dispositionSchedule.title=Bewaarschema +rma_recordsmanagement.type.rma_dispositionSchedule.decription=Bewaarschema + +rma_recordsmanagement.property.rma_dispositionAuthority.title=Archiveringsautoriteit +rma_recordsmanagement.property.rma_dispositionAuthority.decription=Archiveringsautoriteit + +rma_recordsmanagement.property.rma_dispositionInstructions.title=Archiveringsinstructies +rma_recordsmanagement.property.rma_dispositionInstructions.decription=Archiveringsinstructies + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=Archivering recordniveau +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=Archivering recordniveau + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=Archiveringsacties +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=Archiveringsacties + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=Definitie archiveringsactie +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=Definitie archiveringsactie +rma_recordsmanagement.property.rma_dispositionActionName.title=Naam archiveringsactie +rma_recordsmanagement.property.rma_dispositionActionName.decription=Naam archiveringsactie +rma_recordsmanagement.property.rma_dispositionDescription.title=Beschrijving archivering +rma_recordsmanagement.property.rma_dispositionDescription.decription=Beschrijving archivering +rma_recordsmanagement.property.rma_dispositionLocation.title=Archiveringslocatie +rma_recordsmanagement.property.rma_dispositionLocation.decription=Archiveringslocatie +rma_recordsmanagement.property.rma_dispositionPeriod.title=Archiveringstermijn +rma_recordsmanagement.property.rma_dispositionPeriod.decription=Archiveringstermijn +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=Eigenschap archiveringstermijn +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=Eigenschap archiveringstermijn +rma_recordsmanagement.property.rma_dispositionEvent.title=Archiveringsgebeurtenis +rma_recordsmanagement.property.rma_dispositionEvent.decription=Archiveringsgebeurtenis +rma_recordsmanagement.property.rma_dispositionEventCombination.title=Combinatie archiveringsgebeurtenis +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=Combinatie archiveringsgebeurtenis + +rma_recordsmanagement.type.rma_recordFolder.title=Archiefmap +rma_recordsmanagement.type.rma_recordFolder.decription=Archiefmap +rma_recordsmanagement.property.rma_isClosed.title=Record +rma_recordsmanagement.property.rma_isClosed.decription=Record + +rma_recordsmanagement.type.rma_recordCategory.title=Recordcategorie +rma_recordsmanagement.type.rma_recordCategory.decription=Recordcategorie + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=Niet-elektronisch document +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=Niet-elektronisch document +rma_recordsmanagement.property.rma_physicalSize.title=Fysieke grootte +rma_recordsmanagement.property.rma_physicalSize.decription=De grootte van het document gemeten in lineaire meters. +rma_recordsmanagement.property.rma_numberOfCopies.title=Aantal exemplaren +rma_recordsmanagement.property.rma_numberOfCopies.description=Het aantal exemplaren van het document. +rma_recordsmanagement.property.rma_storageLocation.title=Opslaglocatie +rma_recordsmanagement.property.rma_storageLocation.decription=De fysieke opslaglocatie van de record. +rma_recordsmanagement.property.rma_shelf.title=Plank +rma_recordsmanagement.property.rma_shelf.decription=De plank waarop de record wordt bewaard. +rma_recordsmanagement.property.rma_box.title=Doos +rma_recordsmanagement.property.rma_box.description=De doos waarin de record wordt bewaard. +rma_recordsmanagement.property.rma_file.title=Bestand +rma_recordsmanagement.property.rma_file.decription=Het bestand waarin de record wordt bewaard. + +rma_recordsmanagement.type.rma_dispositionAction.title=Archiveringsactie +rma_recordsmanagement.type.rma_dispositionAction.decription=Archiveringsactie +rma_recordsmanagement.property.rma_dispositionActionId.title=Id archiveringsactie +rma_recordsmanagement.property.rma_dispositionActionId.decription=Id archiveringsactie +rma_recordsmanagement.property.rma_dispositionAction.title=Archiveringsactie +rma_recordsmanagement.property.rma_dispositionAction.decription=Archiveringsactie +rma_recordsmanagement.property.rma_dispositionAsOf.title=Archiveringsactie +rma_recordsmanagement.property.rma_dispositionAsOf.decription=Archiveringsactie +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=In aanmerking komende archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=In aanmerking komende archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=Archiveringsactie gestart op +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=Archiveringsactie gestart op +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=Archiveringsactie gestart door +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=Archiveringsactie gestart door +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=Archiveringsactie afgerond op +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=Archiveringsactie afgerond op +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=Archiveringsactie afgerond door +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=Archiveringsactie afgerond door +rma_recordsmanagement.association.rma_eventExecutions.title=Gebeurtenisuitvoeringen +rma_recordsmanagement.association.rma_eventExecutions.decription=Gebeurtenisuitvoeringen + +rma_recordsmanagement.type.rma_eventExecution.title=Gebeurtenisuitvoering +rma_recordsmanagement.type.rma_eventExecution.decription=Gebeurtenisuitvoering +rma_recordsmanagement.property.rma_eventExecutionName.title=Gebeurtenisnaam +rma_recordsmanagement.property.rma_eventExecutionName.decription=Gebeurtenisnaam +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=Gebeurtenis automatisch +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=Gebeurtenis automatisch +rma_recordsmanagement.property.rma_eventExecutionComplete.title=Gebeurtenis afgerond +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=Gebeurtenis afgerond +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=Gebeurtenis afgerond door +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=Gebeurtenis afgerond door +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=Gebeurtenis afgerond op +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=Gebeurtenis afgerond op + +rma_recordsmanagement.type.rma_hold.title=Wachtstand +rma_recordsmanagement.type.rma_hold.decription=Wachtstand +rma_recordsmanagement.property.rma_holdReason.title=Reden van wachtstand +rma_recordsmanagement.property.rma_holdReason.decription=Reden van wachtstand +rma_recordsmanagement.association.rma_frozenRecords.title=Records in wachtstand +rma_recordsmanagement.association.rma_frozenRecords.decription=Records in wachtstand + +rma_recordsmanagement.type.rma_transfer.title=Overzetten +rma_recordsmanagement.type.rma_transfer.decription=Overzetten +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=Indicator voor overzettingsoverdracht +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=Indicator voor overzettingsoverdracht +rma_recordsmanagement.property.rma_transferPDFIndicator.title=Indicator PDF overzetten +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=Indicator PDF overzetten +rma_recordsmanagement.property.rma_transferLocation.title=PDF overzetten +rma_recordsmanagement.property.rma_transferLocation.decription=PDF overzetten +rma_recordsmanagement.association.rma_transferred.title=Overgezet +rma_recordsmanagement.association.rma_transferred.decription=Overgezet + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=Onderdeel ordeningsplan +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=Onderdeel ordeningsplan +rma_recordsmanagement.property.rma_rootNodeRef.title=Oorsprongnode +rma_recordsmanagement.property.rma_rootNodeRef.decription=Oorsprongnode + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=Oorsprong Record Management +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=Oorsprong Record Management +rma_recordsmanagement.association.rma_holds.title=Wachtstanden +rma_recordsmanagement.association.rma_holds.decription=Wachtstanden +rma_recordsmanagement.association.rma_transfers.title=Overzettingen +rma_recordsmanagement.association.rma_transfers.decription=Overzettingen + +rma_recordsmanagement.aspect.rma_declaredRecord.title=Afgeronde record +rma_recordsmanagement.aspect.rma_declaredRecord.decription=Afgeronde record +rma_recordsmanagement.property.rma_declaredAt.title=Datum afgerond +rma_recordsmanagement.property.rma_declaredAt.decription=Datum afgerond +rma_recordsmanagement.property.rma_declaredBy.title=Afgerond door +rma_recordsmanagement.property.rma_declaredBy.decription=Afgerond door + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=Identificatie recordonderdeel +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=Identificatie recordonderdeel +rma_recordsmanagement.property.rma_identifier.title=Identificatie +rma_recordsmanagement.property.rma_identifier.decription=Unieke identificatie record +rma_recordsmanagement.property.rma_dbUniquenessId.title=Uniekheid database +rma_recordsmanagement.property.rma_dbUniquenessId.decription=Uniekheid database + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=Definitie vitale record +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=Definitie vitale record + +rma_recordsmanagement.property.rma_reviewPeriod.title=Revisieperiode +rma_recordsmanagement.property.rma_reviewPeriod.decription=Revisieperiode +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=Indicator vitale record +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=Indicator vitale record + +rma_recordsmanagement.aspect.rma_record.title=Record +rma_recordsmanagement.aspect.rma_record.decription=Record +rma_recordsmanagement.property.rma_dateFiled.title=Datum gearchiveerd +rma_recordsmanagement.property.rma_dateFiled.decription=Datum gearchiveerd +rma_recordsmanagement.property.rma_origionalName=Oorspronkelijke naam + +rma_recordsmanagement.aspect.rma_recordMetaData.title=Metagegevens record +rma_recordsmanagement.aspect.rma_recordMetaData.description=Markeraspect voor metagegevens van record + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=Algemene recordgegevens +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=Algemene metagegevens voor alle recordtypes +rma_recordsmanagement.property.rma_location.title=Locatie +rma_recordsmanagement.property.rma_location.decription=Locatie + +rma_recordsmanagement.aspect.rma_vitalRecord.title=Vitale record +rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vitale record +rma_recordsmanagement.property.rma_reviewAsOf.title=Volgende revisie +rma_recordsmanagement.property.rma_reviewAsOf.decription=Volgende revisie +rma_recordsmanagement.property.rma_notificationIssued.title=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record +rma_recordsmanagement.property.rma_notificationIssued.decription=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record + +rma_recordsmanagement.aspect.rma_scheduled.title=Gepland +rma_recordsmanagement.aspect.rma_scheduled.decription=Gepland +rma_recordsmanagement.association.rma_dispositionSchedule.title=Bewaarschema +rma_recordsmanagement.association.rma_dispositionSchedule.decription=Bewaarschema + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=Archiveringscyclus +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=Archiveringscyclus +rma_recordsmanagement.association.rma_nextDispositionAction.title=Volgende archiveringsactie +rma_recordsmanagement.association.rma_nextDispositionAction.decription=Volgende archiveringsactie +rma_recordsmanagement.association.rma_dispositionActionHistory.title=Geschiedenis archiveringsactie +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=Geschiedenis archiveringsactie + +rma_recordsmanagement.aspect.rma_cutOff.title=Afsluiten +rma_recordsmanagement.aspect.rma_cutOff.decription=Afsluiten +rma_recordsmanagement.property.rma_cutOffDate.title=Datum voor afsluiten +rma_recordsmanagement.property.rma_cutOffDate.decription=Datum voor afsluiten + +rma_recordsmanagement.aspect.rma_transferred.title=Overgezet +rma_recordsmanagement.aspect.rma_transferred.decription=Overgezet + +rma_recordsmanagement.aspect.rma_ascended.title=Opgelopen +rma_recordsmanagement.aspect.rma_ascended.decription=Opgelopen + +rma_recordsmanagement.aspect.rma_frozen.title=In wachtstand +rma_recordsmanagement.aspect.rma_frozen.decription=In wachtstand +rma_recordsmanagement.property.rma_frozenAt.title=In wachtstand in +rma_recordsmanagement.property.rma_frozenAt.decription=In wachtstand in +rma_recordsmanagement.property.rma_frozenBy.title=In wachtstand door +rma_recordsmanagement.property.rma_frozenBy.decription=In wachtstand door + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=Oorsprong Caveat-configuratie +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=Oorsprong Caveat-configuratie +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=Caveat-configuratie +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=Caveat-configuratie + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=Oorsprong e-mailconfiguratie +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=Oorsprong e-mailconfiguratie +rma_recordsmanagement.association.rma_emailConfigAssoc.title=E-mailconfiguratie +rma_recordsmanagement.association.rma_emailConfigAssoc.description=E-mailconfiguratie + +rma_recordsmanagement.aspect.rma_recordSearch.title=Record zoeken +rma_recordsmanagement.aspect.rma_recordSearch.decription=Toegevoegde zoekinformatie ter ondersteuning van Record Management-zoekopdracht +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=Heeft bewaarschema +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=Geeft aan of er een bewaarschema aan het onderdeel is gekoppeld +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=Naam archiveringsactie +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=De naam van de volgende archiveringsactie +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=Archiveringsactie van +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=De datum waarop de volgende archiveringsactie in aanmerking komt +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=Archiveringstermijn +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=Archiveringstermijn +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=Uitdrukking van archiveringstermijn +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=Uitdrukking van archiveringstermijn +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=In aanmerking komende archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=In aanmerking komende archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=Archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=Archiveringsgebeurtenissen +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=Archiveringsautoriteit +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=Archiveringsautoriteit +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=Archiveringsinstructies +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=Archiveringsinstructies +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=Reden van wachtstand +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=Reden van wachtstand +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=Revisieperiode vitale record +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=Revisieperiode vitale record +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=Uitdrukking van revisieperiode +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=Uitdrukking van revisieperiode + +rma_recordsmanagement.aspect.rma_versionedRecord.title=Record met versiebeheer +rma_recordsmanagement.aspect.rma_versionedRecord.decription=Record met versiebeheer + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=Ongepubliceerde update +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=Ongepubliceerde update +rma_recordsmanagement.property.rma_unpublishedUpdate.title=Ongepubliceerde update +rma_recordsmanagement.property.rma_unpublishedUpdate.description=Geeft aan of er een ongepubliceerde update is +rma_recordsmanagement.property.rma_updateTo.title=Bijwerken naar +rma_recordsmanagement.property.rma_updateTo.description=Bestemming van de update +rma_recordsmanagement.property.rma_updatedProperties.title=Bijgewerkte eigenschappen +rma_recordsmanagement.property.rma_updatedProperties.description=De bijgewerkte eigenschappen +rma_recordsmanagement.property.rma_publishInProgress.title=Publicatie bezig +rma_recordsmanagement.property.rma_publishInProgress.description=Geeft aan of er momenteel een publicatie wordt uitgevoerd + +rma_recordsmanagement.aspect.dod_ghosted.title=Record met alleen metadata +rma_recordsmanagement.aspect.dod_ghosted.description=Record met alleen metadata + +listconstraint.rmc_tlList.title=Overzetlocaties listconstraint.rmc_smList.title=Aanvullende markeringen \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties index d79232317c..d036c0f257 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties @@ -1,265 +1,265 @@ -rma_recordsmanagement.description=\u8bb0\u5f55\u7ba1\u7406\u5185\u5bb9\u6a21\u578b - -rma_recordsmanagement.type.rma_rmsite.title=\u8bb0\u5f55\u7ba1\u7406\u7ad9\u70b9 -rma_recordsmanagement.type.rma_rmsite.description=\u8bb0\u5f55\u7ba1\u7406\u4e13\u7528\u7ad9\u70b9 - -rma_recordsmanagement.type.rma_caveatConfig.title=\u8b66\u544a\u914d\u7f6e -rma_recordsmanagement.type.rma_caveatConfig.decription=\u8b66\u544a\u914d\u7f6e - -rma_recordsmanagement.type.rma_emailConfig.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e -rma_recordsmanagement.type.rma_emailConfig.decription=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e - -rma_recordsmanagement.type.rma_recordsManagementContainer.title=\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668 -rma_recordsmanagement.type.rma_recordsManagementContainer.decription=\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668 - -rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=\u8bb0\u5f55\u7ba1\u7406\u6839\u5bb9\u5668 -rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=\u8bb0\u5f55\u7ba1\u7406\u6839\u5bb9\u5668 - -rma_recordsmanagement.type.rma_dispositionSchedule.title=\u5904\u7f6e\u8ba1\u5212 -rma_recordsmanagement.type.rma_dispositionSchedule.decription=\u5904\u7f6e\u8ba1\u5212 - -rma_recordsmanagement.property.rma_dispositionAuthority.title=\u5904\u7f6e\u5f53\u5c40 -rma_recordsmanagement.property.rma_dispositionAuthority.decription=\u5904\u7f6e\u5f53\u5c40 - -rma_recordsmanagement.property.rma_dispositionInstructions.title=\u5904\u7f6e\u8bf4\u660e -rma_recordsmanagement.property.rma_dispositionInstructions.decription=\u5904\u7f6e\u8bf4\u660e - -rma_recordsmanagement.property.rma_recordLevelDisposition.title=\u8bb0\u5f55\u7ea7\u522b\u5904\u7f6e -rma_recordsmanagement.property.rma_recordLevelDisposition.decription=\u8bb0\u5f55\u7ea7\u522b\u5904\u7f6e - -rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=\u5904\u7f6e\u64cd\u4f5c - -rma_recordsmanagement.type.rma_dispositionActionDefinition.title=\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49 -rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49 -rma_recordsmanagement.property.rma_dispositionActionName.title=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 -rma_recordsmanagement.property.rma_dispositionActionName.decription=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 -rma_recordsmanagement.property.rma_dispositionDescription.title=\u5904\u7f6e\u8bf4\u660e -rma_recordsmanagement.property.rma_dispositionDescription.decription=\u5904\u7f6e\u8bf4\u660e -rma_recordsmanagement.property.rma_dispositionLocation.title=\u5904\u7f6e\u4f4d\u7f6e -rma_recordsmanagement.property.rma_dispositionLocation.decription=\u5904\u7f6e\u4f4d\u7f6e -rma_recordsmanagement.property.rma_dispositionPeriod.title=\u5904\u7f6e\u671f\u95f4 -rma_recordsmanagement.property.rma_dispositionPeriod.decription=\u5904\u7f6e\u671f\u95f4 -rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=\u5904\u7f6e\u671f\u95f4\u5c5e\u6027 -rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=\u5904\u7f6e\u671f\u95f4\u5c5e\u6027 -rma_recordsmanagement.property.rma_dispositionEvent.title=\u5904\u7f6e\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_dispositionEvent.decription=\u5904\u7f6e\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_dispositionEventCombination.title=\u5904\u7f6e\u4e8b\u4ef6\u7ec4\u5408 -rma_recordsmanagement.property.rma_dispositionEventCombination.decription=\u5904\u7f6e\u4e8b\u4ef6\u7ec4\u5408 - -rma_recordsmanagement.type.rma_recordFolder.title=\u8bb0\u5f55\u6587\u4ef6\u5939 -rma_recordsmanagement.type.rma_recordFolder.decription=\u8bb0\u5f55\u6587\u4ef6\u5939 -rma_recordsmanagement.property.rma_isClosed.title=\u8bb0\u5f55 -rma_recordsmanagement.property.rma_isClosed.decription=\u8bb0\u5f55 - -rma_recordsmanagement.type.rma_recordCategory.title=\u8bb0\u5f55\u7c7b\u522b -rma_recordsmanagement.type.rma_recordCategory.decription=\u8bb0\u5f55\u7c7b\u522b - -rma_recordsmanagement.type.rma_nonElectronicDocument.title=\u975e\u7535\u5b50\u6587\u6863 -rma_recordsmanagement.type.rma_nonElectronicDocument.decription=\u975e\u7535\u5b50\u6587\u6863 -rma_recordsmanagement.property.rma_physicalSize.title=\u7269\u7406\u5c3a\u5bf8 -rma_recordsmanagement.property.rma_physicalSize.decription=\u7ebf\u6027\u4eea\u8868\u6d4b\u91cf\u7684\u6587\u6863\u5c3a\u5bf8\u3002 -rma_recordsmanagement.property.rma_numberOfCopies.title=\u526f\u672c\u6570\u76ee -rma_recordsmanagement.property.rma_numberOfCopies.description=\u6587\u6863\u526f\u672c\u6570\u76ee\u3002 -rma_recordsmanagement.property.rma_storageLocation.title=\u5b58\u50a8\u4f4d\u7f6e -rma_recordsmanagement.property.rma_storageLocation.decription=\u8bb0\u5f55\u7684\u7269\u7406\u5b58\u50a8\u4f4d\u7f6e\u3002 -rma_recordsmanagement.property.rma_shelf.title=\u6258\u67b6 -rma_recordsmanagement.property.rma_shelf.decription=\u8bb0\u5f55\u9a7b\u7559\u7684\u6258\u67b6\u3002 -rma_recordsmanagement.property.rma_box.title=\u7bb1 -rma_recordsmanagement.property.rma_box.description=\u8bb0\u5f55\u9a7b\u7559\u7684\u7bb1\u3002 -rma_recordsmanagement.property.rma_file.title=\u6587\u4ef6 -rma_recordsmanagement.property.rma_file.decription=\u8bb0\u5f55\u9a7b\u7559\u7684\u6587\u4ef6\u3002 - -rma_recordsmanagement.type.rma_dispositionAction.title=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.type.rma_dispositionAction.decription=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.property.rma_dispositionActionId.title=\u5904\u7f6e\u64cd\u4f5c ID -rma_recordsmanagement.property.rma_dispositionActionId.decription=\u5904\u7f6e\u64cd\u4f5c ID -rma_recordsmanagement.property.rma_dispositionAction.title=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.property.rma_dispositionAction.decription=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.property.rma_dispositionAsOf.title=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.property.rma_dispositionAsOf.decription=\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 -rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 -rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u65f6\u95f4 -rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u65f6\u95f4 -rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u8005 -rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u8005 -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u65f6\u95f4 -rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u65f6\u95f4 -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u8005 -rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u8005 -rma_recordsmanagement.association.rma_eventExecutions.title=\u4e8b\u4ef6\u6267\u884c -rma_recordsmanagement.association.rma_eventExecutions.decription=\u4e8b\u4ef6\u6267\u884c - -rma_recordsmanagement.type.rma_eventExecution.title=\u4e8b\u4ef6\u6267\u884c -rma_recordsmanagement.type.rma_eventExecution.decription=\u4e8b\u4ef6\u6267\u884c -rma_recordsmanagement.property.rma_eventExecutionName.title=\u4e8b\u4ef6\u540d\u79f0 -rma_recordsmanagement.property.rma_eventExecutionName.decription=\u4e8b\u4ef6\u540d\u79f0 -rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u81ea\u52a8\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u81ea\u52a8\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u4e8b\u4ef6\u5b8c\u6210 -rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u4e8b\u4ef6\u5b8c\u6210 -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u4e8b\u4ef6\u5b8c\u6210\u8005 -rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u4e8b\u4ef6\u5b8c\u6210\u8005 -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u4e8b\u4ef6\u5b8c\u6210\u65f6\u95f4 -rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u4e8b\u4ef6\u5b8c\u6210\u65f6\u95f4 - -rma_recordsmanagement.type.rma_hold.title=\u4fdd\u5b58 -rma_recordsmanagement.type.rma_hold.decription=\u4fdd\u5b58 -rma_recordsmanagement.property.rma_holdReason.title=\u4fdd\u5b58\u539f\u56e0 -rma_recordsmanagement.property.rma_holdReason.decription=\u4fdd\u5b58\u539f\u56e0 -rma_recordsmanagement.association.rma_frozenRecords.title=\u4fdd\u5b58\u8bb0\u5f55 -rma_recordsmanagement.association.rma_frozenRecords.decription=\u4fdd\u5b58\u8bb0\u5f55 - -rma_recordsmanagement.type.rma_transfer.title=\u79fb\u4ea4 -rma_recordsmanagement.type.rma_transfer.decription=\u79fb\u4ea4 -rma_recordsmanagement.property.rma_transferAccessionIndicator.title=\u79fb\u4ea4\u5165\u7ba1\u6307\u793a\u7b26 -rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=\u79fb\u4ea4\u5165\u7ba1\u6307\u793a\u7b26 -rma_recordsmanagement.property.rma_transferPDFIndicator.title=\u79fb\u4ea4 PDF \u6307\u793a\u7b26 -rma_recordsmanagement.property.rma_transferPDFIndicator.decription=\u79fb\u4ea4 PDF \u6307\u793a\u7b26 -rma_recordsmanagement.property.rma_transferLocation.title=\u79fb\u4ea4 PDF -rma_recordsmanagement.property.rma_transferLocation.decription=\u79fb\u4ea4 PDF -rma_recordsmanagement.association.rma_transferred.title=\u5df2\u79fb\u4ea4 -rma_recordsmanagement.association.rma_transferred.decription=\u5df2\u79fb\u4ea4 - -rma_recordsmanagement.aspect.rma_filePlanComponent.title=\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6 -rma_recordsmanagement.aspect.rma_filePlanComponent.decription=\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6 -rma_recordsmanagement.property.rma_rootNodeRef.title=\u6839\u8282\u70b9 -rma_recordsmanagement.property.rma_rootNodeRef.decription=\u6839\u8282\u70b9 - -rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=\u8bb0\u5f55\u7ba1\u7406\u6839 -rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=\u8bb0\u5f55\u7ba1\u7406\u6839 -rma_recordsmanagement.association.rma_holds.title=\u4fdd\u5b58 -rma_recordsmanagement.association.rma_holds.decription=\u4fdd\u5b58 -rma_recordsmanagement.association.rma_transfers.title=\u79fb\u4ea4 -rma_recordsmanagement.association.rma_transfers.decription=\u79fb\u4ea4 - -rma_recordsmanagement.aspect.rma_declaredRecord.title=\u5b8c\u6210\u7684\u8bb0\u5f55 -rma_recordsmanagement.aspect.rma_declaredRecord.decription=\u5b8c\u6210\u7684\u8bb0\u5f55 -rma_recordsmanagement.property.rma_declaredAt.title=\u5b8c\u6210\u65e5\u671f -rma_recordsmanagement.property.rma_declaredAt.decription=\u5b8c\u6210\u65e5\u671f -rma_recordsmanagement.property.rma_declaredBy.title=\u5b8c\u6210\u8005 -rma_recordsmanagement.property.rma_declaredBy.decription=\u5b8c\u6210\u8005 - -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=\u8bb0\u5f55\u7ec4\u4ef6\u6807\u8bc6\u7b26 -rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=\u8bb0\u5f55\u7ec4\u4ef6\u6807\u8bc6\u7b26 -rma_recordsmanagement.property.rma_identifier.title=\u6807\u8bc6\u7b26 -rma_recordsmanagement.property.rma_identifier.decription=\u552f\u4e00\u8bb0\u5f55\u6807\u8bc6\u7b26 -rma_recordsmanagement.property.rma_dbUniquenessId.title=\u6570\u636e\u5e93\u552f\u4e00\u6027 -rma_recordsmanagement.property.rma_dbUniquenessId.decription=\u6570\u636e\u5e93\u552f\u4e00\u6027 - -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 -rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 - -rma_recordsmanagement.property.rma_reviewPeriod.title=\u5ba1\u67e5\u671f\u95f4 -rma_recordsmanagement.property.rma_reviewPeriod.decription=\u5ba1\u67e5\u671f\u95f4 -rma_recordsmanagement.property.rma_vitalRecordIndicator.title=\u6838\u5fc3\u8bb0\u5f55\u6307\u793a\u7b26 -rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=\u6838\u5fc3\u8bb0\u5f55\u6307\u793a\u7b26 - -rma_recordsmanagement.aspect.rma_record.title=\u8bb0\u5f55 -rma_recordsmanagement.aspect.rma_record.decription=\u8bb0\u5f55 -rma_recordsmanagement.property.rma_dateFiled.title=\u7acb\u5377\u65e5\u671f -rma_recordsmanagement.property.rma_dateFiled.decription=\u7acb\u5377\u65e5\u671f -rma_recordsmanagement.property.rma_origionalName=\u539f\u59cb\u540d\u79f0 - -rma_recordsmanagement.aspect.rma_recordMetaData.title=\u8bb0\u5f55\u5143\u6570\u636e -rma_recordsmanagement.aspect.rma_recordMetaData.description=\u8bb0\u5f55\u5143\u6570\u636e\u6807\u8bb0\u5207\u9762 - -rma_recordsmanagement.aspect.rma_commonRecordDetails.title=\u5e38\u89c1\u8bb0\u5f55\u8be6\u7ec6\u4fe1\u606f -rma_recordsmanagement.aspect.rma_commonRecordDetails.description=\u6240\u6709\u8bb0\u5f55\u7c7b\u578b\u901a\u7528\u5143\u6570\u636e -rma_recordsmanagement.property.rma_location.title=\u4f4d\u7f6e -rma_recordsmanagement.property.rma_location.decription=\u4f4d\u7f6e - -rma_recordsmanagement.aspect.rma_vitalRecord.title=\u6838\u5fc3\u8bb0\u5f55 -rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u6838\u5fc3\u8bb0\u5f55 -rma_recordsmanagement.property.rma_reviewAsOf.title=\u4e0b\u4e2a\u5ba1\u67e5 -rma_recordsmanagement.property.rma_reviewAsOf.decription=\u4e0b\u4e2a\u5ba1\u67e5 -rma_recordsmanagement.property.rma_notificationIssued.title=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 -rma_recordsmanagement.property.rma_notificationIssued.decription=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 - -rma_recordsmanagement.aspect.rma_scheduled.title=\u5df2\u8ba1\u5212 -rma_recordsmanagement.aspect.rma_scheduled.decription=\u5df2\u8ba1\u5212 -rma_recordsmanagement.association.rma_dispositionSchedule.title=\u5904\u7f6e\u8ba1\u5212 -rma_recordsmanagement.association.rma_dispositionSchedule.decription=\u5904\u7f6e\u8ba1\u5212 - -rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u5904\u7f6e\u751f\u547d\u5468\u671f -rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u5904\u7f6e\u751f\u547d\u5468\u671f -rma_recordsmanagement.association.rma_nextDispositionAction.title=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c -rma_recordsmanagement.association.rma_dispositionActionHistory.title=\u5904\u7f6e\u64cd\u4f5c\u5386\u53f2\u8bb0\u5f55 -rma_recordsmanagement.association.rma_dispositionActionHistory.decription=\u5904\u7f6e\u64cd\u4f5c\u5386\u53f2\u8bb0\u5f55 - -rma_recordsmanagement.aspect.rma_cutOff.title=\u4e2d\u65ad -rma_recordsmanagement.aspect.rma_cutOff.decription=\u4e2d\u65ad -rma_recordsmanagement.property.rma_cutOffDate.title=\u4e2d\u65ad\u65e5\u671f -rma_recordsmanagement.property.rma_cutOffDate.decription=\u4e2d\u65ad\u65e5\u671f - -rma_recordsmanagement.aspect.rma_transferred.title=\u5df2\u79fb\u4ea4 -rma_recordsmanagement.aspect.rma_transferred.decription=\u5df2\u79fb\u4ea4 - -rma_recordsmanagement.aspect.rma_ascended.title=\u5df2\u4e0a\u5347 -rma_recordsmanagement.aspect.rma_ascended.decription=\u5df2\u4e0a\u5347 - -rma_recordsmanagement.aspect.rma_frozen.title=\u4fdd\u5b58\u4e2d -rma_recordsmanagement.aspect.rma_frozen.decription=\u4fdd\u5b58\u4e2d -rma_recordsmanagement.property.rma_frozenAt.title=\u4fdd\u5b58\u4e8e -rma_recordsmanagement.property.rma_frozenAt.decription=\u4fdd\u5b58\u4e8e -rma_recordsmanagement.property.rma_frozenBy.title=\u4fdd\u5b58\u8005 -rma_recordsmanagement.property.rma_frozenBy.decription=\u4fdd\u5b58\u8005 - -rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=\u8b66\u544a\u914d\u7f6e\u6839 -rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=\u8b66\u544a\u914d\u7f6e\u6839 -rma_recordsmanagement.association.rma_caveatConfigAssoc.title=\u8b66\u544a\u914d\u7f6e -rma_recordsmanagement.association.rma_caveatConfigAssoc.description=\u8b66\u544a\u914d\u7f6e - -rma_recordsmanagement.aspect.rma_emailConfigRoot.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e\u6839 -rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e\u6839 -rma_recordsmanagement.association.rma_emailConfigAssoc.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e -rma_recordsmanagement.association.rma_emailConfigAssoc.description=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e - -rma_recordsmanagement.aspect.rma_recordSearch.title=\u8bb0\u5f55\u641c\u7d22 -rma_recordsmanagement.aspect.rma_recordSearch.decription=\u7d2f\u79ef\u641c\u7d22\u4fe1\u606f\u4ee5\u652f\u6301\u8bb0\u5f55\u7ba1\u7406\u641c\u7d22 -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=\u5177\u6709\u5904\u7f6e\u8ba1\u5212 -rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=\u6307\u793a\u9879\u76ee\u662f\u5426\u6709\u5173\u8054\u7684\u5904\u7f6e\u8ba1\u5212 -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 -rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u7684\u540d\u79f0 -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=\u5904\u7f6e\u64cd\u4f5c\u5c5e\u4e8e -rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u5408\u6cd5\u7684\u65e5\u671f -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=\u5904\u7f6e\u671f\u95f4 -rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=\u5904\u7f6e\u671f\u95f4 -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=\u5904\u7f6e\u671f\u95f4\u8868\u8fbe\u5f0f -rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=\u5904\u7f6e\u671f\u95f4\u8868\u8fbe\u5f0f -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 -rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u5904\u7f6e\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u5904\u7f6e\u4e8b\u4ef6 -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=\u5904\u7f6e\u5f53\u5c40 -rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=\u5904\u7f6e\u5f53\u5c40 -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=\u5904\u7f6e\u8bf4\u660e -rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=\u5904\u7f6e\u8bf4\u660e -rma_recordsmanagement.property.rma_recordSearchHoldReason.title=\u4fdd\u5b58\u539f\u56e0 -rma_recordsmanagement.property.rma_recordSearchHoldReason.description=\u4fdd\u5b58\u539f\u56e0 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u6838\u5fc3\u8bb0\u5f55\u5ba1\u67e5\u671f\u95f4 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u6838\u5fc3\u8bb0\u5f55\u5ba1\u67e5\u671f\u95f4 -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=\u5ba1\u67e5\u671f\u95f4\u8868\u8fbe\u5f0f -rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=\u5ba1\u67e5\u671f\u95f4\u8868\u8fbe\u5f0f - -rma_recordsmanagement.aspect.rma_versionedRecord.title=\u7248\u672c\u5316\u8bb0\u5f55 -rma_recordsmanagement.aspect.rma_versionedRecord.decription=\u7248\u672c\u5316\u8bb0\u5f55 - -rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=\u672a\u53d1\u5e03\u66f4\u65b0 -rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=\u672a\u53d1\u5e03\u66f4\u65b0 -rma_recordsmanagement.property.rma_unpublishedUpdate.title=\u672a\u53d1\u5e03\u66f4\u65b0 -rma_recordsmanagement.property.rma_unpublishedUpdate.description=\u6307\u793a\u662f\u5426\u6709\u672a\u53d1\u5e03\u66f4\u65b0 -rma_recordsmanagement.property.rma_updateTo.title=\u66f4\u65b0\u81f3 -rma_recordsmanagement.property.rma_updateTo.description=\u66f4\u65b0\u76ee\u6807 -rma_recordsmanagement.property.rma_updatedProperties.title=\u66f4\u65b0\u7684\u5c5e\u6027 -rma_recordsmanagement.property.rma_updatedProperties.description=\u66f4\u65b0\u7684\u5c5e\u6027 -rma_recordsmanagement.property.rma_publishInProgress.title=\u53d1\u5e03\u8fdb\u884c\u4e2d -rma_recordsmanagement.property.rma_publishInProgress.description=\u6307\u793a\u53d1\u5e03\u5f53\u524d\u662f\u5426\u5728\u8fdb\u884c\u4e2d - -rma_recordsmanagement.aspect.dod_ghosted.title=\u4ec5\u5143\u6570\u636e\u8bb0\u5f55 -rma_recordsmanagement.aspect.dod_ghosted.description=\u4ec5\u5143\u6570\u636e\u8bb0\u5f55 - -listconstraint.rmc_tlList.title=\u79fb\u4ea4\u4f4d\u7f6e +rma_recordsmanagement.description=\u8bb0\u5f55\u7ba1\u7406\u5185\u5bb9\u6a21\u578b + +rma_recordsmanagement.type.rma_rmsite.title=\u8bb0\u5f55\u7ba1\u7406\u7ad9\u70b9 +rma_recordsmanagement.type.rma_rmsite.description=\u8bb0\u5f55\u7ba1\u7406\u4e13\u7528\u7ad9\u70b9 + +rma_recordsmanagement.type.rma_caveatConfig.title=\u8b66\u544a\u914d\u7f6e +rma_recordsmanagement.type.rma_caveatConfig.decription=\u8b66\u544a\u914d\u7f6e + +rma_recordsmanagement.type.rma_emailConfig.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e +rma_recordsmanagement.type.rma_emailConfig.decription=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e + +rma_recordsmanagement.type.rma_recordsManagementContainer.title=\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668 +rma_recordsmanagement.type.rma_recordsManagementContainer.decription=\u8bb0\u5f55\u7ba1\u7406\u5bb9\u5668 + +rma_recordsmanagement.type.rma_recordsManagementRootContainer.title=\u8bb0\u5f55\u7ba1\u7406\u6839\u5bb9\u5668 +rma_recordsmanagement.type.rma_recordsManagementRootContainer.decription=\u8bb0\u5f55\u7ba1\u7406\u6839\u5bb9\u5668 + +rma_recordsmanagement.type.rma_dispositionSchedule.title=\u5904\u7f6e\u8ba1\u5212 +rma_recordsmanagement.type.rma_dispositionSchedule.decription=\u5904\u7f6e\u8ba1\u5212 + +rma_recordsmanagement.property.rma_dispositionAuthority.title=\u5904\u7f6e\u5f53\u5c40 +rma_recordsmanagement.property.rma_dispositionAuthority.decription=\u5904\u7f6e\u5f53\u5c40 + +rma_recordsmanagement.property.rma_dispositionInstructions.title=\u5904\u7f6e\u8bf4\u660e +rma_recordsmanagement.property.rma_dispositionInstructions.decription=\u5904\u7f6e\u8bf4\u660e + +rma_recordsmanagement.property.rma_recordLevelDisposition.title=\u8bb0\u5f55\u7ea7\u522b\u5904\u7f6e +rma_recordsmanagement.property.rma_recordLevelDisposition.decription=\u8bb0\u5f55\u7ea7\u522b\u5904\u7f6e + +rma_recordsmanagement.association.rma_dispositionActionDefinitions.title=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.association.rma_dispositionActionDefinitions.decription=\u5904\u7f6e\u64cd\u4f5c + +rma_recordsmanagement.type.rma_dispositionActionDefinition.title=\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49 +rma_recordsmanagement.type.rma_dispositionActionDefinition.decription=\u5904\u7f6e\u64cd\u4f5c\u5b9a\u4e49 +rma_recordsmanagement.property.rma_dispositionActionName.title=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 +rma_recordsmanagement.property.rma_dispositionActionName.decription=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 +rma_recordsmanagement.property.rma_dispositionDescription.title=\u5904\u7f6e\u8bf4\u660e +rma_recordsmanagement.property.rma_dispositionDescription.decription=\u5904\u7f6e\u8bf4\u660e +rma_recordsmanagement.property.rma_dispositionLocation.title=\u5904\u7f6e\u4f4d\u7f6e +rma_recordsmanagement.property.rma_dispositionLocation.decription=\u5904\u7f6e\u4f4d\u7f6e +rma_recordsmanagement.property.rma_dispositionPeriod.title=\u5904\u7f6e\u671f\u95f4 +rma_recordsmanagement.property.rma_dispositionPeriod.decription=\u5904\u7f6e\u671f\u95f4 +rma_recordsmanagement.property.rma_dispositionPeriodProperty.title=\u5904\u7f6e\u671f\u95f4\u5c5e\u6027 +rma_recordsmanagement.property.rma_dispositionPeriodProperty.decription=\u5904\u7f6e\u671f\u95f4\u5c5e\u6027 +rma_recordsmanagement.property.rma_dispositionEvent.title=\u5904\u7f6e\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_dispositionEvent.decription=\u5904\u7f6e\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_dispositionEventCombination.title=\u5904\u7f6e\u4e8b\u4ef6\u7ec4\u5408 +rma_recordsmanagement.property.rma_dispositionEventCombination.decription=\u5904\u7f6e\u4e8b\u4ef6\u7ec4\u5408 + +rma_recordsmanagement.type.rma_recordFolder.title=\u8bb0\u5f55\u6587\u4ef6\u5939 +rma_recordsmanagement.type.rma_recordFolder.decription=\u8bb0\u5f55\u6587\u4ef6\u5939 +rma_recordsmanagement.property.rma_isClosed.title=\u8bb0\u5f55 +rma_recordsmanagement.property.rma_isClosed.decription=\u8bb0\u5f55 + +rma_recordsmanagement.type.rma_recordCategory.title=\u8bb0\u5f55\u7c7b\u522b +rma_recordsmanagement.type.rma_recordCategory.decription=\u8bb0\u5f55\u7c7b\u522b + +rma_recordsmanagement.type.rma_nonElectronicDocument.title=\u975e\u7535\u5b50\u6587\u6863 +rma_recordsmanagement.type.rma_nonElectronicDocument.decription=\u975e\u7535\u5b50\u6587\u6863 +rma_recordsmanagement.property.rma_physicalSize.title=\u7269\u7406\u5c3a\u5bf8 +rma_recordsmanagement.property.rma_physicalSize.decription=\u7ebf\u6027\u4eea\u8868\u6d4b\u91cf\u7684\u6587\u6863\u5c3a\u5bf8\u3002 +rma_recordsmanagement.property.rma_numberOfCopies.title=\u526f\u672c\u6570\u76ee +rma_recordsmanagement.property.rma_numberOfCopies.description=\u6587\u6863\u526f\u672c\u6570\u76ee\u3002 +rma_recordsmanagement.property.rma_storageLocation.title=\u5b58\u50a8\u4f4d\u7f6e +rma_recordsmanagement.property.rma_storageLocation.decription=\u8bb0\u5f55\u7684\u7269\u7406\u5b58\u50a8\u4f4d\u7f6e\u3002 +rma_recordsmanagement.property.rma_shelf.title=\u6258\u67b6 +rma_recordsmanagement.property.rma_shelf.decription=\u8bb0\u5f55\u9a7b\u7559\u7684\u6258\u67b6\u3002 +rma_recordsmanagement.property.rma_box.title=\u7bb1 +rma_recordsmanagement.property.rma_box.description=\u8bb0\u5f55\u9a7b\u7559\u7684\u7bb1\u3002 +rma_recordsmanagement.property.rma_file.title=\u6587\u4ef6 +rma_recordsmanagement.property.rma_file.decription=\u8bb0\u5f55\u9a7b\u7559\u7684\u6587\u4ef6\u3002 + +rma_recordsmanagement.type.rma_dispositionAction.title=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.type.rma_dispositionAction.decription=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.property.rma_dispositionActionId.title=\u5904\u7f6e\u64cd\u4f5c ID +rma_recordsmanagement.property.rma_dispositionActionId.decription=\u5904\u7f6e\u64cd\u4f5c ID +rma_recordsmanagement.property.rma_dispositionAction.title=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.property.rma_dispositionAction.decription=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.property.rma_dispositionAsOf.title=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.property.rma_dispositionAsOf.decription=\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.property.rma_dispositionEventsEligible.title=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 +rma_recordsmanagement.property.rma_dispositionEventsEligible.decription=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 +rma_recordsmanagement.property.rma_dispositionActionStartedAt.title=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u65f6\u95f4 +rma_recordsmanagement.property.rma_dispositionActionStartedAt.decription=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u65f6\u95f4 +rma_recordsmanagement.property.rma_dispositionActionStartedBy.title=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u8005 +rma_recordsmanagement.property.rma_dispositionActionStartedBy.decription=\u5904\u7f6e\u64cd\u4f5c\u542f\u52a8\u8005 +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.title=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u65f6\u95f4 +rma_recordsmanagement.property.rma_dispositionActionCompletedAt.decription=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u65f6\u95f4 +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.title=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u8005 +rma_recordsmanagement.property.rma_dispositionActionCompletedBy.decription=\u5904\u7f6e\u64cd\u4f5c\u5b8c\u6210\u8005 +rma_recordsmanagement.association.rma_eventExecutions.title=\u4e8b\u4ef6\u6267\u884c +rma_recordsmanagement.association.rma_eventExecutions.decription=\u4e8b\u4ef6\u6267\u884c + +rma_recordsmanagement.type.rma_eventExecution.title=\u4e8b\u4ef6\u6267\u884c +rma_recordsmanagement.type.rma_eventExecution.decription=\u4e8b\u4ef6\u6267\u884c +rma_recordsmanagement.property.rma_eventExecutionName.title=\u4e8b\u4ef6\u540d\u79f0 +rma_recordsmanagement.property.rma_eventExecutionName.decription=\u4e8b\u4ef6\u540d\u79f0 +rma_recordsmanagement.property.rma_eventExecutionAutomatic.title=\u81ea\u52a8\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_eventExecutionAutomatic.decription=\u81ea\u52a8\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_eventExecutionComplete.title=\u4e8b\u4ef6\u5b8c\u6210 +rma_recordsmanagement.property.rma_eventExecutionComplete.decription=\u4e8b\u4ef6\u5b8c\u6210 +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.title=\u4e8b\u4ef6\u5b8c\u6210\u8005 +rma_recordsmanagement.property.rma_eventExecutionCompletedBy.decription=\u4e8b\u4ef6\u5b8c\u6210\u8005 +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.title=\u4e8b\u4ef6\u5b8c\u6210\u65f6\u95f4 +rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u4e8b\u4ef6\u5b8c\u6210\u65f6\u95f4 + +rma_recordsmanagement.type.rma_hold.title=\u4fdd\u5b58 +rma_recordsmanagement.type.rma_hold.decription=\u4fdd\u5b58 +rma_recordsmanagement.property.rma_holdReason.title=\u4fdd\u5b58\u539f\u56e0 +rma_recordsmanagement.property.rma_holdReason.decription=\u4fdd\u5b58\u539f\u56e0 +rma_recordsmanagement.association.rma_frozenRecords.title=\u4fdd\u5b58\u8bb0\u5f55 +rma_recordsmanagement.association.rma_frozenRecords.decription=\u4fdd\u5b58\u8bb0\u5f55 + +rma_recordsmanagement.type.rma_transfer.title=\u79fb\u4ea4 +rma_recordsmanagement.type.rma_transfer.decription=\u79fb\u4ea4 +rma_recordsmanagement.property.rma_transferAccessionIndicator.title=\u79fb\u4ea4\u5165\u7ba1\u6307\u793a\u7b26 +rma_recordsmanagement.property.rma_transferAccessionIndicator.decription=\u79fb\u4ea4\u5165\u7ba1\u6307\u793a\u7b26 +rma_recordsmanagement.property.rma_transferPDFIndicator.title=\u79fb\u4ea4 PDF \u6307\u793a\u7b26 +rma_recordsmanagement.property.rma_transferPDFIndicator.decription=\u79fb\u4ea4 PDF \u6307\u793a\u7b26 +rma_recordsmanagement.property.rma_transferLocation.title=\u79fb\u4ea4 PDF +rma_recordsmanagement.property.rma_transferLocation.decription=\u79fb\u4ea4 PDF +rma_recordsmanagement.association.rma_transferred.title=\u5df2\u79fb\u4ea4 +rma_recordsmanagement.association.rma_transferred.decription=\u5df2\u79fb\u4ea4 + +rma_recordsmanagement.aspect.rma_filePlanComponent.title=\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6 +rma_recordsmanagement.aspect.rma_filePlanComponent.decription=\u5f52\u7c7b\u65b9\u6848\u7ec4\u4ef6 +rma_recordsmanagement.property.rma_rootNodeRef.title=\u6839\u8282\u70b9 +rma_recordsmanagement.property.rma_rootNodeRef.decription=\u6839\u8282\u70b9 + +rma_recordsmanagement.aspect.rma_recordsManagementRoot.title=\u8bb0\u5f55\u7ba1\u7406\u6839 +rma_recordsmanagement.aspect.rma_recordsManagementRoot.decription=\u8bb0\u5f55\u7ba1\u7406\u6839 +rma_recordsmanagement.association.rma_holds.title=\u4fdd\u5b58 +rma_recordsmanagement.association.rma_holds.decription=\u4fdd\u5b58 +rma_recordsmanagement.association.rma_transfers.title=\u79fb\u4ea4 +rma_recordsmanagement.association.rma_transfers.decription=\u79fb\u4ea4 + +rma_recordsmanagement.aspect.rma_declaredRecord.title=\u5b8c\u6210\u7684\u8bb0\u5f55 +rma_recordsmanagement.aspect.rma_declaredRecord.decription=\u5b8c\u6210\u7684\u8bb0\u5f55 +rma_recordsmanagement.property.rma_declaredAt.title=\u5b8c\u6210\u65e5\u671f +rma_recordsmanagement.property.rma_declaredAt.decription=\u5b8c\u6210\u65e5\u671f +rma_recordsmanagement.property.rma_declaredBy.title=\u5b8c\u6210\u8005 +rma_recordsmanagement.property.rma_declaredBy.decription=\u5b8c\u6210\u8005 + +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.title=\u8bb0\u5f55\u7ec4\u4ef6\u6807\u8bc6\u7b26 +rma_recordsmanagement.aspect.rma_recordComponentIdentifier.decription=\u8bb0\u5f55\u7ec4\u4ef6\u6807\u8bc6\u7b26 +rma_recordsmanagement.property.rma_identifier.title=\u6807\u8bc6\u7b26 +rma_recordsmanagement.property.rma_identifier.decription=\u552f\u4e00\u8bb0\u5f55\u6807\u8bc6\u7b26 +rma_recordsmanagement.property.rma_dbUniquenessId.title=\u6570\u636e\u5e93\u552f\u4e00\u6027 +rma_recordsmanagement.property.rma_dbUniquenessId.decription=\u6570\u636e\u5e93\u552f\u4e00\u6027 + +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.title=\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 +rma_recordsmanagement.aspect.rma_vitalRecordDefinition.decription=\u6838\u5fc3\u8bb0\u5f55\u5b9a\u4e49 + +rma_recordsmanagement.property.rma_reviewPeriod.title=\u5ba1\u67e5\u671f\u95f4 +rma_recordsmanagement.property.rma_reviewPeriod.decription=\u5ba1\u67e5\u671f\u95f4 +rma_recordsmanagement.property.rma_vitalRecordIndicator.title=\u6838\u5fc3\u8bb0\u5f55\u6307\u793a\u7b26 +rma_recordsmanagement.property.rma_vitalRecordIndicator.decription=\u6838\u5fc3\u8bb0\u5f55\u6307\u793a\u7b26 + +rma_recordsmanagement.aspect.rma_record.title=\u8bb0\u5f55 +rma_recordsmanagement.aspect.rma_record.decription=\u8bb0\u5f55 +rma_recordsmanagement.property.rma_dateFiled.title=\u7acb\u5377\u65e5\u671f +rma_recordsmanagement.property.rma_dateFiled.decription=\u7acb\u5377\u65e5\u671f +rma_recordsmanagement.property.rma_origionalName=\u539f\u59cb\u540d\u79f0 + +rma_recordsmanagement.aspect.rma_recordMetaData.title=\u8bb0\u5f55\u5143\u6570\u636e +rma_recordsmanagement.aspect.rma_recordMetaData.description=\u8bb0\u5f55\u5143\u6570\u636e\u6807\u8bb0\u5207\u9762 + +rma_recordsmanagement.aspect.rma_commonRecordDetails.title=\u5e38\u89c1\u8bb0\u5f55\u8be6\u7ec6\u4fe1\u606f +rma_recordsmanagement.aspect.rma_commonRecordDetails.description=\u6240\u6709\u8bb0\u5f55\u7c7b\u578b\u901a\u7528\u5143\u6570\u636e +rma_recordsmanagement.property.rma_location.title=\u4f4d\u7f6e +rma_recordsmanagement.property.rma_location.decription=\u4f4d\u7f6e + +rma_recordsmanagement.aspect.rma_vitalRecord.title=\u6838\u5fc3\u8bb0\u5f55 +rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u6838\u5fc3\u8bb0\u5f55 +rma_recordsmanagement.property.rma_reviewAsOf.title=\u4e0b\u4e2a\u5ba1\u67e5 +rma_recordsmanagement.property.rma_reviewAsOf.decription=\u4e0b\u4e2a\u5ba1\u67e5 +rma_recordsmanagement.property.rma_notificationIssued.title=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 +rma_recordsmanagement.property.rma_notificationIssued.decription=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 + +rma_recordsmanagement.aspect.rma_scheduled.title=\u5df2\u8ba1\u5212 +rma_recordsmanagement.aspect.rma_scheduled.decription=\u5df2\u8ba1\u5212 +rma_recordsmanagement.association.rma_dispositionSchedule.title=\u5904\u7f6e\u8ba1\u5212 +rma_recordsmanagement.association.rma_dispositionSchedule.decription=\u5904\u7f6e\u8ba1\u5212 + +rma_recordsmanagement.aspect.rma_dispositionLifecycle.title=\u5904\u7f6e\u751f\u547d\u5468\u671f +rma_recordsmanagement.aspect.rma_dispositionLifecycle.decription=\u5904\u7f6e\u751f\u547d\u5468\u671f +rma_recordsmanagement.association.rma_nextDispositionAction.title=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.association.rma_nextDispositionAction.decription=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c +rma_recordsmanagement.association.rma_dispositionActionHistory.title=\u5904\u7f6e\u64cd\u4f5c\u5386\u53f2\u8bb0\u5f55 +rma_recordsmanagement.association.rma_dispositionActionHistory.decription=\u5904\u7f6e\u64cd\u4f5c\u5386\u53f2\u8bb0\u5f55 + +rma_recordsmanagement.aspect.rma_cutOff.title=\u4e2d\u65ad +rma_recordsmanagement.aspect.rma_cutOff.decription=\u4e2d\u65ad +rma_recordsmanagement.property.rma_cutOffDate.title=\u4e2d\u65ad\u65e5\u671f +rma_recordsmanagement.property.rma_cutOffDate.decription=\u4e2d\u65ad\u65e5\u671f + +rma_recordsmanagement.aspect.rma_transferred.title=\u5df2\u79fb\u4ea4 +rma_recordsmanagement.aspect.rma_transferred.decription=\u5df2\u79fb\u4ea4 + +rma_recordsmanagement.aspect.rma_ascended.title=\u5df2\u4e0a\u5347 +rma_recordsmanagement.aspect.rma_ascended.decription=\u5df2\u4e0a\u5347 + +rma_recordsmanagement.aspect.rma_frozen.title=\u4fdd\u5b58\u4e2d +rma_recordsmanagement.aspect.rma_frozen.decription=\u4fdd\u5b58\u4e2d +rma_recordsmanagement.property.rma_frozenAt.title=\u4fdd\u5b58\u4e8e +rma_recordsmanagement.property.rma_frozenAt.decription=\u4fdd\u5b58\u4e8e +rma_recordsmanagement.property.rma_frozenBy.title=\u4fdd\u5b58\u8005 +rma_recordsmanagement.property.rma_frozenBy.decription=\u4fdd\u5b58\u8005 + +rma_recordsmanagement.aspect.rma_caveatConfigRoot.title=\u8b66\u544a\u914d\u7f6e\u6839 +rma_recordsmanagement.aspect.rma_caveatConfigRoot.decription=\u8b66\u544a\u914d\u7f6e\u6839 +rma_recordsmanagement.association.rma_caveatConfigAssoc.title=\u8b66\u544a\u914d\u7f6e +rma_recordsmanagement.association.rma_caveatConfigAssoc.description=\u8b66\u544a\u914d\u7f6e + +rma_recordsmanagement.aspect.rma_emailConfigRoot.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e\u6839 +rma_recordsmanagement.aspect.rma_emailConfigRoot.decription=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e\u6839 +rma_recordsmanagement.association.rma_emailConfigAssoc.title=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e +rma_recordsmanagement.association.rma_emailConfigAssoc.description=\u7535\u5b50\u90ae\u4ef6\u914d\u7f6e + +rma_recordsmanagement.aspect.rma_recordSearch.title=\u8bb0\u5f55\u641c\u7d22 +rma_recordsmanagement.aspect.rma_recordSearch.decription=\u7d2f\u79ef\u641c\u7d22\u4fe1\u606f\u4ee5\u652f\u6301\u8bb0\u5f55\u7ba1\u7406\u641c\u7d22 +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.title=\u5177\u6709\u5904\u7f6e\u8ba1\u5212 +rma_recordsmanagement.property.rma_recordSearchHasDispositionSchedule.description=\u6307\u793a\u9879\u76ee\u662f\u5426\u6709\u5173\u8054\u7684\u5904\u7f6e\u8ba1\u5212 +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.title=\u5904\u7f6e\u64cd\u4f5c\u540d\u79f0 +rma_recordsmanagement.property.rma_recordSearchDispositionActionName.description=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u7684\u540d\u79f0 +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.title=\u5904\u7f6e\u64cd\u4f5c\u5c5e\u4e8e +rma_recordsmanagement.property.rma_recordSearchDispositionActionAsOf.description=\u4e0b\u4e2a\u5904\u7f6e\u64cd\u4f5c\u5408\u6cd5\u7684\u65e5\u671f +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.title=\u5904\u7f6e\u671f\u95f4 +rma_recordsmanagement.property.rma_recordSearchDispositionPeriod.description=\u5904\u7f6e\u671f\u95f4 +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.title=\u5904\u7f6e\u671f\u95f4\u8868\u8fbe\u5f0f +rma_recordsmanagement.property.rma_recordSearchDispositionPeriodExpression.description=\u5904\u7f6e\u671f\u95f4\u8868\u8fbe\u5f0f +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.title=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 +rma_recordsmanagement.property.rma_recordSearchDispositionEventsEligible.description=\u5904\u7f6e\u4e8b\u4ef6\u5408\u6cd5 +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.title=\u5904\u7f6e\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_recordSearchDispositionEvents.description=\u5904\u7f6e\u4e8b\u4ef6 +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.title=\u5904\u7f6e\u5f53\u5c40 +rma_recordsmanagement.property.rma_recordSearchDispositionAuthority.description=\u5904\u7f6e\u5f53\u5c40 +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.title=\u5904\u7f6e\u8bf4\u660e +rma_recordsmanagement.property.rma_recordSearchDispositionInstructions.description=\u5904\u7f6e\u8bf4\u660e +rma_recordsmanagement.property.rma_recordSearchHoldReason.title=\u4fdd\u5b58\u539f\u56e0 +rma_recordsmanagement.property.rma_recordSearchHoldReason.description=\u4fdd\u5b58\u539f\u56e0 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.title=\u6838\u5fc3\u8bb0\u5f55\u5ba1\u67e5\u671f\u95f4 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriod.description=\u6838\u5fc3\u8bb0\u5f55\u5ba1\u67e5\u671f\u95f4 +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.title=\u5ba1\u67e5\u671f\u95f4\u8868\u8fbe\u5f0f +rma_recordsmanagement.property.rma_recordSearchVitalRecordReviewPeriodExpression.description=\u5ba1\u67e5\u671f\u95f4\u8868\u8fbe\u5f0f + +rma_recordsmanagement.aspect.rma_versionedRecord.title=\u7248\u672c\u5316\u8bb0\u5f55 +rma_recordsmanagement.aspect.rma_versionedRecord.decription=\u7248\u672c\u5316\u8bb0\u5f55 + +rma_recordsmanagement.aspect.rma_unpublishedUpdate.title=\u672a\u53d1\u5e03\u66f4\u65b0 +rma_recordsmanagement.aspect.rma_unpublishedUpdate.decription=\u672a\u53d1\u5e03\u66f4\u65b0 +rma_recordsmanagement.property.rma_unpublishedUpdate.title=\u672a\u53d1\u5e03\u66f4\u65b0 +rma_recordsmanagement.property.rma_unpublishedUpdate.description=\u6307\u793a\u662f\u5426\u6709\u672a\u53d1\u5e03\u66f4\u65b0 +rma_recordsmanagement.property.rma_updateTo.title=\u66f4\u65b0\u81f3 +rma_recordsmanagement.property.rma_updateTo.description=\u66f4\u65b0\u76ee\u6807 +rma_recordsmanagement.property.rma_updatedProperties.title=\u66f4\u65b0\u7684\u5c5e\u6027 +rma_recordsmanagement.property.rma_updatedProperties.description=\u66f4\u65b0\u7684\u5c5e\u6027 +rma_recordsmanagement.property.rma_publishInProgress.title=\u53d1\u5e03\u8fdb\u884c\u4e2d +rma_recordsmanagement.property.rma_publishInProgress.description=\u6307\u793a\u53d1\u5e03\u5f53\u524d\u662f\u5426\u5728\u8fdb\u884c\u4e2d + +rma_recordsmanagement.aspect.dod_ghosted.title=\u4ec5\u5143\u6570\u636e\u8bb0\u5f55 +rma_recordsmanagement.aspect.dod_ghosted.description=\u4ec5\u5143\u6570\u636e\u8bb0\u5f55 + +listconstraint.rmc_tlList.title=\u79fb\u4ea4\u4f4d\u7f6e listconstraint.rmc_smList.title=\u8865\u5145\u6807\u8bb0 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model.properties index 0d85d92411..a3bfabf5b8 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Records Management Report Content Model - -rmr_recordsmanagementreport.type.rmr_report.title=Report -rmr_recordsmanagementreport.type.rmr_report.description=Records management report. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Transfer Report -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records management transfer report. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Destruction Report -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records management destruction report. - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Hold Report +rmr_recordsmanagementreport.description=Records Management Report Content Model + +rmr_recordsmanagementreport.type.rmr_report.title=Report +rmr_recordsmanagementreport.type.rmr_report.description=Records management report. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Transfer Report +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records management transfer report. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Destruction Report +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records management destruction report. + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Hold Report rmr_recordsmanagementreport.type.rmr_holdReport.description=Records management hold report. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_de.properties index 08a676b63d..61b0d6ccae 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_de.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Content Model f\u00fcr Records Management Bericht - -rmr_recordsmanagementreport.type.rmr_report.title=Bericht -rmr_recordsmanagementreport.type.rmr_report.description=Records Management Bericht. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u00dcbertragungsbericht -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records Management \u00dcbertragungsbericht. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Vernichtungsprotokoll -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records Management Vernichtungsprotokoll. - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Sperrbericht +rmr_recordsmanagementreport.description=Content Model f\u00fcr Records Management Bericht + +rmr_recordsmanagementreport.type.rmr_report.title=Bericht +rmr_recordsmanagementreport.type.rmr_report.description=Records Management Bericht. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u00dcbertragungsbericht +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records Management \u00dcbertragungsbericht. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Vernichtungsprotokoll +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Records Management Vernichtungsprotokoll. + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Sperrbericht rmr_recordsmanagementreport.type.rmr_holdReport.description=Records Management Sperrbericht. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_es.properties index 6e02d50569..108187e91c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_es.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Modelo de contenido de informe de gesti\u00f3n de documentos de archivo - -rmr_recordsmanagementreport.type.rmr_report.title=Informe -rmr_recordsmanagementreport.type.rmr_report.description=Informe de gesti\u00f3n de documentos de archivo - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Informe de transferencia -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Informe de transferencia de gesti\u00f3n de documentos de archivo - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Informe de destrucci\u00f3n -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Informe de destrucci\u00f3n de gesti\u00f3n de documentos de archivo - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Informe de bloqueo +rmr_recordsmanagementreport.description=Modelo de contenido de informe de gesti\u00f3n de documentos de archivo + +rmr_recordsmanagementreport.type.rmr_report.title=Informe +rmr_recordsmanagementreport.type.rmr_report.description=Informe de gesti\u00f3n de documentos de archivo + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Informe de transferencia +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Informe de transferencia de gesti\u00f3n de documentos de archivo + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Informe de destrucci\u00f3n +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Informe de destrucci\u00f3n de gesti\u00f3n de documentos de archivo + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Informe de bloqueo rmr_recordsmanagementreport.type.rmr_holdReport.description=Informe de bloqueo de gesti\u00f3n de documentos de archivo \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_fr.properties index 48b8fd2f7b..0757d6e734 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_fr.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Mod\u00e8le de contenu de rapport de gestion des archives - -rmr_recordsmanagementreport.type.rmr_report.title=Rapport -rmr_recordsmanagementreport.type.rmr_report.description=Rapport de gestion des archives - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Rapport de transfert -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Rapport de transfert de gestion des archives. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Rapport de destruction -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Rapport de destruction de gestion des archives. - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Rapport de suspension +rmr_recordsmanagementreport.description=Mod\u00e8le de contenu de rapport de gestion des archives + +rmr_recordsmanagementreport.type.rmr_report.title=Rapport +rmr_recordsmanagementreport.type.rmr_report.description=Rapport de gestion des archives + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Rapport de transfert +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Rapport de transfert de gestion des archives. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Rapport de destruction +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Rapport de destruction de gestion des archives. + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Rapport de suspension rmr_recordsmanagementreport.type.rmr_holdReport.description=Rapport de suspension de gestion des archives. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_it.properties index 364b6e3c9a..9c2bcab148 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_it.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Modello dei contenuti del report di gestione dei record - -rmr_recordsmanagementreport.type.rmr_report.title=Report -rmr_recordsmanagementreport.type.rmr_report.description=Report di gestione dei record. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Report di trasferimento -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Report di trasferimento della gestione dei record. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Report di eliminazione permanente -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Report di eliminazione permanente della gestione dei record. - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Report di sospensione +rmr_recordsmanagementreport.description=Modello dei contenuti del report di gestione dei record + +rmr_recordsmanagementreport.type.rmr_report.title=Report +rmr_recordsmanagementreport.type.rmr_report.description=Report di gestione dei record. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Report di trasferimento +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Report di trasferimento della gestione dei record. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Report di eliminazione permanente +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Report di eliminazione permanente della gestione dei record. + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Report di sospensione rmr_recordsmanagementreport.type.rmr_holdReport.description=Report di sospensione della gestione dei record. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_ja.properties index 24192e0bbc..574e45c3c5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_ja.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30ec\u30dd\u30fc\u30c8\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb - -rmr_recordsmanagementreport.type.rmr_report.title=\u30ec\u30dd\u30fc\u30c8 -rmr_recordsmanagementreport.type.rmr_report.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30ec\u30dd\u30fc\u30c8\u3002 - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8 -rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8\u3002 - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8 -rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u3002 - -rmr_recordsmanagementreport.type.rmr_holdReport.title=\u30db\u30fc\u30eb\u30c9\u30ec\u30dd\u30fc\u30c8 +rmr_recordsmanagementreport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30ec\u30dd\u30fc\u30c8\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb + +rmr_recordsmanagementreport.type.rmr_report.title=\u30ec\u30dd\u30fc\u30c8 +rmr_recordsmanagementreport.type.rmr_report.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30ec\u30dd\u30fc\u30c8\u3002 + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8 +rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u8ee2\u9001\u30ec\u30dd\u30fc\u30c8\u3002 + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u7834\u68c4\u30ec\u30dd\u30fc\u30c8 +rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u7834\u68c4\u30ec\u30dd\u30fc\u30c8\u3002 + +rmr_recordsmanagementreport.type.rmr_holdReport.title=\u30db\u30fc\u30eb\u30c9\u30ec\u30dd\u30fc\u30c8 rmr_recordsmanagementreport.type.rmr_holdReport.description=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u30db\u30fc\u30eb\u30c9\u30ec\u30dd\u30fc\u30c8 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_nl.properties index a7fb8e31f1..b87b309b2b 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_nl.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=Contentmodel Record Management-rapport - -rmr_recordsmanagementreport.type.rmr_report.title=Rapport -rmr_recordsmanagementreport.type.rmr_report.description=Record Management-rapport. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Overzetrapport -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Slaat beheeroverzetrapport op. - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=Vernietigingsrapport -rmr_recordsmanagementreport.type.rmr_destructionReport.description=Slaat vernietigingsrapport op. - -rmr_recordsmanagementreport.type.rmr_holdReport.title=Rapport wachtstand +rmr_recordsmanagementreport.description=Contentmodel Record Management-rapport + +rmr_recordsmanagementreport.type.rmr_report.title=Rapport +rmr_recordsmanagementreport.type.rmr_report.description=Record Management-rapport. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Overzetrapport +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Slaat beheeroverzetrapport op. + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=Vernietigingsrapport +rmr_recordsmanagementreport.type.rmr_destructionReport.description=Slaat vernietigingsrapport op. + +rmr_recordsmanagementreport.type.rmr_holdReport.title=Rapport wachtstand rmr_recordsmanagementreport.type.rmr_holdReport.description=Slaat beheerwachtstandrapport op. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_zh_CN.properties index 5316a9e599..5e241bfe3a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/report-model_zh_CN.properties @@ -1,13 +1,13 @@ -rmr_recordsmanagementreport.description=\u8bb0\u5f55\u7ba1\u7406\u62a5\u544a\u5185\u5bb9\u6a21\u578b - -rmr_recordsmanagementreport.type.rmr_report.title=\u62a5\u544a -rmr_recordsmanagementreport.type.rmr_report.description=\u8bb0\u5f55\u7ba1\u7406\u62a5\u544a\u3002 - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u79fb\u4ea4\u62a5\u544a -rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u8bb0\u5f55\u7ba1\u7406\u79fb\u4ea4\u62a5\u544a\u3002 - -rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u9500\u6bc1\u62a5\u544a -rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u8bb0\u5f55\u7ba1\u7406\u9500\u6bc1\u62a5\u544a\u3002 - -rmr_recordsmanagementreport.type.rmr_holdReport.title=\u4fdd\u5b58\u62a5\u544a +rmr_recordsmanagementreport.description=\u8bb0\u5f55\u7ba1\u7406\u62a5\u544a\u5185\u5bb9\u6a21\u578b + +rmr_recordsmanagementreport.type.rmr_report.title=\u62a5\u544a +rmr_recordsmanagementreport.type.rmr_report.description=\u8bb0\u5f55\u7ba1\u7406\u62a5\u544a\u3002 + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u79fb\u4ea4\u62a5\u544a +rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u8bb0\u5f55\u7ba1\u7406\u79fb\u4ea4\u62a5\u544a\u3002 + +rmr_recordsmanagementreport.type.rmr_destructionReport.title=\u9500\u6bc1\u62a5\u544a +rmr_recordsmanagementreport.type.rmr_destructionReport.description=\u8bb0\u5f55\u7ba1\u7406\u9500\u6bc1\u62a5\u544a\u3002 + +rmr_recordsmanagementreport.type.rmr_holdReport.title=\u4fdd\u5b58\u62a5\u544a rmr_recordsmanagementreport.type.rmr_holdReport.description=\u8bb0\u5f55\u7ba1\u7406\u4fdd\u5b58\u62a5\u544a\u3002 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions.properties index 67f52edda9..4be6af65f4 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=Cut Off -cutoff.description=Cut Off -retain.title=Retain -retain.description=Retain -destroy.title=Destroy -destroy.description=Destroy - +# Disposition Actions +cutoff.title=Cut Off +cutoff.description=Cut Off +retain.title=Retain +retain.description=Retain +destroy.title=Destroy +destroy.description=Destroy + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_de.properties index 8a14b15b9d..66f62cdbaf 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_de.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=Trennen -cutoff.description=Trennen -retain.title=Aufbewahren -retain.description=Aufbewahren -destroy.title=Vernichten -destroy.description=Vernichten - +# Disposition Actions +cutoff.title=Trennen +cutoff.description=Trennen +retain.title=Aufbewahren +retain.description=Aufbewahren +destroy.title=Vernichten +destroy.description=Vernichten + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_es.properties index a5601d3c2e..c5235284ff 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_es.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=Interrumpir -cutoff.description=Interrumpir -retain.title=Retener -retain.description=Retener -destroy.title=Destruir -destroy.description=Destruir - +# Disposition Actions +cutoff.title=Interrumpir +cutoff.description=Interrumpir +retain.title=Retener +retain.description=Retener +destroy.title=Destruir +destroy.description=Destruir + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_fr.properties index c07c4423ae..fc9e6f998a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_fr.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=D\u00e9classer -cutoff.description=D\u00e9classer -retain.title=Retenir -retain.description=Retenir -destroy.title=D\u00e9truire -destroy.description=D\u00e9truire - +# Disposition Actions +cutoff.title=D\u00e9classer +cutoff.description=D\u00e9classer +retain.title=Retenir +retain.description=Retenir +destroy.title=D\u00e9truire +destroy.description=D\u00e9truire + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_it.properties index 88cb708677..554de833f5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_it.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=Cut off -cutoff.description=Cut off -retain.title=Mantieni -retain.description=Mantieni -destroy.title=Elimina definitivamente -destroy.description=Elimina definitivamente - +# Disposition Actions +cutoff.title=Cut off +cutoff.description=Cut off +retain.title=Mantieni +retain.description=Mantieni +destroy.title=Elimina definitivamente +destroy.description=Elimina definitivamente + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_ja.properties index 60135dd26e..57e50da59c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_ja.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 -cutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5 -retain.title=\u7559\u4fdd -retain.description=\u7559\u4fdd -destroy.title=\u7834\u68c4 -destroy.description=\u7834\u68c4 - +# Disposition Actions +cutoff.title=\u30ab\u30c3\u30c8\u30aa\u30d5 +cutoff.description=\u30ab\u30c3\u30c8\u30aa\u30d5 +retain.title=\u7559\u4fdd +retain.description=\u7559\u4fdd +destroy.title=\u7834\u68c4 +destroy.description=\u7834\u68c4 + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_nl.properties index df8ea5abe0..5571355dae 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_nl.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=Afsluiten -cutoff.description=Afsluiten -retain.title=Behouden -retain.description=Behouden -destroy.title=Vernietigen -destroy.description=Vernietigen - +# Disposition Actions +cutoff.title=Afsluiten +cutoff.description=Afsluiten +retain.title=Behouden +retain.description=Behouden +destroy.title=Vernietigen +destroy.description=Vernietigen + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_zh_CN.properties index 61f5d0dc1e..61896eeef8 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-actions_zh_CN.properties @@ -1,8 +1,8 @@ -# Disposition Actions -cutoff.title=\u4e2d\u65ad -cutoff.description=\u4e2d\u65ad -retain.title=\u4fdd\u7559 -retain.description=\u4fdd\u7559 -destroy.title=\u9500\u6bc1 -destroy.description=\u9500\u6bc1 - +# Disposition Actions +cutoff.title=\u4e2d\u65ad +cutoff.description=\u4e2d\u65ad +retain.title=\u4fdd\u7559 +retain.description=\u4fdd\u7559 +destroy.title=\u9500\u6bc1 +destroy.description=\u9500\u6bc1 + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events.properties index ff7d78eab7..6b0340b812 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Simple Event -rmeventservice.rmEventType.obsolete=Obsoleted Event -rmeventservice.rmEventType.superseded=Superseded Event -rmeventservice.rmEventType.crossReferencedRecordTransfered=Cross Referenced Record Transferred -rmeventservice.rmEventType.versioned=Versioned Event - -# Default events -rmevent.case_closed=Case Closed -rmevent.abolished=Abolished -rmevent.re_designated=Redesignated -rmevent.no_longer_needed=No longer needed -rmevent.superseded=Superseded -rmevent.versioned=Versioned -rmevent.study_complete=Study Complete -rmevent.training_complete=Training Complete -rmevent.related_record_trasfered_inactive_storage=Related Record Transferred To Inactive Storage -rmevent.obsolete=Obsolete -rmevent.all_allowances_granted_are_terminated=All Allowances Granted Are Terminated -rmevent.WGI_action_complete=WGI action complete -rmevent.separation=Separation +# Event Types +rmeventservice.rmEventType.simple=Simple Event +rmeventservice.rmEventType.obsolete=Obsoleted Event +rmeventservice.rmEventType.superseded=Superseded Event +rmeventservice.rmEventType.crossReferencedRecordTransfered=Cross Referenced Record Transferred +rmeventservice.rmEventType.versioned=Versioned Event + +# Default events +rmevent.case_closed=Case Closed +rmevent.abolished=Abolished +rmevent.re_designated=Redesignated +rmevent.no_longer_needed=No longer needed +rmevent.superseded=Superseded +rmevent.versioned=Versioned +rmevent.study_complete=Study Complete +rmevent.training_complete=Training Complete +rmevent.related_record_trasfered_inactive_storage=Related Record Transferred To Inactive Storage +rmevent.obsolete=Obsolete +rmevent.all_allowances_granted_are_terminated=All Allowances Granted Are Terminated +rmevent.WGI_action_complete=WGI action complete +rmevent.separation=Separation rmevent.case_complete=Case Complete \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_de.properties index a6c622c541..6c29f08301 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_de.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Einfaches Ereignis -rmeventservice.rmEventType.obsolete=Ereignis mit veraltetem Record -rmeventservice.rmEventType.superseded=Ereignis mit abgel\u00f6stem Record -rmeventservice.rmEventType.crossReferencedRecordTransfered=Record mit Querverweis \u00fcbertragen -rmeventservice.rmEventType.versioned=Versioniertes Ereignis - -# Default events -rmevent.case_closed=Fall geschlossen -rmevent.abolished=Aufgehoben -rmevent.re_designated=Neu zugewiesen -rmevent.no_longer_needed=Nicht mehr ben\u00f6tigt -rmevent.superseded=Abgel\u00f6st -rmevent.versioned=Versioniert -rmevent.study_complete=Untersuchung abgeschlossen -rmevent.training_complete=Training abgeschlossen -rmevent.related_record_trasfered_inactive_storage=Zugeh\u00f6riger Record an inaktiven Speicherort \u00fcbertragen -rmevent.obsolete=Veraltet -rmevent.all_allowances_granted_are_terminated=Alle einger\u00e4umten Berechtigungen sind beendet -rmevent.WGI_action_complete=WGI-Aktion abschlie\u00dfen -rmevent.separation=Trennung +# Event Types +rmeventservice.rmEventType.simple=Einfaches Ereignis +rmeventservice.rmEventType.obsolete=Ereignis mit veraltetem Record +rmeventservice.rmEventType.superseded=Ereignis mit abgel\u00f6stem Record +rmeventservice.rmEventType.crossReferencedRecordTransfered=Record mit Querverweis \u00fcbertragen +rmeventservice.rmEventType.versioned=Versioniertes Ereignis + +# Default events +rmevent.case_closed=Fall geschlossen +rmevent.abolished=Aufgehoben +rmevent.re_designated=Neu zugewiesen +rmevent.no_longer_needed=Nicht mehr ben\u00f6tigt +rmevent.superseded=Abgel\u00f6st +rmevent.versioned=Versioniert +rmevent.study_complete=Untersuchung abgeschlossen +rmevent.training_complete=Training abgeschlossen +rmevent.related_record_trasfered_inactive_storage=Zugeh\u00f6riger Record an inaktiven Speicherort \u00fcbertragen +rmevent.obsolete=Veraltet +rmevent.all_allowances_granted_are_terminated=Alle einger\u00e4umten Berechtigungen sind beendet +rmevent.WGI_action_complete=WGI-Aktion abschlie\u00dfen +rmevent.separation=Trennung rmevent.case_complete=Fall abgeschlossen \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_es.properties index f712f35a5c..e16251ccf9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_es.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Evento simple -rmeventservice.rmEventType.obsolete=Evento obsoleto -rmeventservice.rmEventType.superseded=Evento reemplazado -rmeventservice.rmEventType.crossReferencedRecordTransfered=Documento de archivo con referencia cruzada transferido -rmeventservice.rmEventType.versioned=Evento versionado - -# Default events -rmevent.case_closed=Caso cerrado -rmevent.abolished=Abolido -rmevent.re_designated=Redise\u00f1ado -rmevent.no_longer_needed=Ya no se necesita -rmevent.superseded=Reemplazado -rmevent.versioned=Versionado -rmevent.study_complete=Estudio completo -rmevent.training_complete=Formaci\u00f3n completo -rmevent.related_record_trasfered_inactive_storage=Documento de archivo relacionado transferido a almacenamiento inactivo -rmevent.obsolete=Obsoleto -rmevent.all_allowances_granted_are_terminated=Todas las provisiones otorgadas han terminado -rmevent.WGI_action_complete=Acci\u00f3n WGI completa -rmevent.separation=Separaci\u00f3n +# Event Types +rmeventservice.rmEventType.simple=Evento simple +rmeventservice.rmEventType.obsolete=Evento obsoleto +rmeventservice.rmEventType.superseded=Evento reemplazado +rmeventservice.rmEventType.crossReferencedRecordTransfered=Documento de archivo con referencia cruzada transferido +rmeventservice.rmEventType.versioned=Evento versionado + +# Default events +rmevent.case_closed=Caso cerrado +rmevent.abolished=Abolido +rmevent.re_designated=Redise\u00f1ado +rmevent.no_longer_needed=Ya no se necesita +rmevent.superseded=Reemplazado +rmevent.versioned=Versionado +rmevent.study_complete=Estudio completo +rmevent.training_complete=Formaci\u00f3n completo +rmevent.related_record_trasfered_inactive_storage=Documento de archivo relacionado transferido a almacenamiento inactivo +rmevent.obsolete=Obsoleto +rmevent.all_allowances_granted_are_terminated=Todas las provisiones otorgadas han terminado +rmevent.WGI_action_complete=Acci\u00f3n WGI completa +rmevent.separation=Separaci\u00f3n rmevent.case_complete=Caso completo \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_fr.properties index a18d97bb55..332a8dfb6a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_fr.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Ev\u00e9nement simple -rmeventservice.rmEventType.obsolete=Ev\u00e9nement obsol\u00e8te -rmeventservice.rmEventType.superseded=Ev\u00e9nement remplac\u00e9 -rmeventservice.rmEventType.crossReferencedRecordTransfered=Document d'archives avec r\u00e9f\u00e9rence crois\u00e9e transf\u00e9r\u00e9 -rmeventservice.rmEventType.versioned=Ev\u00e9nement versionn\u00e9 - -# Default events -rmevent.case_closed=Cas clos -rmevent.abolished=Aboli -rmevent.re_designated=Renomm\u00e9 -rmevent.no_longer_needed=Plus n\u00e9cessaire -rmevent.superseded=Remplac\u00e9 -rmevent.versioned=Versionn\u00e9 -rmevent.study_complete=Etude termin\u00e9e -rmevent.training_complete=Formation termin\u00e9e -rmevent.related_record_trasfered_inactive_storage=Document d'archives li\u00e9 transf\u00e9r\u00e9 au stockage inactif -rmevent.obsolete=Obsol\u00e8te -rmevent.all_allowances_granted_are_terminated=Toutes les autorisations accord\u00e9es sont termin\u00e9es -rmevent.WGI_action_complete=Action WGI termin\u00e9e -rmevent.separation=S\u00e9paration +# Event Types +rmeventservice.rmEventType.simple=Ev\u00e9nement simple +rmeventservice.rmEventType.obsolete=Ev\u00e9nement obsol\u00e8te +rmeventservice.rmEventType.superseded=Ev\u00e9nement remplac\u00e9 +rmeventservice.rmEventType.crossReferencedRecordTransfered=Document d'archives avec r\u00e9f\u00e9rence crois\u00e9e transf\u00e9r\u00e9 +rmeventservice.rmEventType.versioned=Ev\u00e9nement versionn\u00e9 + +# Default events +rmevent.case_closed=Cas clos +rmevent.abolished=Aboli +rmevent.re_designated=Renomm\u00e9 +rmevent.no_longer_needed=Plus n\u00e9cessaire +rmevent.superseded=Remplac\u00e9 +rmevent.versioned=Versionn\u00e9 +rmevent.study_complete=Etude termin\u00e9e +rmevent.training_complete=Formation termin\u00e9e +rmevent.related_record_trasfered_inactive_storage=Document d'archives li\u00e9 transf\u00e9r\u00e9 au stockage inactif +rmevent.obsolete=Obsol\u00e8te +rmevent.all_allowances_granted_are_terminated=Toutes les autorisations accord\u00e9es sont termin\u00e9es +rmevent.WGI_action_complete=Action WGI termin\u00e9e +rmevent.separation=S\u00e9paration rmevent.case_complete=Cas termin\u00e9 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_it.properties index 11fc965165..606bd6cb2d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_it.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Evento semplice -rmeventservice.rmEventType.obsolete=Evento obsoleto -rmeventservice.rmEventType.superseded=Evento sostituito -rmeventservice.rmEventType.crossReferencedRecordTransfered=Record con rif. incrociati trasferito -rmeventservice.rmEventType.versioned=Evento con versione - -# Default events -rmevent.case_closed=Caso chiuso -rmevent.abolished=Abolito -rmevent.re_designated=Riprogettato -rmevent.no_longer_needed=Non pi\u00f9 necessario -rmevent.superseded=Sostituito -rmevent.versioned=Con versione -rmevent.study_complete=Studio completato -rmevent.training_complete=Training Completato -rmevent.related_record_trasfered_inactive_storage=Record correlato trasferito a Archiviazione inattiva -rmevent.obsolete=Obsoleto -rmevent.all_allowances_granted_are_terminated=Tutte le concessioni sono state terminate -rmevent.WGI_action_complete=Azione WGI completata -rmevent.separation=Separazione +# Event Types +rmeventservice.rmEventType.simple=Evento semplice +rmeventservice.rmEventType.obsolete=Evento obsoleto +rmeventservice.rmEventType.superseded=Evento sostituito +rmeventservice.rmEventType.crossReferencedRecordTransfered=Record con rif. incrociati trasferito +rmeventservice.rmEventType.versioned=Evento con versione + +# Default events +rmevent.case_closed=Caso chiuso +rmevent.abolished=Abolito +rmevent.re_designated=Riprogettato +rmevent.no_longer_needed=Non pi\u00f9 necessario +rmevent.superseded=Sostituito +rmevent.versioned=Con versione +rmevent.study_complete=Studio completato +rmevent.training_complete=Training Completato +rmevent.related_record_trasfered_inactive_storage=Record correlato trasferito a Archiviazione inattiva +rmevent.obsolete=Obsoleto +rmevent.all_allowances_granted_are_terminated=Tutte le concessioni sono state terminate +rmevent.WGI_action_complete=Azione WGI completata +rmevent.separation=Separazione rmevent.case_complete=Caso completato \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_ja.properties index 538b57a1e5..27b65d3fc5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_ja.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=\u7c21\u6613\u30a4\u30d9\u30f3\u30c8 -rmeventservice.rmEventType.obsolete=\u5ec3\u6b62\u30a4\u30d9\u30f3\u30c8 -rmeventservice.rmEventType.superseded=\u4ee3\u66ff\u30a4\u30d9\u30f3\u30c8 -rmeventservice.rmEventType.crossReferencedRecordTransfered=\u76f8\u4e92\u53c2\u7167\u30ec\u30b3\u30fc\u30c9\u304c\u8ee2\u9001\u6e08\u307f -rmeventservice.rmEventType.versioned=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30a4\u30d9\u30f3\u30c8 - -# Default events -rmevent.case_closed=\u30b1\u30fc\u30b9\u7d42\u4e86 -rmevent.abolished=\u5ec3\u6b62\u6e08\u307f -rmevent.re_designated=\u518d\u6307\u5b9a\u6e08\u307f -rmevent.no_longer_needed=\u4eca\u5f8c\u4e0d\u8981 -rmevent.superseded=\u4ee3\u66ff\u6e08\u307f -rmevent.versioned=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u6e08\u307f -rmevent.study_complete=\u5b66\u7fd2\u5b8c\u4e86 -rmevent.training_complete=\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u5b8c\u4e86 -rmevent.related_record_trasfered_inactive_storage=\u95a2\u9023\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u8ee2\u9001\u6e08\u307f -rmevent.obsolete=\u5ec3\u6b62 -rmevent.all_allowances_granted_are_terminated=\u5831\u916c\u306f\u3059\u3079\u3066\u7d42\u4e86\u3057\u3066\u3044\u308b -rmevent.WGI_action_complete=WGI \u30a2\u30af\u30b7\u30e7\u30f3\u5b8c\u4e86 -rmevent.separation=\u5206\u96e2 +# Event Types +rmeventservice.rmEventType.simple=\u7c21\u6613\u30a4\u30d9\u30f3\u30c8 +rmeventservice.rmEventType.obsolete=\u5ec3\u6b62\u30a4\u30d9\u30f3\u30c8 +rmeventservice.rmEventType.superseded=\u4ee3\u66ff\u30a4\u30d9\u30f3\u30c8 +rmeventservice.rmEventType.crossReferencedRecordTransfered=\u76f8\u4e92\u53c2\u7167\u30ec\u30b3\u30fc\u30c9\u304c\u8ee2\u9001\u6e08\u307f +rmeventservice.rmEventType.versioned=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30a4\u30d9\u30f3\u30c8 + +# Default events +rmevent.case_closed=\u30b1\u30fc\u30b9\u7d42\u4e86 +rmevent.abolished=\u5ec3\u6b62\u6e08\u307f +rmevent.re_designated=\u518d\u6307\u5b9a\u6e08\u307f +rmevent.no_longer_needed=\u4eca\u5f8c\u4e0d\u8981 +rmevent.superseded=\u4ee3\u66ff\u6e08\u307f +rmevent.versioned=\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u6e08\u307f +rmevent.study_complete=\u5b66\u7fd2\u5b8c\u4e86 +rmevent.training_complete=\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u5b8c\u4e86 +rmevent.related_record_trasfered_inactive_storage=\u95a2\u9023\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u8ee2\u9001\u6e08\u307f +rmevent.obsolete=\u5ec3\u6b62 +rmevent.all_allowances_granted_are_terminated=\u5831\u916c\u306f\u3059\u3079\u3066\u7d42\u4e86\u3057\u3066\u3044\u308b +rmevent.WGI_action_complete=WGI \u30a2\u30af\u30b7\u30e7\u30f3\u5b8c\u4e86 +rmevent.separation=\u5206\u96e2 rmevent.case_complete=\u30b1\u30fc\u30b9\u5b8c\u4e86 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_nl.properties index 6f5894c01d..6d3aefb5e0 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_nl.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=Eenvoudige gebeurtenis -rmeventservice.rmEventType.obsolete=Verouderde gebeurtenis -rmeventservice.rmEventType.superseded=Vervangen gebeurtenis -rmeventservice.rmEventType.crossReferencedRecordTransfered=Record met kruisverwijzing overgezet -rmeventservice.rmEventType.versioned=Gebeurtenis met versiebeheer - -# Default events -rmevent.case_closed=Geval gesloten -rmevent.abolished=Vervallen -rmevent.re_designated=Opnieuw aangewezen -rmevent.no_longer_needed=Niet langer nodig -rmevent.superseded=Vervangen -rmevent.versioned=Met versiebeheer -rmevent.study_complete=Onderzoek afgerond -rmevent.training_complete=Training afgerond -rmevent.related_record_trasfered_inactive_storage=Gerelateerde record overgezet naar inactieve opslag -rmevent.obsolete=Verouderd -rmevent.all_allowances_granted_are_terminated=Alle toegekende rechten zijn be\u00ebindigd -rmevent.WGI_action_complete=WGI-actie afgerond -rmevent.separation=Scheiding +# Event Types +rmeventservice.rmEventType.simple=Eenvoudige gebeurtenis +rmeventservice.rmEventType.obsolete=Verouderde gebeurtenis +rmeventservice.rmEventType.superseded=Vervangen gebeurtenis +rmeventservice.rmEventType.crossReferencedRecordTransfered=Record met kruisverwijzing overgezet +rmeventservice.rmEventType.versioned=Gebeurtenis met versiebeheer + +# Default events +rmevent.case_closed=Geval gesloten +rmevent.abolished=Vervallen +rmevent.re_designated=Opnieuw aangewezen +rmevent.no_longer_needed=Niet langer nodig +rmevent.superseded=Vervangen +rmevent.versioned=Met versiebeheer +rmevent.study_complete=Onderzoek afgerond +rmevent.training_complete=Training afgerond +rmevent.related_record_trasfered_inactive_storage=Gerelateerde record overgezet naar inactieve opslag +rmevent.obsolete=Verouderd +rmevent.all_allowances_granted_are_terminated=Alle toegekende rechten zijn be\u00ebindigd +rmevent.WGI_action_complete=WGI-actie afgerond +rmevent.separation=Scheiding rmevent.case_complete=Geval afgerond \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_zh_CN.properties index 54cebe098e..8bfcff9dff 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-events_zh_CN.properties @@ -1,22 +1,22 @@ -# Event Types -rmeventservice.rmEventType.simple=\u7b80\u5355\u4e8b\u4ef6 -rmeventservice.rmEventType.obsolete=\u8fc7\u65f6\u7684\u4e8b\u4ef6 -rmeventservice.rmEventType.superseded=\u88ab\u53d6\u4ee3\u7684\u4e8b\u4ef6 -rmeventservice.rmEventType.crossReferencedRecordTransfered=\u5df2\u79fb\u4ea4\u4ea4\u53c9\u53c2\u8003\u8bb0\u5f55 -rmeventservice.rmEventType.versioned=\u7248\u672c\u5316\u4e8b\u4ef6 - -# Default events -rmevent.case_closed=\u6848\u4f8b\u5df2\u7ed3 -rmevent.abolished=\u5df2\u5e9f\u9664 -rmevent.re_designated=\u5df2\u91cd\u65b0\u6307\u5b9a -rmevent.no_longer_needed=\u4e0d\u518d\u9700\u8981 -rmevent.superseded=\u5df2\u88ab\u53d6\u4ee3 -rmevent.versioned=\u7248\u672c\u5316 -rmevent.study_complete=\u5b66\u4e60\u5b8c\u6210 -rmevent.training_complete=\u57f9\u8bad\u5b8c\u6210 -rmevent.related_record_trasfered_inactive_storage=\u76f8\u5173\u8bb0\u5f55\u5df2\u79fb\u4ea4\u81f3\u4e0d\u6d3b\u52a8\u7684\u5b58\u50a8 -rmevent.obsolete=\u8fc7\u65f6 -rmevent.all_allowances_granted_are_terminated=\u6240\u6709\u6388\u4e88\u7684\u9650\u989d\u5df2\u7ec8\u6b62 -rmevent.WGI_action_complete=WGI \u64cd\u4f5c\u5b8c\u6210 -rmevent.separation=\u5206\u79bb +# Event Types +rmeventservice.rmEventType.simple=\u7b80\u5355\u4e8b\u4ef6 +rmeventservice.rmEventType.obsolete=\u8fc7\u65f6\u7684\u4e8b\u4ef6 +rmeventservice.rmEventType.superseded=\u88ab\u53d6\u4ee3\u7684\u4e8b\u4ef6 +rmeventservice.rmEventType.crossReferencedRecordTransfered=\u5df2\u79fb\u4ea4\u4ea4\u53c9\u53c2\u8003\u8bb0\u5f55 +rmeventservice.rmEventType.versioned=\u7248\u672c\u5316\u4e8b\u4ef6 + +# Default events +rmevent.case_closed=\u6848\u4f8b\u5df2\u7ed3 +rmevent.abolished=\u5df2\u5e9f\u9664 +rmevent.re_designated=\u5df2\u91cd\u65b0\u6307\u5b9a +rmevent.no_longer_needed=\u4e0d\u518d\u9700\u8981 +rmevent.superseded=\u5df2\u88ab\u53d6\u4ee3 +rmevent.versioned=\u7248\u672c\u5316 +rmevent.study_complete=\u5b66\u4e60\u5b8c\u6210 +rmevent.training_complete=\u57f9\u8bad\u5b8c\u6210 +rmevent.related_record_trasfered_inactive_storage=\u76f8\u5173\u8bb0\u5f55\u5df2\u79fb\u4ea4\u81f3\u4e0d\u6d3b\u52a8\u7684\u5b58\u50a8 +rmevent.obsolete=\u8fc7\u65f6 +rmevent.all_allowances_granted_are_terminated=\u6240\u6709\u6388\u4e88\u7684\u9650\u989d\u5df2\u7ec8\u6b62 +rmevent.WGI_action_complete=WGI \u64cd\u4f5c\u5b8c\u6210 +rmevent.separation=\u5206\u79bb rmevent.case_complete=\u6848\u4f8b\u5b8c\u6210 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system.properties index 649a76b2bd..d0d5d9e714 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system.properties @@ -1,25 +1,25 @@ -rm.hold.name=Hold - -## Defaut roles -rm.role.extendedReaders=In-Place Readers -rm.role.extendedWriters=In-Place Writers -rm.role.user=Records Management User -rm.role.powerUser=Records Management Power User -rm.role.securityOfficer=Records Management Security Officer -rm.role.recordsManager=Records Management Manager -rm.role.administrator=Records Management Administrator -rm.role.all=All Records Management Roles - -## Default searches -rm.savedsearch.vitalRecordsName=Vital Records Due For Review -rm.savedsearch.vitalRecordsDesc=All records currently due for review. -rm.savedsearch.incompleteRecordsName=Incomplete Records -rm.savedsearch.incompleteRecordsDesc=All incomplete records. -rm.savedsearch.cutoffRecordsName=Records And Record Folders Eligible For Cut Off -rm.savedsearch.cutoffRecordsDesc=All records and record folders currently eligible for cut off. -rm.savedsearch.transferRecordsName=Records and Record Folders Eligible For Transfer -rm.savedsearch.transferRecordsDesc=All record folders and records currently eligible for transfer. -rm.savedsearch.destructionRecordsName=Records And Record Folders Eligible For Destruction -rm.savedsearch.destructionRecordsDesc=All records currently eligible for destruction. -rm.savedsearch.frozenRecordsName= Records and Record Folders On Hold +rm.hold.name=Hold + +## Defaut roles +rm.role.extendedReaders=In-Place Readers +rm.role.extendedWriters=In-Place Writers +rm.role.user=Records Management User +rm.role.powerUser=Records Management Power User +rm.role.securityOfficer=Records Management Security Officer +rm.role.recordsManager=Records Management Manager +rm.role.administrator=Records Management Administrator +rm.role.all=All Records Management Roles + +## Default searches +rm.savedsearch.vitalRecordsName=Vital Records Due For Review +rm.savedsearch.vitalRecordsDesc=All records currently due for review. +rm.savedsearch.incompleteRecordsName=Incomplete Records +rm.savedsearch.incompleteRecordsDesc=All incomplete records. +rm.savedsearch.cutoffRecordsName=Records And Record Folders Eligible For Cut Off +rm.savedsearch.cutoffRecordsDesc=All records and record folders currently eligible for cut off. +rm.savedsearch.transferRecordsName=Records and Record Folders Eligible For Transfer +rm.savedsearch.transferRecordsDesc=All record folders and records currently eligible for transfer. +rm.savedsearch.destructionRecordsName=Records And Record Folders Eligible For Destruction +rm.savedsearch.destructionRecordsDesc=All records currently eligible for destruction. +rm.savedsearch.frozenRecordsName= Records and Record Folders On Hold rm.savedsearch.frozenRecordsDesc=All records and record folders currently on hold. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_de.properties index a8bc1b20dd..6a0869210d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_de.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_de.properties @@ -1,25 +1,25 @@ -rm.hold.name=Sperrbereich - -## Defaut roles -rm.role.extendedReaders=An Originalposition lesen -rm.role.extendedWriters=An Originalposition schreiben -rm.role.user=Records Management Benutzer -rm.role.powerUser=Records Management Profibenutzer -rm.role.securityOfficer=Records Management Sicherheitsbeauftragter -rm.role.recordsManager=Records Management Manager -rm.role.administrator=Records Management Administrator -rm.role.all=Alle Records Management Rollen - -## Default searches -rm.savedsearch.vitalRecordsName=Besonders relevante Records mit f\u00e4lliger \u00dcberpr\u00fcfung -rm.savedsearch.vitalRecordsDesc=Alle aktuell zum \u00dcberpr\u00fcfen f\u00e4lligen Records. -rm.savedsearch.incompleteRecordsName=Nicht abgeschlossene Records -rm.savedsearch.incompleteRecordsDesc=Alle nicht abgeschlossenen Records. -rm.savedsearch.cutoffRecordsName=Zur Trennung geeignete Records und Record-Ordner -rm.savedsearch.cutoffRecordsDesc=Alle derzeit zur Trennung geeigneten Records und Record-Ordner. -rm.savedsearch.transferRecordsName=Zur \u00dcbertragung geeignete Records und Record-Ordner -rm.savedsearch.transferRecordsDesc=Alle aktuell zur \u00dcbertragung geeigneten Records und Record-Ordner. -rm.savedsearch.destructionRecordsName=Zur Vernichtung geeignete Records und Record-Ordner -rm.savedsearch.destructionRecordsDesc=Alle aktuell zur Vernichtung geeigneten Records. -rm.savedsearch.frozenRecordsName= Gesperrte Records und Record Ordner +rm.hold.name=Sperrbereich + +## Defaut roles +rm.role.extendedReaders=An Originalposition lesen +rm.role.extendedWriters=An Originalposition schreiben +rm.role.user=Records Management Benutzer +rm.role.powerUser=Records Management Profibenutzer +rm.role.securityOfficer=Records Management Sicherheitsbeauftragter +rm.role.recordsManager=Records Management Manager +rm.role.administrator=Records Management Administrator +rm.role.all=Alle Records Management Rollen + +## Default searches +rm.savedsearch.vitalRecordsName=Besonders relevante Records mit f\u00e4lliger \u00dcberpr\u00fcfung +rm.savedsearch.vitalRecordsDesc=Alle aktuell zum \u00dcberpr\u00fcfen f\u00e4lligen Records. +rm.savedsearch.incompleteRecordsName=Nicht abgeschlossene Records +rm.savedsearch.incompleteRecordsDesc=Alle nicht abgeschlossenen Records. +rm.savedsearch.cutoffRecordsName=Zur Trennung geeignete Records und Record-Ordner +rm.savedsearch.cutoffRecordsDesc=Alle derzeit zur Trennung geeigneten Records und Record-Ordner. +rm.savedsearch.transferRecordsName=Zur \u00dcbertragung geeignete Records und Record-Ordner +rm.savedsearch.transferRecordsDesc=Alle aktuell zur \u00dcbertragung geeigneten Records und Record-Ordner. +rm.savedsearch.destructionRecordsName=Zur Vernichtung geeignete Records und Record-Ordner +rm.savedsearch.destructionRecordsDesc=Alle aktuell zur Vernichtung geeigneten Records. +rm.savedsearch.frozenRecordsName= Gesperrte Records und Record Ordner rm.savedsearch.frozenRecordsDesc=Alle derzeit gesperrten Records und Record-Ordner. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_es.properties index 40ad3b939a..042dde586e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_es.properties @@ -1,25 +1,25 @@ -rm.hold.name=Bloqueo - -## Defaut roles -rm.role.extendedReaders=Lectores in situ -rm.role.extendedWriters=Escritores in situ -rm.role.user=Usuario de gesti\u00f3n de documentos de archivo -rm.role.powerUser=Usuario de potencia de gesti\u00f3n de documentos de archivo -rm.role.securityOfficer=Encargado de seguridad de gesti\u00f3n de documentos de archivo -rm.role.recordsManager=Gestor de gesti\u00f3n de documentos de archivo -rm.role.administrator=Jefe de gesti\u00f3n de documentos de archivo -rm.role.all=Todos los roles de gesti\u00f3n de documentos de archivo - -## Default searches -rm.savedsearch.vitalRecordsName=Documentos de archivo vitales pendientes de revisi\u00f3n -rm.savedsearch.vitalRecordsDesc=Todos los documentos de archivo pendientes de revisi\u00f3n. -rm.savedsearch.incompleteRecordsName=Documentos de archivo incompletos -rm.savedsearch.incompleteRecordsDesc=Todos los documentos de archivo incompletos. -rm.savedsearch.cutoffRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden interrumpir -rm.savedsearch.cutoffRecordsDesc=Todos los documentos de archivos y carpetas de documentos de archivos que se pueden interrumpir actualmente. -rm.savedsearch.transferRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden transferir -rm.savedsearch.transferRecordsDesc=Actualmente, todos los documentos y carpetas de documentos de archivo se pueden transferir. -rm.savedsearch.destructionRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden destruir -rm.savedsearch.destructionRecordsDesc=Actualmente, todos los documentos de archivo se pueden destruir. -rm.savedsearch.frozenRecordsName= Documentos de archivo y carpetas de documentos de archivo en espera +rm.hold.name=Bloqueo + +## Defaut roles +rm.role.extendedReaders=Lectores in situ +rm.role.extendedWriters=Escritores in situ +rm.role.user=Usuario de gesti\u00f3n de documentos de archivo +rm.role.powerUser=Usuario de potencia de gesti\u00f3n de documentos de archivo +rm.role.securityOfficer=Encargado de seguridad de gesti\u00f3n de documentos de archivo +rm.role.recordsManager=Gestor de gesti\u00f3n de documentos de archivo +rm.role.administrator=Jefe de gesti\u00f3n de documentos de archivo +rm.role.all=Todos los roles de gesti\u00f3n de documentos de archivo + +## Default searches +rm.savedsearch.vitalRecordsName=Documentos de archivo vitales pendientes de revisi\u00f3n +rm.savedsearch.vitalRecordsDesc=Todos los documentos de archivo pendientes de revisi\u00f3n. +rm.savedsearch.incompleteRecordsName=Documentos de archivo incompletos +rm.savedsearch.incompleteRecordsDesc=Todos los documentos de archivo incompletos. +rm.savedsearch.cutoffRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden interrumpir +rm.savedsearch.cutoffRecordsDesc=Todos los documentos de archivos y carpetas de documentos de archivos que se pueden interrumpir actualmente. +rm.savedsearch.transferRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden transferir +rm.savedsearch.transferRecordsDesc=Actualmente, todos los documentos y carpetas de documentos de archivo se pueden transferir. +rm.savedsearch.destructionRecordsName=Documentos de archivo y carpetas de documentos de archivo que se pueden destruir +rm.savedsearch.destructionRecordsDesc=Actualmente, todos los documentos de archivo se pueden destruir. +rm.savedsearch.frozenRecordsName= Documentos de archivo y carpetas de documentos de archivo en espera rm.savedsearch.frozenRecordsDesc=Todos los documentos de archivo y carpetas de documentos de archivo est\u00e1n en espera. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_fr.properties index be34f29d00..15bb2b1682 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_fr.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_fr.properties @@ -1,25 +1,25 @@ -rm.hold.name=Suspendre - -## Defaut roles -rm.role.extendedReaders=Lecteurs sur place -rm.role.extendedWriters=R\u00e9dacteurs sur place -rm.role.user=Utilisateur de la gestion des archives -rm.role.powerUser=Utilisateur principal de la gestion des archives -rm.role.securityOfficer=Agent de s\u00e9curit\u00e9 de la gestion des archives -rm.role.recordsManager=Responsable de la gestion des archives -rm.role.administrator=Administrateur de la gestion des archives -rm.role.all=Tous les r\u00f4les de la gestion des archives - -## Default searches -rm.savedsearch.vitalRecordsName=Documents d'archives essentiels arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification -rm.savedsearch.vitalRecordsDesc=Tous les documents d'archives arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification. -rm.savedsearch.incompleteRecordsName=Documents d'archives incomplets -rm.savedsearch.incompleteRecordsDesc=Tous les documents d'archives incomplets. -rm.savedsearch.cutoffRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour un d\u00e9classement -rm.savedsearch.cutoffRecordsDesc=Tous les documents d'archives et dossiers d'archives actuellement \u00e9ligibles pour un d\u00e9classement. -rm.savedsearch.transferRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour un transfert -rm.savedsearch.transferRecordsDesc=Tous les documents d'archives et dossiers d'archives actuellement \u00e9ligibles pour un transfert. -rm.savedsearch.destructionRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour une destruction -rm.savedsearch.destructionRecordsDesc=Tous les documents d'archives actuellement \u00e9ligibles pour destruction. -rm.savedsearch.frozenRecordsName= Documents d'archives et dossiers d'archives suspendus +rm.hold.name=Suspendre + +## Defaut roles +rm.role.extendedReaders=Lecteurs sur place +rm.role.extendedWriters=R\u00e9dacteurs sur place +rm.role.user=Utilisateur de la gestion des archives +rm.role.powerUser=Utilisateur principal de la gestion des archives +rm.role.securityOfficer=Agent de s\u00e9curit\u00e9 de la gestion des archives +rm.role.recordsManager=Responsable de la gestion des archives +rm.role.administrator=Administrateur de la gestion des archives +rm.role.all=Tous les r\u00f4les de la gestion des archives + +## Default searches +rm.savedsearch.vitalRecordsName=Documents d'archives essentiels arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification +rm.savedsearch.vitalRecordsDesc=Tous les documents d'archives arriv\u00e9s \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification. +rm.savedsearch.incompleteRecordsName=Documents d'archives incomplets +rm.savedsearch.incompleteRecordsDesc=Tous les documents d'archives incomplets. +rm.savedsearch.cutoffRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour un d\u00e9classement +rm.savedsearch.cutoffRecordsDesc=Tous les documents d'archives et dossiers d'archives actuellement \u00e9ligibles pour un d\u00e9classement. +rm.savedsearch.transferRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour un transfert +rm.savedsearch.transferRecordsDesc=Tous les documents d'archives et dossiers d'archives actuellement \u00e9ligibles pour un transfert. +rm.savedsearch.destructionRecordsName=Documents d'archives et dossiers d'archives \u00e9ligibles pour une destruction +rm.savedsearch.destructionRecordsDesc=Tous les documents d'archives actuellement \u00e9ligibles pour destruction. +rm.savedsearch.frozenRecordsName= Documents d'archives et dossiers d'archives suspendus rm.savedsearch.frozenRecordsDesc=Tous les documents d'archives et dossiers d'archives actuellement suspendus. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_it.properties index ecfcf5927c..6f822a4c2d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_it.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_it.properties @@ -1,25 +1,25 @@ -rm.hold.name=Sospensione - -## Defaut roles -rm.role.extendedReaders=Lettori pronti -rm.role.extendedWriters=Scrittori pronti -rm.role.user=Utente gestione dei record -rm.role.powerUser=Utente alimentazione di gestione dei record -rm.role.securityOfficer=Responsabile della sicurezza della gestione dei record -rm.role.recordsManager=Manager gestione dei record -rm.role.administrator=Amministratore gestione dei record -rm.role.all=Tutti i ruoli di gestione dei record - -## Default searches -rm.savedsearch.vitalRecordsName=Record fondamentali da revisionare -rm.savedsearch.vitalRecordsDesc=Tutti i record attualmente da revisionare. -rm.savedsearch.incompleteRecordsName=Record incompleti -rm.savedsearch.incompleteRecordsDesc=Tutti i record incompleti. -rm.savedsearch.cutoffRecordsName=Record e cartelle di record idonei per il cut off -rm.savedsearch.cutoffRecordsDesc=Tutti i record e le cartelle di record attualmente idonei per il cut off. -rm.savedsearch.transferRecordsName=Record e cartelle di record idonei per il trasferimento -rm.savedsearch.transferRecordsDesc=Tutti i record e le cartelle di record idonei per il trasferimento. -rm.savedsearch.destructionRecordsName=Record e cartelle di record idonei per l'eliminazione permanente -rm.savedsearch.destructionRecordsDesc=Tutti i record attuali idonei per l'eliminazione permanente. -rm.savedsearch.frozenRecordsName= Record e cartelle di record in sospeso +rm.hold.name=Sospensione + +## Defaut roles +rm.role.extendedReaders=Lettori pronti +rm.role.extendedWriters=Scrittori pronti +rm.role.user=Utente gestione dei record +rm.role.powerUser=Utente alimentazione di gestione dei record +rm.role.securityOfficer=Responsabile della sicurezza della gestione dei record +rm.role.recordsManager=Manager gestione dei record +rm.role.administrator=Amministratore gestione dei record +rm.role.all=Tutti i ruoli di gestione dei record + +## Default searches +rm.savedsearch.vitalRecordsName=Record fondamentali da revisionare +rm.savedsearch.vitalRecordsDesc=Tutti i record attualmente da revisionare. +rm.savedsearch.incompleteRecordsName=Record incompleti +rm.savedsearch.incompleteRecordsDesc=Tutti i record incompleti. +rm.savedsearch.cutoffRecordsName=Record e cartelle di record idonei per il cut off +rm.savedsearch.cutoffRecordsDesc=Tutti i record e le cartelle di record attualmente idonei per il cut off. +rm.savedsearch.transferRecordsName=Record e cartelle di record idonei per il trasferimento +rm.savedsearch.transferRecordsDesc=Tutti i record e le cartelle di record idonei per il trasferimento. +rm.savedsearch.destructionRecordsName=Record e cartelle di record idonei per l'eliminazione permanente +rm.savedsearch.destructionRecordsDesc=Tutti i record attuali idonei per l'eliminazione permanente. +rm.savedsearch.frozenRecordsName= Record e cartelle di record in sospeso rm.savedsearch.frozenRecordsDesc=Tutti i record e le cartelle di record attuali in sospeso. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_ja.properties index d8a1733ba1..add65b13fc 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_ja.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_ja.properties @@ -1,25 +1,25 @@ -rm.hold.name=\u30db\u30fc\u30eb\u30c9 - -## Defaut roles -rm.role.extendedReaders=\u914d\u7f6e\u6e08\u307f\u8aad\u8005 -rm.role.extendedWriters=\u914d\u7f6e\u6e08\u307f\u8457\u8005 -rm.role.user=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30e6\u30fc\u30b6\u30fc -rm.role.powerUser=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30d1\u30ef\u30fc\u30e6\u30fc\u30b6\u30fc -rm.role.securityOfficer=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5f79\u54e1 -rm.role.recordsManager=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30de\u30cd\u30fc\u30b8\u30e3\u30fc -rm.role.administrator=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u7ba1\u7406\u8005 -rm.role.all=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u5f79\u5272 - -## Default searches -rm.savedsearch.vitalRecordsName=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650 -rm.savedsearch.vitalRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u3067\u3059\u3002 -rm.savedsearch.incompleteRecordsName=\u672a\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 -rm.savedsearch.incompleteRecordsDesc=\u3059\u3079\u3066\u672a\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9\u3067\u3059\u3002 -rm.savedsearch.cutoffRecordsName=\u30ab\u30c3\u30c8\u30aa\u30d5\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rm.savedsearch.cutoffRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u304c\u73fe\u5728\u30ab\u30c3\u30c8\u30aa\u30d5\u306e\u5bfe\u8c61\u3067\u3059\u3002 -rm.savedsearch.transferRecordsName=\u8ee2\u9001\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rm.savedsearch.transferRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u8ee2\u9001\u306e\u5bfe\u8c61\u3067\u3059\u3002 -rm.savedsearch.destructionRecordsName=\u5ec3\u68c4\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 -rm.savedsearch.destructionRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u5ec3\u68c4\u306e\u5bfe\u8c61\u3067\u3059\u3002 -rm.savedsearch.frozenRecordsName= \u30db\u30fc\u30eb\u30c9\u4e2d\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rm.hold.name=\u30db\u30fc\u30eb\u30c9 + +## Defaut roles +rm.role.extendedReaders=\u914d\u7f6e\u6e08\u307f\u8aad\u8005 +rm.role.extendedWriters=\u914d\u7f6e\u6e08\u307f\u8457\u8005 +rm.role.user=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30e6\u30fc\u30b6\u30fc +rm.role.powerUser=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30d1\u30ef\u30fc\u30e6\u30fc\u30b6\u30fc +rm.role.securityOfficer=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5f79\u54e1 +rm.role.recordsManager=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u30de\u30cd\u30fc\u30b8\u30e3\u30fc +rm.role.administrator=\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u7ba1\u7406\u8005 +rm.role.all=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u7ba1\u7406\u306e\u5f79\u5272 + +## Default searches +rm.savedsearch.vitalRecordsName=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650 +rm.savedsearch.vitalRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u3067\u3059\u3002 +rm.savedsearch.incompleteRecordsName=\u672a\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9 +rm.savedsearch.incompleteRecordsDesc=\u3059\u3079\u3066\u672a\u5b8c\u4e86\u30ec\u30b3\u30fc\u30c9\u3067\u3059\u3002 +rm.savedsearch.cutoffRecordsName=\u30ab\u30c3\u30c8\u30aa\u30d5\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rm.savedsearch.cutoffRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u304c\u73fe\u5728\u30ab\u30c3\u30c8\u30aa\u30d5\u306e\u5bfe\u8c61\u3067\u3059\u3002 +rm.savedsearch.transferRecordsName=\u8ee2\u9001\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rm.savedsearch.transferRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u8ee2\u9001\u306e\u5bfe\u8c61\u3067\u3059\u3002 +rm.savedsearch.destructionRecordsName=\u5ec3\u68c4\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 +rm.savedsearch.destructionRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u73fe\u5728\u5ec3\u68c4\u306e\u5bfe\u8c61\u3067\u3059\u3002 +rm.savedsearch.frozenRecordsName= \u30db\u30fc\u30eb\u30c9\u4e2d\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0 rm.savedsearch.frozenRecordsDesc=\u3059\u3079\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u304a\u3088\u3073\u30ec\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u304c\u73fe\u5728\u30db\u30fc\u30eb\u30c9\u4e2d\u3067\u3059\u3002 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_nl.properties index d4d89ad8a4..f433656f0c 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_nl.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_nl.properties @@ -1,25 +1,25 @@ -rm.hold.name=Wachtstand - -## Defaut roles -rm.role.extendedReaders=Ge\u00efntegreerde lezers -rm.role.extendedWriters=Ge\u00efntegreerde schrijvers -rm.role.user=Gebruiker Record Management -rm.role.powerUser=Hoofdgebruiker Record Management -rm.role.securityOfficer=Beveiligingsmedewerker Record Management -rm.role.recordsManager=Manager Record Management -rm.role.administrator=Beheerder Record Management -rm.role.all=Alle rollen voor Record Management - -## Default searches -rm.savedsearch.vitalRecordsName=Vitale records gereed voor revisie -rm.savedsearch.vitalRecordsDesc=Alle records die momenteel gereed zijn voor revisie. -rm.savedsearch.incompleteRecordsName=Niet-afgeronde records -rm.savedsearch.incompleteRecordsDesc=Alle niet-afgeronde records. -rm.savedsearch.cutoffRecordsName=Records en archiefmappen die in aanmerking komen voor afsluiten -rm.savedsearch.cutoffRecordsDesc=Alle records en archiefmappen die momenteel in aanmerking komen voor afsluiten -rm.savedsearch.transferRecordsName=Records en archiefmappen die in aanmerking komen voor overzetten -rm.savedsearch.transferRecordsDesc=Alle records en archiefmappen die momenteel in aanmerking komen voor overzetten. -rm.savedsearch.destructionRecordsName=Records en archiefmappen die in aanmerking komen voor vernietiging -rm.savedsearch.destructionRecordsDesc=Alle records die momenteel in aanmerking komen voor vernietiging. -rm.savedsearch.frozenRecordsName= Records en archiefmappen die in wachtstand zijn +rm.hold.name=Wachtstand + +## Defaut roles +rm.role.extendedReaders=Ge\u00efntegreerde lezers +rm.role.extendedWriters=Ge\u00efntegreerde schrijvers +rm.role.user=Gebruiker Record Management +rm.role.powerUser=Hoofdgebruiker Record Management +rm.role.securityOfficer=Beveiligingsmedewerker Record Management +rm.role.recordsManager=Manager Record Management +rm.role.administrator=Beheerder Record Management +rm.role.all=Alle rollen voor Record Management + +## Default searches +rm.savedsearch.vitalRecordsName=Vitale records gereed voor revisie +rm.savedsearch.vitalRecordsDesc=Alle records die momenteel gereed zijn voor revisie. +rm.savedsearch.incompleteRecordsName=Niet-afgeronde records +rm.savedsearch.incompleteRecordsDesc=Alle niet-afgeronde records. +rm.savedsearch.cutoffRecordsName=Records en archiefmappen die in aanmerking komen voor afsluiten +rm.savedsearch.cutoffRecordsDesc=Alle records en archiefmappen die momenteel in aanmerking komen voor afsluiten +rm.savedsearch.transferRecordsName=Records en archiefmappen die in aanmerking komen voor overzetten +rm.savedsearch.transferRecordsDesc=Alle records en archiefmappen die momenteel in aanmerking komen voor overzetten. +rm.savedsearch.destructionRecordsName=Records en archiefmappen die in aanmerking komen voor vernietiging +rm.savedsearch.destructionRecordsDesc=Alle records die momenteel in aanmerking komen voor vernietiging. +rm.savedsearch.frozenRecordsName= Records en archiefmappen die in wachtstand zijn rm.savedsearch.frozenRecordsDesc=Alle records en archiefmappen die momenteel in wachtstand zijn. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_zh_CN.properties index 365c506326..a3afc52fdd 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_zh_CN.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/rm-system_zh_CN.properties @@ -1,25 +1,25 @@ -rm.hold.name=\u4fdd\u5b58 - -## Defaut roles -rm.role.extendedReaders=\u5c31\u5730\u8bfb\u8005 -rm.role.extendedWriters=\u5c31\u5730\u4f5c\u8005 -rm.role.user=\u8bb0\u5f55\u7ba1\u7406\u7528\u6237 -rm.role.powerUser=\u8bb0\u5f55\u7ba1\u7406\u9ad8\u7ea7\u7528\u6237 -rm.role.securityOfficer=\u8bb0\u5f55\u7ba1\u7406\u5b89\u5168\u5b98\u5458 -rm.role.recordsManager=\u8bb0\u5f55\u7ba1\u7406\u7684\u7ba1\u7406\u4eba\u5458 -rm.role.administrator=\u8bb0\u5f55\u7ba1\u7406\u7684\u7ba1\u7406\u5458 -rm.role.all=\u6240\u6709\u8bb0\u5f55\u7ba1\u7406\u89d2\u8272 - -## Default searches -rm.savedsearch.vitalRecordsName=\u6838\u5fc3\u8bb0\u5f55\u7684\u5ba1\u67e5\u5230\u671f -rm.savedsearch.vitalRecordsDesc=\u6240\u6709\u8bb0\u5f55\u7684\u5ba1\u67e5\u5f53\u524d\u5df2\u5230\u671f\u3002 -rm.savedsearch.incompleteRecordsName=\u4e0d\u5b8c\u6574\u7684\u8bb0\u5f55 -rm.savedsearch.incompleteRecordsDesc=\u6240\u6709\u4e0d\u5b8c\u6574\u7684\u8bb0\u5f55\u3002 -rm.savedsearch.cutoffRecordsName=\u53ef\u4e2d\u65ad\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 -rm.savedsearch.cutoffRecordsDesc=\u5f53\u524d\u53ef\u4e2d\u65ad\u7684\u6240\u6709\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 -rm.savedsearch.transferRecordsName=\u53ef\u79fb\u4ea4\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 -rm.savedsearch.transferRecordsDesc=\u5f53\u524d\u53ef\u79fb\u4ea4\u7684\u6240\u6709\u8bb0\u5f55\u6587\u4ef6\u5939\u548c\u8bb0\u5f55\u3002 -rm.savedsearch.destructionRecordsName=\u53ef\u9500\u6bc1\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 -rm.savedsearch.destructionRecordsDesc=\u5f53\u524d\u53ef\u9500\u6bc1\u7684\u6240\u6709\u8bb0\u5f55\u3002 -rm.savedsearch.frozenRecordsName= \u4fdd\u5b58\u4e2d\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 +rm.hold.name=\u4fdd\u5b58 + +## Defaut roles +rm.role.extendedReaders=\u5c31\u5730\u8bfb\u8005 +rm.role.extendedWriters=\u5c31\u5730\u4f5c\u8005 +rm.role.user=\u8bb0\u5f55\u7ba1\u7406\u7528\u6237 +rm.role.powerUser=\u8bb0\u5f55\u7ba1\u7406\u9ad8\u7ea7\u7528\u6237 +rm.role.securityOfficer=\u8bb0\u5f55\u7ba1\u7406\u5b89\u5168\u5b98\u5458 +rm.role.recordsManager=\u8bb0\u5f55\u7ba1\u7406\u7684\u7ba1\u7406\u4eba\u5458 +rm.role.administrator=\u8bb0\u5f55\u7ba1\u7406\u7684\u7ba1\u7406\u5458 +rm.role.all=\u6240\u6709\u8bb0\u5f55\u7ba1\u7406\u89d2\u8272 + +## Default searches +rm.savedsearch.vitalRecordsName=\u6838\u5fc3\u8bb0\u5f55\u7684\u5ba1\u67e5\u5230\u671f +rm.savedsearch.vitalRecordsDesc=\u6240\u6709\u8bb0\u5f55\u7684\u5ba1\u67e5\u5f53\u524d\u5df2\u5230\u671f\u3002 +rm.savedsearch.incompleteRecordsName=\u4e0d\u5b8c\u6574\u7684\u8bb0\u5f55 +rm.savedsearch.incompleteRecordsDesc=\u6240\u6709\u4e0d\u5b8c\u6574\u7684\u8bb0\u5f55\u3002 +rm.savedsearch.cutoffRecordsName=\u53ef\u4e2d\u65ad\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 +rm.savedsearch.cutoffRecordsDesc=\u5f53\u524d\u53ef\u4e2d\u65ad\u7684\u6240\u6709\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 +rm.savedsearch.transferRecordsName=\u53ef\u79fb\u4ea4\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 +rm.savedsearch.transferRecordsDesc=\u5f53\u524d\u53ef\u79fb\u4ea4\u7684\u6240\u6709\u8bb0\u5f55\u6587\u4ef6\u5939\u548c\u8bb0\u5f55\u3002 +rm.savedsearch.destructionRecordsName=\u53ef\u9500\u6bc1\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 +rm.savedsearch.destructionRecordsDesc=\u5f53\u524d\u53ef\u9500\u6bc1\u7684\u6240\u6709\u8bb0\u5f55\u3002 +rm.savedsearch.frozenRecordsName= \u4fdd\u5b58\u4e2d\u7684\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939 rm.savedsearch.frozenRecordsDesc=\u5f53\u524d\u4fdd\u5b58\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\u548c\u8bb0\u5f55\u6587\u4ef6\u5939\u3002 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/template.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/template.properties index 63abfd6dde..f47ad67a81 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/template.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/template.properties @@ -1,27 +1,27 @@ -# File Report Template -file.report.acession.report=Accession Report -file.report.date.format=EEE MMM dd HH:mm:ss zzz yyyy -file.report.declared.by=declared by -file.report.declared.on=on -file.report.destroyed=Destroyed -file.report.destroyed.records=Destroyed Records -file.report.destruction.report=Destruction Report -file.report.disposition.authority=Disposition Authority -file.report.disposition.instructions=Disposition Instructions -file.report.nara=NARA -file.report.transfer.date=Transfer Date -file.report.transfer.location=Transfer Location -file.report.transfer.report=Transfer Report -file.report.transferred.items=Transferred Items -file.report.performed.by=Performed By -file.report.record=Record -file.report.record.folder=Record Folder -file.report.unique.folder.identifier=Unique Folder Identifier -file.report.unique.record.identifier=Unique Record Identifier -file.report.hold.report=Hold Report -file.report.hold.name=Hold Name -file.report.hold.description=Hold Description -file.report.hold.reason=Hold Reason -file.report.hold.held=Held -file.report.createdby=Created By +# File Report Template +file.report.acession.report=Accession Report +file.report.date.format=EEE MMM dd HH:mm:ss zzz yyyy +file.report.declared.by=declared by +file.report.declared.on=on +file.report.destroyed=Destroyed +file.report.destroyed.records=Destroyed Records +file.report.destruction.report=Destruction Report +file.report.disposition.authority=Disposition Authority +file.report.disposition.instructions=Disposition Instructions +file.report.nara=NARA +file.report.transfer.date=Transfer Date +file.report.transfer.location=Transfer Location +file.report.transfer.report=Transfer Report +file.report.transferred.items=Transferred Items +file.report.performed.by=Performed By +file.report.record=Record +file.report.record.folder=Record Folder +file.report.unique.folder.identifier=Unique Folder Identifier +file.report.unique.record.identifier=Unique Record Identifier +file.report.hold.report=Hold Report +file.report.hold.name=Hold Name +file.report.hold.description=Hold Description +file.report.hold.reason=Hold Reason +file.report.hold.held=Held +file.report.createdby=Created By file.report.createdon=Created On \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml index a4587c061f..d194cb8743 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml @@ -1,129 +1,129 @@ - - - - - - - - - - - Recordable Version Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Recordable Version Policy List - - - NONE - MAJOR_ONLY - ALL - - - false - - - - - - - - - - - - - File Plan - d:noderef - - - - - Recordable Version Policy - d:text - NONE - - - - - - - - - - - - - - - - - Record Node Reference - d:noderef - - - - - Frozen Owner - d:text - - - - - Destroyed - d:boolean - false> - - - - - - - - - - - - d:noderef - - - - - d:text - - - - d:text - - - - - - + + + + + + + + + + + Recordable Version Model + Roy Wetherall + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recordable Version Policy List + + + NONE + MAJOR_ONLY + ALL + + + false + + + + + + + + + + + + + File Plan + d:noderef + + + + + Recordable Version Policy + d:text + NONE + + + + + + + + + + + + + + + + + Record Node Reference + d:noderef + + + + + Frozen Owner + d:text + + + + + Destroyed + d:boolean + false> + + + + + + + + + + + + d:noderef + + + + + d:text + + + + d:text + + + + + + \ No newline at end of file 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 e4957c7b11..25d1166376 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 @@ -1,1232 +1,1232 @@ - - - - - - - - - Records Management Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - - RM Site - st:site - false - - - - - Caveat Config - cm:content - false - - rma:filePlanComponent - - - - - Email Config - cm:content - - rma:filePlanComponent - - - - - - - - Records Management Container - cm:folder - false - - - cm:titled - rma:recordComponentIdentifier - rma:filePlanComponent - - - - - - - Record Category - rma:recordsManagementContainer - - - rma:vitalRecordDefinition - - - - - - - File Plan - rma:recordsManagementContainer - - - rma:recordsManagementRoot - - - - - - Unfiled Record Container - rma:recordsManagementContainer - - - - Unfiled Record Folder - rma:recordsManagementContainer - - - - Hold Container - rma:recordsManagementContainer - - rma:countable - - - - - Transfer Container - rma:recordsManagementContainer - - rma:countable - - - - - - - Disposition Schedule - cm:cmobject - - - - - Disposition Authority - d:text - true - - true - false - false - - - - - Disposition Instructions - d:text - true - - - - Record Level Disposition - d:boolean - true - false - - - - - - - - Disposition Actions - - false - false - - - rma:dispositionActionDefinition - false - true - - - - - - - rma:filePlanComponent - - - - - - Disposition Action Definition - cm:cmobject - - - - - Disposition Action Name - d:text - true - - - - Disposition Description - d:text - false - - - - Disposition Location - d:text - false - - true - false - false - - - - - Disposition Period - d:period - false - none|0 - - - - Disposition Period Property - d:text - false - - true - false - false - - - - - Disposition Event - d:text - true - - true - false - false - - - - - Disposition Event Combination - d:text - true - or - - true - false - false - - - - - - rma:filePlanComponent - - - - - - Record Folder - cm:folder - false - - - - - - - - Record Folder Closed - Indicates whether the folder is closed - d:boolean - true - true - false - - - - - - cm:titled - rma:recordComponentIdentifier - rma:commonRecordDetails - rma:filePlanComponent - rma:heldChildren - - - - - - - Non-Electronic Document - cm:content - false - - - - Document Physical Size - d:int - false - - true - false - false - - - - - Number Of Copies - d:int - false - 1 - - true - false - false - - - - - Storage Location - d:text - false - - true - false - false - - - - - Shelf - d:text - false - - true - false - false - - - - - Box - d:text - false - - true - false - false - - - - - File - d:text - false - - true - false - false - - - - - - rma:filePlanComponent - - - - - Disposition Action - cm:cmobject - - - Disposition Action Id - d:text - true - - true - false - false - - - - Disposition Action - d:text - true - - true - false - false - - - - Disposition Action Date - d:date - false - - - Disposition Events Eligible - d:boolean - false - - - Disposition Action Started At - d:date - false - - - Disposition Action Started By - d:text - false - - true - false - false - - - - Disposition Action Completed At - d:date - false - - - Disposition Action Copmleted By - d:text - false - - true - false - false - - - - - - - - - Event executions - - false - false - - - rma:eventExecution - false - true - - - - - - - rma:filePlanComponent - - - - - - - Event Execution - Execution details of an event - cm:cmobject - - - - - Event Name - d:text - true - - true - false - false - - - - Event automatic - d:boolean - true - - - Event complete - d:boolean - true - false - - - Event completed by - d:text - false - - true - false - false - - - - Event completed at - d:date - false - - - - - - rma:filePlanComponent - - - - - - Hold - rma:recordsManagementContainer - false - - - - - Hold Reason - d:text - true - - - - - - - Frozen Records - - false - true - - - rma:filePlanComponent - false - true - - - - - - - - - Transfer - cm:folder - false - - - - - Transfer Accession Indicator - d:boolean - true - true - - - - Transfer PDF Indicator - Indicates that transfer includes PDF - d:boolean - true - false - - - - Transfer PDF Indicator - Transfer Location - d:text - - - - - - - - Transferred - - false - false - - - rma:dispositionLifecycle - false - true - - - - - - - cm:titled - rma:filePlanComponent - - - - - - - - - - - - File Plan Component - false - - - Root node reference - d:noderef - true - - - - - - - Records Management Root - - - - - Holds - - false - false - - - rma:hold - false - true - - - - - - Transfers - - false - false - - - rma:transfer - false - true - - - - - - - - Declared Record - - - Date Declared - d:date - - - Declared By - d:text - - true - false - false - - - - - rma:filePlanComponent - - - - - Record component identifier - - - Record Component Identifier - d:text - true - - true - false - false - - - - Database uniqueness id - d:text - true - false - - - - rma:filePlanComponent - - - - - Vital Record Definition - - - Review Period - d:period - none|0 - - - Vital Record Indicator - d:boolean - false - - - - rma:filePlanComponent - - - - - - - Record - - false - - - - - - - - Date Filed - d:date - - - - Original Name - d:text - true - - - - - - - - d:date - false - - - d:text - false - - true - false - false - - - - d:text - false - - true - false - false - - - - d:text - false - - true - false - false - - - - d:text - false - - true - false - false - - - - d:date - false - - - d:text - false - - true - false - false - - - - d:text - false - - true - false - false - - - - - - - cm:titled - rma:recordComponentIdentifier - rma:commonRecordDetails - rma:filePlanComponent - - - - - - - - - - - - - - Location - d:text - false - - true - false - false - - - - - - rma:filePlanComponent - - - - - - - - - d:any - true - - - d:any - true - - - - - - - - Vital Record - - - Next Review Date - d:date - false - - - Indicates whether a notification that this record is due for review has been issued - d:boolean - true - false - false - - - - rma:filePlanComponent - - - - - Scheduled - - - - Disposition Schedule - - false - false - - - rma:dispositionSchedule - false - false - - - - - - rma:filePlanComponent - - - - - Disposition Lifecycle - - - - Next disposition action - - false - false - - - rma:dispositionAction - false - false - - - - - - Disposition Action History - - false - false - - - rma:dispositionAction - false - true - - - - - - rma:filePlanComponent - - - - - - Cut Off - - - Cut Off Date - d:date - true - - - - - - Uncut Off - - - - - Transferring - - - - - Transferred - - - - - Ascended - - - - Frozen - - - Frozen At Date - d:date - true - - - Frozen By - d:text - true - - true - false - false - - - - - - - Caveat Config Root - - - - true - false - - - rma:caveatConfig - false - false - - false - - - - - - Email Config Root - - - - true - false - - - rma:emailConfig - false - false - - false - - - - - - - - Record Search - - - d:boolean - true - - - d:text - true - - true - false - false - - - - d:date - true - - - d:text - true - - true - false - false - - - - d:text - true - - true - false - false - - - - d:boolean - true - - - d:text - true - true - - true - false - false - - - - d:text - true - - true - false - false - - - - d:text - true - - - - d:text - true - - - d:text - true - - true - false - false - - - - d:text - true - - true - false - false - - - - - - - Versioned Record - - - - Unpublished Update - - - d:boolean - true - true - - - d:text - - - d:any - - - d:boolean - true - false - - - - - - - Ghosted Record - false - - - - - Loaded Data Set Id - - - List of the loaded Data Set Ids - d:text - true - - - - - - - The originating details of a record - - - d:text - true - - - d:date - true - - - d:noderef - true - - - - - - - The rejection details of a record - - - d:text - true - - - d:date - true - - - d:text - true - - - - - - - - Held children - - - d:int - true - true - 0 - - - - - - - Countable aspect - - - d:int - true - true - 0 - - - - - - + + + + + + + + + Records Management Model + Roy Wetherall + 1.0 + + + + + + + + + + + + + + + + + + + + + + + RM Site + st:site + false + + + + + Caveat Config + cm:content + false + + rma:filePlanComponent + + + + + Email Config + cm:content + + rma:filePlanComponent + + + + + + + + Records Management Container + cm:folder + false + + + cm:titled + rma:recordComponentIdentifier + rma:filePlanComponent + + + + + + + Record Category + rma:recordsManagementContainer + + + rma:vitalRecordDefinition + + + + + + + File Plan + rma:recordsManagementContainer + + + rma:recordsManagementRoot + + + + + + Unfiled Record Container + rma:recordsManagementContainer + + + + Unfiled Record Folder + rma:recordsManagementContainer + + + + Hold Container + rma:recordsManagementContainer + + rma:countable + + + + + Transfer Container + rma:recordsManagementContainer + + rma:countable + + + + + + + Disposition Schedule + cm:cmobject + + + + + Disposition Authority + d:text + true + + true + false + false + + + + + Disposition Instructions + d:text + true + + + + Record Level Disposition + d:boolean + true + false + + + + + + + + Disposition Actions + + false + false + + + rma:dispositionActionDefinition + false + true + + + + + + + rma:filePlanComponent + + + + + + Disposition Action Definition + cm:cmobject + + + + + Disposition Action Name + d:text + true + + + + Disposition Description + d:text + false + + + + Disposition Location + d:text + false + + true + false + false + + + + + Disposition Period + d:period + false + none|0 + + + + Disposition Period Property + d:text + false + + true + false + false + + + + + Disposition Event + d:text + true + + true + false + false + + + + + Disposition Event Combination + d:text + true + or + + true + false + false + + + + + + rma:filePlanComponent + + + + + + Record Folder + cm:folder + false + + + + + + + + Record Folder Closed + Indicates whether the folder is closed + d:boolean + true + true + false + + + + + + cm:titled + rma:recordComponentIdentifier + rma:commonRecordDetails + rma:filePlanComponent + rma:heldChildren + + + + + + + Non-Electronic Document + cm:content + false + + + + Document Physical Size + d:int + false + + true + false + false + + + + + Number Of Copies + d:int + false + 1 + + true + false + false + + + + + Storage Location + d:text + false + + true + false + false + + + + + Shelf + d:text + false + + true + false + false + + + + + Box + d:text + false + + true + false + false + + + + + File + d:text + false + + true + false + false + + + + + + rma:filePlanComponent + + + + + Disposition Action + cm:cmobject + + + Disposition Action Id + d:text + true + + true + false + false + + + + Disposition Action + d:text + true + + true + false + false + + + + Disposition Action Date + d:date + false + + + Disposition Events Eligible + d:boolean + false + + + Disposition Action Started At + d:date + false + + + Disposition Action Started By + d:text + false + + true + false + false + + + + Disposition Action Completed At + d:date + false + + + Disposition Action Copmleted By + d:text + false + + true + false + false + + + + + + + + + Event executions + + false + false + + + rma:eventExecution + false + true + + + + + + + rma:filePlanComponent + + + + + + + Event Execution + Execution details of an event + cm:cmobject + + + + + Event Name + d:text + true + + true + false + false + + + + Event automatic + d:boolean + true + + + Event complete + d:boolean + true + false + + + Event completed by + d:text + false + + true + false + false + + + + Event completed at + d:date + false + + + + + + rma:filePlanComponent + + + + + + Hold + rma:recordsManagementContainer + false + + + + + Hold Reason + d:text + true + + + + + + + Frozen Records + + false + true + + + rma:filePlanComponent + false + true + + + + + + + + + Transfer + cm:folder + false + + + + + Transfer Accession Indicator + d:boolean + true + true + + + + Transfer PDF Indicator + Indicates that transfer includes PDF + d:boolean + true + false + + + + Transfer PDF Indicator + Transfer Location + d:text + + + + + + + + Transferred + + false + false + + + rma:dispositionLifecycle + false + true + + + + + + + cm:titled + rma:filePlanComponent + + + + + + + + + + + + File Plan Component + false + + + Root node reference + d:noderef + true + + + + + + + Records Management Root + + + + + Holds + + false + false + + + rma:hold + false + true + + + + + + Transfers + + false + false + + + rma:transfer + false + true + + + + + + + + Declared Record + + + Date Declared + d:date + + + Declared By + d:text + + true + false + false + + + + + rma:filePlanComponent + + + + + Record component identifier + + + Record Component Identifier + d:text + true + + true + false + false + + + + Database uniqueness id + d:text + true + false + + + + rma:filePlanComponent + + + + + Vital Record Definition + + + Review Period + d:period + none|0 + + + Vital Record Indicator + d:boolean + false + + + + rma:filePlanComponent + + + + + + + Record + + false + + + + + + + + Date Filed + d:date + + + + Original Name + d:text + true + + + + + + + + d:date + false + + + d:text + false + + true + false + false + + + + d:text + false + + true + false + false + + + + d:text + false + + true + false + false + + + + d:text + false + + true + false + false + + + + d:date + false + + + d:text + false + + true + false + false + + + + d:text + false + + true + false + false + + + + + + + cm:titled + rma:recordComponentIdentifier + rma:commonRecordDetails + rma:filePlanComponent + + + + + + + + + + + + + + Location + d:text + false + + true + false + false + + + + + + rma:filePlanComponent + + + + + + + + + d:any + true + + + d:any + true + + + + + + + + Vital Record + + + Next Review Date + d:date + false + + + Indicates whether a notification that this record is due for review has been issued + d:boolean + true + false + false + + + + rma:filePlanComponent + + + + + Scheduled + + + + Disposition Schedule + + false + false + + + rma:dispositionSchedule + false + false + + + + + + rma:filePlanComponent + + + + + Disposition Lifecycle + + + + Next disposition action + + false + false + + + rma:dispositionAction + false + false + + + + + + Disposition Action History + + false + false + + + rma:dispositionAction + false + true + + + + + + rma:filePlanComponent + + + + + + Cut Off + + + Cut Off Date + d:date + true + + + + + + Uncut Off + + + + + Transferring + + + + + Transferred + + + + + Ascended + + + + Frozen + + + Frozen At Date + d:date + true + + + Frozen By + d:text + true + + true + false + false + + + + + + + Caveat Config Root + + + + true + false + + + rma:caveatConfig + false + false + + false + + + + + + Email Config Root + + + + true + false + + + rma:emailConfig + false + false + + false + + + + + + + + Record Search + + + d:boolean + true + + + d:text + true + + true + false + false + + + + d:date + true + + + d:text + true + + true + false + false + + + + d:text + true + + true + false + false + + + + d:boolean + true + + + d:text + true + true + + true + false + false + + + + d:text + true + + true + false + false + + + + d:text + true + + + + d:text + true + + + d:text + true + + true + false + false + + + + d:text + true + + true + false + false + + + + + + + Versioned Record + + + + Unpublished Update + + + d:boolean + true + true + + + d:text + + + d:any + + + d:boolean + true + false + + + + + + + Ghosted Record + false + + + + + Loaded Data Set Id + + + List of the loaded Data Set Ids + d:text + true + + + + + + + The originating details of a record + + + d:text + true + + + d:date + true + + + d:noderef + true + + + + + + + The rejection details of a record + + + d:text + true + + + d:date + true + + + d:text + true + + + + + + + + Held children + + + d:int + true + true + 0 + + + + + + + Countable aspect + + + d:int + true + true + 0 + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsPermissionModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsPermissionModel.xml index 59017fcf50..d545517f44 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsPermissionModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsPermissionModel.xml @@ -1,497 +1,497 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/reportModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/reportModel.xml index a69c725725..d2d67043a6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/reportModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/reportModel.xml @@ -1,51 +1,51 @@ - - - - - - - - - Records Management Report Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - - Report - cm:content - - - Destruction Report - rmr:report - - - Transfer Report - rmr:report - - - Hold Report - rmr:report - - - + + + + + + + + + Records Management Report Model + Roy Wetherall + 1.0 + + + + + + + + + + + + + + + + + + + + + + + Report + cm:content + + + Destruction Report + rmr:report + + + Transfer Report + rmr:report + + + Hold Report + rmr:report + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/rm-model-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/rm-model-security-context.xml index 648d308704..d97f736648 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/rm-model-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/rm-model-security-context.xml @@ -1,162 +1,162 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml index 962083afce..da7b0a2c4d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -1,241 +1,241 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /${spaces.company_home.childname}/${spaces.dictionary.childname} - alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml - - - - - - - - - - - - - - - - alfresco.module.org_alfresco_module_rm.messages.notification-service - alfresco.module.org_alfresco_module_rm.messages.admin-service - alfresco.module.org_alfresco_module_rm.messages.records-management-service - alfresco.module.org_alfresco_module_rm.messages.action-service - alfresco.module.org_alfresco_module_rm.messages.audit-service - alfresco.module.org_alfresco_module_rm.messages.rm-events - alfresco.module.org_alfresco_module_rm.messages.capability-service - alfresco.module.org_alfresco_module_rm.messages.dataset-service - alfresco.module.org_alfresco_module_rm.messages.rm-system - alfresco.module.org_alfresco_module_rm.messages.template - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rmService - - - - - - - - - - - - - - - - - - - - - - caveatConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EEE, d MMM yyyy HH:mm:ss Z - EEE, d MMM yy HH:mm:ss Z - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /${spaces.company_home.childname}/${spaces.dictionary.childname} + alfresco/module/org_alfresco_module_rm/bootstrap/RMDataDictionaryBootstrap.xml + + + + + + + + + + + + + + + + alfresco.module.org_alfresco_module_rm.messages.notification-service + alfresco.module.org_alfresco_module_rm.messages.admin-service + alfresco.module.org_alfresco_module_rm.messages.records-management-service + alfresco.module.org_alfresco_module_rm.messages.action-service + alfresco.module.org_alfresco_module_rm.messages.audit-service + alfresco.module.org_alfresco_module_rm.messages.rm-events + alfresco.module.org_alfresco_module_rm.messages.capability-service + alfresco.module.org_alfresco_module_rm.messages.dataset-service + alfresco.module.org_alfresco_module_rm.messages.rm-system + alfresco.module.org_alfresco_module_rm.messages.template + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rmService + + + + + + + + + + + + + + + + + + + + + + caveatConfig + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EEE, d MMM yyyy HH:mm:ss Z + EEE, d MMM yy HH:mm:ss Z + + + + + + + + + + + + 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 19d6ed89dd..4bbb56b282 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 @@ -1,11 +1,11 @@ -# Alfresco Records Management Module -module.id=org_alfresco_module_rm - -# 23/02/2012 - Renamed -module.aliases=org_alfresco_module_dod5015 - -module.title=Records Management -module.description=Alfresco Record Management Extension -module.version=2.3 - +# Alfresco Records Management Module +module.id=org_alfresco_module_rm + +# 23/02/2012 - Renamed +module.aliases=org_alfresco_module_dod5015 + +module.title=Records Management +module.description=Alfresco Record Management Extension +module.version=2.3 + module.repo.version.min=4.2.2 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml index 784324a4ce..6e089b6f92 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml @@ -1,45 +1,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml index 863cc68bac..985a809082 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml @@ -1,66 +1,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml index 3652efbb00..aa0a740c59 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml @@ -1,107 +1,107 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v22-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v22-context.xml index ebe66b66e7..039ab39125 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v22-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v22-context.xml @@ -1,106 +1,106 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${rm.ghosting.enabled} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${rm.ghosting.enabled} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v23-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v23-context.xml index ac52237135..1600a1b836 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v23-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v23-context.xml @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index 3b050f6164..e3f1c1a89d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml index bc08a1ec1b..8144e44bf6 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml @@ -1,13 +1,13 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml index 69f8fb517c..59f1687234 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml @@ -1,24 +1,24 @@ - - - - - - - - classpath:alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml - - - - - - - - - - - - - + + + + + + + + classpath:alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMapConfig.xml + + + + + + + + + + + + + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index 87ddf5dfef..5a35561a63 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -1,1153 +1,1153 @@ - - - - - - - - - - alfresco.module.org_alfresco_module_rm.messages.rm-actions - - - - - - - - - RECORD_CATEGORY - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - js - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction - org.alfresco.repo.action.executer.ActionExecuter - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ApproveRecordsScheduledForCutoff - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ApproveRecordsScheduledForCutoff - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.Destroy - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - ${rm.ghosting.enabled} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ReOpenFolders - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CloseFolders - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CycleVitalRecords - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM.Declare.0 - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.UndeclareRecords - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.PlanningReviewCycles - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ManuallyChangeDispositionDates - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AddModifyEventDates - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AddModifyEventDates - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AuthorizeAllTransfers - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AuthorizeNominatedTransfers - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CreateModifyDestroyFileplanMetadata - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.RejectRecords - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.FileUnfiledRecords - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.rmCopy - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.rmMove - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.LinkToRecords - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.DeleteLinks - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${spaces.store} - - - /${spaces.company_home.childname} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.DeleteHold - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ExtendRetentionPeriodOrFreeze - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.Unfreeze - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ViewUpdateReasonsForFreeze - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW - org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW - - - - - - - - - + + + + + + + + + + alfresco.module.org_alfresco_module_rm.messages.rm-actions + + + + + + + + + RECORD_CATEGORY + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction + org.alfresco.repo.action.executer.ActionExecuter + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ApproveRecordsScheduledForCutoff + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ApproveRecordsScheduledForCutoff + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.Destroy + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + ${rm.ghosting.enabled} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ReOpenFolders + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CloseFolders + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CycleVitalRecords + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM.Declare.0 + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.UndeclareRecords + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.PlanningReviewCycles + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ManuallyChangeDispositionDates + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AddModifyEventDates + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AddModifyEventDates + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AuthorizeAllTransfers + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.AuthorizeNominatedTransfers + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.CreateModifyDestroyFileplanMetadata + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.RejectRecords + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.FileUnfiledRecords + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.rmCopy + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.rmMove + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.LinkToRecords + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.DeleteLinks + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${spaces.store} + + + /${spaces.company_home.childname} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.DeleteHold + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ExtendRetentionPeriodOrFreeze + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.Unfreeze + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.ViewUpdateReasonsForFreeze + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml index 6f3d2bf7c9..61c53f3c6b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml @@ -1,95 +1,95 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 97d7422e3a..b2491bc092 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 @@ -1,156 +1,156 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-deprecated-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-deprecated-context.xml index 7a855c5149..cc663d4f93 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-deprecated-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-deprecated-context.xml @@ -1,136 +1,136 @@ - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.RecordsManagementService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.RecordsManagementService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-disposition-properties-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-disposition-properties-context.xml index b83ba6243b..6577e35e1f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-disposition-properties-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-disposition-properties-context.xml @@ -1,40 +1,40 @@ - - - - - - - - - - - - - - - - - - cutoff - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + cutoff + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-id-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-id-context.xml index e31aa1708f..7db5343e41 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-id-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-id-context.xml @@ -1,47 +1,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml index c975a79827..c75861026c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml @@ -1,151 +1,151 @@ - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 0/15 * * * ? - - - - - - - org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - - - - - - - - - - - - - - - - - - - - cutoff - retain - - - - - - - - - - - - - - - - - - - - - ${rm.dispositionlifecycletrigger.cronexpression} - - - - - - org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - - - - - - - - - - - - - - - - - - - - 0/30 * * * * ? - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 0/15 * * * ? + + + + + + + org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob + + + + + + + + + + + + + + + + + + + + cutoff + retain + + + + + + + + + + + + + + + + + + + + + ${rm.dispositionlifecycletrigger.cronexpression} + + + + + + org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob + + + + + + + + + + + + + + + + + + + + 0/30 * * * * ? + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 18fe9ee15f..b19c9647fa 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -1,195 +1,195 @@ - - - - - - - - - - - - - alfresco/module/org_alfresco_module_rm/model/recordsModel.xml - - - - - alfresco/module/org_alfresco_module_rm/messages/records-model - - - - - - /app:company_home/app:dictionary/cm:records_management - - - path - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + alfresco/module/org_alfresco_module_rm/model/recordsModel.xml + + + + + alfresco/module/org_alfresco_module_rm/messages/records-model + + + + + + /app:company_home/app:dictionary/cm:records_management + + + path + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml index 13f2102dbe..8b773b3c9b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml @@ -1,176 +1,176 @@ - - - - - - - - - - - - - - - - - - - - - alfresco/model/permissionDefinitions.xml - - - alfresco/model/permissionSchema.dtd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${system.acl.maxPermissionCheckTimeMillis} - - - ${system.acl.maxPermissionChecks} - - - - {http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent - - - - - - - ${system.acl.maxPermissionCheckTimeMillis} - - - ${system.acl.maxPermissionChecks} - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + alfresco/model/permissionDefinitions.xml + + + alfresco/model/permissionSchema.dtd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${system.acl.maxPermissionCheckTimeMillis} + + + ${system.acl.maxPermissionChecks} + + + + {http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent + + + + + + + ${system.acl.maxPermissionCheckTimeMillis} + + + ${system.acl.maxPermissionChecks} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml index 835c39182c..5df936757b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml @@ -1,106 +1,106 @@ - - - - - - - - - - - alfresco/module/org_alfresco_module_rm/model/reportModel.xml - - - - - alfresco/module/org_alfresco_module_rm/messages/report-model - - - - - - - - - - alfresco.module.org_alfresco_module_rm.messages.report-service - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rma:transfer - - - - - - - - - rma:hold - - - - + + + + + + + + + + + alfresco/module/org_alfresco_module_rm/model/reportModel.xml + + + + + alfresco/module/org_alfresco_module_rm/messages/report-model + + + + + + + + + + alfresco.module.org_alfresco_module_rm.messages.report-service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rma:transfer + + + + + + + + + rma:hold + + + + \ No newline at end of file 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 5b25686727..0ed6c73149 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 @@ -1,1649 +1,1649 @@ - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService - - - - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.transfer.TransferService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rma:recordCategory - rma:recordFolder - rma:record - rma:nonElectronicDocument - - - - - - - org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cm:lastThumbnailModification - cm:autoVersion - cm:autoVersionOnUpdateProps - cm:initialVersion - - - - - - - org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.record.RecordService - - - - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService - - - - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thread-Index - messageFrom - messageTo - messageCc - messageSubject - messageSent - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService - - - - customEmailMappingService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.caveatConfigTransactionalCache - - - - - - - - - - {http://www.alfresco.org/model/recordsmanagement/1.0}recordComponentIdentifier - - - - - - - - {http://www.alfresco.org/model/rmcustom/1.0}rmcustom - - - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService - - - - caveatConfigService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.hold.HoldService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - - - - + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService + + + + + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.transfer.TransferService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rma:recordCategory + rma:recordFolder + rma:record + rma:nonElectronicDocument + + + + + + + org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + cm:lastThumbnailModification + cm:autoVersion + cm:autoVersionOnUpdateProps + cm:initialVersion + + + + + + + org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.record.RecordService + + + + + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService + + + + + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Thread-Index + messageFrom + messageTo + messageCc + messageSubject + messageSent + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService + + + + customEmailMappingService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.caveatConfigTransactionalCache + + + + + + + + + + {http://www.alfresco.org/model/recordsmanagement/1.0}recordComponentIdentifier + + + + + + + + {http://www.alfresco.org/model/rmcustom/1.0}rmcustom + + + + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService + + + + caveatConfigService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.hold.HoldService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + 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 5fd806c439..2082b7c9c0 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 @@ -1,926 +1,926 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - RECORD_FOLDER - - - - - - - - - RECORD - - - - - - - - - RECORD_FOLDER - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - - RECORD_CATEGORY - RECORD_FOLDER - RECORD - UNFILED_RECORD_FOLDER - HOLD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD_FOLDER - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - RECORD_CATEGORY - RECORD_FOLDER - RECORD - UNFILED_RECORD_FOLDER - HOLD - - - - - - - - - - FILE_PLAN - RECORD - RECORD_CATEGORY - RECORD_FOLDER - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - HOLD_CONTAINER - HOLD - TRANSFER - TRANSFER_CONTAINER - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - TRANSFER - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - FILE_PLAN - RECORD_CATEGORY - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - - FILE_PLAN - RECORD_CATEGORY - RECORD_FOLDER - - - - - - - - - - - FILE_PLAN - RECORD_CATEGORY - RECORD_FOLDER - - - - - - - - - - - - - TRANSFER - - - - - - - - - - TRANSFER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - RECORD - - - - - - - - - - RECORD - - - - - - - - - - - FILE_PLAN - RECORD_CATEGORY - RECORD_FOLDER - UNFILED_RECORD_CONTAINER - UNFILED_RECORD_FOLDER - - - - - - - - - RECORD - - - - - - - - - - - RECORD_CATEGORY - - - - - - - - - RECORD - RECORD_FOLDER - - - - - - - - - - HOLD_CONTAINER - - - - - - - - - - RECORD - RECORD_FOLDER - - - - - - - - - - RECORD - RECORD_FOLDER - - - - - - - - - - HOLD - - - - - - - - - - HOLD - - - - - - - - - - HOLD - - - - - - - - - - RECORD - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + RECORD_FOLDER + + + + + + + + + RECORD + + + + + + + + + RECORD_FOLDER + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + + RECORD_CATEGORY + RECORD_FOLDER + RECORD + UNFILED_RECORD_FOLDER + HOLD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD_FOLDER + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + RECORD_CATEGORY + RECORD_FOLDER + RECORD + UNFILED_RECORD_FOLDER + HOLD + + + + + + + + + + FILE_PLAN + RECORD + RECORD_CATEGORY + RECORD_FOLDER + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + HOLD_CONTAINER + HOLD + TRANSFER + TRANSFER_CONTAINER + + + + + + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + RECORD_FOLDER + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + TRANSFER + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + FILE_PLAN + RECORD_CATEGORY + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + + FILE_PLAN + RECORD_CATEGORY + RECORD_FOLDER + + + + + + + + + + + FILE_PLAN + RECORD_CATEGORY + RECORD_FOLDER + + + + + + + + + + + + + TRANSFER + + + + + + + + + + TRANSFER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + RECORD + + + + + + + + + + RECORD + + + + + + + + + + + FILE_PLAN + RECORD_CATEGORY + RECORD_FOLDER + UNFILED_RECORD_CONTAINER + UNFILED_RECORD_FOLDER + + + + + + + + + RECORD + + + + + + + + + + + RECORD_CATEGORY + + + + + + + + + RECORD + RECORD_FOLDER + + + + + + + + + + HOLD_CONTAINER + + + + + + + + + + RECORD + RECORD_FOLDER + + + + + + + + + + RECORD + RECORD_FOLDER + + + + + + + + + + HOLD + + + + + + + + + + HOLD + + + + + + + + + + HOLD + + + + + + + + + + RECORD + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-version-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-version-context.xml index d9de79a796..1f755ca57f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-version-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-version-context.xml @@ -1,92 +1,92 @@ - - - - - - - - - - alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + alfresco/module/org_alfresco_module_rm/model/recordableVersionModel.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 728ac66fc5..fedd555546 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 @@ -1,666 +1,666 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${rm.autocompletesuggestion.minfragmentsize} - - - ${rm.autocompletesuggestion.maxsuggestions.path} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${rm.autocompletesuggestion.minfragmentsize} + + + ${rm.autocompletesuggestion.maxsuggestions.path} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-workflow-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-workflow-context.xml index 6f843caa09..5b6dab5093 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-workflow-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-workflow-context.xml @@ -1,27 +1,27 @@ - - - - - - - - - activiti - alfresco/workflow/requestInfo.bpmn20.xml - text/xml - false - - - - - - alfresco/workflow/rmWorkflowModel.xml - - - - - alfresco/workflow/rm-workflow-messages - - - + + + + + + + + + activiti + alfresco/workflow/requestInfo.bpmn20.xml + text/xml + false + + + + + + alfresco/workflow/rmWorkflowModel.xml + + + + + alfresco/workflow/rm-workflow-messages + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json index 6b8ebd547a..5771b8d991 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json @@ -1,225 +1,225 @@ -[ - { - "name" : "ExtendedReaders", - "displayLabel" : "rm.role.extendedReaders", - "isAdmin" : false, - "capabilities" : - [ - "ViewRecords" - ] - }, - { - "name" : "ExtendedWriters", - "displayLabel" : "rm.role.extendedWriters", - "isAdmin" : false, - "capabilities" : - [ - "ViewRecords", - "EditNonRecordMetadata" - ] - }, - { - "name" : "User", - "displayLabel" : "rm.role.user", - "isAdmin" : false, - "capabilities" : - [ - "DeclareRecords", - "ViewRecords" - ] - }, - { - "name" : "PowerUser", - "displayLabel" : "rm.role.powerUser", - "isAdmin" : false, - "capabilities" : - [ - "DeclareRecords", - "ViewRecords", - "CreateRecords", - "CreateModifyDestroyFolders", - "EditRecordMetadata", - "EditNonRecordMetadata", - "AddModifyEventDates", - "CloseFolders", - "DeclareRecordsInClosedFolders", - "ReOpenFolders", - "CycleVitalRecords", - "PlanningReviewCycles", - "RequestRecordInformation", - "FileUnfiledRecords", - "RejectRecords", - "LinkToRecords" - ] - }, - { - "name" : "SecurityOfficer", - "displayLabel" : "rm.role.securityOfficer", - "isAdmin" : false, - "capabilities" : - [ - "DeclareRecords", - "ViewRecords", - "CreateRecords", - "CreateModifyDestroyFolders", - "EditRecordMetadata", - "EditNonRecordMetadata", - "AddModifyEventDates", - "CloseFolders", - "DeclareRecordsInClosedFolders", - "ReOpenFolders", - "CycleVitalRecords", - "PlanningReviewCycles", - "RequestRecordInformation", - "FileUnfiledRecords", - "RejectRecords", - "LinkToRecords", - "ManageAccessControls" - ] - }, - { - "name" : "RecordsManager", - "displayLabel" : "rm.role.recordsManager", - "isAdmin" : false, - "capabilities" : - [ - "DeclareRecords", - "ViewRecords", - "CreateRecords", - "CreateModifyDestroyFolders", - "EditRecordMetadata", - "EditNonRecordMetadata", - "AddModifyEventDates", - "CloseFolders", - "DeclareRecordsInClosedFolders", - "ReOpenFolders", - "CycleVitalRecords", - "PlanningReviewCycles", - "UpdateTriggerDates", - "CreateModifyDestroyEvents", - "ManageAccessRights", - "MoveRecords", - "ChangeOrDeleteReferences", - "DeleteLinks", - "EditDeclaredRecordMetadata", - "ManuallyChangeDispositionDates", - "ApproveRecordsScheduledForCutoff", - "CreateModifyRecordsInCutoffFolders", - "ExtendRetentionPeriodOrFreeze", - "ViewUpdateReasonsForFreeze", - "DestroyRecordsScheduledForDestruction", - "UpdateVitalRecordCycleInformation", - "UndeclareRecords", - "DeclareAuditAsRecord", - "DeleteAudit", - "AuthorizeNominatedTransfers", - "EditSelectionLists", - "AuthorizeAllTransfers", - "CreateModifyDestroyFileplanMetadata", - "CreateAndAssociateSelectionLists", - "AttachRulesToMetadataProperties", - "CreateModifyDestroyFileplanTypes", - "CreateModifyDestroyRecordTypes", - "MakeOptionalParametersMandatory", - "MapEmailMetadata", - "DeleteRecords", - "TriggerAnEvent", - "CreateModifyDestroyRoles", - "PasswordControl", - "EnableDisableAuditByTypes", - "SelectAuditMetadata", - "DisplayRightsReport", - "AccessAudit", - "ExportAudit", - "CreateModifyDestroyReferenceTypes", - "RequestRecordInformation", - "FileDestructionReport", - "FileUnfiledRecords", - "RejectRecords", - "LinkToRecords", - "FileTransferReport", - "CreateHold", - "AddToHold", - "RemoveFromHold", - "FileHoldReport", - "DeleteHold", - "EndRetention", - "EditHold", - "ManageAccessControls" - - ] - }, - { - "name" : "Administrator", - "displayLabel" : "rm.role.administrator", - "isAdmin" : true, - "capabilities" : - [ - "DeclareRecords", - "ViewRecords", - "CreateRecords", - "CreateModifyDestroyFolders", - "EditRecordMetadata", - "EditNonRecordMetadata", - "AddModifyEventDates", - "CloseFolders", - "DeclareRecordsInClosedFolders", - "ReOpenFolders", - "CycleVitalRecords", - "PlanningReviewCycles", - "UpdateTriggerDates", - "CreateModifyDestroyEvents", - "ManageAccessRights", - "MoveRecords", - "ChangeOrDeleteReferences", - "DeleteLinks", - "EditDeclaredRecordMetadata", - "ManuallyChangeDispositionDates", - "ApproveRecordsScheduledForCutoff", - "CreateModifyRecordsInCutoffFolders", - "ExtendRetentionPeriodOrFreeze", - "ViewUpdateReasonsForFreeze", - "DestroyRecordsScheduledForDestruction", - "UpdateVitalRecordCycleInformation", - "UndeclareRecords", - "DeclareAuditAsRecord", - "DeleteAudit", - "AuthorizeNominatedTransfers", - "EditSelectionLists", - "AuthorizeAllTransfers", - "CreateModifyDestroyFileplanMetadata", - "CreateAndAssociateSelectionLists", - "AttachRulesToMetadataProperties", - "CreateModifyDestroyFileplanTypes", - "CreateModifyDestroyRecordTypes", - "MakeOptionalParametersMandatory", - "MapEmailMetadata", - "DeleteRecords", - "TriggerAnEvent", - "CreateModifyDestroyRoles", - "CreateModifyDestroyUsersAndGroups", - "PasswordControl", - "EnableDisableAuditByTypes", - "SelectAuditMetadata", - "DisplayRightsReport", - "AccessAudit", - "ExportAudit", - "CreateModifyDestroyReferenceTypes", - "ManageAccessControls", - "ManageRules", - "RequestRecordInformation", - "FileDestructionReport", - "FileUnfiledRecords", - "RejectRecords", - "LinkToRecords", - "FileTransferReport", - "CreateHold", - "AddToHold", - "RemoveFromHold", - "FileHoldReport", - "DeleteHold", - "EditHold", - "EndRetention" - ] - } +[ + { + "name" : "ExtendedReaders", + "displayLabel" : "rm.role.extendedReaders", + "isAdmin" : false, + "capabilities" : + [ + "ViewRecords" + ] + }, + { + "name" : "ExtendedWriters", + "displayLabel" : "rm.role.extendedWriters", + "isAdmin" : false, + "capabilities" : + [ + "ViewRecords", + "EditNonRecordMetadata" + ] + }, + { + "name" : "User", + "displayLabel" : "rm.role.user", + "isAdmin" : false, + "capabilities" : + [ + "DeclareRecords", + "ViewRecords" + ] + }, + { + "name" : "PowerUser", + "displayLabel" : "rm.role.powerUser", + "isAdmin" : false, + "capabilities" : + [ + "DeclareRecords", + "ViewRecords", + "CreateRecords", + "CreateModifyDestroyFolders", + "EditRecordMetadata", + "EditNonRecordMetadata", + "AddModifyEventDates", + "CloseFolders", + "DeclareRecordsInClosedFolders", + "ReOpenFolders", + "CycleVitalRecords", + "PlanningReviewCycles", + "RequestRecordInformation", + "FileUnfiledRecords", + "RejectRecords", + "LinkToRecords" + ] + }, + { + "name" : "SecurityOfficer", + "displayLabel" : "rm.role.securityOfficer", + "isAdmin" : false, + "capabilities" : + [ + "DeclareRecords", + "ViewRecords", + "CreateRecords", + "CreateModifyDestroyFolders", + "EditRecordMetadata", + "EditNonRecordMetadata", + "AddModifyEventDates", + "CloseFolders", + "DeclareRecordsInClosedFolders", + "ReOpenFolders", + "CycleVitalRecords", + "PlanningReviewCycles", + "RequestRecordInformation", + "FileUnfiledRecords", + "RejectRecords", + "LinkToRecords", + "ManageAccessControls" + ] + }, + { + "name" : "RecordsManager", + "displayLabel" : "rm.role.recordsManager", + "isAdmin" : false, + "capabilities" : + [ + "DeclareRecords", + "ViewRecords", + "CreateRecords", + "CreateModifyDestroyFolders", + "EditRecordMetadata", + "EditNonRecordMetadata", + "AddModifyEventDates", + "CloseFolders", + "DeclareRecordsInClosedFolders", + "ReOpenFolders", + "CycleVitalRecords", + "PlanningReviewCycles", + "UpdateTriggerDates", + "CreateModifyDestroyEvents", + "ManageAccessRights", + "MoveRecords", + "ChangeOrDeleteReferences", + "DeleteLinks", + "EditDeclaredRecordMetadata", + "ManuallyChangeDispositionDates", + "ApproveRecordsScheduledForCutoff", + "CreateModifyRecordsInCutoffFolders", + "ExtendRetentionPeriodOrFreeze", + "ViewUpdateReasonsForFreeze", + "DestroyRecordsScheduledForDestruction", + "UpdateVitalRecordCycleInformation", + "UndeclareRecords", + "DeclareAuditAsRecord", + "DeleteAudit", + "AuthorizeNominatedTransfers", + "EditSelectionLists", + "AuthorizeAllTransfers", + "CreateModifyDestroyFileplanMetadata", + "CreateAndAssociateSelectionLists", + "AttachRulesToMetadataProperties", + "CreateModifyDestroyFileplanTypes", + "CreateModifyDestroyRecordTypes", + "MakeOptionalParametersMandatory", + "MapEmailMetadata", + "DeleteRecords", + "TriggerAnEvent", + "CreateModifyDestroyRoles", + "PasswordControl", + "EnableDisableAuditByTypes", + "SelectAuditMetadata", + "DisplayRightsReport", + "AccessAudit", + "ExportAudit", + "CreateModifyDestroyReferenceTypes", + "RequestRecordInformation", + "FileDestructionReport", + "FileUnfiledRecords", + "RejectRecords", + "LinkToRecords", + "FileTransferReport", + "CreateHold", + "AddToHold", + "RemoveFromHold", + "FileHoldReport", + "DeleteHold", + "EndRetention", + "EditHold", + "ManageAccessControls" + + ] + }, + { + "name" : "Administrator", + "displayLabel" : "rm.role.administrator", + "isAdmin" : true, + "capabilities" : + [ + "DeclareRecords", + "ViewRecords", + "CreateRecords", + "CreateModifyDestroyFolders", + "EditRecordMetadata", + "EditNonRecordMetadata", + "AddModifyEventDates", + "CloseFolders", + "DeclareRecordsInClosedFolders", + "ReOpenFolders", + "CycleVitalRecords", + "PlanningReviewCycles", + "UpdateTriggerDates", + "CreateModifyDestroyEvents", + "ManageAccessRights", + "MoveRecords", + "ChangeOrDeleteReferences", + "DeleteLinks", + "EditDeclaredRecordMetadata", + "ManuallyChangeDispositionDates", + "ApproveRecordsScheduledForCutoff", + "CreateModifyRecordsInCutoffFolders", + "ExtendRetentionPeriodOrFreeze", + "ViewUpdateReasonsForFreeze", + "DestroyRecordsScheduledForDestruction", + "UpdateVitalRecordCycleInformation", + "UndeclareRecords", + "DeclareAuditAsRecord", + "DeleteAudit", + "AuthorizeNominatedTransfers", + "EditSelectionLists", + "AuthorizeAllTransfers", + "CreateModifyDestroyFileplanMetadata", + "CreateAndAssociateSelectionLists", + "AttachRulesToMetadataProperties", + "CreateModifyDestroyFileplanTypes", + "CreateModifyDestroyRecordTypes", + "MakeOptionalParametersMandatory", + "MapEmailMetadata", + "DeleteRecords", + "TriggerAnEvent", + "CreateModifyDestroyRoles", + "CreateModifyDestroyUsersAndGroups", + "PasswordControl", + "EnableDisableAuditByTypes", + "SelectAuditMetadata", + "DisplayRightsReport", + "AccessAudit", + "ExportAudit", + "CreateModifyDestroyReferenceTypes", + "ManageAccessControls", + "ManageRules", + "RequestRecordInformation", + "FileDestructionReport", + "FileUnfiledRecords", + "RejectRecords", + "LinkToRecords", + "FileTransferReport", + "CreateHold", + "AddToHold", + "RemoveFromHold", + "FileHoldReport", + "DeleteHold", + "EditHold", + "EndRetention" + ] + } ] \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security-context.xml index 6931347171..1d500571ab 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security-context.xml @@ -1,20 +1,20 @@ - - - - - - - - - classpath*:alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties - - classpath*:alfresco/extension/rm-method-security.properties - - - - - - - - + + + + + + + + + classpath*:alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties + + classpath*:alfresco/extension/rm-method-security.properties + + + + + + + + \ No newline at end of file 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 385b0d397e..350505fa84 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties @@ -1,228 +1,228 @@ -## -# RM Method security for Alfresco code services -# -# Note: add alfresco/extension/rm-method-security.properties to extend -## - -## Node Service - -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStores=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createStore=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.exists=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeStatus=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAllRootNodes=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getRootNode=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createNode=RM.Create.0.3 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.moveNode=RM.Move.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getType=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setType=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addAspect=RM.Update.0.1.2 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAspect=RM.Update.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.hasAspect=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAspects=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.deleteNode=RM.Delete.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addChild=RM.Create.0.1.2 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChild=RM.Delete.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChildAssociation=RM.Delete.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperties=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperty=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperties=RM.UpdateProperties.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addProperties=RM.UpdateProperties.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperty=RM.UpdateProperties.0.1.2 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeProperty=RM.UpdateProperties.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getParentAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getParentAssocs=RM.Read.0.1.2 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocs=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildByName=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildrenByName=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPrimaryParent=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createAssociation=RM.Assoc.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=Assoc.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getTargetAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getSourceAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAssoc=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPath=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPaths=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.restoreNode=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsWithoutParentAssocsOfType=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeRef=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsByPropertyValue=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.countChildAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeAclId=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.*=RM_DENY - -## File Folder Service - -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.list=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFiles=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFolders=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listDeepFolders=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getLocalizedSibling=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.search=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.searchSimple=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.rename=RM.Update.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.move=RM.Move.0.1 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.moveFrom=RM.Move.0.2 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.copy=RM.Read.0,RM.Create.1.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.create=RM.Create.0 -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 - -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreTotalSpace=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreFreeSpace=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getRawReader=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getReader=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getWriter=RM.WriteContent.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.isTransformable=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTransformer=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getMaxSourceSizeBytes=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getImageTransformer=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.transform=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTempWriter=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.*=RM_DENY - -## Search Service - -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.query=RM_QUERY,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectNodes=RM_QUERY,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectProperties=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.contains=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.like=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.*=RM_DENY - -## Category Service - -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getChildren=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getCategories=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassifications=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getRootCategories=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassificationAspects=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createClassification=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createRootCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteClassification=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getTopCategories=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.*=RM_DENY - -## Lock Service - -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.lock=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.unlock=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockStatus=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY - -## Multilingual Content Service - -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationForLocale=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getMissingTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getPivotTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.isTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.makeTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.unmakeTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addEmptyTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.copyTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.moveTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.deleteTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.*=RM_DENY - -## Edition Service - -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.createEdition=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getEditions=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedMetadatas=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.*=RM_DENY - -## Check Out Check In Service - -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkout=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkin=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.cancelCheckout=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getWorkingCopy=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getCheckedOut=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isWorkingCopy=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isCheckedOut=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.*=RM_DENY - -## Permission Service - -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllPermission=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getPermissions=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.hasPermission=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.*=RM_DENY - -## Site service - -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.cleanSitePermissions=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.createContainer=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.createSite=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.deleteSite=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.findSites=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getContainer=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRole=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRoleInfo=ACL_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSite=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteGroup=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoleGroup=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoles=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoot=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasContainer=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasCreateSitePermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.isMember=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembers=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembersInfo=ACL_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listSites=RM_ALLOW,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.removeMembership=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.setMembership=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.updateSite=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembersPaged=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listContainers=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.countAuthoritiesWithRole=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.resolveSite=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasSite=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listSitesPaged=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteShortName=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.canAddMember=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.*=RM_ALLOW - -## Form Service - -rm.methodsecurity.org.alfresco.repo.forms.FormService.getForm=RM_ALLOW -rm.methodsecurity.org.alfresco.repo.forms.FormService.saveForm=RM_ALLOW -rm.methodsecurity.org.alfresco.repo.forms.FormService.*=RM_DENY - -## Ownable Service - -rm.methodsecurity.org.alfresco.service.cmr.security.OwnableService.getOwner=RM.Read.0 +## +# RM Method security for Alfresco code services +# +# Note: add alfresco/extension/rm-method-security.properties to extend +## + +## Node Service + +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStores=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createStore=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.exists=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeStatus=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAllRootNodes=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getRootNode=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createNode=RM.Create.0.3 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.moveNode=RM.Move.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getType=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setType=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addAspect=RM.Update.0.1.2 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAspect=RM.Update.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.hasAspect=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAspects=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.deleteNode=RM.Delete.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addChild=RM.Create.0.1.2 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChild=RM.Delete.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChildAssociation=RM.Delete.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperties=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperty=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperties=RM.UpdateProperties.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addProperties=RM.UpdateProperties.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperty=RM.UpdateProperties.0.1.2 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeProperty=RM.UpdateProperties.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getParentAssocs=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getParentAssocs=RM.Read.0.1.2 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocs=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildByName=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildrenByName=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPrimaryParent=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createAssociation=RM.Assoc.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=Assoc.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getTargetAssocs=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getSourceAssocs=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAssoc=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPath=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPaths=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.restoreNode=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsWithoutParentAssocsOfType=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeRef=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsByPropertyValue=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.countChildAssocs=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeAclId=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.*=RM_DENY + +## File Folder Service + +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.list=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFiles=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFolders=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listDeepFolders=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getLocalizedSibling=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.search=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.searchSimple=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.rename=RM.Update.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.move=RM.Move.0.1 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.moveFrom=RM.Move.0.2 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.copy=RM.Read.0,RM.Create.1.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.create=RM.Create.0 +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 + +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreTotalSpace=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreFreeSpace=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getRawReader=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getReader=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getWriter=RM.WriteContent.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.isTransformable=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTransformer=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getMaxSourceSizeBytes=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getImageTransformer=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.transform=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTempWriter=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.*=RM_DENY + +## Search Service + +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.query=RM_QUERY,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectNodes=RM_QUERY,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectProperties=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.contains=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.like=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.*=RM_DENY + +## Category Service + +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getChildren=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassifications=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getRootCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassificationAspects=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createClassification=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createRootCategory=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createCategory=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteClassification=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteCategory=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getTopCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.*=RM_DENY + +## Lock Service + +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.lock=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.unlock=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockStatus=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY + +## Multilingual Content Service + +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslations=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationForLocale=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getMissingTranslations=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getPivotTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.isTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.makeTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.unmakeTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addEmptyTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.copyTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.moveTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.deleteTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.*=RM_DENY + +## Edition Service + +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.createEdition=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getEditions=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedTranslations=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedMetadatas=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.*=RM_DENY + +## Check Out Check In Service + +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkout=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkin=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.cancelCheckout=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getWorkingCopy=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getCheckedOut=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isWorkingCopy=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isCheckedOut=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.*=RM_DENY + +## Permission Service + +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllPermission=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getPermissions=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.hasPermission=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.*=RM_DENY + +## Site service + +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.cleanSitePermissions=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.createContainer=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.createSite=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.deleteSite=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.findSites=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getContainer=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRole=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRoleInfo=ACL_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSite=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteGroup=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoleGroup=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoles=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoot=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasContainer=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasCreateSitePermissions=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.isMember=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembers=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembersInfo=ACL_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listSites=RM_ALLOW,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.removeMembership=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.setMembership=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.updateSite=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembersPaged=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listContainers=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.countAuthoritiesWithRole=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.resolveSite=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasSite=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listSitesPaged=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteShortName=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.canAddMember=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.*=RM_ALLOW + +## Form Service + +rm.methodsecurity.org.alfresco.repo.forms.FormService.getForm=RM_ALLOW +rm.methodsecurity.org.alfresco.repo.forms.FormService.saveForm=RM_ALLOW +rm.methodsecurity.org.alfresco.repo.forms.FormService.*=RM_DENY + +## Ownable Service + +rm.methodsecurity.org.alfresco.service.cmr.security.OwnableService.getOwner=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.security.OwnableService.*=RM_DENY \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.delete.desc.xml index 6bd7f8162d..14851a41bc 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.delete.desc.xml @@ -1,12 +1,12 @@ - - Remove a group or a user from a role - - - /api/rm/roles/{roleId}/authorities/{authorityName} - /api/rm/{store_type}/{store_id}/{id}/roles/{roleId}/authorities/{authorityName} - argument - user - required + + Remove a group or a user from a role + + + /api/rm/roles/{roleId}/authorities/{authorityName} + /api/rm/{store_type}/{store_id}/{id}/roles/{roleId}/authorities/{authorityName} + argument + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.post.desc.xml index 75ee4da9dc..d5a0810210 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-authorities.post.desc.xml @@ -1,12 +1,12 @@ - - Add a group or a user to a role - - - /api/rm/roles/{roleId}/authorities/{authorityName} - /api/rm/{store_type}/{store_id}/{id}/roles/{roleId}/authorities/{authorityName} - argument - user - required + + Add a group or a user to a role + + + /api/rm/roles/{roleId}/authorities/{authorityName} + /api/rm/{store_type}/{store_id}/{id}/roles/{roleId}/authorities/{authorityName} + argument + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actionconditiondefinitions.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actionconditiondefinitions.get.desc.xml index 8627529e25..64948ba800 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actionconditiondefinitions.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actionconditiondefinitions.get.desc.xml @@ -1,8 +1,8 @@ - - Get action condition definition collection for RM - Gets a collection of the available action condition definitions in RM. - /api/rm/rm-actionconditiondefinitions - argument - user - required + + Get action condition definition collection for RM + Gets a collection of the available action condition definitions in RM. + /api/rm/rm-actionconditiondefinitions + argument + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actiondefinitions.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actiondefinitions.get.desc.xml index f55b3246e8..b51593347e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actiondefinitions.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rm-actiondefinitions.get.desc.xml @@ -1,8 +1,8 @@ - - Get action definition collection for RM - Gets a collection of the available action definitions in RM. - /api/rm/rm-actiondefinitions - argument - user - required + + Get action definition collection for RM + Gets a collection of the available action definitions in RM. + /api/rm/rm-actiondefinitions + argument + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/substitutionsuggestions/rm-substitutionsuggestions.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/substitutionsuggestions/rm-substitutionsuggestions.get.desc.xml index b77167b3c0..8665f19ad7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/substitutionsuggestions/rm-substitutionsuggestions.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/substitutionsuggestions/rm-substitutionsuggestions.get.desc.xml @@ -1,8 +1,8 @@ - - Get substitution suggestions for RM - Gets a collection of substitution suggestions for a text fragment for RM. - /api/rm/rm-substitutionsuggestions?fragment={fragment}&path={path?} - argument - user - required + + Get substitution suggestions for RM + Gets a collection of substitution suggestions for a text fragment for RM. + /api/rm/rm-substitutionsuggestions?fragment={fragment}&path={path?} + argument + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.desc.xml index 2c7c93f48d..54d1a8bf5d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.desc.xml @@ -1,8 +1,8 @@ - - Node Version Info - Node Version Info including some RM related information - /api/rm/rm-version - - user - required - + + Node Version Info + Node Version Info including some RM related information + /api/rm/rm-version + + user + required + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.js index 6f7babb711..76b59ddbb0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.js @@ -1,125 +1,125 @@ -var PeopleCache = {}; - -/** - * Gets / caches a person object - * @method getPerson - * @param username {string} User name - */ -function getPerson(username) -{ - if (typeof PeopleCache[username] == "undefined") - { - var person = people.getPerson(username); - if (person == null) - { - if (username == "System" || username.match("^System@") == "System@") - { - // special case for the System users - person = - { - properties: - { - userName: "System", - firstName: "System", - lastName: "User" - }, - assocs: {} - }; - } - else - { - // missing person - may have been deleted from the database - person = - { - properties: - { - userName: username, - firstName: "", - lastName: "" - }, - assocs: {} - }; - } - } - PeopleCache[username] = - { - userName: person.properties.userName, - firstName: person.properties.firstName, - lastName: person.properties.lastName, - displayName: (person.properties.firstName + " " + person.properties.lastName).replace(/^\s+|\s+$/g, "") - }; - } - return PeopleCache[username]; -} - -function main() -{ - var json = "", - versions = []; - - // allow for content to be loaded from id - if (args["nodeRef"] != null) - { - var nodeRef = args["nodeRef"], - node = search.findNode(nodeRef), - versionHistory, version, p, recordNodeRef, isRecordedVersionDestroyed; - - if (node != null) - { - var versionHistory = node.versionHistory; - if (versionHistory != null) - { - for (i = 0; i < versionHistory.length; i++) - { - version = versionHistory[i]; - p = getPerson(version.creator); - - recordNodeRef = version.getVersionProperty("recordNodeRef"); - isRecordedVersionDestroyed = version.getVersionProperty("RecordedVersionDestroyed"); - - versions[versions.length] = - { - nodeRef: version.node.nodeRef.toString(), - name: (isRecordedVersionDestroyed == true) ? "" : version.node.name, - label: version.label, - description: version.description, - createdDate: version.createdDate, - creator: - { - userName: p.userName, - firstName: p.firstName, - lastName: p.lastName - }, - recordNodeRef: recordNodeRef ? recordNodeRef.toString() : "", - isRecordedVersionDestroyed: isRecordedVersionDestroyed - }; - } - } - else - { - p = getPerson(node.properties.creator); - versions[0] = - { - nodeRef: node.nodeRef.toString(), - name: node.name, - label: "1.0", - description: "", - createdDate: node.properties.created, - creator: - { - userName: p.userName, - firstName: p.firstName, - lastName: p.lastName - }, - recordNodeRef: "", - isRecordedVersionDestroyed: false - }; - } - } - } - - // store node onto model - model.versions = versions; -} - +var PeopleCache = {}; + +/** + * Gets / caches a person object + * @method getPerson + * @param username {string} User name + */ +function getPerson(username) +{ + if (typeof PeopleCache[username] == "undefined") + { + var person = people.getPerson(username); + if (person == null) + { + if (username == "System" || username.match("^System@") == "System@") + { + // special case for the System users + person = + { + properties: + { + userName: "System", + firstName: "System", + lastName: "User" + }, + assocs: {} + }; + } + else + { + // missing person - may have been deleted from the database + person = + { + properties: + { + userName: username, + firstName: "", + lastName: "" + }, + assocs: {} + }; + } + } + PeopleCache[username] = + { + userName: person.properties.userName, + firstName: person.properties.firstName, + lastName: person.properties.lastName, + displayName: (person.properties.firstName + " " + person.properties.lastName).replace(/^\s+|\s+$/g, "") + }; + } + return PeopleCache[username]; +} + +function main() +{ + var json = "", + versions = []; + + // allow for content to be loaded from id + if (args["nodeRef"] != null) + { + var nodeRef = args["nodeRef"], + node = search.findNode(nodeRef), + versionHistory, version, p, recordNodeRef, isRecordedVersionDestroyed; + + if (node != null) + { + var versionHistory = node.versionHistory; + if (versionHistory != null) + { + for (i = 0; i < versionHistory.length; i++) + { + version = versionHistory[i]; + p = getPerson(version.creator); + + recordNodeRef = version.getVersionProperty("recordNodeRef"); + isRecordedVersionDestroyed = version.getVersionProperty("RecordedVersionDestroyed"); + + versions[versions.length] = + { + nodeRef: version.node.nodeRef.toString(), + name: (isRecordedVersionDestroyed == true) ? "" : version.node.name, + label: version.label, + description: version.description, + createdDate: version.createdDate, + creator: + { + userName: p.userName, + firstName: p.firstName, + lastName: p.lastName + }, + recordNodeRef: recordNodeRef ? recordNodeRef.toString() : "", + isRecordedVersionDestroyed: isRecordedVersionDestroyed + }; + } + } + else + { + p = getPerson(node.properties.creator); + versions[0] = + { + nodeRef: node.nodeRef.toString(), + name: node.name, + label: "1.0", + description: "", + createdDate: node.properties.created, + creator: + { + userName: p.userName, + firstName: p.firstName, + lastName: p.lastName + }, + recordNodeRef: "", + isRecordedVersionDestroyed: false + }; + } + } + } + + // store node onto model + model.versions = versions; +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.json.ftl index 773b1421e0..6e6f691284 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/version/rm-version.get.json.ftl @@ -1,22 +1,22 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -[ -<#list versions as v> - { - "nodeRef": "${v.nodeRef}", - "name": "${v.name}", - "label": "${v.label}", - "description": "${v.description}", - "createdDate": "${v.createdDate?string("dd MMM yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "createdDateISO": "${xmldate(v.createdDate)}", - "creator": - { - "userName": "${v.creator.userName}", - "firstName": "${v.creator.firstName!""}", - "lastName": "${v.creator.lastName!""}" - }, - "recordNodeRef": "${v.recordNodeRef}", - "isRecordedVersionDestroyed": ${v.isRecordedVersionDestroyed?c} - }<#if (v_has_next)>, - -] +<#escape x as jsonUtils.encodeJSONString(x)> +[ +<#list versions as v> + { + "nodeRef": "${v.nodeRef}", + "name": "${v.name}", + "label": "${v.label}", + "description": "${v.description}", + "createdDate": "${v.createdDate?string("dd MMM yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", + "createdDateISO": "${xmldate(v.createdDate)}", + "creator": + { + "userName": "${v.creator.userName}", + "firstName": "${v.creator.firstName!""}", + "lastName": "${v.creator.lastName!""}" + }, + "recordNodeRef": "${v.recordNodeRef}", + "isRecordedVersionDestroyed": ${v.isRecordedVersionDestroyed?c} + }<#if (v_has_next)>, + +] \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.desc.xml index 40af72f2cb..50fd1191b0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.desc.xml @@ -1,15 +1,15 @@ - - Delete email property map - - DELETE /api/rma/admin/emailmap/{from}/{to} deletes the specified mapping - Returns data in the same format as the get method - ]]> - - /api/rma/admin/emailmap/{from}/{to} - argument - user - required - internal + + Delete email property map + + DELETE /api/rma/admin/emailmap/{from}/{to} deletes the specified mapping + Returns data in the same format as the get method + ]]> + + /api/rma/admin/emailmap/{from}/{to} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.json.ftl index d798509bc0..cf6cca433f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.delete.json.ftl @@ -1,7 +1,7 @@ -<#import "emailmap.lib.ftl" as emailmapLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> -} +<#import "emailmap.lib.ftl" as emailmapLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.desc.xml index 1a8bd1a92e..1aeeb1fdc6 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.desc.xml @@ -1,29 +1,29 @@ - - Get the custom email property map - - fields are specified with "from" and "to". -
- Example data. -
-      "mappings":
-      [
-         {"from" : "messageTo", "to" : "imap:messageTo" } ,
-         {"from" : "Thread-Index", "to" : "imap:threadIndex" } ,
-         {"from" : "messageFrom", "to" : "imap:messageFrom" } ,
-         {"from" : "messageSubject", "to" : "cm:title" } ,
-         {"from" : "messageSubject", "to" : "imap:messageSubject" } ,
-         {"from" : "messageSubject", "to" : "cm:description" } ,
-         {"from" : "messageCc", "to" : "imap:messageCc" } ,
-         {"from" : "Message-ID", "to" : "imap:messageId" }
-      ]
-   
- ]]> -
- /api/rma/admin/emailmap - argument - user - required - internal + + Get the custom email property map + + fields are specified with "from" and "to". +
+ Example data. +
+      "mappings":
+      [
+         {"from" : "messageTo", "to" : "imap:messageTo" } ,
+         {"from" : "Thread-Index", "to" : "imap:threadIndex" } ,
+         {"from" : "messageFrom", "to" : "imap:messageFrom" } ,
+         {"from" : "messageSubject", "to" : "cm:title" } ,
+         {"from" : "messageSubject", "to" : "imap:messageSubject" } ,
+         {"from" : "messageSubject", "to" : "cm:description" } ,
+         {"from" : "messageCc", "to" : "imap:messageCc" } ,
+         {"from" : "Message-ID", "to" : "imap:messageId" }
+      ]
+   
+ ]]> +
+ /api/rma/admin/emailmap + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.json.ftl index d798509bc0..cf6cca433f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.get.json.ftl @@ -1,7 +1,7 @@ -<#import "emailmap.lib.ftl" as emailmapLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> -} +<#import "emailmap.lib.ftl" as emailmapLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.lib.ftl index e857188b9c..1155ed8746 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.lib.ftl @@ -1,14 +1,14 @@ -<#-- renders an email map object --> - -<#macro emailmapJSON emailmap> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "mappings": - [ - <#list emailmap as mapping> - {"from": "${mapping.from}", "to": "${mapping.to}" }<#if mapping_has_next>, - - ] - } - +<#-- renders an email map object --> + +<#macro emailmapJSON emailmap> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "mappings": + [ + <#list emailmap as mapping> + {"from": "${mapping.from}", "to": "${mapping.to}" }<#if mapping_has_next>, + + ] + } + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.desc.xml index cb9073d997..1b4ade6fb7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.desc.xml @@ -1,20 +1,20 @@ - - Add email property map - - Data is specified in JSON format as a JSONObject -
-   {"to":"rmc:Wibble", "from":"whatever"}
-   
-
- POST /api/rma/admin/emailmap adds the specified mapping - Returns data in the same format as the get method - ]]> -
- /api/rma/admin/emailmap - argument - user - required - internal + + Add email property map + + Data is specified in JSON format as a JSONObject +
+   {"to":"rmc:Wibble", "from":"whatever"}
+   
+
+ POST /api/rma/admin/emailmap adds the specified mapping + Returns data in the same format as the get method + ]]> +
+ /api/rma/admin/emailmap + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.json.ftl index d798509bc0..cf6cca433f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmap.post.json.ftl @@ -1,7 +1,7 @@ -<#import "emailmap.lib.ftl" as emailmapLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> -} +<#import "emailmap.lib.ftl" as emailmapLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@emailmapLib.emailmapJSON emailmap=emailmap /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.desc.xml index 888c5f5fb7..84a2019ff9 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.desc.xml @@ -1,9 +1,9 @@ - - RM Email Mapping Keys - Gets the list of email mapping keys - /api/rma/admin/emailmapkeys - argument - user - required - internal + + RM Email Mapping Keys + Gets the list of email mapping keys + /api/rma/admin/emailmapkeys + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.json.ftl index 48e293d18d..dbef6c790c 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/emailmapkeys.get.json.ftl @@ -1,13 +1,13 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data" : - { - "emailmapkeys": - [ - <#list emailmapkeys as emailmapkey> - '${emailmapkey}'<#if emailmapkey_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data" : + { + "emailmapkeys": + [ + <#list emailmapkeys as emailmapkey> + '${emailmapkey}'<#if emailmapkey_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js index 3a56b4a83d..59cc70dd68 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js @@ -1,18 +1,18 @@ -function existsTitle(caveatConfig, title) -{ - var constraints = caveatConfig.allConstraints; - - // Check for existing constraint... - var alreadyExists = false; - for (var i = 0; i < constraints.length; i++) - { - var currTitle = constraints[i].title; - if (currTitle + "" == title) - { - alreadyExists = true; - break; - } - } - - return alreadyExists; +function existsTitle(caveatConfig, title) +{ + var constraints = caveatConfig.allConstraints; + + // Check for existing constraint... + var alreadyExists = false; + for (var i = 0; i < constraints.length; i++) + { + var currTitle = constraints[i].title; + if (currTitle + "" == title) + { + alreadyExists = true; + break; + } + } + + return alreadyExists; } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.desc.xml index 0dd4d5018f..0cbf8f2f2d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.desc.xml @@ -1,13 +1,13 @@ - - Delete an RM Constraint list - - - - /api/rma/admin/rmconstraints/{listName} - argument - user - required - internal + + Delete an RM Constraint list + + + + /api/rma/admin/rmconstraints/{listName} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.js index 3863fdf3b5..9dc82188e1 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.js @@ -1,27 +1,27 @@ -/** - * Delete the rm constraint list - */ -function main() -{ - // Get the shortname - var shortName = url.extension; - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - caveatConfig.deleteConstraintList(shortName); - - // Pass the constraint name to the template - model.constraintName = shortName; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Delete the rm constraint list + */ +function main() +{ + // Get the shortname + var shortName = url.extension; + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + caveatConfig.deleteConstraintList(shortName); + + // Pass the constraint name to the template + model.constraintName = shortName; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.json.ftl index 71ff31ba48..11a87934e8 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.delete.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": { } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": { } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.desc.xml index db15d75311..6caa0bdcae 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.desc.xml @@ -1,22 +1,22 @@ - - Get a RM Constraint method - - - Constraint object -
-
constraintName
the name of the constraint. The underscore character is used instead of the colon
-
constraintTitle
the title of the constraint (human readable)
-
caseSensitive
Are the values case sensitive
-
allowedValues
array of allowed values, this is the complete unrestricted list of all values
-
- ]]> -
- /api/rma/admin/rmconstraints/{listName} - argument - user - required - internal + + Get a RM Constraint method + + + Constraint object +
+
constraintName
the name of the constraint. The underscore character is used instead of the colon
+
constraintTitle
the title of the constraint (human readable)
+
caseSensitive
Are the values case sensitive
+
allowedValues
array of allowed values, this is the complete unrestricted list of all values
+
+ ]]> +
+ /api/rma/admin/rmconstraints/{listName} + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.js index 3abedfd921..a568b280cb 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.js @@ -1,25 +1,25 @@ -/** - * Get the detail of the rm constraint - */ -function main() -{ - // Get the shortname - var shortName = url.extension; - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - // Pass the constraint detail to the template - model.constraint = constraint; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Get the detail of the rm constraint + */ +function main() +{ + // Get the shortname + var shortName = url.extension; + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + // Pass the constraint detail to the template + model.constraint = constraint; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.json.ftl index d01eb83470..e30dee6a49 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.get.json.ftl @@ -1,8 +1,8 @@ -<#import "rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@rmconstraintLib.constraintJSON constraint=constraint /> - -} +<#import "rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@rmconstraintLib.constraintJSON constraint=constraint /> + +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.lib.ftl index e510863426..5aadbbb3b3 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.lib.ftl @@ -1,61 +1,61 @@ -<#-- renders an rm constraint object --> - -<#macro constraintSummaryJSON constraint> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", - "constraintName" : "${constraint.name}", - "constraintTitle" : "${msg(constraint.title)}" - } - - - -<#macro constraintJSON constraint> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", - "constraintName" : "${constraint.name}", - "caseSensitive" : "${constraint.caseSensitive?string("true", "false")}", - "constraintTitle" : "${constraint.title}", - "allowedValues" : [ <#list constraint.allowedValues as allowedValue> "${allowedValue}" <#if allowedValue_has_next>, ] - } - - - -<#macro constraintWithValuesJSON constraint> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", - "constraintName" : "${constraint.name}", - "caseSensitive" : "${constraint.caseSensitive?string("true", "false")}", - "constraintTitle" : "${msg(constraint.title)}", - "values" : [ - <#list constraint.values as value> - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", - "valueName":"${value.valueName}", - "valueTitle":"${value.valueTitle}", - "authorities" : [ <#list value.authorities as authority> { "authorityName" : "${authority.authorityName}", "authorityTitle" : "${authority.authorityTitle}"} <#if authority_has_next>,] - }<#if value_has_next>, - - ] - } - - - -<#macro constraintWithValueJSON constraint value> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", - "constraintName" : "${constraint.name}", - "constraintTitle" : "${constraint.title}", - "value" : - { - "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", - "valueName":"${value.valueName}", - "valueTitle":"${value.valueTitle}", - "authorities" : [ <#list value.authorities as authority> { "authorityName" : "${authority.authorityName}", "authorityTitle" : "${authority.authorityTitle}"} <#if authority_has_next>,] - } - } - +<#-- renders an rm constraint object --> + +<#macro constraintSummaryJSON constraint> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", + "constraintName" : "${constraint.name}", + "constraintTitle" : "${msg(constraint.title)}" + } + + + +<#macro constraintJSON constraint> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", + "constraintName" : "${constraint.name}", + "caseSensitive" : "${constraint.caseSensitive?string("true", "false")}", + "constraintTitle" : "${constraint.title}", + "allowedValues" : [ <#list constraint.allowedValues as allowedValue> "${allowedValue}" <#if allowedValue_has_next>, ] + } + + + +<#macro constraintWithValuesJSON constraint> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name}", + "constraintName" : "${constraint.name}", + "caseSensitive" : "${constraint.caseSensitive?string("true", "false")}", + "constraintTitle" : "${msg(constraint.title)}", + "values" : [ + <#list constraint.values as value> + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", + "valueName":"${value.valueName}", + "valueTitle":"${value.valueTitle}", + "authorities" : [ <#list value.authorities as authority> { "authorityName" : "${authority.authorityName}", "authorityTitle" : "${authority.authorityTitle}"} <#if authority_has_next>,] + }<#if value_has_next>, + + ] + } + + + +<#macro constraintWithValueJSON constraint value> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", + "constraintName" : "${constraint.name}", + "constraintTitle" : "${constraint.title}", + "value" : + { + "url" : "${url.serviceContext + "/api/rma/admin/rmconstraints/" + constraint.name + "/values/" + value.valueName}", + "valueName":"${value.valueName}", + "valueTitle":"${value.valueTitle}", + "authorities" : [ <#list value.authorities as authority> { "authorityName" : "${authority.authorityName}", "authorityTitle" : "${authority.authorityTitle}"} <#if authority_has_next>,] + } + } + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.desc.xml index b7e4533b8f..fef70b6ff0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.desc.xml @@ -1,19 +1,19 @@ - - Update an RM Constraint List - - The following properties may be updatedConstraint object -
-
-
constraintTitle
Optional, the title of the constraint (human readable)
-
allowedValues
Optional, array of allowed values, the complete list must be specified
-
- ]]> -
- /api/rma/admin/rmconstraints/{listName} - argument - user - required - internal + + Update an RM Constraint List + + The following properties may be updatedConstraint object +
+
+
constraintTitle
Optional, the title of the constraint (human readable)
+
allowedValues
Optional, array of allowed values, the complete list must be specified
+
+ ]]> +
+ /api/rma/admin/rmconstraints/{listName} + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.ftl index 42a94a8b34..a298a79a1b 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.ftl @@ -1,11 +1,11 @@ -<#import "rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - <#if !errorMessage??> - "data": <@rmconstraintLib.constraintJSON constraint=constraint /> - <#else> - "message" : "${msg(errorMessage, title)}" - -} +<#import "rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + <#if !errorMessage??> + "data": <@rmconstraintLib.constraintJSON constraint=constraint /> + <#else> + "message" : "${msg(errorMessage, title)}" + +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.js index d9f9553dc0..05ae36986d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint.put.json.js @@ -1,60 +1,60 @@ - - -/** - * Update an rm constraint - */ -function main() -{ - // Get the shortname - var shortName = url.extension; - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - var allowedValues, - title = null; - - if (json.has("constraintTitle")) - { - title = json.get("constraintTitle"); - if (existsTitle(caveatConfig, title)) - { - status.code = 400; - model.errorMessage = "rm.admin.list-already-exists"; - model.title = title; - return; - } - constraint.updateTitle(title); - } - - if (json.has("allowedValues")) - { - values = json.getJSONArray("allowedValues"); - - var i = 0; - allowedValues = new Array(); - - if (values != null) - { - for (var x = 0; x < values.length(); x++) - { - allowedValues[i++] = values.get(x); - } - } - constraint.updateAllowedValues(allowedValues); - } - - // Pass the constraint detail to the template - model.constraint = constraint; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - + + +/** + * Update an rm constraint + */ +function main() +{ + // Get the shortname + var shortName = url.extension; + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + var allowedValues, + title = null; + + if (json.has("constraintTitle")) + { + title = json.get("constraintTitle"); + if (existsTitle(caveatConfig, title)) + { + status.code = 400; + model.errorMessage = "rm.admin.list-already-exists"; + model.title = title; + return; + } + constraint.updateTitle(title); + } + + if (json.has("allowedValues")) + { + values = json.getJSONArray("allowedValues"); + + var i = 0; + allowedValues = new Array(); + + if (values != null) + { + for (var x = 0; x < values.length(); x++) + { + allowedValues[i++] = values.get(x); + } + } + constraint.updateAllowedValues(allowedValues); + } + + // Pass the constraint detail to the template + model.constraint = constraint; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.desc.xml index e8dff744df..edc8be638e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.desc.xml @@ -1,18 +1,18 @@ - - Get the names of all RM Constraint Lists - -
-
constraintTitle
Human readable title for the custom constraint list
-
constraintName
the name of the constraint list, prefixed
-
url
-
- ]]> -
- /api/rma/admin/rmconstraints?withEmptyLists={withEmptyLists?} - argument - user - required - internal + + Get the names of all RM Constraint Lists + +
+
constraintTitle
Human readable title for the custom constraint list
+
constraintName
the name of the constraint list, prefixed
+
url
+
+ ]]> +
+ /api/rma/admin/rmconstraints?withEmptyLists={withEmptyLists?} + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.js index b77cdd6eb1..ec797503d0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.js @@ -1,19 +1,19 @@ -/** - * List the names of the rm constraints - */ -function main() -{ - var wel = true; - var withEmptyLists = args["withEmptyLists"]; - // Pass the information to the template - if (withEmptyLists != null && withEmptyLists === 'false') - { - model.constraints = caveatConfig.constraintsWithoutEmptyList; - } - else - { - model.constraints = caveatConfig.allConstraints; - } -} - +/** + * List the names of the rm constraints + */ +function main() +{ + var wel = true; + var withEmptyLists = args["withEmptyLists"]; + // Pass the information to the template + if (withEmptyLists != null && withEmptyLists === 'false') + { + model.constraints = caveatConfig.constraintsWithoutEmptyList; + } + else + { + model.constraints = caveatConfig.allConstraints; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.json.ftl index 172e46f633..e59e21d270 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.get.json.ftl @@ -1,13 +1,13 @@ -<#import "rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - [ - <#list constraints as constraint> - <@rmconstraintLib.constraintSummaryJSON constraint=constraint /> - <#if constraint_has_next>, - - ] -} +<#import "rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + [ + <#list constraints as constraint> + <@rmconstraintLib.constraintSummaryJSON constraint=constraint /> + <#if constraint_has_next>, + + ] +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.desc.xml index 3d0036b1d4..8e6dec15b4 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.desc.xml @@ -1,20 +1,20 @@ - - Create a new RM Constraint List - - The following properties may be specified -
-
-
constraintName
Optional the name of the constraint. If not specified then one will be generated.
-
constraintTitle
The title of the constraint (human readable)
-
allowedValues
array of allowed values, the complete list must be specified
-
- ]]> -
- /api/rma/admin/rmconstraints - argument - user - required - internal + + Create a new RM Constraint List + + The following properties may be specified +
+
+
constraintName
Optional the name of the constraint. If not specified then one will be generated.
+
constraintTitle
The title of the constraint (human readable)
+
allowedValues
array of allowed values, the complete list must be specified
+
+ ]]> +
+ /api/rma/admin/rmconstraints + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.ftl index 6687f6ed55..9bb649fdd6 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.ftl @@ -1,11 +1,11 @@ -<#import "rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - <#if !errorMessage??> - "data": <@rmconstraintLib.constraintJSON constraint=constraint /> - <#else> - "message" : "${msg(errorMessage, title)}" - -} +<#import "rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + <#if !errorMessage??> + "data": <@rmconstraintLib.constraintJSON constraint=constraint /> + <#else> + "message" : "${msg(errorMessage, title)}" + +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.js index 7bb64fc99b..74749eaf3f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraints.post.json.js @@ -1,54 +1,54 @@ - - -/** - * Create a new RM Constraint List - */ -function main() -{ - // Parse the passed in details - var title = null, - name = null, - allowedValues = {}; - - if (json.has("constraintName")) - { - name = json.get("constraintName"); - } - - if (json.has("constraintTitle")) - { - title = json.get("constraintTitle"); - } - else - { - title = name; - } - - if (existsTitle(caveatConfig, title)) - { - status.code = 400; - model.errorMessage = "rm.admin.list-already-exists"; - model.title = title; - return; - } - - if (json.has("allowedValues")) - { - values = json.getJSONArray("allowedValues"); - - var i = 0; - allowedValues = new Array(); - - if (values != null) - { - for (var x = 0; x < values.length(); x++) - { - allowedValues[i++] = values.get(x); - } - } - } - - model.constraint = caveatConfig.createConstraint(name, title, allowedValues); -} - + + +/** + * Create a new RM Constraint List + */ +function main() +{ + // Parse the passed in details + var title = null, + name = null, + allowedValues = {}; + + if (json.has("constraintName")) + { + name = json.get("constraintName"); + } + + if (json.has("constraintTitle")) + { + title = json.get("constraintTitle"); + } + else + { + title = name; + } + + if (existsTitle(caveatConfig, title)) + { + status.code = 400; + model.errorMessage = "rm.admin.list-already-exists"; + model.title = title; + return; + } + + if (json.has("allowedValues")) + { + values = json.getJSONArray("allowedValues"); + + var i = 0; + allowedValues = new Array(); + + if (values != null) + { + for (var x = 0; x < values.length(); x++) + { + allowedValues[i++] = values.get(x); + } + } + } + + model.constraint = caveatConfig.createConstraint(name, title, allowedValues); +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.desc.xml index e9f2517b1c..fc447a85d1 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.desc.xml @@ -1,63 +1,63 @@ - - Get an RM Constraint - - - The list name is qualified with an underscore between prefix and name to be compatible with Java Script and URLs -
- e.g. rma_listName rather than rma:listName -
- Constraint object -
-
constraintName
the name of the constraint. The underscore character is used instead of the colon
-
caseSensitive
is the constraint case sensitive
-
constraintTitle
the display name of the constraint
-
allowedValues
array of the allowed values, this is the complete unrestricted list of all values
-
values
array of constraint values
-
- Constraint values object -
-
valueName
the full name of the value
-
valueTitle
the display name of the value
-
authorities
array of constraint authorities
-
- Example JSON data -
-   {
-      "data":
-      {
-         "url" : "\/alfresco\/service\/api\/rma\/admin\/rmconstraints\/rma_smList",
-         "constraintName" : "rma_smList",
-         "caseSensitive" :  "true",
-         "constraintTitle" : "Display title for rma:smList",
-         "allowedValues" : [ "Alpha" ,  "Beta" ,  "Gamma" ],
-         "values" :
-         [
-            {
-               "valueName":"NOCON",
-               "valueTitle":"NOCON",
-               "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} ]
-            },
-            {
-               "valueName":"NOFORN",
-               "valueTitle":"NOFORN",
-               "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} , { "authorityName" : "fbloggs", "authorityTitle" : "fbloggs"} , { "authorityName" : "jdoe", "authorityTitle" : "jdoe"} ]
-            },
-            {
-               "valueName":"FGI",
-               "valueTitle":"FGI",
-               "authorities" : [  { "authorityName" : "fbloggs", "authorityTitle" : "fbloggs"} , { "authorityName" : "jdoe", "authorityTitle" : "jdoe"} ]
-            }
-         ]
-      }
-   }
-   
- ]]> -
- /api/rma/admin/rmconstraints/{listName}/values - argument - user - required - internal + + Get an RM Constraint + + + The list name is qualified with an underscore between prefix and name to be compatible with Java Script and URLs +
+ e.g. rma_listName rather than rma:listName +
+ Constraint object +
+
constraintName
the name of the constraint. The underscore character is used instead of the colon
+
caseSensitive
is the constraint case sensitive
+
constraintTitle
the display name of the constraint
+
allowedValues
array of the allowed values, this is the complete unrestricted list of all values
+
values
array of constraint values
+
+ Constraint values object +
+
valueName
the full name of the value
+
valueTitle
the display name of the value
+
authorities
array of constraint authorities
+
+ Example JSON data +
+   {
+      "data":
+      {
+         "url" : "\/alfresco\/service\/api\/rma\/admin\/rmconstraints\/rma_smList",
+         "constraintName" : "rma_smList",
+         "caseSensitive" :  "true",
+         "constraintTitle" : "Display title for rma:smList",
+         "allowedValues" : [ "Alpha" ,  "Beta" ,  "Gamma" ],
+         "values" :
+         [
+            {
+               "valueName":"NOCON",
+               "valueTitle":"NOCON",
+               "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} ]
+            },
+            {
+               "valueName":"NOFORN",
+               "valueTitle":"NOFORN",
+               "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} , { "authorityName" : "fbloggs", "authorityTitle" : "fbloggs"} , { "authorityName" : "jdoe", "authorityTitle" : "jdoe"} ]
+            },
+            {
+               "valueName":"FGI",
+               "valueTitle":"FGI",
+               "authorities" : [  { "authorityName" : "fbloggs", "authorityTitle" : "fbloggs"} , { "authorityName" : "jdoe", "authorityTitle" : "jdoe"} ]
+            }
+         ]
+      }
+   }
+   
+ ]]> +
+ /api/rma/admin/rmconstraints/{listName}/values + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.js index 74261a660e..64ba2a2e95 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.js @@ -1,25 +1,25 @@ -/** - * Get the detail of the rm constraint - */ -function main() -{ - var urlElements = url.extension.split("/"); - var shortName = urlElements[0]; - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - // Pass the constraint detail to the template - model.constraint = constraint; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Get the detail of the rm constraint + */ +function main() +{ + var urlElements = url.extension.split("/"); + var shortName = urlElements[0]; + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + // Pass the constraint detail to the template + model.constraint = constraint; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.json.ftl index ba9688a12b..a3459738af 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.get.json.ftl @@ -1,7 +1,7 @@ -<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> -} +<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.desc.xml index d6c4af865f..86b6d17ed6 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.desc.xml @@ -1,28 +1,28 @@ - - Updates values in an an RM Constraint List - - If the authority is missing from the list then the value is deleted. -
- If an authority does not exist in a list then the authority is added. -
- Only the authorities for the specified values are updated. -
- If a value is missing it will not be affected. -
- JSON Parameter format: -
- "values" : [ ValueName, [ authorityName1, authorityName2 ]] -
- The input format for values is different to the output format. -
- Data Return format. - ]]> -
- /api/rma/admin/rmconstraints/{listName}/values - argument - user - required - internal + + Updates values in an an RM Constraint List + + If the authority is missing from the list then the value is deleted. +
+ If an authority does not exist in a list then the authority is added. +
+ Only the authorities for the specified values are updated. +
+ If a value is missing it will not be affected. +
+ JSON Parameter format: +
+ "values" : [ ValueName, [ authorityName1, authorityName2 ]] +
+ The input format for values is different to the output format. +
+ Data Return format. + ]]> +
+ /api/rma/admin/rmconstraints/{listName}/values + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.ftl index c811deeed9..08eab56d9e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.ftl @@ -1,7 +1,7 @@ -<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> -} +<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.js index 731432cc78..6096991a61 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraint.post.json.js @@ -1,39 +1,39 @@ -/** - * Update the details of a value in an rm constraint - */ -function main() -{ - var urlElements = url.extension.split("/"); - var shortName = urlElements[0]; - - var values = null; - - if (json.has("values")) - { - values = json.getJSONArray("values"); - } - - if (values == null) - { - status.setCode(status.STATUS_BAD_REQUEST, "Values missing"); - return; - } - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - constraint.updateValues(values); - model.constraint = caveatConfig.getConstraint(shortName); - model.constraintName = shortName; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Update the details of a value in an rm constraint + */ +function main() +{ + var urlElements = url.extension.split("/"); + var shortName = urlElements[0]; + + var values = null; + + if (json.has("values")) + { + values = json.getJSONArray("values"); + } + + if (values == null) + { + status.setCode(status.STATUS_BAD_REQUEST, "Values missing"); + return; + } + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + constraint.updateValues(values); + model.constraint = caveatConfig.getConstraint(shortName); + model.constraintName = shortName; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.desc.xml index 74b3f1330e..dfbe501e22 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.desc.xml @@ -1,11 +1,11 @@ - - Delete a value from an RM Constraint List - - - /api/rma/admin/rmconstraints/{listName}/{valueName} - argument - user - required - internal + + Delete a value from an RM Constraint List + + + /api/rma/admin/rmconstraints/{listName}/{valueName} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.js index 28d5e19382..e9c4d91b34 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.js @@ -1,41 +1,41 @@ -/** - * Delete the rm constraint list - */ -function main() -{ - var urlElements = url.extension.split("/"); - var shortName = urlElements[0]; - var authorityName = urlElements[1]; - - if (shortName == null) - { - status.setCode(status.STATUS_BAD_REQUEST, "shortName missing"); - return; - } - if (valueName == null) - { - status.setCode(status.STATUS_BAD_REQUEST, "value missing"); - return; - } - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - caveatConfig.deleteRMConstraintListValue(shortName, valueName); - - var constraint = caveatConfig.getConstraint(shortName); - - // Pass the constraint name to the template - model.constraint = constraint; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Delete the rm constraint list + */ +function main() +{ + var urlElements = url.extension.split("/"); + var shortName = urlElements[0]; + var authorityName = urlElements[1]; + + if (shortName == null) + { + status.setCode(status.STATUS_BAD_REQUEST, "shortName missing"); + return; + } + if (valueName == null) + { + status.setCode(status.STATUS_BAD_REQUEST, "value missing"); + return; + } + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + caveatConfig.deleteRMConstraintListValue(shortName, valueName); + + var constraint = caveatConfig.getConstraint(shortName); + + // Pass the constraint name to the template + model.constraint = constraint; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.json.ftl index c811deeed9..08eab56d9e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.delete.json.ftl @@ -1,7 +1,7 @@ -<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> -} +<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.desc.xml index 482c2ebf21..c53b819e90 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.desc.xml @@ -1,47 +1,47 @@ - - Get an RM Constraint Value - - - The list name is qualified with an underscore between prefix and name to be compatible with Java Script and URLs -
- e.g. rma_listName rather than rma:listName -
- Constraint object -
-
constraintName
the name of the constraint. The underscore character is used instead of the colon
-
constraintTitle
the display name of the constraint
-
value
constraint values
-
- Constraint values object -
-
valueName
the full name of the value
-
valueTitle
the display name of the value
-
authorities
array of constraint authorities
-
- Example JSON data: -
-   {
-      "data":
-      {
-         "url" : "\/alfresco\/service\/api\/rma\/admin\/rmconstraints\/rma_smList/values/NOCON",
-         "constraintName" : "rma_smList",
-         "constraintTitle" : "Display title for rma:smList",
-         "value" :
-         {
-           "valueName":"NOCON", 
-           "valueTitle":"NOCON",
-           "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} ]
-         }
-      }
-   }
-   
- ]]> -
- /api/rma/admin/rmconstraints/{listName}/values/{valueName} - argument - user - required - internal + + Get an RM Constraint Value + + + The list name is qualified with an underscore between prefix and name to be compatible with Java Script and URLs +
+ e.g. rma_listName rather than rma:listName +
+ Constraint object +
+
constraintName
the name of the constraint. The underscore character is used instead of the colon
+
constraintTitle
the display name of the constraint
+
value
constraint values
+
+ Constraint values object +
+
valueName
the full name of the value
+
valueTitle
the display name of the value
+
authorities
array of constraint authorities
+
+ Example JSON data: +
+   {
+      "data":
+      {
+         "url" : "\/alfresco\/service\/api\/rma\/admin\/rmconstraints\/rma_smList/values/NOCON",
+         "constraintName" : "rma_smList",
+         "constraintTitle" : "Display title for rma:smList",
+         "value" :
+         {
+           "valueName":"NOCON", 
+           "valueTitle":"NOCON",
+           "authorities" : [  { "authorityName" : "jrogers", "authorityTitle" : "jrogers"} ]
+         }
+      }
+   }
+   
+ ]]> +
+ /api/rma/admin/rmconstraints/{listName}/values/{valueName} + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.js index 5bf8b82f17..d19b97669d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.js @@ -1,36 +1,36 @@ -/** - * Get the detail of the rm constraint - */ -function main() -{ - var urlElements = url.extension.split("/"); - var shortName = decodeURIComponent(urlElements[0]); - var valueName = decodeURIComponent(urlElements[2]) - - // Get the constraint - var constraint = caveatConfig.getConstraint(shortName); - - if (constraint != null) - { - // Pass the constraint detail to the template - var value = constraint.getValue(valueName); - - if(value == null) - { - // Return 404 - status.setCode(404, "Constraint List: " + shortName + " value: " + valueName + "does not exist"); - return; - } - - model.value = value; - model.constraint = constraint; - } - else - { - // Return 404 - status.setCode(404, "Constraint List " + shortName + " does not exist"); - return; - } -} - +/** + * Get the detail of the rm constraint + */ +function main() +{ + var urlElements = url.extension.split("/"); + var shortName = decodeURIComponent(urlElements[0]); + var valueName = decodeURIComponent(urlElements[2]) + + // Get the constraint + var constraint = caveatConfig.getConstraint(shortName); + + if (constraint != null) + { + // Pass the constraint detail to the template + var value = constraint.getValue(valueName); + + if(value == null) + { + // Return 404 + status.setCode(404, "Constraint List: " + shortName + " value: " + valueName + "does not exist"); + return; + } + + model.value = value; + model.constraint = constraint; + } + else + { + // Return 404 + status.setCode(404, "Constraint List " + shortName + " does not exist"); + return; + } +} + main(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.json.ftl index 392a3b2ac0..b09759fc1b 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/values/rmconstraintvalue.get.json.ftl @@ -1,7 +1,7 @@ -<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@rmconstraintLib.constraintWithValueJSON constraint=constraint value=value/> -} +<#import "../rmconstraint.lib.ftl" as rmconstraintLib/> + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": <@rmconstraintLib.constraintWithValueJSON constraint=constraint value=value/> +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.delete.desc.xml index 0c4801c54a..f0f74a4e42 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.delete.desc.xml @@ -1,14 +1,14 @@ - - Deletes a records management event - - - - /api/rma/admin/rmevents/{eventname} - argument - user - required - internal + + Deletes a records management event + + + + /api/rma/admin/rmevents/{eventname} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.get.desc.xml index e7e1294a75..4667b1a3ef 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.get.desc.xml @@ -1,14 +1,14 @@ - - Get an records management event - - - - /api/rma/admin/rmevents/{eventname} - argument - user - required - internal + + Get an records management event + + + + /api/rma/admin/rmevents/{eventname} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.lib.ftl index 53d3e1fff8..9cf90872d4 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.lib.ftl @@ -1,12 +1,12 @@ -<#-- renders an rm event object --> - -<#macro eventJSON event> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "eventName": "${event.name}", - "eventDisplayLabel": "${event.displayLabel}", - "eventType":"${event.type}" -} - - - +<#-- renders an rm event object --> + +<#macro eventJSON event> +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "eventName": "${event.name}", + "eventDisplayLabel": "${event.displayLabel}", + "eventType":"${event.type}" +} + + + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.put.desc.xml index 3457e2ee65..20fa57cfea 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevent.put.desc.xml @@ -1,14 +1,14 @@ - - Update a records management event - - - - /api/rma/admin/rmevents/{eventname} - argument - user - required - internal + + Update a records management event + + + + /api/rma/admin/rmevents/{eventname} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.get.desc.xml index ca2c548783..b80139a92d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.get.desc.xml @@ -1,14 +1,14 @@ - - Get list of records management events - - - - /api/rma/admin/rmevents - argument - user - required - internal + + Get list of records management events + + + + /api/rma/admin/rmevents + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.post.desc.xml index ed0a8207d5..c7970590a4 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmevents.post.desc.xml @@ -1,14 +1,14 @@ - - Create a new records managment event - - - - /api/rma/admin/rmevents - argument - user - required - internal + + Create a new records managment event + + + + /api/rma/admin/rmevents + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmeventtypes.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmeventtypes.get.desc.xml index d14aecb466..6d28dd8489 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmeventtypes.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmevent/rmeventtypes.get.desc.xml @@ -1,14 +1,14 @@ - - Gets the records management event types - - - - /api/rma/admin/rmeventtypes - argument - user - required - internal + + Gets the records management event types + + + + /api/rma/admin/rmeventtypes + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.delete.desc.xml index 1cd7262836..2977395daa 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.delete.desc.xml @@ -1,16 +1,16 @@ - - Deletes a records management role - - - - /api/rma/admin/rmroles/{rolename} - /api/rma/admin/{siteid}/rmroles/{rolename} - /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} - argument - user - required - internal + + Deletes a records management role + + + + /api/rma/admin/rmroles/{rolename} + /api/rma/admin/{siteid}/rmroles/{rolename} + /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.get.desc.xml index 75a9fa715c..5035c87ac1 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.get.desc.xml @@ -1,16 +1,16 @@ - - Get an records management role - - - - /api/rma/admin/rmroles/{rolename} - /api/rma/admin/{siteid}/rmroles/{rolename} - /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} - argument - user - required - internal + + Get an records management role + + + + /api/rma/admin/rmroles/{rolename} + /api/rma/admin/{siteid}/rmroles/{rolename} + /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.lib.ftl index 26e75ed4eb..37ab26a0d1 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.lib.ftl @@ -1,39 +1,39 @@ -<#-- renders an rm role object --> -<#macro roleJSON role> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "name": "${role.name}", - "displayLabel": "${role.displayLabel}", - "capabilities": - { - <#list role.capabilities as capability> - "${capability.name}": "${capability.title}" <#if capability_has_next>, - - } - <#if role.showAuths> - , - "assignedUsers" : - [ - <#list role.assignedUsers as user> - { - "name" : "${user.name}", - "displayLabel" : "${user.displayLabel}" - }<#if user_has_next>, - - ], - "assignedGroups" : - [ - <#list role.assignedGroups as group> - { - "name" : "${group.name}", - "displayLabel" : "${group.displayLabel}" - }<#if group_has_next>, - - ] - <#if role.groupShortName??> - ,"groupShortName": "${role.groupShortName}" - - -} - +<#-- renders an rm role object --> +<#macro roleJSON role> +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "name": "${role.name}", + "displayLabel": "${role.displayLabel}", + "capabilities": + { + <#list role.capabilities as capability> + "${capability.name}": "${capability.title}" <#if capability_has_next>, + + } + <#if role.showAuths> + , + "assignedUsers" : + [ + <#list role.assignedUsers as user> + { + "name" : "${user.name}", + "displayLabel" : "${user.displayLabel}" + }<#if user_has_next>, + + ], + "assignedGroups" : + [ + <#list role.assignedGroups as group> + { + "name" : "${group.name}", + "displayLabel" : "${group.displayLabel}" + }<#if group_has_next>, + + ] + <#if role.groupShortName??> + ,"groupShortName": "${role.groupShortName}" + + +} + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.put.desc.xml index 093b5e49c9..c939ad16a0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmrole.put.desc.xml @@ -1,16 +1,16 @@ - - Update a records management role - - - - /api/rma/admin/rmroles/{rolename} - /api/rma/admin/{siteid}/rmroles/{rolename} - /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} - argument - user - required - internal + + Update a records management role + + + + /api/rma/admin/rmroles/{rolename} + /api/rma/admin/{siteid}/rmroles/{rolename} + /api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.get.desc.xml index aa9c48a015..d2a382d9aa 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.get.desc.xml @@ -1,22 +1,22 @@ - - Get list of records management roles and their details, for a file plan. - - - - /api/rma/admin/rmroles?user={user?}&auths={auths?}&is={is?} - /api/rma/admin/{store_type}/{store_id}/{id}/rmroles?user={user?}&auths={auths?}&is={is?} - /api/rma/admin/{siteid}/rmroles?user={user?}&auths={auths?}&is={is?} - argument - user - required - internal + + Get list of records management roles and their details, for a file plan. + + + + /api/rma/admin/rmroles?user={user?}&auths={auths?}&is={is?} + /api/rma/admin/{store_type}/{store_id}/{id}/rmroles?user={user?}&auths={auths?}&is={is?} + /api/rma/admin/{siteid}/rmroles?user={user?}&auths={auths?}&is={is?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.post.desc.xml index 9486b8337b..8b472e934e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/admin/rmrole/rmroles.post.desc.xml @@ -1,16 +1,16 @@ - - Create a new records managment role - - - - /api/rma/admin/rmroles - /api/rma/admin/{siteid}/rmroles - /api/rma/admin/{store_type}/{store_id}/{id}/rmroles - argument - user - required - internal + + Create a new records managment role + + + + /api/rma/admin/rmroles + /api/rma/admin/{siteid}/rmroles + /api/rma/admin/{store_type}/{store_id}/{id}/rmroles + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.desc.xml index bcc2921b4e..d1ca358cdd 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.desc.xml @@ -1,15 +1,15 @@ - - Applies fixes to the content model for DoD certification. - - Please note that this script will be removed after the certification process is complete. - ]]> - /api/rma/applydodcertmodelfixes - argument - admin - required - internal + + Applies fixes to the content model for DoD certification. + + Please note that this script will be removed after the certification process is complete. + ]]> + /api/rma/applydodcertmodelfixes + argument + admin + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.json.ftl index 53ac8f9883..3d6e9f6678 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applydodcertmodelfixes.get.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string} +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.desc.xml index 9dada0f840..b468a7889e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.desc.xml @@ -1,9 +1,9 @@ - - Applies fix for MOB-1573. - Fixes the RM custom model by changing the multiplicity on custom references to many-to-many. - /api/rma/applyfixmob1573 - argument - admin - required - internal + + Applies fix for MOB-1573. + Fixes the RM custom model by changing the multiplicity on custom references to many-to-many. + /api/rma/applyfixmob1573 + argument + admin + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.json.ftl index 53ac8f9883..3d6e9f6678 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/applyfixmob1573.get.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string} +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.desc.xml index 14c6f8d6c6..fb55a391ee 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.desc.xml @@ -1,9 +1,9 @@ - - Load the RM DOD bootstrap data. - WebScript to import and fix up the RM DOD bootstrap data. - /api/rma/bootstraptestdata?site={site?}&import={import?} - argument - admin - required - deprecated + + Load the RM DOD bootstrap data. + WebScript to import and fix up the RM DOD bootstrap data. + /api/rma/bootstraptestdata?site={site?}&import={import?} + argument + admin + required + deprecated \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.json.ftl index 53ac8f9883..3d6e9f6678 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/bootstraptestdata.get.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string} +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.desc.xml index 51cb5a1f98..e8b2400d4d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.desc.xml @@ -1,10 +1,10 @@ - - Records Management Capabilities - Get the list of capabilities available to the current user on the given node. - /api/node/{store_type}/{store_id}/{id}/capabilities?includeAll={includeAll?} - /api/capabilities?includeAll={includeAll?}&grouped={grouped?} - argument - user - required - internal + + Records Management Capabilities + Get the list of capabilities available to the current user on the given node. + /api/node/{store_type}/{store_id}/{id}/capabilities?includeAll={includeAll?} + /api/capabilities?includeAll={includeAll?}&grouped={grouped?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.json.ftl index 0176923709..496f6db28f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/capability/capabilities.get.json.ftl @@ -1,33 +1,33 @@ -{ - "data": - { - <#if groupedCapabilities??> - "groupedCapabilities": - [ - <#list groupedCapabilities?keys?sort as groupedCapabilityKey> - { - "${groupedCapabilityKey}": - { - <#assign groupedCapability = groupedCapabilities[groupedCapabilityKey]> - groupTitle: "${groupedCapability.groupTitle}", - capabilities: - { - <#assign capabilities = groupedCapability.capabilities> - <#list capabilities?keys?sort as capabilityKey> - "${capabilityKey}": "${capabilities[capabilityKey]}"<#if capabilityKey_has_next>, - - } - } - }<#if groupedCapabilityKey_has_next>, - - ] - <#else> - "capabilities": - [ - <#list capabilities as capability> - "${capability}"<#if capability_has_next>, - - ] - - } +{ + "data": + { + <#if groupedCapabilities??> + "groupedCapabilities": + [ + <#list groupedCapabilities?keys?sort as groupedCapabilityKey> + { + "${groupedCapabilityKey}": + { + <#assign groupedCapability = groupedCapabilities[groupedCapabilityKey]> + groupTitle: "${groupedCapability.groupTitle}", + capabilities: + { + <#assign capabilities = groupedCapability.capabilities> + <#list capabilities?keys?sort as capabilityKey> + "${capabilityKey}": "${capabilities[capabilityKey]}"<#if capabilityKey_has_next>, + + } + } + }<#if groupedCapabilityKey_has_next>, + + ] + <#else> + "capabilities": + [ + <#list capabilities as capability> + "${capability}"<#if capability_has_next>, + + ] + + } } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.desc.xml index 90aa0b9af9..24e24f2c0e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.desc.xml @@ -1,18 +1,18 @@ - - Attempts to remove specified Custom Property Definitions from the custom model - - It should be noted that it may not be possible to honour this request in all cases.
- In cases where instances of the specified property are already present in the system,
- the request will not succeed. In cases where there are no instances of the specified
- property in the system, the request will attempted.
-
- The propId is that returned by custompropertydefinitions.get. - ]]> -
- /api/rma/admin/custompropertydefinitions/{propId} - argument - user - required - internal -
+ + Attempts to remove specified Custom Property Definitions from the custom model + + It should be noted that it may not be possible to honour this request in all cases.
+ In cases where instances of the specified property are already present in the system,
+ the request will not succeed. In cases where there are no instances of the specified
+ property in the system, the request will attempted.
+
+ The propId is that returned by custompropertydefinitions.get. + ]]> +
+ /api/rma/admin/custompropertydefinitions/{propId} + argument + user + required + internal +
diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.json.ftl index f23634ccec..074181721f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.delete.json.ftl @@ -1,8 +1,8 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "customProperty": "${propertyqname}" - } -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "customProperty": "${propertyqname}" + } +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.post.json.ftl index abc5de2085..350083af77 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.post.json.ftl @@ -1,7 +1,7 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "propId": "${propId!""}", - "url": "${url!""}", - "message": "${errorMessage!""}" -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "propId": "${propId!""}", + "url": "${url!""}", + "message": "${errorMessage!""}" +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.put.json.ftl index 4df42a5c6a..3b1115e14c 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.put.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinition.put.json.ftl @@ -1,7 +1,7 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "propId": "${propId!""}", - "url": "${url!""}", - "message": "${errorMessage!""}" -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "propId": "${propId!""}", + "url": "${url!""}", + "message": "${errorMessage!""}" +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.desc.xml index 464533568d..62916a0b4f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.desc.xml @@ -1,14 +1,14 @@ - - Removes specified Custom Reference Instance from between the specified nodes - - The nodeRef encoded within the URL path is the 'fromNode' in the relationship.
- The nodeRef encoded within the query string is the 'toNode' in the relationship.
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/customreferences/{refId}?st={toStoreType}&si={toStoreId}&id={toId} - argument - user - required - internal -
+ + Removes specified Custom Reference Instance from between the specified nodes + + The nodeRef encoded within the URL path is the 'fromNode' in the relationship.
+ The nodeRef encoded within the query string is the 'toNode' in the relationship.
+ ]]> +
+ /api/node/{store_type}/{store_id}/{id}/customreferences/{refId}?st={toStoreType}&si={toStoreId}&id={toId} + argument + user + required + internal +
diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.json.ftl index f539b37200..637c2cabbd 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.delete.json.ftl @@ -1,3 +1,3 @@ -{ - "success": ${success?string} +{ + "success": ${success?string} } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.post.json.ftl index 1ef9fab7d9..d9fc8cee0b 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customref.post.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string} +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.post.json.ftl index 1216a4579d..8ad7f70c24 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.post.json.ftl @@ -1,10 +1,10 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string}, - "data" : { - "referenceType": "${referenceType?string}", - "refId": "${refId?string}", - "url": "${url?string}" - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string}, + "data" : { + "referenceType": "${referenceType?string}", + "refId": "${refId?string}", + "url": "${url?string}" + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.put.json.ftl index ae7ddd675b..e7b9216bc3 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.put.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/customrefdefinition.put.json.ftl @@ -1,6 +1,6 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "refId": "${refId}", - "url": "${url}" -} - +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "refId": "${refId}", + "url": "${url}" +} + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.desc.xml index ea9d1afe00..a3ec79d5b2 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.desc.xml @@ -1,9 +1,9 @@ - - Import data set into a file plan - WebScript to import a given data set into a given file plan - /api/rma/datasets/{dataSetId}?site={site} - argument - user - required - internal + + Import data set into a file plan + WebScript to import a given data set into a given file plan + /api/rma/datasets/{dataSetId}?site={site} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.json.ftl index e726165d3e..c087d420f0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dataset.post.json.ftl @@ -1,6 +1,6 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string}, - "message": "${message}" -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string}, + "message": "${message}" +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.desc.xml index abe2ffaa1f..e82285d044 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.desc.xml @@ -1,9 +1,9 @@ - - Get data sets - WebScript to get the list of available RM test data - /api/rma/datasets?site={site?}&unloadedonly={unloadedonly?} - argument - user - required - internal + + Get data sets + WebScript to get the list of available RM test data + /api/rma/datasets?site={site?}&unloadedonly={unloadedonly?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.json.ftl index 32b3752d6c..b3b9f19e1f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/datasets.get.json.ftl @@ -1,15 +1,15 @@ -{ - "data": - { - "datasets": - [ - <#list datasets as item> - { - "label": "${item.label}", - "id": "${item.id}", - "isLoaded": "${item.isLoaded}" - }<#if item_has_next>, - - ] - } +{ + "data": + { + "datasets": + [ + <#list datasets as item> + { + "label": "${item.label}", + "id": "${item.id}", + "isLoaded": "${item.isLoaded}" + }<#if item_has_next>, + + ] + } } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.delete.desc.xml index cd9df1aa22..eb7d36286d 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.delete.desc.xml @@ -1,9 +1,9 @@ - - Delete Disposition Action Definition - Deletes a disposition action definition from the collection. - /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions/{action_def_id} - argument - user - required - internal + + Delete Disposition Action Definition + Deletes a disposition action definition from the collection. + /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions/{action_def_id} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.lib.ftl index a780a72024..76dca964b3 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.lib.ftl @@ -1,18 +1,18 @@ -<#macro actionJSON action> -<#escape x as jsonUtils.encodeJSONString(x)> - { - "id": "${action.id}", - "url": "${action.url}", - "index": ${action.index}, - "name": "${action.name}", - "label": "${action.label}", - <#if (action.name == "destroy") && action.ghostOnDestroy??>"ghostOnDestroy": "${action.ghostOnDestroy}", - <#if action.description??>"description": "${action.description}", - <#if action.period??>"period": "${action.period}", - <#if action.periodProperty??>"periodProperty": "${action.periodProperty}", - <#if action.location??>"location": "${action.location}", - <#if action.events??>"events": [<#list action.events as event>"${event}"<#if event_has_next>,], - "eligibleOnFirstCompleteEvent": ${action.eligibleOnFirstCompleteEvent?string} - } - +<#macro actionJSON action> +<#escape x as jsonUtils.encodeJSONString(x)> + { + "id": "${action.id}", + "url": "${action.url}", + "index": ${action.index}, + "name": "${action.name}", + "label": "${action.label}", + <#if (action.name == "destroy") && action.ghostOnDestroy??>"ghostOnDestroy": "${action.ghostOnDestroy}", + <#if action.description??>"description": "${action.description}", + <#if action.period??>"period": "${action.period}", + <#if action.periodProperty??>"periodProperty": "${action.periodProperty}", + <#if action.location??>"location": "${action.location}", + <#if action.events??>"events": [<#list action.events as event>"${event}"<#if event_has_next>,], + "eligibleOnFirstCompleteEvent": ${action.eligibleOnFirstCompleteEvent?string} + } + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.desc.xml index 66692a049a..7801f86edc 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.desc.xml @@ -1,21 +1,21 @@ - - Update Disposition Action Definition - - {
-    "name" : Name of action,
-    "description" : Description of the action definition,
-    "period" : The period of time,
-    "periodProperty" : Model property the period is relative to,
-    "eligibleOnFirstCompleteEvent" : Whether all events have to occur,
-    "events" : [List of event names]
- }
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions/{action_def_id} - argument - user - required - internal + + Update Disposition Action Definition + + {
+    "name" : Name of action,
+    "description" : Description of the action definition,
+    "period" : The period of time,
+    "periodProperty" : Model property the period is relative to,
+    "eligibleOnFirstCompleteEvent" : Whether all events have to occur,
+    "events" : [List of event names]
+ }
+ ]]> +
+ /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions/{action_def_id} + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.json.ftl index c9a440057d..78e4886155 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinition.put.json.ftl @@ -1,5 +1,5 @@ -<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> -{ - "data": - <@actionDefLib.actionJSON action=action/> +<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> +{ + "data": + <@actionDefLib.actionJSON action=action/> } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.desc.xml index a2e5880649..11d132b4c0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.desc.xml @@ -1,21 +1,21 @@ - - Add Disposition Action Definition - - {
-    "name" : Name of action,
-    "description" : Description of the action definition,
-    "period" : The period of time,
-    "periodProperty" : Model property the period is relative to,
-    "eligibleOnFirstCompleteEvent" : Whether all events have to occur,
-    "events" : [List of event names]
- }
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions - argument - user - required - internal + + Add Disposition Action Definition + + {
+    "name" : Name of action,
+    "description" : Description of the action definition,
+    "period" : The period of time,
+    "periodProperty" : Model property the period is relative to,
+    "eligibleOnFirstCompleteEvent" : Whether all events have to occur,
+    "events" : [List of event names]
+ }
+ ]]> +
+ /api/node/{store_type}/{store_id}/{id}/dispositionschedule/dispositionactiondefinitions + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.json.ftl index 0a0aa2d064..38a79dc7fa 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionactiondefinitions.post.json.ftl @@ -1,5 +1,5 @@ -<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> -{ - "data": - <@actionDefLib.actionJSON action=action/> -} +<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> +{ + "data": + <@actionDefLib.actionJSON action=action/> +} diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.desc.xml index f80ee5b24b..2736331dae 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.desc.xml @@ -1,9 +1,9 @@ - - Get Dispositon Lifecycle - Returns Disposition Lifecycle data - /api/node/{store_type}/{store_id}/{id}/nextdispositionaction - argument - user - required - internal + + Get Dispositon Lifecycle + Returns Disposition Lifecycle data + /api/node/{store_type}/{store_id}/{id}/nextdispositionaction + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.json.ftl index 639a39b806..9fe4c3c586 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionlifecycle.get.json.ftl @@ -1,40 +1,40 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - <#if nextaction.notFound?? && nextaction.notFound> - "notFound": ${nextaction.notFound?string}, - "message": "${nextaction.message}" - <#else> - "url": "${nextaction.url}", - "name": "${nextaction.name}", - "label": "${nextaction.label}", - "eventsEligible": ${nextaction.eventsEligible?string}, - <#if nextaction.asOf??>"asOf": "${nextaction.asOf}", - <#if nextaction.startedAt??>"startedAt": "${nextaction.startedAt}", - <#if nextaction.startedBy??>"startedBy": "${nextaction.startedBy}", - <#if nextaction.startedByFirstName??>"startedByFirstName": "${nextaction.startedByFirstName}", - <#if nextaction.startedByLastName??>"startedByLastName": "${nextaction.startedByLastName}", - <#if nextaction.completedAt??>"completedAt": "${nextaction.completedAt}", - <#if nextaction.completedBy??>"completedBy": "${nextaction.completedBy}", - <#if nextaction.completedByFirstName??>"completedByFirstName": "${nextaction.completedByFirstName}", - <#if nextaction.completedByLastName??>"completedByLastName": "${nextaction.completedByLastName}", - "events": - [ - <#list nextaction.events as event> - { - "name": "${event.name}", - "label": "${event.label}", - "complete": ${event.complete?string}, - <#if event.completedAt??>"completedAt": "${event.completedAt}", - <#if event.completedBy??>"completedBy": "${event.completedBy}", - <#if event.completedByFirstName??>"completedByFirstName": "${event.completedByFirstName}", - <#if event.completedByLastName??>"completedByLastName": "${event.completedByLastName}", - "automatic": ${event.automatic?string} - }<#if event_has_next>, - - ] - - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + <#if nextaction.notFound?? && nextaction.notFound> + "notFound": ${nextaction.notFound?string}, + "message": "${nextaction.message}" + <#else> + "url": "${nextaction.url}", + "name": "${nextaction.name}", + "label": "${nextaction.label}", + "eventsEligible": ${nextaction.eventsEligible?string}, + <#if nextaction.asOf??>"asOf": "${nextaction.asOf}", + <#if nextaction.startedAt??>"startedAt": "${nextaction.startedAt}", + <#if nextaction.startedBy??>"startedBy": "${nextaction.startedBy}", + <#if nextaction.startedByFirstName??>"startedByFirstName": "${nextaction.startedByFirstName}", + <#if nextaction.startedByLastName??>"startedByLastName": "${nextaction.startedByLastName}", + <#if nextaction.completedAt??>"completedAt": "${nextaction.completedAt}", + <#if nextaction.completedBy??>"completedBy": "${nextaction.completedBy}", + <#if nextaction.completedByFirstName??>"completedByFirstName": "${nextaction.completedByFirstName}", + <#if nextaction.completedByLastName??>"completedByLastName": "${nextaction.completedByLastName}", + "events": + [ + <#list nextaction.events as event> + { + "name": "${event.name}", + "label": "${event.label}", + "complete": ${event.complete?string}, + <#if event.completedAt??>"completedAt": "${event.completedAt}", + <#if event.completedBy??>"completedBy": "${event.completedBy}", + <#if event.completedByFirstName??>"completedByFirstName": "${event.completedByFirstName}", + <#if event.completedByLastName??>"completedByLastName": "${event.completedByLastName}", + "automatic": ${event.automatic?string} + }<#if event_has_next>, + + ] + + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.desc.xml index c1c99e8dce..f268f3d88f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.desc.xml @@ -1,9 +1,9 @@ - - Disposition Properties - Returns a list of the disposition properties based on the context provided. - /api/rma/dispositionproperties?recordlevel={recordlevel}&dispositionaction={dispositionaction} - argument - user - required - internal + + Disposition Properties + Returns a list of the disposition properties based on the context provided. + /api/rma/dispositionproperties?recordlevel={recordlevel}&dispositionaction={dispositionaction} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.json.ftl index 9fd47f2e6b..a0dc8ba6e7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionproperties.get.json.ftl @@ -1,14 +1,14 @@ -{ - "data" : - { - "properties": - [ - <#list properties as item> - { - "label": "${item.label}", - "value": "${item.value}" - }<#if item_has_next>, - - ] - } +{ + "data" : + { + "properties": + [ + <#list properties as item> + { + "label": "${item.label}", + "value": "${item.value}" + }<#if item_has_next>, + + ] + } } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.desc.xml index cc21bc2ec4..3ea48069e5 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.desc.xml @@ -1,9 +1,9 @@ - - Get Dispositon Schedule - Returns Disposition Schedule - /api/node/{store_type}/{store_id}/{id}/dispositionschedule?inherited={inherited?} - argument - user - required - internal + + Get Dispositon Schedule + Returns Disposition Schedule + /api/node/{store_type}/{store_id}/{id}/dispositionschedule?inherited={inherited?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.json.ftl index 251d15855c..d590edb8ab 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/dispositionschedule.get.json.ftl @@ -1,29 +1,29 @@ -<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> - -<@scheduleJSON schedule=schedule/> - -<#macro scheduleJSON schedule> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "url": "${schedule.url}", - "nodeRef": "${schedule.nodeRef}", - <#if schedule.authority??>"authority": "${schedule.authority}", - <#if schedule.instructions??>"instructions": "${schedule.instructions}", - "unpublishedUpdates" : ${schedule.unpublishedUpdates?string}, - "publishInProgress" : ${schedule.publishInProgress?string}, - "recordLevelDisposition": ${schedule.recordLevelDisposition?string}, - "canStepsBeRemoved": ${schedule.canStepsBeRemoved?string}, - "actionsUrl": "${schedule.actionsUrl}", - "actions": - [ - <#list schedule.actions as action> - <@actionDefLib.actionJSON action=action/> - <#if action_has_next>, - - ] - } -} - +<#import "dispositionactiondefinition.lib.ftl" as actionDefLib/> + +<@scheduleJSON schedule=schedule/> + +<#macro scheduleJSON schedule> +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "url": "${schedule.url}", + "nodeRef": "${schedule.nodeRef}", + <#if schedule.authority??>"authority": "${schedule.authority}", + <#if schedule.instructions??>"instructions": "${schedule.instructions}", + "unpublishedUpdates" : ${schedule.unpublishedUpdates?string}, + "publishInProgress" : ${schedule.publishInProgress?string}, + "recordLevelDisposition": ${schedule.recordLevelDisposition?string}, + "canStepsBeRemoved": ${schedule.canStepsBeRemoved?string}, + "actionsUrl": "${schedule.actionsUrl}", + "actions": + [ + <#list schedule.actions as action> + <@actionDefLib.actionJSON action=action/> + <#if action_has_next>, + + ] + } +} + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/export.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/export.post.desc.xml index a9f50f435c..4599afcb45 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/export.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/export.post.desc.xml @@ -1,16 +1,16 @@ - - Records Management Export - - The body of the post should be in the form
- {
-    "nodeRefs" : array of nodeRefs to export
- }
- ]]> -
- /api/rma/admin/export - argument - user - required - internal + + Records Management Export + + The body of the post should be in the form
+ {
+    "nodeRefs" : array of nodeRefs to export
+ }
+ ]]> +
+ /api/rma/admin/export + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml index 10b936385b..c58f296207 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml @@ -1,17 +1,17 @@ - - Adds item(s) to the hold(s) - - The body of the post should be in the form
- {
-    "nodeRefs" : array of nodeRefs for item(s) (record(s) / record folder(s)),
-    "holds" : array of nodeRefs for the hold(s)
- }
- ]]> -
- /api/rma/holds - argument - user - required - internal + + Adds item(s) to the hold(s) + + The body of the post should be in the form
+ {
+    "nodeRefs" : array of nodeRefs for item(s) (record(s) / record folder(s)),
+    "holds" : array of nodeRefs for the hold(s)
+ }
+ ]]> +
+ /api/rma/holds + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.put.desc.xml index 6f18a336fc..13edad40eb 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.put.desc.xml @@ -1,17 +1,17 @@ - - Removes item(s) from the hold(s) - - The body of the put should be in the form
- {
-    "nodeRefs" : array of nodeRefs for the item(s) (record(s) / record folder(s)),
-    "holds" : array of nodeRefs for the hold(s)
- }
- ]]> -
- /api/rma/holds - argument - user - required - internal + + Removes item(s) from the hold(s) + + The body of the put should be in the form
+ {
+    "nodeRefs" : array of nodeRefs for the item(s) (record(s) / record folder(s)),
+    "holds" : array of nodeRefs for the hold(s)
+ }
+ ]]> +
+ /api/rma/holds + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.desc.xml index 4f3dcbf566..5a20fceff7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.desc.xml @@ -1,20 +1,20 @@ - - Gets the list of the hold(s) - - - /api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}&includedInHold={includedInHold?}&fileOnly={fileOnly?} - /api/rma/holds?itemNodeRef={itemNodeRef?} - argument - user - required - internal + + Gets the list of the hold(s) + + + /api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}&includedInHold={includedInHold?}&fileOnly={fileOnly?} + /api/rma/holds?itemNodeRef={itemNodeRef?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.json.ftl index 928522c250..4e64dce155 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/holds.get.json.ftl @@ -1,16 +1,16 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "holds": - [ - <#list holds as hold> - { - "name": "${hold.name}", - "nodeRef": "${hold.nodeRef}" - }<#if hold_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "holds": + [ + <#list holds as hold> + { + "name": "${hold.name}", + "nodeRef": "${hold.nodeRef}" + }<#if hold_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.desc.xml index bb2c537379..6930926ff7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.desc.xml @@ -1,17 +1,17 @@ - - Records Management Import - - The body of the post should be multipart/form-data and contain the following fields.
-
    -
  • destination: array of nodeRefs to export
  • -
  • archive: array of nodeRefs to export
  • -
- ]]> -
- /api/rma/admin/import - - user - required - internal + + Records Management Import + + The body of the post should be multipart/form-data and contain the following fields.
+
    +
  • destination: array of nodeRefs to export
  • +
  • archive: array of nodeRefs to export
  • +
+ ]]> +
+ /api/rma/admin/import + + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.json.ftl index 1ef9fab7d9..d9fc8cee0b 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/import.post.json.ftl @@ -1,5 +1,5 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "success": ${success?string} +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.desc.xml index 9b216d0058..16eb309e1f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.desc.xml @@ -1,9 +1,9 @@ - - List Of Values - Returns lists of items used by the Records Management service - /api/rma/admin/listofvalues - argument - user - required - internal + + List Of Values + Returns lists of items used by the Records Management service + /api/rma/admin/listofvalues + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.json.ftl index a84e447879..bcc3709d1e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.get.json.ftl @@ -1,2 +1,2 @@ -<#import "listofvalues.lib.ftl" as listsLib/> +<#import "listofvalues.lib.ftl" as listsLib/> <@listsLib.listsJSON lists=lists/> \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.lib.ftl index ae50014424..09ef41e1ac 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/listofvalues.lib.ftl @@ -1,75 +1,75 @@ -<#macro listsJSON lists> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "dispositionActions": - { - "url": "${lists.dispositionActions.url}", - "items": - [ - <#list lists.dispositionActions.items as item> - { - "label": "${item.label}", - "value": "${item.value}" - }<#if item_has_next>, - - ] - }, - "events": - { - "url": "${lists.events.url}", - "items": - [ - <#list lists.events.items as item> - { - "label": "${item.label}", - "value": "${item.value}", - "automatic": ${item.automatic?string} - }<#if item_has_next>, - - ] - }, - "periodTypes": - { - "url": "${lists.periodTypes.url}", - "items": - [ - <#list lists.periodTypes.items as item> - { - "label": "${item.label}", - "value": "${item.value}" - }<#if item_has_next>, - - ] - }, - "periodProperties": - { - "url": "${lists.periodProperties.url}", - "items": - [ - <#list lists.periodProperties.items as item> - { - "label": "${item.label}", - "value": "${item.value}" - }<#if item_has_next>, - - ] - }, - "auditEvents": - { - "url": "${lists.auditEvents.url}", - "items": - [ - <#list lists.auditEvents.items as item> - { - "label": "${item.label}", - "value": "${item.value}" - }<#if item_has_next>, - - ] - } - } -} - - +<#macro listsJSON lists> +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "dispositionActions": + { + "url": "${lists.dispositionActions.url}", + "items": + [ + <#list lists.dispositionActions.items as item> + { + "label": "${item.label}", + "value": "${item.value}" + }<#if item_has_next>, + + ] + }, + "events": + { + "url": "${lists.events.url}", + "items": + [ + <#list lists.events.items as item> + { + "label": "${item.label}", + "value": "${item.value}", + "automatic": ${item.automatic?string} + }<#if item_has_next>, + + ] + }, + "periodTypes": + { + "url": "${lists.periodTypes.url}", + "items": + [ + <#list lists.periodTypes.items as item> + { + "label": "${item.label}", + "value": "${item.value}" + }<#if item_has_next>, + + ] + }, + "periodProperties": + { + "url": "${lists.periodProperties.url}", + "items": + [ + <#list lists.periodProperties.items as item> + { + "label": "${item.label}", + "value": "${item.value}" + }<#if item_has_next>, + + ] + }, + "auditEvents": + { + "url": "${lists.auditEvents.url}", + "items": + [ + <#list lists.auditEvents.items as item> + { + "label": "${item.label}", + "value": "${item.value}" + }<#if item_has_next>, + + ] + } + } +} + + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationship.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationship.delete.json.ftl index 3b7961a392..c85c20f2b4 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationship.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationship.delete.json.ftl @@ -1,3 +1,3 @@ -{ - "success": ${success?string} +{ + "success": ${success?string} } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationships.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationships.get.json.ftl index ede191397c..4cb0117aeb 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationships.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/relationships.get.json.ftl @@ -1,15 +1,15 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "items": - [ - <#list relationships as relationship> - { - "node": <#noescape>${relationship} - }<#if relationship_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "items": + [ + <#list relationships as relationship> + { + "node": <#noescape>${relationship} + }<#if relationship_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.desc.xml index 8cf91b17a0..699de3dcde 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.desc.xml @@ -1,9 +1,9 @@ - - Clears Records Management Audit Log - Clears the Records Management audit log - /api/rma/admin/rmauditlog - argument - user - required - internal + + Clears Records Management Audit Log + Clears the Records Management audit log + /api/rma/admin/rmauditlog + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.json.ftl index 9f0631dd99..f324a7ec82 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.delete.json.ftl @@ -1,2 +1,2 @@ -<#import "rmauditlog.lib.ftl" as auditLib/> +<#import "rmauditlog.lib.ftl" as auditLib/> <@auditLib.auditStatusJSON auditstatus=auditstatus/> \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.get.desc.xml index 0f76ff2953..3553d5b79f 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.get.desc.xml @@ -1,22 +1,22 @@ - - Records Management Audit Log - The following parameters can also be passed: -
    -
  • size: Maximum number of log entries to return
  • -
  • user: Only return log entries by the specified user
  • -
  • event: Only return log entries matching this event
  • -
  • from: Only return log entries after the specified date, date should be in yyyy-MM-dd format
  • -
  • to: Only return log entries before the specified date, date should be in yyyy-MM-dd format
  • -
  • export: Set this to 'true' to force the browser to display the Save As dialog
  • -
- ]]> -
- /api/rma/admin/rmauditlog - /api/node/{store_type}/{store_id}/{id}/rmauditlog - argument - user - required - internal + + Records Management Audit Log + The following parameters can also be passed: +
    +
  • size: Maximum number of log entries to return
  • +
  • user: Only return log entries by the specified user
  • +
  • event: Only return log entries matching this event
  • +
  • from: Only return log entries after the specified date, date should be in yyyy-MM-dd format
  • +
  • to: Only return log entries before the specified date, date should be in yyyy-MM-dd format
  • +
  • export: Set this to 'true' to force the browser to display the Save As dialog
  • +
+ ]]> +
+ /api/rma/admin/rmauditlog + /api/node/{store_type}/{store_id}/{id}/rmauditlog + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.lib.ftl index dd270cebca..0450ea0188 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.lib.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.lib.ftl @@ -1,12 +1,12 @@ -<#macro auditStatusJSON auditstatus> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "enabled": ${auditstatus.enabled?string}, - "started": "${auditstatus.started}", - "stopped": "${auditstatus.stopped}" - } -} - - +<#macro auditStatusJSON auditstatus> +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "enabled": ${auditstatus.enabled?string}, + "started": "${auditstatus.started}", + "stopped": "${auditstatus.stopped}" + } +} + + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.post.desc.xml index d0ddd80ac3..0e70b5a335 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.post.desc.xml @@ -1,23 +1,23 @@ - - Files a Records Management audit log as a record - - A JSON structure is expected as follows:
- {
-    "destination" : NodeRef of record folder to file the audit log in
-    "size" : Maximum number of log entries to return
-    "user" : Only return log entries by the specified user
-    "event" : Only return log entries matching this event
-    "from" : Only return log entries after the specified date, date should be in yyyy-MM-dd format
-    "to" : Only return log entries before the specified date, date should be in yyyy-MM-dd format
- }
- ]]> -
- /api/rma/admin/rmauditlog - /api/node/{store_type}/{store_id}/{id}/rmauditlog - argument - user - required - internal + + Files a Records Management audit log as a record + + A JSON structure is expected as follows:
+ {
+    "destination" : NodeRef of record folder to file the audit log in
+    "size" : Maximum number of log entries to return
+    "user" : Only return log entries by the specified user
+    "event" : Only return log entries matching this event
+    "from" : Only return log entries after the specified date, date should be in yyyy-MM-dd format
+    "to" : Only return log entries before the specified date, date should be in yyyy-MM-dd format
+ }
+ ]]> +
+ /api/rma/admin/rmauditlog + /api/node/{store_type}/{store_id}/{id}/rmauditlog + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.desc.xml index e13de43b34..de86e27b70 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.desc.xml @@ -1,16 +1,16 @@ - - Start or Stop Records Management Audit Log - The body of the put should be in the form
- {
-    "enabled" : true|false
- }
- ]]> -
- /api/rma/admin/rmauditlog - argument - user - required - internal + + Start or Stop Records Management Audit Log + The body of the put should be in the form
+ {
+    "enabled" : true|false
+ }
+ ]]> +
+ /api/rma/admin/rmauditlog + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.json.ftl index 9f0631dd99..f324a7ec82 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlog.put.json.ftl @@ -1,2 +1,2 @@ -<#import "rmauditlog.lib.ftl" as auditLib/> +<#import "rmauditlog.lib.ftl" as auditLib/> <@auditLib.auditStatusJSON auditstatus=auditstatus/> \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.desc.xml index 3d32335110..f3d37989ce 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.desc.xml @@ -1,12 +1,12 @@ - - Records Management Audit Log Status - - - /api/rma/admin/rmauditlog/status - argument - user - required - internal + + Records Management Audit Log Status + + + /api/rma/admin/rmauditlog/status + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.json.ftl index bbb76957b5..a9ecc50e4e 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmauditlogstatus.get.json.ftl @@ -1,6 +1,6 @@ -{ - "data" : - { - "enabled" : ${enabled?string} - } +{ + "data" : + { + "enabled" : ${enabled?string} + } } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.desc.xml index 445dc99bf0..5e2e094870 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.desc.xml @@ -1,14 +1,14 @@ - - Get the allowed values for the authenticated user for an rm list constraint. - - listName is the qualified name of the list with the ":" replaced by "_" eg rmc_smList - ]]> - - /api/rma/rmconstraints/{listName} - argument - user - required - internal + + Get the allowed values for the authenticated user for an rm list constraint. + + listName is the qualified name of the list with the ":" replaced by "_" eg rmc_smList + ]]> + + /api/rma/rmconstraints/{listName} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.json.ftl index 995b7e3c48..26fd074f08 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmconstraints.get.json.ftl @@ -1,15 +1,15 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": { - "constraintName": "${constraintName}", - "allowedValuesForCurrentUser" : [ - <#list allowedValuesForCurrentUser as item> - { - "label": "${item}", - "value": "${item}" - }<#if item_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": { + "constraintName": "${constraintName}", + "allowedValuesForCurrentUser" : [ + <#list allowedValuesForCurrentUser as item> + { + "label": "${item}", + "value": "${item}" + }<#if item_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.desc.xml index e96bac280c..cfd7423f82 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.desc.xml @@ -1,36 +1,36 @@ - - Apply Records Management Permissions to a node - -
- The body of the post json should be of the form: -
-   {
-      "permissions":
-      [
-         {
-            "id": "Filing",
-            "authority": "GROUP_Administrator"
-         },
-         {
-            "id": "ReadRecords",
-            "authority": "userxyz"
-            "remove": true
-         },
-         ...
-      ]
-   }
-   
- Existing permissions will be updated by the supplied permission set, - where 'id' and 'authority' are mandatory values.
- If the optional 'remove' flag is set then the permission will be removed. - Note that it is only valid to set the following RM related permissions: - 'Filing', 'ReadRecords' and 'FileRecords'. - ]]> -
- /api/node/{store_type}/{store_id}/{id}/rmpermissions - argument - user - required - internal + + Apply Records Management Permissions to a node + +
+ The body of the post json should be of the form: +
+   {
+      "permissions":
+      [
+         {
+            "id": "Filing",
+            "authority": "GROUP_Administrator"
+         },
+         {
+            "id": "ReadRecords",
+            "authority": "userxyz"
+            "remove": true
+         },
+         ...
+      ]
+   }
+   
+ Existing permissions will be updated by the supplied permission set, + where 'id' and 'authority' are mandatory values.
+ If the optional 'remove' flag is set then the permission will be removed. + Note that it is only valid to set the following RM related permissions: + 'Filing', 'ReadRecords' and 'FileRecords'. + ]]> +
+ /api/node/{store_type}/{store_id}/{id}/rmpermissions + argument + user + required + internal
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.json.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.json.js index a29ec41b13..5415eb9247 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.json.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/rmpermissions.post.json.js @@ -1,57 +1,57 @@ -/** - * Entry point for rmpermissions POST data webscript. - * Applies supplied RM permissions to an RM node. - * - * @method main - */ -function main() -{ - // Get the node from the URL - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = search.findNode(pathSegments[2], reference); - - // 404 if the node is not found - if (node == null) - { - status.setCode(status.STATUS_NOT_FOUND, "The node could not be found"); - return; - } - - if (json.has("permissions") == false) - { - status.setCode(status.STATUS_BAD_REQUEST, "Permissions value missing from request."); - } - - if (json.has("isInherited")) - { - node.setInheritsPermissions(json.getBoolean("isInherited")); - } - - var permissions = json.getJSONArray("permissions"); - for (var i=0; i - Records Management Transfer - Streams an Alfresco Content Pacakge (ACP) file containing the contents of a transfer - /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id} - argument - user - required - deprecated + + Records Management Transfer + Streams an Alfresco Content Pacakge (ACP) file containing the contents of a transfer + /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id} + argument + user + required + deprecated \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.get.desc.xml index 8a82f9637b..a450507a86 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.get.desc.xml @@ -1,9 +1,9 @@ - - Records Management Transfer Report - Returns a transfer report to the caller in JSON format - /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id}/report - argument - user - required - deprecated + + Records Management Transfer Report + Returns a transfer report to the caller in JSON format + /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id}/report + argument + user + required + deprecated \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.post.desc.xml index 882842220a..26a514a0aa 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/transferreport.post.desc.xml @@ -1,16 +1,16 @@ - - Files a Records Management Transfer Report - A JSON structure is expected as follows:
- {
-    "destination" : NodeRef of record folder to file the transfer report in
- }
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id}/report - argument - user - required - deprecated + + Files a Records Management Transfer Report + A JSON structure is expected as follows:
+ {
+    "destination" : NodeRef of record folder to file the transfer report in
+ }
+ ]]> +
+ /api/node/{store_type}/{store_id}/{id}/transfers/{transfer_id}/report + argument + user + required + deprecated
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.desc.xml index d0151a4915..5026a37097 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.desc.xml @@ -1,9 +1,9 @@ - - Records Management User Rights Report - Returns a user rights report showing users, roles and groups to the caller in JSON format - /api/rma/admin/userrightsreport - argument - user - required - internal + + Records Management User Rights Report + Returns a user rights report showing users, roles and groups to the caller in JSON format + /api/rma/admin/userrightsreport + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.json.ftl index 81e88674a3..24221308b7 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/userrightsreport.get.json.ftl @@ -1,46 +1,46 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "users": - { - <#list report.users?keys as user> - "${user}": - { - "userName": "${report.users[user].userName!""}", - "firstName": "${report.users[user].firstName!""}", - "lastName": "${report.users[user].lastName!""}", - "roles": [<#list report.users[user].roles as role>"${role}"<#if role_has_next>,], - "groups": [<#list report.users[user].groups as group>"${group}"<#if group_has_next>,] - } - <#if user_has_next>, - - }, - "roles": - { - <#list report.roles?keys as role> - "${role}": - { - "name": "${report.roles[role].name!""}", - "label": "${report.roles[role].displayLabel!""}", - "users": [<#list report.roles[role].users as user>"${user}"<#if user_has_next>,], - "capabilities": [<#list report.roles[role].capabilities as capability>"${capability}"<#if capability_has_next>,] - } - <#if role_has_next>, - - }, - "groups": - { - <#list report.groups?keys as group> - "${group}": - { - "name": "${report.groups[group].name!""}", - "label": "${report.groups[group].displayLabel!""}", - "users": [<#list report.groups[group].users as user>"${user}"<#if user_has_next>,] - } - <#if group_has_next>, - - } - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "users": + { + <#list report.users?keys as user> + "${user}": + { + "userName": "${report.users[user].userName!""}", + "firstName": "${report.users[user].firstName!""}", + "lastName": "${report.users[user].lastName!""}", + "roles": [<#list report.users[user].roles as role>"${role}"<#if role_has_next>,], + "groups": [<#list report.users[user].groups as group>"${group}"<#if group_has_next>,] + } + <#if user_has_next>, + + }, + "roles": + { + <#list report.roles?keys as role> + "${role}": + { + "name": "${report.roles[role].name!""}", + "label": "${report.roles[role].displayLabel!""}", + "users": [<#list report.roles[role].users as user>"${user}"<#if user_has_next>,], + "capabilities": [<#list report.roles[role].capabilities as capability>"${capability}"<#if capability_has_next>,] + } + <#if role_has_next>, + + }, + "groups": + { + <#list report.groups?keys as group> + "${group}": + { + "name": "${report.groups[group].name!""}", + "label": "${report.groups[group].displayLabel!""}", + "users": [<#list report.groups[group].users as user>"${user}"<#if user_has_next>,] + } + <#if group_has_next>, + + } + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js index 768af5f619..8d39c68554 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js @@ -1,11 +1,11 @@ - - - - - - - -/** - * Document List Component: doclist - */ -model.doclist = rm_doclist_main(); + + + + + + + +/** + * Document List Component: doclist + */ +model.doclist = rm_doclist_main(); diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-filters.lib.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-filters.lib.js index c68408e498..eb8651d3fd 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-filters.lib.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-filters.lib.js @@ -1,196 +1,196 @@ -/** -* Query templates for custom search -*/ -Filters.QUERY_TEMPLATES = -[ - { field: "keywords", template: "%(cm:name cm:title cm:description TEXT)" }, - { field: "name", template: "%(cm:name)" }, - { field: "title", template: "%(cm:title)" }, - { field: "description", template: "%(cm:description)" }, - { field: "creator", template: "%(cm:creator)" }, - { field: "created", template: "%(cm:created)" }, - { field: "modifier", template: "%(cm:modifier)" }, - { field: "modified", template: "%(cm:modified)" }, - { field: "author", template: "%(cm:author)" }, - { field: "markings", template: "%(rmc:supplementalMarkingList)" }, - { field: "dispositionEvents", template: "%(rma:recordSearchDispositionEvents)" }, - { field: "dispositionActionName", template: "%(rma:recordSearchDispositionActionName)" }, - { field: "dispositionActionAsOf", template: "%(rma:recordSearchDispositionActionAsOf)" }, - { field: "dispositionEventsEligible", template: "%(rma:recordSearchDispositionEventsEligible)" }, - { field: "dispositionPeriod", template: "%(rma:recordSearchDispositionPeriod)" }, - { field: "hasDispositionSchedule", template: "%(rma:recordSearchHasDispositionSchedule)" }, - { field: "dispositionInstructions", template: "%(rma:recordSearchDispositionInstructions)" }, - { field: "dispositionAuthority", template: "%(rma:recordSearchDispositionAuthority)" }, - { field: "vitalRecordReviewPeriod", template: "%(rma:recordSearchVitalRecordReviewPeriod)" } -]; - -Filters.IGNORED_TYPES = -[ - /* Defaults */ - "cm:systemfolder", - "fm:forums", - "fm:forum", - "fm:topic", - "fm:post", - /* Records Management */ - "rma:dispositionSchedule", - "rma:dispositionActionDefinition", - "rma:dispositionAction", - "rma:holdContainer", - "rma:transferContainer", - "rma:unfiledRecordContainer" -]; - -/** - * Create filter parameters based on input parameters - * - * @method getFilterParams - * @param filter {string} Required filter - * @param parsedArgs {object} Parsed arguments object literal - * @param optional {object} Optional arguments depending on filter type - * @return {object} Object literal containing parameters to be used in Lucene search - */ -Filters.getFilterParams = function RecordsManagementFilter_getFilterParams(filter, parsedArgs, optional) -{ - var filterParams = - { - query: "+PATH:\"" + parsedArgs.pathNode.qnamePath + "/*\"", - limitResults: null, - sort: [ - { - column: "@cm:name", - ascending: true - }], - language: "lucene", - templates: null, - variablePath: true, - ignoreTypes: Filters.IGNORED_TYPES - }; - - optional = optional || {}; - - // Sorting parameters specified? - var sortAscending = args.sortAsc, - sortField = args.sortField; - - if (sortAscending == "false") - { - filterParams.sort[0].ascending = false; - } - if (sortField !== null) - { - filterParams.sort[0].column = (sortField.indexOf(":") != -1 ? "@" : "") + sortField; - } - - // Max returned results specified? - var argMax = args.max; - if ((argMax !== null) && !isNaN(argMax)) - { - filterParams.limitResults = argMax; - } - - // Create query based on passed-in arguments - var filterData = args.filterData, - filterQuery = ""; - - // Common types and aspects to filter from the UI - var filterQueryDefaults = ' -TYPE:"' + Filters.IGNORED_TYPES.join('" -TYPE:"') + '"'; - - // Create query based on passed-in arguments - switch (String(filter)) - { - case "all": - filterQuery = "+PATH:\"" + parsedArgs.rootNode.qnamePath + "//*\""; - filterQuery += " -TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\""; - filterParams.query = filterQuery + filterQueryDefaults; - break; - - case "node": - parsedArgs.pathNode = parsedArgs.rootNode.parent; - filterParams.variablePath = false; - filterParams.query = "+ID:\"" + parsedArgs.rootNode.nodeRef + "\""; - break; - - case "savedsearch": - var searchNode = parsedArgs.location.siteNode.getContainer("Saved Searches"); - if (searchNode != null) - { - var ssNode = searchNode.childByNamePath(String(filterData)); - - if (ssNode != null) - { - var ssJson = eval('try{(' + ssNode.content + ')}catch(e){}'); - filterQuery = ssJson.query; - // Wrap the query so that only valid items within the filePlan are returned - filterParams.query = 'PATH:"' + parsedArgs.rootNode.qnamePath + '//*" AND (' + filterQuery + ')'; - filterParams.templates = Filters.QUERY_TEMPLATES; - filterParams.language = "fts-alfresco"; - filterParams.namespace = "http://www.alfresco.org/model/recordsmanagement/1.0"; - // gather up the sort by fields - // they are encoded as "property/dir" i.e. "cm:name/asc" - if (ssJson.sort && ssJson.sort.length !== 0) - { - var sortPairs = ssJson.sort.split(","); - var sort = []; - for (var i=0, j; i 0) - { - pathNode = container[0]; - } - } - else if (args.filter == "holds") - { - var container = rootNode.childrenByXPath("rma:Holds"); - if (container.length > 0) - { - pathNode = container[0]; - } - } - else if (args.filter == "transfers") - { - var container = rootNode.childrenByXPath("rma:Transfers"); - if (container.length > 0) - { - pathNode = container[0]; - } - } - else - { - // Path input? - path = url.templateArgs.path || ""; - pathNode = path.length > 0 ? rootNode.childByNamePath(path) : (pathNode || rootNode); - } - - if (pathNode === null) - { - status.setCode(status.STATUS_NOT_FOUND, "Path not found: '" + path + "'"); - return null; - } - - // Parent location parameter adjustment - location = Common.getLocation(pathNode, libraryRoot); - if (location === null) - { - status.setCode(status.STATUS_GONE, "Location is 'null'. (No permission?)"); - return null; - } - if (path !== "") - { - location.path = ParseArgs.combinePaths(location.path, location.file); - } - if (args.filter !== "node" && !pathNode.isContainer) - { - location.file = ""; - } - - var objRet = - { - rootNode: rootNode, - pathNode: pathNode, - libraryRoot: libraryRoot, - location: location, - path: path, - nodeRef: nodeRef, - type: type - }; - - // Multiple input files in the JSON body? - var files = ParseArgs.getMultipleInputValues("nodeRefs"); - if (typeof files != "string") - { - objRet.files = files; - } - - return objRet; +/** + * Get and parse arguments + * + * @method getParsedArgs + * @return {array|null} Array containing the validated input parameters + */ +ParseArgs.getParsedArgs = function RecordsManagementFilter_getParsedArgs(containerType) +{ + var type = url.templateArgs.type, + libraryRoot = args.libraryRoot, + rootNode = null, + pathNode = null, + nodeRef = null, + path = "", + location = null; + + // Is this library rooted from a non-site nodeRef? + if (libraryRoot !== null) + { + libraryRoot = ParseArgs.resolveNode(libraryRoot); + } + + + if (url.templateArgs.store_type !== null) + { + /** + * nodeRef input: store_type, store_id and id + */ + var storeType = url.templateArgs.store_type, + storeId = url.templateArgs.store_id, + id = url.templateArgs.id; + + nodeRef = storeType + "://" + storeId + "/" + id; + rootNode = libraryRoot || ParseArgs.resolveNode(nodeRef); + if (rootNode == null) + { + status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); + return null; + } + + // Special case: make sure filter picks up correct mode + if (type == null && args.filter == null) + { + args.filter = "node"; + } + } + else + { + /** + * Site and container input + */ + var siteId = url.templateArgs.site, + containerId = url.templateArgs.container, + siteNode = siteService.getSite(siteId); + + if (siteNode === null) + { + status.setCode(status.STATUS_GONE, "Site not found: '" + siteId + "'"); + return null; + } + + rootNode = siteNode.getContainer(containerId); + if (rootNode === null) + { + rootNode = siteNode.createContainer(containerId, containerType || "cm:folder"); + if (rootNode === null) + { + status.setCode(status.STATUS_GONE, "Document Library container '" + containerId + "' not found in '" + siteId + "'. (No permission?)"); + return null; + } + + rootNode.properties["cm:description"] = "Document Library"; + + /** + * MOB-593: Add email alias on documentLibrary container creation + * + rootNode.addAspect("emailserver:aliasable"); + var emailAlias = siteId; + if (containerId != "documentLibrary") + { + emailAlias += "-" + containerId; + } + rootNode.properties["emailserver:alias"] = emailAlias; + */ + rootNode.save(); + } + } + + if (args.filter == "unfiledRecords") + { + var container = rootNode.childrenByXPath("rma:Unfiled_x0020_Records"); + if (container.length > 0) + { + pathNode = container[0]; + } + } + else if (args.filter == "holds") + { + var container = rootNode.childrenByXPath("rma:Holds"); + if (container.length > 0) + { + pathNode = container[0]; + } + } + else if (args.filter == "transfers") + { + var container = rootNode.childrenByXPath("rma:Transfers"); + if (container.length > 0) + { + pathNode = container[0]; + } + } + else + { + // Path input? + path = url.templateArgs.path || ""; + pathNode = path.length > 0 ? rootNode.childByNamePath(path) : (pathNode || rootNode); + } + + if (pathNode === null) + { + status.setCode(status.STATUS_NOT_FOUND, "Path not found: '" + path + "'"); + return null; + } + + // Parent location parameter adjustment + location = Common.getLocation(pathNode, libraryRoot); + if (location === null) + { + status.setCode(status.STATUS_GONE, "Location is 'null'. (No permission?)"); + return null; + } + if (path !== "") + { + location.path = ParseArgs.combinePaths(location.path, location.file); + } + if (args.filter !== "node" && !pathNode.isContainer) + { + location.file = ""; + } + + var objRet = + { + rootNode: rootNode, + pathNode: pathNode, + libraryRoot: libraryRoot, + location: location, + path: path, + nodeRef: nodeRef, + type: type + }; + + // Multiple input files in the JSON body? + var files = ParseArgs.getMultipleInputValues("nodeRefs"); + if (typeof files != "string") + { + objRet.files = files; + } + + return objRet; }; \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.desc.xml index e61684260a..b6004fb1e4 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.desc.xml @@ -1,9 +1,9 @@ - - Gets Recorded Version Config - Gets Recorded Version Config Data - /slingshot/doclib/action/recorded-version-config/node/{store_type}/{store_id}/{id} - argument - user - required - internal + + Gets Recorded Version Config + Gets Recorded Version Config Data + /slingshot/doclib/action/recorded-version-config/node/{store_type}/{store_id}/{id} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.json.ftl index fef4721616..fd6d052800 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.get.json.ftl @@ -1,16 +1,16 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - "recordableVersions": - [ - <#list recordableVersions as recordableVersion> - { - "policy": "${recordableVersion.policy}", - "selected": "${recordableVersion.selected?string("true", "false")}" - }<#if recordableVersion_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "recordableVersions": + [ + <#list recordableVersions as recordableVersion> + { + "policy": "${recordableVersion.policy}", + "selected": "${recordableVersion.selected?string("true", "false")}" + }<#if recordableVersion_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.post.desc.xml index d40c295377..3d9e11e440 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/recorded-version-config.post.desc.xml @@ -1,9 +1,9 @@ - - Sets Recorded Version Config - Sets Recorded Version Config Data - /slingshot/doclib/action/recorded-version-config/node/{store_type}/{store_id}/{id} - argument - user - required - internal + + Sets Recorded Version Config + Sets Recorded Version Config Data + /slingshot/doclib/action/recorded-version-config/node/{store_type}/{store_id}/{id} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.desc.xml index 6a453de08a..878c391608 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.desc.xml @@ -1,8 +1,8 @@ - - RM node metadata retrieval service - Used by the extended RM forms service to retrieve RM node metadata. - /api/rmmetadata?noderef={noderef?}&type={type?}&extended={extended?} - - user - required + + RM node metadata retrieval service + Used by the extended RM forms service to retrieve RM node metadata. + /api/rmmetadata?noderef={noderef?}&type={type?}&extended={extended?} + + user + required \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.json.ftl index 5179c2499b..3f3bd1b069 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/forms/metadata.get.json.ftl @@ -1,16 +1,16 @@ -{ - "kind" : "${kind}" - <#if extended> - , - "aspects": - [ - <#list aspects as aspect> - { - "name": "${aspect.name}", - "prefixedName": "${aspect.prefixedName}" - } - <#if aspect_has_next>, - - ] - +{ + "kind" : "${kind}" + <#if extended> + , + "aspects": + [ + <#list aspects as aspect> + { + "name": "${aspect.name}", + "prefixedName": "${aspect.prefixedName}" + } + <#if aspect_has_next>, + + ] + } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.desc.xml index ea338656dc..d5cb481437 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.desc.xml @@ -1,9 +1,9 @@ - - rmsavedsearches - RM Saved Searches - /slingshot/rmsavedsearches/site/{site}/{name} - argument - user - required - internal + + rmsavedsearches + RM Saved Searches + /slingshot/rmsavedsearches/site/{site}/{name} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.json.ftl index 576619debc..46b977c060 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.delete.json.ftl @@ -1,3 +1,3 @@ -{ - "success": ${success?string} +{ + "success": ${success?string} } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.desc.xml index f7824c206b..7a030401e0 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.desc.xml @@ -1,9 +1,9 @@ - - rmsavedsearches - RM Saved Searches - /slingshot/rmsavedsearches/site/{site}?p={public?} - argument - user - required - internal + + rmsavedsearches + RM Saved Searches + /slingshot/rmsavedsearches/site/{site}?p={public?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.json.ftl index e554900d31..9a377a7696 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.get.json.ftl @@ -1,16 +1,16 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "items": - [ - <#list savedSearches as s> - { - "name": "${s.name}", - "description": "${s.description!""}", - "query": "${s.query}", - "params": "${s.params}", - "sort": "${s.sort}" - }<#if s_has_next>, - - ] -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "items": + [ + <#list savedSearches as s> + { + "name": "${s.name}", + "description": "${s.description!""}", + "query": "${s.query}", + "params": "${s.params}", + "sort": "${s.sort}" + }<#if s_has_next>, + + ] +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.desc.xml index dd07b5143c..f48520e4cd 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.desc.xml @@ -1,9 +1,9 @@ - - rmsavedsearches - RM Saved Searches - /slingshot/rmsavedsearches/site/{site} - argument - user - required - internal + + rmsavedsearches + RM Saved Searches + /slingshot/rmsavedsearches/site/{site} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.json.ftl index 576619debc..46b977c060 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsavedsearches.post.json.ftl @@ -1,3 +1,3 @@ -{ - "success": ${success?string} +{ + "success": ${success?string} } \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.desc.xml index c97310a712..e001ab570b 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.desc.xml @@ -1,9 +1,9 @@ - - rmsearch - Record Search Component Data Webscript - /slingshot/rmsearch/{site}?query={query?}&sortby={sortby?}&filters={filters?}&maxitems={maxitems?} - argument - user - required - internal + + rmsearch + Record Search Component Data Webscript + /slingshot/rmsearch/{site}?query={query?}&sortby={sortby?}&filters={filters?}&maxitems={maxitems?} + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.json.ftl index 4474bb8afb..16384c1272 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearch.get.json.ftl @@ -1,48 +1,48 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - <#if !errorMessage??> - "items": - [ - <#list items as item> - { - "nodeRef": "${item.nodeRef}", - "type": "${item.type}", - "name": "${item.name}", - "title": "${item.title!''}", - "description": "${item.description!''}", - "modifiedOn": "${xmldate(item.modifiedOn)}", - "modifiedByUser": "${item.modifiedByUser}", - "modifiedBy": "${item.modifiedBy}", - "createdOn": "${xmldate(item.createdOn)}", - "createdByUser": "${item.createdByUser}", - "createdBy": "${item.createdBy}", - "author": "${item.author!''}", - "size": ${item.size?c}, - <#if item.browseUrl??>"browseUrl": "${item.browseUrl}", - "parentFolder": "${item.parentFolder!""}", - "properties": - { - <#assign first=true> - <#list item.properties?keys as k> - <#if item.properties[k]??> - <#if !first>,<#else><#assign first=false>"${k}": - <#assign prop = item.properties[k]> - <#if prop?is_date>"${xmldate(prop)}" - <#elseif prop?is_boolean>${prop?string("true", "false")} - <#elseif prop?is_enumerable>[<#list prop as p>"${p}"<#if p_has_next>, ] - <#elseif prop?is_number>${prop?c} - <#elseif prop?is_string>"${prop}" - <#elseif prop?is_hash_ex>[<#list prop?values as p>"${p}"<#if p_has_next>, ] - <#else>"${prop}" - - - - } - }<#if item_has_next>, - - ] - <#else> - "errorMessage": "${errorMessage}" - -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + <#if !errorMessage??> + "items": + [ + <#list items as item> + { + "nodeRef": "${item.nodeRef}", + "type": "${item.type}", + "name": "${item.name}", + "title": "${item.title!''}", + "description": "${item.description!''}", + "modifiedOn": "${xmldate(item.modifiedOn)}", + "modifiedByUser": "${item.modifiedByUser}", + "modifiedBy": "${item.modifiedBy}", + "createdOn": "${xmldate(item.createdOn)}", + "createdByUser": "${item.createdByUser}", + "createdBy": "${item.createdBy}", + "author": "${item.author!''}", + "size": ${item.size?c}, + <#if item.browseUrl??>"browseUrl": "${item.browseUrl}", + "parentFolder": "${item.parentFolder!""}", + "properties": + { + <#assign first=true> + <#list item.properties?keys as k> + <#if item.properties[k]??> + <#if !first>,<#else><#assign first=false>"${k}": + <#assign prop = item.properties[k]> + <#if prop?is_date>"${xmldate(prop)}" + <#elseif prop?is_boolean>${prop?string("true", "false")} + <#elseif prop?is_enumerable>[<#list prop as p>"${p}"<#if p_has_next>, ] + <#elseif prop?is_number>${prop?c} + <#elseif prop?is_string>"${prop}" + <#elseif prop?is_hash_ex>[<#list prop?values as p>"${p}"<#if p_has_next>, ] + <#else>"${prop}" + + + + } + }<#if item_has_next>, + + ] + <#else> + "errorMessage": "${errorMessage}" + +} \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml index 18105dc400..27f2ff01ac 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml @@ -1,9 +1,9 @@ - - rmsearchproperties - RM Search Properties - /slingshot/rmsearchproperties - argument - user - required - internal + + rmsearchproperties + RM Search Properties + /slingshot/rmsearchproperties + argument + user + required + internal \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl index 0341c3843b..89d5d51afb 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl @@ -1,27 +1,27 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data" : - { - "groups" : - [ - <#list groups as group> - { - "id" : "${group.id}", - "label" : "${group.label}", - "properties" : - [ - <#list group.properties as property> - { - "prefix" : "${property.prefix}", - "name" : "${property.shortName}", - "label" : "${property.label}", - "type" : "${property.type}" - }<#if property_has_next>, - - ] - }<#if group_has_next>, - - ] - } -} +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data" : + { + "groups" : + [ + <#list groups as group> + { + "id" : "${group.id}", + "label" : "${group.label}", + "properties" : + [ + <#list group.properties as property> + { + "prefix" : "${property.prefix}", + "name" : "${property.shortName}", + "label" : "${property.label}", + "type" : "${property.type}" + }<#if property_has_next>, + + ] + }<#if group_has_next>, + + ] + } +} \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/requestInfo.bpmn20.xml b/rm-server/config/alfresco/workflow/requestInfo.bpmn20.xml index 9731a15c90..3959a8f7ae 100644 --- a/rm-server/config/alfresco/workflow/requestInfo.bpmn20.xml +++ b/rm-server/config/alfresco/workflow/requestInfo.bpmn20.xml @@ -1,102 +1,102 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages.properties index f4ed3188ae..ab632e91d7 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Information requested for record -activitiReviewPooled.workflow.info.provided=Information provided for record -activitiReviewPooled.workflow.email.subject=Information provided for the record -activitiReviewPooled.workflow.email.body1=The user -activitiReviewPooled.workflow.email.body2=has provided the information required for the record. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=Workflow Task -rmwf_workflowmodel.type.rmwf_workflowTask.decription=Workflow Task -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Requested Information -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Requestioned Information -rmwf_workflowmodel.property.rmwf_message.title=Message -rmwf_workflowmodel.property.rmwf_message.decription=Message - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Request Information Task -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Request Information Task -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Assignees -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Assignees - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Request Information Task -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Request Information Task - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Request Information Task +activitiReviewPooled.workflow.info.requested=Information requested for record +activitiReviewPooled.workflow.info.provided=Information provided for record +activitiReviewPooled.workflow.email.subject=Information provided for the record +activitiReviewPooled.workflow.email.body1=The user +activitiReviewPooled.workflow.email.body2=has provided the information required for the record. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=Workflow Task +rmwf_workflowmodel.type.rmwf_workflowTask.decription=Workflow Task +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Requested Information +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Requestioned Information +rmwf_workflowmodel.property.rmwf_message.title=Message +rmwf_workflowmodel.property.rmwf_message.decription=Message + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Request Information Task +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Request Information Task +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Assignees +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Assignees + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Request Information Task +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Request Information Task + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Request Information Task rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=Request Information Task \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_de.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_de.properties index d51c979066..ed05cd5bcf 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_de.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_de.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Informationen f\u00fcr Record angefordert -activitiReviewPooled.workflow.info.provided=Informationen f\u00fcr Record bereitgestellt -activitiReviewPooled.workflow.email.subject=Informationen f\u00fcr Record bereitgestellt -activitiReviewPooled.workflow.email.body1=Der Benutzer -activitiReviewPooled.workflow.email.body2=hat die f\u00fcr den Record erforderlichen Informationen bereitgestellt. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=Aufgabe im Workflow -rmwf_workflowmodel.type.rmwf_workflowTask.decription=Aufgabe im Workflow -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Angeforderte Informationen -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Beantragte Informationen -rmwf_workflowmodel.property.rmwf_message.title=Nachricht -rmwf_workflowmodel.property.rmwf_message.decription=Nachricht - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Aufgabe 'Informationen anfordern' -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Aufgabe 'Informationen anfordern' -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Bevollm\u00e4chtigte -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Bevollm\u00e4chtigte - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Aufgabe 'Informationen anfordern' -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Aufgabe 'Informationen anfordern' - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Aufgabe 'Informationen anfordern' +activitiReviewPooled.workflow.info.requested=Informationen f\u00fcr Record angefordert +activitiReviewPooled.workflow.info.provided=Informationen f\u00fcr Record bereitgestellt +activitiReviewPooled.workflow.email.subject=Informationen f\u00fcr Record bereitgestellt +activitiReviewPooled.workflow.email.body1=Der Benutzer +activitiReviewPooled.workflow.email.body2=hat die f\u00fcr den Record erforderlichen Informationen bereitgestellt. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=Aufgabe im Workflow +rmwf_workflowmodel.type.rmwf_workflowTask.decription=Aufgabe im Workflow +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Angeforderte Informationen +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Beantragte Informationen +rmwf_workflowmodel.property.rmwf_message.title=Nachricht +rmwf_workflowmodel.property.rmwf_message.decription=Nachricht + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Aufgabe 'Informationen anfordern' +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Aufgabe 'Informationen anfordern' +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Bevollm\u00e4chtigte +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Bevollm\u00e4chtigte + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Aufgabe 'Informationen anfordern' +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Aufgabe 'Informationen anfordern' + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Aufgabe 'Informationen anfordern' rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=Aufgabe 'Informationen anfordern' \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_es.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_es.properties index 9be2617ad4..e6c63ef0f0 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_es.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_es.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Informaci\u00f3n solicitada para el documento de archivo -activitiReviewPooled.workflow.info.provided=Informaci\u00f3n proporcionada para el documento de archivo -activitiReviewPooled.workflow.email.subject=Informaci\u00f3n proporcionada para el documento de archivo -activitiReviewPooled.workflow.email.body1=El usuario -activitiReviewPooled.workflow.email.body2=ha proporcionado la informaci\u00f3n requerida para el documento de archivo. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=Tarea de flujo de trabajo -rmwf_workflowmodel.type.rmwf_workflowTask.decription=Tarea de flujo de trabajo -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informaci\u00f3n solicitada -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informaci\u00f3n solicitada -rmwf_workflowmodel.property.rmwf_message.title=Mensaje -rmwf_workflowmodel.property.rmwf_message.decription=Mensaje - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Tarea de solicitud de informaci\u00f3n -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Tarea de solicitud de informaci\u00f3n -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Usuarios a asignar la tarea -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Usuarios a asignar la tarea - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Tarea de solicitud de informaci\u00f3n -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Tarea de solicitud de informaci\u00f3n - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Tarea de solicitud de informaci\u00f3n +activitiReviewPooled.workflow.info.requested=Informaci\u00f3n solicitada para el documento de archivo +activitiReviewPooled.workflow.info.provided=Informaci\u00f3n proporcionada para el documento de archivo +activitiReviewPooled.workflow.email.subject=Informaci\u00f3n proporcionada para el documento de archivo +activitiReviewPooled.workflow.email.body1=El usuario +activitiReviewPooled.workflow.email.body2=ha proporcionado la informaci\u00f3n requerida para el documento de archivo. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=Tarea de flujo de trabajo +rmwf_workflowmodel.type.rmwf_workflowTask.decription=Tarea de flujo de trabajo +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informaci\u00f3n solicitada +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informaci\u00f3n solicitada +rmwf_workflowmodel.property.rmwf_message.title=Mensaje +rmwf_workflowmodel.property.rmwf_message.decription=Mensaje + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Tarea de solicitud de informaci\u00f3n +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Tarea de solicitud de informaci\u00f3n +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Usuarios a asignar la tarea +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Usuarios a asignar la tarea + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Tarea de solicitud de informaci\u00f3n +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Tarea de solicitud de informaci\u00f3n + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Tarea de solicitud de informaci\u00f3n rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=Tarea de solicitud de informaci\u00f3n \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_fr.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_fr.properties index 50889487fa..de1315186f 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_fr.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_fr.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Demande d'informations pour le document d'archives -activitiReviewPooled.workflow.info.provided=Informations fournies pour le document d'archives -activitiReviewPooled.workflow.email.subject=Informations fournies pour le document d'archives -activitiReviewPooled.workflow.email.body1=L'utilisateur -activitiReviewPooled.workflow.email.body2=a fourni les informations requises pour le document d'archives. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=T\u00e2che du workflow -rmwf_workflowmodel.type.rmwf_workflowTask.decription=T\u00e2che du workflow -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informations demand\u00e9es -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informations redemand\u00e9es -rmwf_workflowmodel.property.rmwf_message.title=Message -rmwf_workflowmodel.property.rmwf_message.decription=Message - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=T\u00e2che de demande d'informations -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=T\u00e2che de demande d'informations -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Acteurs -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Acteurs - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=T\u00e2che de demande d'informations -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=T\u00e2che de demande d'informations - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=T\u00e2che de demande d'informations +activitiReviewPooled.workflow.info.requested=Demande d'informations pour le document d'archives +activitiReviewPooled.workflow.info.provided=Informations fournies pour le document d'archives +activitiReviewPooled.workflow.email.subject=Informations fournies pour le document d'archives +activitiReviewPooled.workflow.email.body1=L'utilisateur +activitiReviewPooled.workflow.email.body2=a fourni les informations requises pour le document d'archives. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=T\u00e2che du workflow +rmwf_workflowmodel.type.rmwf_workflowTask.decription=T\u00e2che du workflow +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informations demand\u00e9es +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informations redemand\u00e9es +rmwf_workflowmodel.property.rmwf_message.title=Message +rmwf_workflowmodel.property.rmwf_message.decription=Message + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=T\u00e2che de demande d'informations +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=T\u00e2che de demande d'informations +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Acteurs +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Acteurs + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=T\u00e2che de demande d'informations +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=T\u00e2che de demande d'informations + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=T\u00e2che de demande d'informations rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=T\u00e2che de demande d'informations \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_it.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_it.properties index 621ca58951..2c308fca65 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_it.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_it.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Informazioni richieste per record -activitiReviewPooled.workflow.info.provided=Informazioni fornite per record -activitiReviewPooled.workflow.email.subject=Informazioni fornite per il record -activitiReviewPooled.workflow.email.body1=L'utente -activitiReviewPooled.workflow.email.body2=ha fornito le informazioni richieste per il record. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=Attivit\u00e0 del flusso di lavoro -rmwf_workflowmodel.type.rmwf_workflowTask.decription=Attivit\u00e0 del flusso di lavoro -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informazioni richieste -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informazioni richieste -rmwf_workflowmodel.property.rmwf_message.title=Messaggio -rmwf_workflowmodel.property.rmwf_message.decription=Messaggio - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Attivit\u00e0 di richiesta informazioni -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Attivit\u00e0 di richiesta informazioni -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Assegnatari -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Assegnatari - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Attivit\u00e0 di richiesta informazioni -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Attivit\u00e0 di richiesta informazioni - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Attivit\u00e0 di richiesta informazioni +activitiReviewPooled.workflow.info.requested=Informazioni richieste per record +activitiReviewPooled.workflow.info.provided=Informazioni fornite per record +activitiReviewPooled.workflow.email.subject=Informazioni fornite per il record +activitiReviewPooled.workflow.email.body1=L'utente +activitiReviewPooled.workflow.email.body2=ha fornito le informazioni richieste per il record. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=Attivit\u00e0 del flusso di lavoro +rmwf_workflowmodel.type.rmwf_workflowTask.decription=Attivit\u00e0 del flusso di lavoro +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Informazioni richieste +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Informazioni richieste +rmwf_workflowmodel.property.rmwf_message.title=Messaggio +rmwf_workflowmodel.property.rmwf_message.decription=Messaggio + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Attivit\u00e0 di richiesta informazioni +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Attivit\u00e0 di richiesta informazioni +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Assegnatari +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Assegnatari + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Attivit\u00e0 di richiesta informazioni +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Attivit\u00e0 di richiesta informazioni + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Attivit\u00e0 di richiesta informazioni rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=Attivit\u00e0 di richiesta informazioni \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_ja.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_ja.properties index 7d0cb5b363..f0ef566cdd 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_ja.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_ja.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=\u30ec\u30b3\u30fc\u30c9\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u60c5\u5831 -activitiReviewPooled.workflow.info.provided=\u30ec\u30b3\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u305f\u60c5\u5831 -activitiReviewPooled.workflow.email.subject=\u30ec\u30b3\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u305f\u60c5\u5831 -activitiReviewPooled.workflow.email.body1=\u30e6\u30fc\u30b6\u30fc\u304c -activitiReviewPooled.workflow.email.body2=\u30ec\u30b3\u30fc\u30c9\u306b\u5fc5\u8981\u306a\u60c5\u5831\u3092\u6307\u5b9a\u3057\u307e\u3057\u305f\u3002 - -rmwf_workflowmodel.type.rmwf_workflowTask.title=\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30bf\u30b9\u30af -rmwf_workflowmodel.type.rmwf_workflowTask.decription=\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30bf\u30b9\u30af -rmwf_workflowmodel.property.rmwf_requestedInformation.title=\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u60c5\u5831 -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=\u518d\u5ea6\u8cea\u554f\u3055\u308c\u305f\u60c5\u5831 -rmwf_workflowmodel.property.rmwf_message.title=\u30e1\u30c3\u30bb\u30fc\u30b8 -rmwf_workflowmodel.property.rmwf_message.decription=\u30e1\u30c3\u30bb\u30fc\u30b8 - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=\u53d7\u8a17\u8005 -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=\u53d7\u8a17\u8005 - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af +activitiReviewPooled.workflow.info.requested=\u30ec\u30b3\u30fc\u30c9\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u60c5\u5831 +activitiReviewPooled.workflow.info.provided=\u30ec\u30b3\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u305f\u60c5\u5831 +activitiReviewPooled.workflow.email.subject=\u30ec\u30b3\u30fc\u30c9\u306b\u6307\u5b9a\u3055\u308c\u305f\u60c5\u5831 +activitiReviewPooled.workflow.email.body1=\u30e6\u30fc\u30b6\u30fc\u304c +activitiReviewPooled.workflow.email.body2=\u30ec\u30b3\u30fc\u30c9\u306b\u5fc5\u8981\u306a\u60c5\u5831\u3092\u6307\u5b9a\u3057\u307e\u3057\u305f\u3002 + +rmwf_workflowmodel.type.rmwf_workflowTask.title=\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30bf\u30b9\u30af +rmwf_workflowmodel.type.rmwf_workflowTask.decription=\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30bf\u30b9\u30af +rmwf_workflowmodel.property.rmwf_requestedInformation.title=\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u60c5\u5831 +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=\u518d\u5ea6\u8cea\u554f\u3055\u308c\u305f\u60c5\u5831 +rmwf_workflowmodel.property.rmwf_message.title=\u30e1\u30c3\u30bb\u30fc\u30b8 +rmwf_workflowmodel.property.rmwf_message.decription=\u30e1\u30c3\u30bb\u30fc\u30b8 + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=\u53d7\u8a17\u8005 +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=\u53d7\u8a17\u8005 + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=\u60c5\u5831\u30ea\u30af\u30a8\u30b9\u30c8\u30bf\u30b9\u30af \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_nl.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_nl.properties index cab8f8aeac..821a978b0f 100755 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_nl.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_nl.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=Informatie aangevraagd voor record -activitiReviewPooled.workflow.info.provided=Informatie aangeleverd voor record -activitiReviewPooled.workflow.email.subject=Informatie aangeleverd voor de record -activitiReviewPooled.workflow.email.body1=De gebruiker -activitiReviewPooled.workflow.email.body2=heeft de vereiste informatie voor de record aangeleverd. - -rmwf_workflowmodel.type.rmwf_workflowTask.title=Werkstroomtaak -rmwf_workflowmodel.type.rmwf_workflowTask.decription=Werkstroomtaak -rmwf_workflowmodel.property.rmwf_requestedInformation.title=Aangevraagde informatie -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Aangevraagde informatie -rmwf_workflowmodel.property.rmwf_message.title=Bericht -rmwf_workflowmodel.property.rmwf_message.decription=Bericht - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Informatie-aanvraagtaak -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Informatie-aanvraagtaak -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Uitvoerders -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Uitvoerders - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Informatie-aanvraagtaak -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Informatie-aanvraagtaak - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Informatie-aanvraagtaak +activitiReviewPooled.workflow.info.requested=Informatie aangevraagd voor record +activitiReviewPooled.workflow.info.provided=Informatie aangeleverd voor record +activitiReviewPooled.workflow.email.subject=Informatie aangeleverd voor de record +activitiReviewPooled.workflow.email.body1=De gebruiker +activitiReviewPooled.workflow.email.body2=heeft de vereiste informatie voor de record aangeleverd. + +rmwf_workflowmodel.type.rmwf_workflowTask.title=Werkstroomtaak +rmwf_workflowmodel.type.rmwf_workflowTask.decription=Werkstroomtaak +rmwf_workflowmodel.property.rmwf_requestedInformation.title=Aangevraagde informatie +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=Aangevraagde informatie +rmwf_workflowmodel.property.rmwf_message.title=Bericht +rmwf_workflowmodel.property.rmwf_message.decription=Bericht + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=Informatie-aanvraagtaak +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=Informatie-aanvraagtaak +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=Uitvoerders +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=Uitvoerders + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=Informatie-aanvraagtaak +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=Informatie-aanvraagtaak + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=Informatie-aanvraagtaak rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=Informatie-aanvraagtaak \ No newline at end of file diff --git a/rm-server/config/alfresco/workflow/rm-workflow-messages_zh_CN.properties b/rm-server/config/alfresco/workflow/rm-workflow-messages_zh_CN.properties index 12047dd7d9..272c703087 100644 --- a/rm-server/config/alfresco/workflow/rm-workflow-messages_zh_CN.properties +++ b/rm-server/config/alfresco/workflow/rm-workflow-messages_zh_CN.properties @@ -1,23 +1,23 @@ -activitiReviewPooled.workflow.info.requested=\u4e3a\u8bb0\u5f55\u8bf7\u6c42\u7684\u4fe1\u606f -activitiReviewPooled.workflow.info.provided=\u4e3a\u8bb0\u5f55\u63d0\u4f9b\u7684\u4fe1\u606f -activitiReviewPooled.workflow.email.subject=\u4e3a\u8bb0\u5f55\u63d0\u4f9b\u7684\u4fe1\u606f -activitiReviewPooled.workflow.email.body1=\u7528\u6237 -activitiReviewPooled.workflow.email.body2=\u5df2\u7ecf\u63d0\u4f9b\u8bb0\u5f55\u6240\u9700\u7684\u4fe1\u606f\u3002 - -rmwf_workflowmodel.type.rmwf_workflowTask.title=\u5de5\u4f5c\u6d41\u7a0b\u4efb\u52a1 -rmwf_workflowmodel.type.rmwf_workflowTask.decription=\u5de5\u4f5c\u6d41\u7a0b\u4efb\u52a1 -rmwf_workflowmodel.property.rmwf_requestedInformation.title=\u8bf7\u6c42\u7684\u4fe1\u606f -rmwf_workflowmodel.property.rmwf_requestedInformation.decription=\u8bf7\u6c42\u7684\u4fe1\u606f -rmwf_workflowmodel.property.rmwf_message.title=\u6d88\u606f -rmwf_workflowmodel.property.rmwf_message.decription=\u6d88\u606f - -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 -rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 -rmwf_workflowmodel.association.rmwf_mixedAssignees.title=\u88ab\u6307\u6d3e\u8005\u6570 -rmwf_workflowmodel.association.rmwf_mixedAssignees.description=\u88ab\u6307\u6d3e\u8005\u6570 - -rmwf_workflowmodel.type.rmwf_requestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 -rmwf_workflowmodel.type.rmwf_requestInfoTask.description=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 - -rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 +activitiReviewPooled.workflow.info.requested=\u4e3a\u8bb0\u5f55\u8bf7\u6c42\u7684\u4fe1\u606f +activitiReviewPooled.workflow.info.provided=\u4e3a\u8bb0\u5f55\u63d0\u4f9b\u7684\u4fe1\u606f +activitiReviewPooled.workflow.email.subject=\u4e3a\u8bb0\u5f55\u63d0\u4f9b\u7684\u4fe1\u606f +activitiReviewPooled.workflow.email.body1=\u7528\u6237 +activitiReviewPooled.workflow.email.body2=\u5df2\u7ecf\u63d0\u4f9b\u8bb0\u5f55\u6240\u9700\u7684\u4fe1\u606f\u3002 + +rmwf_workflowmodel.type.rmwf_workflowTask.title=\u5de5\u4f5c\u6d41\u7a0b\u4efb\u52a1 +rmwf_workflowmodel.type.rmwf_workflowTask.decription=\u5de5\u4f5c\u6d41\u7a0b\u4efb\u52a1 +rmwf_workflowmodel.property.rmwf_requestedInformation.title=\u8bf7\u6c42\u7684\u4fe1\u606f +rmwf_workflowmodel.property.rmwf_requestedInformation.decription=\u8bf7\u6c42\u7684\u4fe1\u606f +rmwf_workflowmodel.property.rmwf_message.title=\u6d88\u606f +rmwf_workflowmodel.property.rmwf_message.decription=\u6d88\u606f + +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 +rmwf_workflowmodel.type.rmwf_submitRequestInfoTask.description=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 +rmwf_workflowmodel.association.rmwf_mixedAssignees.title=\u88ab\u6307\u6d3e\u8005\u6570 +rmwf_workflowmodel.association.rmwf_mixedAssignees.description=\u88ab\u6307\u6d3e\u8005\u6570 + +rmwf_workflowmodel.type.rmwf_requestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 +rmwf_workflowmodel.type.rmwf_requestInfoTask.description=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 + +rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.title=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 rmwf_workflowmodel.type.rmwf_reviewRequestInfoTask.description=\u8bf7\u6c42\u4fe1\u606f\u4efb\u52a1 \ No newline at end of file diff --git a/rm-server/pom.xml b/rm-server/pom.xml index 8485681602..2289c2dac4 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -1,264 +1,264 @@ - - - - org.alfresco - alfresco-rm-parent - 2.3.1-SNAPSHOT - - 4.0.0 - alfresco-rm-server - Alfresco RM Server - - alfresco - - - source/java - test/java - - - config - - - - - test/resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - - add-source - - - - source/compatibility - - - - - add-test-source - - add-test-source - - - - unit-test/java - - - - - - - maven-surefire-plugin - - - - usedefaultlisteners - false - - - listener - org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter - - - - ${project.build.testOutputDirectory}/testng.xml - - - - - - - - wipeDB - - - - - org.codehaus.mojo - sql-maven-plugin - - true - ${db.driver} - ${db.master.url} - ${db.username} - ${db.password} - - - - postgresql - postgresql - 9.1-901.jdbc4 - - - mysql - mysql-connector-java - 5.1.14 - - - - - wipe-database - process-test-resources - - execute - - - drop database if exists alfresco - - - - create-database - process-test-resources - - execute - - - create database alfresco - - - - - - - - - fullBuild - - - - org.alfresco.maven.plugin - alfresco-maven-plugin - - - - amp - - - - - - maven-antrun-plugin - - - prepare-package - - run - - - - - - - - - - - - - - - - - - enterprise - - alfresco-enterprise - - - - - - org.alfresco - ${webapp.id} - ${alfresco.base.version} - war - - - org.alfresco - alfresco-remote-api - ${alfresco.base.version} - - - - io.takari.junit - takari-cpsuite - 1.2.7 - test - - - junit - junit - 4.11 - test - - - org.springframework.extensions.surf - spring-webscripts - ${alfresco.base.version} - tests - test - - - org.mockito - mockito-all - 1.9.5 - test - - - org.springframework - spring-test - 2.5 - test - - - org.alfresco - alfresco-repository - ${alfresco.base.version} - tests - test - - - org.alfresco - alfresco-remote-api - ${alfresco.base.version} - tests - test - - - - postgresql - postgresql - 9.1-901.jdbc4 - test - - - mysql - mysql-connector-java - 5.1.14 - test - - - - org.uncommons - reportng - 1.1.4 - test - - - com.google.inject - guice - 3.0 - test - - + + + + org.alfresco + alfresco-rm-parent + 2.3.1-SNAPSHOT + + 4.0.0 + alfresco-rm-server + Alfresco RM Server + + alfresco + + + source/java + test/java + + + config + + + + + test/resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + + add-source + + + + source/compatibility + + + + + add-test-source + + add-test-source + + + + unit-test/java + + + + + + + maven-surefire-plugin + + + + usedefaultlisteners + false + + + listener + org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter + + + + ${project.build.testOutputDirectory}/testng.xml + + + + + + + + wipeDB + + + + + org.codehaus.mojo + sql-maven-plugin + + true + ${db.driver} + ${db.master.url} + ${db.username} + ${db.password} + + + + postgresql + postgresql + 9.1-901.jdbc4 + + + mysql + mysql-connector-java + 5.1.14 + + + + + wipe-database + process-test-resources + + execute + + + drop database if exists alfresco + + + + create-database + process-test-resources + + execute + + + create database alfresco + + + + + + + + + fullBuild + + + + org.alfresco.maven.plugin + alfresco-maven-plugin + + + + amp + + + + + + maven-antrun-plugin + + + prepare-package + + run + + + + + + + + + + + + + + + + + + enterprise + + alfresco-enterprise + + + + + + org.alfresco + ${webapp.id} + ${alfresco.base.version} + war + + + org.alfresco + alfresco-remote-api + ${alfresco.base.version} + + + + io.takari.junit + takari-cpsuite + 1.2.7 + test + + + junit + junit + 4.11 + test + + + org.springframework.extensions.surf + spring-webscripts + ${alfresco.base.version} + tests + test + + + org.mockito + mockito-all + 1.9.5 + test + + + org.springframework + spring-test + 2.5 + test + + + org.alfresco + alfresco-repository + ${alfresco.base.version} + tests + test + + + org.alfresco + alfresco-remote-api + ${alfresco.base.version} + tests + test + + + + postgresql + postgresql + 9.1-901.jdbc4 + test + + + mysql + mysql-connector-java + 5.1.14 + test + + + + org.uncommons + reportng + 1.1.4 + test + + + com.google.inject + guice + 3.0 + test + + \ No newline at end of file diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_dod5015/caveat/RMListOfValuesConstraint.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_dod5015/caveat/RMListOfValuesConstraint.java index a49ea148e0..ad64350044 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_dod5015/caveat/RMListOfValuesConstraint.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_dod5015/caveat/RMListOfValuesConstraint.java @@ -1,32 +1,32 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_dod5015.caveat; - -/** - * Compatibility Implementation. - *

- * Used as a compatibility implementation when migrating from V1.0 to V2.0. RMCustom model still references - * this class implementation, but package has been changed. - * - * @author Roy Wetherall - */ -public class RMListOfValuesConstraint extends org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint -{ - // No implementation -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_dod5015.caveat; + +/** + * Compatibility Implementation. + *

+ * Used as a compatibility implementation when migrating from V1.0 to V2.0. RMCustom model still references + * this class implementation, but package has been changed. + * + * @author Roy Wetherall + */ +public class RMListOfValuesConstraint extends org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint +{ + // No implementation +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminService.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminService.java index 14658f9a1b..6b479b2b08 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminService.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminService.java @@ -1,29 +1,29 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - - -/** - * @deprecated as of 2.1 see {@link org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService} - */ -public interface RecordsManagementAdminService - extends org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService -{ - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + + +/** + * @deprecated as of 2.1 see {@link org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService} + */ +public interface RecordsManagementAdminService + extends org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService +{ + +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java index 2cbb01ffab..63f2a8aff0 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java @@ -1,299 +1,299 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management service interface. - * - * Allows simple creation, manipulation and querying of records management components. - * - * @author Roy Wetherall - * @deprecated as of 2.2 - */ -public interface RecordsManagementService -{ - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} - */ - @Deprecated - boolean isFilePlanComponent(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} - */ - @Deprecated - FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} - */ - @Deprecated - FilePlanComponentKind getFilePlanComponentKindFromType(QName type); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} - */ - @Deprecated - boolean isRecordsManagementContainer(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} - */ - @Deprecated - boolean isFilePlan(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} - */ - @Deprecated - boolean isRecordCategory(NodeRef nodeRef); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} - */ - @Deprecated - boolean isRecordFolder(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.2, see {@link TransferService#isTransfer(NodeRef)} - */ - @Deprecated - boolean isTransfer(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} - */ - @Deprecated - boolean isMetadataStub(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)} - */ - boolean isCutoff(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} - */ - @Deprecated - List getNodeRefPath(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} - */ - @Deprecated - NodeRef getFilePlan(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} - */ - @Deprecated - List getFilePlans(); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} - */ - @Deprecated - NodeRef createFilePlan(NodeRef parent, String name, QName type); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} - */ - @Deprecated - NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} - */ - @Deprecated - NodeRef createFilePlan(NodeRef parent, String name); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} - */ - @Deprecated - NodeRef createFilePlan(NodeRef parent, String name, Map properties); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} - */ - @Deprecated - List getAllContained(NodeRef recordCategory, boolean deep); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} - */ - @Deprecated - List getAllContained(NodeRef recordCategory); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} - */ - @Deprecated - List getContainedRecordCategories(NodeRef recordCategory, boolean deep); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} - */ - @Deprecated - List getContainedRecordCategories(NodeRef recordCategory); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} - */ - @Deprecated - List getContainedRecordFolders(NodeRef container, boolean deep); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} - */ - @Deprecated - List getContainedRecordFolders(NodeRef container); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} - */ - @Deprecated - NodeRef createRecordCategory(NodeRef parent, String name, QName type); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} - */ - @Deprecated - NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} - */ - @Deprecated - NodeRef createRecordCategory(NodeRef parent, String name); - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} - */ - @Deprecated - NodeRef createRecordCategory(NodeRef parent, String name, Map properties); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} - */ - @Deprecated - boolean isRecordFolderDeclared(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} - */ - @Deprecated - boolean isRecordFolderClosed(NodeRef nodeRef); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} - */ - @Deprecated - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} - */ - @Deprecated - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} - */ - @Deprecated - NodeRef createRecordFolder(NodeRef parent, String name); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map) - */ - @Deprecated - NodeRef createRecordFolder(NodeRef parent, String name, Map properties); - - /** - * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} - */ - @Deprecated - List getRecords(NodeRef recordFolder); - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} - */ - @Deprecated - List getRecordFolders(NodeRef record); - - /** - * @deprecated As of 2.1, replaced by {@link RecordService#getRecordMetaDataAspects()} - */ - @Deprecated - Set getRecordMetaDataAspects(); - - /** - * @deprecated As of 2.1, replaced by {@link RecordService#isDeclared(NodeRef)} - */ - @Deprecated - boolean isRecordDeclared(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.1, replaced by {@link FreezeService#isHold(NodeRef)} - */ - @Deprecated - boolean isHold(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.1, replaced by {@link FreezeService#isFrozen(NodeRef)} - */ - @Deprecated - boolean isFrozen(NodeRef nodeRef); - - /** - * @since 2.0 - * @deprecated As of 2.1, replaced by {@link FreezeService#hasFrozenChildren(NodeRef)} - */ - @Deprecated - boolean hasFrozenChildren(NodeRef nodeRef); - - /** - * @deprecated As of 2.1, replaced by {@link RecordService#isRecord(NodeRef)} - */ - @Deprecated - boolean isRecord(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management service interface. + * + * Allows simple creation, manipulation and querying of records management components. + * + * @author Roy Wetherall + * @deprecated as of 2.2 + */ +public interface RecordsManagementService +{ + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + */ + @Deprecated + boolean isFilePlanComponent(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} + */ + @Deprecated + FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} + */ + @Deprecated + FilePlanComponentKind getFilePlanComponentKindFromType(QName type); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} + */ + @Deprecated + boolean isRecordsManagementContainer(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + */ + @Deprecated + boolean isFilePlan(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} + */ + @Deprecated + boolean isRecordCategory(NodeRef nodeRef); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} + */ + @Deprecated + boolean isRecordFolder(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.2, see {@link TransferService#isTransfer(NodeRef)} + */ + @Deprecated + boolean isTransfer(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} + */ + @Deprecated + boolean isMetadataStub(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)} + */ + boolean isCutoff(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} + */ + @Deprecated + List getNodeRefPath(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} + */ + @Deprecated + NodeRef getFilePlan(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} + */ + @Deprecated + List getFilePlans(); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} + */ + @Deprecated + NodeRef createFilePlan(NodeRef parent, String name, QName type); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} + */ + @Deprecated + NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} + */ + @Deprecated + NodeRef createFilePlan(NodeRef parent, String name); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} + */ + @Deprecated + NodeRef createFilePlan(NodeRef parent, String name, Map properties); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} + */ + @Deprecated + List getAllContained(NodeRef recordCategory, boolean deep); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} + */ + @Deprecated + List getAllContained(NodeRef recordCategory); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} + */ + @Deprecated + List getContainedRecordCategories(NodeRef recordCategory, boolean deep); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} + */ + @Deprecated + List getContainedRecordCategories(NodeRef recordCategory); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} + */ + @Deprecated + List getContainedRecordFolders(NodeRef container, boolean deep); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} + */ + @Deprecated + List getContainedRecordFolders(NodeRef container); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} + */ + @Deprecated + NodeRef createRecordCategory(NodeRef parent, String name, QName type); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} + */ + @Deprecated + NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} + */ + @Deprecated + NodeRef createRecordCategory(NodeRef parent, String name); + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} + */ + @Deprecated + NodeRef createRecordCategory(NodeRef parent, String name, Map properties); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} + */ + @Deprecated + boolean isRecordFolderDeclared(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} + */ + @Deprecated + boolean isRecordFolderClosed(NodeRef nodeRef); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef parent, String name); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map) + */ + @Deprecated + NodeRef createRecordFolder(NodeRef parent, String name, Map properties); + + /** + * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} + */ + @Deprecated + List getRecords(NodeRef recordFolder); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} + */ + @Deprecated + List getRecordFolders(NodeRef record); + + /** + * @deprecated As of 2.1, replaced by {@link RecordService#getRecordMetaDataAspects()} + */ + @Deprecated + Set getRecordMetaDataAspects(); + + /** + * @deprecated As of 2.1, replaced by {@link RecordService#isDeclared(NodeRef)} + */ + @Deprecated + boolean isRecordDeclared(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.1, replaced by {@link FreezeService#isHold(NodeRef)} + */ + @Deprecated + boolean isHold(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.1, replaced by {@link FreezeService#isFrozen(NodeRef)} + */ + @Deprecated + boolean isFrozen(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.1, replaced by {@link FreezeService#hasFrozenChildren(NodeRef)} + */ + @Deprecated + boolean hasFrozenChildren(NodeRef nodeRef); + + /** + * @deprecated As of 2.1, replaced by {@link RecordService#isRecord(NodeRef)} + */ + @Deprecated + boolean isRecord(NodeRef nodeRef); +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java index b764e4234d..4a09c1705b 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java @@ -1,495 +1,495 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management service implementation. - * - * @author Roy Wetherall - * @deprecated as of 2.2 - */ -public class RecordsManagementServiceImpl extends ServiceBaseImpl - implements RecordsManagementService, - RecordsManagementModel -{ - /** Store that the RM roots are contained within */ - @SuppressWarnings("unused") - @Deprecated - private StoreRef defaultStoreRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; - - /** Service registry */ - private RecordsManagementServiceRegistry serviceRegistry; - - /** - * Set the service registry service - * - * @param serviceRegistry service registry - */ - public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry) - { - // Internal ops use the unprotected services from the voter (e.g. nodeService) - this.serviceRegistry = serviceRegistry; - this.dictionaryService = serviceRegistry.getDictionaryService(); - } - - /** - * Sets the default RM store reference - * @param defaultStoreRef store reference - */ - @Deprecated - public void setDefaultStoreRef(StoreRef defaultStoreRef) - { - this.defaultStoreRef = defaultStoreRef; - } - - /** - * @return File plan service - */ - private FilePlanService getFilePlanService() - { - return serviceRegistry.getFilePlanService(); - } - - /** - * @return Record Folder Service - */ - private RecordFolderService getRecordFolderService() - { - return serviceRegistry.getRecordFolderService(); - } - - /** - * @return Record Service - */ - private RecordService getRecordService() - { - return serviceRegistry.getRecordService(); - } - - /** - * @return Freeze Service - */ - private FreezeService getFreezeService() - { - return serviceRegistry.getFreezeService(); - } - - /** - * @return Disposition Service - */ - private DispositionService getDispositionService() - { - return serviceRegistry.getDispositionService(); - } - - /** - * @return Transfer service - */ - private TransferService getTransferService() - { - return serviceRegistry.getTransferService(); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanComponent(NodeRef)} - */ - @Override - public boolean isFilePlanComponent(NodeRef nodeRef) - { - return getFilePlanService().isFilePlanComponent(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} - */ - @Override - public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) - { - return getFilePlanService().getFilePlanComponentKind(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} - */ - @Override - public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) - { - return getFilePlanService().getFilePlanComponentKindFromType(type); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} - */ - @Override - public boolean isRecordsManagementContainer(NodeRef nodeRef) - { - return getFilePlanService().isFilePlanContainer(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} - */ - @Override - public boolean isFilePlan(NodeRef nodeRef) - { - return getFilePlanService().isFilePlan(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} - */ - @Override - public boolean isRecordCategory(NodeRef nodeRef) - { - return getFilePlanService().isRecordCategory(nodeRef); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} - */ - @Override - public boolean isRecordFolder(NodeRef nodeRef) - { - return getRecordFolderService().isRecordFolder(nodeRef); - } - - /** - * @deprecated As of 2.2, see {@link TransferService#isTransfer(NodeRef)} - */ - @Override - public boolean isTransfer(NodeRef nodeRef) - { - return getTransferService().isTransfer(nodeRef); - } - - /** - * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} - */ - @Override - public boolean isMetadataStub(NodeRef nodeRef) - { - return getRecordService().isMetadataStub(nodeRef); - } - - /** - * @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)} - */ - @Override - public boolean isCutoff(NodeRef nodeRef) - { - return getDispositionService().isDisposableItemCutoff(nodeRef); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} - */ - @Override - public List getNodeRefPath(NodeRef nodeRef) - { - return getFilePlanService().getNodeRefPath(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} - */ - @Override - public NodeRef getFilePlan(NodeRef nodeRef) - { - return getFilePlanService().getFilePlan(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} - */ - @Override - public List getFilePlans() - { - return new ArrayList(getFilePlanService().getFilePlans()); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} - */ - @Override - public NodeRef createFilePlan(NodeRef parent, String name, QName type) - { - return getFilePlanService().createFilePlan(parent, name, type); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} - */ - @Override - public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) - { - return getFilePlanService().createFilePlan(parent, name, type, properties); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} - */ - @Override - public NodeRef createFilePlan(NodeRef parent, String name) - { - return getFilePlanService().createFilePlan(parent, name); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} - */ - @Override - public NodeRef createFilePlan(NodeRef parent, String name, Map properties) - { - return getFilePlanService().createFilePlan(parent, name, properties); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} - */ - @Override - public List getAllContained(NodeRef container, boolean deep) - { - return getFilePlanService().getAllContained(container, deep); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} - */ - @Override - public List getAllContained(NodeRef container) - { - return getFilePlanService().getAllContained(container); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} - */ - @Override - public List getContainedRecordCategories(NodeRef container, boolean deep) - { - return getFilePlanService().getContainedRecordCategories(container, deep); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} - */ - @Override - public List getContainedRecordCategories(NodeRef container) - { - return getFilePlanService().getContainedRecordCategories(container); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef, boolean)} - */ - @Override - public List getContainedRecordFolders(NodeRef container, boolean deep) - { - return getFilePlanService().getContainedRecordFolders(container, deep); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} - */ - @Override - public List getContainedRecordFolders(NodeRef container) - { - return getFilePlanService().getContainedRecordFolders(container); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} - */ - @Override - public NodeRef createRecordCategory(NodeRef parent, String name, QName type) - { - return getFilePlanService().createRecordCategory(parent, name, type); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} - */ - @Override - public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) - { - return getFilePlanService().createRecordCategory(parent, name, type, properties); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} - */ - @Override - public NodeRef createRecordCategory(NodeRef parent, String name) - { - return getFilePlanService().createRecordCategory(parent, name); - } - - /** - * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} - */ - public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) - { - return getFilePlanService().createRecordCategory(parent, name, properties); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} - */ - @Override - public boolean isRecordFolderDeclared(NodeRef recordFolder) - { - return getRecordFolderService().isRecordFolderDeclared(recordFolder); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} - */ - @Override - public boolean isRecordFolderClosed(NodeRef nodeRef) - { - return getRecordFolderService().isRecordFolderClosed(nodeRef); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} - */ - @Override - public NodeRef createRecordFolder(NodeRef parent, String name, QName type) - { - return getRecordFolderService().createRecordFolder(parent, name, type); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} - */ - @Override - public NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties) - { - return getRecordFolderService().createRecordFolder(rmContainer, name, type, properties); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} - */ - @Override - public NodeRef createRecordFolder(NodeRef rmContrainer, String name) - { - return getRecordFolderService().createRecordFolder(rmContrainer, name); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map)} - */ - @Override - public NodeRef createRecordFolder(NodeRef parent, String name, Map properties) - { - return getRecordFolderService().createRecordFolder(parent, name, properties); - } - - /** - * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} - */ - @Override - public List getRecords(NodeRef recordFolder) - { - return getRecordService().getRecords(recordFolder); - } - - /** - * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} - */ - @Override - public List getRecordFolders(NodeRef record) - { - return getRecordFolderService().getRecordFolders(record); - } - - /** - * @deprecated As of 2.1, see {@link RecordService#getRecordMetaDataAspects()} - */ - @Override - public Set getRecordMetaDataAspects() - { - return getRecordService().getRecordMetaDataAspects(); - } - - /** - * @deprecated As of 2.1, see {@link RecordService#isDeclared(NodeRef)} - */ - @Override - public boolean isRecordDeclared(NodeRef nodeRef) - { - return getRecordService().isDeclared(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FreezeService#isHold(NodeRef)} - */ - @Override - public boolean isHold(NodeRef nodeRef) - { - return getFreezeService().isHold(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FreezeService#isFrozen(NodeRef)} - */ - @Override - public boolean isFrozen(NodeRef nodeRef) - { - return getFreezeService().isFrozen(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link FreezeService#hasFrozenChildren(NodeRef)} - */ - @Override - public boolean hasFrozenChildren(NodeRef nodeRef) - { - return getFreezeService().hasFrozenChildren(nodeRef); - } - - /** - * @deprecated As of 2.1, see {@link RecordService#isRecord(NodeRef)} - */ - @Override - public boolean isRecord(NodeRef nodeRef) - { - return getRecordService().isRecord(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management service implementation. + * + * @author Roy Wetherall + * @deprecated as of 2.2 + */ +public class RecordsManagementServiceImpl extends ServiceBaseImpl + implements RecordsManagementService, + RecordsManagementModel +{ + /** Store that the RM roots are contained within */ + @SuppressWarnings("unused") + @Deprecated + private StoreRef defaultStoreRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; + + /** Service registry */ + private RecordsManagementServiceRegistry serviceRegistry; + + /** + * Set the service registry service + * + * @param serviceRegistry service registry + */ + public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry) + { + // Internal ops use the unprotected services from the voter (e.g. nodeService) + this.serviceRegistry = serviceRegistry; + this.dictionaryService = serviceRegistry.getDictionaryService(); + } + + /** + * Sets the default RM store reference + * @param defaultStoreRef store reference + */ + @Deprecated + public void setDefaultStoreRef(StoreRef defaultStoreRef) + { + this.defaultStoreRef = defaultStoreRef; + } + + /** + * @return File plan service + */ + private FilePlanService getFilePlanService() + { + return serviceRegistry.getFilePlanService(); + } + + /** + * @return Record Folder Service + */ + private RecordFolderService getRecordFolderService() + { + return serviceRegistry.getRecordFolderService(); + } + + /** + * @return Record Service + */ + private RecordService getRecordService() + { + return serviceRegistry.getRecordService(); + } + + /** + * @return Freeze Service + */ + private FreezeService getFreezeService() + { + return serviceRegistry.getFreezeService(); + } + + /** + * @return Disposition Service + */ + private DispositionService getDispositionService() + { + return serviceRegistry.getDispositionService(); + } + + /** + * @return Transfer service + */ + private TransferService getTransferService() + { + return serviceRegistry.getTransferService(); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanComponent(NodeRef)} + */ + @Override + public boolean isFilePlanComponent(NodeRef nodeRef) + { + return getFilePlanService().isFilePlanComponent(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} + */ + @Override + public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) + { + return getFilePlanService().getFilePlanComponentKind(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} + */ + @Override + public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) + { + return getFilePlanService().getFilePlanComponentKindFromType(type); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} + */ + @Override + public boolean isRecordsManagementContainer(NodeRef nodeRef) + { + return getFilePlanService().isFilePlanContainer(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + */ + @Override + public boolean isFilePlan(NodeRef nodeRef) + { + return getFilePlanService().isFilePlan(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} + */ + @Override + public boolean isRecordCategory(NodeRef nodeRef) + { + return getFilePlanService().isRecordCategory(nodeRef); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} + */ + @Override + public boolean isRecordFolder(NodeRef nodeRef) + { + return getRecordFolderService().isRecordFolder(nodeRef); + } + + /** + * @deprecated As of 2.2, see {@link TransferService#isTransfer(NodeRef)} + */ + @Override + public boolean isTransfer(NodeRef nodeRef) + { + return getTransferService().isTransfer(nodeRef); + } + + /** + * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} + */ + @Override + public boolean isMetadataStub(NodeRef nodeRef) + { + return getRecordService().isMetadataStub(nodeRef); + } + + /** + * @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)} + */ + @Override + public boolean isCutoff(NodeRef nodeRef) + { + return getDispositionService().isDisposableItemCutoff(nodeRef); + } + + /** + * @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} + */ + @Override + public List getNodeRefPath(NodeRef nodeRef) + { + return getFilePlanService().getNodeRefPath(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} + */ + @Override + public NodeRef getFilePlan(NodeRef nodeRef) + { + return getFilePlanService().getFilePlan(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} + */ + @Override + public List getFilePlans() + { + return new ArrayList(getFilePlanService().getFilePlans()); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} + */ + @Override + public NodeRef createFilePlan(NodeRef parent, String name, QName type) + { + return getFilePlanService().createFilePlan(parent, name, type); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} + */ + @Override + public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) + { + return getFilePlanService().createFilePlan(parent, name, type, properties); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} + */ + @Override + public NodeRef createFilePlan(NodeRef parent, String name) + { + return getFilePlanService().createFilePlan(parent, name); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} + */ + @Override + public NodeRef createFilePlan(NodeRef parent, String name, Map properties) + { + return getFilePlanService().createFilePlan(parent, name, properties); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} + */ + @Override + public List getAllContained(NodeRef container, boolean deep) + { + return getFilePlanService().getAllContained(container, deep); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} + */ + @Override + public List getAllContained(NodeRef container) + { + return getFilePlanService().getAllContained(container); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} + */ + @Override + public List getContainedRecordCategories(NodeRef container, boolean deep) + { + return getFilePlanService().getContainedRecordCategories(container, deep); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} + */ + @Override + public List getContainedRecordCategories(NodeRef container) + { + return getFilePlanService().getContainedRecordCategories(container); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef, boolean)} + */ + @Override + public List getContainedRecordFolders(NodeRef container, boolean deep) + { + return getFilePlanService().getContainedRecordFolders(container, deep); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} + */ + @Override + public List getContainedRecordFolders(NodeRef container) + { + return getFilePlanService().getContainedRecordFolders(container); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name, QName type) + { + return getFilePlanService().createRecordCategory(parent, name, type); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) + { + return getFilePlanService().createRecordCategory(parent, name, type, properties); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name) + { + return getFilePlanService().createRecordCategory(parent, name); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} + */ + public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) + { + return getFilePlanService().createRecordCategory(parent, name, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} + */ + @Override + public boolean isRecordFolderDeclared(NodeRef recordFolder) + { + return getRecordFolderService().isRecordFolderDeclared(recordFolder); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} + */ + @Override + public boolean isRecordFolderClosed(NodeRef nodeRef) + { + return getRecordFolderService().isRecordFolderClosed(nodeRef); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} + */ + @Override + public NodeRef createRecordFolder(NodeRef parent, String name, QName type) + { + return getRecordFolderService().createRecordFolder(parent, name, type); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties) + { + return getRecordFolderService().createRecordFolder(rmContainer, name, type, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContrainer, String name) + { + return getRecordFolderService().createRecordFolder(rmContrainer, name); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map)} + */ + @Override + public NodeRef createRecordFolder(NodeRef parent, String name, Map properties) + { + return getRecordFolderService().createRecordFolder(parent, name, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} + */ + @Override + public List getRecords(NodeRef recordFolder) + { + return getRecordService().getRecords(recordFolder); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} + */ + @Override + public List getRecordFolders(NodeRef record) + { + return getRecordFolderService().getRecordFolders(record); + } + + /** + * @deprecated As of 2.1, see {@link RecordService#getRecordMetaDataAspects()} + */ + @Override + public Set getRecordMetaDataAspects() + { + return getRecordService().getRecordMetaDataAspects(); + } + + /** + * @deprecated As of 2.1, see {@link RecordService#isDeclared(NodeRef)} + */ + @Override + public boolean isRecordDeclared(NodeRef nodeRef) + { + return getRecordService().isDeclared(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FreezeService#isHold(NodeRef)} + */ + @Override + public boolean isHold(NodeRef nodeRef) + { + return getFreezeService().isHold(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FreezeService#isFrozen(NodeRef)} + */ + @Override + public boolean isFrozen(NodeRef nodeRef) + { + return getFreezeService().isFrozen(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FreezeService#hasFrozenChildren(NodeRef)} + */ + @Override + public boolean hasFrozenChildren(NodeRef nodeRef) + { + return getFreezeService().hasFrozenChildren(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link RecordService#isRecord(NodeRef)} + */ + @Override + public boolean isRecord(NodeRef nodeRef) + { + return getRecordService().isRecord(nodeRef); + } +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java index 63a2f6c4b8..a3a3e87cc4 100755 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java @@ -1,71 +1,71 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Deprecated records management audit interface methods. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordsManagementAuditServiceDeprecated -{ - /** - * @deprecated as of 2.1, see {@link #stop(NodeRef)} - */ - @Deprecated - void stop(); - - /** - * @deprecated as of 2.1, see {@link #clear(NodeRef)} - */ - @Deprecated - void clear(); - - /** - * @deprecated as of 2.1, see {@link #isEnabled(NodeRef)} - */ - @Deprecated - boolean isEnabled(); - - /** - * @deprecated as of 2.1, see {@link #getDateLastStarted(NodeRef)} - */ - @Deprecated - Date getDateLastStarted(); - - /** - * @deprecated as of 2.1, see {@link #getDateLastStopped(NodeRef)} - */ - Date getDateLastStopped(); - - /** - * @deprecated as of 2.1 - */ - @Deprecated - void auditRMAction(RecordsManagementAction action, NodeRef nodeRef, Map parameters); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit; + +import java.io.Serializable; +import java.util.Date; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Deprecated records management audit interface methods. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordsManagementAuditServiceDeprecated +{ + /** + * @deprecated as of 2.1, see {@link #stop(NodeRef)} + */ + @Deprecated + void stop(); + + /** + * @deprecated as of 2.1, see {@link #clear(NodeRef)} + */ + @Deprecated + void clear(); + + /** + * @deprecated as of 2.1, see {@link #isEnabled(NodeRef)} + */ + @Deprecated + boolean isEnabled(); + + /** + * @deprecated as of 2.1, see {@link #getDateLastStarted(NodeRef)} + */ + @Deprecated + Date getDateLastStarted(); + + /** + * @deprecated as of 2.1, see {@link #getDateLastStopped(NodeRef)} + */ + Date getDateLastStopped(); + + /** + * @deprecated as of 2.1 + */ + @Deprecated + void auditRMAction(RecordsManagementAction action, NodeRef nodeRef, Map parameters); + +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/compatibility/CompatibilityModel.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/compatibility/CompatibilityModel.java index e3d5a663c7..d6cb17276b 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/compatibility/CompatibilityModel.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/compatibility/CompatibilityModel.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.compatibility; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.service.namespace.QName; - -/** - * RM 1.0 compatibility model - * - * @author Roy Wetherall - */ -public interface CompatibilityModel extends DOD5015Model -{ - // Record series DOD type - QName TYPE_RECORD_SERIES = QName.createQName(DOD_URI, "recordSeries"); - - // V1.0 custom property aspect names - String NAME_CUSTOM_RECORD_PROPERTIES = "customRecordProperties"; - String NAME_CUSTOM_RECORD_FOLDER_PROPERTIES = "customRecordFolderProperties"; - String NAME_CUSTOM_RECORD_CATEGORY_PROPERTIES = "customRecordCategoryProperties"; - String NAME_CUSTOM_RECORD_SERIES_PROPERTIES = "customRecordSeriesProperties"; -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.compatibility; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.service.namespace.QName; + +/** + * RM 1.0 compatibility model + * + * @author Roy Wetherall + */ +public interface CompatibilityModel extends DOD5015Model +{ + // Record series DOD type + QName TYPE_RECORD_SERIES = QName.createQName(DOD_URI, "recordSeries"); + + // V1.0 custom property aspect names + String NAME_CUSTOM_RECORD_PROPERTIES = "customRecordProperties"; + String NAME_CUSTOM_RECORD_FOLDER_PROPERTIES = "customRecordFolderProperties"; + String NAME_CUSTOM_RECORD_CATEGORY_PROPERTIES = "customRecordCategoryProperties"; + String NAME_CUSTOM_RECORD_SERIES_PROPERTIES = "customRecordSeriesProperties"; +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityService.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityService.java index 59dfcc4dca..4cea09d1de 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityService.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityService.java @@ -1,206 +1,206 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management permission service interface - * - * @author Roy Wetherall - * - * @deprecated As of release 2.1, replaced by {@link ModelSecurityService}, {@link FilePlanRoleService} and {@link FilePlanPermissionService} - */ -public interface RecordsManagementSecurityService -{ - /** - * Creates the initial set of default roles for a root records management node - * - * @param rmRootNode root node - * - * @deprecated As of release 2.1, operation no longer supported - */ - @Deprecated - void bootstrapDefaultRoles(NodeRef rmRootNode); - - /** - * Returns the name of the container group for all roles of a specified file - * plan. - * - * @param filePlan file plan node reference - * @return String group name - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getAllRolesContainerGroup(NodeRef)} - */ - @Deprecated - String getAllRolesContainerGroup(NodeRef filePlan); - - /** - * Get all the available roles for the given records management root node - * - * @param rmRootNode root node - * @return {@link Set}<{@link Role}> all roles for a given root node - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRoles(NodeRef)} - */ - @Deprecated - Set getRoles(NodeRef rmRootNode); - - /** - * Gets the roles for a given user - * - * @param rmRootNode - * @param user - * @return - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRolesByUser(NodeRef, String)} - */ - @Deprecated - Set getRolesByUser(NodeRef rmRootNode, String user); - - /** - * Get a role by name - * - * @param rmRootNode - * @param role - * @return - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRole(NodeRef, String)} - */ - @Deprecated - Role getRole(NodeRef rmRootNode, String role); - - /** - * Indicate whether a role exists for a given records management root node - * @param rmRootNode - * @param role - * @return - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#existsRole(NodeRef, String)} - */ - @Deprecated - boolean existsRole(NodeRef rmRootNode, String role); - - /** - * Determines whether the given user has the RM Admin role - * - * @param rmRootNode RM root node - * @param user user name to check - * @return true if the user has the RM Admin role, false otherwise - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#hasRMAdminRole(NodeRef, String)} - */ - @Deprecated - boolean hasRMAdminRole(NodeRef rmRootNode, String user); - - /** - * Create a new role - * - * @param rmRootNode - * @param role - * @param roleDisplayLabel - * @param capabilities - * @return - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#createRole(NodeRef, String, String, Set)} - */ - @Deprecated - Role createRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities); - - /** - * Update an existing role - * - * @param rmRootNode - * @param role - * @param roleDisplayLabel - * @param capabilities - * @return - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#updateRole(NodeRef, String, String, Set)} - */ - @Deprecated - Role updateRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities); - - /** - * Delete a role - * - * @param rmRootNode - * @param role - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#deleteRole(NodeRef, String)} - */ - @Deprecated - void deleteRole(NodeRef rmRootNode, String role); - - /** - * Assign a role to an authority - * - * @param authorityName - * @param rmRootNode - * @param role - * - * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#assignRoleToAuthority(NodeRef, String, String)} - */ - @Deprecated - void assignRoleToAuthority(NodeRef rmRootNode, String role, String authorityName); - - /** - * Sets a permission on a RM object. Assumes allow is true. Cascades permission down to record folder. - * Cascades ReadRecord up to file plan. - * - * @param nodeRef node reference - * @param authority authority - * @param permission permission - * - * @deprecated As of release 2.1, replaced by {@link FilePlanPermissionService#setPermission(NodeRef, String, String)} - */ - @Deprecated - void setPermission(NodeRef nodeRef, String authority, String permission); - - /** - * Deletes a permission from a RM object. Cascades removal down to record folder. - * - * @param nodeRef node reference - * @param authority authority - * @param permission permission - * - * @deprecated As of release 2.1, replaced by {@link FilePlanPermissionService#deletePermission(NodeRef, String, String)} - */ - @Deprecated - void deletePermission(NodeRef nodeRef, String authority, String permission); - - /** - * @return {@link Set}<{@link QName}> protected aspect names - * @deprecated As of release 2.1, replaced by {@link ModelSecurityService#getProtectedAspects} - */ - @Deprecated - Set getProtectedAspects(); - - /** - * @return {@link Set}<{@link QName}> protected properties - * @deprecated As of release 2.1, replaced by {@link ModelSecurityService#getProtectedProperties} - */ - Set getProtectedProperties(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management permission service interface + * + * @author Roy Wetherall + * + * @deprecated As of release 2.1, replaced by {@link ModelSecurityService}, {@link FilePlanRoleService} and {@link FilePlanPermissionService} + */ +public interface RecordsManagementSecurityService +{ + /** + * Creates the initial set of default roles for a root records management node + * + * @param rmRootNode root node + * + * @deprecated As of release 2.1, operation no longer supported + */ + @Deprecated + void bootstrapDefaultRoles(NodeRef rmRootNode); + + /** + * Returns the name of the container group for all roles of a specified file + * plan. + * + * @param filePlan file plan node reference + * @return String group name + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getAllRolesContainerGroup(NodeRef)} + */ + @Deprecated + String getAllRolesContainerGroup(NodeRef filePlan); + + /** + * Get all the available roles for the given records management root node + * + * @param rmRootNode root node + * @return {@link Set}<{@link Role}> all roles for a given root node + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRoles(NodeRef)} + */ + @Deprecated + Set getRoles(NodeRef rmRootNode); + + /** + * Gets the roles for a given user + * + * @param rmRootNode + * @param user + * @return + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRolesByUser(NodeRef, String)} + */ + @Deprecated + Set getRolesByUser(NodeRef rmRootNode, String user); + + /** + * Get a role by name + * + * @param rmRootNode + * @param role + * @return + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#getRole(NodeRef, String)} + */ + @Deprecated + Role getRole(NodeRef rmRootNode, String role); + + /** + * Indicate whether a role exists for a given records management root node + * @param rmRootNode + * @param role + * @return + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#existsRole(NodeRef, String)} + */ + @Deprecated + boolean existsRole(NodeRef rmRootNode, String role); + + /** + * Determines whether the given user has the RM Admin role + * + * @param rmRootNode RM root node + * @param user user name to check + * @return true if the user has the RM Admin role, false otherwise + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#hasRMAdminRole(NodeRef, String)} + */ + @Deprecated + boolean hasRMAdminRole(NodeRef rmRootNode, String user); + + /** + * Create a new role + * + * @param rmRootNode + * @param role + * @param roleDisplayLabel + * @param capabilities + * @return + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#createRole(NodeRef, String, String, Set)} + */ + @Deprecated + Role createRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities); + + /** + * Update an existing role + * + * @param rmRootNode + * @param role + * @param roleDisplayLabel + * @param capabilities + * @return + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#updateRole(NodeRef, String, String, Set)} + */ + @Deprecated + Role updateRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities); + + /** + * Delete a role + * + * @param rmRootNode + * @param role + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#deleteRole(NodeRef, String)} + */ + @Deprecated + void deleteRole(NodeRef rmRootNode, String role); + + /** + * Assign a role to an authority + * + * @param authorityName + * @param rmRootNode + * @param role + * + * @deprecated As of release 2.1, replaced by {@link FilePlanRoleService#assignRoleToAuthority(NodeRef, String, String)} + */ + @Deprecated + void assignRoleToAuthority(NodeRef rmRootNode, String role, String authorityName); + + /** + * Sets a permission on a RM object. Assumes allow is true. Cascades permission down to record folder. + * Cascades ReadRecord up to file plan. + * + * @param nodeRef node reference + * @param authority authority + * @param permission permission + * + * @deprecated As of release 2.1, replaced by {@link FilePlanPermissionService#setPermission(NodeRef, String, String)} + */ + @Deprecated + void setPermission(NodeRef nodeRef, String authority, String permission); + + /** + * Deletes a permission from a RM object. Cascades removal down to record folder. + * + * @param nodeRef node reference + * @param authority authority + * @param permission permission + * + * @deprecated As of release 2.1, replaced by {@link FilePlanPermissionService#deletePermission(NodeRef, String, String)} + */ + @Deprecated + void deletePermission(NodeRef nodeRef, String authority, String permission); + + /** + * @return {@link Set}<{@link QName}> protected aspect names + * @deprecated As of release 2.1, replaced by {@link ModelSecurityService#getProtectedAspects} + */ + @Deprecated + Set getProtectedAspects(); + + /** + * @return {@link Set}<{@link QName}> protected properties + * @deprecated As of release 2.1, replaced by {@link ModelSecurityService#getProtectedProperties} + */ + Set getProtectedProperties(); +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java index 497420898f..96495a8d27 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java @@ -1,221 +1,221 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management permission service implementation - * - * @author Roy Wetherall - */ -@SuppressWarnings("deprecation") -public class RecordsManagementSecurityServiceImpl implements RecordsManagementSecurityService, - RecordsManagementModel -{ - /** Model security service */ - private ModelSecurityService modelSecurityService; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** File plan permission service */ - private FilePlanPermissionService filePlanPermissionService; - - /** - * @param modelSecurityService model security service - */ - public void setModelSecurityService(ModelSecurityService modelSecurityService) - { - this.modelSecurityService = modelSecurityService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param filePlanPermissionService file plan permission service - */ - public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) - { - this.filePlanPermissionService = filePlanPermissionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getProtectedAspects() - */ - @Deprecated - @Override - public Set getProtectedAspects() - { - return modelSecurityService.getProtectedAspects(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getProtectedProperties() - */ - @Deprecated - @Override - public Set getProtectedProperties() - { - return modelSecurityService.getProtectedProperties(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - @Deprecated - @Override - public void assignRoleToAuthority(NodeRef rmRootNode, String role, String authorityName) - { - filePlanRoleService.assignRoleToAuthority(rmRootNode, role, authorityName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#bootstrapDefaultRoles(org.alfresco.service.cmr.repository.NodeRef) - */ - @Deprecated - @Override - public void bootstrapDefaultRoles(NodeRef rmRootNode) - { - throw new UnsupportedOperationException("This method is no longer supported."); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#createRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) - */ - @Deprecated - @Override - public Role createRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities) - { - return Role.toRole(filePlanRoleService.createRole(rmRootNode, role, roleDisplayLabel, capabilities)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deleteRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Deprecated - @Override - public void deleteRole(NodeRef rmRootNode, String role) - { - filePlanRoleService.deleteRole(rmRootNode, role); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#existsRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Deprecated - @Override - public boolean existsRole(NodeRef rmRootNode, String role) - { - return filePlanRoleService.existsRole(rmRootNode, role); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef) - */ - @Deprecated - @Override - public String getAllRolesContainerGroup(NodeRef filePlan) - { - return filePlanRoleService.getAllRolesContainerGroup(filePlan); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Deprecated - @Override - public Role getRole(NodeRef rmRootNode, String role) - { - return Role.toRole(filePlanRoleService.getRole(rmRootNode, role)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRoles(org.alfresco.service.cmr.repository.NodeRef) - */ - @Deprecated - @Override - public Set getRoles(NodeRef rmRootNode) - { - return Role.toRoleSet(filePlanRoleService.getRoles(rmRootNode)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRolesByUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Deprecated - @Override - public Set getRolesByUser(NodeRef rmRootNode, String user) - { - return Role.toRoleSet(filePlanRoleService.getRolesByUser(rmRootNode, user)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#hasRMAdminRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Deprecated - @Override - public boolean hasRMAdminRole(NodeRef rmRootNode, String user) - { - return filePlanRoleService.hasRMAdminRole(rmRootNode, user); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) - */ - @Deprecated - @Override - public Role updateRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities) - { - return Role.toRole(filePlanRoleService.updateRole(rmRootNode, role, roleDisplayLabel, capabilities)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deletePermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - @Deprecated - @Override - public void deletePermission(NodeRef nodeRef, String authority, String permission) - { - filePlanPermissionService.deletePermission(nodeRef, authority, permission); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - @Deprecated - @Override - public void setPermission(NodeRef nodeRef, String authority, String permission) - { - filePlanPermissionService.setPermission(nodeRef, authority, permission); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management permission service implementation + * + * @author Roy Wetherall + */ +@SuppressWarnings("deprecation") +public class RecordsManagementSecurityServiceImpl implements RecordsManagementSecurityService, + RecordsManagementModel +{ + /** Model security service */ + private ModelSecurityService modelSecurityService; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** File plan permission service */ + private FilePlanPermissionService filePlanPermissionService; + + /** + * @param modelSecurityService model security service + */ + public void setModelSecurityService(ModelSecurityService modelSecurityService) + { + this.modelSecurityService = modelSecurityService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param filePlanPermissionService file plan permission service + */ + public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) + { + this.filePlanPermissionService = filePlanPermissionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getProtectedAspects() + */ + @Deprecated + @Override + public Set getProtectedAspects() + { + return modelSecurityService.getProtectedAspects(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getProtectedProperties() + */ + @Deprecated + @Override + public Set getProtectedProperties() + { + return modelSecurityService.getProtectedProperties(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + @Deprecated + @Override + public void assignRoleToAuthority(NodeRef rmRootNode, String role, String authorityName) + { + filePlanRoleService.assignRoleToAuthority(rmRootNode, role, authorityName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#bootstrapDefaultRoles(org.alfresco.service.cmr.repository.NodeRef) + */ + @Deprecated + @Override + public void bootstrapDefaultRoles(NodeRef rmRootNode) + { + throw new UnsupportedOperationException("This method is no longer supported."); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#createRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) + */ + @Deprecated + @Override + public Role createRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities) + { + return Role.toRole(filePlanRoleService.createRole(rmRootNode, role, roleDisplayLabel, capabilities)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deleteRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Deprecated + @Override + public void deleteRole(NodeRef rmRootNode, String role) + { + filePlanRoleService.deleteRole(rmRootNode, role); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#existsRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Deprecated + @Override + public boolean existsRole(NodeRef rmRootNode, String role) + { + return filePlanRoleService.existsRole(rmRootNode, role); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef) + */ + @Deprecated + @Override + public String getAllRolesContainerGroup(NodeRef filePlan) + { + return filePlanRoleService.getAllRolesContainerGroup(filePlan); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Deprecated + @Override + public Role getRole(NodeRef rmRootNode, String role) + { + return Role.toRole(filePlanRoleService.getRole(rmRootNode, role)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRoles(org.alfresco.service.cmr.repository.NodeRef) + */ + @Deprecated + @Override + public Set getRoles(NodeRef rmRootNode) + { + return Role.toRoleSet(filePlanRoleService.getRoles(rmRootNode)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRolesByUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Deprecated + @Override + public Set getRolesByUser(NodeRef rmRootNode, String user) + { + return Role.toRoleSet(filePlanRoleService.getRolesByUser(rmRootNode, user)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#hasRMAdminRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Deprecated + @Override + public boolean hasRMAdminRole(NodeRef rmRootNode, String user) + { + return filePlanRoleService.hasRMAdminRole(rmRootNode, user); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) + */ + @Deprecated + @Override + public Role updateRole(NodeRef rmRootNode, String role, String roleDisplayLabel, Set capabilities) + { + return Role.toRole(filePlanRoleService.updateRole(rmRootNode, role, roleDisplayLabel, capabilities)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deletePermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + @Deprecated + @Override + public void deletePermission(NodeRef nodeRef, String authority, String permission) + { + filePlanPermissionService.deletePermission(nodeRef, authority, permission); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + @Deprecated + @Override + public void setPermission(NodeRef nodeRef, String authority, String permission) + { + filePlanPermissionService.setPermission(nodeRef, authority, permission); + } +} diff --git a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/Role.java b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/Role.java index f2734e14da..87b812b2bd 100644 --- a/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/Role.java +++ b/rm-server/source/compatibility/org/alfresco/module/org_alfresco_module_rm/security/Role.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; - -/** - * Records management role class - * - * @author Roy Wetherall - * - * @deprecated As of release 2.1, see {@link org.alfresco.module.org_alfresco_module_rm.role.Role} - */ -public class Role extends org.alfresco.module.org_alfresco_module_rm.role.Role -{ - /** - * Compatibility method - */ - public static Role toRole(org.alfresco.module.org_alfresco_module_rm.role.Role role) - { - return new Role(role.getName(), role.getDisplayLabel(), role.getCapabilities(), role.getRoleGroupName()); - } - - /** - * Compatibility method - */ - public static Set toRoleSet(Set roles) - { - Set result = new HashSet(roles.size()); - for (org.alfresco.module.org_alfresco_module_rm.role.Role role : roles) - { - result.add(Role.toRole(role)); - } - return result; - } - - /** - * Constructor - */ - @Deprecated - public Role(String name, String displayLabel, Set capabilities, String roleGroupName) - { - super(name, displayLabel, capabilities, roleGroupName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; + +/** + * Records management role class + * + * @author Roy Wetherall + * + * @deprecated As of release 2.1, see {@link org.alfresco.module.org_alfresco_module_rm.role.Role} + */ +public class Role extends org.alfresco.module.org_alfresco_module_rm.role.Role +{ + /** + * Compatibility method + */ + public static Role toRole(org.alfresco.module.org_alfresco_module_rm.role.Role role) + { + return new Role(role.getName(), role.getDisplayLabel(), role.getCapabilities(), role.getRoleGroupName()); + } + + /** + * Compatibility method + */ + public static Set toRoleSet(Set roles) + { + Set result = new HashSet(roles.size()); + for (org.alfresco.module.org_alfresco_module_rm.role.Role role : roles) + { + result.add(Role.toRole(role)); + } + return result; + } + + /** + * Constructor + */ + @Deprecated + public Role(String name, String displayLabel, Set capabilities, String roleGroupName) + { + super(name, displayLabel, capabilities, roleGroupName); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementPolicies.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementPolicies.java index 64bed6e94d..9de7906576 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementPolicies.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementPolicies.java @@ -1,120 +1,120 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.policy.ClassPolicy; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Interface containing records management policies - * - * @author Roy Wetherall - */ -public interface RecordsManagementPolicies -{ - /** Policy names */ - QName BEFORE_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRMActionExecution"); - QName ON_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "onRMActionExecution"); - QName BEFORE_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeCreateReference"); - QName ON_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateReference"); - QName BEFORE_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRemoveReference"); - QName ON_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveReference"); - - /** Before records management action execution */ - interface BeforeRMActionExecution extends ClassPolicy - { - void beforeRMActionExecution(NodeRef nodeRef, String name, Map parameters); - } - - /** On records management action execution */ - interface OnRMActionExecution extends ClassPolicy - { - void onRMActionExecution(NodeRef nodeRef, String name, Map parameters); - } - - /** Before creation of reference */ - interface BeforeCreateReference extends ClassPolicy - { - void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); - } - - /** On creation of reference */ - interface OnCreateReference extends ClassPolicy - { - void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); - } - - /** Before removal of reference */ - interface BeforeRemoveReference extends ClassPolicy - { - void beforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); - } - - /** - * On removal of reference - * - * @since 1.0 - */ - interface OnRemoveReference extends ClassPolicy - { - /** - * @param fromNodeRef from node reference - * @param toNodeRef to node reference - * @param reference name of reference - */ - void onRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); - } - - /** - * Before record file policy - * - * @since 2.2 - */ - interface BeforeFileRecord extends ClassPolicy - { - /** policy name */ - QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRecordFile"); - - /** - * @param nodeRef node reference - */ - void beforeFileRecord(NodeRef nodeRef); - } - - /** - * On record file policy - * - * @since 2.2 - */ - interface OnFileRecord extends ClassPolicy - { - /** policy name */ - QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onRecordFile"); - - /** - * @param nodeRef node reference - */ - void onFileRecord(NodeRef nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.policy.ClassPolicy; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Interface containing records management policies + * + * @author Roy Wetherall + */ +public interface RecordsManagementPolicies +{ + /** Policy names */ + QName BEFORE_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRMActionExecution"); + QName ON_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "onRMActionExecution"); + QName BEFORE_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeCreateReference"); + QName ON_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateReference"); + QName BEFORE_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRemoveReference"); + QName ON_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveReference"); + + /** Before records management action execution */ + interface BeforeRMActionExecution extends ClassPolicy + { + void beforeRMActionExecution(NodeRef nodeRef, String name, Map parameters); + } + + /** On records management action execution */ + interface OnRMActionExecution extends ClassPolicy + { + void onRMActionExecution(NodeRef nodeRef, String name, Map parameters); + } + + /** Before creation of reference */ + interface BeforeCreateReference extends ClassPolicy + { + void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); + } + + /** On creation of reference */ + interface OnCreateReference extends ClassPolicy + { + void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); + } + + /** Before removal of reference */ + interface BeforeRemoveReference extends ClassPolicy + { + void beforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); + } + + /** + * On removal of reference + * + * @since 1.0 + */ + interface OnRemoveReference extends ClassPolicy + { + /** + * @param fromNodeRef from node reference + * @param toNodeRef to node reference + * @param reference name of reference + */ + void onRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference); + } + + /** + * Before record file policy + * + * @since 2.2 + */ + interface BeforeFileRecord extends ClassPolicy + { + /** policy name */ + QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRecordFile"); + + /** + * @param nodeRef node reference + */ + void beforeFileRecord(NodeRef nodeRef); + } + + /** + * On record file policy + * + * @since 2.2 + */ + interface OnFileRecord extends ClassPolicy + { + /** policy name */ + QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onRecordFile"); + + /** + * @param nodeRef node reference + */ + void onFileRecord(NodeRef nodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java index 6eabd7d7e8..dc8ec1a7df 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java @@ -1,184 +1,184 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.service.NotAuditable; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Records management service registry - * - * @author Roy Wetherall - */ -@SuppressWarnings("deprecation") -public interface RecordsManagementServiceRegistry extends ServiceRegistry -{ - /** Service QName constants */ - QName RECORDS_MANAGEMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementService"); - QName DISPOSITION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DispositionService"); - QName RECORDS_MANAGEMENT_ADMIN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAdminService"); - QName RECORDS_MANAGEMENT_ACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementActionService"); - QName RECORDS_MANAGEMENT_EVENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementEventService"); - QName RECORDS_MANAGEMENT_AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAuditService"); - QName CAPABILITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CapabilityService"); - QName RECORD_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordService"); - QName FREEZE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FreezeService"); - QName EXTENDED_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ExtendedSecurityService"); - QName FILE_PLAN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanService"); - QName FILE_PLAN_ROLE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanRoleService"); - QName FILE_PLAN_PERMISSION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanPermissionService"); - QName FILE_PLAN_AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanAuthenticationService"); - QName IDENTIFIER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "recordsManagementIdentifierService"); - QName RECORD_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordFolderService"); - QName TRANSFER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TransferService"); - @Deprecated - QName RECORDS_MANAGEMENT_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementSecurityService"); - - - /** - * @return records management service - */ - @NotAuditable - RecordsManagementService getRecordsManagementService(); - - /** - * @return record service - */ - @NotAuditable - RecordService getRecordService(); - - /** - * @return disposition service - */ - @NotAuditable - DispositionService getDispositionService(); - - /** - * @return records management admin service - */ - @NotAuditable - RecordsManagementAdminService getRecordsManagementAdminService(); - - /** - * @return records management action service - */ - @NotAuditable - RecordsManagementActionService getRecordsManagementActionService(); - - /** - * @return records management event service - */ - @NotAuditable - RecordsManagementEventService getRecordsManagementEventService(); - - /** - * @return records management security service - * - * @deprecated As of release 2.1, replaced with {@link FilePlanRoleService}, {@link FilePlanPermissionService} and {@link ModelSecurityService} - */ - @Deprecated - @NotAuditable - RecordsManagementSecurityService getRecordsManagementSecurityService(); - - /** - * @return records management audit service - */ - @NotAuditable - RecordsManagementAuditService getRecordsManagementAuditService(); - - /** - * @return capability service - * @since 2.0 - */ - @NotAuditable - CapabilityService getCapabilityService(); - - /** - * @return freeze service - * @since 2.1 - */ - @NotAuditable - FreezeService getFreezeService(); - - /** - * @return extended security service - * @since 2.1 - */ - @NotAuditable - ExtendedSecurityService getExtendedSecurityService(); - - /** - * @return file plan service - * @since 2.1 - */ - @NotAuditable - FilePlanService getFilePlanService(); - - /** - * @return file plan role service - * @since 2.1 - */ - @NotAuditable - FilePlanRoleService getFilePlanRoleService(); - - /** - * @return file plan permission service - * @since 2.1 - */ - @NotAuditable - FilePlanPermissionService getFilePlanPermissionService(); - - /** - * @return identifier service - * @since 2.1 - */ - IdentifierService getIdentifierService(); - - /** - * @return record folder service - * @since 2.2 - */ - @NotAuditable - RecordFolderService getRecordFolderService(); - - /** - * @return transfer service - * @since 2.2 - */ - @NotAuditable - TransferService getTransferService(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.service.NotAuditable; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Records management service registry + * + * @author Roy Wetherall + */ +@SuppressWarnings("deprecation") +public interface RecordsManagementServiceRegistry extends ServiceRegistry +{ + /** Service QName constants */ + QName RECORDS_MANAGEMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementService"); + QName DISPOSITION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DispositionService"); + QName RECORDS_MANAGEMENT_ADMIN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAdminService"); + QName RECORDS_MANAGEMENT_ACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementActionService"); + QName RECORDS_MANAGEMENT_EVENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementEventService"); + QName RECORDS_MANAGEMENT_AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAuditService"); + QName CAPABILITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CapabilityService"); + QName RECORD_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordService"); + QName FREEZE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FreezeService"); + QName EXTENDED_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ExtendedSecurityService"); + QName FILE_PLAN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanService"); + QName FILE_PLAN_ROLE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanRoleService"); + QName FILE_PLAN_PERMISSION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanPermissionService"); + QName FILE_PLAN_AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanAuthenticationService"); + QName IDENTIFIER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "recordsManagementIdentifierService"); + QName RECORD_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordFolderService"); + QName TRANSFER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TransferService"); + @Deprecated + QName RECORDS_MANAGEMENT_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementSecurityService"); + + + /** + * @return records management service + */ + @NotAuditable + RecordsManagementService getRecordsManagementService(); + + /** + * @return record service + */ + @NotAuditable + RecordService getRecordService(); + + /** + * @return disposition service + */ + @NotAuditable + DispositionService getDispositionService(); + + /** + * @return records management admin service + */ + @NotAuditable + RecordsManagementAdminService getRecordsManagementAdminService(); + + /** + * @return records management action service + */ + @NotAuditable + RecordsManagementActionService getRecordsManagementActionService(); + + /** + * @return records management event service + */ + @NotAuditable + RecordsManagementEventService getRecordsManagementEventService(); + + /** + * @return records management security service + * + * @deprecated As of release 2.1, replaced with {@link FilePlanRoleService}, {@link FilePlanPermissionService} and {@link ModelSecurityService} + */ + @Deprecated + @NotAuditable + RecordsManagementSecurityService getRecordsManagementSecurityService(); + + /** + * @return records management audit service + */ + @NotAuditable + RecordsManagementAuditService getRecordsManagementAuditService(); + + /** + * @return capability service + * @since 2.0 + */ + @NotAuditable + CapabilityService getCapabilityService(); + + /** + * @return freeze service + * @since 2.1 + */ + @NotAuditable + FreezeService getFreezeService(); + + /** + * @return extended security service + * @since 2.1 + */ + @NotAuditable + ExtendedSecurityService getExtendedSecurityService(); + + /** + * @return file plan service + * @since 2.1 + */ + @NotAuditable + FilePlanService getFilePlanService(); + + /** + * @return file plan role service + * @since 2.1 + */ + @NotAuditable + FilePlanRoleService getFilePlanRoleService(); + + /** + * @return file plan permission service + * @since 2.1 + */ + @NotAuditable + FilePlanPermissionService getFilePlanPermissionService(); + + /** + * @return identifier service + * @since 2.1 + */ + IdentifierService getIdentifierService(); + + /** + * @return record folder service + * @since 2.2 + */ + @NotAuditable + RecordFolderService getRecordFolderService(); + + /** + * @return transfer service + * @since 2.2 + */ + @NotAuditable + TransferService getTransferService(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java index ba8ce301d9..96a6863700 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java @@ -1,199 +1,199 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.repo.service.ServiceDescriptorRegistry; - -/** - * Records management service registry implementation - * - * @author Roy Wetherall - */ -@SuppressWarnings("deprecation") -public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry - implements RecordsManagementServiceRegistry -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementActionService() - */ - @Override - public RecordsManagementActionService getRecordsManagementActionService() - { - return (RecordsManagementActionService) getService(RECORDS_MANAGEMENT_ACTION_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAdminService() - */ - @Override - public RecordsManagementAdminService getRecordsManagementAdminService() - { - return (RecordsManagementAdminService) getService(RECORDS_MANAGEMENT_ADMIN_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementEventService() - */ - @Override - public RecordsManagementEventService getRecordsManagementEventService() - { - return (RecordsManagementEventService) getService(RECORDS_MANAGEMENT_EVENT_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementService() - */ - @Override - public RecordsManagementService getRecordsManagementService() - { - return (RecordsManagementService) getService(RECORDS_MANAGEMENT_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService() - */ - public RecordService getRecordService() - { - return (RecordService) getService(RECORD_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService() - */ - @Override - @Deprecated - public RecordsManagementSecurityService getRecordsManagementSecurityService() - { - return (RecordsManagementSecurityService) getService(RECORDS_MANAGEMENT_SECURITY_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService() - */ - @Override - public RecordsManagementAuditService getRecordsManagementAuditService() - { - return (RecordsManagementAuditService) getService(RECORDS_MANAGEMENT_AUDIT_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getDictionaryService() - */ - @Override - public DispositionService getDispositionService() - { - return (DispositionService) getService(DISPOSITION_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getCapabilityService() - */ - @Override - public CapabilityService getCapabilityService() - { - return (CapabilityService) getService(CAPABILITY_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFreezeService() - */ - @Override - public FreezeService getFreezeService() - { - return (FreezeService) getService(FREEZE_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getExtendedSecurityService() - */ - @Override - public ExtendedSecurityService getExtendedSecurityService() - { - return (ExtendedSecurityService) getService(EXTENDED_SECURITY_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanService() - */ - @Override - public FilePlanService getFilePlanService() - { - return (FilePlanService) getService(FILE_PLAN_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanRoleService() - */ - @Override - public FilePlanRoleService getFilePlanRoleService() - { - return (FilePlanRoleService) getService(FILE_PLAN_ROLE_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanPermissionService() - */ - @Override - public FilePlanPermissionService getFilePlanPermissionService() - { - return (FilePlanPermissionService) getService(FILE_PLAN_PERMISSION_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getIdentifierService() - */ - @Override - public IdentifierService getIdentifierService() - { - return (IdentifierService) getService(IDENTIFIER_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordFolderService() - */ - @Override - public RecordFolderService getRecordFolderService() - { - return (RecordFolderService) getService(RECORD_FOLDER_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getTransferService() - */ - @Override - public TransferService getTransferService() - { - return (TransferService) getService(TRANSFER_SERVICE); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.repo.service.ServiceDescriptorRegistry; + +/** + * Records management service registry implementation + * + * @author Roy Wetherall + */ +@SuppressWarnings("deprecation") +public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry + implements RecordsManagementServiceRegistry +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementActionService() + */ + @Override + public RecordsManagementActionService getRecordsManagementActionService() + { + return (RecordsManagementActionService) getService(RECORDS_MANAGEMENT_ACTION_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAdminService() + */ + @Override + public RecordsManagementAdminService getRecordsManagementAdminService() + { + return (RecordsManagementAdminService) getService(RECORDS_MANAGEMENT_ADMIN_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementEventService() + */ + @Override + public RecordsManagementEventService getRecordsManagementEventService() + { + return (RecordsManagementEventService) getService(RECORDS_MANAGEMENT_EVENT_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementService() + */ + @Override + public RecordsManagementService getRecordsManagementService() + { + return (RecordsManagementService) getService(RECORDS_MANAGEMENT_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService() + */ + public RecordService getRecordService() + { + return (RecordService) getService(RECORD_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService() + */ + @Override + @Deprecated + public RecordsManagementSecurityService getRecordsManagementSecurityService() + { + return (RecordsManagementSecurityService) getService(RECORDS_MANAGEMENT_SECURITY_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService() + */ + @Override + public RecordsManagementAuditService getRecordsManagementAuditService() + { + return (RecordsManagementAuditService) getService(RECORDS_MANAGEMENT_AUDIT_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getDictionaryService() + */ + @Override + public DispositionService getDispositionService() + { + return (DispositionService) getService(DISPOSITION_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getCapabilityService() + */ + @Override + public CapabilityService getCapabilityService() + { + return (CapabilityService) getService(CAPABILITY_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFreezeService() + */ + @Override + public FreezeService getFreezeService() + { + return (FreezeService) getService(FREEZE_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getExtendedSecurityService() + */ + @Override + public ExtendedSecurityService getExtendedSecurityService() + { + return (ExtendedSecurityService) getService(EXTENDED_SECURITY_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanService() + */ + @Override + public FilePlanService getFilePlanService() + { + return (FilePlanService) getService(FILE_PLAN_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanRoleService() + */ + @Override + public FilePlanRoleService getFilePlanRoleService() + { + return (FilePlanRoleService) getService(FILE_PLAN_ROLE_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanPermissionService() + */ + @Override + public FilePlanPermissionService getFilePlanPermissionService() + { + return (FilePlanPermissionService) getService(FILE_PLAN_PERMISSION_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getIdentifierService() + */ + @Override + public IdentifierService getIdentifierService() + { + return (IdentifierService) getService(IDENTIFIER_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordFolderService() + */ + @Override + public RecordFolderService getRecordFolderService() + { + return (RecordFolderService) getService(RECORD_FOLDER_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getTransferService() + */ + @Override + public TransferService getTransferService() + { + return (TransferService) getService(TRANSFER_SERVICE); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java index 9a9a9b4e5e..4965c07647 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java @@ -1,160 +1,160 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * Auditable action executer abstract base - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class AuditableActionExecuterAbstractBase extends ActionExecuterAbstractBase implements ApplicationContextAware -{ - /** Indicates whether the action is auditable or not */ - private boolean auditable = true; - - /** Indicates whether the action is audited immediately or not */ - private boolean auditedImmediately = false; - - /** Application context */ - private ApplicationContext applicationContext; - - /** Records management audit service */ - private RecordsManagementAuditService auditService; - - /** - * @return True if auditable, false otherwise - */ - protected boolean isAuditable() - { - return this.auditable; - } - - /** - * @return True if audited immediately, false otherwise - */ - protected boolean isAuditedImmediately() - { - return this.auditedImmediately; - } - - /** - * @return Application context - */ - protected ApplicationContext getApplicationContext() - { - return this.applicationContext; - } - - /** - * @param auditable true if auditable, false otherwise - */ - public void setAuditable(boolean auditable) - { - this.auditable = auditable; - } - - /** - * @param auditedImmediately true if to be audited immediately, false to be audited after transaction commits - */ - public void setAuditedImmediately(boolean auditedImmediately) - { - this.auditedImmediately = auditedImmediately; - } - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - { - this.applicationContext = applicationContext; - } - - /** - * @return records management audit service - */ - private RecordsManagementAuditService getAuditService() - { - if (auditService == null) - { - auditService = (RecordsManagementAuditService) getApplicationContext().getBean("recordsManagementAuditService"); - } - return auditService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#init() - */ - @Override - public void init() - { - if (!(this instanceof RecordsManagementAction)) - { - super.init(); - } - - if (isAuditable()) - { - // get the details of the action - String name = getActionDefinition().getName(); - String title = getActionDefinition().getTitle(); - if (title == null || title.isEmpty()) - { - // default to name if no title available - title = name; - } - - // register audit event - getAuditService().registerAuditEvent(name, title); - } - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void execute(Action action, NodeRef actionedUponNodeRef) - { - // audit the execution of the action - if (isAuditable()) - { - if (isAuditedImmediately()) - { - // To be audited immediately before the action is executed, eg. to audit before actionedUponNodeRef gets deleted during the execution. - getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName(), null, null, true); - } - else - { - // To be stacked up with other audit entries and audited after the transaction commits. - getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName()); - } - } - - // execute the action - super.execute(action, actionedUponNodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * Auditable action executer abstract base + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class AuditableActionExecuterAbstractBase extends ActionExecuterAbstractBase implements ApplicationContextAware +{ + /** Indicates whether the action is auditable or not */ + private boolean auditable = true; + + /** Indicates whether the action is audited immediately or not */ + private boolean auditedImmediately = false; + + /** Application context */ + private ApplicationContext applicationContext; + + /** Records management audit service */ + private RecordsManagementAuditService auditService; + + /** + * @return True if auditable, false otherwise + */ + protected boolean isAuditable() + { + return this.auditable; + } + + /** + * @return True if audited immediately, false otherwise + */ + protected boolean isAuditedImmediately() + { + return this.auditedImmediately; + } + + /** + * @return Application context + */ + protected ApplicationContext getApplicationContext() + { + return this.applicationContext; + } + + /** + * @param auditable true if auditable, false otherwise + */ + public void setAuditable(boolean auditable) + { + this.auditable = auditable; + } + + /** + * @param auditedImmediately true if to be audited immediately, false to be audited after transaction commits + */ + public void setAuditedImmediately(boolean auditedImmediately) + { + this.auditedImmediately = auditedImmediately; + } + + /** + * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) + { + this.applicationContext = applicationContext; + } + + /** + * @return records management audit service + */ + private RecordsManagementAuditService getAuditService() + { + if (auditService == null) + { + auditService = (RecordsManagementAuditService) getApplicationContext().getBean("recordsManagementAuditService"); + } + return auditService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#init() + */ + @Override + public void init() + { + if (!(this instanceof RecordsManagementAction)) + { + super.init(); + } + + if (isAuditable()) + { + // get the details of the action + String name = getActionDefinition().getName(); + String title = getActionDefinition().getTitle(); + if (title == null || title.isEmpty()) + { + // default to name if no title available + title = name; + } + + // register audit event + getAuditService().registerAuditEvent(name, title); + } + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void execute(Action action, NodeRef actionedUponNodeRef) + { + // audit the execution of the action + if (isAuditable()) + { + if (isAuditedImmediately()) + { + // To be audited immediately before the action is executed, eg. to audit before actionedUponNodeRef gets deleted during the execution. + getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName(), null, null, true); + } + else + { + // To be stacked up with other audit entries and audited after the transaction commits. + getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName()); + } + } + + // execute the action + super.execute(action, actionedUponNodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/PropertySubActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/PropertySubActionExecuterAbstractBase.java index ea5f5b4ef4..92d68ec5f7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/PropertySubActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/PropertySubActionExecuterAbstractBase.java @@ -1,87 +1,87 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import org.alfresco.repo.action.parameter.ParameterProcessorComponent; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Extension to action implementation hierarchy to insert parameter substitution processing. - * - * NOTE: this should eventually be pushed into the core. - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class PropertySubActionExecuterAbstractBase extends AuditableActionExecuterAbstractBase -{ - /** Parameter processor component */ - private ParameterProcessorComponent parameterProcessorComponent; - - /** Indicates whether parameter substitutions are allowed */ - private boolean allowParameterSubstitutions = false; - - /** - * @return Parameter processor component - */ - protected ParameterProcessorComponent getParameterProcessorComponent() - { - return this.parameterProcessorComponent; - } - - /** - * @return True if parameter substitutions are allowed, false otherwise - */ - protected boolean isAllowParameterSubstitutions() - { - return this.allowParameterSubstitutions; - } - - /** - * @param parameterProcessorComponent parameter processor component - */ - public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) - { - this.parameterProcessorComponent = parameterProcessorComponent; - } - - /** - * @param allowParameterSubstitutions true if property subs allowed, false otherwise - */ - public void setAllowParameterSubstitutions(boolean allowParameterSubstitutions) - { - this.allowParameterSubstitutions = allowParameterSubstitutions; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void execute(Action action, NodeRef actionedUponNodeRef) - { - // do the property subs (if any exist) - if (isAllowParameterSubstitutions()) - { - getParameterProcessorComponent().process(action, getActionDefinition(), actionedUponNodeRef); - } - - super.execute(action, actionedUponNodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import org.alfresco.repo.action.parameter.ParameterProcessorComponent; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Extension to action implementation hierarchy to insert parameter substitution processing. + * + * NOTE: this should eventually be pushed into the core. + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class PropertySubActionExecuterAbstractBase extends AuditableActionExecuterAbstractBase +{ + /** Parameter processor component */ + private ParameterProcessorComponent parameterProcessorComponent; + + /** Indicates whether parameter substitutions are allowed */ + private boolean allowParameterSubstitutions = false; + + /** + * @return Parameter processor component + */ + protected ParameterProcessorComponent getParameterProcessorComponent() + { + return this.parameterProcessorComponent; + } + + /** + * @return True if parameter substitutions are allowed, false otherwise + */ + protected boolean isAllowParameterSubstitutions() + { + return this.allowParameterSubstitutions; + } + + /** + * @param parameterProcessorComponent parameter processor component + */ + public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) + { + this.parameterProcessorComponent = parameterProcessorComponent; + } + + /** + * @param allowParameterSubstitutions true if property subs allowed, false otherwise + */ + public void setAllowParameterSubstitutions(boolean allowParameterSubstitutions) + { + this.allowParameterSubstitutions = allowParameterSubstitutions; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void execute(Action action, NodeRef actionedUponNodeRef) + { + // do the property subs (if any exist) + if (isAllowParameterSubstitutions()) + { + getParameterProcessorComponent().process(action, getActionDefinition(), actionedUponNodeRef); + } + + super.execute(action, actionedUponNodeRef); + } +} 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 a7d60157e2..b750c52e9e 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 @@ -1,612 +1,612 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ActionDefinition; -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.PropertyCheck; -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.util.StringUtils; - -/** - * Records management action executer base class - * - * @author Roy Wetherall - */ -public abstract class RMActionExecuterAbstractBase extends PropertySubActionExecuterAbstractBase - implements RecordsManagementAction, - RecordsManagementModel, - BeanNameAware -{ - /** Namespace service */ - private NamespaceService namespaceService; - - /** Used to control transactional behaviour including post-commit auditing */ - private TransactionService transactionService; - - /** Node service */ - private NodeService nodeService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Content service */ - private ContentService contentService; - - /** Action service */ - private ActionService actionService; - - /** Records management action service */ - private RecordsManagementAuditService recordsManagementAuditService; - - /** Records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** Record service */ - private RecordService recordService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Vital record service */ - private VitalRecordService vitalRecordService; - - /** Records management event service */ - private RecordsManagementEventService recordsManagementEventService; - - /** Records management action service */ - private RecordsManagementAdminService recordsManagementAdminService; - - /** Ownable service **/ - private OwnableService ownableService; - - /** Freeze service */ - private FreezeService freezeService; - - /** Model security service */ - private ModelSecurityService modelSecurityService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** Hold service */ - private HoldService holdService; - - /** List of kinds for which this action is applicable */ - protected Set applicableKinds = new HashSet(); - - /** - * Get the transaction service - */ - protected TransactionService getTransactionService() - { - return this.transactionService; - } - - /** - * Set the transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * Gets the namespace service - */ - protected NamespaceService getNamespaceService() - { - return this.namespaceService; - } - - /** - * Set the namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Gets the node service - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Set node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Gets the dictionary service - */ - protected DictionaryService getDictionaryService() - { - return this.dictionaryService; - } - - /** - * Set the dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Gets the content service - */ - protected ContentService getContentService() - { - return this.contentService; - } - - /** - * Set the content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Gets the action service - */ - protected ActionService getActionService() - { - return this.actionService; - } - - /** - * Set action service - */ - public void setActionService(ActionService actionService) - { - this.actionService = actionService; - } - - /** - * Gets the records management audit service - */ - protected RecordsManagementAuditService getRecordsManagementAuditService() - { - return this.recordsManagementAuditService; - } - - /** - * Set the audit service that action details will be sent to - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) - { - this.recordsManagementAuditService = recordsManagementAuditService; - } - - /** - * Gets the records management action service - */ - protected RecordsManagementActionService getRecordsManagementActionService() - { - return this.recordsManagementActionService; - } - - /** - * Set records management service - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * Gets the disposition service - */ - protected DispositionService getDispositionService() - { - return this.dispositionService; - } - - /** - * Set the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Gets the vital record service - */ - protected VitalRecordService getVitalRecordService() - { - return this.vitalRecordService; - } - - /** - * @param vitalRecordService vital record service - */ - public void setVitalRecordService(VitalRecordService vitalRecordService) - { - this.vitalRecordService = vitalRecordService; - } - - /** - * Gets the records management event service - */ - protected RecordsManagementEventService getRecordsManagementEventService() - { - return this.recordsManagementEventService; - } - - /** - * Set records management event service - */ - public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) - { - this.recordsManagementEventService = recordsManagementEventService; - } - - /** - * Gets the ownable service - */ - protected OwnableService getOwnableService() - { - return this.ownableService; - } - - /** - * Set the ownable service - * @param ownableSerice - */ - public void setOwnableService(OwnableService ownableService) - { - this.ownableService = ownableService; - } - - /** - * Gets the freeze service - */ - protected FreezeService getFreezeService() - { - return this.freezeService; - } - - /** - * Set freeze service - * - * @param freezeService freeze service - */ - public void setFreezeService(FreezeService freezeService) - { - this.freezeService = freezeService; - } - - /** - * Gets the record service - */ - protected RecordService getRecordService() - { - return this.recordService; - } - - /** - * Set record service - * - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @return records management admin service - */ - protected RecordsManagementAdminService getRecordsManagementAdminService() - { - return recordsManagementAdminService; - } - - /** - * @param recordsManagementAdminService records management admin service - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) - { - this.recordsManagementAdminService = recordsManagementAdminService; - } - - /** - * Gets the model security service - */ - protected ModelSecurityService getModelSecurityService() - { - return this.modelSecurityService; - } - - /** - * @param modelSecurityService model security service - */ - public void setModelSecurityService(ModelSecurityService modelSecurityService) - { - this.modelSecurityService = modelSecurityService; - } - - /** - * Gets the record folder service - */ - protected RecordFolderService getRecordFolderService() - { - return this.recordFolderService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * Gets the hold service - */ - protected HoldService getHoldService() - { - return this.holdService; - } - - /** - * @param holdService hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - /** - * @param applicableKinds kinds that this action is applicable for - */ - public void setApplicableKinds(String[] applicableKinds) - { - for(String kind : applicableKinds) - { - this.applicableKinds.add(FilePlanComponentKind.valueOf(kind)); - } - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#createActionDefinition(java.lang.String) - */ - @Override - protected ActionDefinition createActionDefinition(String name) - { - return new RecordsManagementActionDefinitionImpl(name); - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition() - */ - @Override - public ActionDefinition getActionDefinition() - { - ActionDefinition actionDefinition = super.getActionDefinition(); - ((RecordsManagementActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds); - return actionDefinition; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getRecordsManagementActionDefinition() - */ - @Override - public RecordsManagementActionDefinition getRecordsManagementActionDefinition() - { - return (RecordsManagementActionDefinition)getActionDefinition(); - } - - /** - * Init method - */ - @Override - public void init() - { - PropertyCheck.mandatory(this, "namespaceService", namespaceService); - PropertyCheck.mandatory(this, "transactionService", transactionService); - PropertyCheck.mandatory(this, "nodeService", nodeService); - PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); - PropertyCheck.mandatory(this, "contentService", contentService); - PropertyCheck.mandatory(this, "actionService", actionService); - PropertyCheck.mandatory(this, "transactionService", transactionService); - PropertyCheck.mandatory(this, "recordsManagementAuditService", recordsManagementAuditService); - PropertyCheck.mandatory(this, "recordsManagementActionService", recordsManagementActionService); - PropertyCheck.mandatory(this, "recordsManagementAdminService", recordsManagementAdminService); - PropertyCheck.mandatory(this, "recordsManagementEventService", recordsManagementEventService); - - super.init(); - } - - /** - * Indicates whether this records management action is public or not - * - * @return boolean true if public, false otherwise - */ - @Override - public boolean isPublicAction() - { - return publicAction; - } - - /** - * @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String) - */ - @Override - public void setBeanName(String name) - { - this.name = name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName() - */ - public String getName() - { - return this.name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel() - */ - public String getLabel() - { - String label = I18NUtil.getMessage(this.getTitleKey()); - - if (label == null) - { - // default to the name of the action with first letter capitalised - label = StringUtils.capitalize(this.name); - } - - return label; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription() - */ - public String getDescription() - { - String desc = I18NUtil.getMessage(this.getDescriptionKey()); - - if (desc == null) - { - // default to the name of the action with first letter capitalised - desc = StringUtils.capitalize(this.name); - } - - return desc; - } - - /** - * By default an action is not a disposition action - * - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#isDispositionAction() - */ - public boolean isDispositionAction() - { - return false; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#execute(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) - */ - public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map parameters) - { - // Create the action - Action action = this.actionService.createAction(name); - action.setParameterValues(parameters); - - // disable model security whilst we execute the RM rule - modelSecurityService.disable(); - try - { - // Execute the action - actionService.executeAction(action, filePlanComponent); - } - finally - { - modelSecurityService.enable(); - } - - // Get the result - Object value = action.getParameterValue(ActionExecuterAbstractBase.PARAM_RESULT); - return new RecordsManagementActionResult(value); - } - - /** - * Function to pad a string with zero '0' characters to the required length - * - * @param s String to pad with leading zero '0' characters - * @param len Length to pad to - * - * @return padded string or the original if already at >=len characters - * - * @deprecated As of 2.1, replaced by {@link org.apache.commons.lang.StringUtils.leftPad} - */ - @Deprecated - protected String padString(String s, int len) - { - String result = s; - for (int i=0; i<(len - s.length()); i++) - { - result = "0" + result; - } - return result; - } - - /** - * By default there are no parameters. - * - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - // No parameters - } - - /** - * By default, rmActions do not provide an implicit target nodeRef. - */ - public NodeRef getImplicitTargetNodeRef() - { - return null; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ActionDefinition; +import org.alfresco.service.cmr.action.ActionService; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.PropertyCheck; +import org.springframework.beans.factory.BeanNameAware; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.util.StringUtils; + +/** + * Records management action executer base class + * + * @author Roy Wetherall + */ +public abstract class RMActionExecuterAbstractBase extends PropertySubActionExecuterAbstractBase + implements RecordsManagementAction, + RecordsManagementModel, + BeanNameAware +{ + /** Namespace service */ + private NamespaceService namespaceService; + + /** Used to control transactional behaviour including post-commit auditing */ + private TransactionService transactionService; + + /** Node service */ + private NodeService nodeService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** Content service */ + private ContentService contentService; + + /** Action service */ + private ActionService actionService; + + /** Records management action service */ + private RecordsManagementAuditService recordsManagementAuditService; + + /** Records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** Record service */ + private RecordService recordService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Vital record service */ + private VitalRecordService vitalRecordService; + + /** Records management event service */ + private RecordsManagementEventService recordsManagementEventService; + + /** Records management action service */ + private RecordsManagementAdminService recordsManagementAdminService; + + /** Ownable service **/ + private OwnableService ownableService; + + /** Freeze service */ + private FreezeService freezeService; + + /** Model security service */ + private ModelSecurityService modelSecurityService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Hold service */ + private HoldService holdService; + + /** List of kinds for which this action is applicable */ + protected Set applicableKinds = new HashSet(); + + /** + * Get the transaction service + */ + protected TransactionService getTransactionService() + { + return this.transactionService; + } + + /** + * Set the transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * Gets the namespace service + */ + protected NamespaceService getNamespaceService() + { + return this.namespaceService; + } + + /** + * Set the namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Gets the node service + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Set node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Gets the dictionary service + */ + protected DictionaryService getDictionaryService() + { + return this.dictionaryService; + } + + /** + * Set the dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Gets the content service + */ + protected ContentService getContentService() + { + return this.contentService; + } + + /** + * Set the content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * Gets the action service + */ + protected ActionService getActionService() + { + return this.actionService; + } + + /** + * Set action service + */ + public void setActionService(ActionService actionService) + { + this.actionService = actionService; + } + + /** + * Gets the records management audit service + */ + protected RecordsManagementAuditService getRecordsManagementAuditService() + { + return this.recordsManagementAuditService; + } + + /** + * Set the audit service that action details will be sent to + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) + { + this.recordsManagementAuditService = recordsManagementAuditService; + } + + /** + * Gets the records management action service + */ + protected RecordsManagementActionService getRecordsManagementActionService() + { + return this.recordsManagementActionService; + } + + /** + * Set records management service + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * Gets the disposition service + */ + protected DispositionService getDispositionService() + { + return this.dispositionService; + } + + /** + * Set the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Gets the vital record service + */ + protected VitalRecordService getVitalRecordService() + { + return this.vitalRecordService; + } + + /** + * @param vitalRecordService vital record service + */ + public void setVitalRecordService(VitalRecordService vitalRecordService) + { + this.vitalRecordService = vitalRecordService; + } + + /** + * Gets the records management event service + */ + protected RecordsManagementEventService getRecordsManagementEventService() + { + return this.recordsManagementEventService; + } + + /** + * Set records management event service + */ + public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) + { + this.recordsManagementEventService = recordsManagementEventService; + } + + /** + * Gets the ownable service + */ + protected OwnableService getOwnableService() + { + return this.ownableService; + } + + /** + * Set the ownable service + * @param ownableSerice + */ + public void setOwnableService(OwnableService ownableService) + { + this.ownableService = ownableService; + } + + /** + * Gets the freeze service + */ + protected FreezeService getFreezeService() + { + return this.freezeService; + } + + /** + * Set freeze service + * + * @param freezeService freeze service + */ + public void setFreezeService(FreezeService freezeService) + { + this.freezeService = freezeService; + } + + /** + * Gets the record service + */ + protected RecordService getRecordService() + { + return this.recordService; + } + + /** + * Set record service + * + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @return records management admin service + */ + protected RecordsManagementAdminService getRecordsManagementAdminService() + { + return recordsManagementAdminService; + } + + /** + * @param recordsManagementAdminService records management admin service + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) + { + this.recordsManagementAdminService = recordsManagementAdminService; + } + + /** + * Gets the model security service + */ + protected ModelSecurityService getModelSecurityService() + { + return this.modelSecurityService; + } + + /** + * @param modelSecurityService model security service + */ + public void setModelSecurityService(ModelSecurityService modelSecurityService) + { + this.modelSecurityService = modelSecurityService; + } + + /** + * Gets the record folder service + */ + protected RecordFolderService getRecordFolderService() + { + return this.recordFolderService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * Gets the hold service + */ + protected HoldService getHoldService() + { + return this.holdService; + } + + /** + * @param holdService hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * @param applicableKinds kinds that this action is applicable for + */ + public void setApplicableKinds(String[] applicableKinds) + { + for(String kind : applicableKinds) + { + this.applicableKinds.add(FilePlanComponentKind.valueOf(kind)); + } + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#createActionDefinition(java.lang.String) + */ + @Override + protected ActionDefinition createActionDefinition(String name) + { + return new RecordsManagementActionDefinitionImpl(name); + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition() + */ + @Override + public ActionDefinition getActionDefinition() + { + ActionDefinition actionDefinition = super.getActionDefinition(); + ((RecordsManagementActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds); + return actionDefinition; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getRecordsManagementActionDefinition() + */ + @Override + public RecordsManagementActionDefinition getRecordsManagementActionDefinition() + { + return (RecordsManagementActionDefinition)getActionDefinition(); + } + + /** + * Init method + */ + @Override + public void init() + { + PropertyCheck.mandatory(this, "namespaceService", namespaceService); + PropertyCheck.mandatory(this, "transactionService", transactionService); + PropertyCheck.mandatory(this, "nodeService", nodeService); + PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); + PropertyCheck.mandatory(this, "contentService", contentService); + PropertyCheck.mandatory(this, "actionService", actionService); + PropertyCheck.mandatory(this, "transactionService", transactionService); + PropertyCheck.mandatory(this, "recordsManagementAuditService", recordsManagementAuditService); + PropertyCheck.mandatory(this, "recordsManagementActionService", recordsManagementActionService); + PropertyCheck.mandatory(this, "recordsManagementAdminService", recordsManagementAdminService); + PropertyCheck.mandatory(this, "recordsManagementEventService", recordsManagementEventService); + + super.init(); + } + + /** + * Indicates whether this records management action is public or not + * + * @return boolean true if public, false otherwise + */ + @Override + public boolean isPublicAction() + { + return publicAction; + } + + /** + * @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String) + */ + @Override + public void setBeanName(String name) + { + this.name = name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName() + */ + public String getName() + { + return this.name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel() + */ + public String getLabel() + { + String label = I18NUtil.getMessage(this.getTitleKey()); + + if (label == null) + { + // default to the name of the action with first letter capitalised + label = StringUtils.capitalize(this.name); + } + + return label; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription() + */ + public String getDescription() + { + String desc = I18NUtil.getMessage(this.getDescriptionKey()); + + if (desc == null) + { + // default to the name of the action with first letter capitalised + desc = StringUtils.capitalize(this.name); + } + + return desc; + } + + /** + * By default an action is not a disposition action + * + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#isDispositionAction() + */ + public boolean isDispositionAction() + { + return false; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#execute(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) + */ + public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map parameters) + { + // Create the action + Action action = this.actionService.createAction(name); + action.setParameterValues(parameters); + + // disable model security whilst we execute the RM rule + modelSecurityService.disable(); + try + { + // Execute the action + actionService.executeAction(action, filePlanComponent); + } + finally + { + modelSecurityService.enable(); + } + + // Get the result + Object value = action.getParameterValue(ActionExecuterAbstractBase.PARAM_RESULT); + return new RecordsManagementActionResult(value); + } + + /** + * Function to pad a string with zero '0' characters to the required length + * + * @param s String to pad with leading zero '0' characters + * @param len Length to pad to + * + * @return padded string or the original if already at >=len characters + * + * @deprecated As of 2.1, replaced by {@link org.apache.commons.lang.StringUtils.leftPad} + */ + @Deprecated + protected String padString(String s, int len) + { + String result = s; + for (int i=0; i<(len - s.length()); i++) + { + result = "0" + result; + } + return result; + } + + /** + * By default there are no parameters. + * + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + // No parameters + } + + /** + * By default, rmActions do not provide an implicit target nodeRef. + */ + public NodeRef getImplicitTargetNodeRef() + { + return null; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java index aeda1c56c8..7cf50b4b30 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java @@ -1,303 +1,303 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * @author Roy Wetherall - */ -public abstract class RMDispositionActionExecuterAbstractBase extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_RECORD_NOT_DECLARED = "rm.action.record-not-declared"; - private static final String MSG_EXPECTED_RECORD_LEVEL = "rm.action.expected-record-level"; - private static final String MSG_NOT_ALL_RECORDS_DECLARED = "rm.action.not-all-records-declared"; - private static final String MSG_NOT_ELIGIBLE = "rm.action.not-eligible"; - private static final String MSG_NO_DISPOITION_INSTRUCTIONS = "rm.action.no-disposition-instructions"; - private static final String MSG_NO_DIS_LIFECYCLE_SET = "rm.action.no-disposition-lisfecycle-set"; - private static final String MSG_NEXT_DISP_NOT_SET = "rm.action.next-disp-not-set"; - private static final String MSG_NOT_NEXT_DISP = "rm.action.not-next-disp"; - private static final String MSG_NOT_RECORD_FOLDER = "rm.action.not-record-folder"; - - /** Parameter value indicating whether we should be doing non-error raising state checks */ - public static final String PARAM_NO_ERROR_CHECK = "rm.no-error-check"; - - /** - * All children of this implementation are disposition actions. - * - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isDispositionAction() - */ - @Override - public boolean isDispositionAction() - { - return true; - } - - /** - * Indicates whether the disposition is marked complete - * - * @return boolean true if marked complete, false otherwise - */ - public boolean getSetDispositionActionComplete() - { - return true; - } - - /** - * Indicates whether we should validate the next disposition action is the action we are - * trying to execute. - * - * @return - */ - protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef) - { - return true; - } - - /** - * Indicated whether we should validate the disposition action is eligible or not. - * - * @param actionedUponNodeRef - * @return - */ - protected boolean checkEligibility(NodeRef actionedUponNodeRef) - { - return true; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - NodeRef nextDispositionActionNodeRef = getNextDispostionAction(actionedUponNodeRef); - - // determine whether we should be raising errors during state checking or not - boolean checkError = true; - Boolean checkErrorValue = (Boolean)action.getParameterValue(PARAM_NO_ERROR_CHECK); - if (checkErrorValue != null) - { - checkError = checkErrorValue.booleanValue(); - } - - // Check the validity of the action (is it the next action, are we dealing with the correct type of object for - // the disposition level? - DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, checkError); - if (di != null) - { - // Check the eligibility of the action - if (!checkEligibility(actionedUponNodeRef) || - getDispositionService().isNextDispositionActionEligible(actionedUponNodeRef)) - { - if (di.isRecordLevelDisposition()) - { - // Check that we do indeed have a record - if (getRecordService().isRecord(actionedUponNodeRef)) - { - // Can only execute disposition action on record if declared - if (getRecordService().isDeclared(actionedUponNodeRef)) - { - // Indicate that the disposition action is underway - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); - - // Execute record level disposition - executeRecordLevelDisposition(action, actionedUponNodeRef); - - if (getNodeService().exists(nextDispositionActionNodeRef) && - getSetDispositionActionComplete()) - { - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_NOT_DECLARED, getName(), actionedUponNodeRef.toString())); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), actionedUponNodeRef.toString())); - } - } - else - { - if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) - { - if (getRecordFolderService().isRecordFolderDeclared(actionedUponNodeRef)) - { - // Indicate that the disposition action is underway - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); - - executeRecordFolderLevelDisposition(action, actionedUponNodeRef); - - // Indicate that the disposition action is compelte - if (getNodeService().exists(nextDispositionActionNodeRef) && - getSetDispositionActionComplete()) - { - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); - getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); - } - - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ALL_RECORDS_DECLARED, getName(), actionedUponNodeRef.toString())); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString())); - } - - } - - if (getNodeService().exists(actionedUponNodeRef) && getSetDispositionActionComplete()) - { - // Update the disposition schedule - getDispositionService().updateNextDispositionAction(actionedUponNodeRef); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ELIGIBLE, getName(), actionedUponNodeRef.toString())); - } - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - // TODO add the "checkEligibility" parameter - } - - /** - * @param action - * @param record - */ - protected abstract void executeRecordLevelDisposition(Action action, NodeRef record); - - /** - * @param action - * @param recordFolder - */ - protected abstract void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder); - - /** - * @param nodeRef - * @return - */ - protected DispositionSchedule checkDispositionActionExecutionValidity(NodeRef nodeRef, NodeRef nextDispositionActionNodeRef, boolean throwError) - { - // Check the node has associated disposition instructions - DispositionSchedule di = getDispositionService().getDispositionSchedule(nodeRef); - if (di == null) - { - if (throwError) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DISPOITION_INSTRUCTIONS, getName(), nodeRef.toString())); - } - else - { - return null; - } - } - - // Check the node has the disposition schedule aspect applied - if (!getNodeService().hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - if (throwError) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DIS_LIFECYCLE_SET, getName(), nodeRef.toString())); - } - else - { - return null; - } - } - - if (checkNextDispositionAction(nodeRef)) - { - // Check this the next disposition action - NodeRef nextDispositionAction = nextDispositionActionNodeRef; - if (nextDispositionAction == null) - { - if (throwError) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NEXT_DISP_NOT_SET, getName(), nodeRef.toString())); - } - else - { - return null; - } - } - String actionName = (String) getNodeService().getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION); - if (actionName == null || !actionName.equals(getName())) - { - if (throwError) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_NEXT_DISP, getName(), nodeRef.toString())); - } - else - { - return null; - } - } - } - - return di; - } - - /** - * Get the next disposition action node. Null if none present. - * - * @param nodeRef - * the disposable node reference - * @return NodeRef the next disposition action, null if none - */ - private NodeRef getNextDispostionAction(NodeRef nodeRef) - { - NodeRef result = null; - List assocs = getNodeService().getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL); - if (assocs.size() != 0) - { - result = assocs.get(0).getChildRef(); - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.util.Date; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * @author Roy Wetherall + */ +public abstract class RMDispositionActionExecuterAbstractBase extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_RECORD_NOT_DECLARED = "rm.action.record-not-declared"; + private static final String MSG_EXPECTED_RECORD_LEVEL = "rm.action.expected-record-level"; + private static final String MSG_NOT_ALL_RECORDS_DECLARED = "rm.action.not-all-records-declared"; + private static final String MSG_NOT_ELIGIBLE = "rm.action.not-eligible"; + private static final String MSG_NO_DISPOITION_INSTRUCTIONS = "rm.action.no-disposition-instructions"; + private static final String MSG_NO_DIS_LIFECYCLE_SET = "rm.action.no-disposition-lisfecycle-set"; + private static final String MSG_NEXT_DISP_NOT_SET = "rm.action.next-disp-not-set"; + private static final String MSG_NOT_NEXT_DISP = "rm.action.not-next-disp"; + private static final String MSG_NOT_RECORD_FOLDER = "rm.action.not-record-folder"; + + /** Parameter value indicating whether we should be doing non-error raising state checks */ + public static final String PARAM_NO_ERROR_CHECK = "rm.no-error-check"; + + /** + * All children of this implementation are disposition actions. + * + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isDispositionAction() + */ + @Override + public boolean isDispositionAction() + { + return true; + } + + /** + * Indicates whether the disposition is marked complete + * + * @return boolean true if marked complete, false otherwise + */ + public boolean getSetDispositionActionComplete() + { + return true; + } + + /** + * Indicates whether we should validate the next disposition action is the action we are + * trying to execute. + * + * @return + */ + protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef) + { + return true; + } + + /** + * Indicated whether we should validate the disposition action is eligible or not. + * + * @param actionedUponNodeRef + * @return + */ + protected boolean checkEligibility(NodeRef actionedUponNodeRef) + { + return true; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + NodeRef nextDispositionActionNodeRef = getNextDispostionAction(actionedUponNodeRef); + + // determine whether we should be raising errors during state checking or not + boolean checkError = true; + Boolean checkErrorValue = (Boolean)action.getParameterValue(PARAM_NO_ERROR_CHECK); + if (checkErrorValue != null) + { + checkError = checkErrorValue.booleanValue(); + } + + // Check the validity of the action (is it the next action, are we dealing with the correct type of object for + // the disposition level? + DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, checkError); + if (di != null) + { + // Check the eligibility of the action + if (!checkEligibility(actionedUponNodeRef) || + getDispositionService().isNextDispositionActionEligible(actionedUponNodeRef)) + { + if (di.isRecordLevelDisposition()) + { + // Check that we do indeed have a record + if (getRecordService().isRecord(actionedUponNodeRef)) + { + // Can only execute disposition action on record if declared + if (getRecordService().isDeclared(actionedUponNodeRef)) + { + // Indicate that the disposition action is underway + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); + + // Execute record level disposition + executeRecordLevelDisposition(action, actionedUponNodeRef); + + if (getNodeService().exists(nextDispositionActionNodeRef) && + getSetDispositionActionComplete()) + { + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_NOT_DECLARED, getName(), actionedUponNodeRef.toString())); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), actionedUponNodeRef.toString())); + } + } + else + { + if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) + { + if (getRecordFolderService().isRecordFolderDeclared(actionedUponNodeRef)) + { + // Indicate that the disposition action is underway + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); + + executeRecordFolderLevelDisposition(action, actionedUponNodeRef); + + // Indicate that the disposition action is compelte + if (getNodeService().exists(nextDispositionActionNodeRef) && + getSetDispositionActionComplete()) + { + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); + getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); + } + + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ALL_RECORDS_DECLARED, getName(), actionedUponNodeRef.toString())); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString())); + } + + } + + if (getNodeService().exists(actionedUponNodeRef) && getSetDispositionActionComplete()) + { + // Update the disposition schedule + getDispositionService().updateNextDispositionAction(actionedUponNodeRef); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ELIGIBLE, getName(), actionedUponNodeRef.toString())); + } + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + // TODO add the "checkEligibility" parameter + } + + /** + * @param action + * @param record + */ + protected abstract void executeRecordLevelDisposition(Action action, NodeRef record); + + /** + * @param action + * @param recordFolder + */ + protected abstract void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder); + + /** + * @param nodeRef + * @return + */ + protected DispositionSchedule checkDispositionActionExecutionValidity(NodeRef nodeRef, NodeRef nextDispositionActionNodeRef, boolean throwError) + { + // Check the node has associated disposition instructions + DispositionSchedule di = getDispositionService().getDispositionSchedule(nodeRef); + if (di == null) + { + if (throwError) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DISPOITION_INSTRUCTIONS, getName(), nodeRef.toString())); + } + else + { + return null; + } + } + + // Check the node has the disposition schedule aspect applied + if (!getNodeService().hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + if (throwError) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DIS_LIFECYCLE_SET, getName(), nodeRef.toString())); + } + else + { + return null; + } + } + + if (checkNextDispositionAction(nodeRef)) + { + // Check this the next disposition action + NodeRef nextDispositionAction = nextDispositionActionNodeRef; + if (nextDispositionAction == null) + { + if (throwError) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NEXT_DISP_NOT_SET, getName(), nodeRef.toString())); + } + else + { + return null; + } + } + String actionName = (String) getNodeService().getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION); + if (actionName == null || !actionName.equals(getName())) + { + if (throwError) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_NEXT_DISP, getName(), nodeRef.toString())); + } + else + { + return null; + } + } + } + + return di; + } + + /** + * Get the next disposition action node. Null if none present. + * + * @param nodeRef + * the disposable node reference + * @return NodeRef the next disposition action, null if none + */ + private NodeRef getNextDispostionAction(NodeRef nodeRef) + { + NodeRef result = null; + List assocs = getNodeService().getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL); + if (assocs.size() != 0) + { + result = assocs.get(0).getChildRef(); + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementAction.java index 3875cb646b..e2c8fa4544 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementAction.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Record Management Action - * - * @author Roy Wetherall - */ -public interface RecordsManagementAction -{ - /** - * Get the name of the action - * - * @return String action name - */ - String getName(); - - /** - * Get the label of the action - * - * @return String action label - */ - String getLabel(); - - /** - * Get the description of the action - * - * @return String action description - */ - String getDescription(); - - /** - * Indicates whether this is a disposition action or not - * - * @return boolean true if a disposition action, false otherwise - */ - boolean isDispositionAction(); - - /** - * Execution of the action - * - * @param filePlanComponent file plan component the action is executed upon - * @param parameters action parameters - */ - RecordsManagementActionResult execute(NodeRef filePlanComponent, Map parameters); - - /** - * Some admin-related rmActions execute against a target nodeRef which is not provided - * by the calling code, but is instead an implementation detail of the action. - * - * @return the target nodeRef - */ - NodeRef getImplicitTargetNodeRef(); - - /** - * Get the records management action definition. - * - * @return - * @since 2.1 - */ - RecordsManagementActionDefinition getRecordsManagementActionDefinition(); - - /** - * Indicates whether the action is public or not - * - * @return - * @since 2.1 - */ - boolean isPublicAction(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Record Management Action + * + * @author Roy Wetherall + */ +public interface RecordsManagementAction +{ + /** + * Get the name of the action + * + * @return String action name + */ + String getName(); + + /** + * Get the label of the action + * + * @return String action label + */ + String getLabel(); + + /** + * Get the description of the action + * + * @return String action description + */ + String getDescription(); + + /** + * Indicates whether this is a disposition action or not + * + * @return boolean true if a disposition action, false otherwise + */ + boolean isDispositionAction(); + + /** + * Execution of the action + * + * @param filePlanComponent file plan component the action is executed upon + * @param parameters action parameters + */ + RecordsManagementActionResult execute(NodeRef filePlanComponent, Map parameters); + + /** + * Some admin-related rmActions execute against a target nodeRef which is not provided + * by the calling code, but is instead an implementation detail of the action. + * + * @return the target nodeRef + */ + NodeRef getImplicitTargetNodeRef(); + + /** + * Get the records management action definition. + * + * @return + * @since 2.1 + */ + RecordsManagementActionDefinition getRecordsManagementActionDefinition(); + + /** + * Indicates whether the action is public or not + * + * @return + * @since 2.1 + */ + boolean isPublicAction(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionCondition.java index 9f3bbe8fec..7a24761e11 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionCondition.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -/** - * Record Management Action Condition - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordsManagementActionCondition -{ - /** - * Get the name of the action condition - * - * @return String action condition name - */ - String getName(); - - /** - * Get the label of the action condition - * - * @return String action condition label - */ - String getLabel(); - - /** - * Get the description of the action condition - * - * @return String action condition description - */ - String getDescription(); - - /** - * - * @return - */ - RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition(); - - /** - * - * @return - */ - boolean isPublicCondition(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +/** + * Record Management Action Condition + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordsManagementActionCondition +{ + /** + * Get the name of the action condition + * + * @return String action condition name + */ + String getName(); + + /** + * Get the label of the action condition + * + * @return String action condition label + */ + String getLabel(); + + /** + * Get the description of the action condition + * + * @return String action condition description + */ + String getDescription(); + + /** + * + * @return + */ + RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition(); + + /** + * + * @return + */ + boolean isPublicCondition(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinition.java index 9d2668446a..6ec02461a8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinition.java @@ -1,33 +1,33 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import org.alfresco.service.cmr.action.ActionConditionDefinition; - -/** - * Records management condition definition. - * - * Primarily used as a marker interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordsManagementActionConditionDefinition extends ActionConditionDefinition -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import org.alfresco.service.cmr.action.ActionConditionDefinition; + +/** + * Records management condition definition. + * + * Primarily used as a marker interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordsManagementActionConditionDefinition extends ActionConditionDefinition +{ +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinitionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinitionImpl.java index 19c461750c..8df41bee0e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinitionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionDefinitionImpl.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import org.alfresco.repo.action.ActionConditionDefinitionImpl; - -/** - * Records management condition definition implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordsManagementActionConditionDefinitionImpl extends ActionConditionDefinitionImpl - implements RecordsManagementActionConditionDefinition -{ - /** Serial Version UID */ - private static final long serialVersionUID = -7599279732731533610L; - - /** - * Default constructor. - * - * @param name name of the condition - */ - public RecordsManagementActionConditionDefinitionImpl(String name) - { - super(name); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import org.alfresco.repo.action.ActionConditionDefinitionImpl; + +/** + * Records management condition definition implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordsManagementActionConditionDefinitionImpl extends ActionConditionDefinitionImpl + implements RecordsManagementActionConditionDefinition +{ + /** Serial Version UID */ + private static final long serialVersionUID = -7599279732731533610L; + + /** + * Default constructor. + * + * @param name name of the condition + */ + public RecordsManagementActionConditionDefinitionImpl(String name) + { + super(name); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionEvaluatorAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionEvaluatorAbstractBase.java index 17fdb52cfa..018bb12dec 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionEvaluatorAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionConditionEvaluatorAbstractBase.java @@ -1,215 +1,215 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.action.ActionConditionDefinition; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Records management action condition evaluator abstract base implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class RecordsManagementActionConditionEvaluatorAbstractBase extends ActionConditionEvaluatorAbstractBase - implements RecordsManagementActionCondition, - BeanNameAware -{ - /** records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** bean name */ - private String name; - - /** public condition */ - private boolean publicCondition = true; - - private RetryingTransactionHelper retryingTransactionHelper; - - /** - * @return Records management action service - */ - protected RecordsManagementActionService getRecordsManagementActionService() - { - return this.recordsManagementActionService; - } - - /** - * @return File plan service - */ - protected FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * @param recordsManagementActionService records management action service - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param retryingTransactionHelper - */ - public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#init() - */ - @Override - public void init() - { - // override to prevent condition being registered with the core action service - - // run the following code as System - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() - { - getRecordsManagementActionService().register(RecordsManagementActionConditionEvaluatorAbstractBase.this); - - return null; - } - }; - - retryingTransactionHelper.doInTransaction(callback); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - } - - @Override - public void setPublicCondition(boolean publicCondition) - { - this.publicCondition = publicCondition; - } - - /** - * @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String) - */ - @Override - public void setBeanName(String name) - { - this.name = name; - super.setBeanName(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName() - */ - public String getName() - { - return this.name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel() - */ - public String getLabel() - { - return getActionConditionDefintion().getTitle(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription() - */ - public String getDescription() - { - return getActionConditionDefintion().getDescription(); - } - - /** - * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#getActionConditionDefintion() - * - * TODO base class should provide "createActionDefinition" method that can be over-ridden like the ActionExecuter - * base class to prevent duplication of code and a cleaner extension. - */ - @Override - public ActionConditionDefinition getActionConditionDefintion() - { - if (this.actionConditionDefinition == null) - { - this.actionConditionDefinition = new RecordsManagementActionConditionDefinitionImpl(name); - ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setTitleKey(getTitleKey()); - ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setDescriptionKey(getDescriptionKey()); - ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed()); - ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setConditionEvaluator(name); - ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setParameterDefinitions(getParameterDefintions()); - } - return this.actionConditionDefinition; - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List arg0) - { - // No param implementation by default - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#isPublicCondition() - */ - @Override - public boolean isPublicCondition() - { - return publicCondition; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#getRecordsManagementActionConditionDefinition() - */ - @Override - public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition() - { - return (RecordsManagementActionConditionDefinition)getActionConditionDefintion(); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.action.ActionConditionDefinition; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Records management action condition evaluator abstract base implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class RecordsManagementActionConditionEvaluatorAbstractBase extends ActionConditionEvaluatorAbstractBase + implements RecordsManagementActionCondition, + BeanNameAware +{ + /** records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** bean name */ + private String name; + + /** public condition */ + private boolean publicCondition = true; + + private RetryingTransactionHelper retryingTransactionHelper; + + /** + * @return Records management action service + */ + protected RecordsManagementActionService getRecordsManagementActionService() + { + return this.recordsManagementActionService; + } + + /** + * @return File plan service + */ + protected FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * @param recordsManagementActionService records management action service + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param retryingTransactionHelper + */ + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + /** + * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#init() + */ + @Override + public void init() + { + // override to prevent condition being registered with the core action service + + // run the following code as System + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() + { + getRecordsManagementActionService().register(RecordsManagementActionConditionEvaluatorAbstractBase.this); + + return null; + } + }; + + retryingTransactionHelper.doInTransaction(callback); + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + } + + @Override + public void setPublicCondition(boolean publicCondition) + { + this.publicCondition = publicCondition; + } + + /** + * @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String) + */ + @Override + public void setBeanName(String name) + { + this.name = name; + super.setBeanName(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName() + */ + public String getName() + { + return this.name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel() + */ + public String getLabel() + { + return getActionConditionDefintion().getTitle(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription() + */ + public String getDescription() + { + return getActionConditionDefintion().getDescription(); + } + + /** + * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#getActionConditionDefintion() + * + * TODO base class should provide "createActionDefinition" method that can be over-ridden like the ActionExecuter + * base class to prevent duplication of code and a cleaner extension. + */ + @Override + public ActionConditionDefinition getActionConditionDefintion() + { + if (this.actionConditionDefinition == null) + { + this.actionConditionDefinition = new RecordsManagementActionConditionDefinitionImpl(name); + ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setTitleKey(getTitleKey()); + ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setDescriptionKey(getDescriptionKey()); + ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed()); + ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setConditionEvaluator(name); + ((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setParameterDefinitions(getParameterDefintions()); + } + return this.actionConditionDefinition; + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List arg0) + { + // No param implementation by default + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#isPublicCondition() + */ + @Override + public boolean isPublicCondition() + { + return publicCondition; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#getRecordsManagementActionConditionDefinition() + */ + @Override + public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition() + { + return (RecordsManagementActionConditionDefinition)getActionConditionDefintion(); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinition.java index 88d63e3783..e73fba1e1e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinition.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.service.cmr.action.ActionDefinition; - -/** - * Extended action definition interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordsManagementActionDefinition extends ActionDefinition -{ - /** - * @return list of applicable file plan component kinds - */ - Set getApplicableKinds(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.service.cmr.action.ActionDefinition; + +/** + * Extended action definition interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordsManagementActionDefinition extends ActionDefinition +{ + /** + * @return list of applicable file plan component kinds + */ + Set getApplicableKinds(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinitionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinitionImpl.java index ab4173ccf0..327dc28b17 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinitionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionDefinitionImpl.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.repo.action.ActionDefinitionImpl; - -/** - * Extended action definition implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordsManagementActionDefinitionImpl extends ActionDefinitionImpl implements RecordsManagementActionDefinition -{ - /** generated serial version id */ - private static final long serialVersionUID = -5226538434707253206L; - - /** Applicable kinds */ - private Set applicableKinds; - - /** - * Default constructor. - * - * @param name action definition name - */ - public RecordsManagementActionDefinitionImpl(String name) - { - super(name); - } - - /** - * @param applicableKinds applicable kinds - */ - public void setApplicableKinds(Set applicableKinds) - { - this.applicableKinds = applicableKinds; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition#getApplicableKinds() - */ - @Override - public Set getApplicableKinds() - { - return applicableKinds; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.repo.action.ActionDefinitionImpl; + +/** + * Extended action definition implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordsManagementActionDefinitionImpl extends ActionDefinitionImpl implements RecordsManagementActionDefinition +{ + /** generated serial version id */ + private static final long serialVersionUID = -5226538434707253206L; + + /** Applicable kinds */ + private Set applicableKinds; + + /** + * Default constructor. + * + * @param name action definition name + */ + public RecordsManagementActionDefinitionImpl(String name) + { + super(name); + } + + /** + * @param applicableKinds applicable kinds + */ + public void setApplicableKinds(Set applicableKinds) + { + this.applicableKinds = applicableKinds; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition#getApplicableKinds() + */ + @Override + public Set getApplicableKinds() + { + return applicableKinds; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionResult.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionResult.java index 583beefe40..735b6db039 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionResult.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionResult.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2009-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.action; - -/** - * Records management action result. - * - * @author Roy Wetherall - */ -public class RecordsManagementActionResult -{ - /** Result value */ - private Object value; - - /** - * Constructor. - * - * @param value result value - */ - public RecordsManagementActionResult(Object value) - { - this.value = value; - } - - /** - * @return result value - */ - public Object getValue() - { - return this.value; - } -} +/* + * Copyright (C) 2009-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.action; + +/** + * Records management action result. + * + * @author Roy Wetherall + */ +public class RecordsManagementActionResult +{ + /** Result value */ + private Object value; + + /** + * Constructor. + * + * @param value result value + */ + public RecordsManagementActionResult(Object value) + { + this.value = value; + } + + /** + * @return result value + */ + public Object getValue() + { + return this.value; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionService.java index edbab08b96..490049861b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionService.java @@ -1,129 +1,129 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * Records management action service interface - * - * @author Roy Wetherall - */ -public interface RecordsManagementActionService -{ - /** - * Get a list of the available records management actions - * - * @return List records management actions - */ - List getRecordsManagementActions(); - - /** - * - * @return - * @since 2.1 - */ - List getRecordsManagementActionConditions(); - - /** - * Get a list of the available disposition actions. A disposition action is a records - * management action that can be used when defining disposition instructions. - * - * @return List disposition actions - */ - List getDispositionActions(); - - /** - * Gets the named records management action - * - * @param name The name of the RM action to retrieve - * @return The RecordsManagementAction or null if it doesn't exist - */ - RecordsManagementAction getRecordsManagementAction(String name); - - /** - * Gets the named disposition action - * - * @param name The name of the disposition action to retrieve - * @return The RecordsManagementAction or null if it doesn't exist - */ - RecordsManagementAction getDispositionAction(String name); - - /** - * Execute a records management action - * - * @param nodeRef node reference to a rm container, rm folder or record - * @param name action name - */ - RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name); - - /** - * Execute a records management action against several nodes - * - * @param nodeRefs node references to rm containers, rm folders or records - * @param name action name - */ - Map executeRecordsManagementAction(List nodeRefs, String name); - - /** - * Execute a records management action - * - * @param nodeRef node reference to a rm container, rm folder or record - * @param name action name - * @param parameters action parameters - */ - RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map parameters); - - /** - * Execute a records management action against several nodes - * - * @param nodeRefs node references to rm containers, rm folders or records - * @param name action name - * @param parameters action parameters - */ - Map executeRecordsManagementAction(List nodeRefs, String name, Map parameters); - - /** - * Execute a records management action. The nodeRef against which the action is to be - * executed must be provided by the RecordsManagementAction implementation. - * - * @param name action name - * @param parameters action parameters - */ - RecordsManagementActionResult executeRecordsManagementAction(String name, Map parameters); - - /** - * Register records management action - * - * @param rmAction records management action - */ - void register(RecordsManagementAction rmAction); - - /** - * - * @param rmCondition - * @since 2.1 - */ - void register(RecordsManagementActionCondition rmCondition); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Records management action service interface + * + * @author Roy Wetherall + */ +public interface RecordsManagementActionService +{ + /** + * Get a list of the available records management actions + * + * @return List records management actions + */ + List getRecordsManagementActions(); + + /** + * + * @return + * @since 2.1 + */ + List getRecordsManagementActionConditions(); + + /** + * Get a list of the available disposition actions. A disposition action is a records + * management action that can be used when defining disposition instructions. + * + * @return List disposition actions + */ + List getDispositionActions(); + + /** + * Gets the named records management action + * + * @param name The name of the RM action to retrieve + * @return The RecordsManagementAction or null if it doesn't exist + */ + RecordsManagementAction getRecordsManagementAction(String name); + + /** + * Gets the named disposition action + * + * @param name The name of the disposition action to retrieve + * @return The RecordsManagementAction or null if it doesn't exist + */ + RecordsManagementAction getDispositionAction(String name); + + /** + * Execute a records management action + * + * @param nodeRef node reference to a rm container, rm folder or record + * @param name action name + */ + RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name); + + /** + * Execute a records management action against several nodes + * + * @param nodeRefs node references to rm containers, rm folders or records + * @param name action name + */ + Map executeRecordsManagementAction(List nodeRefs, String name); + + /** + * Execute a records management action + * + * @param nodeRef node reference to a rm container, rm folder or record + * @param name action name + * @param parameters action parameters + */ + RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map parameters); + + /** + * Execute a records management action against several nodes + * + * @param nodeRefs node references to rm containers, rm folders or records + * @param name action name + * @param parameters action parameters + */ + Map executeRecordsManagementAction(List nodeRefs, String name, Map parameters); + + /** + * Execute a records management action. The nodeRef against which the action is to be + * executed must be provided by the RecordsManagementAction implementation. + * + * @param name action name + * @param parameters action parameters + */ + RecordsManagementActionResult executeRecordsManagementAction(String name, Map parameters); + + /** + * Register records management action + * + * @param rmAction records management action + */ + void register(RecordsManagementAction rmAction); + + /** + * + * @param rmCondition + * @since 2.1 + */ + void register(RecordsManagementActionCondition rmCondition); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionServiceImpl.java index 219aeb6b9d..b2b63d3d5b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RecordsManagementActionServiceImpl.java @@ -1,325 +1,325 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution; -import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil; -import org.alfresco.repo.policy.ClassPolicyDelegate; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Records Management Action Service Implementation - * - * @author Roy Wetherall - */ -public class RecordsManagementActionServiceImpl implements RecordsManagementActionService -{ - /** I18N */ - private static final String MSG_NOT_DEFINED = "rm.action.not-defined"; - private static final String MSG_NO_IMPLICIT_NODEREF = "rm.action.no-implicit-noderef"; - - /** Logger */ - private static Log logger = LogFactory.getLog(RecordsManagementActionServiceImpl.class); - - /** Registered records management actions */ - private Map rmActions = new HashMap(13); - private Map rmConditions = new HashMap(13); - - private Map dispositionActions = new HashMap(5); - - /** Policy component */ - private PolicyComponent policyComponent; - - /** Node service */ - private NodeService nodeService; - - /** Policy delegates */ - private ClassPolicyDelegate beforeRMActionExecutionDelegate; - private ClassPolicyDelegate onRMActionExecutionDelegate; - - /** - * @return Policy component - */ - protected PolicyComponent getPolicyComponent() - { - return this.policyComponent; - } - - /** - * @return Node Service - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Set the policy component - * - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * Set the node service - * - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Initialise RM action service - */ - public void init() - { - // Register the various policies - beforeRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(BeforeRMActionExecution.class); - onRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(OnRMActionExecution.class); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#register(org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction) - */ - public void register(RecordsManagementAction rmAction) - { - if (!rmActions.containsKey(rmAction.getName())) - { - rmActions.put(rmAction.getName(), rmAction); - - if (rmAction.isDispositionAction()) - { - dispositionActions.put(rmAction.getName(), rmAction); - } - } - } - - public void register(RecordsManagementActionCondition rmCondition) - { - if (!rmConditions.containsKey(rmCondition.getName())) - { - rmConditions.put(rmCondition.getName(), rmCondition); - } - } - - /** - * Invoke beforeRMActionExecution policy - * - * @param nodeRef node reference - * @param name action name - * @param parameters action parameters - */ - protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map parameters) - { - // get qnames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef); - // execute policy for node type and aspects - BeforeRMActionExecution policy = beforeRMActionExecutionDelegate.get(qnames); - policy.beforeRMActionExecution(nodeRef, name, parameters); - } - - /** - * Invoke onRMActionExecution policy - * - * @param nodeRef node reference - * @param name action name - * @param parameters action parameters - */ - protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map parameters) - { - // get qnames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef); - // execute policy for node type and aspects - OnRMActionExecution policy = onRMActionExecutionDelegate.get(qnames); - policy.onRMActionExecution(nodeRef, name, parameters); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getRecordsManagementActions() - */ - public List getRecordsManagementActions() - { - List result = new ArrayList(this.rmActions.size()); - result.addAll(this.rmActions.values()); - return Collections.unmodifiableList(result); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActionConditions() - */ - @Override - public List getRecordsManagementActionConditions() - { - List result = new ArrayList(rmConditions.size()); - result.addAll(rmConditions.values()); - return Collections.unmodifiableList(result); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionActions(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unused") - public List getDispositionActions(NodeRef nodeRef) - { - List result = new ArrayList(this.rmActions.size()); - - for (RecordsManagementAction action : this.rmActions.values()) - { - // TODO check the permissions on the action ... - } - - return Collections.unmodifiableList(result); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getDispositionActionDefinitions() - */ - public List getDispositionActions() - { - List result = new ArrayList(dispositionActions.size()); - result.addAll(dispositionActions.values()); - return Collections.unmodifiableList(result); - } - - /* - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionAction(java.lang.String) - */ - public RecordsManagementAction getDispositionAction(String name) - { - return dispositionActions.get(name); - } - - /* - * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementAction(java.lang.String) - */ - public RecordsManagementAction getRecordsManagementAction(String name) - { - return this.rmActions.get(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name) - { - return executeRecordsManagementAction(nodeRef, name, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String) - */ - public Map executeRecordsManagementAction(List nodeRefs, String name) - { - return executeRecordsManagementAction(nodeRefs, name, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) - */ - public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map parameters) - { - if (logger.isDebugEnabled()) - { - logger.debug("Executing record management action on " + nodeRef); - logger.debug(" actionName = " + name); - logger.debug(" parameters = " + parameters); - } - - RecordsManagementAction rmAction = this.rmActions.get(name); - if (rmAction == null) - { - String msg = I18NUtil.getMessage(MSG_NOT_DEFINED, name); - if (logger.isWarnEnabled()) - { - logger.warn(msg); - } - throw new AlfrescoRuntimeException(msg); - } - - // Execute action - invokeBeforeRMActionExecution(nodeRef, name, parameters); - RecordsManagementActionResult result = rmAction.execute(nodeRef, parameters); - if (getNodeService().exists(nodeRef)) - { - invokeOnRMActionExecution(nodeRef, name, parameters); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.lang.String, java.util.Map) - */ - public RecordsManagementActionResult executeRecordsManagementAction(String name, Map parameters) - { - RecordsManagementAction rmAction = rmActions.get(name); - - NodeRef implicitTargetNode = rmAction.getImplicitTargetNodeRef(); - if (implicitTargetNode == null) - { - String msg = I18NUtil.getMessage(MSG_NO_IMPLICIT_NODEREF, name); - if (logger.isWarnEnabled()) - { - logger.warn(msg); - } - throw new AlfrescoRuntimeException(msg); - } - else - { - return this.executeRecordsManagementAction(implicitTargetNode, name, parameters); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String, java.util.Map) - */ - public Map executeRecordsManagementAction(List nodeRefs, String name, Map parameters) - { - // Execute the action on each node in the list - Map results = new HashMap(nodeRefs.size()); - for (NodeRef nodeRef : nodeRefs) - { - RecordsManagementActionResult result = executeRecordsManagementAction(nodeRef, name, parameters); - results.put(nodeRef, result); - } - - return results; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution; +import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil; +import org.alfresco.repo.policy.ClassPolicyDelegate; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Records Management Action Service Implementation + * + * @author Roy Wetherall + */ +public class RecordsManagementActionServiceImpl implements RecordsManagementActionService +{ + /** I18N */ + private static final String MSG_NOT_DEFINED = "rm.action.not-defined"; + private static final String MSG_NO_IMPLICIT_NODEREF = "rm.action.no-implicit-noderef"; + + /** Logger */ + private static Log logger = LogFactory.getLog(RecordsManagementActionServiceImpl.class); + + /** Registered records management actions */ + private Map rmActions = new HashMap(13); + private Map rmConditions = new HashMap(13); + + private Map dispositionActions = new HashMap(5); + + /** Policy component */ + private PolicyComponent policyComponent; + + /** Node service */ + private NodeService nodeService; + + /** Policy delegates */ + private ClassPolicyDelegate beforeRMActionExecutionDelegate; + private ClassPolicyDelegate onRMActionExecutionDelegate; + + /** + * @return Policy component + */ + protected PolicyComponent getPolicyComponent() + { + return this.policyComponent; + } + + /** + * @return Node Service + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Set the policy component + * + * @param policyComponent policy component + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * Set the node service + * + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Initialise RM action service + */ + public void init() + { + // Register the various policies + beforeRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(BeforeRMActionExecution.class); + onRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(OnRMActionExecution.class); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#register(org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction) + */ + public void register(RecordsManagementAction rmAction) + { + if (!rmActions.containsKey(rmAction.getName())) + { + rmActions.put(rmAction.getName(), rmAction); + + if (rmAction.isDispositionAction()) + { + dispositionActions.put(rmAction.getName(), rmAction); + } + } + } + + public void register(RecordsManagementActionCondition rmCondition) + { + if (!rmConditions.containsKey(rmCondition.getName())) + { + rmConditions.put(rmCondition.getName(), rmCondition); + } + } + + /** + * Invoke beforeRMActionExecution policy + * + * @param nodeRef node reference + * @param name action name + * @param parameters action parameters + */ + protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map parameters) + { + // get qnames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef); + // execute policy for node type and aspects + BeforeRMActionExecution policy = beforeRMActionExecutionDelegate.get(qnames); + policy.beforeRMActionExecution(nodeRef, name, parameters); + } + + /** + * Invoke onRMActionExecution policy + * + * @param nodeRef node reference + * @param name action name + * @param parameters action parameters + */ + protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map parameters) + { + // get qnames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef); + // execute policy for node type and aspects + OnRMActionExecution policy = onRMActionExecutionDelegate.get(qnames); + policy.onRMActionExecution(nodeRef, name, parameters); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getRecordsManagementActions() + */ + public List getRecordsManagementActions() + { + List result = new ArrayList(this.rmActions.size()); + result.addAll(this.rmActions.values()); + return Collections.unmodifiableList(result); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActionConditions() + */ + @Override + public List getRecordsManagementActionConditions() + { + List result = new ArrayList(rmConditions.size()); + result.addAll(rmConditions.values()); + return Collections.unmodifiableList(result); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionActions(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unused") + public List getDispositionActions(NodeRef nodeRef) + { + List result = new ArrayList(this.rmActions.size()); + + for (RecordsManagementAction action : this.rmActions.values()) + { + // TODO check the permissions on the action ... + } + + return Collections.unmodifiableList(result); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getDispositionActionDefinitions() + */ + public List getDispositionActions() + { + List result = new ArrayList(dispositionActions.size()); + result.addAll(dispositionActions.values()); + return Collections.unmodifiableList(result); + } + + /* + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionAction(java.lang.String) + */ + public RecordsManagementAction getDispositionAction(String name) + { + return dispositionActions.get(name); + } + + /* + * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementAction(java.lang.String) + */ + public RecordsManagementAction getRecordsManagementAction(String name) + { + return this.rmActions.get(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name) + { + return executeRecordsManagementAction(nodeRef, name, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String) + */ + public Map executeRecordsManagementAction(List nodeRefs, String name) + { + return executeRecordsManagementAction(nodeRefs, name, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) + */ + public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map parameters) + { + if (logger.isDebugEnabled()) + { + logger.debug("Executing record management action on " + nodeRef); + logger.debug(" actionName = " + name); + logger.debug(" parameters = " + parameters); + } + + RecordsManagementAction rmAction = this.rmActions.get(name); + if (rmAction == null) + { + String msg = I18NUtil.getMessage(MSG_NOT_DEFINED, name); + if (logger.isWarnEnabled()) + { + logger.warn(msg); + } + throw new AlfrescoRuntimeException(msg); + } + + // Execute action + invokeBeforeRMActionExecution(nodeRef, name, parameters); + RecordsManagementActionResult result = rmAction.execute(nodeRef, parameters); + if (getNodeService().exists(nodeRef)) + { + invokeOnRMActionExecution(nodeRef, name, parameters); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.lang.String, java.util.Map) + */ + public RecordsManagementActionResult executeRecordsManagementAction(String name, Map parameters) + { + RecordsManagementAction rmAction = rmActions.get(name); + + NodeRef implicitTargetNode = rmAction.getImplicitTargetNodeRef(); + if (implicitTargetNode == null) + { + String msg = I18NUtil.getMessage(MSG_NO_IMPLICIT_NODEREF, name); + if (logger.isWarnEnabled()) + { + logger.warn(msg); + } + throw new AlfrescoRuntimeException(msg); + } + else + { + return this.executeRecordsManagementAction(implicitTargetNode, name, parameters); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String, java.util.Map) + */ + public Map executeRecordsManagementAction(List nodeRefs, String name, Map parameters) + { + // Execute the action on each node in the list + Map results = new HashMap(nodeRefs.size()); + for (NodeRef nodeRef : nodeRefs) + { + RecordsManagementActionResult result = executeRecordsManagementAction(nodeRef, name, parameters); + results.put(nodeRef, result); + } + + return results; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/ScheduledDispositionJob.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/ScheduledDispositionJob.java index be14759848..585d095853 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/ScheduledDispositionJob.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/ScheduledDispositionJob.java @@ -1,129 +1,129 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import java.util.Calendar; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * Scheduled disposition job. - * - * Automatically cuts off eligible nodes. - * - * @author Roy Wetherall - */ -public class ScheduledDispositionJob implements Job -{ - /** Logger */ - private static Log logger = LogFactory.getLog(ScheduledDispositionJob.class); - - /** - * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) - */ - public void execute(JobExecutionContext context) throws JobExecutionException - { - RecordsManagementActionService rmActionService - = (RecordsManagementActionService)context.getJobDetail().getJobDataMap().get("recordsManagementActionService"); - NodeService nodeService = (NodeService)context.getJobDetail().getJobDataMap().get("nodeService"); - - - // Calculate the date range used in the query - Calendar cal = Calendar.getInstance(); - String year = String.valueOf(cal.get(Calendar.YEAR)); - String month = String.valueOf(cal.get(Calendar.MONTH) + 1); - String dayOfMonth = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); - - //TODO These pad() calls are in RMActionExecuterAbstractBase. I've copied them - // here as I have no access to that class. - - final String currentDate = padString(year, 2) + "-" + padString(month, 2) + - "-" + padString(dayOfMonth, 2) + "T00:00:00.00Z"; - - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Executing ") - .append(this.getClass().getSimpleName()) - .append(" with currentDate ") - .append(currentDate); - logger.debug(msg.toString()); - } - - //TODO Copied the 1970 start date from the old RM JavaScript impl. - String dateRange = "[\"1970-01-01T00:00:00.00Z\" TO \"" + currentDate + "\"]"; - - // Execute the query and process the results - String query = "+ASPECT:\"rma:record\" +ASPECT:\"rma:dispositionSchedule\" +@rma\\:dispositionAsOf:" + dateRange; - - SearchService search = (SearchService)context.getJobDetail().getJobDataMap().get("searchService"); - ResultSet results = search.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, query); - - List resultNodes = results.getNodeRefs(); - results.close(); - - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Found ") - .append(resultNodes.size()) - .append(" records eligible for disposition."); - logger.debug(msg.toString()); - } - - for (NodeRef node : resultNodes ) - { - String dispActionName = (String)nodeService.getProperty(node, RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME); - - // Only automatically execute "cutoff" actions. - // destroy and transfer and anything else should be manual for now - if (dispActionName != null && dispActionName.equalsIgnoreCase("cutoff")) - { - rmActionService.executeRecordsManagementAction(node, dispActionName); - - if (logger.isDebugEnabled()) - { - logger.debug("Performing " + dispActionName + " dispoition action on disposable item " + node.toString()); - } - } - } - } - - //TODO This has been pasted out of RMActionExecuterAbstractBase. To be relocated. - private String padString(String s, int len) - { - String result = s; - for (int i=0; i<(len - s.length()); i++) - { - result = "0" + result; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import java.util.Calendar; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * Scheduled disposition job. + * + * Automatically cuts off eligible nodes. + * + * @author Roy Wetherall + */ +public class ScheduledDispositionJob implements Job +{ + /** Logger */ + private static Log logger = LogFactory.getLog(ScheduledDispositionJob.class); + + /** + * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) + */ + public void execute(JobExecutionContext context) throws JobExecutionException + { + RecordsManagementActionService rmActionService + = (RecordsManagementActionService)context.getJobDetail().getJobDataMap().get("recordsManagementActionService"); + NodeService nodeService = (NodeService)context.getJobDetail().getJobDataMap().get("nodeService"); + + + // Calculate the date range used in the query + Calendar cal = Calendar.getInstance(); + String year = String.valueOf(cal.get(Calendar.YEAR)); + String month = String.valueOf(cal.get(Calendar.MONTH) + 1); + String dayOfMonth = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); + + //TODO These pad() calls are in RMActionExecuterAbstractBase. I've copied them + // here as I have no access to that class. + + final String currentDate = padString(year, 2) + "-" + padString(month, 2) + + "-" + padString(dayOfMonth, 2) + "T00:00:00.00Z"; + + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Executing ") + .append(this.getClass().getSimpleName()) + .append(" with currentDate ") + .append(currentDate); + logger.debug(msg.toString()); + } + + //TODO Copied the 1970 start date from the old RM JavaScript impl. + String dateRange = "[\"1970-01-01T00:00:00.00Z\" TO \"" + currentDate + "\"]"; + + // Execute the query and process the results + String query = "+ASPECT:\"rma:record\" +ASPECT:\"rma:dispositionSchedule\" +@rma\\:dispositionAsOf:" + dateRange; + + SearchService search = (SearchService)context.getJobDetail().getJobDataMap().get("searchService"); + ResultSet results = search.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, query); + + List resultNodes = results.getNodeRefs(); + results.close(); + + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Found ") + .append(resultNodes.size()) + .append(" records eligible for disposition."); + logger.debug(msg.toString()); + } + + for (NodeRef node : resultNodes ) + { + String dispActionName = (String)nodeService.getProperty(node, RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME); + + // Only automatically execute "cutoff" actions. + // destroy and transfer and anything else should be manual for now + if (dispActionName != null && dispActionName.equalsIgnoreCase("cutoff")) + { + rmActionService.executeRecordsManagementAction(node, dispActionName); + + if (logger.isDebugEnabled()) + { + logger.debug("Performing " + dispActionName + " dispoition action on disposable item " + node.toString()); + } + } + } + } + + //TODO This has been pasted out of RMActionExecuterAbstractBase. To be relocated. + private String padString(String s, int len) + { + String result = s; + for (int i=0; i<(len - s.length()); i++) + { + result = "0" + result; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/CustomParameterConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/CustomParameterConstraint.java index 67058be72c..79231e6be6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/CustomParameterConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/CustomParameterConstraint.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2009-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.action.constraint; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.action.constraint.BaseParameterConstraint; - -/** - * A parameter constraint that reads in a list of allowable values from Spring configuration - * - * @author Craig Tan - * @since 2.1 - */ -public class CustomParameterConstraint extends BaseParameterConstraint -{ - - private List parameterValues; - - /** - * @param parameterValues - */ - public void setParameterValues(List parameterValues) - { - this.parameterValues = parameterValues; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - Map allowableValues = new HashMap(parameterValues.size()); - - for (Object parameterValue : parameterValues) - { - // Look up the I18N value - String displayLabel = getI18NLabel(parameterValue.toString()); - - // Add to the map of allowed values - allowableValues.put(parameterValue.toString(), displayLabel); - } - - return allowableValues; - } -} +/* + * Copyright (C) 2009-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.action.constraint; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.repo.action.constraint.BaseParameterConstraint; + +/** + * A parameter constraint that reads in a list of allowable values from Spring configuration + * + * @author Craig Tan + * @since 2.1 + */ +public class CustomParameterConstraint extends BaseParameterConstraint +{ + + private List parameterValues; + + /** + * @param parameterValues + */ + public void setParameterValues(List parameterValues) + { + this.parameterValues = parameterValues; + } + + /** + * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() + */ + protected Map getAllowableValuesImpl() + { + Map allowableValues = new HashMap(parameterValues.size()); + + for (Object parameterValue : parameterValues) + { + // Look up the I18N value + String displayLabel = getI18NLabel(parameterValue.toString()); + + // Add to the map of allowed values + allowableValues.put(parameterValue.toString(), displayLabel); + } + + return allowableValues; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/DispositionActionParameterConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/DispositionActionParameterConstraint.java index 7e51ca40ea..1753484bf0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/DispositionActionParameterConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/DispositionActionParameterConstraint.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2009-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.action.constraint; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.repo.action.constraint.BaseParameterConstraint; - -/** - * Record type parameter constraint - * - * @author Craig Tan - * @since 2.1 - */ -public class DispositionActionParameterConstraint extends BaseParameterConstraint -{ - /** Name constant */ - public static final String NAME = "rm-ac-record-types"; - - private RecordsManagementActionService rmActionService; - - public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) - { - this.rmActionService = rmActionService; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - List rmActions = rmActionService.getDispositionActions(); - - Map result = new HashMap(rmActions.size()); - for (RecordsManagementAction rmAction : rmActions) - { - result.put(rmAction.getName(), rmAction.getLabel()); - } - return result; - } - - -} +/* + * Copyright (C) 2009-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.action.constraint; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.repo.action.constraint.BaseParameterConstraint; + +/** + * Record type parameter constraint + * + * @author Craig Tan + * @since 2.1 + */ +public class DispositionActionParameterConstraint extends BaseParameterConstraint +{ + /** Name constant */ + public static final String NAME = "rm-ac-record-types"; + + private RecordsManagementActionService rmActionService; + + public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) + { + this.rmActionService = rmActionService; + } + + /** + * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() + */ + protected Map getAllowableValuesImpl() + { + List rmActions = rmActionService.getDispositionActions(); + + Map result = new HashMap(rmActions.size()); + for (RecordsManagementAction rmAction : rmActions) + { + result.put(rmAction.getName(), rmAction.getLabel()); + } + return result; + } + + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/ManualEventParameterConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/ManualEventParameterConstraint.java index 6e2cd540ee..34e1885a1e 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/ManualEventParameterConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/ManualEventParameterConstraint.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2009-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.action.constraint; - -import java.util.HashMap; -import java.util.List; -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.module.org_alfresco_module_rm.event.RecordsManagementEventType; -import org.alfresco.repo.action.constraint.BaseParameterConstraint; - -/** - * Manual event parameter constraint - * - * @author Craig Tan - */ -public class ManualEventParameterConstraint extends BaseParameterConstraint -{ - /** Name constant */ - public static final String NAME = "rm-ac-manual-events"; - - private RecordsManagementEventService recordsManagementEventService; - - public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) - { - this.recordsManagementEventService = recordsManagementEventService; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - List events = recordsManagementEventService.getEvents(); - Map result = new HashMap(events.size()); - for (RecordsManagementEvent event : events) - { - RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType()); - if (eventType != null && !eventType.isAutomaticEvent()) - { - result.put(event.getName(), event.getDisplayLabel()); - } - } - return result; - } - - -} +/* + * Copyright (C) 2009-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.action.constraint; + +import java.util.HashMap; +import java.util.List; +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.module.org_alfresco_module_rm.event.RecordsManagementEventType; +import org.alfresco.repo.action.constraint.BaseParameterConstraint; + +/** + * Manual event parameter constraint + * + * @author Craig Tan + */ +public class ManualEventParameterConstraint extends BaseParameterConstraint +{ + /** Name constant */ + public static final String NAME = "rm-ac-manual-events"; + + private RecordsManagementEventService recordsManagementEventService; + + public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) + { + this.recordsManagementEventService = recordsManagementEventService; + } + + /** + * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() + */ + protected Map getAllowableValuesImpl() + { + List events = recordsManagementEventService.getEvents(); + Map result = new HashMap(events.size()); + for (RecordsManagementEvent event : events) + { + RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType()); + if (eventType != null && !eventType.isAutomaticEvent()) + { + result.put(event.getName(), event.getDisplayLabel()); + } + } + return result; + } + + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/RecordTypeParameterConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/RecordTypeParameterConstraint.java index 5fa20597a4..565e0a4301 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/RecordTypeParameterConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/RecordTypeParameterConstraint.java @@ -1,118 +1,118 @@ -/* - * Copyright (C) 2009-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.action.constraint; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.action.constraint.BaseParameterConstraint; -import org.alfresco.repo.i18n.StaticMessageLookup; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Record type parameter constraint - * - * @author Craig Tan - * @since 2.1 - */ -public class RecordTypeParameterConstraint extends BaseParameterConstraint -{ - /** Name constant */ - public static final String NAME = "rm-ac-record-types"; - - /** record service */ - private RecordService recordService; - - /** dictionary service */ - private DictionaryService dictionaryService; - - /** file plan service */ - private FilePlanService filePlanService; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - return AuthenticationUtil.runAsSystem(new RunAsWork>() - { - @SuppressWarnings("unchecked") - public Map doWork() - { - Map result = Collections.EMPTY_MAP; - - // get the file plan - // TODO we will likely have to re-implement as a custom control so that context of the file - // plan can be correctly determined when setting the rule up - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - if (filePlan != null) - { - Set recordTypes = recordService.getRecordMetadataAspects(filePlan); - - result = new HashMap(recordTypes.size()); - for (QName recordType : recordTypes) - { - AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType); - if (aspectDefinition != null) - { - result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup())); - } - } - } - - return result; - } - }); - } -} +/* + * Copyright (C) 2009-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.action.constraint; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.action.constraint.BaseParameterConstraint; +import org.alfresco.repo.i18n.StaticMessageLookup; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Record type parameter constraint + * + * @author Craig Tan + * @since 2.1 + */ +public class RecordTypeParameterConstraint extends BaseParameterConstraint +{ + /** Name constant */ + public static final String NAME = "rm-ac-record-types"; + + /** record service */ + private RecordService recordService; + + /** dictionary service */ + private DictionaryService dictionaryService; + + /** file plan service */ + private FilePlanService filePlanService; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() + */ + protected Map getAllowableValuesImpl() + { + return AuthenticationUtil.runAsSystem(new RunAsWork>() + { + @SuppressWarnings("unchecked") + public Map doWork() + { + Map result = Collections.EMPTY_MAP; + + // get the file plan + // TODO we will likely have to re-implement as a custom control so that context of the file + // plan can be correctly determined when setting the rule up + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + if (filePlan != null) + { + Set recordTypes = recordService.getRecordMetadataAspects(filePlan); + + result = new HashMap(recordTypes.size()); + for (QName recordType : recordTypes) + { + AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType); + if (aspectDefinition != null) + { + result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup())); + } + } + } + + return result; + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/VersionParameterConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/VersionParameterConstraint.java index c1677f84d8..61554c5ae9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/VersionParameterConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/constraint/VersionParameterConstraint.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.constraint; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.repo.action.constraint.BaseParameterConstraint; - -/** - * Recordable version config constraint - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class VersionParameterConstraint extends BaseParameterConstraint -{ - /** - * @see org.alfresco.repo.action.constraint.BaseParameterConstraint#getAllowableValuesImpl() - */ - @Override - protected Map getAllowableValuesImpl() - { - RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values(); - Map allowableValues = new HashMap(recordableVersionPolicies.length); - for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies) - { - String policy = recordableVersionPolicy.toString(); - allowableValues.put(policy, getI18NLabel(policy)); - } - return allowableValues; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.constraint; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.repo.action.constraint.BaseParameterConstraint; + +/** + * Recordable version config constraint + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class VersionParameterConstraint extends BaseParameterConstraint +{ + /** + * @see org.alfresco.repo.action.constraint.BaseParameterConstraint#getAllowableValuesImpl() + */ + @Override + protected Map getAllowableValuesImpl() + { + RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values(); + Map allowableValues = new HashMap(recordableVersionPolicies.length); + for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies) + { + String policy = recordableVersionPolicy.toString(); + allowableValues.put(policy, getI18NLabel(policy)); + } + return allowableValues; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java index e7d091eea5..78881fd4d3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java @@ -1,233 +1,233 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Creates a new record from an existing content object. - * - * Note: This is a 'normal' dm action, rather than a records management action. - * - * @author Roy Wetherall - */ -public class CreateRecordAction extends AuditableActionExecuterAbstractBase - implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(CreateRecordAction.class); - - /** Action name */ - public static final String NAME = "create-record"; - - /** Parameter names */ - public static final String PARAM_FILE_PLAN = "file-plan"; - public static final String PARAM_HIDE_RECORD = "hide-record"; - - /** Sync Model URI */ - static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; - /** Synced aspect */ - static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); - - /** Record service */ - private RecordService recordService; - - /** Node service */ - private NodeService nodeService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) - { - - if (!nodeService.exists(actionedUponNodeRef)) - { - // do not create record if the actioned upon node does not exist! - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " does not exist."); - } - } - else if (!dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT)) - { - // TODO eventually we should support other types .. either as record folders or as composite records - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is not a supported type."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) - { - // Do not create record if the actioned upon node is already a record! - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is already a record."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY)) - { - // We can not create records from working copies - if (logger.isDebugEnabled()) - { - logger.debug("Can node create record, because " + actionedUponNodeRef.toString() + " is a working copy."); - } - - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS)) - { - // can not create a record from a previously rejected one - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " has previously been rejected."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED)) - { - // can't declare the record if the node is sync'ed - if (logger.isDebugEnabled()) - { - logger.debug("Can't declare as record, because " + actionedUponNodeRef.toString() + " is synched content."); - } - } - else - { - NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); - if (filePlan == null) - { - // TODO .. eventually make the file plan parameter required - - filePlan = AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - }, AuthenticationUtil.getAdminUserName()); - - // if the file plan is still null, raise an exception - if (filePlan == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because the default file plan can not be determined. Make sure at least one file plan has been created."); - } - throw new AlfrescoRuntimeException("Can not create record, because the default file plan can not be determined."); - } - } - else - { - // verify that the provided file plan is actually a file plan - if (!filePlanService.isFilePlan(filePlan)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Can not create record, because the provided file plan node reference is not a file plan."); - } - throw new AlfrescoRuntimeException("Can not create record, because the provided file plan node reference is not a file plan."); - } - } - - // indicate whether the record should be hidden or not (default not) - boolean hideRecord = false; - Boolean hideRecordValue = ((Boolean)action.getParameterValue(PARAM_HIDE_RECORD)); - if (hideRecordValue != null) - { - hideRecord = hideRecordValue.booleanValue(); - } - - synchronized (this) - { - // create record from existing document - recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord); - } - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List params) - { - // NOTE: commented out for now so that it doesn't appear in the UI ... enable later when multi-file plan support is added - //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); - params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD))); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Creates a new record from an existing content object. + * + * Note: This is a 'normal' dm action, rather than a records management action. + * + * @author Roy Wetherall + */ +public class CreateRecordAction extends AuditableActionExecuterAbstractBase + implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(CreateRecordAction.class); + + /** Action name */ + public static final String NAME = "create-record"; + + /** Parameter names */ + public static final String PARAM_FILE_PLAN = "file-plan"; + public static final String PARAM_HIDE_RECORD = "hide-record"; + + /** Sync Model URI */ + static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; + /** Synced aspect */ + static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); + + /** Record service */ + private RecordService recordService; + + /** Node service */ + private NodeService nodeService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + { + + if (!nodeService.exists(actionedUponNodeRef)) + { + // do not create record if the actioned upon node does not exist! + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " does not exist."); + } + } + else if (!dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT)) + { + // TODO eventually we should support other types .. either as record folders or as composite records + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is not a supported type."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) + { + // Do not create record if the actioned upon node is already a record! + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is already a record."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY)) + { + // We can not create records from working copies + if (logger.isDebugEnabled()) + { + logger.debug("Can node create record, because " + actionedUponNodeRef.toString() + " is a working copy."); + } + + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS)) + { + // can not create a record from a previously rejected one + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " has previously been rejected."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED)) + { + // can't declare the record if the node is sync'ed + if (logger.isDebugEnabled()) + { + logger.debug("Can't declare as record, because " + actionedUponNodeRef.toString() + " is synched content."); + } + } + else + { + NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); + if (filePlan == null) + { + // TODO .. eventually make the file plan parameter required + + filePlan = AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + }, AuthenticationUtil.getAdminUserName()); + + // if the file plan is still null, raise an exception + if (filePlan == null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because the default file plan can not be determined. Make sure at least one file plan has been created."); + } + throw new AlfrescoRuntimeException("Can not create record, because the default file plan can not be determined."); + } + } + else + { + // verify that the provided file plan is actually a file plan + if (!filePlanService.isFilePlan(filePlan)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Can not create record, because the provided file plan node reference is not a file plan."); + } + throw new AlfrescoRuntimeException("Can not create record, because the provided file plan node reference is not a file plan."); + } + } + + // indicate whether the record should be hidden or not (default not) + boolean hideRecord = false; + Boolean hideRecordValue = ((Boolean)action.getParameterValue(PARAM_HIDE_RECORD)); + if (hideRecordValue != null) + { + hideRecord = hideRecordValue.booleanValue(); + } + + synchronized (this) + { + // create record from existing document + recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord); + } + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List params) + { + // NOTE: commented out for now so that it doesn't appear in the UI ... enable later when multi-file plan support is added + //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); + params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD))); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordAction.java index 07a8e951ed..6dd985edd8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordAction.java @@ -1,235 +1,235 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Creates a new record from the 'current' document version. - * - * Note: This is a 'normal' dm action, rather than a records management action. - * - * @author Roy Wetherall - */ -public class DeclareAsVersionRecordAction extends AuditableActionExecuterAbstractBase - implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(DeclareAsVersionRecordAction.class); - - /** Action name */ - public static final String NAME = "declare-version-record"; - - /** Parameter names */ - public static final String PARAM_FILE_PLAN = "file-plan"; - - /** Sync Model URI */ - private static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; - - /** Synced aspect */ - private static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); - - /** Node service */ - private NodeService nodeService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** recordable version service */ - private RecordableVersionService recordableVersionService; - - /** authentication util */ - private AuthenticationUtil authenticationUtil; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param recordableVersionService recordable version service - */ - public void setRecordableVersionService(RecordableVersionService recordableVersionService) - { - this.recordableVersionService = recordableVersionService; - } - - /** - * @param authenticationUtil authentication util - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) - { - if (!nodeService.exists(actionedUponNodeRef)) - { - // do not create record if the actioned upon node does not exist! - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " does not exist."); - } - } - else if (!dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT)) - { - // TODO eventually we should support other types .. either as record folders or as composite records - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " is not a supported type."); - } - } - else if (!nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " does not have the versionable aspect applied."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) - { - // Do not declare version record if the actioned upon node is already a record! - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " is already a record."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY)) - { - // We can not create records from working copies - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " is a working copy."); - } - - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS)) - { - // can not create a record from a previously rejected one - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " has previously been rejected."); - } - } - else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED)) - { - // can't declare the record if the node is sync'ed - if (logger.isDebugEnabled()) - { - logger.debug("Can't declare version record, because " + actionedUponNodeRef.toString() + " is synched content."); - } - } - else - { - NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); - if (filePlan == null) - { - // TODO .. eventually make the file plan parameter required - - filePlan = authenticationUtil.runAs(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() - { - @Override - public NodeRef doWork() - { - return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - }, authenticationUtil.getAdminUserName()); - - // if the file plan is still null, raise an exception - if (filePlan == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because the default file plan can not be determined. Make sure at least one file plan has been created."); - } - throw new AlfrescoRuntimeException("Can not declare version record, because the default file plan can not be determined."); - } - } - else - { - // verify that the provided file plan is actually a file plan - if (!filePlanService.isFilePlan(filePlan)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Can not declare version record, because the provided file plan node reference is not a file plan."); - } - throw new AlfrescoRuntimeException("Can not declare version record, because the provided file plan node reference is not a file plan."); - } - } - - // create record from latest version - recordableVersionService.createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List params) - { - // NOTE: commented out for now so that it doesn't appear in the UI ... enable later when multi-file plan support is added - //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Creates a new record from the 'current' document version. + * + * Note: This is a 'normal' dm action, rather than a records management action. + * + * @author Roy Wetherall + */ +public class DeclareAsVersionRecordAction extends AuditableActionExecuterAbstractBase + implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(DeclareAsVersionRecordAction.class); + + /** Action name */ + public static final String NAME = "declare-version-record"; + + /** Parameter names */ + public static final String PARAM_FILE_PLAN = "file-plan"; + + /** Sync Model URI */ + private static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; + + /** Synced aspect */ + private static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); + + /** Node service */ + private NodeService nodeService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** recordable version service */ + private RecordableVersionService recordableVersionService; + + /** authentication util */ + private AuthenticationUtil authenticationUtil; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param recordableVersionService recordable version service + */ + public void setRecordableVersionService(RecordableVersionService recordableVersionService) + { + this.recordableVersionService = recordableVersionService; + } + + /** + * @param authenticationUtil authentication util + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + { + if (!nodeService.exists(actionedUponNodeRef)) + { + // do not create record if the actioned upon node does not exist! + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " does not exist."); + } + } + else if (!dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT)) + { + // TODO eventually we should support other types .. either as record folders or as composite records + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " is not a supported type."); + } + } + else if (!nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " does not have the versionable aspect applied."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) + { + // Do not declare version record if the actioned upon node is already a record! + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " is already a record."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY)) + { + // We can not create records from working copies + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " is a working copy."); + } + + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS)) + { + // can not create a record from a previously rejected one + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " has previously been rejected."); + } + } + else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED)) + { + // can't declare the record if the node is sync'ed + if (logger.isDebugEnabled()) + { + logger.debug("Can't declare version record, because " + actionedUponNodeRef.toString() + " is synched content."); + } + } + else + { + NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); + if (filePlan == null) + { + // TODO .. eventually make the file plan parameter required + + filePlan = authenticationUtil.runAs(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() + { + @Override + public NodeRef doWork() + { + return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + }, authenticationUtil.getAdminUserName()); + + // if the file plan is still null, raise an exception + if (filePlan == null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because the default file plan can not be determined. Make sure at least one file plan has been created."); + } + throw new AlfrescoRuntimeException("Can not declare version record, because the default file plan can not be determined."); + } + } + else + { + // verify that the provided file plan is actually a file plan + if (!filePlanService.isFilePlan(filePlan)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Can not declare version record, because the provided file plan node reference is not a file plan."); + } + throw new AlfrescoRuntimeException("Can not declare version record, because the provided file plan node reference is not a file plan."); + } + } + + // create record from latest version + recordableVersionService.createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List params) + { + // NOTE: commented out for now so that it doesn't appear in the UI ... enable later when multi-file plan support is added + //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/ExecuteScriptAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/ExecuteScriptAction.java index f6dbbb8edd..070276342a 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/ExecuteScriptAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/ExecuteScriptAction.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ScriptActionExecuter; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; - -/** - * Executes a JavaScript - * - * Note: This is a 'normal' dm action, rather than a records management action. - * - * @author Craig Tan - */ -public class ExecuteScriptAction extends ScriptActionExecuter -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_SCRIPTREF, DataTypeDefinition.NODE_REF, true, - getParamDisplayLabel(PARAM_SCRIPTREF), false, "rm-ac-scripts")); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import java.util.List; + +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.action.executer.ScriptActionExecuter; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; + +/** + * Executes a JavaScript + * + * Note: This is a 'normal' dm action, rather than a records management action. + * + * @author Craig Tan + */ +public class ExecuteScriptAction extends ScriptActionExecuter +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_SCRIPTREF, DataTypeDefinition.NODE_REF, true, + getParamDisplayLabel(PARAM_SCRIPTREF), false, "rm-ac-scripts")); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java index 011a7fcbe1..0ee4454876 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java @@ -1,102 +1,102 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Hides a record within a collaboration site. - * - * Note: This is a 'normal' dm action, rather than a records management action. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class HideRecordAction extends AuditableActionExecuterAbstractBase - implements RecordsManagementModel -{ - - /** Logger */ - private static Log logger = LogFactory.getLog(HideRecordAction.class); - - /** Action name */ - public static final String NAME = "hide-record"; - - /** Node service */ - private NodeService nodeService; - - /** Inplace record service */ - private InplaceRecordService inplaceRecordService; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param inplaceRecordService inplace record service - */ - public void setInplaceRecordService(InplaceRecordService inplaceRecordService) - { - this.inplaceRecordService = inplaceRecordService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (!nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) - { - // we cannot hide a document which is not a record - if (logger.isDebugEnabled()) - { - logger.debug("Cannot hide the document, because '" + actionedUponNodeRef.toString() + "' is not a record."); - } - } - else - { - // hide the record from the collaboration site - inplaceRecordService.hideRecord(actionedUponNodeRef); - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - // Intentionally empty - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Hides a record within a collaboration site. + * + * Note: This is a 'normal' dm action, rather than a records management action. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class HideRecordAction extends AuditableActionExecuterAbstractBase + implements RecordsManagementModel +{ + + /** Logger */ + private static Log logger = LogFactory.getLog(HideRecordAction.class); + + /** Action name */ + public static final String NAME = "hide-record"; + + /** Node service */ + private NodeService nodeService; + + /** Inplace record service */ + private InplaceRecordService inplaceRecordService; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param inplaceRecordService inplace record service + */ + public void setInplaceRecordService(InplaceRecordService inplaceRecordService) + { + this.inplaceRecordService = inplaceRecordService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (!nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD)) + { + // we cannot hide a document which is not a record + if (logger.isDebugEnabled()) + { + logger.debug("Cannot hide the document, because '" + actionedUponNodeRef.toString() + "' is not a record."); + } + } + else + { + // hide the record from the collaboration site + inplaceRecordService.hideRecord(actionedUponNodeRef); + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + // Intentionally empty + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java index e0898671ad..327ff13a96 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java @@ -1,143 +1,143 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Moves a record within a collaboration site. - * The record can be moved only within the collaboration site where it was declared. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class MoveDmRecordAction extends AuditableActionExecuterAbstractBase implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(MoveDmRecordAction.class); - - /** Action name */ - public static final String NAME = "move-dm-record"; - - /** Constant for target node reference parameter */ - public static final String PARAM_TARGET_NODE_REF = "targetNodeRef"; - - /** Node service */ - private NodeService nodeService; - - /** Inplace record service */ - private InplaceRecordService inplaceRecordService; - - /** - * Gets the node service - * - * @return Node service - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Sets the node service - * - * @param nodeService Node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Gets the inplace record service - * - * @return Inplace record service - */ - protected InplaceRecordService getInplaceRecordService() - { - return this.inplaceRecordService; - } - - /** - * Sets the inplace record service - * - * @param InplaceRecordService Inplace record service - */ - public void setInplaceRecordService(InplaceRecordService inplaceRecordService) - { - this.inplaceRecordService = inplaceRecordService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // Cannot move a document which is not a record - if (!getNodeService().hasAspect(actionedUponNodeRef, ASPECT_RECORD) && logger.isDebugEnabled()) - { - logger.debug("Cannot move the document, because '" + actionedUponNodeRef.toString() + "' is not a record."); - } - else - { - // Move the record within the collaboration site - getInplaceRecordService().moveRecord(actionedUponNodeRef, getTargetNodeRef(action)); - } - } - - /** - * Helper method to get the target node reference from the action parameter - * - * @param action The action - * @return Node reference of the target - */ - private NodeRef getTargetNodeRef(Action action) - { - String targetNodeRef = (String) action.getParameterValue(PARAM_TARGET_NODE_REF); - - if (StringUtils.isBlank(targetNodeRef)) - { - throw new AlfrescoRuntimeException("Could not find target node reference."); - } - - return new NodeRef(targetNodeRef); - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - // Intentionally empty - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Moves a record within a collaboration site. + * The record can be moved only within the collaboration site where it was declared. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class MoveDmRecordAction extends AuditableActionExecuterAbstractBase implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(MoveDmRecordAction.class); + + /** Action name */ + public static final String NAME = "move-dm-record"; + + /** Constant for target node reference parameter */ + public static final String PARAM_TARGET_NODE_REF = "targetNodeRef"; + + /** Node service */ + private NodeService nodeService; + + /** Inplace record service */ + private InplaceRecordService inplaceRecordService; + + /** + * Gets the node service + * + * @return Node service + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Sets the node service + * + * @param nodeService Node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Gets the inplace record service + * + * @return Inplace record service + */ + protected InplaceRecordService getInplaceRecordService() + { + return this.inplaceRecordService; + } + + /** + * Sets the inplace record service + * + * @param InplaceRecordService Inplace record service + */ + public void setInplaceRecordService(InplaceRecordService inplaceRecordService) + { + this.inplaceRecordService = inplaceRecordService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // Cannot move a document which is not a record + if (!getNodeService().hasAspect(actionedUponNodeRef, ASPECT_RECORD) && logger.isDebugEnabled()) + { + logger.debug("Cannot move the document, because '" + actionedUponNodeRef.toString() + "' is not a record."); + } + else + { + // Move the record within the collaboration site + getInplaceRecordService().moveRecord(actionedUponNodeRef, getTargetNodeRef(action)); + } + } + + /** + * Helper method to get the target node reference from the action parameter + * + * @param action The action + * @return Node reference of the target + */ + private NodeRef getTargetNodeRef(Action action) + { + String targetNodeRef = (String) action.getParameterValue(PARAM_TARGET_NODE_REF); + + if (StringUtils.isBlank(targetNodeRef)) + { + throw new AlfrescoRuntimeException("Could not find target node reference."); + } + + return new NodeRef(targetNodeRef); + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + // Intentionally empty + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/RecordableVersionConfigAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/RecordableVersionConfigAction.java index b9ce07b602..99af8a1314 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/RecordableVersionConfigAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/RecordableVersionConfigAction.java @@ -1,195 +1,195 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import static org.alfresco.model.ContentModel.ASPECT_VERSIONABLE; -import static org.alfresco.model.ContentModel.TYPE_CONTENT; -import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; -import static org.alfresco.service.cmr.dictionary.DataTypeDefinition.TEXT; -import static org.apache.commons.logging.LogFactory.getLog; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; - -/** - * Sets the recordable version config for a document within a collaboration site. - * - * Note: This is a 'normal' dm action, rather than a records management action. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordableVersionConfigAction extends ActionExecuterAbstractBase -{ - /** Logger */ - private static Log LOGGER = getLog(RecordableVersionConfigAction.class); - - /** Action name */ - public static final String NAME = "recordable-version-config"; - - /** Parameter names */ - public static final String PARAM_VERSION = "version"; - - /** Node service */ - private NodeService nodeService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** - * Gets the node service - * - * @return The node service - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Sets the node service - * - * @param nodeService The node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Gets the dictionary service - * - * @return The dictionary service - */ - protected DictionaryService getDictionaryService() - { - return this.dictionaryService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (passedChecks(actionedUponNodeRef)) - { - String version = (String) action.getParameterValue(PARAM_VERSION); - getNodeService().setProperty(actionedUponNodeRef, PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.valueOf(version)); - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_VERSION, TEXT, true, getParamDisplayLabel(PARAM_VERSION), false, "ac-versions")); - } - - /** - * Helper method to do checks on the actioned upon node reference - * - * @param actionedUponNodeRef The actioned upon node reference - * @return true if the actioned upon node reference passes the checks, false otherwise - */ - private boolean passedChecks(NodeRef actionedUponNodeRef) - { - boolean passedChecks = true; - - if (!getNodeService().exists(actionedUponNodeRef)) - { - passedChecks = false; - if (LOGGER.isDebugEnabled()) - { - String message = buildLogMessage(actionedUponNodeRef, "' because the node does not exist."); - LOGGER.debug(message); - } - } - - QName type = getNodeService().getType(actionedUponNodeRef); - if (!getDictionaryService().isSubClass(type, TYPE_CONTENT)) - { - passedChecks = false; - if (LOGGER.isDebugEnabled()) - { - String message = buildLogMessage(actionedUponNodeRef, "' because the type of the node '" + type.getLocalName() + "' is not supported."); - LOGGER.debug(message); - } - } - - if (getNodeService().hasAspect(actionedUponNodeRef, ASPECT_RECORD)) - { - passedChecks = false; - if (LOGGER.isDebugEnabled()) - { - String message = buildLogMessage(actionedUponNodeRef, "' because the rule cannot be applied to records."); - LOGGER.debug(message); - } - } - - if (!getNodeService().hasAspect(actionedUponNodeRef, ASPECT_VERSIONABLE)) - { - passedChecks = false; - if (LOGGER.isDebugEnabled()) - { - String buildLogMessage = buildLogMessage(actionedUponNodeRef, "' because the rule cannot be applied to records."); - LOGGER.debug(buildLogMessage); - } - } - - return passedChecks; - } - - /** - * Helper method to construct log message - * - * @param actionedUponNodeRef The actioned upon node reference - * @param messagePart The message which should be appended. - * @return The constructed log message - */ - private String buildLogMessage(NodeRef actionedUponNodeRef, String messagePart) - { - StringBuilder sb = new StringBuilder(); - sb.append("Cannot set recordable version config for '"); - sb.append(actionedUponNodeRef.toString()); - sb.append(messagePart); - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import static org.alfresco.model.ContentModel.ASPECT_VERSIONABLE; +import static org.alfresco.model.ContentModel.TYPE_CONTENT; +import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; +import static org.alfresco.service.cmr.dictionary.DataTypeDefinition.TEXT; +import static org.apache.commons.logging.LogFactory.getLog; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; + +/** + * Sets the recordable version config for a document within a collaboration site. + * + * Note: This is a 'normal' dm action, rather than a records management action. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordableVersionConfigAction extends ActionExecuterAbstractBase +{ + /** Logger */ + private static Log LOGGER = getLog(RecordableVersionConfigAction.class); + + /** Action name */ + public static final String NAME = "recordable-version-config"; + + /** Parameter names */ + public static final String PARAM_VERSION = "version"; + + /** Node service */ + private NodeService nodeService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** + * Gets the node service + * + * @return The node service + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Sets the node service + * + * @param nodeService The node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Gets the dictionary service + * + * @return The dictionary service + */ + protected DictionaryService getDictionaryService() + { + return this.dictionaryService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (passedChecks(actionedUponNodeRef)) + { + String version = (String) action.getParameterValue(PARAM_VERSION); + getNodeService().setProperty(actionedUponNodeRef, PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.valueOf(version)); + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_VERSION, TEXT, true, getParamDisplayLabel(PARAM_VERSION), false, "ac-versions")); + } + + /** + * Helper method to do checks on the actioned upon node reference + * + * @param actionedUponNodeRef The actioned upon node reference + * @return true if the actioned upon node reference passes the checks, false otherwise + */ + private boolean passedChecks(NodeRef actionedUponNodeRef) + { + boolean passedChecks = true; + + if (!getNodeService().exists(actionedUponNodeRef)) + { + passedChecks = false; + if (LOGGER.isDebugEnabled()) + { + String message = buildLogMessage(actionedUponNodeRef, "' because the node does not exist."); + LOGGER.debug(message); + } + } + + QName type = getNodeService().getType(actionedUponNodeRef); + if (!getDictionaryService().isSubClass(type, TYPE_CONTENT)) + { + passedChecks = false; + if (LOGGER.isDebugEnabled()) + { + String message = buildLogMessage(actionedUponNodeRef, "' because the type of the node '" + type.getLocalName() + "' is not supported."); + LOGGER.debug(message); + } + } + + if (getNodeService().hasAspect(actionedUponNodeRef, ASPECT_RECORD)) + { + passedChecks = false; + if (LOGGER.isDebugEnabled()) + { + String message = buildLogMessage(actionedUponNodeRef, "' because the rule cannot be applied to records."); + LOGGER.debug(message); + } + } + + if (!getNodeService().hasAspect(actionedUponNodeRef, ASPECT_VERSIONABLE)) + { + passedChecks = false; + if (LOGGER.isDebugEnabled()) + { + String buildLogMessage = buildLogMessage(actionedUponNodeRef, "' because the rule cannot be applied to records."); + LOGGER.debug(buildLogMessage); + } + } + + return passedChecks; + } + + /** + * Helper method to construct log message + * + * @param actionedUponNodeRef The actioned upon node reference + * @param messagePart The message which should be appended. + * @return The constructed log message + */ + private String buildLogMessage(NodeRef actionedUponNodeRef, String messagePart) + { + StringBuilder sb = new StringBuilder(); + sb.append("Cannot set recordable version config for '"); + sb.append(actionedUponNodeRef.toString()); + sb.append(messagePart); + return sb.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/CapabilityConditionEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/CapabilityConditionEvaluator.java index 7215d204d6..d819225058 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/CapabilityConditionEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/CapabilityConditionEvaluator.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; - -/** - * Records management evaluator base implementation that delegates to a configured capability condition - * implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class CapabilityConditionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase -{ - /** Capability Condition */ - private CapabilityCondition capabilityCondition; - - /** - * @param capabilityCondition capability condition - */ - public void setCapabilityCondition(CapabilityCondition capabilityCondition) - { - this.capabilityCondition = capabilityCondition; - } - - /** - * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) - { - // check a capability condition has been set and delegate - ParameterCheck.mandatory("capabilityCondition", capabilityCondition); - return capabilityCondition.evaluate(actionedUponNodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.ParameterCheck; + +/** + * Records management evaluator base implementation that delegates to a configured capability condition + * implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class CapabilityConditionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase +{ + /** Capability Condition */ + private CapabilityCondition capabilityCondition; + + /** + * @param capabilityCondition capability condition + */ + public void setCapabilityCondition(CapabilityCondition capabilityCondition) + { + this.capabilityCondition = capabilityCondition; + } + + /** + * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) + { + // check a capability condition has been set and delegate + ParameterCheck.mandatory("capabilityCondition", capabilityCondition); + return capabilityCondition.evaluate(actionedUponNodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DelegateActionCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DelegateActionCondition.java index 14f9939716..2d7a7822a3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DelegateActionCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DelegateActionCondition.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; -import org.alfresco.repo.action.evaluator.ActionConditionEvaluator; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Records management action condition who's implementation is delegated to an existing - * action condition. - *

- * Useful for creating a RM version of an existing action condition implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class DelegateActionCondition extends RecordsManagementActionConditionEvaluatorAbstractBase -{ - /** Delegate action evaluator */ - private ActionConditionEvaluator actionConditionEvaluator; - - /** - * @param actionEvaluator action evaluator - */ - public void setActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator) - { - this.actionConditionEvaluator = actionConditionEvaluator; - } - - /** - * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) - { - return actionConditionEvaluator.evaluate(actionCondition, actionedUponNodeRef); - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions() - */ - @Override - protected List getParameterDefintions() - { - return actionConditionEvaluator.getActionConditionDefintion().getParameterDefinitions(); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; +import org.alfresco.repo.action.evaluator.ActionConditionEvaluator; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Records management action condition who's implementation is delegated to an existing + * action condition. + *

+ * Useful for creating a RM version of an existing action condition implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class DelegateActionCondition extends RecordsManagementActionConditionEvaluatorAbstractBase +{ + /** Delegate action evaluator */ + private ActionConditionEvaluator actionConditionEvaluator; + + /** + * @param actionEvaluator action evaluator + */ + public void setActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator) + { + this.actionConditionEvaluator = actionConditionEvaluator; + } + + /** + * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) + { + return actionConditionEvaluator.evaluate(actionCondition, actionedUponNodeRef); + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions() + */ + @Override + protected List getParameterDefintions() + { + return actionConditionEvaluator.getActionConditionDefintion().getParameterDefinitions(); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DispositionActionRelativePositions.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DispositionActionRelativePositions.java index ccc480bab5..8be7bff9a6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DispositionActionRelativePositions.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/DispositionActionRelativePositions.java @@ -1,30 +1,30 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -/** - * Disposition action relative position enumeration class.
- * - * @author Craig Tan - * @since 2.1 - */ -public enum DispositionActionRelativePositions -{ - ANY, NEXT, PREVIOUS; -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +/** + * Disposition action relative position enumeration class.
+ * + * @author Craig Tan + * @since 2.1 + */ +public enum DispositionActionRelativePositions +{ + ANY, NEXT, PREVIOUS; +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/HasDispositionActionEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/HasDispositionActionEvaluator.java index ea6d77d414..2e056b7a43 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/HasDispositionActionEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/HasDispositionActionEvaluator.java @@ -1,130 +1,130 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - - - -/** - * Records management hasDispositionAction evaluator that evaluates whether the given node's disposition schedule has the specified disposition action. - * - * @author Craig Tan - * @since 2.1 - */ -public class HasDispositionActionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase -{ - /** - * Evaluator constants - */ - public static final String NAME = "hasDispositionAction"; - - public static final String PARAM_DISPOSITION_ACTION_RELATIVE_POSITION = "position"; - - public static final String PARAM_DISPOSITION_ACTION = "action"; - - private DispositionService dispositionService; - - /** - * @param dispositionService - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - @Override - protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) - { - boolean result = false; - String position = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION)).getLocalName(); - String action = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION)).getLocalName(); - - - if (dispositionService.isDisposableItem(actionedUponNodeRef)) - { - - if (position.equals(DispositionActionRelativePositions.ANY.toString())) - { - - DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(actionedUponNodeRef); - if (dispositionSchedule != null) - { - for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) - { - if (dispositionActionDefinition.getName().equals(action)) - { - result = true; - break; - } - } - } - } - else if (position.equals(DispositionActionRelativePositions.NEXT.toString())) - { - DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(actionedUponNodeRef); - if (nextDispositionAction != null) - { - // Get the disposition actions name - String actionName = nextDispositionAction.getName(); - if (actionName.equals(action)) - { - result = true; - } - } - } - else if (position.equals(DispositionActionRelativePositions.PREVIOUS.toString())) - { - DispositionAction lastCompletedDispositionAction = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef); - if (lastCompletedDispositionAction != null) - { - // Get the disposition actions name - String actionName = lastCompletedDispositionAction.getName(); - if (actionName.equals(action)) - { - result = true; - } - } - } - } - return result; - } - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION, DataTypeDefinition.QNAME, true, - getParamDisplayLabel(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION), false, "rm-ac-disposition-action-relative-positions")); - paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_DISPOSITION_ACTION), false, - "rm-ac-disposition-actions")); - - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + + + +/** + * Records management hasDispositionAction evaluator that evaluates whether the given node's disposition schedule has the specified disposition action. + * + * @author Craig Tan + * @since 2.1 + */ +public class HasDispositionActionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase +{ + /** + * Evaluator constants + */ + public static final String NAME = "hasDispositionAction"; + + public static final String PARAM_DISPOSITION_ACTION_RELATIVE_POSITION = "position"; + + public static final String PARAM_DISPOSITION_ACTION = "action"; + + private DispositionService dispositionService; + + /** + * @param dispositionService + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + @Override + protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) + { + boolean result = false; + String position = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION)).getLocalName(); + String action = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION)).getLocalName(); + + + if (dispositionService.isDisposableItem(actionedUponNodeRef)) + { + + if (position.equals(DispositionActionRelativePositions.ANY.toString())) + { + + DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(actionedUponNodeRef); + if (dispositionSchedule != null) + { + for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) + { + if (dispositionActionDefinition.getName().equals(action)) + { + result = true; + break; + } + } + } + } + else if (position.equals(DispositionActionRelativePositions.NEXT.toString())) + { + DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(actionedUponNodeRef); + if (nextDispositionAction != null) + { + // Get the disposition actions name + String actionName = nextDispositionAction.getName(); + if (actionName.equals(action)) + { + result = true; + } + } + } + else if (position.equals(DispositionActionRelativePositions.PREVIOUS.toString())) + { + DispositionAction lastCompletedDispositionAction = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef); + if (lastCompletedDispositionAction != null) + { + // Get the disposition actions name + String actionName = lastCompletedDispositionAction.getName(); + if (actionName.equals(action)) + { + result = true; + } + } + } + } + return result; + } + + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION, DataTypeDefinition.QNAME, true, + getParamDisplayLabel(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION), false, "rm-ac-disposition-action-relative-positions")); + paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_DISPOSITION_ACTION), false, + "rm-ac-disposition-actions")); + + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsKindEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsKindEvaluator.java index 72f2780f40..a604739057 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsKindEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsKindEvaluator.java @@ -1,74 +1,74 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - - - -/** - * Records management IsKind evaluator that evaluates according to the file plan - * component kind passed in. - * - * @author Craig Tan - * @since 2.1 - */ -/** - * @author ctan - */ -public class IsKindEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase -{ - /** - * Evaluator constants - */ - public static final String NAME = "isKind"; - public static final String PARAM_KIND = "kind"; - - @Override - protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) - { - boolean result = false; - String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName(); - - FilePlanComponentKind filePlanComponentKind = getFilePlanService().getFilePlanComponentKind(actionedUponNodeRef); - - if (filePlanComponentKind != null && - filePlanComponentKind.toString().equals(kind)) - { - result = true; - } - return result; - } - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_KIND, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_KIND), false, "rm-ac-is-kind-kinds")); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + + + +/** + * Records management IsKind evaluator that evaluates according to the file plan + * component kind passed in. + * + * @author Craig Tan + * @since 2.1 + */ +/** + * @author ctan + */ +public class IsKindEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase +{ + /** + * Evaluator constants + */ + public static final String NAME = "isKind"; + public static final String PARAM_KIND = "kind"; + + @Override + protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) + { + boolean result = false; + String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName(); + + FilePlanComponentKind filePlanComponentKind = getFilePlanService().getFilePlanComponentKind(actionedUponNodeRef); + + if (filePlanComponentKind != null && + filePlanComponentKind.toString().equals(kind)) + { + result = true; + } + return result; + } + + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_KIND, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_KIND), false, "rm-ac-is-kind-kinds")); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsRecordTypeEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsRecordTypeEvaluator.java index 5755f575ff..0387917c44 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsRecordTypeEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/evaluator/IsRecordTypeEvaluator.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; - - - -/** - * Records management IsRecordType evaluator that evaluates whether the record is of the specified type. - * - * @author Craig Tan - * @since 2.1 - */ -/** - * @author ctan - */ -public class IsRecordTypeEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase implements DOD5015Model -{ - /** - * Evaluator constants - */ - public static final String NAME = "isRecordType"; - - public static final String PARAM_RECORD_TYPE = "type"; - - private NodeService nodeService; - - /** - * @param nodeService - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - @Override - protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) - { - boolean result = false; - String type = ((QName) actionCondition.getParameterValue(PARAM_RECORD_TYPE)).getLocalName(); - - if (type != null) - { - result = nodeService.hasAspect(actionedUponNodeRef, QName.createQName(DOD_URI, type)); - } - - return result; - } - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_RECORD_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_RECORD_TYPE), false, "rm-ac-record-types")); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + + + +/** + * Records management IsRecordType evaluator that evaluates whether the record is of the specified type. + * + * @author Craig Tan + * @since 2.1 + */ +/** + * @author ctan + */ +public class IsRecordTypeEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase implements DOD5015Model +{ + /** + * Evaluator constants + */ + public static final String NAME = "isRecordType"; + + public static final String PARAM_RECORD_TYPE = "type"; + + private NodeService nodeService; + + /** + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + @Override + protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) + { + boolean result = false; + String type = ((QName) actionCondition.getParameterValue(PARAM_RECORD_TYPE)).getLocalName(); + + if (type != null) + { + result = nodeService.hasAspect(actionedUponNodeRef, QName.createQName(DOD_URI, type)); + } + + return result; + } + + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_RECORD_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_RECORD_TYPE), false, "rm-ac-record-types")); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/AddRecordTypeAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/AddRecordTypeAction.java index 61281dbd6c..b7bdeb23be 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/AddRecordTypeAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/AddRecordTypeAction.java @@ -1,121 +1,121 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Action to add types to a record - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class AddRecordTypeAction extends RMActionExecuterAbstractBase -{ - /** Logger */ - private static Log logger = LogFactory.getLog(AddRecordTypeAction.class); - - /** I18N */ - private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record"; - - /** Constant */ - private static final String DELIMITER = ","; - - /** Parameter names */ - public static final String PARAM_ADD_RECORD_TYPES = "recordTypes"; - - /** Action name */ - public static final String NAME = "addRecordTypes"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (eligibleForAction(actionedUponNodeRef)) - { - for (String type : getRecordTypes(action)) - { - getRecordService().addRecordType(actionedUponNodeRef, QName.createQName(type, getNamespaceService())); - } - } - else if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString())); - } - } - - /** - * Helper method to check the actioned upon node reference to decide to execute the action - * The preconditions are: - * - The node must exist - * - The node must not be frozen - * - The node must be record - * - The node must not be declared - * - * @param actionedUponNodeRef node reference - * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise - */ - private boolean eligibleForAction(NodeRef actionedUponNodeRef) - { - boolean result = false; - if (getNodeService().exists(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef) && - getRecordService().isRecord(actionedUponNodeRef) && - !getRecordService().isDeclared(actionedUponNodeRef)) - { - result = true; - } - return result; - } - - /** - * Helper method to get the record types from the action - * - * @param action The action - * @return An array of record types - */ - private String[] getRecordTypes(Action action) - { - String recordTypes = (String) action.getParameterValue(PARAM_ADD_RECORD_TYPES); - return recordTypes.split(DELIMITER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_ADD_RECORD_TYPES, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_ADD_RECORD_TYPES))); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Action to add types to a record + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class AddRecordTypeAction extends RMActionExecuterAbstractBase +{ + /** Logger */ + private static Log logger = LogFactory.getLog(AddRecordTypeAction.class); + + /** I18N */ + private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record"; + + /** Constant */ + private static final String DELIMITER = ","; + + /** Parameter names */ + public static final String PARAM_ADD_RECORD_TYPES = "recordTypes"; + + /** Action name */ + public static final String NAME = "addRecordTypes"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (eligibleForAction(actionedUponNodeRef)) + { + for (String type : getRecordTypes(action)) + { + getRecordService().addRecordType(actionedUponNodeRef, QName.createQName(type, getNamespaceService())); + } + } + else if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString())); + } + } + + /** + * Helper method to check the actioned upon node reference to decide to execute the action + * The preconditions are: + * - The node must exist + * - The node must not be frozen + * - The node must be record + * - The node must not be declared + * + * @param actionedUponNodeRef node reference + * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise + */ + private boolean eligibleForAction(NodeRef actionedUponNodeRef) + { + boolean result = false; + if (getNodeService().exists(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef) && + getRecordService().isRecord(actionedUponNodeRef) && + !getRecordService().isDeclared(actionedUponNodeRef)) + { + result = true; + } + return result; + } + + /** + * Helper method to get the record types from the action + * + * @param action The action + * @return An array of record types + */ + private String[] getRecordTypes(Action action) + { + String recordTypes = (String) action.getParameterValue(PARAM_ADD_RECORD_TYPES); + return recordTypes.split(DELIMITER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_ADD_RECORD_TYPES, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_ADD_RECORD_TYPES))); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/ApplyCustomTypeAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/ApplyCustomTypeAction.java index c9d78a3080..91d5415044 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/ApplyCustomTypeAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/ApplyCustomTypeAction.java @@ -1,146 +1,146 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * This class applies the aspect specified in the spring bean property customTypeAspect. - * It is used to apply one of the 4 "custom type" aspects from the DOD 5015 model. - * - * @author Neil McErlean - */ -public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record"; - private static final String MSG_CUSTOM_ASPECT_NOT_RECOGNISED = "rm.action.custom-aspect-not-recognised"; - - private static Log logger = LogFactory.getLog(ApplyCustomTypeAction.class); - private QName customTypeAspect; - private List parameterDefinitions; - - public void setCustomTypeAspect(String customTypeAspect) - { - this.customTypeAspect = QName.createQName(customTypeAspect, getNamespaceService()); - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (logger.isDebugEnabled()) - { - logger.debug("Executing action [" + action.getActionDefinitionName() + "] on " + actionedUponNodeRef); - } - - if (getRecordService().isRecord(actionedUponNodeRef)) - { - // Apply the appropriate aspect and set the properties. - Map aspectProps = getPropertyValues(action); - this.getNodeService().addAspect(actionedUponNodeRef, customTypeAspect, aspectProps); - } - else if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString())); - } - } - - /** - * This method extracts the properties from the custom type's aspect. - * @see #getCustomTypeAspect() - */ - @Override - protected final void addParameterDefinitions(List paramList) - { - AspectDefinition aspectDef = getDictionaryService().getAspect(customTypeAspect); - for (PropertyDefinition propDef : aspectDef.getProperties().values()) - { - QName propName = propDef.getName(); - QName propType = propDef.getDataType().getName(); - paramList.add(new ParameterDefinitionImpl(propName.toPrefixString(), propType, propDef.isMandatory(), null)); - } - } - - /** - * This method converts a Map of String, Serializable to a Map of QName, Serializable. - * To do this, it assumes that each parameter name is a String representing a qname - * of the form prefix:localName. - */ - private Map getPropertyValues(Action action) - { - Map paramValues = action.getParameterValues(); - - Map result = new HashMap(paramValues.size()); - for (Map.Entry entry : paramValues.entrySet()) - { - QName propQName = QName.createQName(entry.getKey(), this.getNamespaceService()); - result.put(propQName, entry.getValue()); - } - - return result; - } - - @Override - protected synchronized List getParameterDefintions() - { - // We can take these parameter definitions from the properties defined in the dod model. - if (this.parameterDefinitions == null) - { - AspectDefinition aspectDefinition = getDictionaryService().getAspect(customTypeAspect); - if (aspectDefinition == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_ASPECT_NOT_RECOGNISED, customTypeAspect)); - } - - Map props = aspectDefinition.getProperties(); - - this.parameterDefinitions = new ArrayList(props.size()); - - for (Map.Entry entry : props.entrySet()) - { - String paramName = entry.getKey().toPrefixString(getNamespaceService()); - PropertyDefinition value = entry.getValue(); - QName paramType = value.getDataType().getName(); - boolean paramIsMandatory = value.isMandatory(); - parameterDefinitions.add(new ParameterDefinitionImpl(paramName, paramType, paramIsMandatory, null)); - } - } - return parameterDefinitions; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * This class applies the aspect specified in the spring bean property customTypeAspect. + * It is used to apply one of the 4 "custom type" aspects from the DOD 5015 model. + * + * @author Neil McErlean + */ +public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record"; + private static final String MSG_CUSTOM_ASPECT_NOT_RECOGNISED = "rm.action.custom-aspect-not-recognised"; + + private static Log logger = LogFactory.getLog(ApplyCustomTypeAction.class); + private QName customTypeAspect; + private List parameterDefinitions; + + public void setCustomTypeAspect(String customTypeAspect) + { + this.customTypeAspect = QName.createQName(customTypeAspect, getNamespaceService()); + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (logger.isDebugEnabled()) + { + logger.debug("Executing action [" + action.getActionDefinitionName() + "] on " + actionedUponNodeRef); + } + + if (getRecordService().isRecord(actionedUponNodeRef)) + { + // Apply the appropriate aspect and set the properties. + Map aspectProps = getPropertyValues(action); + this.getNodeService().addAspect(actionedUponNodeRef, customTypeAspect, aspectProps); + } + else if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString())); + } + } + + /** + * This method extracts the properties from the custom type's aspect. + * @see #getCustomTypeAspect() + */ + @Override + protected final void addParameterDefinitions(List paramList) + { + AspectDefinition aspectDef = getDictionaryService().getAspect(customTypeAspect); + for (PropertyDefinition propDef : aspectDef.getProperties().values()) + { + QName propName = propDef.getName(); + QName propType = propDef.getDataType().getName(); + paramList.add(new ParameterDefinitionImpl(propName.toPrefixString(), propType, propDef.isMandatory(), null)); + } + } + + /** + * This method converts a Map of String, Serializable to a Map of QName, Serializable. + * To do this, it assumes that each parameter name is a String representing a qname + * of the form prefix:localName. + */ + private Map getPropertyValues(Action action) + { + Map paramValues = action.getParameterValues(); + + Map result = new HashMap(paramValues.size()); + for (Map.Entry entry : paramValues.entrySet()) + { + QName propQName = QName.createQName(entry.getKey(), this.getNamespaceService()); + result.put(propQName, entry.getValue()); + } + + return result; + } + + @Override + protected synchronized List getParameterDefintions() + { + // We can take these parameter definitions from the properties defined in the dod model. + if (this.parameterDefinitions == null) + { + AspectDefinition aspectDefinition = getDictionaryService().getAspect(customTypeAspect); + if (aspectDefinition == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_ASPECT_NOT_RECOGNISED, customTypeAspect)); + } + + Map props = aspectDefinition.getProperties(); + + this.parameterDefinitions = new ArrayList(props.size()); + + for (Map.Entry entry : props.entrySet()) + { + String paramName = entry.getKey().toPrefixString(getNamespaceService()); + PropertyDefinition value = entry.getValue(); + QName paramType = value.getDataType().getName(); + boolean paramIsMandatory = value.isMandatory(); + parameterDefinitions.add(new ParameterDefinitionImpl(paramName, paramType, paramIsMandatory, null)); + } + } + return parameterDefinitions; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/BroadcastDispositionActionDefinitionUpdateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/BroadcastDispositionActionDefinitionUpdateAction.java index fcd70bad1c..7dc22f9b65 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/BroadcastDispositionActionDefinitionUpdateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/BroadcastDispositionActionDefinitionUpdateAction.java @@ -1,266 +1,266 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Action to implement the consequences of a change to the value of the DispositionActionDefinition - * properties. When these properties are changed on a disposition schedule, then any associated - * disposition actions may need to be updated as a consequence. - * - * @author Neil McErlean - */ -public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionExecuterAbstractBase -{ - /** Logger */ - private static Log logger = LogFactory.getLog(BroadcastDispositionActionDefinitionUpdateAction.class); - - public static final String NAME = "broadcastDispositionActionDefinitionUpdate"; - public static final String CHANGED_PROPERTIES = "changedProperties"; - - private BehaviourFilter behaviourFilter; - - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (!RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION.equals(getNodeService().getType(actionedUponNodeRef))) - { - return; - } - - List changedProps = (List)action.getParameterValue(CHANGED_PROPERTIES); - - // Navigate up the containment hierarchy to get the record category grandparent and schedule. - NodeRef dispositionScheduleNode = getNodeService().getPrimaryParent(actionedUponNodeRef).getParentRef(); - NodeRef rmContainer = getNodeService().getPrimaryParent(dispositionScheduleNode).getParentRef(); - DispositionSchedule dispositionSchedule = getDispositionService().getAssociatedDispositionSchedule(rmContainer); - - behaviourFilter.disableBehaviour(); - try - { - List disposableItems = getDispositionService().getDisposableItems(dispositionSchedule); - for (NodeRef disposableItem : disposableItems) - { - updateDisposableItem(dispositionSchedule, disposableItem, actionedUponNodeRef, changedProps); - } - } - finally - { - behaviourFilter.enableBehaviour(); - } - } - - /** - * - * @param ds - * @param disposableItem - * @param dispositionActionDefinition - * @param changedProps - */ - private void updateDisposableItem(DispositionSchedule ds, NodeRef disposableItem, NodeRef dispositionActionDefinition, List changedProps) - { - // We need to check that this folder is under the management of the disposition schedule that - // has been updated - DispositionSchedule itemDs = getDispositionService().getDispositionSchedule(disposableItem); - if (itemDs != null && - itemDs.getNodeRef().equals(ds.getNodeRef())) - { - if (getNodeService().hasAspect(disposableItem, ASPECT_DISPOSITION_LIFECYCLE)) - { - // disposition lifecycle already exists for node so process changes - processActionDefinitionChanges(dispositionActionDefinition, changedProps, disposableItem); - } - else - { - // disposition lifecycle does not exist on the node so setup disposition - getDispositionService().updateNextDispositionAction(disposableItem); - } - - // update rolled up search information - rollupSearchProperties(disposableItem); - } - } - - /** - * Manually update the rolled up search properties - * - * @param disposableItem disposable item - */ - private void rollupSearchProperties(NodeRef disposableItem) - { - DispositionAction da = getDispositionService().getNextDispositionAction(disposableItem); - if (da != null) - { - Map props = getNodeService().getProperties(disposableItem); - - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); - props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); - props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, getNodeService().getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); - Period period = daDefinition.getPeriod(); - if (period != null) - { - props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); - } - else - { - props.put(PROP_RS_DISPOSITION_PERIOD, null); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); - } - - List events = da.getEventCompletionDetails(); - List list = new ArrayList(events.size()); - for (EventCompletionDetails event : events) - { - list.add(event.getEventName()); - } - props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable)list); - - getNodeService().setProperties(disposableItem, props); - } - } - - /** - * Processes all the changes applied to the given disposition - * action definition node for the given record or folder node. - * - * @param dispositionActionDef The disposition action definition node - * @param changedProps The set of properties changed on the action definition - * @param recordOrFolder The record or folder the changes potentially need to be applied to - */ - private void processActionDefinitionChanges(NodeRef dispositionActionDef, List changedProps, NodeRef recordOrFolder) - { - // check that the step being edited is the current step for the folder, - // if not, the change has no effect on the current step so ignore - DispositionAction nextAction = getDispositionService().getNextDispositionAction(recordOrFolder); - if (doesChangedStepAffectNextAction(dispositionActionDef, nextAction)) - { - // the change does effect the nextAction for this node - // so go ahead and determine what needs updating - if (changedProps.contains(PROP_DISPOSITION_PERIOD)) - { - persistPeriodChanges(dispositionActionDef, nextAction); - } - - if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION)) - { - nextAction.refreshEvents(); - } - - if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME)) - { - String action = (String)getNodeService().getProperty(dispositionActionDef, PROP_DISPOSITION_ACTION_NAME); - getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_ACTION, action); - } - } - } - - /** - * Determines whether the disposition action definition (step) being - * updated has any effect on the given next action - * - * @param dispositionActionDef The disposition action definition node - * @param nextAction The next disposition action - * @return true if the step change affects the next action - */ - private boolean doesChangedStepAffectNextAction(NodeRef dispositionActionDef, - DispositionAction nextAction) - { - boolean affectsNextAction = false; - - if (dispositionActionDef != null && nextAction != null) - { - // check whether the id of the action definition node being changed - // is the same as the id of the next action - String nextActionId = nextAction.getId(); - if (dispositionActionDef.getId().equals(nextActionId)) - { - affectsNextAction = true; - } - } - - return affectsNextAction; - } - - /** - * Persists any changes made to the period on the given disposition action - * definition on the given next action. - * - * @param dispositionActionDef The disposition action definition node - * @param nextAction The next disposition action - */ - private void persistPeriodChanges(NodeRef dispositionActionDef, DispositionAction nextAction) - { - Date newAsOfDate = null; - Period dispositionPeriod = (Period) getNodeService().getProperty(dispositionActionDef, PROP_DISPOSITION_PERIOD); - - if (dispositionPeriod != null) - { - // calculate the new as of date as we have been provided a new period - Date now = new Date(); - newAsOfDate = dispositionPeriod.getNextDate(now); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Set disposition as of date for next action '" + nextAction.getName() + - "' (" + nextAction.getNodeRef() + ") to: " + newAsOfDate); - } - - getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_AS_OF, newAsOfDate); - } - - @Override - protected void addParameterDefinitions(List paramList) - { - // Intentionally empty - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Action to implement the consequences of a change to the value of the DispositionActionDefinition + * properties. When these properties are changed on a disposition schedule, then any associated + * disposition actions may need to be updated as a consequence. + * + * @author Neil McErlean + */ +public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionExecuterAbstractBase +{ + /** Logger */ + private static Log logger = LogFactory.getLog(BroadcastDispositionActionDefinitionUpdateAction.class); + + public static final String NAME = "broadcastDispositionActionDefinitionUpdate"; + public static final String CHANGED_PROPERTIES = "changedProperties"; + + private BehaviourFilter behaviourFilter; + + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (!RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION.equals(getNodeService().getType(actionedUponNodeRef))) + { + return; + } + + List changedProps = (List)action.getParameterValue(CHANGED_PROPERTIES); + + // Navigate up the containment hierarchy to get the record category grandparent and schedule. + NodeRef dispositionScheduleNode = getNodeService().getPrimaryParent(actionedUponNodeRef).getParentRef(); + NodeRef rmContainer = getNodeService().getPrimaryParent(dispositionScheduleNode).getParentRef(); + DispositionSchedule dispositionSchedule = getDispositionService().getAssociatedDispositionSchedule(rmContainer); + + behaviourFilter.disableBehaviour(); + try + { + List disposableItems = getDispositionService().getDisposableItems(dispositionSchedule); + for (NodeRef disposableItem : disposableItems) + { + updateDisposableItem(dispositionSchedule, disposableItem, actionedUponNodeRef, changedProps); + } + } + finally + { + behaviourFilter.enableBehaviour(); + } + } + + /** + * + * @param ds + * @param disposableItem + * @param dispositionActionDefinition + * @param changedProps + */ + private void updateDisposableItem(DispositionSchedule ds, NodeRef disposableItem, NodeRef dispositionActionDefinition, List changedProps) + { + // We need to check that this folder is under the management of the disposition schedule that + // has been updated + DispositionSchedule itemDs = getDispositionService().getDispositionSchedule(disposableItem); + if (itemDs != null && + itemDs.getNodeRef().equals(ds.getNodeRef())) + { + if (getNodeService().hasAspect(disposableItem, ASPECT_DISPOSITION_LIFECYCLE)) + { + // disposition lifecycle already exists for node so process changes + processActionDefinitionChanges(dispositionActionDefinition, changedProps, disposableItem); + } + else + { + // disposition lifecycle does not exist on the node so setup disposition + getDispositionService().updateNextDispositionAction(disposableItem); + } + + // update rolled up search information + rollupSearchProperties(disposableItem); + } + } + + /** + * Manually update the rolled up search properties + * + * @param disposableItem disposable item + */ + private void rollupSearchProperties(NodeRef disposableItem) + { + DispositionAction da = getDispositionService().getNextDispositionAction(disposableItem); + if (da != null) + { + Map props = getNodeService().getProperties(disposableItem); + + props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); + props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); + props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, getNodeService().getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + Period period = daDefinition.getPeriod(); + if (period != null) + { + props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); + } + else + { + props.put(PROP_RS_DISPOSITION_PERIOD, null); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); + } + + List events = da.getEventCompletionDetails(); + List list = new ArrayList(events.size()); + for (EventCompletionDetails event : events) + { + list.add(event.getEventName()); + } + props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable)list); + + getNodeService().setProperties(disposableItem, props); + } + } + + /** + * Processes all the changes applied to the given disposition + * action definition node for the given record or folder node. + * + * @param dispositionActionDef The disposition action definition node + * @param changedProps The set of properties changed on the action definition + * @param recordOrFolder The record or folder the changes potentially need to be applied to + */ + private void processActionDefinitionChanges(NodeRef dispositionActionDef, List changedProps, NodeRef recordOrFolder) + { + // check that the step being edited is the current step for the folder, + // if not, the change has no effect on the current step so ignore + DispositionAction nextAction = getDispositionService().getNextDispositionAction(recordOrFolder); + if (doesChangedStepAffectNextAction(dispositionActionDef, nextAction)) + { + // the change does effect the nextAction for this node + // so go ahead and determine what needs updating + if (changedProps.contains(PROP_DISPOSITION_PERIOD)) + { + persistPeriodChanges(dispositionActionDef, nextAction); + } + + if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION)) + { + nextAction.refreshEvents(); + } + + if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME)) + { + String action = (String)getNodeService().getProperty(dispositionActionDef, PROP_DISPOSITION_ACTION_NAME); + getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_ACTION, action); + } + } + } + + /** + * Determines whether the disposition action definition (step) being + * updated has any effect on the given next action + * + * @param dispositionActionDef The disposition action definition node + * @param nextAction The next disposition action + * @return true if the step change affects the next action + */ + private boolean doesChangedStepAffectNextAction(NodeRef dispositionActionDef, + DispositionAction nextAction) + { + boolean affectsNextAction = false; + + if (dispositionActionDef != null && nextAction != null) + { + // check whether the id of the action definition node being changed + // is the same as the id of the next action + String nextActionId = nextAction.getId(); + if (dispositionActionDef.getId().equals(nextActionId)) + { + affectsNextAction = true; + } + } + + return affectsNextAction; + } + + /** + * Persists any changes made to the period on the given disposition action + * definition on the given next action. + * + * @param dispositionActionDef The disposition action definition node + * @param nextAction The next disposition action + */ + private void persistPeriodChanges(NodeRef dispositionActionDef, DispositionAction nextAction) + { + Date newAsOfDate = null; + Period dispositionPeriod = (Period) getNodeService().getProperty(dispositionActionDef, PROP_DISPOSITION_PERIOD); + + if (dispositionPeriod != null) + { + // calculate the new as of date as we have been provided a new period + Date now = new Date(); + newAsOfDate = dispositionPeriod.getNextDate(now); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Set disposition as of date for next action '" + nextAction.getName() + + "' (" + nextAction.getNodeRef() + ") to: " + newAsOfDate); + } + + getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_AS_OF, newAsOfDate); + } + + @Override + protected void addParameterDefinitions(List paramList) + { + // Intentionally empty + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java index b53e55fd4c..6f901d9287 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java @@ -1,80 +1,80 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Action to close the records folder - * - * @author Roy Wetherall - */ -public class CloseRecordFolderAction extends RMActionExecuterAbstractBase -{ - /** Parameter names */ - public static final String PARAM_CLOSE_PARENT = "closeParent"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, final NodeRef actionedUponNodeRef) - { - if (eligibleForAction(actionedUponNodeRef)) - { - // do the work of creating the record as the system user - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - getRecordFolderService().closeRecordFolder(actionedUponNodeRef); - - return null; - } - }); - } - } - - /** - * Helper method to check the actioned upon node reference to decide to execute the action - * The preconditions are: - * - The node must exist - * - The node must not be frozen - * - * @param actionedUponNodeRef node reference - * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise - */ - private boolean eligibleForAction(NodeRef actionedUponNodeRef) - { - boolean result = false; - if (getNodeService().exists(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef) && - !TYPE_UNFILED_RECORD_FOLDER.equals(getNodeService().getType(actionedUponNodeRef))) - { - result = true; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Action to close the records folder + * + * @author Roy Wetherall + */ +public class CloseRecordFolderAction extends RMActionExecuterAbstractBase +{ + /** Parameter names */ + public static final String PARAM_CLOSE_PARENT = "closeParent"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, final NodeRef actionedUponNodeRef) + { + if (eligibleForAction(actionedUponNodeRef)) + { + // do the work of creating the record as the system user + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + getRecordFolderService().closeRecordFolder(actionedUponNodeRef); + + return null; + } + }); + } + } + + /** + * Helper method to check the actioned upon node reference to decide to execute the action + * The preconditions are: + * - The node must exist + * - The node must not be frozen + * + * @param actionedUponNodeRef node reference + * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise + */ + private boolean eligibleForAction(NodeRef actionedUponNodeRef) + { + boolean result = false; + if (getNodeService().exists(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef) && + !TYPE_UNFILED_RECORD_FOLDER.equals(getNodeService().getType(actionedUponNodeRef))) + { + result = true; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java index 97c31045bd..28ccf28aed 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java @@ -1,89 +1,89 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.Date; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Complete event action - * - * @author Roy Wetherall - * @since 1.0 - */ -public class CompleteEventAction extends RMActionExecuterAbstractBase -{ - /** action name */ - public static final String NAME = "completeEvent"; - - /** action parameter names */ - public static final String PARAM_EVENT_NAME = "eventName"; - public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy"; - public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt"; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_EVENT_NAME), - false, - "rm-ac-manual-events")); - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef)) - { - /** get parameter values */ - String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); - String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY); - Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT); - - if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - // Get the next disposition action - DispositionAction da = this.getDispositionService().getNextDispositionAction(actionedUponNodeRef); - if (da != null) - { - // complete event - da.completeEvent(eventName, eventCompletedAt, eventCompletedBy); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.Date; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Complete event action + * + * @author Roy Wetherall + * @since 1.0 + */ +public class CompleteEventAction extends RMActionExecuterAbstractBase +{ + /** action name */ + public static final String NAME = "completeEvent"; + + /** action parameter names */ + public static final String PARAM_EVENT_NAME = "eventName"; + public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy"; + public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt"; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, + DataTypeDefinition.TEXT, + true, + getParamDisplayLabel(PARAM_EVENT_NAME), + false, + "rm-ac-manual-events")); + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef)) + { + /** get parameter values */ + String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); + String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY); + Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT); + + if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + // Get the next disposition action + DispositionAction da = this.getDispositionService().getNextDispositionAction(actionedUponNodeRef); + if (da != null) + { + // complete event + da.completeEvent(eventName, eventCompletedAt, eventCompletedBy); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java index e3eb0d4b86..4a4ebbaab2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java @@ -1,440 +1,440 @@ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.dao.ConcurrencyFailureException; -import org.springframework.util.StringUtils; - -/** - * File To action implementation. - * - * @author Mark Hibbins - * @since 2.2 - */ -public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstractBase -{ - private static Log logger = LogFactory.getLog(CopyMoveLinkFileToBaseAction.class); - - /** Retrying transaction helper */ - private RetryingTransactionHelper retryingTransactionHelper; - - /** action parameters */ - public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder"; - public static final String PARAM_PATH = "path"; - public static final String PARAM_CREATE_RECORD_PATH = "createRecordPath"; - public static final String ACTION_FILETO = "fileTo"; - public static final String ACTION_LINKTO = "linkTo"; - - /** file folder service */ - private FileFolderService fileFolderService; - - /** file plan service */ - private FilePlanService filePlanService; - - /** action modes */ - public enum CopyMoveLinkFileToActionMode - { - COPY, MOVE, LINK - }; - - /** Action Mode */ - private CopyMoveLinkFileToActionMode mode; - - /** - * @return Action Mode - */ - protected CopyMoveLinkFileToActionMode getMode() - { - return this.mode; - } - - /** - * Sets the action mode - * - * @param mode Action mode - */ - protected void setMode(CopyMoveLinkFileToActionMode mode) - { - this.mode = mode; - } - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param retryingTransactionHelper retrying transaction helper - */ - public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_PATH, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_PATH))); - paramList.add(new ParameterDefinitionImpl(PARAM_CREATE_RECORD_PATH, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_CREATE_RECORD_PATH))); - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) - { - String actionName = action.getActionDefinitionName(); - if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) - { - QName actionedUponType = getNodeService().getType(actionedUponNodeRef); - - boolean targetIsUnfiledRecords; - if (ACTION_FILETO.equals(action.getActionDefinitionName())) - { - targetIsUnfiledRecords = false; - } - else - { - targetIsUnfiledRecords = (getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT) && !getRecordService().isFiled(actionedUponNodeRef)) - || TYPE_UNFILED_RECORD_FOLDER.equals(actionedUponType); - } - - // first look to see if the destination record folder has been specified - NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER); - if (recordFolder == null) - { - final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords; - recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - NodeRef result = null; - try - { - // get the reference to the record folder based on the relative path - result = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); - } - catch (DuplicateChildNodeNameException ex) - { - throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); - } - - return result; - } - }, false, true); - } - - // now we have the reference to the target folder we can do some final checks to see if the action is valid - validateActionPostPathResolution(actionedUponNodeRef, recordFolder, actionName, targetIsUnfiledRecords); - - final NodeRef finalRecordFolder = recordFolder; - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - try - { - synchronized (this) - { - if (getMode() == CopyMoveLinkFileToActionMode.MOVE) - { - fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null); - } - else if (getMode() == CopyMoveLinkFileToActionMode.COPY) - { - fileFolderService.copy(actionedUponNodeRef, finalRecordFolder, null); - } - else if (getMode() == CopyMoveLinkFileToActionMode.LINK) - { - getRecordService().link(actionedUponNodeRef, finalRecordFolder); - } - } - } - catch (FileNotFoundException fileNotFound) - { - throw new AlfrescoRuntimeException("Unable to execute file to action, because the " + (mode == CopyMoveLinkFileToActionMode.MOVE ? "move" : "copy") + " operation failed.", fileNotFound); - } - - return null; - } - - }); - } - } - - /** - * Return true if the passed parameters to the action are valid for the given action - * - * @param actionedUponNodeRef - * @param actionName - * @return - */ - private boolean isOkToProceedWithAction(NodeRef actionedUponNodeRef, String actionName) - { - // Check that the incoming parameters are valid prior to performing any action - boolean okToProceed = false; - if(getNodeService().exists(actionedUponNodeRef) && !getFreezeService().isFrozen(actionedUponNodeRef)) - { - QName actionedUponType = getNodeService().getType(actionedUponNodeRef); - if(ACTION_FILETO.equals(actionName)) - { - // file to action can only be performed on unfiled records - okToProceed = !getRecordService().isFiled(actionedUponNodeRef) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT); - if(!okToProceed && logger.isDebugEnabled()) - { - logger.debug("Unable to run " + actionName + " action on a node that isn't unfiled and a sub-class of content type"); - } - } - else if(ACTION_LINKTO.equals(actionName)) - { - // link to action can only be performed on filed records - okToProceed = getRecordService().isFiled(actionedUponNodeRef) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT); - if(!okToProceed && logger.isDebugEnabled()) - { - logger.debug("Unable to run " + actionName + " action on a node that isn't filed and a sub-class of content type"); - } - } - else - { - okToProceed = true; - } - } - return okToProceed; - } - - /** - * Do a final validation for the parameters and the resolve target path - * - * @param actionedUponNodeRef - * @param target - * @param actionName - * @param targetIsUnfiledRecords - */ - private void validateActionPostPathResolution(NodeRef actionedUponNodeRef, NodeRef target, String actionName, boolean targetIsUnfiledRecords) - { - QName actionedUponType = getNodeService().getType(actionedUponNodeRef); - // now we have the reference to the target folder we can do some final checks to see if the action is valid - if (target == null) - { - throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder could not be determined."); - } - if(targetIsUnfiledRecords) - { - QName targetFolderType = getNodeService().getType(target); - if(!TYPE_UNFILED_RECORD_CONTAINER.equals(targetFolderType) && !TYPE_UNFILED_RECORD_FOLDER.equals(targetFolderType)) - { - throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type."); - } - } - else - { - if(getRecordFolderService().isRecordFolder(target) && !getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT) && (getRecordFolderService().isRecordFolder(actionedUponNodeRef) || filePlanService.isRecordCategory(actionedUponNodeRef))) - { - throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type. A record folder cannot contain another folder or a category"); - } - else if(filePlanService.isRecordCategory(target) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT)) - { - throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type. A record category cannot contain a record"); - } - } - } - - /** - * Create or resolve the path specified in the action's path parameter - * - * @param action - * @param actionedUponNodeRef - * @param targetisUnfiledRecords true is the target is in unfiled records - * @return - */ - private NodeRef createOrResolvePath(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) - { - // get the starting context - NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); - NodeRef path = context; - - // get the path we wish to resolve - String pathParameter = (String)action.getParameterValue(PARAM_PATH); - String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); - if((pathElementsArray != null) && (pathElementsArray.length > 0)) - { - // get the create parameter - Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_PATH); - boolean create = createValue == null ? false : createValue.booleanValue(); - - // create or resolve the specified path - path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, create, false); - } - return path; - } - - /** - * Create or resolve the specified path - * - * @param action Action to use for reporting if anything goes wrong - * @param parent Parent of path to be created - * @param actionedUponNodeRef The node subject to the file/move/copy action - * @param pathElements The elements of the path to be created - * @param targetisUnfiledRecords true if the target is within unfiled records - * @param create true if the path should be creeated if it does not exist - * @param creating true if we have already created the parent and therefore can skip the check to see if the next path element already exists - * @return - */ - private NodeRef createOrResolvePath(Action action, NodeRef parent, NodeRef actionedUponNodeRef, List pathElements, boolean targetisUnfiledRecords, boolean create, boolean creating) - { - NodeRef nodeRef = null; - String childName = pathElements.get(0); - boolean lastPathElement = pathElements.size() == 1; - if(!creating) - { - nodeRef = getChild(parent, childName); - } - if(nodeRef == null) - { - if(create) - { - creating = true; - boolean lastAsFolder = lastPathElement && (getDictionaryService().isSubClass(getNodeService().getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) || RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT.equals(getNodeService().getType(actionedUponNodeRef))); - nodeRef = createChild(action, parent, childName, targetisUnfiledRecords, lastAsFolder); - } - else - { - throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path could not be determined."); - } - } - else - { - QName nodeType = getNodeService().getType(nodeRef); - if(nodeType.equals(RecordsManagementModel.TYPE_HOLD_CONTAINER) || - nodeType.equals(RecordsManagementModel.TYPE_TRANSFER_CONTAINER) || - nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER)) - { - throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path in invalid."); - } - } - if(pathElements.size() > 1) - { - nodeRef = createOrResolvePath(action, nodeRef, actionedUponNodeRef, pathElements.subList(1, pathElements.size()), targetisUnfiledRecords, create, creating); - } - return nodeRef; - } - - /** - * Get the specified child node ref of the specified parent if it exists, otherwise return null - * - * @param parent - * @param childName - * @return - */ - private NodeRef getChild(NodeRef parent, String childName) - { - return getNodeService().getChildByName(parent, ContentModel.ASSOC_CONTAINS, childName); - } - - /** - * Create the specified child of the specified parent - * - * @param action Action to use for reporting if anything goes wrong - * @param parent Parent of the child to be created - * @param childName The name of the child to be created - * @param targetisUnfiledRecords true if the child is being created in the unfiled directory (determines type as unfiled container child) - * @param lastAsFolder true if this is the last element of the pathe being created and it should be created as a folder. ignored if targetIsUnfiledRecords is true - * @return - */ - private NodeRef createChild(final Action action, final NodeRef parent, final String childName, final boolean targetisUnfiledRecords, final boolean lastAsFolder) - { - return AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() - { - // double check that the child hasn't been created by another thread - NodeRef child = getChild(parent, childName); - if (child == null) - { - if(targetisUnfiledRecords) - { - // create unfiled folder - child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); - } - else if(lastAsFolder) - { - // create record folder - child = getRecordFolderService().createRecordFolder(parent, childName); - } - else - { - // ensure we are not trying to create a record categtory in a record folder - if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(getNodeService().getType(parent))) - { - throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path has a record category within a record folder."); - } - - // create record category - child = filePlanService.createRecordCategory(parent, childName); - } - } - return child; - } - }); - } - - /** - * Return the context. This will be the unfiled records container of the context if targetisUnfiledRecords is true - * - * @param action - * @param actionedUponNodeRef - * @param targetisUnfiledRecords - * @return - */ - private NodeRef getContext(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) - { - NodeRef context = filePlanService.getFilePlan(actionedUponNodeRef); - if(targetisUnfiledRecords && (context != null) && getNodeService().exists(context)) - { - context = filePlanService.getUnfiledContainer(context); - } - if((context == null) || (!getNodeService().exists(context))) - { - throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the path resolution context could not be determined."); - } - return context; - } - -} +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.Arrays; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.model.FileNotFoundException; +import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.dao.ConcurrencyFailureException; +import org.springframework.util.StringUtils; + +/** + * File To action implementation. + * + * @author Mark Hibbins + * @since 2.2 + */ +public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstractBase +{ + private static Log logger = LogFactory.getLog(CopyMoveLinkFileToBaseAction.class); + + /** Retrying transaction helper */ + private RetryingTransactionHelper retryingTransactionHelper; + + /** action parameters */ + public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder"; + public static final String PARAM_PATH = "path"; + public static final String PARAM_CREATE_RECORD_PATH = "createRecordPath"; + public static final String ACTION_FILETO = "fileTo"; + public static final String ACTION_LINKTO = "linkTo"; + + /** file folder service */ + private FileFolderService fileFolderService; + + /** file plan service */ + private FilePlanService filePlanService; + + /** action modes */ + public enum CopyMoveLinkFileToActionMode + { + COPY, MOVE, LINK + }; + + /** Action Mode */ + private CopyMoveLinkFileToActionMode mode; + + /** + * @return Action Mode + */ + protected CopyMoveLinkFileToActionMode getMode() + { + return this.mode; + } + + /** + * Sets the action mode + * + * @param mode Action mode + */ + protected void setMode(CopyMoveLinkFileToActionMode mode) + { + this.mode = mode; + } + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param retryingTransactionHelper retrying transaction helper + */ + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_PATH, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_PATH))); + paramList.add(new ParameterDefinitionImpl(PARAM_CREATE_RECORD_PATH, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_CREATE_RECORD_PATH))); + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + { + String actionName = action.getActionDefinitionName(); + if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) + { + QName actionedUponType = getNodeService().getType(actionedUponNodeRef); + + boolean targetIsUnfiledRecords; + if (ACTION_FILETO.equals(action.getActionDefinitionName())) + { + targetIsUnfiledRecords = false; + } + else + { + targetIsUnfiledRecords = (getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT) && !getRecordService().isFiled(actionedUponNodeRef)) + || TYPE_UNFILED_RECORD_FOLDER.equals(actionedUponType); + } + + // first look to see if the destination record folder has been specified + NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER); + if (recordFolder == null) + { + final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords; + recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef result = null; + try + { + // get the reference to the record folder based on the relative path + result = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); + } + catch (DuplicateChildNodeNameException ex) + { + throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); + } + + return result; + } + }, false, true); + } + + // now we have the reference to the target folder we can do some final checks to see if the action is valid + validateActionPostPathResolution(actionedUponNodeRef, recordFolder, actionName, targetIsUnfiledRecords); + + final NodeRef finalRecordFolder = recordFolder; + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + try + { + synchronized (this) + { + if (getMode() == CopyMoveLinkFileToActionMode.MOVE) + { + fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null); + } + else if (getMode() == CopyMoveLinkFileToActionMode.COPY) + { + fileFolderService.copy(actionedUponNodeRef, finalRecordFolder, null); + } + else if (getMode() == CopyMoveLinkFileToActionMode.LINK) + { + getRecordService().link(actionedUponNodeRef, finalRecordFolder); + } + } + } + catch (FileNotFoundException fileNotFound) + { + throw new AlfrescoRuntimeException("Unable to execute file to action, because the " + (mode == CopyMoveLinkFileToActionMode.MOVE ? "move" : "copy") + " operation failed.", fileNotFound); + } + + return null; + } + + }); + } + } + + /** + * Return true if the passed parameters to the action are valid for the given action + * + * @param actionedUponNodeRef + * @param actionName + * @return + */ + private boolean isOkToProceedWithAction(NodeRef actionedUponNodeRef, String actionName) + { + // Check that the incoming parameters are valid prior to performing any action + boolean okToProceed = false; + if(getNodeService().exists(actionedUponNodeRef) && !getFreezeService().isFrozen(actionedUponNodeRef)) + { + QName actionedUponType = getNodeService().getType(actionedUponNodeRef); + if(ACTION_FILETO.equals(actionName)) + { + // file to action can only be performed on unfiled records + okToProceed = !getRecordService().isFiled(actionedUponNodeRef) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT); + if(!okToProceed && logger.isDebugEnabled()) + { + logger.debug("Unable to run " + actionName + " action on a node that isn't unfiled and a sub-class of content type"); + } + } + else if(ACTION_LINKTO.equals(actionName)) + { + // link to action can only be performed on filed records + okToProceed = getRecordService().isFiled(actionedUponNodeRef) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT); + if(!okToProceed && logger.isDebugEnabled()) + { + logger.debug("Unable to run " + actionName + " action on a node that isn't filed and a sub-class of content type"); + } + } + else + { + okToProceed = true; + } + } + return okToProceed; + } + + /** + * Do a final validation for the parameters and the resolve target path + * + * @param actionedUponNodeRef + * @param target + * @param actionName + * @param targetIsUnfiledRecords + */ + private void validateActionPostPathResolution(NodeRef actionedUponNodeRef, NodeRef target, String actionName, boolean targetIsUnfiledRecords) + { + QName actionedUponType = getNodeService().getType(actionedUponNodeRef); + // now we have the reference to the target folder we can do some final checks to see if the action is valid + if (target == null) + { + throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder could not be determined."); + } + if(targetIsUnfiledRecords) + { + QName targetFolderType = getNodeService().getType(target); + if(!TYPE_UNFILED_RECORD_CONTAINER.equals(targetFolderType) && !TYPE_UNFILED_RECORD_FOLDER.equals(targetFolderType)) + { + throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type."); + } + } + else + { + if(getRecordFolderService().isRecordFolder(target) && !getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT) && (getRecordFolderService().isRecordFolder(actionedUponNodeRef) || filePlanService.isRecordCategory(actionedUponNodeRef))) + { + throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type. A record folder cannot contain another folder or a category"); + } + else if(filePlanService.isRecordCategory(target) && getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT)) + { + throw new AlfrescoRuntimeException("Unable to run " + actionName + " action, because the destination record folder is an inappropriate type. A record category cannot contain a record"); + } + } + } + + /** + * Create or resolve the path specified in the action's path parameter + * + * @param action + * @param actionedUponNodeRef + * @param targetisUnfiledRecords true is the target is in unfiled records + * @return + */ + private NodeRef createOrResolvePath(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) + { + // get the starting context + NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); + NodeRef path = context; + + // get the path we wish to resolve + String pathParameter = (String)action.getParameterValue(PARAM_PATH); + String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); + if((pathElementsArray != null) && (pathElementsArray.length > 0)) + { + // get the create parameter + Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_PATH); + boolean create = createValue == null ? false : createValue.booleanValue(); + + // create or resolve the specified path + path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, create, false); + } + return path; + } + + /** + * Create or resolve the specified path + * + * @param action Action to use for reporting if anything goes wrong + * @param parent Parent of path to be created + * @param actionedUponNodeRef The node subject to the file/move/copy action + * @param pathElements The elements of the path to be created + * @param targetisUnfiledRecords true if the target is within unfiled records + * @param create true if the path should be creeated if it does not exist + * @param creating true if we have already created the parent and therefore can skip the check to see if the next path element already exists + * @return + */ + private NodeRef createOrResolvePath(Action action, NodeRef parent, NodeRef actionedUponNodeRef, List pathElements, boolean targetisUnfiledRecords, boolean create, boolean creating) + { + NodeRef nodeRef = null; + String childName = pathElements.get(0); + boolean lastPathElement = pathElements.size() == 1; + if(!creating) + { + nodeRef = getChild(parent, childName); + } + if(nodeRef == null) + { + if(create) + { + creating = true; + boolean lastAsFolder = lastPathElement && (getDictionaryService().isSubClass(getNodeService().getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) || RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT.equals(getNodeService().getType(actionedUponNodeRef))); + nodeRef = createChild(action, parent, childName, targetisUnfiledRecords, lastAsFolder); + } + else + { + throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path could not be determined."); + } + } + else + { + QName nodeType = getNodeService().getType(nodeRef); + if(nodeType.equals(RecordsManagementModel.TYPE_HOLD_CONTAINER) || + nodeType.equals(RecordsManagementModel.TYPE_TRANSFER_CONTAINER) || + nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER)) + { + throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path in invalid."); + } + } + if(pathElements.size() > 1) + { + nodeRef = createOrResolvePath(action, nodeRef, actionedUponNodeRef, pathElements.subList(1, pathElements.size()), targetisUnfiledRecords, create, creating); + } + return nodeRef; + } + + /** + * Get the specified child node ref of the specified parent if it exists, otherwise return null + * + * @param parent + * @param childName + * @return + */ + private NodeRef getChild(NodeRef parent, String childName) + { + return getNodeService().getChildByName(parent, ContentModel.ASSOC_CONTAINS, childName); + } + + /** + * Create the specified child of the specified parent + * + * @param action Action to use for reporting if anything goes wrong + * @param parent Parent of the child to be created + * @param childName The name of the child to be created + * @param targetisUnfiledRecords true if the child is being created in the unfiled directory (determines type as unfiled container child) + * @param lastAsFolder true if this is the last element of the pathe being created and it should be created as a folder. ignored if targetIsUnfiledRecords is true + * @return + */ + private NodeRef createChild(final Action action, final NodeRef parent, final String childName, final boolean targetisUnfiledRecords, final boolean lastAsFolder) + { + return AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public NodeRef doWork() + { + // double check that the child hasn't been created by another thread + NodeRef child = getChild(parent, childName); + if (child == null) + { + if(targetisUnfiledRecords) + { + // create unfiled folder + child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); + } + else if(lastAsFolder) + { + // create record folder + child = getRecordFolderService().createRecordFolder(parent, childName); + } + else + { + // ensure we are not trying to create a record categtory in a record folder + if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(getNodeService().getType(parent))) + { + throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path has a record category within a record folder."); + } + + // create record category + child = filePlanService.createRecordCategory(parent, childName); + } + } + return child; + } + }); + } + + /** + * Return the context. This will be the unfiled records container of the context if targetisUnfiledRecords is true + * + * @param action + * @param actionedUponNodeRef + * @param targetisUnfiledRecords + * @return + */ + private NodeRef getContext(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) + { + NodeRef context = filePlanService.getFilePlan(actionedUponNodeRef); + if(targetisUnfiledRecords && (context != null) && getNodeService().exists(context)) + { + context = filePlanService.getUnfiledContainer(context); + } + if((context == null) || (!getNodeService().exists(context))) + { + throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the path resolution context could not be determined."); + } + return context; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyToAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyToAction.java index cb2686cd12..28fe17e1b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyToAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyToAction.java @@ -1,20 +1,20 @@ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -/** - * File To action implementation. - * - * @author Mark Hibbins - * @since 2.2 - */ -public class CopyToAction extends CopyMoveLinkFileToBaseAction -{ - /** action name */ - public static final String NAME = "copyTo"; - - @Override - public void init() - { - super.init(); - setMode(CopyMoveLinkFileToActionMode.COPY); - } +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +/** + * File To action implementation. + * + * @author Mark Hibbins + * @since 2.2 + */ +public class CopyToAction extends CopyMoveLinkFileToBaseAction +{ + /** action name */ + public static final String NAME = "copyTo"; + + @Override + public void init() + { + super.init(); + setMode(CopyMoveLinkFileToActionMode.COPY); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java index f04f0c77ff..f96c6911ff 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java @@ -1,85 +1,85 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Create disposition schedule action - * - * @author Roy Wetherall - */ -public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_NODE_NOT_RECORD_CATEGORY = "rm.action.node-not-record-category"; - - /** file plan service */ - private FilePlanService filePlanService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (eligibleForAction(actionedUponNodeRef)) - { - // Create the disposition schedule - getDispositionService().createDispositionSchedule(actionedUponNodeRef, null); - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_RECORD_CATEGORY, actionedUponNodeRef)); - } - } - - /** - * Helper method to check the actioned upon node reference to decide to execute the action - * The preconditions are: - * - The node must exist - * - The node must not be a record category - * - * @param actionedUponNodeRef node reference - * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise - */ - private boolean eligibleForAction(NodeRef actionedUponNodeRef) - { - boolean result = false; - if (getNodeService().exists(actionedUponNodeRef) && - filePlanService.isRecordCategory(actionedUponNodeRef)) - { - result = true; - } - return result; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Create disposition schedule action + * + * @author Roy Wetherall + */ +public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_NODE_NOT_RECORD_CATEGORY = "rm.action.node-not-record-category"; + + /** file plan service */ + private FilePlanService filePlanService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (eligibleForAction(actionedUponNodeRef)) + { + // Create the disposition schedule + getDispositionService().createDispositionSchedule(actionedUponNodeRef, null); + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_RECORD_CATEGORY, actionedUponNodeRef)); + } + } + + /** + * Helper method to check the actioned upon node reference to decide to execute the action + * The preconditions are: + * - The node must exist + * - The node must not be a record category + * + * @param actionedUponNodeRef node reference + * @return Return true if the node reference passes all the preconditions for executing the action, false otherwise + */ + private boolean eligibleForAction(NodeRef actionedUponNodeRef) + { + boolean result = false; + if (getNodeService().exists(actionedUponNodeRef) && + filePlanService.isRecordCategory(actionedUponNodeRef)) + { + result = true; + } + return result; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java index 09b35c9b71..30f44adec1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java @@ -1,89 +1,89 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Cut off disposition action - * - * @author Roy Wetherall - */ -public class CutOffAction extends RMDispositionActionExecuterAbstractBase -{ - /** Action name */ - public static final String NAME = "cutoff"; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) - { - if(checkUncutOffStatus(action, recordFolder)) - { - // Mark the folder as cut off - getDispositionService().cutoffDisposableItem(recordFolder); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordLevelDisposition(Action action, NodeRef record) - { - if(checkUncutOffStatus(action, record)) - { - // Mark the record as cut off - getDispositionService().cutoffDisposableItem(record); - } - } - - /** - * Check if the record or folder has been uncut off. If it has and this cut off action is an - * automated disposition action then the cut off isn't run. If it has and this is a manual - * cut off action then the uncut off aspect is removed prior to the uncut action. - * - * @param action The cut off action - * @param recordOrFolder The record or folder to be cut off - * @return True if the record or folder can be cut off - */ - private boolean checkUncutOffStatus(Action action, NodeRef recordOrFolder) - { - boolean okToCutOff = true; - if(getNodeService().hasAspect(recordOrFolder, ASPECT_UNCUT_OFF)) - { - if(action.getParameterValue(PARAM_NO_ERROR_CHECK) != null) - { - // this exception stops the cut off disposition schedule action taking place and because we're - // running from the schedule (PARAM_NO_ERROR_CHECK is set) then the exception will not be reported - throw new AlfrescoRuntimeException("Cannot cut off from schedule when uncut off aspect is present"); - } - else - { - getNodeService().removeAspect(recordOrFolder, ASPECT_UNCUT_OFF); - } - } - return okToCutOff; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Cut off disposition action + * + * @author Roy Wetherall + */ +public class CutOffAction extends RMDispositionActionExecuterAbstractBase +{ + /** Action name */ + public static final String NAME = "cutoff"; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) + { + if(checkUncutOffStatus(action, recordFolder)) + { + // Mark the folder as cut off + getDispositionService().cutoffDisposableItem(recordFolder); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordLevelDisposition(Action action, NodeRef record) + { + if(checkUncutOffStatus(action, record)) + { + // Mark the record as cut off + getDispositionService().cutoffDisposableItem(record); + } + } + + /** + * Check if the record or folder has been uncut off. If it has and this cut off action is an + * automated disposition action then the cut off isn't run. If it has and this is a manual + * cut off action then the uncut off aspect is removed prior to the uncut action. + * + * @param action The cut off action + * @param recordOrFolder The record or folder to be cut off + * @return True if the record or folder can be cut off + */ + private boolean checkUncutOffStatus(Action action, NodeRef recordOrFolder) + { + boolean okToCutOff = true; + if(getNodeService().hasAspect(recordOrFolder, ASPECT_UNCUT_OFF)) + { + if(action.getParameterValue(PARAM_NO_ERROR_CHECK) != null) + { + // this exception stops the cut off disposition schedule action taking place and because we're + // running from the schedule (PARAM_NO_ERROR_CHECK is set) then the exception will not be reported + throw new AlfrescoRuntimeException("Cannot cut off from schedule when uncut off aspect is present"); + } + else + { + getNodeService().removeAspect(recordOrFolder, ASPECT_UNCUT_OFF); + } + } + return okToCutOff; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java index 8ea77081c9..dd62a3f729 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java @@ -1,206 +1,206 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Declare record action - * - * @author Roy Wetherall - */ -public class DeclareRecordAction extends RMActionExecuterAbstractBase -{ - /** action name */ - public static final String NAME = "declareRecord"; - - /** I18N */ - private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records"; - private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop"; - - /** Logger */ - private static Log logger = LogFactory.getLog(DeclareRecordAction.class); - - /** check mandatory properties */ - private boolean checkMandatoryPropertiesEnabled = true; - - /** - * @param checkMandatoryPropertiesEnabled true if check mandatory properties is enabled, false otherwise - */ - public void setCheckMandatoryPropertiesEnabled(boolean checkMandatoryPropertiesEnabled) - { - this.checkMandatoryPropertiesEnabled = checkMandatoryPropertiesEnabled; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - getRecordService().isRecord(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef)) - { - if (!getRecordService().isDeclared(actionedUponNodeRef)) - { - List missingProperties = new ArrayList(5); - // Aspect not already defined - check mandatory properties then add - if (!checkMandatoryPropertiesEnabled || - mandatoryPropertiesSet(actionedUponNodeRef, missingProperties)) - { - getRecordService().disablePropertyEditableCheck(); - try - { - // Add the declared aspect - Map declaredProps = new HashMap(2); - declaredProps.put(PROP_DECLARED_AT, new Date()); - declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser()); - this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps); - - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // remove all owner related rights - getOwnableService().setOwner(actionedUponNodeRef, OwnableService.NO_OWNER); - return null; - } - }); - } - finally - { - getRecordService().enablePropertyEditableCheck(); - } - } - else - { - logger.debug(buildMissingPropertiesErrorString(missingProperties)); - action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, "missingProperties"); - } - } - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, actionedUponNodeRef.toString())); - } - } - } - - private String buildMissingPropertiesErrorString(List missingProperties) - { - StringBuilder builder = new StringBuilder(255); - builder.append(I18NUtil.getMessage(MSG_NO_DECLARE_MAND_PROP)); - builder.append(" "); - for (String missingProperty : missingProperties) - { - builder.append(missingProperty).append(", "); - } - return builder.toString(); - } - - /** - * Helper method to check whether all the mandatory properties of the node have been set - * - * @param nodeRef node reference - * @return boolean true if all mandatory properties are set, false otherwise - */ - private boolean mandatoryPropertiesSet(NodeRef nodeRef, List missingProperties) - { - boolean result = true; - - Map nodeRefProps = this.getNodeService().getProperties(nodeRef); - - QName nodeRefType = this.getNodeService().getType(nodeRef); - - TypeDefinition typeDef = this.getDictionaryService().getType(nodeRefType); - for (PropertyDefinition propDef : typeDef.getProperties().values()) - { - if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null) - { - logMissingProperty(propDef, missingProperties); - - result = false; - break; - } - } - - if (result) - { - Set aspects = this.getNodeService().getAspects(nodeRef); - for (QName aspect : aspects) - { - AspectDefinition aspectDef = this.getDictionaryService().getAspect(aspect); - for (PropertyDefinition propDef : aspectDef.getProperties().values()) - { - if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null) - { - logMissingProperty(propDef, missingProperties); - - result = false; - break; - } - } - } - } - - return result; - } - - /** - * Log information about missing properties. - * - * @param propDef property definition - * @param missingProperties missing properties - */ - private void logMissingProperty(PropertyDefinition propDef, List missingProperties) - { - if (logger.isWarnEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Mandatory property missing: ").append(propDef.getName()); - logger.warn(msg.toString()); - } - missingProperties.add(propDef.getName().toString()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Declare record action + * + * @author Roy Wetherall + */ +public class DeclareRecordAction extends RMActionExecuterAbstractBase +{ + /** action name */ + public static final String NAME = "declareRecord"; + + /** I18N */ + private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records"; + private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop"; + + /** Logger */ + private static Log logger = LogFactory.getLog(DeclareRecordAction.class); + + /** check mandatory properties */ + private boolean checkMandatoryPropertiesEnabled = true; + + /** + * @param checkMandatoryPropertiesEnabled true if check mandatory properties is enabled, false otherwise + */ + public void setCheckMandatoryPropertiesEnabled(boolean checkMandatoryPropertiesEnabled) + { + this.checkMandatoryPropertiesEnabled = checkMandatoryPropertiesEnabled; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + getRecordService().isRecord(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef)) + { + if (!getRecordService().isDeclared(actionedUponNodeRef)) + { + List missingProperties = new ArrayList(5); + // Aspect not already defined - check mandatory properties then add + if (!checkMandatoryPropertiesEnabled || + mandatoryPropertiesSet(actionedUponNodeRef, missingProperties)) + { + getRecordService().disablePropertyEditableCheck(); + try + { + // Add the declared aspect + Map declaredProps = new HashMap(2); + declaredProps.put(PROP_DECLARED_AT, new Date()); + declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser()); + this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps); + + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // remove all owner related rights + getOwnableService().setOwner(actionedUponNodeRef, OwnableService.NO_OWNER); + return null; + } + }); + } + finally + { + getRecordService().enablePropertyEditableCheck(); + } + } + else + { + logger.debug(buildMissingPropertiesErrorString(missingProperties)); + action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, "missingProperties"); + } + } + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, actionedUponNodeRef.toString())); + } + } + } + + private String buildMissingPropertiesErrorString(List missingProperties) + { + StringBuilder builder = new StringBuilder(255); + builder.append(I18NUtil.getMessage(MSG_NO_DECLARE_MAND_PROP)); + builder.append(" "); + for (String missingProperty : missingProperties) + { + builder.append(missingProperty).append(", "); + } + return builder.toString(); + } + + /** + * Helper method to check whether all the mandatory properties of the node have been set + * + * @param nodeRef node reference + * @return boolean true if all mandatory properties are set, false otherwise + */ + private boolean mandatoryPropertiesSet(NodeRef nodeRef, List missingProperties) + { + boolean result = true; + + Map nodeRefProps = this.getNodeService().getProperties(nodeRef); + + QName nodeRefType = this.getNodeService().getType(nodeRef); + + TypeDefinition typeDef = this.getDictionaryService().getType(nodeRefType); + for (PropertyDefinition propDef : typeDef.getProperties().values()) + { + if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null) + { + logMissingProperty(propDef, missingProperties); + + result = false; + break; + } + } + + if (result) + { + Set aspects = this.getNodeService().getAspects(nodeRef); + for (QName aspect : aspects) + { + AspectDefinition aspectDef = this.getDictionaryService().getAspect(aspect); + for (PropertyDefinition propDef : aspectDef.getProperties().values()) + { + if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null) + { + logMissingProperty(propDef, missingProperties); + + result = false; + break; + } + } + } + } + + return result; + } + + /** + * Log information about missing properties. + * + * @param propDef property definition + * @param missingProperties missing properties + */ + private void logMissingProperty(PropertyDefinition propDef, List missingProperties) + { + if (logger.isWarnEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Mandatory property missing: ").append(propDef.getName()); + logger.warn(msg.toString()); + } + missingProperties.add(propDef.getName().toString()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DelegateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DelegateAction.java index efa55760e1..bce7d9e924 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DelegateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DelegateAction.java @@ -1,88 +1,88 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.executer.ActionExecuter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Records management action who's implementation is delegated to an existing Action. - *

- * Useful for creating a RM version of an existing action implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class DelegateAction extends RMActionExecuterAbstractBase -{ - /** Delegate action executer*/ - private ActionExecuter delegateActionExecuter; - - /** should we check whether the node is frozen */ - private boolean checkFrozen = false; - - /** - * @param delegateActionExecuter delegate action executer - */ - public void setDelegateAction(ActionExecuter delegateActionExecuter) - { - this.delegateActionExecuter = delegateActionExecuter; - } - - /** - * @param checkFrozen true if we check whether the actioned upon node reference is frozen, false otherwise - */ - public void setCheckFrozen(boolean checkFrozen) - { - this.checkFrozen = checkFrozen; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - (!checkFrozen || !getFreezeService().isFrozen(actionedUponNodeRef))) - { - // do the property subs (if any exist) - if (isAllowParameterSubstitutions()) - { - getParameterProcessorComponent().process(action, delegateActionExecuter.getActionDefinition(), actionedUponNodeRef); - } - - delegateActionExecuter.execute(action, actionedUponNodeRef); - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions() - */ - @Override - protected List getParameterDefintions() - { - return delegateActionExecuter.getActionDefinition().getParameterDefinitions(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.executer.ActionExecuter; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Records management action who's implementation is delegated to an existing Action. + *

+ * Useful for creating a RM version of an existing action implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class DelegateAction extends RMActionExecuterAbstractBase +{ + /** Delegate action executer*/ + private ActionExecuter delegateActionExecuter; + + /** should we check whether the node is frozen */ + private boolean checkFrozen = false; + + /** + * @param delegateActionExecuter delegate action executer + */ + public void setDelegateAction(ActionExecuter delegateActionExecuter) + { + this.delegateActionExecuter = delegateActionExecuter; + } + + /** + * @param checkFrozen true if we check whether the actioned upon node reference is frozen, false otherwise + */ + public void setCheckFrozen(boolean checkFrozen) + { + this.checkFrozen = checkFrozen; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + (!checkFrozen || !getFreezeService().isFrozen(actionedUponNodeRef))) + { + // do the property subs (if any exist) + if (isAllowParameterSubstitutions()) + { + getParameterProcessorComponent().process(action, delegateActionExecuter.getActionDefinition(), actionedUponNodeRef); + } + + delegateActionExecuter.execute(action, actionedUponNodeRef); + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions() + */ + @Override + protected List getParameterDefintions() + { + return delegateActionExecuter.getActionDefinition().getParameterDefinitions(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeleteHoldAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeleteHoldAction.java index d06c792991..5764b4344c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeleteHoldAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeleteHoldAction.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Delete Hold Action - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class DeleteHoldAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_DELETE_NOT_HOLD_TYPE = "rm.action.delete-not-hold-type"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getHoldService().isHold(actionedUponNodeRef)) - { - getHoldService().deleteHold(actionedUponNodeRef); - } - else - { - throw new AlfrescoRuntimeException(MSG_DELETE_NOT_HOLD_TYPE, new Object[]{ TYPE_HOLD.toString(), actionedUponNodeRef.toString() }); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Delete Hold Action + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class DeleteHoldAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_DELETE_NOT_HOLD_TYPE = "rm.action.delete-not-hold-type"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getHoldService().isHold(actionedUponNodeRef)) + { + getHoldService().deleteHold(actionedUponNodeRef); + } + else + { + throw new AlfrescoRuntimeException(MSG_DELETE_NOT_HOLD_TYPE, new Object[]{ TYPE_HOLD.toString(), actionedUponNodeRef.toString() }); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java index d16dd76c78..9c91f3586b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java @@ -1,284 +1,284 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; - -/** - * Destroy action. - * - * @author Roy Wetherall - */ -public class DestroyAction extends RMDispositionActionExecuterAbstractBase -{ - /** Action name */ - public static final String NAME = "destroy"; - - /** Eager content store cleaner */ - private EagerContentStoreCleaner eagerContentStoreCleaner; - - /** Capability service */ - private CapabilityService capabilityService; - - /** Recordable version service */ - private RecordableVersionService recordableVersionService; - - /** Indicates if ghosting is enabled or not */ - private boolean ghostingEnabled = true; - - /** - * @param eagerContentStoreCleaner eager content store cleaner - */ - public void setEagerContentStoreCleaner(EagerContentStoreCleaner eagerContentStoreCleaner) - { - this.eagerContentStoreCleaner = eagerContentStoreCleaner; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param recordableVersionService recordable version service - */ - public void setRecordableVersionService(RecordableVersionService recordableVersionService) - { - this.recordableVersionService = recordableVersionService; - } - - /** - * @param ghostingEnabled true if ghosting is enabled, false otherwise - */ - public void setGhostingEnabled(boolean ghostingEnabled) - { - this.ghostingEnabled = ghostingEnabled; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkNextDispositionAction() - */ - @Override - protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef) - { - return checkForDestroyRecordsCapability(actionedUponNodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkEligibility(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean checkEligibility(NodeRef actionedUponNodeRef) - { - return checkForDestroyRecordsCapability(actionedUponNodeRef); - } - - /** - * - * @param actionedUponNodeRef - * @return - */ - private boolean checkForDestroyRecordsCapability(NodeRef actionedUponNodeRef) - { - boolean result = true; - if (AccessStatus.ALLOWED.equals(capabilityService.getCapability("DestroyRecords").hasPermission(actionedUponNodeRef))) - { - result = false; - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) - { - List records = getRecordService().getRecords(recordFolder); - for (NodeRef record : records) - { - executeRecordLevelDisposition(action, record); - } - if (isGhostOnDestroySetForAction(action, recordFolder)) - { - getNodeService().addAspect(recordFolder, ASPECT_GHOSTED, Collections. emptyMap()); - } - else - { - getNodeService().deleteNode(recordFolder); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordLevelDisposition(Action action, NodeRef record) - { - // Clear the content - clearAllContent(record); - - // Clear thumbnail content - clearThumbnails(record); - - if (isGhostOnDestroySetForAction(action, record)) - { - // mark version as destroyed - Version version = recordableVersionService.getRecordedVersion(record); - if (version != null) - { - recordableVersionService.destroyRecordedVersion(version); - } - - // Add the ghosted aspect - getNodeService().addAspect(record, ASPECT_GHOSTED, null); - } - else - { - // If ghosting is not enabled, delete the node - getNodeService().deleteNode(record); - } - } - - /** - * Clear all the content properties - * - * @param nodeRef - */ - private void clearAllContent(NodeRef nodeRef) - { - Set props = this.getNodeService().getProperties(nodeRef).keySet(); - props.retainAll(this.getDictionaryService().getAllProperties(DataTypeDefinition.CONTENT)); - for (QName prop : props) - { - // Clear the content - clearContent(nodeRef, prop); - - // Remove the property - this.getNodeService().removeProperty(nodeRef, prop); - } - } - - /** - * Clear all the thumbnail information - * - * @param nodeRef - */ - @SuppressWarnings("deprecation") - private void clearThumbnails(NodeRef nodeRef) - { - // Remove the renditioned aspect (and its properties and associations) if it is present. - // - // From Alfresco 3.3 it is the rn:renditioned aspect which defines the - // child-association being considered in this method. - // Note also that the cm:thumbnailed aspect extends the rn:renditioned aspect. - // - // We want to remove the rn:renditioned aspect, but due to the possibility - // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect - // applied, we must consider removing it too. - if (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || - getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) - { - // Add the ghosted aspect to all the renditioned children, so that they will not be archived when the - // renditioned aspect is removed - Set childAssocTypes = getDictionaryService().getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet(); - for (ChildAssociationRef child : getNodeService().getChildAssocs(nodeRef)) - { - if (childAssocTypes.contains(child.getTypeQName())) - { - // Clear the content and delete the rendition - clearAllContent(child.getChildRef()); - getNodeService().deleteNode(child.getChildRef()); - } - } - } - } - - /** - * Clear a content property - * - * @param nodeRef - * @param contentProperty - */ - private void clearContent(NodeRef nodeRef, QName contentProperty) - { - // Ensure the content is cleaned at the end of the transaction - ContentData contentData = (ContentData)getNodeService().getProperty(nodeRef, contentProperty); - if (contentData != null && contentData.getContentUrl() != null) - { - eagerContentStoreCleaner.registerOrphanedContentUrl(contentData.getContentUrl(), true); - } - } - - /** - * Return true if the ghost on destroy property is set against the - * definition for the passed action on the specified node - * - * @param action - * @param nodeRef - * @return - */ - private boolean isGhostOnDestroySetForAction(Action action, NodeRef nodeRef) - { - boolean ghostOnDestroy = this.ghostingEnabled; - String actionDefinitionName = action.getActionDefinitionName(); - if (!StringUtils.isEmpty(actionDefinitionName)) - { - DispositionSchedule dispositionSchedule = this.getDispositionService().getDispositionSchedule(nodeRef); - if (dispositionSchedule != null) - { - DispositionActionDefinition actionDefinition = dispositionSchedule - .getDispositionActionDefinitionByName(actionDefinitionName); - if (actionDefinition != null) - { - String ghostOnDestroyProperty = actionDefinition.getGhostOnDestroy(); - if (ghostOnDestroyProperty != null) - { - ghostOnDestroy = "ghost".equals(actionDefinition.getGhostOnDestroy()); - } - } - } - } - return ghostOnDestroy; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.model.RenditionModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.StringUtils; + +/** + * Destroy action. + * + * @author Roy Wetherall + */ +public class DestroyAction extends RMDispositionActionExecuterAbstractBase +{ + /** Action name */ + public static final String NAME = "destroy"; + + /** Eager content store cleaner */ + private EagerContentStoreCleaner eagerContentStoreCleaner; + + /** Capability service */ + private CapabilityService capabilityService; + + /** Recordable version service */ + private RecordableVersionService recordableVersionService; + + /** Indicates if ghosting is enabled or not */ + private boolean ghostingEnabled = true; + + /** + * @param eagerContentStoreCleaner eager content store cleaner + */ + public void setEagerContentStoreCleaner(EagerContentStoreCleaner eagerContentStoreCleaner) + { + this.eagerContentStoreCleaner = eagerContentStoreCleaner; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param recordableVersionService recordable version service + */ + public void setRecordableVersionService(RecordableVersionService recordableVersionService) + { + this.recordableVersionService = recordableVersionService; + } + + /** + * @param ghostingEnabled true if ghosting is enabled, false otherwise + */ + public void setGhostingEnabled(boolean ghostingEnabled) + { + this.ghostingEnabled = ghostingEnabled; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkNextDispositionAction() + */ + @Override + protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef) + { + return checkForDestroyRecordsCapability(actionedUponNodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkEligibility(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean checkEligibility(NodeRef actionedUponNodeRef) + { + return checkForDestroyRecordsCapability(actionedUponNodeRef); + } + + /** + * + * @param actionedUponNodeRef + * @return + */ + private boolean checkForDestroyRecordsCapability(NodeRef actionedUponNodeRef) + { + boolean result = true; + if (AccessStatus.ALLOWED.equals(capabilityService.getCapability("DestroyRecords").hasPermission(actionedUponNodeRef))) + { + result = false; + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) + { + List records = getRecordService().getRecords(recordFolder); + for (NodeRef record : records) + { + executeRecordLevelDisposition(action, record); + } + if (isGhostOnDestroySetForAction(action, recordFolder)) + { + getNodeService().addAspect(recordFolder, ASPECT_GHOSTED, Collections. emptyMap()); + } + else + { + getNodeService().deleteNode(recordFolder); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordLevelDisposition(Action action, NodeRef record) + { + // Clear the content + clearAllContent(record); + + // Clear thumbnail content + clearThumbnails(record); + + if (isGhostOnDestroySetForAction(action, record)) + { + // mark version as destroyed + Version version = recordableVersionService.getRecordedVersion(record); + if (version != null) + { + recordableVersionService.destroyRecordedVersion(version); + } + + // Add the ghosted aspect + getNodeService().addAspect(record, ASPECT_GHOSTED, null); + } + else + { + // If ghosting is not enabled, delete the node + getNodeService().deleteNode(record); + } + } + + /** + * Clear all the content properties + * + * @param nodeRef + */ + private void clearAllContent(NodeRef nodeRef) + { + Set props = this.getNodeService().getProperties(nodeRef).keySet(); + props.retainAll(this.getDictionaryService().getAllProperties(DataTypeDefinition.CONTENT)); + for (QName prop : props) + { + // Clear the content + clearContent(nodeRef, prop); + + // Remove the property + this.getNodeService().removeProperty(nodeRef, prop); + } + } + + /** + * Clear all the thumbnail information + * + * @param nodeRef + */ + @SuppressWarnings("deprecation") + private void clearThumbnails(NodeRef nodeRef) + { + // Remove the renditioned aspect (and its properties and associations) if it is present. + // + // From Alfresco 3.3 it is the rn:renditioned aspect which defines the + // child-association being considered in this method. + // Note also that the cm:thumbnailed aspect extends the rn:renditioned aspect. + // + // We want to remove the rn:renditioned aspect, but due to the possibility + // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect + // applied, we must consider removing it too. + if (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || + getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) + { + // Add the ghosted aspect to all the renditioned children, so that they will not be archived when the + // renditioned aspect is removed + Set childAssocTypes = getDictionaryService().getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet(); + for (ChildAssociationRef child : getNodeService().getChildAssocs(nodeRef)) + { + if (childAssocTypes.contains(child.getTypeQName())) + { + // Clear the content and delete the rendition + clearAllContent(child.getChildRef()); + getNodeService().deleteNode(child.getChildRef()); + } + } + } + } + + /** + * Clear a content property + * + * @param nodeRef + * @param contentProperty + */ + private void clearContent(NodeRef nodeRef, QName contentProperty) + { + // Ensure the content is cleaned at the end of the transaction + ContentData contentData = (ContentData)getNodeService().getProperty(nodeRef, contentProperty); + if (contentData != null && contentData.getContentUrl() != null) + { + eagerContentStoreCleaner.registerOrphanedContentUrl(contentData.getContentUrl(), true); + } + } + + /** + * Return true if the ghost on destroy property is set against the + * definition for the passed action on the specified node + * + * @param action + * @param nodeRef + * @return + */ + private boolean isGhostOnDestroySetForAction(Action action, NodeRef nodeRef) + { + boolean ghostOnDestroy = this.ghostingEnabled; + String actionDefinitionName = action.getActionDefinitionName(); + if (!StringUtils.isEmpty(actionDefinitionName)) + { + DispositionSchedule dispositionSchedule = this.getDispositionService().getDispositionSchedule(nodeRef); + if (dispositionSchedule != null) + { + DispositionActionDefinition actionDefinition = dispositionSchedule + .getDispositionActionDefinitionByName(actionDefinitionName); + if (actionDefinition != null) + { + String ghostOnDestroyProperty = actionDefinition.getGhostOnDestroy(); + if (ghostOnDestroyProperty != null) + { + ghostOnDestroy = "ghost".equals(actionDefinition.getGhostOnDestroy()); + } + } + } + } + return ghostOnDestroy; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java index 2e9badd71f..59976aa365 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.Date; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Edit review as of date action. - * - * @author Roy Wetherall - */ -public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_VALID_DATE_DISP_ASOF = "rm.action.valid-date-disp-asof"; - private static final String MSG_DISP_ASOF_LIFECYCLE_APPLIED = "rm.action.disp-asof-lifecycle-applied"; - - /** Action parameters */ - public static final String PARAM_AS_OF_DATE = "asOfDate"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - // Get the action parameter - Date asOfDate = (Date)action.getParameterValue(PARAM_AS_OF_DATE); - if (asOfDate == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_VALID_DATE_DISP_ASOF)); - } - - // Set the dispostion action as of date - DispositionAction da = getDispositionService().getNextDispositionAction(actionedUponNodeRef); - if (da != null) - { - getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DISP_ASOF_LIFECYCLE_APPLIED)); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.Date; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Edit review as of date action. + * + * @author Roy Wetherall + */ +public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_VALID_DATE_DISP_ASOF = "rm.action.valid-date-disp-asof"; + private static final String MSG_DISP_ASOF_LIFECYCLE_APPLIED = "rm.action.disp-asof-lifecycle-applied"; + + /** Action parameters */ + public static final String PARAM_AS_OF_DATE = "asOfDate"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + // Get the action parameter + Date asOfDate = (Date)action.getParameterValue(PARAM_AS_OF_DATE); + if (asOfDate == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_VALID_DATE_DISP_ASOF)); + } + + // Set the dispostion action as of date + DispositionAction da = getDispositionService().getNextDispositionAction(actionedUponNodeRef); + if (da != null) + { + getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DISP_ASOF_LIFECYCLE_APPLIED)); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java index 786cf4ffac..f65f449f3b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Edit freeze reason Action - * - * @author Roy Wetherall - */ -public class EditHoldReasonAction extends RMActionExecuterAbstractBase -{ - private static final String MSG_HOLD_EDIT_REASON_NONE = "rm.action.hold-edit-reason-none"; - private static final String MSG_HOLD_EDIT_TYPE = "rm.action.hold-edit-type"; - - /** Parameter names */ - public static final String PARAM_REASON = "reason"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("deprecation") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getFreezeService().isHold(actionedUponNodeRef)) - { - // Get the property values - String reason = (String) action.getParameterValue(PARAM_REASON); - if (StringUtils.isBlank(reason)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_REASON_NONE)); - } - - // Update hold reason - getFreezeService().updateReason(actionedUponNodeRef, reason); - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString())); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Edit freeze reason Action + * + * @author Roy Wetherall + */ +public class EditHoldReasonAction extends RMActionExecuterAbstractBase +{ + private static final String MSG_HOLD_EDIT_REASON_NONE = "rm.action.hold-edit-reason-none"; + private static final String MSG_HOLD_EDIT_TYPE = "rm.action.hold-edit-type"; + + /** Parameter names */ + public static final String PARAM_REASON = "reason"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("deprecation") + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getFreezeService().isHold(actionedUponNodeRef)) + { + // Get the property values + String reason = (String) action.getParameterValue(PARAM_REASON); + if (StringUtils.isBlank(reason)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_REASON_NONE)); + } + + // Update hold reason + getFreezeService().updateReason(actionedUponNodeRef, reason); + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString())); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java index 6c91a5087e..46ad0ccba0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.Date; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * - * Edit review as of date action - * - * @author Roy Wetherall - */ -public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_SPECIFY_VALID_DATE = "rm.action.specify-avlid-date"; - private static final String MSG_REVIEW_DETAILS_ONLY = "rm.action.review-details-only"; - - public static final String PARAM_AS_OF_DATE = "asOfDate"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getRecordService().isRecord(actionedUponNodeRef) && - getNodeService().hasAspect(actionedUponNodeRef, ASPECT_VITAL_RECORD)) - { - // Get the action parameter - Date reviewAsOf = (Date)action.getParameterValue(PARAM_AS_OF_DATE); - if (reviewAsOf == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SPECIFY_VALID_DATE)); - } - - // Set the as of date - this.getNodeService().setProperty(actionedUponNodeRef, PROP_REVIEW_AS_OF, reviewAsOf); - - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY)); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.Date; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * + * Edit review as of date action + * + * @author Roy Wetherall + */ +public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_SPECIFY_VALID_DATE = "rm.action.specify-avlid-date"; + private static final String MSG_REVIEW_DETAILS_ONLY = "rm.action.review-details-only"; + + public static final String PARAM_AS_OF_DATE = "asOfDate"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getRecordService().isRecord(actionedUponNodeRef) && + getNodeService().hasAspect(actionedUponNodeRef, ASPECT_VITAL_RECORD)) + { + // Get the action parameter + Date reviewAsOf = (Date)action.getParameterValue(PARAM_AS_OF_DATE); + if (reviewAsOf == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SPECIFY_VALID_DATE)); + } + + // Set the as of date + this.getNodeService().setProperty(actionedUponNodeRef, PROP_REVIEW_AS_OF, reviewAsOf); + + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY)); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java index ce74c1dbb7..7569212eb3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java @@ -1,191 +1,191 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.report.Report; -import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; -import org.alfresco.module.org_alfresco_module_rm.report.ReportService; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * File report generic action. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel -{ - /** action name */ - public static final String NAME = "fileReport"; - - /** Constants for the parameters passed from the UI */ - public static final String REPORT_TYPE = "reportType"; - - public static final String DESTINATION = "destination"; - - public static final String MIMETYPE = "mimetype"; - - /** I18N */ - private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied"; - - /** Report service */ - private ReportService reportService; - - /** Capability service */ - private CapabilityService capabilityService; - - /** - * @return Report service - */ - protected ReportService getReportService() - { - return this.reportService; - } - - /** - * @return Capability service - */ - protected CapabilityService getCapabilityService() - { - return this.capabilityService; - } - - /** - * @param reportService report service - */ - public void setReportService(ReportService reportService) - { - this.reportService = reportService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // get the mimetype of the report - String mimetype = (String) action.getParameterValue(MIMETYPE); - if (mimetype == null || mimetype.isEmpty()) - { - mimetype = MimetypeMap.MIMETYPE_HTML; - } - - // get the report type - QName reportType = getReportType(action); - - // get the destination - final NodeRef destination = getDestination(action); - - // Check the filing permission only capability for the destination - checkFilingPermissionOnlyCapability(destination); - - // generate the report - final Report report = getReportService().generateReport(reportType, actionedUponNodeRef, mimetype); - - // file the report as system - NodeRef filedReport = AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return getReportService().fileReport(destination, report); - } - }); - - // return the report name - String filedReportName = (String) getNodeService().getProperty(filedReport, ContentModel.PROP_NAME); - action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, filedReportName); - } - - /** - * Checks if the destination is frozen, closed, cut off or not. In case if it is an exception will be thrown. - * - * @param nodeRef The destination node reference for which the capability should be checked - */ - private void checkFilingPermissionOnlyCapability(NodeRef nodeRef) - { - if (AccessStatus.DENIED.equals(capabilityService.getCapability("FillingPermissionOnly").hasPermission(nodeRef))) - { - throw new AlfrescoRuntimeException("You don't have filing permission on the destination or the destination is either frozen, closed or cut off!"); - } - } - - /** - * Retrieves the value of the given parameter. If the parameter has not been - * passed from the UI an error will be thrown - * - * @param action The action - * @param parameter The parameter for which the value should be retrieved - * @return The value of the given parameter - */ - private String getParameterValue(Action action, String parameter) - { - String paramValue = (String) action.getParameterValue(parameter); - if (StringUtils.isBlank(paramValue)) { throw new AlfrescoRuntimeException(I18NUtil.getMessage( - MSG_PARAM_NOT_SUPPLIED, parameter)); } - return paramValue; - } - - /** - * Helper method for getting the destination. - * - * @param action The action - * @return The file plan node reference - */ - private NodeRef getDestination(Action action) - { - String destination = getParameterValue(action, DESTINATION); - return new NodeRef(destination); - } - - /** - * Helper method for getting the report type. - * - * @param action The action - * @return The report type - */ - private QName getReportType(Action action) - { - String reportType = getParameterValue(action, REPORT_TYPE); - return QName.createQName(reportType, getNamespaceService()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.report.Report; +import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; +import org.alfresco.module.org_alfresco_module_rm.report.ReportService; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * File report generic action. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel +{ + /** action name */ + public static final String NAME = "fileReport"; + + /** Constants for the parameters passed from the UI */ + public static final String REPORT_TYPE = "reportType"; + + public static final String DESTINATION = "destination"; + + public static final String MIMETYPE = "mimetype"; + + /** I18N */ + private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied"; + + /** Report service */ + private ReportService reportService; + + /** Capability service */ + private CapabilityService capabilityService; + + /** + * @return Report service + */ + protected ReportService getReportService() + { + return this.reportService; + } + + /** + * @return Capability service + */ + protected CapabilityService getCapabilityService() + { + return this.capabilityService; + } + + /** + * @param reportService report service + */ + public void setReportService(ReportService reportService) + { + this.reportService = reportService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // get the mimetype of the report + String mimetype = (String) action.getParameterValue(MIMETYPE); + if (mimetype == null || mimetype.isEmpty()) + { + mimetype = MimetypeMap.MIMETYPE_HTML; + } + + // get the report type + QName reportType = getReportType(action); + + // get the destination + final NodeRef destination = getDestination(action); + + // Check the filing permission only capability for the destination + checkFilingPermissionOnlyCapability(destination); + + // generate the report + final Report report = getReportService().generateReport(reportType, actionedUponNodeRef, mimetype); + + // file the report as system + NodeRef filedReport = AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return getReportService().fileReport(destination, report); + } + }); + + // return the report name + String filedReportName = (String) getNodeService().getProperty(filedReport, ContentModel.PROP_NAME); + action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, filedReportName); + } + + /** + * Checks if the destination is frozen, closed, cut off or not. In case if it is an exception will be thrown. + * + * @param nodeRef The destination node reference for which the capability should be checked + */ + private void checkFilingPermissionOnlyCapability(NodeRef nodeRef) + { + if (AccessStatus.DENIED.equals(capabilityService.getCapability("FillingPermissionOnly").hasPermission(nodeRef))) + { + throw new AlfrescoRuntimeException("You don't have filing permission on the destination or the destination is either frozen, closed or cut off!"); + } + } + + /** + * Retrieves the value of the given parameter. If the parameter has not been + * passed from the UI an error will be thrown + * + * @param action The action + * @param parameter The parameter for which the value should be retrieved + * @return The value of the given parameter + */ + private String getParameterValue(Action action, String parameter) + { + String paramValue = (String) action.getParameterValue(parameter); + if (StringUtils.isBlank(paramValue)) { throw new AlfrescoRuntimeException(I18NUtil.getMessage( + MSG_PARAM_NOT_SUPPLIED, parameter)); } + return paramValue; + } + + /** + * Helper method for getting the destination. + * + * @param action The action + * @return The file plan node reference + */ + private NodeRef getDestination(Action action) + { + String destination = getParameterValue(action, DESTINATION); + return new NodeRef(destination); + } + + /** + * Helper method for getting the report type. + * + * @param action The action + * @return The report type + */ + private QName getReportType(Action action) + { + String reportType = getParameterValue(action, REPORT_TYPE); + return QName.createQName(reportType, getNamespaceService()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java index 6e15273974..aa2e17da26 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java @@ -1,20 +1,20 @@ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -/** - * File To action implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FileToAction extends CopyMoveLinkFileToBaseAction -{ - /** action name */ - public static final String NAME = "fileTo"; - - @Override - public void init() - { - super.init(); - setMode(CopyMoveLinkFileToActionMode.MOVE); - } -} +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +/** + * File To action implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FileToAction extends CopyMoveLinkFileToBaseAction +{ + /** action name */ + public static final String NAME = "fileTo"; + + @Override + public void init() + { + super.init(); + setMode(CopyMoveLinkFileToActionMode.MOVE); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java index dc21f4ec54..951a307a60 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Freeze Action - * - * @author Roy Wetherall - */ -public class FreezeAction extends RMActionExecuterAbstractBase -{ - /** Parameter names */ - public static final String PARAM_REASON = "reason"; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REASON))); - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("deprecation") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // NOTE: we can only freeze records and record folders so ignore everything else - if (getNodeService().exists(actionedUponNodeRef) && - !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && - (getRecordService().isRecord(actionedUponNodeRef) || - getRecordFolderService().isRecordFolder(actionedUponNodeRef)) && - !getFreezeService().isFrozen(actionedUponNodeRef)) - { - getFreezeService().freeze((String) action.getParameterValue(PARAM_REASON), actionedUponNodeRef); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Freeze Action + * + * @author Roy Wetherall + */ +public class FreezeAction extends RMActionExecuterAbstractBase +{ + /** Parameter names */ + public static final String PARAM_REASON = "reason"; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REASON))); + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("deprecation") + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // NOTE: we can only freeze records and record folders so ignore everything else + if (getNodeService().exists(actionedUponNodeRef) && + !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && + (getRecordService().isRecord(actionedUponNodeRef) || + getRecordFolderService().isRecordFolder(actionedUponNodeRef)) && + !getFreezeService().isFrozen(actionedUponNodeRef)) + { + getFreezeService().freeze((String) action.getParameterValue(PARAM_REASON), actionedUponNodeRef); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/LinkToAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/LinkToAction.java index e5254d9c73..67bf45ef53 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/LinkToAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/LinkToAction.java @@ -1,20 +1,20 @@ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -/** - * Link To action implementation. - * - * @author Mark Hibbins - * @since 2.2 - */ -public class LinkToAction extends CopyMoveLinkFileToBaseAction -{ - /** action name */ - public static final String NAME = "linkTo"; - - @Override - public void init() - { - super.init(); - setMode(CopyMoveLinkFileToActionMode.LINK); - } +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +/** + * Link To action implementation. + * + * @author Mark Hibbins + * @since 2.2 + */ +public class LinkToAction extends CopyMoveLinkFileToBaseAction +{ + /** action name */ + public static final String NAME = "linkTo"; + + @Override + public void init() + { + super.init(); + setMode(CopyMoveLinkFileToActionMode.LINK); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/MoveToAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/MoveToAction.java index c3ff161ee4..c77a8a8c97 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/MoveToAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/MoveToAction.java @@ -1,20 +1,20 @@ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -/** - * File To action implementation. - * - * @author Mark Hibbins - * @since 2.2 - */ -public class MoveToAction extends CopyMoveLinkFileToBaseAction -{ - /** action name */ - public static final String NAME = "moveTo"; - - @Override - public void init() - { - super.init(); - setMode(CopyMoveLinkFileToActionMode.MOVE); - } +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +/** + * File To action implementation. + * + * @author Mark Hibbins + * @since 2.2 + */ +public class MoveToAction extends CopyMoveLinkFileToBaseAction +{ + /** action name */ + public static final String NAME = "moveTo"; + + @Override + public void init() + { + super.init(); + setMode(CopyMoveLinkFileToActionMode.MOVE); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java index 481e609b2a..bff2603f5e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java @@ -1,86 +1,86 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Action to re-open the records folder - * - * @author Roy Wetherall - */ -public class OpenRecordFolderAction extends RMActionExecuterAbstractBase -{ - /** Logger */ - private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class); - - /** I18N */ - private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder"; - - /** Parameter names */ - public static final String PARAM_OPEN_PARENT = "openParent"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef) && - !(getDictionaryService().isSubClass(getNodeService().getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) && !getRecordService().isFiled(actionedUponNodeRef))) - { - // TODO move re-open logic into a service method - // TODO check that the user in question has the correct permission to re-open a records folder - - if (getRecordService().isRecord(actionedUponNodeRef)) - { - ChildAssociationRef assocRef = getNodeService().getPrimaryParent(actionedUponNodeRef); - if (assocRef != null) - { - actionedUponNodeRef = assocRef.getParentRef(); - } - } - - if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) - { - Boolean isClosed = (Boolean) getNodeService().getProperty(actionedUponNodeRef, PROP_IS_CLOSED); - if (Boolean.TRUE.equals(isClosed)) - { - getNodeService().setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false); - } - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString())); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Action to re-open the records folder + * + * @author Roy Wetherall + */ +public class OpenRecordFolderAction extends RMActionExecuterAbstractBase +{ + /** Logger */ + private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class); + + /** I18N */ + private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder"; + + /** Parameter names */ + public static final String PARAM_OPEN_PARENT = "openParent"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef) && + !(getDictionaryService().isSubClass(getNodeService().getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) && !getRecordService().isFiled(actionedUponNodeRef))) + { + // TODO move re-open logic into a service method + // TODO check that the user in question has the correct permission to re-open a records folder + + if (getRecordService().isRecord(actionedUponNodeRef)) + { + ChildAssociationRef assocRef = getNodeService().getPrimaryParent(actionedUponNodeRef); + if (assocRef != null) + { + actionedUponNodeRef = assocRef.getParentRef(); + } + } + + if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) + { + Boolean isClosed = (Boolean) getNodeService().getProperty(actionedUponNodeRef, PROP_IS_CLOSED); + if (Boolean.TRUE.equals(isClosed)) + { + getNodeService().setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false); + } + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString())); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RejectAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RejectAction.java index 47a54503bd..f69f502e71 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RejectAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RejectAction.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Reject action for an unfiled record - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RejectAction extends RMActionExecuterAbstractBase -{ - /** Parameter names */ - public static final String PARAM_REASON = "reason"; - - /** Action name */ - public static final String NAME = "reject"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef) && - getNodeService().getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION) != null) - { - getRecordService().rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON)); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_REASON))); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Reject action for an unfiled record + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RejectAction extends RMActionExecuterAbstractBase +{ + /** Parameter names */ + public static final String PARAM_REASON = "reason"; + + /** Action name */ + public static final String NAME = "reject"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef) && + getNodeService().getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION) != null) + { + getRecordService().rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON)); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_REASON))); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RelinquishHoldAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RelinquishHoldAction.java index cbf320a50e..f407c53f70 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RelinquishHoldAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RelinquishHoldAction.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Relinquish Hold Action - * - * @author Roy Wetherall - */ -public class RelinquishHoldAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_NOT_HOLD_TYPE = "rm.action.not-hold-type"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("deprecation") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getFreezeService().isHold(actionedUponNodeRef)) - { - getFreezeService().relinquish(actionedUponNodeRef); - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_HOLD_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString())); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Relinquish Hold Action + * + * @author Roy Wetherall + */ +public class RelinquishHoldAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_NOT_HOLD_TYPE = "rm.action.not-hold-type"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("deprecation") + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getFreezeService().isHold(actionedUponNodeRef)) + { + getFreezeService().relinquish(actionedUponNodeRef); + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_HOLD_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString())); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java index 925eceeb5e..4a1e952530 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java @@ -1,170 +1,170 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.namespace.QName; -import org.alfresco.workflow.RMWorkflowModel; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Request info action for starting a workflow to request more information for an undeclared record - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RequestInfoAction extends RMActionExecuterAbstractBase -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RequestInfoAction.class); - - /** Parameter names */ - public static final String PARAM_REQUESTED_INFO = "requestedInfo"; - public static final String PARAM_ASSIGNEES = "assignees"; - public static final String PARAM_RULE_CREATOR = "ruleCreator"; - - /** Action name */ - public static final String NAME = "requestInfo"; - - /** Workflow definition name */ - private static final String REQUEST_INFO_WORKFLOW_DEFINITION_NAME = "activiti$activitiRequestForInformation"; - - /** Workflow service */ - private WorkflowService workflowService; - - /** - * @param workflowService workflow service - */ - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef) && - !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && - getRecordService().isRecord(actionedUponNodeRef) && - !getRecordService().isDeclared(actionedUponNodeRef)) - { - String workflowDefinitionId = workflowService.getDefinitionByName(REQUEST_INFO_WORKFLOW_DEFINITION_NAME).getId(); - Map parameters = new HashMap(); - - parameters.put(WorkflowModel.ASSOC_PACKAGE, getWorkflowPackage(action, actionedUponNodeRef)); - parameters.put(RMWorkflowModel.RM_MIXED_ASSIGNEES, getAssignees(action)); - parameters.put(RMWorkflowModel.RM_REQUESTED_INFORMATION, getRequestedInformation(action)); - parameters.put(RMWorkflowModel.RM_RULE_CREATOR, getRuleCreator(action)); - - workflowService.startWorkflow(workflowDefinitionId, parameters); - } - else - { - logger.info("Can't start the request information workflow for node '" + actionedUponNodeRef.toString() + "'."); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_REQUESTED_INFO, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REQUESTED_INFO))); - paramList.add(new ParameterDefinitionImpl(PARAM_ASSIGNEES, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_ASSIGNEES))); - paramList.add(new ParameterDefinitionImpl(PARAM_RULE_CREATOR, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_RULE_CREATOR))); - } - - /** - * Helper method for creating a workflow package to contain the actioned upon nodeRef - * - * @param action The request info action - * @param actionedUponNodeRef The actioned upon nodeRef - * @return Returns a workflow package containing the actioned upon nodeRef - */ - private NodeRef getWorkflowPackage(Action action, NodeRef actionedUponNodeRef) - { - NodeRef workflowPackage = (NodeRef) action.getParameterValue(WorkflowModel.ASSOC_PACKAGE.toPrefixString(getNamespaceService())); - workflowPackage = workflowService.createPackage(workflowPackage); - ChildAssociationRef childAssoc = getNodeService().getPrimaryParent(actionedUponNodeRef); - getNodeService().addChild(workflowPackage, actionedUponNodeRef, WorkflowModel.ASSOC_PACKAGE_CONTAINS, childAssoc.getQName()); - return workflowPackage; - } - - /** - * Helper method for getting the assignees from the action - * - * @param action The request info action - * @return Returns a list of {@link NodeRef}s each representing the assignee - */ - private Serializable getAssignees(Action action) - { - List assigneesList = new ArrayList(); - String assigneesAsString = (String) action.getParameterValue(PARAM_ASSIGNEES); - String[] assignees = StringUtils.split(assigneesAsString, ','); - for (String assignee : assignees) - { - assigneesList.add(new NodeRef(assignee)); - } - return (Serializable) assigneesList; - } - - /** - * Helper method for getting the requested information from the action - * - * @param action The request info action - * @return Returns the requested information - */ - private Serializable getRequestedInformation(Action action) - { - return action.getParameterValue(PARAM_REQUESTED_INFO); - } - - /** - * Helper method for getting the rule creator - * - * @param action The request info action - * @return Returns the rule creator - */ - private Serializable getRuleCreator(Action action) - { - return action.getParameterValue(PARAM_RULE_CREATOR); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.workflow.WorkflowModel; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.workflow.WorkflowService; +import org.alfresco.service.namespace.QName; +import org.alfresco.workflow.RMWorkflowModel; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Request info action for starting a workflow to request more information for an undeclared record + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RequestInfoAction extends RMActionExecuterAbstractBase +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RequestInfoAction.class); + + /** Parameter names */ + public static final String PARAM_REQUESTED_INFO = "requestedInfo"; + public static final String PARAM_ASSIGNEES = "assignees"; + public static final String PARAM_RULE_CREATOR = "ruleCreator"; + + /** Action name */ + public static final String NAME = "requestInfo"; + + /** Workflow definition name */ + private static final String REQUEST_INFO_WORKFLOW_DEFINITION_NAME = "activiti$activitiRequestForInformation"; + + /** Workflow service */ + private WorkflowService workflowService; + + /** + * @param workflowService workflow service + */ + public void setWorkflowService(WorkflowService workflowService) + { + this.workflowService = workflowService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef) && + !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && + getRecordService().isRecord(actionedUponNodeRef) && + !getRecordService().isDeclared(actionedUponNodeRef)) + { + String workflowDefinitionId = workflowService.getDefinitionByName(REQUEST_INFO_WORKFLOW_DEFINITION_NAME).getId(); + Map parameters = new HashMap(); + + parameters.put(WorkflowModel.ASSOC_PACKAGE, getWorkflowPackage(action, actionedUponNodeRef)); + parameters.put(RMWorkflowModel.RM_MIXED_ASSIGNEES, getAssignees(action)); + parameters.put(RMWorkflowModel.RM_REQUESTED_INFORMATION, getRequestedInformation(action)); + parameters.put(RMWorkflowModel.RM_RULE_CREATOR, getRuleCreator(action)); + + workflowService.startWorkflow(workflowDefinitionId, parameters); + } + else + { + logger.info("Can't start the request information workflow for node '" + actionedUponNodeRef.toString() + "'."); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_REQUESTED_INFO, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REQUESTED_INFO))); + paramList.add(new ParameterDefinitionImpl(PARAM_ASSIGNEES, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_ASSIGNEES))); + paramList.add(new ParameterDefinitionImpl(PARAM_RULE_CREATOR, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_RULE_CREATOR))); + } + + /** + * Helper method for creating a workflow package to contain the actioned upon nodeRef + * + * @param action The request info action + * @param actionedUponNodeRef The actioned upon nodeRef + * @return Returns a workflow package containing the actioned upon nodeRef + */ + private NodeRef getWorkflowPackage(Action action, NodeRef actionedUponNodeRef) + { + NodeRef workflowPackage = (NodeRef) action.getParameterValue(WorkflowModel.ASSOC_PACKAGE.toPrefixString(getNamespaceService())); + workflowPackage = workflowService.createPackage(workflowPackage); + ChildAssociationRef childAssoc = getNodeService().getPrimaryParent(actionedUponNodeRef); + getNodeService().addChild(workflowPackage, actionedUponNodeRef, WorkflowModel.ASSOC_PACKAGE_CONTAINS, childAssoc.getQName()); + return workflowPackage; + } + + /** + * Helper method for getting the assignees from the action + * + * @param action The request info action + * @return Returns a list of {@link NodeRef}s each representing the assignee + */ + private Serializable getAssignees(Action action) + { + List assigneesList = new ArrayList(); + String assigneesAsString = (String) action.getParameterValue(PARAM_ASSIGNEES); + String[] assignees = StringUtils.split(assigneesAsString, ','); + for (String assignee : assignees) + { + assigneesList.add(new NodeRef(assignee)); + } + return (Serializable) assigneesList; + } + + /** + * Helper method for getting the requested information from the action + * + * @param action The request info action + * @return Returns the requested information + */ + private Serializable getRequestedInformation(Action action) + { + return action.getParameterValue(PARAM_REQUESTED_INFO); + } + + /** + * Helper method for getting the rule creator + * + * @param action The request info action + * @return Returns the rule creator + */ + private Serializable getRuleCreator(Action action) + { + return action.getParameterValue(PARAM_RULE_CREATOR); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RetainAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RetainAction.java index d805fea2b5..a948f8387c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RetainAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RetainAction.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Retain action - * - * @author Roy Wetherall - */ -public class RetainAction extends RMDispositionActionExecuterAbstractBase -{ - @Override - protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) - { - // Do nothing - } - - @Override - protected void executeRecordLevelDisposition(Action action, NodeRef record) - { - // Do nothing - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Retain action + * + * @author Roy Wetherall + */ +public class RetainAction extends RMDispositionActionExecuterAbstractBase +{ + @Override + protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) + { + // Do nothing + } + + @Override + protected void executeRecordLevelDisposition(Action action, NodeRef record) + { + // Do nothing + } +} 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 8a25b62c0c..2e4da9ae87 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 @@ -1,293 +1,293 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import static org.apache.commons.lang.StringUtils.isBlank; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.Part; -import javax.mail.internet.ContentType; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeUtility; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.model.ImapModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.util.FileCopyUtils; - -/** - * Split Email Action - * - * Splits the attachments for an email message out to independent records. - * - * @author Mark Rogers - */ -public class SplitEmailAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_NO_READ_MIME_MESSAGE = "rm.action.no-read-mime-message"; - private static final String MSG_EMAIL_DECLARED = "rm.action.email-declared"; - private static final String MSG_EMAIL_NOT_RECORD = "rm.action.email-not-record"; - - /** Relationship Labels */ - private static final String REL_FROM = "Message"; - private static final String REL_TO = "Attachment"; - - /** Logger */ - private static Log logger = LogFactory.getLog(SplitEmailAction.class); - - /** Relationship service */ - private RelationshipService relationshipService; - - /** - * Gets the relationship service instance - * - * @return The relationship service instance - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Sets the relationship service instance - * - * @param relationshipService The relationship service instance - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** Unique name of the relationship definition */ - private String relationshipUniqueName; - - public void bootstrap() - { - Set relationshipDefinitions = getRelationshipService().getRelationshipDefinitions(); - for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) - { - RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); - String sourceText = displayName.getSourceText(); - String targetText = displayName.getTargetText(); - - if (sourceText.equals(REL_FROM) && targetText.equals(REL_TO)) - { - relationshipUniqueName = relationshipDefinition.getUniqueName(); - } - } - - if (isBlank(relationshipUniqueName)) - { - RelationshipDisplayName displayName = new RelationshipDisplayName(REL_FROM, REL_TO); - RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName); - relationshipUniqueName = relationshipDefinition.getUniqueName(); - } - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // get node type - getNodeService().getType(actionedUponNodeRef); - - if (logger.isDebugEnabled()) - { - logger.debug("split email:" + actionedUponNodeRef); - } - - if (getRecordService().isRecord(actionedUponNodeRef)) - { - if (!getRecordService().isDeclared(actionedUponNodeRef)) - { - ChildAssociationRef parent = getNodeService().getPrimaryParent(actionedUponNodeRef); - - /** - * Check whether the email message has already been split - do nothing if it has already been split - */ - List refs = getNodeService().getTargetAssocs(actionedUponNodeRef, ImapModel.ASSOC_IMAP_ATTACHMENT); - if(refs.size() > 0) - { - if (logger.isDebugEnabled()) - { - logger.debug("mail message has already been split - do nothing"); - } - return; - } - - /** - * Get the content and if its a mime message then create atachments for each part - */ - try - { - ContentReader reader = getContentService().getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT); - InputStream is = reader.getContentInputStream(); - MimeMessage mimeMessage = new MimeMessage(null, is); - Object content = mimeMessage.getContent(); - if (content instanceof Multipart) - { - Multipart multipart = (Multipart)content; - - for (int i = 0, n = multipart.getCount(); i < n; i++) - { - Part part = multipart.getBodyPart(i); - if ("attachment".equalsIgnoreCase(part.getDisposition())) - { - createAttachment(actionedUponNodeRef, parent.getParentRef(), part); - } - } - } - } - catch (Exception e) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_READ_MIME_MESSAGE, e.toString()), e); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_DECLARED, actionedUponNodeRef.toString())); - } - } - else - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString())); - } - } - - /** - * Create attachment from Mime Message Part - * @param messageNodeRef - the node ref of the mime message - * @param parentNodeRef - the node ref of the parent folder - * @param part - * @throws MessagingException - * @throws IOException - */ - private void createAttachment(NodeRef messageNodeRef, NodeRef parentNodeRef, Part part) throws MessagingException, IOException - { - String fileName = part.getFileName(); - try - { - fileName = MimeUtility.decodeText(fileName); - } - catch (UnsupportedEncodingException e) - { - if (logger.isWarnEnabled()) - { - logger.warn("Cannot decode file name '" + fileName + "'", e); - } - } - - Map messageProperties = getNodeService().getProperties(messageNodeRef); - String messageTitle = (String)messageProperties.get(ContentModel.PROP_NAME); - if(messageTitle == null) - { - messageTitle = fileName; - } - else - { - messageTitle = messageTitle + " - " + fileName; - } - - ContentType contentType = new ContentType(part.getContentType()); - - Map docProps = new HashMap(1); - docProps.put(ContentModel.PROP_NAME, messageTitle + " - " + fileName); - docProps.put(ContentModel.PROP_TITLE, fileName); - - /** - * Create an attachment node in the same folder as the message - */ - ChildAssociationRef attachmentRef = getNodeService().createNode(parentNodeRef, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), - ContentModel.TYPE_CONTENT, - docProps); - - /** - * Write the content into the new attachment node - */ - ContentWriter writer = getContentService().getWriter(attachmentRef.getChildRef(), ContentModel.PROP_CONTENT, true); - writer.setMimetype(contentType.getBaseType()); - OutputStream os = writer.getContentOutputStream(); - FileCopyUtils.copy(part.getInputStream(), os); - - /** - * Create a link from the message to the attachment - */ - createRMReference(messageNodeRef, attachmentRef.getChildRef()); - - - } - - /** - * Create a link from the message to the attachment - */ - private void createRMReference(final NodeRef parentRef, final NodeRef childRef) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // add the relationship - getRelationshipService().addRelationship(relationshipUniqueName, parentRef, childRef); - - // add the IMAP attachment aspect - getNodeService().createAssociation( - parentRef, - childRef, - ImapModel.ASSOC_IMAP_ATTACHMENT); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import static org.apache.commons.lang.StringUtils.isBlank; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.Part; +import javax.mail.internet.ContentType; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeUtility; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.model.ImapModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.util.FileCopyUtils; + +/** + * Split Email Action + * + * Splits the attachments for an email message out to independent records. + * + * @author Mark Rogers + */ +public class SplitEmailAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_NO_READ_MIME_MESSAGE = "rm.action.no-read-mime-message"; + private static final String MSG_EMAIL_DECLARED = "rm.action.email-declared"; + private static final String MSG_EMAIL_NOT_RECORD = "rm.action.email-not-record"; + + /** Relationship Labels */ + private static final String REL_FROM = "Message"; + private static final String REL_TO = "Attachment"; + + /** Logger */ + private static Log logger = LogFactory.getLog(SplitEmailAction.class); + + /** Relationship service */ + private RelationshipService relationshipService; + + /** + * Gets the relationship service instance + * + * @return The relationship service instance + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Sets the relationship service instance + * + * @param relationshipService The relationship service instance + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** Unique name of the relationship definition */ + private String relationshipUniqueName; + + public void bootstrap() + { + Set relationshipDefinitions = getRelationshipService().getRelationshipDefinitions(); + for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) + { + RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); + String sourceText = displayName.getSourceText(); + String targetText = displayName.getTargetText(); + + if (sourceText.equals(REL_FROM) && targetText.equals(REL_TO)) + { + relationshipUniqueName = relationshipDefinition.getUniqueName(); + } + } + + if (isBlank(relationshipUniqueName)) + { + RelationshipDisplayName displayName = new RelationshipDisplayName(REL_FROM, REL_TO); + RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName); + relationshipUniqueName = relationshipDefinition.getUniqueName(); + } + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // get node type + getNodeService().getType(actionedUponNodeRef); + + if (logger.isDebugEnabled()) + { + logger.debug("split email:" + actionedUponNodeRef); + } + + if (getRecordService().isRecord(actionedUponNodeRef)) + { + if (!getRecordService().isDeclared(actionedUponNodeRef)) + { + ChildAssociationRef parent = getNodeService().getPrimaryParent(actionedUponNodeRef); + + /** + * Check whether the email message has already been split - do nothing if it has already been split + */ + List refs = getNodeService().getTargetAssocs(actionedUponNodeRef, ImapModel.ASSOC_IMAP_ATTACHMENT); + if(refs.size() > 0) + { + if (logger.isDebugEnabled()) + { + logger.debug("mail message has already been split - do nothing"); + } + return; + } + + /** + * Get the content and if its a mime message then create atachments for each part + */ + try + { + ContentReader reader = getContentService().getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT); + InputStream is = reader.getContentInputStream(); + MimeMessage mimeMessage = new MimeMessage(null, is); + Object content = mimeMessage.getContent(); + if (content instanceof Multipart) + { + Multipart multipart = (Multipart)content; + + for (int i = 0, n = multipart.getCount(); i < n; i++) + { + Part part = multipart.getBodyPart(i); + if ("attachment".equalsIgnoreCase(part.getDisposition())) + { + createAttachment(actionedUponNodeRef, parent.getParentRef(), part); + } + } + } + } + catch (Exception e) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_READ_MIME_MESSAGE, e.toString()), e); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_DECLARED, actionedUponNodeRef.toString())); + } + } + else + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString())); + } + } + + /** + * Create attachment from Mime Message Part + * @param messageNodeRef - the node ref of the mime message + * @param parentNodeRef - the node ref of the parent folder + * @param part + * @throws MessagingException + * @throws IOException + */ + private void createAttachment(NodeRef messageNodeRef, NodeRef parentNodeRef, Part part) throws MessagingException, IOException + { + String fileName = part.getFileName(); + try + { + fileName = MimeUtility.decodeText(fileName); + } + catch (UnsupportedEncodingException e) + { + if (logger.isWarnEnabled()) + { + logger.warn("Cannot decode file name '" + fileName + "'", e); + } + } + + Map messageProperties = getNodeService().getProperties(messageNodeRef); + String messageTitle = (String)messageProperties.get(ContentModel.PROP_NAME); + if(messageTitle == null) + { + messageTitle = fileName; + } + else + { + messageTitle = messageTitle + " - " + fileName; + } + + ContentType contentType = new ContentType(part.getContentType()); + + Map docProps = new HashMap(1); + docProps.put(ContentModel.PROP_NAME, messageTitle + " - " + fileName); + docProps.put(ContentModel.PROP_TITLE, fileName); + + /** + * Create an attachment node in the same folder as the message + */ + ChildAssociationRef attachmentRef = getNodeService().createNode(parentNodeRef, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), + ContentModel.TYPE_CONTENT, + docProps); + + /** + * Write the content into the new attachment node + */ + ContentWriter writer = getContentService().getWriter(attachmentRef.getChildRef(), ContentModel.PROP_CONTENT, true); + writer.setMimetype(contentType.getBaseType()); + OutputStream os = writer.getContentOutputStream(); + FileCopyUtils.copy(part.getInputStream(), os); + + /** + * Create a link from the message to the attachment + */ + createRMReference(messageNodeRef, attachmentRef.getChildRef()); + + + } + + /** + * Create a link from the message to the attachment + */ + private void createRMReference(final NodeRef parentRef, final NodeRef childRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // add the relationship + getRelationshipService().addRelationship(relationshipUniqueName, parentRef, childRef); + + // add the IMAP attachment aspect + getNodeService().createAssociation( + parentRef, + childRef, + ImapModel.ASSOC_IMAP_ATTACHMENT); + + return null; + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java index 3c02ba59fe..6a62965524 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java @@ -1,109 +1,109 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.repo.action.executer.ActionExecuter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Transfer action - * - * @author Roy Wetherall - */ -public class TransferAction extends RMDispositionActionExecuterAbstractBase -{ - /** Action name */ - public static final String NAME = "transfer"; - - /** Indicates whether the transfer is an accession or not */ - private boolean isAccession = false; - - /** transfer service */ - private TransferService transferService; - - /** - * Indicates whether this transfer is an accession or not - * - * @param isAccession - */ - public void setIsAccession(boolean isAccession) - { - this.isAccession = isAccession; - } - - /** - * @param transferService transfer service - */ - public void setTransferService(TransferService transferService) - { - this.transferService = transferService; - } - - /** - * Do not set the transfer action to auto-complete - * - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#getSetDispositionActionComplete() - */ - @Override - public boolean getSetDispositionActionComplete() - { - return false; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) - { - doTransfer(action, recordFolder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeRecordLevelDisposition(Action action, NodeRef record) - { - doTransfer(action, record); - } - - /** - * Create the transfer node and link the disposition lifecycle node beneath it - * - * @param action action - * @param dispositionLifeCycleNodeRef disposition lifecycle node - */ - private void doTransfer(Action action, NodeRef dispositionLifeCycleNodeRef) - { - NodeRef transferNodeRef = transferService.transfer(dispositionLifeCycleNodeRef, isAccession); - - // Set the return value of the action - action.setParameterValue(ActionExecuter.PARAM_RESULT, transferNodeRef); - - // Cut off the disposable item if it's not cut off already - if (!getDispositionService().isDisposableItemCutoff(dispositionLifeCycleNodeRef)) - { - getDispositionService().cutoffDisposableItem(dispositionLifeCycleNodeRef); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.repo.action.executer.ActionExecuter; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Transfer action + * + * @author Roy Wetherall + */ +public class TransferAction extends RMDispositionActionExecuterAbstractBase +{ + /** Action name */ + public static final String NAME = "transfer"; + + /** Indicates whether the transfer is an accession or not */ + private boolean isAccession = false; + + /** transfer service */ + private TransferService transferService; + + /** + * Indicates whether this transfer is an accession or not + * + * @param isAccession + */ + public void setIsAccession(boolean isAccession) + { + this.isAccession = isAccession; + } + + /** + * @param transferService transfer service + */ + public void setTransferService(TransferService transferService) + { + this.transferService = transferService; + } + + /** + * Do not set the transfer action to auto-complete + * + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#getSetDispositionActionComplete() + */ + @Override + public boolean getSetDispositionActionComplete() + { + return false; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) + { + doTransfer(action, recordFolder); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeRecordLevelDisposition(Action action, NodeRef record) + { + doTransfer(action, record); + } + + /** + * Create the transfer node and link the disposition lifecycle node beneath it + * + * @param action action + * @param dispositionLifeCycleNodeRef disposition lifecycle node + */ + private void doTransfer(Action action, NodeRef dispositionLifeCycleNodeRef) + { + NodeRef transferNodeRef = transferService.transfer(dispositionLifeCycleNodeRef, isAccession); + + // Set the return value of the action + action.setParameterValue(ActionExecuter.PARAM_RESULT, transferNodeRef); + + // Cut off the disposable item if it's not cut off already + if (!getDispositionService().isDisposableItemCutoff(dispositionLifeCycleNodeRef)) + { + getDispositionService().cutoffDisposableItem(dispositionLifeCycleNodeRef); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java index 527175bc81..6620500420 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java @@ -1,85 +1,85 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Transfer complete action - * - * @author Roy Wetherall - */ -public class TransferCompleteAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_NODE_NOT_TRANSFER = "rm.action.node-not-transfer"; - - /** Action name */ - public static final String NAME = "transferComplete"; - - /** Transfer service */ - private TransferService transferService; - - /** - * @return transfer service - */ - protected TransferService getTransferService() - { - return this.transferService; - } - - /** - * @param transferService transfer service - */ - public void setTransferService(TransferService transferService) - { - this.transferService = transferService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - checkTransferSubClass(actionedUponNodeRef); - getTransferService().completeTransfer(actionedUponNodeRef); - } - - /** - * Checks if the actioned upon node reference is a sub class of transfer - * - * @param actionedUponNodeRef actioned upon node reference - */ - private void checkTransferSubClass(NodeRef actionedUponNodeRef) - { - QName type = getNodeService().getType(actionedUponNodeRef); - if (!getDictionaryService().isSubClass(type, TYPE_TRANSFER)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_TRANSFER)); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Transfer complete action + * + * @author Roy Wetherall + */ +public class TransferCompleteAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_NODE_NOT_TRANSFER = "rm.action.node-not-transfer"; + + /** Action name */ + public static final String NAME = "transferComplete"; + + /** Transfer service */ + private TransferService transferService; + + /** + * @return transfer service + */ + protected TransferService getTransferService() + { + return this.transferService; + } + + /** + * @param transferService transfer service + */ + public void setTransferService(TransferService transferService) + { + this.transferService = transferService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + checkTransferSubClass(actionedUponNodeRef); + getTransferService().completeTransfer(actionedUponNodeRef); + } + + /** + * Checks if the actioned upon node reference is a sub class of transfer + * + * @param actionedUponNodeRef actioned upon node reference + */ + private void checkTransferSubClass(NodeRef actionedUponNodeRef) + { + QName type = getNodeService().getType(actionedUponNodeRef); + if (!getDictionaryService().isSubClass(type, TYPE_TRANSFER)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_TRANSFER)); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java index f60db31934..3be5646487 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java @@ -1,89 +1,89 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * UnCutoff action implementation - * - * @author Roy Wetherall - */ -public class UnCutoffAction extends RMActionExecuterAbstractBase -{ - /** I18N */ - private static final String MSG_UNDO_NOT_LAST = "rm.action.undo-not-last"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) && - getNodeService().hasAspect(actionedUponNodeRef, ASPECT_CUT_OFF)) - { - // Get the last disposition action - DispositionAction da = getDispositionService().getLastCompletedDispostionAction(actionedUponNodeRef); - - // Check that the last disposition action was a cutoff - if (da == null || !da.getName().equals("cutoff")) - { - // Can not undo cut off since cut off was not the last thing done - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDO_NOT_LAST)); - } - - // Remove the cutoff aspect and add the uncutoff aspect - getNodeService().removeAspect(actionedUponNodeRef, ASPECT_CUT_OFF); - getNodeService().addAspect(actionedUponNodeRef, ASPECT_UNCUT_OFF, null); - if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) - { - List records = getRecordService().getRecords(actionedUponNodeRef); - for (NodeRef record : records) - { - getNodeService().removeAspect(record, ASPECT_CUT_OFF); - getNodeService().addAspect(record, ASPECT_UNCUT_OFF, null); - } - } - - // Delete the current disposition action - DispositionAction currentDa = getDispositionService().getNextDispositionAction(actionedUponNodeRef); - if (currentDa != null) - { - getNodeService().deleteNode(currentDa.getNodeRef()); - } - - // Move the previous (cutoff) disposition back to be current - getNodeService().moveNode(da.getNodeRef(), actionedUponNodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION); - - // Reset the started and completed property values - getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_AT, null); - getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_BY, null); - getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, null); - getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, null); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * UnCutoff action implementation + * + * @author Roy Wetherall + */ +public class UnCutoffAction extends RMActionExecuterAbstractBase +{ + /** I18N */ + private static final String MSG_UNDO_NOT_LAST = "rm.action.undo-not-last"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) && + getNodeService().hasAspect(actionedUponNodeRef, ASPECT_CUT_OFF)) + { + // Get the last disposition action + DispositionAction da = getDispositionService().getLastCompletedDispostionAction(actionedUponNodeRef); + + // Check that the last disposition action was a cutoff + if (da == null || !da.getName().equals("cutoff")) + { + // Can not undo cut off since cut off was not the last thing done + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDO_NOT_LAST)); + } + + // Remove the cutoff aspect and add the uncutoff aspect + getNodeService().removeAspect(actionedUponNodeRef, ASPECT_CUT_OFF); + getNodeService().addAspect(actionedUponNodeRef, ASPECT_UNCUT_OFF, null); + if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) + { + List records = getRecordService().getRecords(actionedUponNodeRef); + for (NodeRef record : records) + { + getNodeService().removeAspect(record, ASPECT_CUT_OFF); + getNodeService().addAspect(record, ASPECT_UNCUT_OFF, null); + } + } + + // Delete the current disposition action + DispositionAction currentDa = getDispositionService().getNextDispositionAction(actionedUponNodeRef); + if (currentDa != null) + { + getNodeService().deleteNode(currentDa.getNodeRef()); + } + + // Move the previous (cutoff) disposition back to be current + getNodeService().moveNode(da.getNodeRef(), actionedUponNodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION); + + // Reset the started and completed property values + getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_AT, null); + getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_BY, null); + getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, null); + getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, null); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndeclareRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndeclareRecordAction.java index 9c5aba4ea3..7d214b83f4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndeclareRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndeclareRecordAction.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Undeclare record action - * - * @author Roy Wetherall - */ -public class UndeclareRecordAction extends RMActionExecuterAbstractBase -{ - /** Logger */ - private static Log logger = LogFactory.getLog(UndeclareRecordAction.class); - - /** I18N */ - private static final String MSG_RECORDS_ONLY_UNDECLARED = "rm.action.records_only_undeclared"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (getNodeService().exists(actionedUponNodeRef)) - { - if (getRecordService().isRecord(actionedUponNodeRef)) - { - // repoen if already complete and not frozen - if (getRecordService().isDeclared(actionedUponNodeRef) && - !getFreezeService().isFrozen(actionedUponNodeRef)) - { - // Remove the declared aspect - this.getNodeService().removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD); - } - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED)); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Undeclare record action + * + * @author Roy Wetherall + */ +public class UndeclareRecordAction extends RMActionExecuterAbstractBase +{ + /** Logger */ + private static Log logger = LogFactory.getLog(UndeclareRecordAction.class); + + /** I18N */ + private static final String MSG_RECORDS_ONLY_UNDECLARED = "rm.action.records_only_undeclared"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (getNodeService().exists(actionedUponNodeRef)) + { + if (getRecordService().isRecord(actionedUponNodeRef)) + { + // repoen if already complete and not frozen + if (getRecordService().isDeclared(actionedUponNodeRef) && + !getFreezeService().isFrozen(actionedUponNodeRef)) + { + // Remove the declared aspect + this.getNodeService().removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD); + } + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED)); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndoEventAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndoEventAction.java index e27f4589e0..53a561c843 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndoEventAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UndoEventAction.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Undo event action - * - * @author Roy Wetherall - * @since 1.0 - */ -public class UndoEventAction extends RMActionExecuterAbstractBase -{ - /** Params */ - public static final String PARAM_EVENT_NAME = "eventName"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); - - if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - // Get the next disposition action - DispositionAction da = this.getDispositionService().getNextDispositionAction(actionedUponNodeRef); - if (da != null) - { - // undo completed event - da.undoEvent(eventName); - } - } - } - - /** - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - // TODO add parameter definitions .... - // eventName - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Undo event action + * + * @author Roy Wetherall + * @since 1.0 + */ +public class UndoEventAction extends RMActionExecuterAbstractBase +{ + /** Params */ + public static final String PARAM_EVENT_NAME = "eventName"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); + + if (this.getNodeService().hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + // Get the next disposition action + DispositionAction da = this.getDispositionService().getNextDispositionAction(actionedUponNodeRef); + if (da != null) + { + // undo completed event + da.undoEvent(eventName); + } + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + @Override + protected void addParameterDefinitions(List paramList) + { + // TODO add parameter definitions .... + // eventName + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnfreezeAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnfreezeAction.java index a69c4478be..b9a1e3f4d7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnfreezeAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnfreezeAction.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unfreeze Action - * - * @author Roy Wetherall - */ -public class UnfreezeAction extends RMActionExecuterAbstractBase -{ - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("deprecation") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - getFreezeService().unFreeze(actionedUponNodeRef); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unfreeze Action + * + * @author Roy Wetherall + */ +public class UnfreezeAction extends RMActionExecuterAbstractBase +{ + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("deprecation") + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + getFreezeService().unFreeze(actionedUponNodeRef); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromAction.java index 91e492ad19..eb36f724c0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromAction.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unlink from action implementation. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class UnlinkFromAction extends RMActionExecuterAbstractBase -{ - /** action name */ - public static final String NAME = "unlinkFrom"; - - /** action parameters */ - public static final String PARAM_RECORD_FOLDER = "recordFolder"; - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // check that the actioned upon node reference exists and is of the correct type - if (getNodeService().exists(actionedUponNodeRef) && - !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && - getRecordService().isRecord(actionedUponNodeRef)) - { - // get the record folder we are unlinking from - String recordFolderValue = (String)action.getParameterValue(PARAM_RECORD_FOLDER); - if (recordFolderValue == null || recordFolderValue.isEmpty()) - { - // indicate that the record folder is mandatory - throw new AlfrescoRuntimeException("Can't unlink, because no record folder was provided."); - } - NodeRef recordFolder = new NodeRef(recordFolderValue); - - // unlink record from record folder - getRecordService().unlink(actionedUponNodeRef, recordFolder); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unlink from action implementation. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class UnlinkFromAction extends RMActionExecuterAbstractBase +{ + /** action name */ + public static final String NAME = "unlinkFrom"; + + /** action parameters */ + public static final String PARAM_RECORD_FOLDER = "recordFolder"; + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // check that the actioned upon node reference exists and is of the correct type + if (getNodeService().exists(actionedUponNodeRef) && + !getNodeService().hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) && + getRecordService().isRecord(actionedUponNodeRef)) + { + // get the record folder we are unlinking from + String recordFolderValue = (String)action.getParameterValue(PARAM_RECORD_FOLDER); + if (recordFolderValue == null || recordFolderValue.isEmpty()) + { + // indicate that the record folder is mandatory + throw new AlfrescoRuntimeException("Can't unlink, because no record folder was provided."); + } + NodeRef recordFolder = new NodeRef(recordFolderValue); + + // unlink record from record folder + getRecordService().unlink(actionedUponNodeRef, recordFolder); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CannotApplyConstraintMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CannotApplyConstraintMetadataException.java index e91ce04574..0f265346cc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CannotApplyConstraintMetadataException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CannotApplyConstraintMetadataException.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Custom metadata exception. - * - * @author Roy Wethearll - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.CannotApplyConstraintMetadataException - */ -public class CannotApplyConstraintMetadataException extends CustomMetadataException -{ - private static final long serialVersionUID = -6194867814140009959L; - public static final String MSG_CANNOT_APPLY_CONSTRAINT = "rm.admin.cannot-apply-constraint"; - - public CannotApplyConstraintMetadataException(QName lovConstraint, String propIdAsString, QName dataType) - { - super(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, lovConstraint, propIdAsString, dataType)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Custom metadata exception. + * + * @author Roy Wethearll + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.CannotApplyConstraintMetadataException + */ +public class CannotApplyConstraintMetadataException extends CustomMetadataException +{ + private static final long serialVersionUID = -6194867814140009959L; + public static final String MSG_CANNOT_APPLY_CONSTRAINT = "rm.admin.cannot-apply-constraint"; + + public CannotApplyConstraintMetadataException(QName lovConstraint, String propIdAsString, QName dataType) + { + super(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, lovConstraint, propIdAsString, dataType)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CustomMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CustomMetadataException.java index 3dbdbaa1df..0abe96fd9b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CustomMetadataException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/CustomMetadataException.java @@ -1,36 +1,36 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -/** - * Custom metadata exception. - * - * @author Roy Wethearll - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.CustomMetadataException - */ -public abstract class CustomMetadataException extends Exception -{ - private static final long serialVersionUID = -6676112294794381360L; - - public CustomMetadataException(String msg) - { - super(msg); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +/** + * Custom metadata exception. + * + * @author Roy Wethearll + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.CustomMetadataException + */ +public abstract class CustomMetadataException extends Exception +{ + private static final long serialVersionUID = -6676112294794381360L; + + public CustomMetadataException(String msg) + { + super(msg); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/InvalidCustomAspectMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/InvalidCustomAspectMetadataException.java index 0a84a7a7a0..f7f2084a2d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/InvalidCustomAspectMetadataException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/InvalidCustomAspectMetadataException.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Custom metadata exception. - * - * @author Roy Wethearll - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.InvalidCustomAspectMetadataException - */ -public class InvalidCustomAspectMetadataException extends CustomMetadataException -{ - private static final long serialVersionUID = -6194867814140009959L; - public static final String MSG_INVALID_CUSTOM_ASPECT = "rm.admin.invalid-custom-aspect"; - - public InvalidCustomAspectMetadataException(QName customAspect, String aspectName) - { - super(I18NUtil.getMessage(MSG_INVALID_CUSTOM_ASPECT, customAspect, aspectName)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Custom metadata exception. + * + * @author Roy Wethearll + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.InvalidCustomAspectMetadataException + */ +public class InvalidCustomAspectMetadataException extends CustomMetadataException +{ + private static final long serialVersionUID = -6194867814140009959L; + public static final String MSG_INVALID_CUSTOM_ASPECT = "rm.admin.invalid-custom-aspect"; + + public InvalidCustomAspectMetadataException(QName customAspect, String aspectName) + { + super(I18NUtil.getMessage(MSG_INVALID_CUSTOM_ASPECT, customAspect, aspectName)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/NotCustomisableMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/NotCustomisableMetadataException.java index bc7b2e99d9..70e2b3f03b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/NotCustomisableMetadataException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/NotCustomisableMetadataException.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Custom metadata exception. - * - * @author Roy Wethearll - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.NotCustomisableMetadataException - */ -public class NotCustomisableMetadataException extends CustomMetadataException -{ - private static final long serialVersionUID = -6194867814140009959L; - public static final String MSG_NOT_CUSTOMISABLE = "rm.admin.not-customisable"; - - public NotCustomisableMetadataException(String aspectName) - { - super(I18NUtil.getMessage(MSG_NOT_CUSTOMISABLE, aspectName)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Custom metadata exception. + * + * @author Roy Wethearll + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.NotCustomisableMetadataException + */ +public class NotCustomisableMetadataException extends CustomMetadataException +{ + private static final long serialVersionUID = -6194867814140009959L; + public static final String MSG_NOT_CUSTOMISABLE = "rm.admin.not-customisable"; + + public NotCustomisableMetadataException(String aspectName) + { + super(I18NUtil.getMessage(MSG_NOT_CUSTOMISABLE, aspectName)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/PropertyAlreadyExistsMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/PropertyAlreadyExistsMetadataException.java index ffd9ec39f1..dcb37a262c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/PropertyAlreadyExistsMetadataException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/PropertyAlreadyExistsMetadataException.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Custom metadata exception. - * - * @author Roy Wethearll - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.PropertyAlreadyExistsMetadataException - */ -public class PropertyAlreadyExistsMetadataException extends CustomMetadataException -{ - private static final long serialVersionUID = -6194867814140009959L; - - public static final String MSG_PROPERTY_ALREADY_EXISTS = "rm.admin.property-already-exists"; - - public PropertyAlreadyExistsMetadataException(String propIdAsString) - { - super(I18NUtil.getMessage(MSG_PROPERTY_ALREADY_EXISTS, propIdAsString)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Custom metadata exception. + * + * @author Roy Wethearll + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.PropertyAlreadyExistsMetadataException + */ +public class PropertyAlreadyExistsMetadataException extends CustomMetadataException +{ + private static final long serialVersionUID = -6194867814140009959L; + + public static final String MSG_PROPERTY_ALREADY_EXISTS = "rm.admin.property-already-exists"; + + public PropertyAlreadyExistsMetadataException(String propIdAsString) + { + super(I18NUtil.getMessage(MSG_PROPERTY_ALREADY_EXISTS, propIdAsString)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminBase.java index 32a0c37f5c..44b7154a18 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminBase.java @@ -1,376 +1,376 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.dictionary.DictionaryRepositoryBootstrap; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.dictionary.M2Namespace; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryException; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -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.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Base class for RM admin services - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordsManagementAdminBase implements RecordsManagementCustomModel -{ - /** Logger */ - protected Log logger = LogFactory.getLog(this.getClass()); - - /** Constants */ - private static final String SOURCE_TARGET_ID_SEPARATOR = "__"; - private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model"); - - /** I18N */ - private static final String MSG_CUSTOM_MODEL_NOT_FOUND = "rm.admin.custom-model-not-found"; - private static final String MSG_CUSTOM_MODEL_NO_CONTENT = "rm.admin.custom-model-no-content"; - private static final String MSG_ERROR_WRITE_CUSTOM_MODEL = "rm.admin.error-write-custom-model"; - private static final String MSG_ERROR_SPLIT_ID = "rm.admin.error-split-id"; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Node service */ - private NodeService nodeService; - - /** Content service */ - private ContentService contentService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Dictionary repository bootstrap */ - private DictionaryRepositoryBootstrap dictionaryRepositoryBootstrap; - - /** - * Gets the dictionary service instance - * - * @return The dictionary service instance - */ - protected DictionaryService getDictionaryService() - { - return this.dictionaryService; - } - - /** - * Gets the node service instance - * - * @return The node service instance - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Gets the content service instance - * - * @return The content service instance - */ - protected ContentService getContentService() - { - return this.contentService; - } - - /** - * Gets the namespace service instance - * - * @return The namespace service instance - */ - protected NamespaceService getNamespaceService() - { - return this.namespaceService; - } - - /** - * Gets the dictionary repository bootstrap instance - * - * @return The dictionary repository bootstrap instance - */ - protected DictionaryRepositoryBootstrap getDictionaryRepositoryBootstrap() - { - return this.dictionaryRepositoryBootstrap; - } - - /** - * Sets the dictionary service instance - * - * @param dictionaryService The dictionary service instance - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Sets the node service instance - * - * @param nodeService The node service instance - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Sets the content service instance - * - * @param contentService The content service instance - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Sets the namespace service instance - * - * @param namespaceService The namespace service instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Sets the dictionary repository bootstrap instance - * - * @param dictionaryRepositoryBootstrap The dictionary repository bootstrap instance - */ - public void setDictionaryRepositoryBootstrap(DictionaryRepositoryBootstrap dictionaryRepositoryBootstrap) - { - this.dictionaryRepositoryBootstrap = dictionaryRepositoryBootstrap; - } - - /** - * Gets all the custom associations - * - * @return All custom associations - */ - protected Map getCustomAssociations() - { - Map customAssociations = new HashMap(); - - AspectDefinition aspectDefn = getDictionaryService().getAspect(ASPECT_CUSTOM_ASSOCIATIONS); - if (aspectDefn != null) - { - customAssociations.putAll(aspectDefn.getAssociations()); - } - - return customAssociations; - } - - /** - * Gets the node reference of the custom model - * - * @param uri The URI of the model namespace - * @return The node reference of the custom model - */ - protected NodeRef getCustomModelRef(String uri) - { - if ((uri.equals("")) || (uri.equals(RecordsManagementModel.RM_CUSTOM_URI))) - { - // note: short-cut for "rmc" currently assumes that RM custom model does not define additional namespaces - return RM_CUSTOM_MODEL_NODE_REF; - } - else - { - // ALF-5875 - List modelRefs = getDictionaryRepositoryBootstrap().getModelRefs(); - - for (NodeRef modelRef : modelRefs) - { - try - { - M2Model model = readCustomContentModel(modelRef); - - for (M2Namespace namespace : model.getNamespaces()) - { - if (namespace.getUri().equals(uri)) - { - return modelRef; - } - } - } - catch (DictionaryException de) - { - logger.warn("readCustomContentModel: skip model ("+modelRef+") whilst searching for uri ("+uri+"): ", de); - } - } - - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NOT_FOUND, uri)); - } - } - - /** - * Gets the deserialized model - * - * @param modelNodeRef The node reference of the model - * @return The deserialized model - */ - protected M2Model readCustomContentModel(NodeRef modelNodeRef) - { - ContentReader reader = getContentService().getReader(modelNodeRef, ContentModel.TYPE_CONTENT); - if (!reader.exists()) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NO_CONTENT, modelNodeRef.toString())); - } - - InputStream contentIn = null; - M2Model deserializedModel = null; - - try - { - contentIn = reader.getContentInputStream(); - deserializedModel = M2Model.createModel(contentIn); - } - finally - { - try - { - if (contentIn != null) - { - contentIn.close(); - } - } - catch (IOException ignored) - { - // Intentionally empty. - } - } - - return deserializedModel; - } - - /** - * Updates the content of the custom model - * - * @param modelRef The node reference of the model - * @param deserializedModel The deserialized model - */ - protected void writeCustomContentModel(NodeRef modelRef, M2Model deserializedModel) - { - ContentWriter writer = getContentService().getWriter(modelRef, ContentModel.TYPE_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_XML); - writer.setEncoding("UTF-8"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - deserializedModel.toXML(baos); - - String updatedModelXml; - try - { - updatedModelXml = baos.toString("UTF-8"); - writer.putContent(updatedModelXml); - // putContent closes all resources. - // so we don't have to. - } - catch (UnsupportedEncodingException uex) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ERROR_WRITE_CUSTOM_MODEL, modelRef.toString()), uex); - } - } - - /** - * Checks if the given association definition title exists - * - * @param associationDefinitionTitle The association definition title - * @return true if the association definition title exists, false otherwise - */ - protected boolean existsTitle(String associationDefinitionTitle) - { - boolean existsLabel = false; - Collection associationDefinitions = getCustomAssociations().values(); - for (AssociationDefinition associationDefinition : associationDefinitions) - { - if (associationDefinition.getTitle(getDictionaryService()).equalsIgnoreCase(associationDefinitionTitle)) - { - existsLabel = true; - } - } - return existsLabel; - } - - /** - * Splits the association definition title into source text and target text - * - * @param sourceTargetText The text to split into source text and target text - * @return Splited association definition title which includes source text and target text - */ - protected String[] splitAssociationDefinitionTitle(String sourceTargetText) - { - if (!sourceTargetText.contains(SOURCE_TARGET_ID_SEPARATOR)) - { - throw new IllegalArgumentException(I18NUtil.getMessage(MSG_ERROR_SPLIT_ID, sourceTargetText, SOURCE_TARGET_ID_SEPARATOR)); - } - - return sourceTargetText.split(SOURCE_TARGET_ID_SEPARATOR); - } - - /** - * Creates the association definition title form the source text and target text - * - * @param sourceText The source text - * @param targetText The target text - * @return The association definition title created from the source text and target text - */ - protected String composeAssociationDefinitionTitle(String sourceText, String targetText) - { - if (sourceText.contains(SOURCE_TARGET_ID_SEPARATOR)) - { - throw new IllegalArgumentException("sourceId cannot contain '" + SOURCE_TARGET_ID_SEPARATOR + "': " + sourceText); - } - - StringBuilder sb = new StringBuilder(); - sb.append(sourceText) - .append(SOURCE_TARGET_ID_SEPARATOR) - .append(targetText); - - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.dictionary.DictionaryRepositoryBootstrap; +import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.repo.dictionary.M2Namespace; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryException; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +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.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Base class for RM admin services + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordsManagementAdminBase implements RecordsManagementCustomModel +{ + /** Logger */ + protected Log logger = LogFactory.getLog(this.getClass()); + + /** Constants */ + private static final String SOURCE_TARGET_ID_SEPARATOR = "__"; + private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model"); + + /** I18N */ + private static final String MSG_CUSTOM_MODEL_NOT_FOUND = "rm.admin.custom-model-not-found"; + private static final String MSG_CUSTOM_MODEL_NO_CONTENT = "rm.admin.custom-model-no-content"; + private static final String MSG_ERROR_WRITE_CUSTOM_MODEL = "rm.admin.error-write-custom-model"; + private static final String MSG_ERROR_SPLIT_ID = "rm.admin.error-split-id"; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** Node service */ + private NodeService nodeService; + + /** Content service */ + private ContentService contentService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Dictionary repository bootstrap */ + private DictionaryRepositoryBootstrap dictionaryRepositoryBootstrap; + + /** + * Gets the dictionary service instance + * + * @return The dictionary service instance + */ + protected DictionaryService getDictionaryService() + { + return this.dictionaryService; + } + + /** + * Gets the node service instance + * + * @return The node service instance + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Gets the content service instance + * + * @return The content service instance + */ + protected ContentService getContentService() + { + return this.contentService; + } + + /** + * Gets the namespace service instance + * + * @return The namespace service instance + */ + protected NamespaceService getNamespaceService() + { + return this.namespaceService; + } + + /** + * Gets the dictionary repository bootstrap instance + * + * @return The dictionary repository bootstrap instance + */ + protected DictionaryRepositoryBootstrap getDictionaryRepositoryBootstrap() + { + return this.dictionaryRepositoryBootstrap; + } + + /** + * Sets the dictionary service instance + * + * @param dictionaryService The dictionary service instance + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Sets the node service instance + * + * @param nodeService The node service instance + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Sets the content service instance + * + * @param contentService The content service instance + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * Sets the namespace service instance + * + * @param namespaceService The namespace service instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Sets the dictionary repository bootstrap instance + * + * @param dictionaryRepositoryBootstrap The dictionary repository bootstrap instance + */ + public void setDictionaryRepositoryBootstrap(DictionaryRepositoryBootstrap dictionaryRepositoryBootstrap) + { + this.dictionaryRepositoryBootstrap = dictionaryRepositoryBootstrap; + } + + /** + * Gets all the custom associations + * + * @return All custom associations + */ + protected Map getCustomAssociations() + { + Map customAssociations = new HashMap(); + + AspectDefinition aspectDefn = getDictionaryService().getAspect(ASPECT_CUSTOM_ASSOCIATIONS); + if (aspectDefn != null) + { + customAssociations.putAll(aspectDefn.getAssociations()); + } + + return customAssociations; + } + + /** + * Gets the node reference of the custom model + * + * @param uri The URI of the model namespace + * @return The node reference of the custom model + */ + protected NodeRef getCustomModelRef(String uri) + { + if ((uri.equals("")) || (uri.equals(RecordsManagementModel.RM_CUSTOM_URI))) + { + // note: short-cut for "rmc" currently assumes that RM custom model does not define additional namespaces + return RM_CUSTOM_MODEL_NODE_REF; + } + else + { + // ALF-5875 + List modelRefs = getDictionaryRepositoryBootstrap().getModelRefs(); + + for (NodeRef modelRef : modelRefs) + { + try + { + M2Model model = readCustomContentModel(modelRef); + + for (M2Namespace namespace : model.getNamespaces()) + { + if (namespace.getUri().equals(uri)) + { + return modelRef; + } + } + } + catch (DictionaryException de) + { + logger.warn("readCustomContentModel: skip model ("+modelRef+") whilst searching for uri ("+uri+"): ", de); + } + } + + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NOT_FOUND, uri)); + } + } + + /** + * Gets the deserialized model + * + * @param modelNodeRef The node reference of the model + * @return The deserialized model + */ + protected M2Model readCustomContentModel(NodeRef modelNodeRef) + { + ContentReader reader = getContentService().getReader(modelNodeRef, ContentModel.TYPE_CONTENT); + if (!reader.exists()) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NO_CONTENT, modelNodeRef.toString())); + } + + InputStream contentIn = null; + M2Model deserializedModel = null; + + try + { + contentIn = reader.getContentInputStream(); + deserializedModel = M2Model.createModel(contentIn); + } + finally + { + try + { + if (contentIn != null) + { + contentIn.close(); + } + } + catch (IOException ignored) + { + // Intentionally empty. + } + } + + return deserializedModel; + } + + /** + * Updates the content of the custom model + * + * @param modelRef The node reference of the model + * @param deserializedModel The deserialized model + */ + protected void writeCustomContentModel(NodeRef modelRef, M2Model deserializedModel) + { + ContentWriter writer = getContentService().getWriter(modelRef, ContentModel.TYPE_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_XML); + writer.setEncoding("UTF-8"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + deserializedModel.toXML(baos); + + String updatedModelXml; + try + { + updatedModelXml = baos.toString("UTF-8"); + writer.putContent(updatedModelXml); + // putContent closes all resources. + // so we don't have to. + } + catch (UnsupportedEncodingException uex) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ERROR_WRITE_CUSTOM_MODEL, modelRef.toString()), uex); + } + } + + /** + * Checks if the given association definition title exists + * + * @param associationDefinitionTitle The association definition title + * @return true if the association definition title exists, false otherwise + */ + protected boolean existsTitle(String associationDefinitionTitle) + { + boolean existsLabel = false; + Collection associationDefinitions = getCustomAssociations().values(); + for (AssociationDefinition associationDefinition : associationDefinitions) + { + if (associationDefinition.getTitle(getDictionaryService()).equalsIgnoreCase(associationDefinitionTitle)) + { + existsLabel = true; + } + } + return existsLabel; + } + + /** + * Splits the association definition title into source text and target text + * + * @param sourceTargetText The text to split into source text and target text + * @return Splited association definition title which includes source text and target text + */ + protected String[] splitAssociationDefinitionTitle(String sourceTargetText) + { + if (!sourceTargetText.contains(SOURCE_TARGET_ID_SEPARATOR)) + { + throw new IllegalArgumentException(I18NUtil.getMessage(MSG_ERROR_SPLIT_ID, sourceTargetText, SOURCE_TARGET_ID_SEPARATOR)); + } + + return sourceTargetText.split(SOURCE_TARGET_ID_SEPARATOR); + } + + /** + * Creates the association definition title form the source text and target text + * + * @param sourceText The source text + * @param targetText The target text + * @return The association definition title created from the source text and target text + */ + protected String composeAssociationDefinitionTitle(String sourceText, String targetText) + { + if (sourceText.contains(SOURCE_TARGET_ID_SEPARATOR)) + { + throw new IllegalArgumentException("sourceId cannot contain '" + SOURCE_TARGET_ID_SEPARATOR + "': " + sourceText); + } + + StringBuilder sb = new StringBuilder(); + sb.append(sourceText) + .append(SOURCE_TARGET_ID_SEPARATOR) + .append(targetText); + + return sb.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminService.java index 168f80ebf2..5215342682 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminService.java @@ -1,418 +1,418 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.ConstraintDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Records management custom model service interface. Implementations of this class are responsible - * for the creation and maintenance of RM-related custom properties and custom associations. - * - * @author Neil McErlean, janv - * @since 2.1 - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService - */ -public interface RecordsManagementAdminService -{ - /** - * Get a list of all registered customisable types and aspects. - * - * @return {@link Set}<{@link QName}> QName's of customisable types and aspects - */ - Set getCustomisable(); - - /** - * Get a list of all the registered customisable types and aspects present on a given - * node reference. - * - * @param nodeRef node reference - * @return {@link Set}<{@link QName}> QName's of customisable types and aspects, empty if none - */ - Set getCustomisable(NodeRef nodeRef); - - /** - * Indicates whether a type (or aspect) is customisable. - * - * @param type customisable type {@link QName} - * @return boolean true if type customisable, false otherwise - */ - boolean isCustomisable(QName type); - - /** - * Makes a type customisable. - * - * @param type type {@link QName} to make customisable - */ - void makeCustomisable(QName type); - - /** - * Assuming the custom properties are not in use, makes a type no longer customisable. - * - * @param type type {@link QName} to make customisable - */ - void unmakeCustomisable(QName type); - - /** - * Indicates whether the custom property exists. - * - * @param property properties {@link QName} - * @return boolean true if property exists, false otherwise - */ - boolean existsCustomProperty(QName property); - - /** - * This method returns the custom properties that have been defined for the specified - * customisable RM element. - *

- * Note: the custom property definitions are retrieved from the dictionaryService - * which is notified of any newly created definitions on transaction commit. - * Therefore custom properties created in the current transaction will not appear - * in the result of this method. - * - * @param customisedElement - * @return - * @see CustomisableRmElement - */ - Map getCustomPropertyDefinitions(QName customisableType); - - /** - * This method returns the custom properties that have been defined for all of - * the specified customisable RM elements. - * Note: the custom property definitions are retrieved from the dictionaryService - * which is notified of any newly created definitions on transaction commit. - * Therefore custom properties created in the current transaction will not appear - * in the result of this method. - * - * @return - * @see CustomisableRmElement - */ - Map getCustomPropertyDefinitions(); - - /** - * Add custom property definition - * - * Note: no default value, single valued, optional, not system protected, no constraints - * - * @param propId - If a value for propId is provided it will be used to identify property definitions - * within URLs and in QNames. Therefore it must contain URL/QName-valid characters - * only. It must also be unique. - * If a null value is passed, an id will be generated. - * @param aspectName - mandatory. The aspect within which the property is to be defined. - * This must be one of the CustomisableRmElements. - * @param label - mandatory - * @param dataType - mandatory - * @param title - optional - * @param description - optional - * - * @return the propId, whether supplied as a parameter or generated. - * @see CustomisableRmElement#getCorrespondingAspect() - */ - QName addCustomPropertyDefinition(QName propId, QName typeName, String label, QName dataType, String title, String description) throws CustomMetadataException; - - /** - * Add custom property definition with one optional constraint reference - * - * @param propId - If a value for propId is provided it will be used to identify property definitions - * within URLs and in QNames. Therefore it must contain URL/QName-valid characters - * only. It must also be unique. - * If a null value is passed, an id will be generated. - * @param aspectName - mandatory. The aspect within which the property is to be defined. - * This must be one of the CustomisableRmElements. - * @param label - mandatory - * @param dataType - mandatory - * @param title - optional - * @param description - optional - * @param defaultValue - optional - * @param multiValued - TRUE if multi-valued property - * @param mandatory - TRUE if mandatory property - * @param isProtected - TRUE if protected property - * @param lovConstraintQName - optional custom constraint - * - * @return the propId, whether supplied as a parameter or generated. - * @see CustomisableRmElement#getCorrespondingAspect() - */ - - // TODO propId string (not QName) ? - // TODO remove title (since it is ignored) (or remove label to title) - - QName addCustomPropertyDefinition(QName propId, - QName typeName, - String label, - QName dataType, - String title, - String description, - String defaultValue, - boolean multiValued, - boolean mandatory, - boolean isProtected, - QName lovConstraintQName) throws CustomMetadataException; - - /** - * Update the custom property definition's label (title). - * - * @param propQName the qname of the property definition - * @param newLabel the new value for the label. - * @return the propId. - */ - QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) throws PropertyAlreadyExistsMetadataException; - - /** - * Update the name and label of the custom property definition. - * @param propQName The qname of the existing property definition - * @param newName THe new name for both the custom property and its label. - * @return - * @throws CustomMetadataException - */ - QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException; - - /** - * Sets a new list of values constraint on the custom property definition. - * - * @param propQName the qname of the property definition - * @param newLovConstraint the List-Of-Values constraintRef. - * @return the propId. - */ - QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint); - - /** - * Removes all list of values constraints from the custom property definition. - * - * @param propQName the qname of the property definition - * @return the propId. - */ - QName removeCustomPropertyDefinitionConstraints(QName propQName); +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; - /** +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.ConstraintDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Records management custom model service interface. Implementations of this class are responsible + * for the creation and maintenance of RM-related custom properties and custom associations. + * + * @author Neil McErlean, janv + * @since 2.1 + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService + */ +public interface RecordsManagementAdminService +{ + /** + * Get a list of all registered customisable types and aspects. + * + * @return {@link Set}<{@link QName}> QName's of customisable types and aspects + */ + Set getCustomisable(); + + /** + * Get a list of all the registered customisable types and aspects present on a given + * node reference. + * + * @param nodeRef node reference + * @return {@link Set}<{@link QName}> QName's of customisable types and aspects, empty if none + */ + Set getCustomisable(NodeRef nodeRef); + + /** + * Indicates whether a type (or aspect) is customisable. + * + * @param type customisable type {@link QName} + * @return boolean true if type customisable, false otherwise + */ + boolean isCustomisable(QName type); + + /** + * Makes a type customisable. + * + * @param type type {@link QName} to make customisable + */ + void makeCustomisable(QName type); + + /** + * Assuming the custom properties are not in use, makes a type no longer customisable. + * + * @param type type {@link QName} to make customisable + */ + void unmakeCustomisable(QName type); + + /** + * Indicates whether the custom property exists. + * + * @param property properties {@link QName} + * @return boolean true if property exists, false otherwise + */ + boolean existsCustomProperty(QName property); + + /** + * This method returns the custom properties that have been defined for the specified + * customisable RM element. + *

+ * Note: the custom property definitions are retrieved from the dictionaryService + * which is notified of any newly created definitions on transaction commit. + * Therefore custom properties created in the current transaction will not appear + * in the result of this method. + * + * @param customisedElement + * @return + * @see CustomisableRmElement + */ + Map getCustomPropertyDefinitions(QName customisableType); + + /** + * This method returns the custom properties that have been defined for all of + * the specified customisable RM elements. + * Note: the custom property definitions are retrieved from the dictionaryService + * which is notified of any newly created definitions on transaction commit. + * Therefore custom properties created in the current transaction will not appear + * in the result of this method. + * + * @return + * @see CustomisableRmElement + */ + Map getCustomPropertyDefinitions(); + + /** + * Add custom property definition + * + * Note: no default value, single valued, optional, not system protected, no constraints + * + * @param propId - If a value for propId is provided it will be used to identify property definitions + * within URLs and in QNames. Therefore it must contain URL/QName-valid characters + * only. It must also be unique. + * If a null value is passed, an id will be generated. + * @param aspectName - mandatory. The aspect within which the property is to be defined. + * This must be one of the CustomisableRmElements. + * @param label - mandatory + * @param dataType - mandatory + * @param title - optional + * @param description - optional + * + * @return the propId, whether supplied as a parameter or generated. + * @see CustomisableRmElement#getCorrespondingAspect() + */ + QName addCustomPropertyDefinition(QName propId, QName typeName, String label, QName dataType, String title, String description) throws CustomMetadataException; + + /** + * Add custom property definition with one optional constraint reference + * + * @param propId - If a value for propId is provided it will be used to identify property definitions + * within URLs and in QNames. Therefore it must contain URL/QName-valid characters + * only. It must also be unique. + * If a null value is passed, an id will be generated. + * @param aspectName - mandatory. The aspect within which the property is to be defined. + * This must be one of the CustomisableRmElements. + * @param label - mandatory + * @param dataType - mandatory + * @param title - optional + * @param description - optional + * @param defaultValue - optional + * @param multiValued - TRUE if multi-valued property + * @param mandatory - TRUE if mandatory property + * @param isProtected - TRUE if protected property + * @param lovConstraintQName - optional custom constraint + * + * @return the propId, whether supplied as a parameter or generated. + * @see CustomisableRmElement#getCorrespondingAspect() + */ + + // TODO propId string (not QName) ? + // TODO remove title (since it is ignored) (or remove label to title) + + QName addCustomPropertyDefinition(QName propId, + QName typeName, + String label, + QName dataType, + String title, + String description, + String defaultValue, + boolean multiValued, + boolean mandatory, + boolean isProtected, + QName lovConstraintQName) throws CustomMetadataException; + + /** + * Update the custom property definition's label (title). + * + * @param propQName the qname of the property definition + * @param newLabel the new value for the label. + * @return the propId. + */ + QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) throws PropertyAlreadyExistsMetadataException; + + /** + * Update the name and label of the custom property definition. + * @param propQName The qname of the existing property definition + * @param newName THe new name for both the custom property and its label. + * @return + * @throws CustomMetadataException + */ + QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException; + + /** + * Sets a new list of values constraint on the custom property definition. + * + * @param propQName the qname of the property definition + * @param newLovConstraint the List-Of-Values constraintRef. + * @return the propId. + */ + QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint); + + /** + * Removes all list of values constraints from the custom property definition. + * + * @param propQName the qname of the property definition + * @return the propId. + */ + QName removeCustomPropertyDefinitionConstraints(QName propQName); + + /** * Remove custom property definition - * - * @param propQName - */ - void removeCustomPropertyDefinition(QName propQName); - - /** - * This method returns the custom references that have been defined in the custom - * model. - * Note: the custom reference definitions are retrieved from the dictionaryService - * which is notified of any newly created definitions on transaction commit. - * Therefore custom references created in the current transaction will not appear - * in the results. - * - * @return The Map of custom references (both parent-child and standard). - * @deprecated as of RM 2.3, please use {@link RelationshipService#getRelationshipDefinitions()} instead. - */ - Map getCustomReferenceDefinitions(); - - /** - * Fetches all associations from the given source. - * - * @param node the node from which the associations start. - * @return a List of associations. - * @deprecated as of RM 2.3, please use {@link NodeService#getTargetAssocs(NodeRef, RegexQNamePattern.MATCH_ALL)} instead. - */ - List getCustomReferencesFrom(NodeRef node); - - /** - * Fetches all child associations of the given source. i.e. all associations where the - * given node is the parent. - * - * @param node - * @return - * @deprecated as of RM 2.3, please use {@link NodeService#getChildAssocs(NodeRef)} instead. - */ - List getCustomChildReferences(NodeRef node); - - /** - * Returns a List of all associations to the given node. - * - * @param node the node to which the associations point. - * @return a List of associations. - * @deprecated as of RM 2.3, please use {@link NodeService#getSourceAssocs(NodeRef, RegexQNamePattern.MATCH_ALL)} instead. - */ - List getCustomReferencesTo(NodeRef node); - - /** - * Fetches all child associations where the given node is the child. - * - * @param node - * @return - * @deprecated as of RM 2.3, please use {@link NodeService#getParentAssocs(NodeRef)} instead. - */ - List getCustomParentReferences(NodeRef node); - - /** - * This method adds the specified custom reference instance between the specified nodes. - * Only one instance of any custom reference type is allowed in a given direction - * between two given records. - * - * @param fromNode - * @param toNode - * @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567 - * @throws AlfrescoRuntimeException if an instance of the specified reference type - * already exists from fromNode to toNode. - * @deprecated as of RM 2.3, please use {@link RelationshipService#addRelationship(String, NodeRef, NodeRef)} instead. - */ - void addCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId); - - /** - * This method removes the specified custom reference instance from the specified node. - * - * @param fromNode - * @param toNode - * @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567 - * @deprecated as of RM 2.3, please use {@link RelationshipService#removeRelationship(String, NodeRef, NodeRef)} instead. - */ - void removeCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId); - - /** - * This method creates a new custom association, using the given label as the title. - * - * @param label the title of the association definition - * @return the QName of the newly-created association. - * @deprecated as of RM 2.3, please use {@link RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. - */ - QName addCustomAssocDefinition(String label); - - /** - * This method creates a new custom child association, combining the given source and - * target and using the combined String as the title. - * - * @param source - * @param target - * @return the QName of the newly-created association. - * @deprecated as of RM 2.3, please use {@link RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. - */ - QName addCustomChildAssocDefinition(String source, String target); - - /** - * This method updates the source and target values for the specified child association. - * The source and target will be combined into a single string and stored in the title property. - * Source and target are String metadata for RM parent/child custom references. - * - * @param refQName qname of the child association. - * @param newSource the new value for the source field. - * @param newTarget the new value for the target field. - * @see #getCompoundIdFor(String, String) - * @see #splitSourceTargetId(String) - * @deprecated as of RM 2.3, please use {@link RelationshipService#updateRelationshipDefinition(String, org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. - */ - QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget); - - /** - * This method updates the label value for the specified association. - * The label will be stored in the title property. - * Label is String metadata for bidirectional custom references. - * - * @param refQName qname of the child association. - * @param newLabel the new value for the label field. - * @deprecated as of RM 2.3, please use {@link RelationshipService#updateRelationshipDefinition(String, org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. - */ - QName updateCustomAssocDefinition(QName refQName, String newLabel); + * + * @param propQName + */ + void removeCustomPropertyDefinition(QName propQName); - /** + /** + * This method returns the custom references that have been defined in the custom + * model. + * Note: the custom reference definitions are retrieved from the dictionaryService + * which is notified of any newly created definitions on transaction commit. + * Therefore custom references created in the current transaction will not appear + * in the results. + * + * @return The Map of custom references (both parent-child and standard). + * @deprecated as of RM 2.3, please use {@link RelationshipService#getRelationshipDefinitions()} instead. + */ + Map getCustomReferenceDefinitions(); + + /** + * Fetches all associations from the given source. + * + * @param node the node from which the associations start. + * @return a List of associations. + * @deprecated as of RM 2.3, please use {@link NodeService#getTargetAssocs(NodeRef, RegexQNamePattern.MATCH_ALL)} instead. + */ + List getCustomReferencesFrom(NodeRef node); + + /** + * Fetches all child associations of the given source. i.e. all associations where the + * given node is the parent. + * + * @param node + * @return + * @deprecated as of RM 2.3, please use {@link NodeService#getChildAssocs(NodeRef)} instead. + */ + List getCustomChildReferences(NodeRef node); + + /** + * Returns a List of all associations to the given node. + * + * @param node the node to which the associations point. + * @return a List of associations. + * @deprecated as of RM 2.3, please use {@link NodeService#getSourceAssocs(NodeRef, RegexQNamePattern.MATCH_ALL)} instead. + */ + List getCustomReferencesTo(NodeRef node); + + /** + * Fetches all child associations where the given node is the child. + * + * @param node + * @return + * @deprecated as of RM 2.3, please use {@link NodeService#getParentAssocs(NodeRef)} instead. + */ + List getCustomParentReferences(NodeRef node); + + /** + * This method adds the specified custom reference instance between the specified nodes. + * Only one instance of any custom reference type is allowed in a given direction + * between two given records. + * + * @param fromNode + * @param toNode + * @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567 + * @throws AlfrescoRuntimeException if an instance of the specified reference type + * already exists from fromNode to toNode. + * @deprecated as of RM 2.3, please use {@link RelationshipService#addRelationship(String, NodeRef, NodeRef)} instead. + */ + void addCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId); + + /** + * This method removes the specified custom reference instance from the specified node. + * + * @param fromNode + * @param toNode + * @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567 + * @deprecated as of RM 2.3, please use {@link RelationshipService#removeRelationship(String, NodeRef, NodeRef)} instead. + */ + void removeCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId); + + /** + * This method creates a new custom association, using the given label as the title. + * + * @param label the title of the association definition + * @return the QName of the newly-created association. + * @deprecated as of RM 2.3, please use {@link RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. + */ + QName addCustomAssocDefinition(String label); + + /** + * This method creates a new custom child association, combining the given source and + * target and using the combined String as the title. + * + * @param source + * @param target + * @return the QName of the newly-created association. + * @deprecated as of RM 2.3, please use {@link RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. + */ + QName addCustomChildAssocDefinition(String source, String target); + + /** + * This method updates the source and target values for the specified child association. + * The source and target will be combined into a single string and stored in the title property. + * Source and target are String metadata for RM parent/child custom references. + * + * @param refQName qname of the child association. + * @param newSource the new value for the source field. + * @param newTarget the new value for the target field. + * @see #getCompoundIdFor(String, String) + * @see #splitSourceTargetId(String) + * @deprecated as of RM 2.3, please use {@link RelationshipService#updateRelationshipDefinition(String, org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. + */ + QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget); + + /** + * This method updates the label value for the specified association. + * The label will be stored in the title property. + * Label is String metadata for bidirectional custom references. + * + * @param refQName qname of the child association. + * @param newLabel the new value for the label field. + * @deprecated as of RM 2.3, please use {@link RelationshipService#updateRelationshipDefinition(String, org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)} instead. + */ + QName updateCustomAssocDefinition(QName refQName, String newLabel); + + /** * This method returns ConstraintDefinition objects defined in the given model - * (note: not property references or in-line defs) - * The custom constraint definitions are retrieved from the dictionaryService - * which is notified of any newly created definitions on transaction commit. - * Therefore custom constraints created in the current transaction will not appear - * in the results. - */ + * (note: not property references or in-line defs) + * The custom constraint definitions are retrieved from the dictionaryService + * which is notified of any newly created definitions on transaction commit. + * Therefore custom constraints created in the current transaction will not appear + * in the results. + */ List getCustomConstraintDefinitions(QName modelQName); - - /** - * This method adds a Constraint definition to the custom model. - * The implementation of this method would have to go into the M2Model and insert - * the relevant M2Objects for this new constraint. - * - * param type not included as it would always be RMListOfValuesConstraint for RM. - * - * @param constraintName the name e.g. rmc:foo - * @param title the human-readable title e.g. My foo list - * @param caseSensitive - * @param allowedValues the allowed values list + + /** + * This method adds a Constraint definition to the custom model. + * The implementation of this method would have to go into the M2Model and insert + * the relevant M2Objects for this new constraint. + * + * param type not included as it would always be RMListOfValuesConstraint for RM. + * + * @param constraintName the name e.g. rmc:foo + * @param title the human-readable title e.g. My foo list + * @param caseSensitive + * @param allowedValues the allowed values list * @param matchLogic AND (all values must match), OR (at least one values must match) - */ + */ void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List allowedValues, MatchLogic matchLogic); - - /** + + /** * Remove custom constraint definition - if not referenced (by any properties) - * - * + * + * * @param constraintName the name e.g. rmc:foo - */ - void removeCustomConstraintDefinition(QName constraintName); - - /** + */ + void removeCustomConstraintDefinition(QName constraintName); + + /** * Update custom constraint definition with new list of values (replaces existing list, if any) - * + * * @param constraintName the name e.g. rmc:foo - * @param newValues - */ - void changeCustomConstraintValues(QName constraintName, List newValues); - - /** - * - * @param constraintName - * @param title - */ - void changeCustomConstraintTitle(QName constraintName, String title); - - /** - * This method iterates over the custom properties, references looking for one whose id - * exactly matches that specified. - * - * @param localName the localName part of the qname of the property or reference definition. - * @return the QName of the property, association definition which matches, or null. - */ - QName getQNameForClientId(String localName); + * @param newValues + */ + void changeCustomConstraintValues(QName constraintName, List newValues); - /** - * Given a compound id for source and target strings (as used with parent/child - * custom references), this method splits the String and returns an array containing - * the source and target IDs separately. - * - * @param sourceTargetId the compound ID. - * @return a String array, where result[0] == sourceId and result[1] == targetId. - */ - String[] splitSourceTargetId(String sourceTargetId); + /** + * + * @param constraintName + * @param title + */ + void changeCustomConstraintTitle(QName constraintName, String title); - /** - * This method retrieves a compound ID (client-side) for the specified - * sourceId and targetId. - * - * @param sourceId - * @param targetId - * @return - */ - String getCompoundIdFor(String sourceId, String targetId); -} + /** + * This method iterates over the custom properties, references looking for one whose id + * exactly matches that specified. + * + * @param localName the localName part of the qname of the property or reference definition. + * @return the QName of the property, association definition which matches, or null. + */ + QName getQNameForClientId(String localName); + + /** + * Given a compound id for source and target strings (as used with parent/child + * custom references), this method splits the String and returns an array containing + * the source and target IDs separately. + * + * @param sourceTargetId the compound ID. + * @return a String array, where result[0] == sourceId and result[1] == targetId. + */ + String[] splitSourceTargetId(String sourceTargetId); + + /** + * This method retrieves a compound ID (client-side) for the specified + * sourceId and targetId. + * + * @param sourceId + * @param targetId + * @return + */ + String getCompoundIdFor(String sourceId, String targetId); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java index 54bbc7a5bd..76654f48bd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java @@ -1,1363 +1,1363 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.admin; - -import static org.springframework.extensions.surf.util.ParameterCheck.mandatory; -import static org.springframework.extensions.surf.util.ParameterCheck.mandatoryString; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; -import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.repo.dictionary.IndexTokenisationMode; -import org.alfresco.repo.dictionary.M2Aspect; -import org.alfresco.repo.dictionary.M2Constraint; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.dictionary.M2Property; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.Constraint; -import org.alfresco.service.cmr.dictionary.ConstraintDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.GUID; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.core.Ordered; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.extensions.surf.util.URLDecoder; - -/** - * Records Management AdminService Implementation. - * - * @author Neil McErlean, janv - */ -@BehaviourBean -public class RecordsManagementAdminServiceImpl extends RecordsManagementAdminBase - implements RecordsManagementAdminService, - RecordsManagementCustomModel, - NodeServicePolicies.OnAddAspectPolicy, - NodeServicePolicies.OnRemoveAspectPolicy, - NodeServicePolicies.OnCreateNodePolicy, - ApplicationListener, - Ordered -{ - /** I18N messages*/ - private static final String MSG_SERVICE_NOT_INIT = "rm.admin.service-not-init"; - private static final String MSG_PROP_EXIST = "rm.admin.prop-exist"; - private static final String MSG_CUSTOM_PROP_EXIST = "rm.admin.custom-prop-exist"; - private static final String MSG_UNKNOWN_ASPECT = "rm.admin.unknown-aspect"; - private static final String MSG_CONSTRAINT_EXISTS = "rm.admin.constraint-exists"; - private static final String MSG_CANNOT_FIND_CONSTRAINT = "rm.admin.contraint-cannot-find"; - private static final String MSG_UNEXPECTED_TYPE_CONSTRAINT = "rm.admin.unexpected_type_constraint"; - private static final String MSG_ERROR_CLIENT_ID = "rm.admin.error-client-id"; - - /** Constants */ - private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName(); - private static final String CAPATIBILITY_CUSTOM_CONTRAINT_TYPE = org.alfresco.module.org_alfresco_module_dod5015.caveat.RMListOfValuesConstraint.class.getName(); - private static final String PARAM_ALLOWED_VALUES = "allowedValues"; - private static final String PARAM_CASE_SENSITIVE = "caseSensitive"; - private static final String PARAM_MATCH_LOGIC = "matchLogic"; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** Transaction service */ - private TransactionService transactionService; - - /** List of types that can be customisable */ - private List pendingCustomisableTypes; - private Map customisableTypes; - - /** indicates whether the custom map has been initialised or not */ - private boolean isCustomMapInit = false; - - /** - * @param transactionService transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * @param relationshipService The relationship service instance - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * Gets the relationship service instance - * - * @return The relationship service instance - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Indicate that this application content listener must be executed with the lowest - * precedence. (ie last) - * - * @see Ordered#getOrder() - */ - @Override - public int getOrder() - { - return Ordered.LOWEST_PRECEDENCE; - } - - /** - * Load the custom properties map - * - * @see ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) - */ - @Override - public void onApplicationEvent(ContextRefreshedEvent event) - { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // initialise custom properties - initCustomMap(); - - return null; - } - }); - } - - /** - * Helper method to indicate whether the custom map is initialised or not. - * - * @return boolean true if initialised, false otherwise - */ - public boolean isCustomMapInit() - { - return isCustomMapInit; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - if (isCustomMapInit) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (getNodeService().exists(nodeRef) && - getDictionaryService().getAllModels().contains(RM_CUSTOM_MODEL) && - isCustomisable(aspectTypeQName)) - { - QName customPropertyAspect = getCustomAspect(aspectTypeQName); - getNodeService().addAspect(nodeRef, customPropertyAspect, null); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onRemoveAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - if (isCustomMapInit) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (getNodeService().exists(nodeRef) && - isCustomisable(aspectTypeQName)) - { - QName customPropertyAspect = getCustomAspect(aspectTypeQName); - getNodeService().removeAspect(nodeRef, customPropertyAspect); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - } - - /** - * Make sure any custom property aspects are applied to newly created nodes. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onCreateNode(final ChildAssociationRef childAssocRef) - { - if (isCustomMapInit) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (getDictionaryService().getAllModels().contains(RecordsManagementCustomModel.RM_CUSTOM_MODEL)) - { - NodeRef nodeRef = childAssocRef.getChildRef(); - QName type = getNodeService().getType(nodeRef); - while (type != null && !ContentModel.TYPE_CMOBJECT.equals(type)) - { - if (isCustomisable(type)) - { - QName customPropertyAspect = getCustomAspect(type); - getNodeService().addAspect(nodeRef, customPropertyAspect, null); - } - - TypeDefinition def = getDictionaryService().getType(type); - if (def != null) - { - type = def.getParentName(); - } - else - { - type = null; - } - } - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - } - - /** - * @param customisableTypes list of string representations of the type qnames that are customisable - */ - public void setCustomisableTypes(List customisableTypes) - { - mandatory("customisableTypes", customisableTypes); - - pendingCustomisableTypes = new ArrayList(); - for (String customisableType : customisableTypes) - { - pendingCustomisableTypes.add(QName.createQName(customisableType, getNamespaceService())); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable() - */ - public Set getCustomisable() - { - return getCustomisableMap().keySet(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Set getCustomisable(NodeRef nodeRef) - { - mandatory("nodeRef", nodeRef); - - Set result = new HashSet(5); - - // Check the nodes hierarchy for customisable types - QName type = getNodeService().getType(nodeRef); - while (type != null && !ContentModel.TYPE_CMOBJECT.equals(type)) - { - // Add to the list if the type is customisable - if (isCustomisable(type)) - { - result.add(type); - } - - // Type and get the types parent - TypeDefinition def = getDictionaryService().getType(type); - if (def != null) - { - type = def.getParentName(); - } - else - { - type = null; - } - } - - // Get all the nodes aspects - Set aspects = getNodeService().getAspects(nodeRef); - for (QName aspect : aspects) - { - QName tempAspect = QName.createQName(aspect.toString()); - while (tempAspect != null) - { - // Add to the list if the aspect is customisable - if (isCustomisable(tempAspect)) - { - result.add(tempAspect); - } - - // Try and get the parent aspect - AspectDefinition aspectDef = getDictionaryService().getAspect(tempAspect); - if (aspectDef != null) - { - tempAspect = aspectDef.getParentName(); - } - else - { - tempAspect = null; - } - } - } - - return result; - } - - /** - * Initialise custom type map - */ - private void initCustomMap() - { - customisableTypes = new HashMap(7); - Collection aspects = getDictionaryService().getAspects(RM_CUSTOM_MODEL); - for (QName aspect : aspects) - { - AspectDefinition aspectDef = getDictionaryService().getAspect(aspect); - String name = aspectDef.getName().getLocalName(); - if (name.endsWith("Properties")) - { - QName type = null; - String prefixString = aspectDef.getDescription(getDictionaryService()); - if (prefixString == null) - { - // Backward compatibility from previous RM V1.0 custom models - if (CompatibilityModel.NAME_CUSTOM_RECORD_PROPERTIES.equals(name)) - { - type = RecordsManagementModel.ASPECT_RECORD; - } - else if (CompatibilityModel.NAME_CUSTOM_RECORD_FOLDER_PROPERTIES.equals(name)) - { - type = RecordsManagementModel.TYPE_RECORD_FOLDER; - } - else if (CompatibilityModel.NAME_CUSTOM_RECORD_CATEGORY_PROPERTIES.equals(name)) - { - type = RecordsManagementModel.TYPE_RECORD_CATEGORY; - } - else if (CompatibilityModel.NAME_CUSTOM_RECORD_SERIES_PROPERTIES.equals(name) && - // Only add the deprecated record series type as customisable if - // a v1.0 installation has added custom properties - aspectDef.getProperties().size() != 0) - { - type = CompatibilityModel.TYPE_RECORD_SERIES; - } - } - else - { - type = QName.createQName(prefixString, getNamespaceService()); - } - - // Add the customisable type to the map - if (type != null) - { - customisableTypes.put(type, aspect); - - // Remove customisable type from the pending list - if (pendingCustomisableTypes != null && pendingCustomisableTypes.contains(type)) - { - pendingCustomisableTypes.remove(type); - } - } - } - } - - // Deal with any pending types left over - if (pendingCustomisableTypes != null && pendingCustomisableTypes.size() != 0) - { - NodeRef modelRef = getCustomModelRef(RecordsManagementModel.RM_CUSTOM_URI); - M2Model model = readCustomContentModel(modelRef); - try - { - for (QName customisableType : pendingCustomisableTypes) - { - QName customAspect = getCustomAspectImpl(customisableType); - - // Create the new aspect to hold the custom properties - M2Aspect aspect = model.createAspect(customAspect.toPrefixString(getNamespaceService())); - aspect.setDescription(customisableType.toPrefixString(getNamespaceService())); - - // Make a record of the customisable type - customisableTypes.put(customisableType, customAspect); - } - } - finally - { - writeCustomContentModel(modelRef, model); - } - } - - // indicate map is initialised - isCustomMapInit = true; - } - - /** - * Gets a map containing all the customisable types - * - * @return map from the customisable type to its custom aspect - */ - private Map getCustomisableMap() - { - if (customisableTypes == null) - { - throw AlfrescoRuntimeException.create("Customisable map has not been initialised correctly."); - } - return customisableTypes; - } - - /** - * Gets the QName of the custom aspect given the customisable type QName - * - * @param customisableType - * @return - */ - private QName getCustomAspect(QName customisableType) - { - Map map = getCustomisableMap(); - QName result = map.get(customisableType); - if (result == null) - { - result = getCustomAspectImpl(customisableType); - } - return result; - } - - /** - * Builds a custom aspect QName from a customisable type/aspect QName - * - * @param customisableType - * @return - */ - private QName getCustomAspectImpl(QName customisableType) - { - String localName = customisableType.toPrefixString(getNamespaceService()).replace(":", ""); - localName = MessageFormat.format("{0}CustomProperties", localName); - return QName.createQName(RM_CUSTOM_URI, localName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#isCustomisable(org.alfresco.service.namespace.QName) - */ - @Override - public boolean isCustomisable(QName type) - { - mandatory("type", type); - - return getCustomisable().contains(type); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#makeCustomisable(org.alfresco.service.namespace.QName) - */ - @Override - public void makeCustomisable(QName type) - { - mandatory("type", type); - - if (customisableTypes == null) - { - // Add the type to the pending list - pendingCustomisableTypes.add(type); - } - else - { - QName customAspect = getCustomAspect(type); - if (getDictionaryService().getAspect(customAspect) == null) - { - NodeRef modelRef = getCustomModelRef(customAspect.getNamespaceURI()); - M2Model model = readCustomContentModel(modelRef); - try - { - // Create the new aspect to hold the custom properties - M2Aspect aspect = model.createAspect(customAspect.toPrefixString(getNamespaceService())); - aspect.setDescription(type.toPrefixString(getNamespaceService())); - } - finally - { - writeCustomContentModel(modelRef, model); - } - customisableTypes.put(type, customAspect); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#unmakeCustomisable(org.alfresco.service.namespace.QName) - */ - @Override - public void unmakeCustomisable(QName type) - { - mandatory("type", type); - - if (customisableTypes == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SERVICE_NOT_INIT)); - } - - QName customAspect = getCustomAspect(type); - if (getDictionaryService().getAspect(customAspect) != null) - { - // TODO need to confirm that the custom properties are not being used! - - NodeRef modelRef = getCustomModelRef(customAspect.getNamespaceURI()); - M2Model model = readCustomContentModel(modelRef); - try - { - // Create the new aspect to hold the custom properties - model.removeAspect(customAspect.toPrefixString(getNamespaceService())); - } - finally - { - writeCustomContentModel(modelRef, model); - } - customisableTypes.remove(type); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#existsCustomProperty(org.alfresco.service.namespace.QName) - */ - @Override - public boolean existsCustomProperty(QName propertyName) - { - mandatory("propertyName", propertyName); - - boolean result = false; - if (RM_CUSTOM_URI.equals(propertyName.getNamespaceURI()) && - getDictionaryService().getProperty(propertyName) != null) - { - result = true; - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomPropertyDefinitions() - */ - public Map getCustomPropertyDefinitions() - { - Map result = new HashMap(); - for (QName customisableType : getCustomisable()) - { - Map props = getCustomPropertyDefinitions(customisableType); - if (props != null) - { - result.putAll(props); - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomPropertyDefinitions(org.alfresco.module.org_alfresco_module_rm.CustomisableRmElement) - */ - public Map getCustomPropertyDefinitions(QName customisableType) - { - mandatory("customisableType", customisableType); - - Map propDefns = null; - QName relevantAspectQName = getCustomAspect(customisableType); - AspectDefinition aspectDefn = getDictionaryService().getAspect(relevantAspectQName); - if (aspectDefn != null) - { - propDefns = aspectDefn.getProperties(); - } - - return propDefns; - } - - /** - * @throws CustomMetadataException - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String) - */ - public QName addCustomPropertyDefinition(QName propId, QName aspectName, String label, QName dataType, String title, String description) throws CustomMetadataException - { - return addCustomPropertyDefinition(propId, aspectName, label, dataType, title, description, null, false, false, false, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, boolean, org.alfresco.service.namespace.QName) - */ - public QName addCustomPropertyDefinition(QName propId, - QName aspectName, - String label, - QName dataType, - String title, - String description, - String defaultValue, - boolean multiValued, - boolean mandatory, - boolean isProtected, - QName lovConstraint) throws CustomMetadataException - { - if (!isCustomisable(aspectName)) - { - throw new NotCustomisableMetadataException(aspectName.toPrefixString(getNamespaceService())); - } - - // title parameter is currently ignored. Intentionally. - if (propId == null) - { - // Generate a propId - propId = this.generateQNameFor(label); - } - - mandatory("aspectName", aspectName); - mandatory("label", label); - mandatory("dataType", dataType); - - NodeRef modelRef = getCustomModelRef(propId.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - QName customAspect = getCustomAspect(aspectName); - M2Aspect customPropsAspect = deserializedModel.getAspect(customAspect.toPrefixString(getNamespaceService())); - - if (customPropsAspect == null) - { - throw new InvalidCustomAspectMetadataException(customAspect, aspectName.toPrefixString(getNamespaceService())); - } - - String propIdAsString = propId.toPrefixString(getNamespaceService()); - M2Property customProp = customPropsAspect.getProperty(propIdAsString); - if (customProp != null) - { - throw new PropertyAlreadyExistsMetadataException(propIdAsString); - } - - M2Property newProp = customPropsAspect.createProperty(propIdAsString); - newProp.setName(propIdAsString); - newProp.setType(dataType.toPrefixString(getNamespaceService())); - - // Note that the title is used to store the RM 'label'. - newProp.setTitle(label); - newProp.setDescription(description); - newProp.setDefaultValue(defaultValue); - - newProp.setMandatory(mandatory); - newProp.setProtected(isProtected); - newProp.setMultiValued(multiValued); - - newProp.setIndexed(true); - newProp.setIndexedAtomically(true); - newProp.setStoredInIndex(false); - newProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE); - - if (lovConstraint != null) - { - if (! dataType.equals(DataTypeDefinition.TEXT)) - { - throw new CannotApplyConstraintMetadataException(lovConstraint, propIdAsString, dataType); - } - - String lovConstraintQNameAsString = lovConstraint.toPrefixString(getNamespaceService()); - newProp.addConstraintRef(lovConstraintQNameAsString); - } - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("addCustomPropertyDefinition: "+label+ - "=" + propIdAsString + " to aspect: "+aspectName); - } - - return propId; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#updateCustomPropertyDefinitionName(org.alfresco.service.namespace.QName, java.lang.String) - */ - public QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException - { - mandatory("propQName", propQName); - - PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); - if (propDefn == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); - } - - if (newName == null) - { - return propQName; - } - - QName newPropQName = getQNameForClientId(newName); - if (newPropQName != null) - { - PropertyDefinition newPropDefn = getDictionaryService().getProperty(newPropQName); - if (newPropDefn != null && !propDefn.equals(newPropDefn)) - { - // The requested QName is already in use - String propIdAsString = newPropQName.toPrefixString(getNamespaceService()); - throw new PropertyAlreadyExistsMetadataException(propIdAsString); - } - } - - NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - M2Property targetProperty = findProperty(propQName, deserializedModel); - targetProperty.setName(new StringBuilder().append(RecordsManagementCustomModel.RM_CUSTOM_PREFIX).append(QName.NAMESPACE_PREFIX).append(newName).toString()); - targetProperty.setTitle(URLDecoder.decode(newName)); - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("setCustomPropertyDefinitionLabel: "+propQName+ - "=" + newName); - } - - return propQName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionLabel(org.alfresco.service.namespace.QName, java.lang.String) - */ - public QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) - { - mandatory("propQName", propQName); - - PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); - if (propDefn == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); - } - - if (newLabel == null) - { - return propQName; - } - - NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - M2Property targetProperty = findProperty(propQName, deserializedModel); - - targetProperty.setTitle(newLabel); - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("setCustomPropertyDefinitionLabel: "+propQName+ - "=" + newLabel); - } - - return propQName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionConstraint(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) - */ - public QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint) - { - mandatory("propQName", propQName); - mandatory("newLovConstraint", newLovConstraint); - - PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); - if (propDefn == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); - } - - NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - M2Property targetProp = findProperty(propQName, deserializedModel); - String dataType = targetProp.getType(); - - if (! dataType.equals(DataTypeDefinition.TEXT.toPrefixString(getNamespaceService()))) - { - - throw new AlfrescoRuntimeException(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, newLovConstraint, targetProp.getName(), dataType)); - } - String lovConstraintQNameAsString = newLovConstraint.toPrefixString(getNamespaceService()); - - // Add the constraint - if it isn't already there. - String refOfExistingConstraint = null; - - for (M2Constraint c : targetProp.getConstraints()) - { - // There should only be one constraint. - refOfExistingConstraint = c.getRef(); - break; - } - if (refOfExistingConstraint != null) - { - targetProp.removeConstraintRef(refOfExistingConstraint); - } - targetProp.addConstraintRef(lovConstraintQNameAsString); - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("addCustomPropertyDefinitionConstraint: "+lovConstraintQNameAsString); - } - - return propQName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#removeCustomPropertyDefinitionConstraints(org.alfresco.service.namespace.QName) - */ - public QName removeCustomPropertyDefinitionConstraints(QName propQName) - { - mandatory("propQName", propQName); - - PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); - if (propDefn == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); - } - - NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - M2Property targetProperty = findProperty(propQName, deserializedModel); - - // Need to count backwards to remove constraints - for (int i = targetProperty.getConstraints().size() - 1; i >= 0; i--) - { - String ref = targetProperty.getConstraints().get(i).getRef(); - targetProperty.removeConstraintRef(ref); - } - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("removeCustomPropertyDefinitionConstraints: "+propQName); - } - - return propQName; - } - - /** - * - * @param propQName - * @param deserializedModel - * @return - */ - private M2Property findProperty(QName propQName, M2Model deserializedModel) - { - List aspects = deserializedModel.getAspects(); - // Search through the aspects looking for the custom property - for (M2Aspect aspect : aspects) - { - for (M2Property prop : aspect.getProperties()) - { - if (propQName.toPrefixString(getNamespaceService()).equals(prop.getName())) - { - return prop; - } - } - } - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_PROP_EXIST, propQName)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#removeCustomPropertyDefinition(org.alfresco.service.namespace.QName) - */ - public void removeCustomPropertyDefinition(QName propQName) - { - mandatory("propQName", propQName); - - NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String propQNameAsString = propQName.toPrefixString(getNamespaceService()); - - String aspectName = null; - - boolean found = false; - - // Need to select the correct aspect in the customModel from which we'll - // attempt to delete the property definition. - for (QName customisableType : getCustomisable()) - { - aspectName = getCustomAspect(customisableType).toPrefixString(getNamespaceService()); - M2Aspect customPropsAspect = deserializedModel.getAspect(aspectName); - - if (customPropsAspect == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNKNOWN_ASPECT, aspectName)); - } - - M2Property prop = customPropsAspect.getProperty(propQNameAsString); - if (prop != null) - { - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Attempting to delete custom property: "); - msg.append(propQNameAsString); - logger.debug(msg.toString()); - } - - found = true; - customPropsAspect.removeProperty(propQNameAsString); - break; - } - } - - if (!found) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQNameAsString)); - } - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("deleteCustomPropertyDefinition: "+propQNameAsString+" from aspect: "+aspectName); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomReferenceDefinitions() - */ - public Map getCustomReferenceDefinitions() - { - return getCustomAssociations(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - public void addCustomReference(NodeRef fromNode, NodeRef toNode, QName refId) - { - mandatory("fromNode", fromNode); - mandatory("toNode", toNode); - mandatory("refId", refId); - - getRelationshipService().addRelationship(refId.getLocalName(), fromNode, toNode); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - public void removeCustomReference(final NodeRef fromNode, final NodeRef toNode, final QName assocId) - { - mandatory("fromNode", fromNode); - mandatory("toNode", toNode); - mandatory("assocId",assocId); - - getRelationshipService().removeRelationship(assocId.getLocalName(), fromNode, toNode); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesFrom(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getCustomReferencesFrom(NodeRef node) - { - mandatory("node", node); - - return getNodeService().getTargetAssocs(node, RegexQNamePattern.MATCH_ALL); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomChildReferences(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getCustomChildReferences(NodeRef node) - { - mandatory("node", node); - - return getNodeService().getChildAssocs(node); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesTo(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getCustomReferencesTo(NodeRef node) - { - mandatory("node", node); - - return getNodeService().getSourceAssocs(node, RegexQNamePattern.MATCH_ALL); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomParentReferences(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getCustomParentReferences(NodeRef node) - { - mandatory("node", node); - - return getNodeService().getParentAssocs(node); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomAssocDefinition(java.lang.String) - * - * note: currently RMC custom assocs only - */ - public QName addCustomAssocDefinition(String label) - { - mandatoryString("label", label); - - return addCustomChildAssocDefinition(label, label); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomChildAssocDefinition(java.lang.String, java.lang.String) - * - * note: currently RMC custom assocs only - */ - public QName addCustomChildAssocDefinition(String source, String target) - { - mandatoryString("source", source); - mandatoryString("target", target); - - RelationshipDisplayName displayName = new RelationshipDisplayName(source, target); - RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName); - - return QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), getNamespaceService()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#updateCustomChildAssocDefinition(org.alfresco.service.namespace.QName, java.lang.String, java.lang.String) - * - * note: currently RMC custom assocs only - */ - public QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget) - { - mandatory("refQName", refQName); - mandatoryString("newSource", newSource); - mandatoryString("newTarget", newTarget); - - RelationshipDisplayName displayName = new RelationshipDisplayName(newSource, newTarget); - String localName = refQName.getLocalName(); - RelationshipDefinition relationshipDefinition = getRelationshipService().updateRelationshipDefinition(localName, displayName); - return QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), getNamespaceService()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#updateCustomAssocDefinition(org.alfresco.service.namespace.QName, java.lang.String) - * - * note: currently RMC custom assocs only - */ - public QName updateCustomAssocDefinition(QName refQName, String newLabel) - { - mandatory("refQName", refQName); - mandatoryString("newLabel", newLabel); - - return updateCustomChildAssocDefinition(refQName, newLabel, newLabel); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomConstraintDefinition(org.alfresco.service.namespace.QName, java.lang.String, boolean, java.util.List, org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic) - */ - public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List allowedValues, MatchLogic matchLogic) - { - mandatory("constraintName", constraintName); - mandatoryString("title", title); - mandatory("allowedValues", allowedValues); - mandatory("matchLogic", matchLogic); - - NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); - - M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); - if (customConstraint != null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONSTRAINT_EXISTS, constraintNameAsPrefixString)); - } - - M2Constraint newCon = deserializedModel.createConstraint(constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE); - - newCon.setTitle(title); - newCon.createParameter(PARAM_ALLOWED_VALUES, allowedValues); - newCon.createParameter(PARAM_CASE_SENSITIVE, caseSensitive ? "true" : "false"); - newCon.createParameter(PARAM_MATCH_LOGIC, matchLogic.toString()); - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("addCustomConstraintDefinition: "+constraintNameAsPrefixString+" (valueCnt: "+allowedValues.size()+")"); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintValues(org.alfresco.service.namespace.QName, java.util.List) - */ - public void changeCustomConstraintValues(QName constraintName, List newAllowedValues) - { - mandatory("constraintName", constraintName); - mandatory("newAllowedValues", newAllowedValues); - - NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); - - M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); - if (customConstraint == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); - } - - String type = customConstraint.getType(); - if (type == null || - (!type.equals(CUSTOM_CONSTRAINT_TYPE) && - !type.equals(CAPATIBILITY_CUSTOM_CONTRAINT_TYPE))) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); - } - - customConstraint.removeParameter(PARAM_ALLOWED_VALUES); - customConstraint.createParameter(PARAM_ALLOWED_VALUES, newAllowedValues); - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("changeCustomConstraintValues: "+constraintNameAsPrefixString+" (valueCnt: "+newAllowedValues.size()+")"); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintTitle(org.alfresco.service.namespace.QName, java.lang.String) - */ - public void changeCustomConstraintTitle(QName constraintName, String title) - { - mandatory("constraintName", constraintName); - mandatoryString("title", title); - - NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); - - M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); - if (customConstraint == null) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); - } - - String type = customConstraint.getType(); - if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE))) - { - - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); - } - - customConstraint.setTitle(title); - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("changeCustomConstraintTitle: "+constraintNameAsPrefixString+" (title: "+title+")"); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomConstraintDefinitions(org.alfresco.service.namespace.QName) - */ - public List getCustomConstraintDefinitions(QName modelQName) - { - mandatory("modelQName", modelQName); - - Collection conDefs = getDictionaryService().getConstraints(modelQName, true); - - for (ConstraintDefinition conDef : conDefs) - { - Constraint con = conDef.getConstraint(); - if (! (con instanceof RMListOfValuesConstraint)) - { - conDefs.remove(conDef); - } - } - - return new ArrayList(conDefs); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomConstraintDefinition(org.alfresco.service.namespace.QName) - */ - public void removeCustomConstraintDefinition(QName constraintName) - { - mandatory("constraintName", constraintName); - - NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); - - M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); - if (customConstraint == null) - { - - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); - } - - deserializedModel.removeConstraint(constraintNameAsPrefixString); - - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("deleteCustomConstraintDefinition: "+constraintNameAsPrefixString); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getQNameForClientId(java.lang.String) - */ - public QName getQNameForClientId(String localName) - { - //TODO 1. After certification. This implementation currently does not support reference, - // property, constraints definitions with the same names, which is technically allowed by Alfresco. - - //TODO 2. Note the implicit assumption here that all custom references will have - // unique titles. This is, in fact, not guaranteed. - - QName propertyResult = null; - for (QName qn : getCustomPropertyDefinitions().keySet()) - { - if (localName != null && localName.equals(qn.getLocalName())) - { - propertyResult = qn; - } - } - - if (propertyResult != null) - { - return propertyResult; - } - - QName referenceResult = null; - for (QName refQn : getCustomReferenceDefinitions().keySet()) - { - if (localName != null && localName.equals(refQn.getLocalName())) - { - referenceResult = refQn; - } - } - - // TODO Handle the case where both are not null - return referenceResult; - } - - /** - * @param clientId - * @return - */ - private QName generateQNameFor(String clientId) - { - if (getQNameForClientId(clientId) != null) - { - // TODO log it's already taken. What to do? - throw new IllegalArgumentException(I18NUtil.getMessage(MSG_ERROR_CLIENT_ID, clientId)); - } - - String newGUID = GUID.generate(); - QName newQName = QName.createQName(RM_CUSTOM_PREFIX, newGUID, getNamespaceService()); - - return newQName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#splitSourceTargetId(java.lang.String) - */ - public String[] splitSourceTargetId(String sourceTargetId) - { - mandatoryString("sourceTargetId", sourceTargetId); - - return splitAssociationDefinitionTitle(sourceTargetId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCompoundIdFor(java.lang.String, java.lang.String) - */ - public String getCompoundIdFor(String sourceId, String targetId) - { - mandatoryString("sourceId", sourceId); - mandatoryString("targetId", targetId); - - return composeAssociationDefinitionTitle(sourceId, targetId); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.admin; + +import static org.springframework.extensions.surf.util.ParameterCheck.mandatory; +import static org.springframework.extensions.surf.util.ParameterCheck.mandatoryString; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; +import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.repo.dictionary.IndexTokenisationMode; +import org.alfresco.repo.dictionary.M2Aspect; +import org.alfresco.repo.dictionary.M2Constraint; +import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.repo.dictionary.M2Property; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.Constraint; +import org.alfresco.service.cmr.dictionary.ConstraintDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.GUID; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.core.Ordered; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.extensions.surf.util.URLDecoder; + +/** + * Records Management AdminService Implementation. + * + * @author Neil McErlean, janv + */ +@BehaviourBean +public class RecordsManagementAdminServiceImpl extends RecordsManagementAdminBase + implements RecordsManagementAdminService, + RecordsManagementCustomModel, + NodeServicePolicies.OnAddAspectPolicy, + NodeServicePolicies.OnRemoveAspectPolicy, + NodeServicePolicies.OnCreateNodePolicy, + ApplicationListener, + Ordered +{ + /** I18N messages*/ + private static final String MSG_SERVICE_NOT_INIT = "rm.admin.service-not-init"; + private static final String MSG_PROP_EXIST = "rm.admin.prop-exist"; + private static final String MSG_CUSTOM_PROP_EXIST = "rm.admin.custom-prop-exist"; + private static final String MSG_UNKNOWN_ASPECT = "rm.admin.unknown-aspect"; + private static final String MSG_CONSTRAINT_EXISTS = "rm.admin.constraint-exists"; + private static final String MSG_CANNOT_FIND_CONSTRAINT = "rm.admin.contraint-cannot-find"; + private static final String MSG_UNEXPECTED_TYPE_CONSTRAINT = "rm.admin.unexpected_type_constraint"; + private static final String MSG_ERROR_CLIENT_ID = "rm.admin.error-client-id"; + + /** Constants */ + private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName(); + private static final String CAPATIBILITY_CUSTOM_CONTRAINT_TYPE = org.alfresco.module.org_alfresco_module_dod5015.caveat.RMListOfValuesConstraint.class.getName(); + private static final String PARAM_ALLOWED_VALUES = "allowedValues"; + private static final String PARAM_CASE_SENSITIVE = "caseSensitive"; + private static final String PARAM_MATCH_LOGIC = "matchLogic"; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** Transaction service */ + private TransactionService transactionService; + + /** List of types that can be customisable */ + private List pendingCustomisableTypes; + private Map customisableTypes; + + /** indicates whether the custom map has been initialised or not */ + private boolean isCustomMapInit = false; + + /** + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * @param relationshipService The relationship service instance + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * Gets the relationship service instance + * + * @return The relationship service instance + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Indicate that this application content listener must be executed with the lowest + * precedence. (ie last) + * + * @see Ordered#getOrder() + */ + @Override + public int getOrder() + { + return Ordered.LOWEST_PRECEDENCE; + } + + /** + * Load the custom properties map + * + * @see ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) + */ + @Override + public void onApplicationEvent(ContextRefreshedEvent event) + { + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // initialise custom properties + initCustomMap(); + + return null; + } + }); + } + + /** + * Helper method to indicate whether the custom map is initialised or not. + * + * @return boolean true if initialised, false otherwise + */ + public boolean isCustomMapInit() + { + return isCustomMapInit; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + if (isCustomMapInit) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (getNodeService().exists(nodeRef) && + getDictionaryService().getAllModels().contains(RM_CUSTOM_MODEL) && + isCustomisable(aspectTypeQName)) + { + QName customPropertyAspect = getCustomAspect(aspectTypeQName); + getNodeService().addAspect(nodeRef, customPropertyAspect, null); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onRemoveAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + if (isCustomMapInit) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (getNodeService().exists(nodeRef) && + isCustomisable(aspectTypeQName)) + { + QName customPropertyAspect = getCustomAspect(aspectTypeQName); + getNodeService().removeAspect(nodeRef, customPropertyAspect); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + } + + /** + * Make sure any custom property aspects are applied to newly created nodes. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onCreateNode(final ChildAssociationRef childAssocRef) + { + if (isCustomMapInit) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (getDictionaryService().getAllModels().contains(RecordsManagementCustomModel.RM_CUSTOM_MODEL)) + { + NodeRef nodeRef = childAssocRef.getChildRef(); + QName type = getNodeService().getType(nodeRef); + while (type != null && !ContentModel.TYPE_CMOBJECT.equals(type)) + { + if (isCustomisable(type)) + { + QName customPropertyAspect = getCustomAspect(type); + getNodeService().addAspect(nodeRef, customPropertyAspect, null); + } + + TypeDefinition def = getDictionaryService().getType(type); + if (def != null) + { + type = def.getParentName(); + } + else + { + type = null; + } + } + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + } + + /** + * @param customisableTypes list of string representations of the type qnames that are customisable + */ + public void setCustomisableTypes(List customisableTypes) + { + mandatory("customisableTypes", customisableTypes); + + pendingCustomisableTypes = new ArrayList(); + for (String customisableType : customisableTypes) + { + pendingCustomisableTypes.add(QName.createQName(customisableType, getNamespaceService())); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable() + */ + public Set getCustomisable() + { + return getCustomisableMap().keySet(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Set getCustomisable(NodeRef nodeRef) + { + mandatory("nodeRef", nodeRef); + + Set result = new HashSet(5); + + // Check the nodes hierarchy for customisable types + QName type = getNodeService().getType(nodeRef); + while (type != null && !ContentModel.TYPE_CMOBJECT.equals(type)) + { + // Add to the list if the type is customisable + if (isCustomisable(type)) + { + result.add(type); + } + + // Type and get the types parent + TypeDefinition def = getDictionaryService().getType(type); + if (def != null) + { + type = def.getParentName(); + } + else + { + type = null; + } + } + + // Get all the nodes aspects + Set aspects = getNodeService().getAspects(nodeRef); + for (QName aspect : aspects) + { + QName tempAspect = QName.createQName(aspect.toString()); + while (tempAspect != null) + { + // Add to the list if the aspect is customisable + if (isCustomisable(tempAspect)) + { + result.add(tempAspect); + } + + // Try and get the parent aspect + AspectDefinition aspectDef = getDictionaryService().getAspect(tempAspect); + if (aspectDef != null) + { + tempAspect = aspectDef.getParentName(); + } + else + { + tempAspect = null; + } + } + } + + return result; + } + + /** + * Initialise custom type map + */ + private void initCustomMap() + { + customisableTypes = new HashMap(7); + Collection aspects = getDictionaryService().getAspects(RM_CUSTOM_MODEL); + for (QName aspect : aspects) + { + AspectDefinition aspectDef = getDictionaryService().getAspect(aspect); + String name = aspectDef.getName().getLocalName(); + if (name.endsWith("Properties")) + { + QName type = null; + String prefixString = aspectDef.getDescription(getDictionaryService()); + if (prefixString == null) + { + // Backward compatibility from previous RM V1.0 custom models + if (CompatibilityModel.NAME_CUSTOM_RECORD_PROPERTIES.equals(name)) + { + type = RecordsManagementModel.ASPECT_RECORD; + } + else if (CompatibilityModel.NAME_CUSTOM_RECORD_FOLDER_PROPERTIES.equals(name)) + { + type = RecordsManagementModel.TYPE_RECORD_FOLDER; + } + else if (CompatibilityModel.NAME_CUSTOM_RECORD_CATEGORY_PROPERTIES.equals(name)) + { + type = RecordsManagementModel.TYPE_RECORD_CATEGORY; + } + else if (CompatibilityModel.NAME_CUSTOM_RECORD_SERIES_PROPERTIES.equals(name) && + // Only add the deprecated record series type as customisable if + // a v1.0 installation has added custom properties + aspectDef.getProperties().size() != 0) + { + type = CompatibilityModel.TYPE_RECORD_SERIES; + } + } + else + { + type = QName.createQName(prefixString, getNamespaceService()); + } + + // Add the customisable type to the map + if (type != null) + { + customisableTypes.put(type, aspect); + + // Remove customisable type from the pending list + if (pendingCustomisableTypes != null && pendingCustomisableTypes.contains(type)) + { + pendingCustomisableTypes.remove(type); + } + } + } + } + + // Deal with any pending types left over + if (pendingCustomisableTypes != null && pendingCustomisableTypes.size() != 0) + { + NodeRef modelRef = getCustomModelRef(RecordsManagementModel.RM_CUSTOM_URI); + M2Model model = readCustomContentModel(modelRef); + try + { + for (QName customisableType : pendingCustomisableTypes) + { + QName customAspect = getCustomAspectImpl(customisableType); + + // Create the new aspect to hold the custom properties + M2Aspect aspect = model.createAspect(customAspect.toPrefixString(getNamespaceService())); + aspect.setDescription(customisableType.toPrefixString(getNamespaceService())); + + // Make a record of the customisable type + customisableTypes.put(customisableType, customAspect); + } + } + finally + { + writeCustomContentModel(modelRef, model); + } + } + + // indicate map is initialised + isCustomMapInit = true; + } + + /** + * Gets a map containing all the customisable types + * + * @return map from the customisable type to its custom aspect + */ + private Map getCustomisableMap() + { + if (customisableTypes == null) + { + throw AlfrescoRuntimeException.create("Customisable map has not been initialised correctly."); + } + return customisableTypes; + } + + /** + * Gets the QName of the custom aspect given the customisable type QName + * + * @param customisableType + * @return + */ + private QName getCustomAspect(QName customisableType) + { + Map map = getCustomisableMap(); + QName result = map.get(customisableType); + if (result == null) + { + result = getCustomAspectImpl(customisableType); + } + return result; + } + + /** + * Builds a custom aspect QName from a customisable type/aspect QName + * + * @param customisableType + * @return + */ + private QName getCustomAspectImpl(QName customisableType) + { + String localName = customisableType.toPrefixString(getNamespaceService()).replace(":", ""); + localName = MessageFormat.format("{0}CustomProperties", localName); + return QName.createQName(RM_CUSTOM_URI, localName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#isCustomisable(org.alfresco.service.namespace.QName) + */ + @Override + public boolean isCustomisable(QName type) + { + mandatory("type", type); + + return getCustomisable().contains(type); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#makeCustomisable(org.alfresco.service.namespace.QName) + */ + @Override + public void makeCustomisable(QName type) + { + mandatory("type", type); + + if (customisableTypes == null) + { + // Add the type to the pending list + pendingCustomisableTypes.add(type); + } + else + { + QName customAspect = getCustomAspect(type); + if (getDictionaryService().getAspect(customAspect) == null) + { + NodeRef modelRef = getCustomModelRef(customAspect.getNamespaceURI()); + M2Model model = readCustomContentModel(modelRef); + try + { + // Create the new aspect to hold the custom properties + M2Aspect aspect = model.createAspect(customAspect.toPrefixString(getNamespaceService())); + aspect.setDescription(type.toPrefixString(getNamespaceService())); + } + finally + { + writeCustomContentModel(modelRef, model); + } + customisableTypes.put(type, customAspect); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#unmakeCustomisable(org.alfresco.service.namespace.QName) + */ + @Override + public void unmakeCustomisable(QName type) + { + mandatory("type", type); + + if (customisableTypes == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SERVICE_NOT_INIT)); + } + + QName customAspect = getCustomAspect(type); + if (getDictionaryService().getAspect(customAspect) != null) + { + // TODO need to confirm that the custom properties are not being used! + + NodeRef modelRef = getCustomModelRef(customAspect.getNamespaceURI()); + M2Model model = readCustomContentModel(modelRef); + try + { + // Create the new aspect to hold the custom properties + model.removeAspect(customAspect.toPrefixString(getNamespaceService())); + } + finally + { + writeCustomContentModel(modelRef, model); + } + customisableTypes.remove(type); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#existsCustomProperty(org.alfresco.service.namespace.QName) + */ + @Override + public boolean existsCustomProperty(QName propertyName) + { + mandatory("propertyName", propertyName); + + boolean result = false; + if (RM_CUSTOM_URI.equals(propertyName.getNamespaceURI()) && + getDictionaryService().getProperty(propertyName) != null) + { + result = true; + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomPropertyDefinitions() + */ + public Map getCustomPropertyDefinitions() + { + Map result = new HashMap(); + for (QName customisableType : getCustomisable()) + { + Map props = getCustomPropertyDefinitions(customisableType); + if (props != null) + { + result.putAll(props); + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomPropertyDefinitions(org.alfresco.module.org_alfresco_module_rm.CustomisableRmElement) + */ + public Map getCustomPropertyDefinitions(QName customisableType) + { + mandatory("customisableType", customisableType); + + Map propDefns = null; + QName relevantAspectQName = getCustomAspect(customisableType); + AspectDefinition aspectDefn = getDictionaryService().getAspect(relevantAspectQName); + if (aspectDefn != null) + { + propDefns = aspectDefn.getProperties(); + } + + return propDefns; + } + + /** + * @throws CustomMetadataException + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String) + */ + public QName addCustomPropertyDefinition(QName propId, QName aspectName, String label, QName dataType, String title, String description) throws CustomMetadataException + { + return addCustomPropertyDefinition(propId, aspectName, label, dataType, title, description, null, false, false, false, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, boolean, org.alfresco.service.namespace.QName) + */ + public QName addCustomPropertyDefinition(QName propId, + QName aspectName, + String label, + QName dataType, + String title, + String description, + String defaultValue, + boolean multiValued, + boolean mandatory, + boolean isProtected, + QName lovConstraint) throws CustomMetadataException + { + if (!isCustomisable(aspectName)) + { + throw new NotCustomisableMetadataException(aspectName.toPrefixString(getNamespaceService())); + } + + // title parameter is currently ignored. Intentionally. + if (propId == null) + { + // Generate a propId + propId = this.generateQNameFor(label); + } + + mandatory("aspectName", aspectName); + mandatory("label", label); + mandatory("dataType", dataType); + + NodeRef modelRef = getCustomModelRef(propId.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + QName customAspect = getCustomAspect(aspectName); + M2Aspect customPropsAspect = deserializedModel.getAspect(customAspect.toPrefixString(getNamespaceService())); + + if (customPropsAspect == null) + { + throw new InvalidCustomAspectMetadataException(customAspect, aspectName.toPrefixString(getNamespaceService())); + } + + String propIdAsString = propId.toPrefixString(getNamespaceService()); + M2Property customProp = customPropsAspect.getProperty(propIdAsString); + if (customProp != null) + { + throw new PropertyAlreadyExistsMetadataException(propIdAsString); + } + + M2Property newProp = customPropsAspect.createProperty(propIdAsString); + newProp.setName(propIdAsString); + newProp.setType(dataType.toPrefixString(getNamespaceService())); + + // Note that the title is used to store the RM 'label'. + newProp.setTitle(label); + newProp.setDescription(description); + newProp.setDefaultValue(defaultValue); + + newProp.setMandatory(mandatory); + newProp.setProtected(isProtected); + newProp.setMultiValued(multiValued); + + newProp.setIndexed(true); + newProp.setIndexedAtomically(true); + newProp.setStoredInIndex(false); + newProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE); + + if (lovConstraint != null) + { + if (! dataType.equals(DataTypeDefinition.TEXT)) + { + throw new CannotApplyConstraintMetadataException(lovConstraint, propIdAsString, dataType); + } + + String lovConstraintQNameAsString = lovConstraint.toPrefixString(getNamespaceService()); + newProp.addConstraintRef(lovConstraintQNameAsString); + } + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("addCustomPropertyDefinition: "+label+ + "=" + propIdAsString + " to aspect: "+aspectName); + } + + return propId; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#updateCustomPropertyDefinitionName(org.alfresco.service.namespace.QName, java.lang.String) + */ + public QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException + { + mandatory("propQName", propQName); + + PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); + if (propDefn == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); + } + + if (newName == null) + { + return propQName; + } + + QName newPropQName = getQNameForClientId(newName); + if (newPropQName != null) + { + PropertyDefinition newPropDefn = getDictionaryService().getProperty(newPropQName); + if (newPropDefn != null && !propDefn.equals(newPropDefn)) + { + // The requested QName is already in use + String propIdAsString = newPropQName.toPrefixString(getNamespaceService()); + throw new PropertyAlreadyExistsMetadataException(propIdAsString); + } + } + + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + M2Property targetProperty = findProperty(propQName, deserializedModel); + targetProperty.setName(new StringBuilder().append(RecordsManagementCustomModel.RM_CUSTOM_PREFIX).append(QName.NAMESPACE_PREFIX).append(newName).toString()); + targetProperty.setTitle(URLDecoder.decode(newName)); + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("setCustomPropertyDefinitionLabel: "+propQName+ + "=" + newName); + } + + return propQName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionLabel(org.alfresco.service.namespace.QName, java.lang.String) + */ + public QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) + { + mandatory("propQName", propQName); + + PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); + if (propDefn == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); + } + + if (newLabel == null) + { + return propQName; + } + + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + M2Property targetProperty = findProperty(propQName, deserializedModel); + + targetProperty.setTitle(newLabel); + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("setCustomPropertyDefinitionLabel: "+propQName+ + "=" + newLabel); + } + + return propQName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionConstraint(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) + */ + public QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint) + { + mandatory("propQName", propQName); + mandatory("newLovConstraint", newLovConstraint); + + PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); + if (propDefn == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); + } + + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + M2Property targetProp = findProperty(propQName, deserializedModel); + String dataType = targetProp.getType(); + + if (! dataType.equals(DataTypeDefinition.TEXT.toPrefixString(getNamespaceService()))) + { + + throw new AlfrescoRuntimeException(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, newLovConstraint, targetProp.getName(), dataType)); + } + String lovConstraintQNameAsString = newLovConstraint.toPrefixString(getNamespaceService()); + + // Add the constraint - if it isn't already there. + String refOfExistingConstraint = null; + + for (M2Constraint c : targetProp.getConstraints()) + { + // There should only be one constraint. + refOfExistingConstraint = c.getRef(); + break; + } + if (refOfExistingConstraint != null) + { + targetProp.removeConstraintRef(refOfExistingConstraint); + } + targetProp.addConstraintRef(lovConstraintQNameAsString); + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("addCustomPropertyDefinitionConstraint: "+lovConstraintQNameAsString); + } + + return propQName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#removeCustomPropertyDefinitionConstraints(org.alfresco.service.namespace.QName) + */ + public QName removeCustomPropertyDefinitionConstraints(QName propQName) + { + mandatory("propQName", propQName); + + PropertyDefinition propDefn = getDictionaryService().getProperty(propQName); + if (propDefn == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); + } + + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + M2Property targetProperty = findProperty(propQName, deserializedModel); + + // Need to count backwards to remove constraints + for (int i = targetProperty.getConstraints().size() - 1; i >= 0; i--) + { + String ref = targetProperty.getConstraints().get(i).getRef(); + targetProperty.removeConstraintRef(ref); + } + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("removeCustomPropertyDefinitionConstraints: "+propQName); + } + + return propQName; + } + + /** + * + * @param propQName + * @param deserializedModel + * @return + */ + private M2Property findProperty(QName propQName, M2Model deserializedModel) + { + List aspects = deserializedModel.getAspects(); + // Search through the aspects looking for the custom property + for (M2Aspect aspect : aspects) + { + for (M2Property prop : aspect.getProperties()) + { + if (propQName.toPrefixString(getNamespaceService()).equals(prop.getName())) + { + return prop; + } + } + } + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_PROP_EXIST, propQName)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#removeCustomPropertyDefinition(org.alfresco.service.namespace.QName) + */ + public void removeCustomPropertyDefinition(QName propQName) + { + mandatory("propQName", propQName); + + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String propQNameAsString = propQName.toPrefixString(getNamespaceService()); + + String aspectName = null; + + boolean found = false; + + // Need to select the correct aspect in the customModel from which we'll + // attempt to delete the property definition. + for (QName customisableType : getCustomisable()) + { + aspectName = getCustomAspect(customisableType).toPrefixString(getNamespaceService()); + M2Aspect customPropsAspect = deserializedModel.getAspect(aspectName); + + if (customPropsAspect == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNKNOWN_ASPECT, aspectName)); + } + + M2Property prop = customPropsAspect.getProperty(propQNameAsString); + if (prop != null) + { + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Attempting to delete custom property: "); + msg.append(propQNameAsString); + logger.debug(msg.toString()); + } + + found = true; + customPropsAspect.removeProperty(propQNameAsString); + break; + } + } + + if (!found) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQNameAsString)); + } + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("deleteCustomPropertyDefinition: "+propQNameAsString+" from aspect: "+aspectName); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomReferenceDefinitions() + */ + public Map getCustomReferenceDefinitions() + { + return getCustomAssociations(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + public void addCustomReference(NodeRef fromNode, NodeRef toNode, QName refId) + { + mandatory("fromNode", fromNode); + mandatory("toNode", toNode); + mandatory("refId", refId); + + getRelationshipService().addRelationship(refId.getLocalName(), fromNode, toNode); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + public void removeCustomReference(final NodeRef fromNode, final NodeRef toNode, final QName assocId) + { + mandatory("fromNode", fromNode); + mandatory("toNode", toNode); + mandatory("assocId",assocId); + + getRelationshipService().removeRelationship(assocId.getLocalName(), fromNode, toNode); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesFrom(org.alfresco.service.cmr.repository.NodeRef) + */ + public List getCustomReferencesFrom(NodeRef node) + { + mandatory("node", node); + + return getNodeService().getTargetAssocs(node, RegexQNamePattern.MATCH_ALL); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomChildReferences(org.alfresco.service.cmr.repository.NodeRef) + */ + public List getCustomChildReferences(NodeRef node) + { + mandatory("node", node); + + return getNodeService().getChildAssocs(node); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesTo(org.alfresco.service.cmr.repository.NodeRef) + */ + public List getCustomReferencesTo(NodeRef node) + { + mandatory("node", node); + + return getNodeService().getSourceAssocs(node, RegexQNamePattern.MATCH_ALL); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomParentReferences(org.alfresco.service.cmr.repository.NodeRef) + */ + public List getCustomParentReferences(NodeRef node) + { + mandatory("node", node); + + return getNodeService().getParentAssocs(node); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomAssocDefinition(java.lang.String) + * + * note: currently RMC custom assocs only + */ + public QName addCustomAssocDefinition(String label) + { + mandatoryString("label", label); + + return addCustomChildAssocDefinition(label, label); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomChildAssocDefinition(java.lang.String, java.lang.String) + * + * note: currently RMC custom assocs only + */ + public QName addCustomChildAssocDefinition(String source, String target) + { + mandatoryString("source", source); + mandatoryString("target", target); + + RelationshipDisplayName displayName = new RelationshipDisplayName(source, target); + RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName); + + return QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), getNamespaceService()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#updateCustomChildAssocDefinition(org.alfresco.service.namespace.QName, java.lang.String, java.lang.String) + * + * note: currently RMC custom assocs only + */ + public QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget) + { + mandatory("refQName", refQName); + mandatoryString("newSource", newSource); + mandatoryString("newTarget", newTarget); + + RelationshipDisplayName displayName = new RelationshipDisplayName(newSource, newTarget); + String localName = refQName.getLocalName(); + RelationshipDefinition relationshipDefinition = getRelationshipService().updateRelationshipDefinition(localName, displayName); + return QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), getNamespaceService()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#updateCustomAssocDefinition(org.alfresco.service.namespace.QName, java.lang.String) + * + * note: currently RMC custom assocs only + */ + public QName updateCustomAssocDefinition(QName refQName, String newLabel) + { + mandatory("refQName", refQName); + mandatoryString("newLabel", newLabel); + + return updateCustomChildAssocDefinition(refQName, newLabel, newLabel); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomConstraintDefinition(org.alfresco.service.namespace.QName, java.lang.String, boolean, java.util.List, org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic) + */ + public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List allowedValues, MatchLogic matchLogic) + { + mandatory("constraintName", constraintName); + mandatoryString("title", title); + mandatory("allowedValues", allowedValues); + mandatory("matchLogic", matchLogic); + + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); + + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); + if (customConstraint != null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONSTRAINT_EXISTS, constraintNameAsPrefixString)); + } + + M2Constraint newCon = deserializedModel.createConstraint(constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE); + + newCon.setTitle(title); + newCon.createParameter(PARAM_ALLOWED_VALUES, allowedValues); + newCon.createParameter(PARAM_CASE_SENSITIVE, caseSensitive ? "true" : "false"); + newCon.createParameter(PARAM_MATCH_LOGIC, matchLogic.toString()); + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("addCustomConstraintDefinition: "+constraintNameAsPrefixString+" (valueCnt: "+allowedValues.size()+")"); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintValues(org.alfresco.service.namespace.QName, java.util.List) + */ + public void changeCustomConstraintValues(QName constraintName, List newAllowedValues) + { + mandatory("constraintName", constraintName); + mandatory("newAllowedValues", newAllowedValues); + + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); + + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); + if (customConstraint == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); + } + + String type = customConstraint.getType(); + if (type == null || + (!type.equals(CUSTOM_CONSTRAINT_TYPE) && + !type.equals(CAPATIBILITY_CUSTOM_CONTRAINT_TYPE))) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); + } + + customConstraint.removeParameter(PARAM_ALLOWED_VALUES); + customConstraint.createParameter(PARAM_ALLOWED_VALUES, newAllowedValues); + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("changeCustomConstraintValues: "+constraintNameAsPrefixString+" (valueCnt: "+newAllowedValues.size()+")"); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintTitle(org.alfresco.service.namespace.QName, java.lang.String) + */ + public void changeCustomConstraintTitle(QName constraintName, String title) + { + mandatory("constraintName", constraintName); + mandatoryString("title", title); + + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); + + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); + if (customConstraint == null) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); + } + + String type = customConstraint.getType(); + if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE))) + { + + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); + } + + customConstraint.setTitle(title); + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("changeCustomConstraintTitle: "+constraintNameAsPrefixString+" (title: "+title+")"); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomConstraintDefinitions(org.alfresco.service.namespace.QName) + */ + public List getCustomConstraintDefinitions(QName modelQName) + { + mandatory("modelQName", modelQName); + + Collection conDefs = getDictionaryService().getConstraints(modelQName, true); + + for (ConstraintDefinition conDef : conDefs) + { + Constraint con = conDef.getConstraint(); + if (! (con instanceof RMListOfValuesConstraint)) + { + conDefs.remove(conDef); + } + } + + return new ArrayList(conDefs); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomConstraintDefinition(org.alfresco.service.namespace.QName) + */ + public void removeCustomConstraintDefinition(QName constraintName) + { + mandatory("constraintName", constraintName); + + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService()); + + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); + if (customConstraint == null) + { + + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); + } + + deserializedModel.removeConstraint(constraintNameAsPrefixString); + + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("deleteCustomConstraintDefinition: "+constraintNameAsPrefixString); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getQNameForClientId(java.lang.String) + */ + public QName getQNameForClientId(String localName) + { + //TODO 1. After certification. This implementation currently does not support reference, + // property, constraints definitions with the same names, which is technically allowed by Alfresco. + + //TODO 2. Note the implicit assumption here that all custom references will have + // unique titles. This is, in fact, not guaranteed. + + QName propertyResult = null; + for (QName qn : getCustomPropertyDefinitions().keySet()) + { + if (localName != null && localName.equals(qn.getLocalName())) + { + propertyResult = qn; + } + } + + if (propertyResult != null) + { + return propertyResult; + } + + QName referenceResult = null; + for (QName refQn : getCustomReferenceDefinitions().keySet()) + { + if (localName != null && localName.equals(refQn.getLocalName())) + { + referenceResult = refQn; + } + } + + // TODO Handle the case where both are not null + return referenceResult; + } + + /** + * @param clientId + * @return + */ + private QName generateQNameFor(String clientId) + { + if (getQNameForClientId(clientId) != null) + { + // TODO log it's already taken. What to do? + throw new IllegalArgumentException(I18NUtil.getMessage(MSG_ERROR_CLIENT_ID, clientId)); + } + + String newGUID = GUID.generate(); + QName newQName = QName.createQName(RM_CUSTOM_PREFIX, newGUID, getNamespaceService()); + + return newQName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#splitSourceTargetId(java.lang.String) + */ + public String[] splitSourceTargetId(String sourceTargetId) + { + mandatoryString("sourceTargetId", sourceTargetId); + + return splitAssociationDefinitionTitle(sourceTargetId); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCompoundIdFor(java.lang.String, java.lang.String) + */ + public String getCompoundIdFor(String sourceId, String targetId) + { + mandatoryString("sourceId", sourceId); + mandatoryString("targetId", targetId); + + return composeAssociationDefinitionTitle(sourceId, targetId); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java index b2dddd7c70..d5fa53c341 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java @@ -1,268 +1,268 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; - -/** - * Class to represent a Records Management audit entry. - * - * @author Gavin Cornwell - */ -public final class RecordsManagementAuditEntry -{ - private final Date timestamp; - private final String userName; - private final String fullName; - private final String userRole; - private final NodeRef nodeRef; - private final String nodeName; - private final String nodeType; - private final String event; - private final String identifier; - private final String path; - private final Map beforeProperties; - private final Map afterProperties; - private Map> changedProperties; - - /** - * Default constructor - */ - public RecordsManagementAuditEntry(Date timestamp, - String userName, String fullName, String userRole, - NodeRef nodeRef, String nodeName, String nodeType, - String event, String identifier, String path, - Map beforeProperties, - Map afterProperties) - { - ParameterCheck.mandatory("timestamp", timestamp); - ParameterCheck.mandatory("userName", userName); - - this.timestamp = timestamp; - this.userName = userName; - this.userRole = userRole; - this.fullName = fullName; - this.nodeRef = nodeRef; - this.nodeName = nodeName; - this.nodeType = nodeType; - this.event = event; - this.identifier = identifier; - this.path = path; - this.beforeProperties = beforeProperties; - this.afterProperties = afterProperties; - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append("(") - .append("timestamp=").append(timestamp) - .append(", userName=").append(userName) - .append(", userRole=").append(userRole) - .append(", fullName=").append(fullName) - .append(", nodeRef=").append(nodeRef) - .append(", nodeName=").append(nodeName) - .append(", event=").append(event) - .append(", identifier=").append(identifier) - .append(", path=").append(path) - .append(", beforeProperties=").append(beforeProperties) - .append(", afterProperties=").append(afterProperties) - .append(", changedProperties=").append(changedProperties) - .append(")"); - return sb.toString(); - } - - /** - * - * @return The date of the audit entry - */ - public Date getTimestamp() - { - return this.timestamp; - } - - /** - * - * @return The date of the audit entry as an ISO8601 formatted String - */ - public String getTimestampString() - { - return ISO8601DateFormat.format(this.timestamp); - } - - /** - * - * @return The username of the user that caused the audit log entry to be created - */ - public String getUserName() - { - return this.userName; - } - - /** - * - * @return The full name of the user that caused the audit log entry to be created - */ - public String getFullName() - { - return this.fullName; - } - - /** - * - * @return The role of the user that caused the audit log entry to be created - */ - public String getUserRole() - { - return this.userRole; - } - - /** - * - * @return The NodeRef of the node the audit log entry is for - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - /** - * - * @return The name of the node the audit log entry is for - */ - public String getNodeName() - { - return this.nodeName; - } - - /** - * - * @return The type of the node the audit log entry is for - */ - public String getNodeType() - { - return this.nodeType; - } - - /** - * - * @return The human readable description of the reason for the audit log - * entry i.e. metadata updated, record declared - */ - public String getEvent() - { - return this.event; - } - - /** - * An identifier for the item being audited, for example for a record - * it will be the unique record identifier, for a user it would be the - * username etc. - * - * @return Ad identifier for the thing being audited - */ - public String getIdentifier() - { - return this.identifier; - } - - /** - * - * @return The path to the object being audited - */ - public String getPath() - { - return this.path; - } - - /** - * - * @return Map of properties before the audited action - */ - public Map getBeforeProperties() - { - return this.beforeProperties; - } - - /** - * - * @return Map of properties after the audited action - */ - public Map getAfterProperties() - { - return this.afterProperties; - } - - /** - * - * @return Map of changed properties - */ - public Map> getChangedProperties() - { - if (this.changedProperties == null) - { - initChangedProperties(); - } - - return this.changedProperties; - } - - /** - * Initialises the map of changed values given the before and after properties - */ - private void initChangedProperties() - { - if (this.beforeProperties != null && this.afterProperties != null) - { - this.changedProperties = new HashMap>( - this.beforeProperties.size() + this.afterProperties.size()); - - // add all the properties present before the audited action - for (QName valuePropName : this.beforeProperties.keySet()) - { - Pair values = new Pair( - this.beforeProperties.get(valuePropName), - this.afterProperties.get(valuePropName)); - this.changedProperties.put(valuePropName, values); - } - - // add all the properties present after the audited action that - // have not already been added - for (QName valuePropName : this.afterProperties.keySet()) - { - if (!this.beforeProperties.containsKey(valuePropName)) - { - Pair values = new Pair(null, - this.afterProperties.get(valuePropName)); - this.changedProperties.put(valuePropName, values); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; + +/** + * Class to represent a Records Management audit entry. + * + * @author Gavin Cornwell + */ +public final class RecordsManagementAuditEntry +{ + private final Date timestamp; + private final String userName; + private final String fullName; + private final String userRole; + private final NodeRef nodeRef; + private final String nodeName; + private final String nodeType; + private final String event; + private final String identifier; + private final String path; + private final Map beforeProperties; + private final Map afterProperties; + private Map> changedProperties; + + /** + * Default constructor + */ + public RecordsManagementAuditEntry(Date timestamp, + String userName, String fullName, String userRole, + NodeRef nodeRef, String nodeName, String nodeType, + String event, String identifier, String path, + Map beforeProperties, + Map afterProperties) + { + ParameterCheck.mandatory("timestamp", timestamp); + ParameterCheck.mandatory("userName", userName); + + this.timestamp = timestamp; + this.userName = userName; + this.userRole = userRole; + this.fullName = fullName; + this.nodeRef = nodeRef; + this.nodeName = nodeName; + this.nodeType = nodeType; + this.event = event; + this.identifier = identifier; + this.path = path; + this.beforeProperties = beforeProperties; + this.afterProperties = afterProperties; + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("(") + .append("timestamp=").append(timestamp) + .append(", userName=").append(userName) + .append(", userRole=").append(userRole) + .append(", fullName=").append(fullName) + .append(", nodeRef=").append(nodeRef) + .append(", nodeName=").append(nodeName) + .append(", event=").append(event) + .append(", identifier=").append(identifier) + .append(", path=").append(path) + .append(", beforeProperties=").append(beforeProperties) + .append(", afterProperties=").append(afterProperties) + .append(", changedProperties=").append(changedProperties) + .append(")"); + return sb.toString(); + } + + /** + * + * @return The date of the audit entry + */ + public Date getTimestamp() + { + return this.timestamp; + } + + /** + * + * @return The date of the audit entry as an ISO8601 formatted String + */ + public String getTimestampString() + { + return ISO8601DateFormat.format(this.timestamp); + } + + /** + * + * @return The username of the user that caused the audit log entry to be created + */ + public String getUserName() + { + return this.userName; + } + + /** + * + * @return The full name of the user that caused the audit log entry to be created + */ + public String getFullName() + { + return this.fullName; + } + + /** + * + * @return The role of the user that caused the audit log entry to be created + */ + public String getUserRole() + { + return this.userRole; + } + + /** + * + * @return The NodeRef of the node the audit log entry is for + */ + public NodeRef getNodeRef() + { + return this.nodeRef; + } + + /** + * + * @return The name of the node the audit log entry is for + */ + public String getNodeName() + { + return this.nodeName; + } + + /** + * + * @return The type of the node the audit log entry is for + */ + public String getNodeType() + { + return this.nodeType; + } + + /** + * + * @return The human readable description of the reason for the audit log + * entry i.e. metadata updated, record declared + */ + public String getEvent() + { + return this.event; + } + + /** + * An identifier for the item being audited, for example for a record + * it will be the unique record identifier, for a user it would be the + * username etc. + * + * @return Ad identifier for the thing being audited + */ + public String getIdentifier() + { + return this.identifier; + } + + /** + * + * @return The path to the object being audited + */ + public String getPath() + { + return this.path; + } + + /** + * + * @return Map of properties before the audited action + */ + public Map getBeforeProperties() + { + return this.beforeProperties; + } + + /** + * + * @return Map of properties after the audited action + */ + public Map getAfterProperties() + { + return this.afterProperties; + } + + /** + * + * @return Map of changed properties + */ + public Map> getChangedProperties() + { + if (this.changedProperties == null) + { + initChangedProperties(); + } + + return this.changedProperties; + } + + /** + * Initialises the map of changed values given the before and after properties + */ + private void initChangedProperties() + { + if (this.beforeProperties != null && this.afterProperties != null) + { + this.changedProperties = new HashMap>( + this.beforeProperties.size() + this.afterProperties.size()); + + // add all the properties present before the audited action + for (QName valuePropName : this.beforeProperties.keySet()) + { + Pair values = new Pair( + this.beforeProperties.get(valuePropName), + this.afterProperties.get(valuePropName)); + this.changedProperties.put(valuePropName, values); + } + + // add all the properties present after the audited action that + // have not already been added + for (QName valuePropName : this.afterProperties.keySet()) + { + if (!this.beforeProperties.containsKey(valuePropName)) + { + Pair values = new Pair(null, + this.afterProperties.get(valuePropName)); + this.changedProperties.put(valuePropName, values); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java index 104580aa25..4af11575b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java @@ -1,205 +1,205 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit; - -import java.util.Date; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Class to represent the parameters for a Records Management - * audit log query. - * - * @author Gavin Cornwell - */ -public final class RecordsManagementAuditQueryParameters -{ - private int maxEntries = -1; - private String user; - private NodeRef nodeRef; - private Date dateFrom; - private Date dateTo; - private String event; - private QName property; - - /** - * Default constructor. - */ - public RecordsManagementAuditQueryParameters() - { - } - - /** - * - * @return The username to filter by - */ - public String getUser() - { - return this.user; - } - - /** - * Restricts the retrieved audit trail to entries made by - * the provided user. - * - * @param user The username to filter by - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * - * @return The maximum number of audit log entries to retrieve - */ - public int getMaxEntries() - { - return this.maxEntries; - } - - /** - * Restricts the retrieved audit trail to the last - * maxEntries entries. - * - * @param maxEntries Maximum number of entries - */ - public void setMaxEntries(int maxEntries) - { - this.maxEntries = maxEntries; - } - - /** - * - * @return The node to get entries for - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - /** - * Restricts the retrieved audit trail to only those entries - * created by the give node. - * - * @param nodeRef The node to get entries for - */ - public void setNodeRef(NodeRef nodeRef) - { - this.nodeRef = nodeRef; - } - - /** - * - * @return The date to retrieve entries from - */ - public Date getDateFrom() - { - return this.dateFrom; - } - - /** - * Restricts the retrieved audit trail to only those entries - * that occurred after the given date. - * - * @param dateFrom Date to retrieve entries after - */ - public void setDateFrom(Date dateFrom) - { - this.dateFrom = dateFrom; - } - - /** - * - * @return The date to retrive entries to - */ - public Date getDateTo() - { - return this.dateTo; - } - - /** - * Restricts the retrieved audit trail to only those entries - * that occurred before the given date. - * - * @param dateTo Date to retrieve entries before - */ - public void setDateTo(Date dateTo) - { - this.dateTo = dateTo; - } - - /** - * - * @return The event to retrive entries for - */ - public String getEvent() - { - return this.event; - } - - /** - * Restricts the retrieved audit trail to only those entries - * that match the given event string. - * - * @param event Event to retrieve entries for - */ - public void setEvent(String event) - { - this.event = event; - } - - /** - * - * @return The property to retrieve entries for - */ - public QName getProperty() - { - return this.property; - } - - /** - * Restricts the audit trail to only those entries that involve - * the given property. - * - * @param property The property to retrieve entries for - */ - public void setProperty(QName property) - { - this.property = property; - } - - /* - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(super.toString()); - - builder.append(" (nodeRef='").append(nodeRef).append("', user='") - .append(user).append("', dateFrom='").append(dateFrom) - .append("', dateTo='").append(dateTo).append("', maxEntries='") - .append(maxEntries).append("', event='").append(event) - .append("', property='").append(property).append("')"); - - return builder.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit; + +import java.util.Date; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Class to represent the parameters for a Records Management + * audit log query. + * + * @author Gavin Cornwell + */ +public final class RecordsManagementAuditQueryParameters +{ + private int maxEntries = -1; + private String user; + private NodeRef nodeRef; + private Date dateFrom; + private Date dateTo; + private String event; + private QName property; + + /** + * Default constructor. + */ + public RecordsManagementAuditQueryParameters() + { + } + + /** + * + * @return The username to filter by + */ + public String getUser() + { + return this.user; + } + + /** + * Restricts the retrieved audit trail to entries made by + * the provided user. + * + * @param user The username to filter by + */ + public void setUser(String user) + { + this.user = user; + } + + /** + * + * @return The maximum number of audit log entries to retrieve + */ + public int getMaxEntries() + { + return this.maxEntries; + } + + /** + * Restricts the retrieved audit trail to the last + * maxEntries entries. + * + * @param maxEntries Maximum number of entries + */ + public void setMaxEntries(int maxEntries) + { + this.maxEntries = maxEntries; + } + + /** + * + * @return The node to get entries for + */ + public NodeRef getNodeRef() + { + return this.nodeRef; + } + + /** + * Restricts the retrieved audit trail to only those entries + * created by the give node. + * + * @param nodeRef The node to get entries for + */ + public void setNodeRef(NodeRef nodeRef) + { + this.nodeRef = nodeRef; + } + + /** + * + * @return The date to retrieve entries from + */ + public Date getDateFrom() + { + return this.dateFrom; + } + + /** + * Restricts the retrieved audit trail to only those entries + * that occurred after the given date. + * + * @param dateFrom Date to retrieve entries after + */ + public void setDateFrom(Date dateFrom) + { + this.dateFrom = dateFrom; + } + + /** + * + * @return The date to retrive entries to + */ + public Date getDateTo() + { + return this.dateTo; + } + + /** + * Restricts the retrieved audit trail to only those entries + * that occurred before the given date. + * + * @param dateTo Date to retrieve entries before + */ + public void setDateTo(Date dateTo) + { + this.dateTo = dateTo; + } + + /** + * + * @return The event to retrive entries for + */ + public String getEvent() + { + return this.event; + } + + /** + * Restricts the retrieved audit trail to only those entries + * that match the given event string. + * + * @param event Event to retrieve entries for + */ + public void setEvent(String event) + { + this.event = event; + } + + /** + * + * @return The property to retrieve entries for + */ + public QName getProperty() + { + return this.property; + } + + /** + * Restricts the audit trail to only those entries that involve + * the given property. + * + * @param property The property to retrieve entries for + */ + public void setProperty(QName property) + { + this.property = property; + } + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(super.toString()); + + builder.append(" (nodeRef='").append(nodeRef).append("', user='") + .append(user).append("', dateFrom='").append(dateFrom) + .append("', dateTo='").append(dateTo).append("', maxEntries='") + .append(maxEntries).append("', event='").append(event) + .append("', property='").append(property).append("')"); + + return builder.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java index 1d5b9c81a8..e2a2c4d577 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java @@ -1,213 +1,213 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit; - -import java.io.File; -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management audit service. - * - * @author Gavin Cornwell - */ -public interface RecordsManagementAuditService extends RecordsManagementAuditServiceDeprecated -{ - public enum ReportFormat { HTML, JSON } - - - - /** - * Retrieves a list of audit events. - * - * @return List of audit events - */ - List getAuditEvents(); - - /** - * Register audit event. - *

- * Creates an instance of a simple audit event and registers it with - * the service. - * - * @param name name of audit event - * @param label display label of audit event - */ - void registerAuditEvent(String name, String label); - - /** - * Register audit event. - * - * @param auditEvent audit event - */ - void registerAuditEvent(AuditEvent auditEvent); - - /** - * Audits an event, assumes no properties where modified and that the event should not be audited - * immediately. - * - * @param nodeRef node reference - * @param eventName event name - */ - void auditEvent(NodeRef nodeRef, - String eventName); - - /** - * Audits an event, assumes that the event should not be audited immediately and not be removed if no property is changed. - * - * @param nodeRef node reference - * @param eventName event name - * @param before property values before event - * @param after property values after event - */ - void auditEvent(NodeRef nodeRef, - String eventName, - Map before, - Map after); - - /** - * Audit event, assumes not to be removed if no property is changed. - * - * @param nodeRef node reference - * @param eventName event name - * @param before property values before event - * @param after property values after event - * @param immediate true if event is to be audited immediately, false otherwise - */ - void auditEvent(NodeRef nodeRef, - String eventName, - Map before, - Map after, - boolean immediate); - - /** - * Audit event. - * - * @param nodeRef node reference - * @param eventName event name - * @param before property values before event - * @param after property values after event - * @param immediate true if event is to be audited immediately, false otherwise - * @param removeIfNoPropertyChanged true if event is not audited when there are no properties changed, false otherwise - */ - void auditEvent(NodeRef nodeRef, - String eventName, - Map before, - Map after, - boolean immediate, - boolean removeIfNoPropertyChanged); - - /** - * Determines whether the RM audit log is currently enabled. - * - * @param filePlan file plan - * @return true if RM auditing is active false otherwise - */ - boolean isAuditLogEnabled(NodeRef filePlan); - - /** - * Start RM auditing. - * - * @param filePlan file plan - */ - void startAuditLog(NodeRef filePlan); - - /** - * Stop RM auditing. - * - * @param filePlan file plan - */ - void stopAuditLog(NodeRef filePlan); - - - /** - * Clears the RM audit. - * - * @param filePlan file plan - */ - void clearAuditLog(NodeRef filePlan); - - /** - * Returns the date the RM audit was last started. - * - * @param filePlan file plan - * @return Date the audit was last started - */ - Date getDateAuditLogLastStarted(NodeRef filePlan); - - /** - * Returns the date the RM audit was last stopped. - * - * @return Date the audit was last stopped - */ - Date getDateAuditLogLastStopped(NodeRef filePlan); - - /** - * Retrieves a list of audit log entries using the provided parameters - * represented by the RecordsManagementAuditQueryParameters instance. - *

- * The parameters are all optional so an empty RecordsManagementAuditQueryParameters - * object will result in ALL audit log entries for the RM system being - * returned. Setting the various parameters effectively filters the full - * audit trail. - * - * @param params Parameters to use to retrieve audit trail (never null) - * @param format The format the report should be produced in - * @return File containing JSON representation of audit trail - */ - File getAuditTrailFile(RecordsManagementAuditQueryParameters params, ReportFormat format); - - /** - * Retrieves a list of audit log entries using the provided parameters - * represented by the RecordsManagementAuditQueryParameters instance. - *

- * The parameters are all optional so an empty RecordsManagementAuditQueryParameters - * object will result in ALL audit log entries for the RM system being - * returned. Setting the various parameters effectively filters the full - * audit trail. - * - * @param params Parameters to use to retrieve audit trail (never null) - * @return All entries for the audit trail - */ - List getAuditTrail(RecordsManagementAuditQueryParameters params); - - /** - * Retrieves a list of audit log entries using the provided parameters - * represented by the RecordsManagementAuditQueryParameters instance and - * then files the resulting log as an undeclared record in the record folder - * represented by the given NodeRef. - *

- * The parameters are all optional so an empty RecordsManagementAuditQueryParameters - * object will result in ALL audit log entries for the RM system being - * returned. Setting the various parameters effectively filters the full - * audit trail. - * - * @param params Parameters to use to retrieve audit trail (never null) - * @param destination NodeRef representing a record folder in which to file the audit log - * @param format The format the report should be produced in - * @return NodeRef of the undeclared record filed - */ - NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, NodeRef destination, ReportFormat format); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit; + +import java.io.File; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management audit service. + * + * @author Gavin Cornwell + */ +public interface RecordsManagementAuditService extends RecordsManagementAuditServiceDeprecated +{ + public enum ReportFormat { HTML, JSON } + + + + /** + * Retrieves a list of audit events. + * + * @return List of audit events + */ + List getAuditEvents(); + + /** + * Register audit event. + *

+ * Creates an instance of a simple audit event and registers it with + * the service. + * + * @param name name of audit event + * @param label display label of audit event + */ + void registerAuditEvent(String name, String label); + + /** + * Register audit event. + * + * @param auditEvent audit event + */ + void registerAuditEvent(AuditEvent auditEvent); + + /** + * Audits an event, assumes no properties where modified and that the event should not be audited + * immediately. + * + * @param nodeRef node reference + * @param eventName event name + */ + void auditEvent(NodeRef nodeRef, + String eventName); + + /** + * Audits an event, assumes that the event should not be audited immediately and not be removed if no property is changed. + * + * @param nodeRef node reference + * @param eventName event name + * @param before property values before event + * @param after property values after event + */ + void auditEvent(NodeRef nodeRef, + String eventName, + Map before, + Map after); + + /** + * Audit event, assumes not to be removed if no property is changed. + * + * @param nodeRef node reference + * @param eventName event name + * @param before property values before event + * @param after property values after event + * @param immediate true if event is to be audited immediately, false otherwise + */ + void auditEvent(NodeRef nodeRef, + String eventName, + Map before, + Map after, + boolean immediate); + + /** + * Audit event. + * + * @param nodeRef node reference + * @param eventName event name + * @param before property values before event + * @param after property values after event + * @param immediate true if event is to be audited immediately, false otherwise + * @param removeIfNoPropertyChanged true if event is not audited when there are no properties changed, false otherwise + */ + void auditEvent(NodeRef nodeRef, + String eventName, + Map before, + Map after, + boolean immediate, + boolean removeIfNoPropertyChanged); + + /** + * Determines whether the RM audit log is currently enabled. + * + * @param filePlan file plan + * @return true if RM auditing is active false otherwise + */ + boolean isAuditLogEnabled(NodeRef filePlan); + + /** + * Start RM auditing. + * + * @param filePlan file plan + */ + void startAuditLog(NodeRef filePlan); + + /** + * Stop RM auditing. + * + * @param filePlan file plan + */ + void stopAuditLog(NodeRef filePlan); + + + /** + * Clears the RM audit. + * + * @param filePlan file plan + */ + void clearAuditLog(NodeRef filePlan); + + /** + * Returns the date the RM audit was last started. + * + * @param filePlan file plan + * @return Date the audit was last started + */ + Date getDateAuditLogLastStarted(NodeRef filePlan); + + /** + * Returns the date the RM audit was last stopped. + * + * @return Date the audit was last stopped + */ + Date getDateAuditLogLastStopped(NodeRef filePlan); + + /** + * Retrieves a list of audit log entries using the provided parameters + * represented by the RecordsManagementAuditQueryParameters instance. + *

+ * The parameters are all optional so an empty RecordsManagementAuditQueryParameters + * object will result in ALL audit log entries for the RM system being + * returned. Setting the various parameters effectively filters the full + * audit trail. + * + * @param params Parameters to use to retrieve audit trail (never null) + * @param format The format the report should be produced in + * @return File containing JSON representation of audit trail + */ + File getAuditTrailFile(RecordsManagementAuditQueryParameters params, ReportFormat format); + + /** + * Retrieves a list of audit log entries using the provided parameters + * represented by the RecordsManagementAuditQueryParameters instance. + *

+ * The parameters are all optional so an empty RecordsManagementAuditQueryParameters + * object will result in ALL audit log entries for the RM system being + * returned. Setting the various parameters effectively filters the full + * audit trail. + * + * @param params Parameters to use to retrieve audit trail (never null) + * @return All entries for the audit trail + */ + List getAuditTrail(RecordsManagementAuditQueryParameters params); + + /** + * Retrieves a list of audit log entries using the provided parameters + * represented by the RecordsManagementAuditQueryParameters instance and + * then files the resulting log as an undeclared record in the record folder + * represented by the given NodeRef. + *

+ * The parameters are all optional so an empty RecordsManagementAuditQueryParameters + * object will result in ALL audit log entries for the RM system being + * returned. Setting the various parameters effectively filters the full + * audit trail. + * + * @param params Parameters to use to retrieve audit trail (never null) + * @param destination NodeRef representing a record folder in which to file the audit log + * @param format The format the report should be produced in + * @return NodeRef of the undeclared record filed + */ + NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, NodeRef destination, ReportFormat format); +} 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 dfe8aab534..50c142e7f1 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 @@ -1,1750 +1,1750 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.repo.audit.AuditComponent; -import org.alfresco.repo.audit.model.AuditApplication; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.transaction.TransactionalResourceHelper; -import org.alfresco.service.cmr.audit.AuditQueryParameters; -import org.alfresco.service.cmr.audit.AuditService; -import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MLText; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.Pair; -import org.alfresco.util.PropertyCheck; -import org.alfresco.util.PropertyMap; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.transaction.TransactionListenerAdapter; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.time.DateUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Records Management Audit Service Implementation. - * - * @author Gavin Cornwell - * @since 3.2 - */ -public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean - implements RecordsManagementAuditService -{ - /** I18N */ - private static final String MSG_TRAIL_FILE_FAIL = "rm.audit.trail-file-fail"; - private static final String MSG_AUDIT_REPORT = "rm.audit.audit-report"; - - /** Logger */ - private static Log logger = LogFactory.getLog(RecordsManagementAuditServiceImpl.class); - - private static final String ACCESS_AUDIT_CAPABILITY = "AccessAudit"; - - private static final String KEY_RM_AUDIT_NODE_RECORDS = "RMAUditNodeRecords"; - - protected static final String RM_AUDIT_EVENT_LOGIN_SUCCESS = "Login.Success"; - protected static final String RM_AUDIT_EVENT_LOGIN_FAILURE = "Login.Failure"; - - protected static final String RM_AUDIT_APPLICATION_NAME = "RM"; - protected static final String RM_AUDIT_PATH_ROOT = "/RM"; - protected static final String RM_AUDIT_SNIPPET_EVENT = "/event"; - protected static final String RM_AUDIT_SNIPPET_PERSON = "/person"; - protected static final String RM_AUDIT_SNIPPET_NAME = "/name"; - protected static final String RM_AUDIT_SNIPPET_NODE = "/node"; - protected static final String RM_AUDIT_SNIPPET_CHANGES = "/changes"; - protected static final String RM_AUDIT_SNIPPET_BEFORE = "/before"; - protected static final String RM_AUDIT_SNIPPET_AFTER = "/after"; - - protected static final String RM_AUDIT_DATA_PERSON_FULLNAME = "/RM/event/person/fullName"; - protected static final String RM_AUDIT_DATA_PERSON_ROLES = "/RM/event/person/roles"; - protected static final String RM_AUDIT_DATA_EVENT_NAME = "/RM/event/name/value"; - protected static final String RM_AUDIT_DATA_NODE_NODEREF = "/RM/event/node/noderef"; - protected static final String RM_AUDIT_DATA_NODE_NAME = "/RM/event/node/name"; - protected static final String RM_AUDIT_DATA_NODE_TYPE = "/RM/event/node/type"; - protected static final String RM_AUDIT_DATA_NODE_IDENTIFIER = "/RM/event/node/identifier"; - protected static final String RM_AUDIT_DATA_NODE_NAMEPATH = "/RM/event/node/namePath"; - protected static final String RM_AUDIT_DATA_NODE_CHANGES_BEFORE = "/RM/event/node/changes/before/value"; - protected static final String RM_AUDIT_DATA_NODE_CHANGES_AFTER = "/RM/event/node/changes/after/value"; - - protected static final String RM_AUDIT_DATA_LOGIN_USERNAME = "/RM/login/args/userName/value"; - protected static final String RM_AUDIT_DATA_LOGIN_FULLNAME = "/RM/login/no-error/fullName"; - protected static final String RM_AUDIT_DATA_LOGIN_ERROR = "/RM/login/error/value"; - - /* Provide Backward compatibility with DOD5015 Audit Events RM-904*/ - protected static final String DOD5015_AUDIT_APPLICATION_NAME = "DOD5015"; - protected static final String DOD5015_AUDIT_PATH_ROOT = "/DOD5015"; - protected static final String DOD5015_AUDIT_SNIPPET_EVENT = "/event"; - protected static final String DOD5015_AUDIT_SNIPPET_PERSON = "/person"; - protected static final String DOD5015_AUDIT_SNIPPET_NAME = "/name"; - protected static final String DOD5015_AUDIT_SNIPPET_NODE = "/node"; - protected static final String DOD5015_AUDIT_SNIPPET_CHANGES = "/changes"; - protected static final String DOD5015_AUDIT_SNIPPET_BEFORE = "/before"; - protected static final String DOD5015_AUDIT_SNIPPET_AFTER = "/after"; - - protected static final String DOD5015_AUDIT_DATA_PERSON_FULLNAME = "/DOD5015/event/person/fullName"; - protected static final String DOD5015_AUDIT_DATA_PERSON_ROLES = "/DOD5015/event/person/roles"; - protected static final String DOD5015_AUDIT_DATA_EVENT_NAME = "/DOD5015/event/name/value"; - protected static final String DOD5015_AUDIT_DATA_NODE_NODEREF = "/DOD5015/event/node/noderef"; - protected static final String DOD5015_AUDIT_DATA_NODE_NAME = "/DOD5015/event/node/name"; - protected static final String DOD5015_AUDIT_DATA_NODE_TYPE = "/DOD5015/event/node/type"; - protected static final String DOD5015_AUDIT_DATA_NODE_IDENTIFIER = "/DOD5015/event/node/identifier"; - protected static final String DOD5015_AUDIT_DATA_NODE_NAMEPATH = "/DOD5015/event/node/namePath"; - protected static final String DOD5015_AUDIT_DATA_NODE_CHANGES_BEFORE = "/DOD5015/event/node/changes/before/value"; - protected static final String DOD5015_AUDIT_DATA_NODE_CHANGES_AFTER = "/DOD5015/event/node/changes/after/value"; - - protected static final String DOD5015_AUDIT_DATA_LOGIN_USERNAME = "/DOD5015/login/args/userName/value"; - protected static final String DOD5015_AUDIT_DATA_LOGIN_FULLNAME = "/DOD5015/login/no-error/fullName"; - protected static final String DOD5015_AUDIT_DATA_LOGIN_ERROR = "/DOD5015/login/error/value"; - /* End Backward compatibility with DOD5015 Audit Events */ - - protected static final String AUDIT_TRAIL_FILE_PREFIX = "audit_"; - protected static final String AUDIT_TRAIL_JSON_FILE_SUFFIX = ".json"; - protected static final String AUDIT_TRAIL_HTML_FILE_SUFFIX = ".html"; - - /** Audit auditing events */ - private static final String AUDIT_EVENT_START = "audit.start"; - private static final String MSG_AUDIT_START = "rm.audit.audit-start"; - private static final String AUDIT_EVENT_STOP = "audit.stop"; - private static final String MSG_AUDIT_STOP = "rm.audit.audit-stop"; - private static final String AUDIT_EVENT_CLEAR = "audit.clear"; - private static final String MSG_AUDIT_CLEAR = "rm.audit.audit-clear"; - private static final String AUDIT_EVENT_VIEW = "audit.view"; - private static final String MSG_AUDIT_VIEW = "rm.audit.audit-view"; - - private PolicyComponent policyComponent; - private DictionaryService dictionaryService; - private TransactionService transactionService; - private NodeService nodeService; - private ContentService contentService; - private AuditComponent auditComponent; - private AuditService auditService; - private RecordsManagementActionService rmActionService; - private FilePlanService filePlanService; - private NamespaceService namespaceService; - protected CapabilityService capabilityService; - - private boolean shutdown = false; - - private List ignoredAuditProperties; - - private List propertiesToBeRemoved = new ArrayList(); - - private RMAuditTxnListener txnListener = new RMAuditTxnListener(); - - /** Registered and initialised records management auditEvents */ - private Map auditEvents = new HashMap(); - - /** - * Set the component used to bind to behaviour callbacks - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * Provides user-readable names for types - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Set the component used to start new transactions - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * Sets the NodeService instance - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Sets the ContentService instance - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * The component to create audit events - */ - public void setAuditComponent(AuditComponent auditComponent) - { - this.auditComponent = auditComponent; - } - - /** - * Sets the AuditService instance - */ - public void setAuditService(AuditService auditService) - { - this.auditService = auditService; - } - - /** - * Sets the RecordsManagementActionService instance - */ - public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) - { - this.rmActionService = rmActionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - - - - /** - * @param ignoredAuditProperties - */ - public void setIgnoredAuditProperties(List ignoredAuditProperties) - { - this.ignoredAuditProperties = ignoredAuditProperties; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(java.lang.String, java.lang.String) - */ - @Override - public void registerAuditEvent(String name, String label) - { - registerAuditEvent(new AuditEvent(name, label)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent) - */ - @Override - public void registerAuditEvent(AuditEvent auditEvent) - { - if (logger.isDebugEnabled()) - { - logger.debug("Registering audit event " + auditEvent.getName()); - } - - this.auditEvents.put(auditEvent.getName(), auditEvent); - } - - /** - * Checks that all necessary properties have been set. - */ - public void init() - { - PropertyCheck.mandatory(this, "policyComponent", policyComponent); - PropertyCheck.mandatory(this, "transactionService", transactionService); - PropertyCheck.mandatory(this, "nodeService", nodeService); - PropertyCheck.mandatory(this, "contentService", contentService); - PropertyCheck.mandatory(this, "auditComponent", auditComponent); - PropertyCheck.mandatory(this, "auditService", auditService); - PropertyCheck.mandatory(this, "rmActionService", rmActionService); - PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); - PropertyCheck.mandatory(this, "filePlanService", filePlanService); - - // register audit auditing events - registerAuditEvent(AUDIT_EVENT_CLEAR, MSG_AUDIT_CLEAR); - registerAuditEvent(AUDIT_EVENT_START, MSG_AUDIT_START); - registerAuditEvent(AUDIT_EVENT_STOP, MSG_AUDIT_STOP); - registerAuditEvent(AUDIT_EVENT_VIEW, MSG_AUDIT_VIEW); - - // properties to be ignored by audit - for (String qname : ignoredAuditProperties) - { - this.propertiesToBeRemoved.add(QName.createQName(qname, this.namespaceService)); - } - } - - /** - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) - */ - @Override - protected void onBootstrap(ApplicationEvent event) - { - shutdown = false; - } - - /** - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) - */ - @Override - protected void onShutdown(ApplicationEvent event) - { - shutdown = true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#isAuditLogEnabled(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isAuditLogEnabled(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - return auditService.isAuditEnabled( - RM_AUDIT_APPLICATION_NAME, - RM_AUDIT_PATH_ROOT); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#startAuditLog(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void startAuditLog(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - auditService.enableAudit( - RM_AUDIT_APPLICATION_NAME, - RM_AUDIT_PATH_ROOT); - - if (logger.isInfoEnabled()) - { - logger.info("Started Records Management auditing"); - } - - auditEvent(filePlan, AUDIT_EVENT_START, null, null, true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#stopAuditLog(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void stopAuditLog(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - auditEvent(filePlan, AUDIT_EVENT_STOP, null, null, true); - - auditService.disableAudit( - RM_AUDIT_APPLICATION_NAME, - RM_AUDIT_PATH_ROOT); - - if (logger.isInfoEnabled()) - { - logger.info("Stopped Records Management auditing"); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#clearAuditLog(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void clearAuditLog(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - auditService.clearAudit(RM_AUDIT_APPLICATION_NAME, null, null); - if (logger.isInfoEnabled()) - { - logger.debug("Records Management audit log has been cleared"); - } - - auditEvent(filePlan, AUDIT_EVENT_CLEAR, null, null, true); - } - - /** - * {@inheritDoc} - */ - @Override - public Date getDateAuditLogLastStarted(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - // TODO: return proper date, for now it's today's date - return getStartOfDay(new Date()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#getDateAuditLogLastStopped(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Date getDateAuditLogLastStopped(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - // TODO use file plan to scope audit log - - // TODO: return proper date, for now it's today's date - return getEndOfDay(new Date()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public void auditEvent(NodeRef nodeRef, String eventName) - { - auditEvent(nodeRef, eventName, null, null, false, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map) - */ - @Override - public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after) - { - auditEvent(nodeRef, eventName, before, after, false, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) - */ - @Override - public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate) - { - auditEvent(nodeRef, eventName, before, after, immediate, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) - */ - @Override - public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate, boolean removeIfNoPropertyChanged) - { - // deal with immediate auditing if required - if (immediate) - { - Map auditMap = buildAuditMap(nodeRef, eventName, before, after, removeIfNoPropertyChanged); - auditComponent.recordAuditValues(RM_AUDIT_PATH_ROOT, auditMap); - } - else - { - Set auditDetails = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS); - AlfrescoTransactionSupport.bindListener(txnListener); - - // RM-936: Eliminate multiple audit maps from being generated when events with the same name are required to be fired multiple times in the same transaction. - // Check if auditDetails already contains an auditedNode with the same combination of nodeRef and eventName. - boolean auditNodeAlreadyExists = false; - for (RMAuditNode existingRMAuditNode : auditDetails) - { - if (existingRMAuditNode.getNodeRef().equals(nodeRef) && existingRMAuditNode.getEventName().equals(eventName)) - { - // If there exists such an auditNode, update its 'after' properties with the latest set of properties and leave its 'before' properties unchanged so that it - // retains the original set of properties. The first 'before' and last 'after' will be diff'ed when comes to building the auditMap later when the transaction - // commits. - existingRMAuditNode.setNodePropertiesAfter(after); - auditNodeAlreadyExists = true; - break; - } - } - - if (!auditNodeAlreadyExists) - { - // Create a new auditNode if it doesn't already exist - RMAuditNode auditedNode = new RMAuditNode(); - auditedNode.setNodeRef(nodeRef); - auditedNode.setEventName(eventName); - auditedNode.setNodePropertiesBefore(before); - auditedNode.setNodePropertiesAfter(after); - auditedNode.setRemoveIfNoPropertyChanged(removeIfNoPropertyChanged); - - auditDetails.add(auditedNode); - } - } - } - - /** - * Helper method to build audit map - * - * @param nodeRef - * @param eventName - * @return - * @since 2.0.3 - */ - private Map buildAuditMap(NodeRef nodeRef, String eventName, Map propertiesBefore, Map propertiesAfter, boolean removeOnNoPropertyChange) - { - Map auditMap = new HashMap(13); - auditMap.put( - AuditApplication.buildPath( - RM_AUDIT_SNIPPET_EVENT, - RM_AUDIT_SNIPPET_NAME), - eventName); - - if (nodeRef != null) - { - auditMap.put( - AuditApplication.buildPath( - RM_AUDIT_SNIPPET_EVENT, - RM_AUDIT_SNIPPET_NODE), - nodeRef); - } - - // Filter out any properties to be audited if specified in the Spring configuration. - if (!ignoredAuditProperties.isEmpty()) - { - removeAuditProperties(propertiesBefore, propertiesAfter); - } - - // Property changes - Pair, Map> deltaPair = PropertyMap.getBeforeAndAfterMapsForChanges(propertiesBefore, propertiesAfter); - - // If both the first and second Map in the deltaPair are empty and removeOnNoPropertyChange is true, the entire auditMap is discarded so it won't be audited. - if (deltaPair.getFirst().isEmpty() && deltaPair.getSecond().isEmpty() && removeOnNoPropertyChange) - { - auditMap.clear(); - } - else - { - auditMap.put( - AuditApplication.buildPath( - RM_AUDIT_SNIPPET_EVENT, - RM_AUDIT_SNIPPET_NODE, - RM_AUDIT_SNIPPET_CHANGES, - RM_AUDIT_SNIPPET_BEFORE), - (Serializable) deltaPair.getFirst()); - auditMap.put( - AuditApplication.buildPath( - RM_AUDIT_SNIPPET_EVENT, - RM_AUDIT_SNIPPET_NODE, - RM_AUDIT_SNIPPET_CHANGES, - RM_AUDIT_SNIPPET_AFTER), - (Serializable) deltaPair.getSecond()); - } - return auditMap; - } - - /** - * Helper method to remove system properties from maps - * - * @param properties - */ - private void removeAuditProperties(Map before, Map after) - { - if (before != null) - { - before.keySet().removeAll(this.propertiesToBeRemoved); - } - if (after != null) - { - after.keySet().removeAll(this.propertiesToBeRemoved); - } - } - - /** - * A stateless transaction listener for RM auditing. This component picks up the data of modified nodes and generates the audit information. - *

- * This class is not static so that the instances will have access to the action's implementation. - * - * @author Derek Hulley - * @since 3.2 - */ - private class RMAuditTxnListener extends TransactionListenerAdapter - { - private final Log logger = LogFactory.getLog(RecordsManagementAuditServiceImpl.class); - - /* - * Equality and hashcode generation are left unimplemented; we expect to only have a single - * instance of this class per action. - */ - - /** - * Get the action parameters from the transaction and audit them. - */ - @Override - public void afterCommit() - { - final Set auditedNodes = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS); - - // Start a *new* read-write transaction to audit in - RetryingTransactionCallback auditCallback = new RetryingTransactionCallback() - { - @Override - public Void execute() throws Throwable - { - auditInTxn(auditedNodes); - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback, false, true); - } - - /** - * Do the actual auditing, assuming the presence of a viable transaction - * - * @param auditedNodes details of the nodes that were modified - */ - private void auditInTxn(Set auditedNodes) throws Throwable - { - // Go through all the audit information and audit it - boolean auditedSomething = false; - for (RMAuditNode auditedNode : auditedNodes) - { - NodeRef nodeRef = auditedNode.getNodeRef(); - - // If the node is gone, then do nothing - if (nodeRef != null && !nodeService.exists(nodeRef)) - { - continue; - } - - // build the audit map - Map auditMap = buildAuditMap(nodeRef, - auditedNode.getEventName(), - auditedNode.getNodePropertiesBefore(), - auditedNode.getNodePropertiesAfter(), - auditedNode.getRemoveIfNoPropertyChanged()); - // Audit it - if (logger.isDebugEnabled()) - { - logger.debug("RM Audit: Auditing values: \n" + auditMap); - } - auditMap = auditComponent.recordAuditValues(RM_AUDIT_PATH_ROOT, auditMap); - if (auditMap.isEmpty()) - { - if (logger.isDebugEnabled()) - { - logger.debug("RM Audit: Nothing was audited."); - } - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("RM Audit: Audited values: \n" + auditMap); - } - // We must commit the transaction to get the values in - auditedSomething = true; - } - } - // Check if anything was audited - if (!auditedSomething) - { - // Nothing was audited, so do nothing - RetryingTransactionHelper.getActiveUserTransaction().setRollbackOnly(); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public File getAuditTrailFile(RecordsManagementAuditQueryParameters params, ReportFormat format) - { - ParameterCheck.mandatory("params", params); - - Writer fileWriter = null; - try - { - File auditTrailFile = TempFileProvider.createTempFile(AUDIT_TRAIL_FILE_PREFIX, - format == ReportFormat.HTML ? AUDIT_TRAIL_HTML_FILE_SUFFIX : AUDIT_TRAIL_JSON_FILE_SUFFIX); - fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(auditTrailFile),"UTF8")); - // Get the results, dumping to file - getAuditTrailImpl(params, null, fileWriter, format); - // Done - return auditTrailFile; - } - catch (IOException e) - { - throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e); - } - finally - { - // close the writer - if (fileWriter != null) - { - try { fileWriter.close(); } catch (IOException closeEx) {} - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public List getAuditTrail(RecordsManagementAuditQueryParameters params) - { - ParameterCheck.mandatory("params", params); - - List entries = new ArrayList(50); - try - { - getAuditTrailImpl(params, entries, null, null); - // Done - return entries; - } - catch (IOException e) - { - // Should be - throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e); - } - } - - /** - * Get the audit trail, optionally dumping the results the the given writer dumping to a list. - * - * @param params the search parameters - * @param results the list to which individual results will be dumped - * @param writer Writer to write the audit trail - * @param reportFormat Format to write the audit trail in, ignored if writer is null - */ - private void getAuditTrailImpl( - final RecordsManagementAuditQueryParameters params, - final List results, - final Writer writer, - final ReportFormat reportFormat) - throws IOException - { - if (logger.isDebugEnabled()) - { - logger.debug("Retrieving audit trail in '" + reportFormat + "' format using parameters: " + params); - } - - // define the callback - AuditQueryCallback callback = new AuditQueryCallback() - { - private boolean firstEntry = true; - - - @Override - public boolean valuesRequired() - { - return true; - } - - /** - * Just log the error, but continue - */ - @Override - public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error) - { - logger.warn(errorMsg, error); - return true; - } - - @Override - @SuppressWarnings("unchecked") - public boolean handleAuditEntry( - Long entryId, - String applicationName, - String user, - long time, - Map values) - { - // Check for context shutdown - if (shutdown) - { - return false; - } - - - Date timestamp = new Date(time); - String eventName = null; - String fullName = null; - String userRoles = null; - NodeRef nodeRef = null; - String nodeName = null; - String nodeType = null; - String nodeIdentifier = null; - String namePath = null; - Map beforeProperties = null; - Map afterProperties = null; - - if (values.containsKey(RM_AUDIT_DATA_EVENT_NAME)) - { - // This data is /RM/event/... - eventName = (String) values.get(RM_AUDIT_DATA_EVENT_NAME); - fullName = (String) values.get(RM_AUDIT_DATA_PERSON_FULLNAME); - userRoles = (String) values.get(RM_AUDIT_DATA_PERSON_ROLES); - nodeRef = (NodeRef) values.get(RM_AUDIT_DATA_NODE_NODEREF); - nodeName = (String) values.get(RM_AUDIT_DATA_NODE_NAME); - QName nodeTypeQname = (QName) values.get(RM_AUDIT_DATA_NODE_TYPE); - nodeIdentifier = (String) values.get(RM_AUDIT_DATA_NODE_IDENTIFIER); - namePath = (String) values.get(RM_AUDIT_DATA_NODE_NAMEPATH); - beforeProperties = (Map) values.get(RM_AUDIT_DATA_NODE_CHANGES_BEFORE); - afterProperties = (Map) values.get(RM_AUDIT_DATA_NODE_CHANGES_AFTER); - - // Convert some of the values to recognizable forms - nodeType = null; - if (nodeTypeQname != null) - { - TypeDefinition typeDef = dictionaryService.getType(nodeTypeQname); - nodeType = (typeDef != null) ? typeDef.getTitle(dictionaryService) : null; - } - } - else if (values.containsKey(DOD5015_AUDIT_DATA_EVENT_NAME)) - { - // This data is /RM/event/... - eventName = (String) values.get(DOD5015_AUDIT_DATA_EVENT_NAME); - fullName = (String) values.get(DOD5015_AUDIT_DATA_PERSON_FULLNAME); - userRoles = (String) values.get(DOD5015_AUDIT_DATA_PERSON_ROLES); - nodeRef = (NodeRef) values.get(DOD5015_AUDIT_DATA_NODE_NODEREF); - nodeName = (String) values.get(DOD5015_AUDIT_DATA_NODE_NAME); - QName nodeTypeQname = (QName) values.get(DOD5015_AUDIT_DATA_NODE_TYPE); - nodeIdentifier = (String) values.get(DOD5015_AUDIT_DATA_NODE_IDENTIFIER); - namePath = (String) values.get(DOD5015_AUDIT_DATA_NODE_NAMEPATH); - beforeProperties = (Map) values.get( DOD5015_AUDIT_DATA_NODE_CHANGES_BEFORE); - afterProperties = (Map) values.get(DOD5015_AUDIT_DATA_NODE_CHANGES_AFTER); - - // Convert some of the values to recognizable forms - nodeType = null; - if (nodeTypeQname != null) - { - TypeDefinition typeDef = dictionaryService.getType(nodeTypeQname); - nodeType = (typeDef != null) ? typeDef.getTitle(dictionaryService) : null; - } - } - else if (values.containsKey(RM_AUDIT_DATA_LOGIN_USERNAME)) - { - user = (String) values.get(RM_AUDIT_DATA_LOGIN_USERNAME); - if (values.containsKey(RM_AUDIT_DATA_LOGIN_ERROR)) - { - eventName = RM_AUDIT_EVENT_LOGIN_FAILURE; - // The user didn't log in - fullName = user; - } - else - { - eventName = RM_AUDIT_EVENT_LOGIN_SUCCESS; - fullName = (String) values.get(RM_AUDIT_DATA_LOGIN_FULLNAME); - } - } - else if (values.containsKey(DOD5015_AUDIT_DATA_LOGIN_USERNAME)) - { - user = (String) values.get(DOD5015_AUDIT_DATA_LOGIN_USERNAME); - if (values.containsKey(DOD5015_AUDIT_DATA_LOGIN_ERROR)) - { - eventName = RM_AUDIT_EVENT_LOGIN_FAILURE; - // The user didn't log in - fullName = user; - } - else - { - eventName = RM_AUDIT_EVENT_LOGIN_SUCCESS; - fullName = (String) values.get(DOD5015_AUDIT_DATA_LOGIN_FULLNAME); - } - } - else - { - // This is not recognisable data - logger.warn( - "Unable to process audit entry for RM. Unexpected data: \n" + - " Entry: " + entryId + "\n" + - " Data: " + values); - // Skip it - return true; - } - - if(nodeRef != null && nodeService.exists(nodeRef) && - !AccessStatus.ALLOWED.equals( - capabilityService.getCapabilityAccessState(nodeRef, ACCESS_AUDIT_CAPABILITY))) - { - return true; - } - - // TODO: Refactor this to use the builder pattern - RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry( - timestamp, - user, - fullName, - // A concatenated string of roles - userRoles, - nodeRef, - nodeName, - nodeType, - eventName, - nodeIdentifier, - namePath, - beforeProperties, - afterProperties); - - // write out the entry to the file in requested format - writeEntryToFile(entry); - - if (results != null) - { - results.add(entry); - } - - if (logger.isDebugEnabled()) - { - logger.debug(" " + entry); - } - - // Keep going - return true; - } - - private void writeEntryToFile(RecordsManagementAuditEntry entry) - { - if (writer == null) - { - return; - } - try - { - if (!firstEntry) - { - if (reportFormat == ReportFormat.HTML) - { - writer.write("\n"); - } - else - { - writer.write(","); - } - } - else - { - firstEntry = false; - } - - // write the entry to the file - if (reportFormat == ReportFormat.JSON) - { - writer.write("\n\t\t"); - } - - writeAuditTrailEntry(writer, entry, reportFormat); - } - catch (IOException ioe) - { - throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, ioe); - } - } - }; - - String user = params.getUser(); - Long fromTime = getFromDateTime(params.getDateFrom()); - Long toTime = getToDateTime(params.getDateTo()); - NodeRef nodeRef = params.getNodeRef(); - int maxEntries = params.getMaxEntries(); - // Reverse order if the results are limited - boolean forward = maxEntries > 0 ? false : true; - - // start the audit trail report - writeAuditTrailHeader(writer, params, reportFormat); - - if (logger.isDebugEnabled()) - { - logger.debug("RM Audit: Issuing query: " + params); - } - - // Build audit query parameters - AuditQueryParameters dod5015AuditQueryParams = new AuditQueryParameters(); - dod5015AuditQueryParams.setForward(forward); - dod5015AuditQueryParams.setApplicationName(DOD5015_AUDIT_APPLICATION_NAME); - dod5015AuditQueryParams.setUser(user); - dod5015AuditQueryParams.setFromTime(fromTime); - dod5015AuditQueryParams.setToTime(toTime); - if (nodeRef != null) - { - dod5015AuditQueryParams.addSearchKey(DOD5015_AUDIT_DATA_NODE_NODEREF, nodeRef); - } - - // - AuditQueryParameters auditQueryParams = new AuditQueryParameters(); - auditQueryParams.setForward(forward); - auditQueryParams.setApplicationName(RM_AUDIT_APPLICATION_NAME); - auditQueryParams.setUser(user); - auditQueryParams.setFromTime(fromTime); - auditQueryParams.setToTime(toTime); - if (nodeRef != null) - { - auditQueryParams.addSearchKey(RM_AUDIT_DATA_NODE_NODEREF, nodeRef); - } - else if (params.getEvent() != null) - { - auditQueryParams.addSearchKey(RM_AUDIT_DATA_EVENT_NAME, params.getEvent()); - } - - // Get audit entries - auditService.auditQuery(callback, dod5015AuditQueryParams, maxEntries); - auditService.auditQuery(callback, auditQueryParams, maxEntries); - - // finish off the audit trail report - writeAuditTrailFooter(writer, reportFormat); - - // audit that the audit has been view'ed - if (nodeRef == null) - { - // grab the default file plan, but don't fail if it can't be found! - nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - auditEvent(nodeRef, AUDIT_EVENT_VIEW, null, null, true); - } - - /** - * Calculates the start of the given date. - * For example, if you had the date time of 12 Aug 2013 12:10:15.158 - * the result would be 12 Aug 2013 00:00:00.000. - * - * @param date The date for which the start should be calculated. - * @return Returns the start of the given date. - */ - private Date getStartOfDay(Date date) - { - return DateUtils.truncate(date == null ? new Date() : date, Calendar.DATE); - } - - /** - * Gets the start of the from date - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditServiceImpl.getStartOfDay() - * - * @param date The date for which the start should be retrieved. - * @return Returns null if the given date is null, otherwise the start of the given day. - */ - private Date getFromDate(Date date) - { - return date == null ? null : getStartOfDay(date); - } - - /** - * Returns the number of milliseconds for the "from date". - * - * @param date The date for which the number of milliseconds should retrieved. - * @return Returns null if the given date is null, otherwise the number of milliseconds for the given date. - */ - private Long getFromDateTime(Date date) - { - Long fromDateTime = null; - Date fromDate = getFromDate(date); - if (fromDate != null) - { - fromDateTime = Long.valueOf(fromDate.getTime()); - } - return fromDateTime; - } - - /** - * Calculates the end of the given date. - * For example, if you had the date time of 12 Aug 2013 12:10:15.158 - * the result would be 12 Aug 2013 23:59:59.999. - * - * @param date The date for which the end should be calculated. - * @return Returns the end of the given date. - */ - private Date getEndOfDay(Date date) - { - return DateUtils.addMilliseconds(DateUtils.ceiling(date == null ? new Date() : date, Calendar.DATE), -1); - } - - /** - * Gets the end of the from date - * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditServiceImpl.getEndOfDay() - * - * @param date The date for which the end should be retrieved. - * @return Returns null if the given date is null, otherwise the end of the given day. - */ - private Date getToDate(Date date) - { - return date == null ? null : getEndOfDay(date); - } - - /** - * Returns the number of milliseconds for the "to date". - * - * @param date The date for which the number of milliseconds should retrieved. - * @return Returns null if the given date is null, otherwise the number of milliseconds for the given date. - */ - private Long getToDateTime(Date date) - { - Long toDateTime = null; - Date toDate = getToDate(date); - if (toDate != null) - { - toDateTime = Long.valueOf(toDate.getTime()); - } - return toDateTime; - } - - /** - * {@inheritDoc} - */ - @Override - public NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, - NodeRef destination, ReportFormat format) - { - ParameterCheck.mandatory("params", params); - ParameterCheck.mandatory("destination", destination); - - // NOTE: the underlying RM services will check all the remaining pre-conditions - - NodeRef record = null; - - // get the audit trail for the provided parameters - File auditTrail = this.getAuditTrailFile(params, format); - - if (logger.isDebugEnabled()) - { - logger.debug("Filing audit trail in file " + auditTrail.getAbsolutePath() + - " as a record in record folder: " + destination); - } - - try - { - Map properties = new HashMap(1); - properties.put(ContentModel.PROP_NAME, auditTrail.getName()); - - // file the audit log as an undeclared record - record = this.nodeService.createNode(destination, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - QName.createValidLocalName(auditTrail.getName())), - ContentModel.TYPE_CONTENT, properties).getChildRef(); - - // Set the content - ContentWriter writer = this.contentService.getWriter(record, ContentModel.PROP_CONTENT, true); - writer.setMimetype(format == ReportFormat.HTML ? MimetypeMap.MIMETYPE_HTML : MimetypeMap.MIMETYPE_JSON); - writer.setEncoding("UTF-8"); - writer.putContent(auditTrail); - } - finally - { - if (logger.isDebugEnabled()) - { - logger.debug("Audit trail report saved to temporary file: " + auditTrail.getAbsolutePath()); - } - else - { - auditTrail.delete(); - } - } - - return record; - } - - /** - * {@inheritDoc} - */ - @Override - public List getAuditEvents() - { - List listAuditEvents = new ArrayList(this.auditEvents.size()); - listAuditEvents.addAll(this.auditEvents.values()); - Collections.sort(listAuditEvents); - return listAuditEvents; - } - - /** - * Writes the start of the audit trail stream to the given writer - * - * @param writer The writer to write to - * @params params The parameters being used - * @param reportFormat The format to write the header in - * @throws IOException - */ - private void writeAuditTrailHeader(Writer writer, - RecordsManagementAuditQueryParameters params, - ReportFormat reportFormat) throws IOException - { - if (writer == null) - { - return; - } - - if (reportFormat == ReportFormat.HTML) - { - // write header as HTML - writer.write("\n"); - writer.write("\n\n"); - writer.write(""); - writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT)); - writer.write("\n"); - writer.write("\n"); - writer.write("\n

"); - writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT)); - writer.write("

\n"); - writer.write("
\n"); - - writer.write("From:"); - writer.write(""); - Date from = params.getDateFrom(); - writer.write(from == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(from.toString())); - writer.write(""); - - writer.write("To:"); - writer.write(""); - Date to = params.getDateTo(); - writer.write(to == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(to.toString())); - writer.write(""); - - writer.write("Property:"); - writer.write(""); - QName prop = params.getProperty(); - writer.write(prop == null ? "All" : StringEscapeUtils.escapeHtml(getPropertyLabel(prop))); - writer.write(""); - - writer.write("User:"); - writer.write(""); - writer.write(params.getUser() == null ? "All" : StringEscapeUtils.escapeHtml(params.getUser())); - writer.write(""); - - writer.write("Event:"); - writer.write(""); - writer.write(params.getEvent() == null ? "All" : StringEscapeUtils.escapeHtml(getAuditEventLabel(params.getEvent()))); - writer.write("\n"); - - writer.write("
\n"); - } - else - { - // write header as JSON - writer.write("{\n\t\"data\":\n\t{"); - writer.write("\n\t\t\"started\": \""); - writer.write(ISO8601DateFormat.format(getStartOfDay(params.getDateFrom()))); - writer.write("\",\n\t\t\"stopped\": \""); - writer.write(ISO8601DateFormat.format(getEndOfDay(params.getDateTo()))); - writer.write("\",\n\t\t\"enabled\": "); - writer.write(Boolean.toString(isEnabled())); - writer.write(",\n\t\t\"entries\":["); - } - } - - /** - * Writes an audit trail entry to the given writer - * - * @param writer The writer to write to - * @param entry The entry to write - * @param reportFormat The format to write the header in - * @throws IOException - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - private void writeAuditTrailEntry(Writer writer, RecordsManagementAuditEntry entry, - ReportFormat reportFormat) throws IOException - { - if (writer == null) - { - return; - } - - if (reportFormat == ReportFormat.HTML) - { - writer.write("
\n"); - writer.write("
"); - writer.write("Timestamp:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getTimestamp().toString())); - writer.write(""); - writer.write("User:"); - writer.write(""); - writer.write(entry.getFullName() != null ? - StringEscapeUtils.escapeHtml(entry.getFullName()) : - StringEscapeUtils.escapeHtml(entry.getUserName())); - writer.write(""); - if (entry.getUserRole() != null && entry.getUserRole().length() > 0) - { - writer.write("Role:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getUserRole())); - writer.write(""); - } - if (entry.getEvent() != null && entry.getEvent().length() > 0) - { - writer.write("Event:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(getAuditEventLabel(entry.getEvent()))); - writer.write("\n"); - } - writer.write("
\n"); - writer.write("
"); - if (entry.getIdentifier() != null && entry.getIdentifier().length() > 0) - { - writer.write("Identifier:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getIdentifier())); - writer.write(""); - } - if (entry.getNodeType() != null && entry.getNodeType().length() > 0) - { - writer.write("Type:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getNodeType())); - writer.write(""); - } - if (entry.getPath() != null && entry.getPath().length() > 0) - { - // we need to strip off the first part of the path - String path = entry.getPath(); - String displayPath = path; - int idx = path.indexOf('/', 1); - if (idx != -1) - { - displayPath = "/File Plan" + path.substring(idx); - } - - writer.write("Location:"); - writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(displayPath)); - writer.write(""); - } - writer.write("
\n"); - - if (entry.getChangedProperties() != null) - { - writer.write(""); - writer.write(""); - - // create an entry for each property that changed - for (QName valueName : entry.getChangedProperties().keySet()) - { - Pair values = entry.getChangedProperties().get(valueName); - writer.write(""); - } - - writer.write("
PropertyPrevious ValueNew Value
"); - writer.write(getPropertyLabel(valueName)); - writer.write(""); - - // inspect the property to determine it's data type - QName propDataType = DataTypeDefinition.TEXT; - PropertyDefinition propDef = dictionaryService.getProperty(valueName); - if (propDef != null) - { - propDataType = propDef.getDataType().getName(); - } - - if(DataTypeDefinition.MLTEXT.equals(propDataType)) - { - writer.write(values.getFirst() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getFirst()).getDefaultValue())); - writer.write(""); - writer.write(values.getSecond() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getSecond()).getDefaultValue())); - } - else - { - Serializable oldValue = values.getFirst(); - writer.write(oldValue == null ? "<none>" : StringEscapeUtils.escapeHtml(oldValue.toString())); - writer.write(""); - Serializable newValue = values.getSecond(); - writer.write(newValue == null ? "<none>" : StringEscapeUtils.escapeHtml(newValue.toString())); - } - - writer.write("
\n"); - } - - writer.write("
"); - } - else - { - try - { - JSONObject json = new JSONObject(); - - json.put("timestamp", entry.getTimestampString()); - json.put("userName", entry.getUserName()); - json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole()); - json.put("fullName", entry.getFullName() == null ? "": entry.getFullName()); - json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef()); - - // TODO: Find another way for checking the event - if (entry.getEvent().equals("Create Person") && entry.getNodeRef() != null) - { - NodeRef nodeRef = entry.getNodeRef(); - String userName = ""; - if (nodeService.exists(nodeRef)) - { - userName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); - } - json.put("nodeName", userName == null ? "" : userName); - json.put("createPerson", true); - } - else - { - json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); - } - - // TODO: Find another way for checking the event - if (entry.getEvent().equals("Delete RM Object")) - { - json.put("deleteObject", true); - } - - 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()); - json.put("path", entry.getPath() == null ? "": entry.getPath()); - - JSONArray changedValues = new JSONArray(); - - if (entry.getChangedProperties() != null) - { - // create an entry for each property that changed - for (QName valueName : entry.getChangedProperties().keySet()) - { - Pair values = entry.getChangedProperties().get(valueName); - - JSONObject changedValue = new JSONObject(); - changedValue.put("name", getPropertyLabel(valueName)); - - // inspect the property to determine it's data type - QName propDataType = DataTypeDefinition.TEXT; - PropertyDefinition propDef = dictionaryService.getProperty(valueName); - if (propDef != null) - { - propDataType = propDef.getDataType().getName(); - } - - // handle output of mltext properties - if(DataTypeDefinition.MLTEXT.equals(propDataType)) - { - changedValue.put("previous", values.getFirst() == null ? "" : convertToMlText((Map)values.getFirst()).getDefaultValue()); - changedValue.put("new", values.getSecond() == null ? "" : convertToMlText((Map)values.getSecond()).getDefaultValue()); - } - else - { - changedValue.put("previous", values.getFirst() == null ? "" : values.getFirst().toString()); - changedValue.put("new", values.getSecond() == null ? "" : values.getSecond().toString()); - } - - changedValues.put(changedValue); - } - } - - json.put("changedValues", changedValues); - - writer.write(json.toString()); - } - catch (JSONException je) - { - writer.write("{}"); - } - } - } - - /** - * Helper method to convert value to MLText - * - * @param map map of locale's and values - * @return {@link MLText} multilingual text value - */ - private MLText convertToMlText(Map map) - { - MLText mlText = new MLText(); - mlText.putAll(map); - return mlText; - } - - /** - * Writes the end of the audit trail stream to the given writer - * - * @param writer The writer to write to - * @param reportFormat The format to write the footer in - * @throws IOException - */ - private void writeAuditTrailFooter(Writer writer, ReportFormat reportFormat) throws IOException - { - if (writer == null) - { - return; - } - - if (reportFormat == ReportFormat.HTML) - { - // write footer as HTML - writer.write("\n"); - } - else - { - // write footer as JSON - writer.write("\n\t\t]\n\t}\n}"); - } - } - - /** - * Returns the display label for a property QName - * - * @param property The property to get label for - * @param ddService DictionaryService instance - * @param namespaceService NamespaceService instance - * @return The label - */ - private String getPropertyLabel(QName property) - { - String label = null; - - PropertyDefinition propDef = this.dictionaryService.getProperty(property); - if (propDef != null) - { - label = propDef.getTitle(dictionaryService); - } - - if (label == null) - { - label = property.getLocalName(); - } - - return label; - } - - /** - * Returns the display label for the given audit event key - * - * @param eventKey The audit event key - * @return The display label or null if the key does not exist - */ - private String getAuditEventLabel(String eventKey) - { - String label = eventKey; - - AuditEvent event = this.auditEvents.get(eventKey); - if (event != null) - { - label = event.getLabel(); - } - - return label; - } - - /** - * A class to carry audit information through the transaction. - * - * @author Derek Hulley - * @since 3.2 - */ - private static class RMAuditNode - { - private NodeRef nodeRef; - private String eventName; - private Map nodePropertiesBefore; - private Map nodePropertiesAfter; - private boolean removeIfNoPropertyChanged = false; - - public NodeRef getNodeRef() - { - return nodeRef; - } - - public void setNodeRef(NodeRef nodeRef) - { - this.nodeRef = nodeRef; - } - - public String getEventName() - { - return eventName; - } - - public void setEventName(String eventName) - { - this.eventName = eventName; - } - - public Map getNodePropertiesBefore() - { - return nodePropertiesBefore; - } - - public void setNodePropertiesBefore(Map nodePropertiesBefore) - { - this.nodePropertiesBefore = nodePropertiesBefore; - } - - public Map getNodePropertiesAfter() - { - return nodePropertiesAfter; - } - - public void setNodePropertiesAfter(Map nodePropertiesAfter) - { - this.nodePropertiesAfter = nodePropertiesAfter; - } - - public boolean getRemoveIfNoPropertyChanged() - { - return removeIfNoPropertyChanged; - } - - public void setRemoveIfNoPropertyChanged(boolean removeIfNoPropertyChanged) - { - this.removeIfNoPropertyChanged = removeIfNoPropertyChanged; - } - } - - /** Deprecated Method Implementations **/ - - /** - * Helper method to get the default file plan - * - * @return NodRef default file plan - */ - private NodeRef getDefaultFilePlan() - { - NodeRef defaultFilePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (defaultFilePlan == null) - { - throw new AlfrescoRuntimeException("Default file plan could not be found."); - } - return defaultFilePlan; - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public boolean isEnabled() - { - return isAuditLogEnabled(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - */ - @Deprecated - public void start() - { - startAuditLog(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public void stop() - { - stopAuditLog(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public Date getDateLastStarted() - { - return getDateAuditLogLastStarted(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public Date getDateLastStopped() - { - return getDateAuditLogLastStopped(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public void clear() - { - clearAuditLog(getDefaultFilePlan()); - } - - /** - * {@inheritDoc} - * @since 3.2 - * @deprecated since 2.1 - */ - @Override - @Deprecated - public void auditRMAction( - RecordsManagementAction action, - NodeRef nodeRef, - Map parameters) - { - auditEvent(nodeRef, action.getName()); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Serializable; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.repo.audit.AuditComponent; +import org.alfresco.repo.audit.model.AuditApplication; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.repo.transaction.TransactionalResourceHelper; +import org.alfresco.service.cmr.audit.AuditQueryParameters; +import org.alfresco.service.cmr.audit.AuditService; +import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.MLText; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.Pair; +import org.alfresco.util.PropertyCheck; +import org.alfresco.util.PropertyMap; +import org.alfresco.util.TempFileProvider; +import org.alfresco.util.transaction.TransactionListenerAdapter; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.context.ApplicationEvent; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.extensions.surf.util.ParameterCheck; + +/** + * Records Management Audit Service Implementation. + * + * @author Gavin Cornwell + * @since 3.2 + */ +public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean + implements RecordsManagementAuditService +{ + /** I18N */ + private static final String MSG_TRAIL_FILE_FAIL = "rm.audit.trail-file-fail"; + private static final String MSG_AUDIT_REPORT = "rm.audit.audit-report"; + + /** Logger */ + private static Log logger = LogFactory.getLog(RecordsManagementAuditServiceImpl.class); + + private static final String ACCESS_AUDIT_CAPABILITY = "AccessAudit"; + + private static final String KEY_RM_AUDIT_NODE_RECORDS = "RMAUditNodeRecords"; + + protected static final String RM_AUDIT_EVENT_LOGIN_SUCCESS = "Login.Success"; + protected static final String RM_AUDIT_EVENT_LOGIN_FAILURE = "Login.Failure"; + + protected static final String RM_AUDIT_APPLICATION_NAME = "RM"; + protected static final String RM_AUDIT_PATH_ROOT = "/RM"; + protected static final String RM_AUDIT_SNIPPET_EVENT = "/event"; + protected static final String RM_AUDIT_SNIPPET_PERSON = "/person"; + protected static final String RM_AUDIT_SNIPPET_NAME = "/name"; + protected static final String RM_AUDIT_SNIPPET_NODE = "/node"; + protected static final String RM_AUDIT_SNIPPET_CHANGES = "/changes"; + protected static final String RM_AUDIT_SNIPPET_BEFORE = "/before"; + protected static final String RM_AUDIT_SNIPPET_AFTER = "/after"; + + protected static final String RM_AUDIT_DATA_PERSON_FULLNAME = "/RM/event/person/fullName"; + protected static final String RM_AUDIT_DATA_PERSON_ROLES = "/RM/event/person/roles"; + protected static final String RM_AUDIT_DATA_EVENT_NAME = "/RM/event/name/value"; + protected static final String RM_AUDIT_DATA_NODE_NODEREF = "/RM/event/node/noderef"; + protected static final String RM_AUDIT_DATA_NODE_NAME = "/RM/event/node/name"; + protected static final String RM_AUDIT_DATA_NODE_TYPE = "/RM/event/node/type"; + protected static final String RM_AUDIT_DATA_NODE_IDENTIFIER = "/RM/event/node/identifier"; + protected static final String RM_AUDIT_DATA_NODE_NAMEPATH = "/RM/event/node/namePath"; + protected static final String RM_AUDIT_DATA_NODE_CHANGES_BEFORE = "/RM/event/node/changes/before/value"; + protected static final String RM_AUDIT_DATA_NODE_CHANGES_AFTER = "/RM/event/node/changes/after/value"; + + protected static final String RM_AUDIT_DATA_LOGIN_USERNAME = "/RM/login/args/userName/value"; + protected static final String RM_AUDIT_DATA_LOGIN_FULLNAME = "/RM/login/no-error/fullName"; + protected static final String RM_AUDIT_DATA_LOGIN_ERROR = "/RM/login/error/value"; + + /* Provide Backward compatibility with DOD5015 Audit Events RM-904*/ + protected static final String DOD5015_AUDIT_APPLICATION_NAME = "DOD5015"; + protected static final String DOD5015_AUDIT_PATH_ROOT = "/DOD5015"; + protected static final String DOD5015_AUDIT_SNIPPET_EVENT = "/event"; + protected static final String DOD5015_AUDIT_SNIPPET_PERSON = "/person"; + protected static final String DOD5015_AUDIT_SNIPPET_NAME = "/name"; + protected static final String DOD5015_AUDIT_SNIPPET_NODE = "/node"; + protected static final String DOD5015_AUDIT_SNIPPET_CHANGES = "/changes"; + protected static final String DOD5015_AUDIT_SNIPPET_BEFORE = "/before"; + protected static final String DOD5015_AUDIT_SNIPPET_AFTER = "/after"; + + protected static final String DOD5015_AUDIT_DATA_PERSON_FULLNAME = "/DOD5015/event/person/fullName"; + protected static final String DOD5015_AUDIT_DATA_PERSON_ROLES = "/DOD5015/event/person/roles"; + protected static final String DOD5015_AUDIT_DATA_EVENT_NAME = "/DOD5015/event/name/value"; + protected static final String DOD5015_AUDIT_DATA_NODE_NODEREF = "/DOD5015/event/node/noderef"; + protected static final String DOD5015_AUDIT_DATA_NODE_NAME = "/DOD5015/event/node/name"; + protected static final String DOD5015_AUDIT_DATA_NODE_TYPE = "/DOD5015/event/node/type"; + protected static final String DOD5015_AUDIT_DATA_NODE_IDENTIFIER = "/DOD5015/event/node/identifier"; + protected static final String DOD5015_AUDIT_DATA_NODE_NAMEPATH = "/DOD5015/event/node/namePath"; + protected static final String DOD5015_AUDIT_DATA_NODE_CHANGES_BEFORE = "/DOD5015/event/node/changes/before/value"; + protected static final String DOD5015_AUDIT_DATA_NODE_CHANGES_AFTER = "/DOD5015/event/node/changes/after/value"; + + protected static final String DOD5015_AUDIT_DATA_LOGIN_USERNAME = "/DOD5015/login/args/userName/value"; + protected static final String DOD5015_AUDIT_DATA_LOGIN_FULLNAME = "/DOD5015/login/no-error/fullName"; + protected static final String DOD5015_AUDIT_DATA_LOGIN_ERROR = "/DOD5015/login/error/value"; + /* End Backward compatibility with DOD5015 Audit Events */ + + protected static final String AUDIT_TRAIL_FILE_PREFIX = "audit_"; + protected static final String AUDIT_TRAIL_JSON_FILE_SUFFIX = ".json"; + protected static final String AUDIT_TRAIL_HTML_FILE_SUFFIX = ".html"; + + /** Audit auditing events */ + private static final String AUDIT_EVENT_START = "audit.start"; + private static final String MSG_AUDIT_START = "rm.audit.audit-start"; + private static final String AUDIT_EVENT_STOP = "audit.stop"; + private static final String MSG_AUDIT_STOP = "rm.audit.audit-stop"; + private static final String AUDIT_EVENT_CLEAR = "audit.clear"; + private static final String MSG_AUDIT_CLEAR = "rm.audit.audit-clear"; + private static final String AUDIT_EVENT_VIEW = "audit.view"; + private static final String MSG_AUDIT_VIEW = "rm.audit.audit-view"; + + private PolicyComponent policyComponent; + private DictionaryService dictionaryService; + private TransactionService transactionService; + private NodeService nodeService; + private ContentService contentService; + private AuditComponent auditComponent; + private AuditService auditService; + private RecordsManagementActionService rmActionService; + private FilePlanService filePlanService; + private NamespaceService namespaceService; + protected CapabilityService capabilityService; + + private boolean shutdown = false; + + private List ignoredAuditProperties; + + private List propertiesToBeRemoved = new ArrayList(); + + private RMAuditTxnListener txnListener = new RMAuditTxnListener(); + + /** Registered and initialised records management auditEvents */ + private Map auditEvents = new HashMap(); + + /** + * Set the component used to bind to behaviour callbacks + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * Provides user-readable names for types + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Set the component used to start new transactions + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * Sets the NodeService instance + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Sets the ContentService instance + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * The component to create audit events + */ + public void setAuditComponent(AuditComponent auditComponent) + { + this.auditComponent = auditComponent; + } + + /** + * Sets the AuditService instance + */ + public void setAuditService(AuditService auditService) + { + this.auditService = auditService; + } + + /** + * Sets the RecordsManagementActionService instance + */ + public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) + { + this.rmActionService = rmActionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + + + + /** + * @param ignoredAuditProperties + */ + public void setIgnoredAuditProperties(List ignoredAuditProperties) + { + this.ignoredAuditProperties = ignoredAuditProperties; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(java.lang.String, java.lang.String) + */ + @Override + public void registerAuditEvent(String name, String label) + { + registerAuditEvent(new AuditEvent(name, label)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent) + */ + @Override + public void registerAuditEvent(AuditEvent auditEvent) + { + if (logger.isDebugEnabled()) + { + logger.debug("Registering audit event " + auditEvent.getName()); + } + + this.auditEvents.put(auditEvent.getName(), auditEvent); + } + + /** + * Checks that all necessary properties have been set. + */ + public void init() + { + PropertyCheck.mandatory(this, "policyComponent", policyComponent); + PropertyCheck.mandatory(this, "transactionService", transactionService); + PropertyCheck.mandatory(this, "nodeService", nodeService); + PropertyCheck.mandatory(this, "contentService", contentService); + PropertyCheck.mandatory(this, "auditComponent", auditComponent); + PropertyCheck.mandatory(this, "auditService", auditService); + PropertyCheck.mandatory(this, "rmActionService", rmActionService); + PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); + PropertyCheck.mandatory(this, "filePlanService", filePlanService); + + // register audit auditing events + registerAuditEvent(AUDIT_EVENT_CLEAR, MSG_AUDIT_CLEAR); + registerAuditEvent(AUDIT_EVENT_START, MSG_AUDIT_START); + registerAuditEvent(AUDIT_EVENT_STOP, MSG_AUDIT_STOP); + registerAuditEvent(AUDIT_EVENT_VIEW, MSG_AUDIT_VIEW); + + // properties to be ignored by audit + for (String qname : ignoredAuditProperties) + { + this.propertiesToBeRemoved.add(QName.createQName(qname, this.namespaceService)); + } + } + + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onBootstrap(ApplicationEvent event) + { + shutdown = false; + } + + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onShutdown(ApplicationEvent event) + { + shutdown = true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#isAuditLogEnabled(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isAuditLogEnabled(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + return auditService.isAuditEnabled( + RM_AUDIT_APPLICATION_NAME, + RM_AUDIT_PATH_ROOT); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#startAuditLog(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void startAuditLog(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + auditService.enableAudit( + RM_AUDIT_APPLICATION_NAME, + RM_AUDIT_PATH_ROOT); + + if (logger.isInfoEnabled()) + { + logger.info("Started Records Management auditing"); + } + + auditEvent(filePlan, AUDIT_EVENT_START, null, null, true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#stopAuditLog(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void stopAuditLog(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + auditEvent(filePlan, AUDIT_EVENT_STOP, null, null, true); + + auditService.disableAudit( + RM_AUDIT_APPLICATION_NAME, + RM_AUDIT_PATH_ROOT); + + if (logger.isInfoEnabled()) + { + logger.info("Stopped Records Management auditing"); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#clearAuditLog(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void clearAuditLog(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + auditService.clearAudit(RM_AUDIT_APPLICATION_NAME, null, null); + if (logger.isInfoEnabled()) + { + logger.debug("Records Management audit log has been cleared"); + } + + auditEvent(filePlan, AUDIT_EVENT_CLEAR, null, null, true); + } + + /** + * {@inheritDoc} + */ + @Override + public Date getDateAuditLogLastStarted(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + // TODO: return proper date, for now it's today's date + return getStartOfDay(new Date()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#getDateAuditLogLastStopped(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Date getDateAuditLogLastStopped(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + // TODO use file plan to scope audit log + + // TODO: return proper date, for now it's today's date + return getEndOfDay(new Date()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public void auditEvent(NodeRef nodeRef, String eventName) + { + auditEvent(nodeRef, eventName, null, null, false, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map) + */ + @Override + public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after) + { + auditEvent(nodeRef, eventName, before, after, false, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) + */ + @Override + public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate) + { + auditEvent(nodeRef, eventName, before, after, immediate, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) + */ + @Override + public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate, boolean removeIfNoPropertyChanged) + { + // deal with immediate auditing if required + if (immediate) + { + Map auditMap = buildAuditMap(nodeRef, eventName, before, after, removeIfNoPropertyChanged); + auditComponent.recordAuditValues(RM_AUDIT_PATH_ROOT, auditMap); + } + else + { + Set auditDetails = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS); + AlfrescoTransactionSupport.bindListener(txnListener); + + // RM-936: Eliminate multiple audit maps from being generated when events with the same name are required to be fired multiple times in the same transaction. + // Check if auditDetails already contains an auditedNode with the same combination of nodeRef and eventName. + boolean auditNodeAlreadyExists = false; + for (RMAuditNode existingRMAuditNode : auditDetails) + { + if (existingRMAuditNode.getNodeRef().equals(nodeRef) && existingRMAuditNode.getEventName().equals(eventName)) + { + // If there exists such an auditNode, update its 'after' properties with the latest set of properties and leave its 'before' properties unchanged so that it + // retains the original set of properties. The first 'before' and last 'after' will be diff'ed when comes to building the auditMap later when the transaction + // commits. + existingRMAuditNode.setNodePropertiesAfter(after); + auditNodeAlreadyExists = true; + break; + } + } + + if (!auditNodeAlreadyExists) + { + // Create a new auditNode if it doesn't already exist + RMAuditNode auditedNode = new RMAuditNode(); + auditedNode.setNodeRef(nodeRef); + auditedNode.setEventName(eventName); + auditedNode.setNodePropertiesBefore(before); + auditedNode.setNodePropertiesAfter(after); + auditedNode.setRemoveIfNoPropertyChanged(removeIfNoPropertyChanged); + + auditDetails.add(auditedNode); + } + } + } + + /** + * Helper method to build audit map + * + * @param nodeRef + * @param eventName + * @return + * @since 2.0.3 + */ + private Map buildAuditMap(NodeRef nodeRef, String eventName, Map propertiesBefore, Map propertiesAfter, boolean removeOnNoPropertyChange) + { + Map auditMap = new HashMap(13); + auditMap.put( + AuditApplication.buildPath( + RM_AUDIT_SNIPPET_EVENT, + RM_AUDIT_SNIPPET_NAME), + eventName); + + if (nodeRef != null) + { + auditMap.put( + AuditApplication.buildPath( + RM_AUDIT_SNIPPET_EVENT, + RM_AUDIT_SNIPPET_NODE), + nodeRef); + } + + // Filter out any properties to be audited if specified in the Spring configuration. + if (!ignoredAuditProperties.isEmpty()) + { + removeAuditProperties(propertiesBefore, propertiesAfter); + } + + // Property changes + Pair, Map> deltaPair = PropertyMap.getBeforeAndAfterMapsForChanges(propertiesBefore, propertiesAfter); + + // If both the first and second Map in the deltaPair are empty and removeOnNoPropertyChange is true, the entire auditMap is discarded so it won't be audited. + if (deltaPair.getFirst().isEmpty() && deltaPair.getSecond().isEmpty() && removeOnNoPropertyChange) + { + auditMap.clear(); + } + else + { + auditMap.put( + AuditApplication.buildPath( + RM_AUDIT_SNIPPET_EVENT, + RM_AUDIT_SNIPPET_NODE, + RM_AUDIT_SNIPPET_CHANGES, + RM_AUDIT_SNIPPET_BEFORE), + (Serializable) deltaPair.getFirst()); + auditMap.put( + AuditApplication.buildPath( + RM_AUDIT_SNIPPET_EVENT, + RM_AUDIT_SNIPPET_NODE, + RM_AUDIT_SNIPPET_CHANGES, + RM_AUDIT_SNIPPET_AFTER), + (Serializable) deltaPair.getSecond()); + } + return auditMap; + } + + /** + * Helper method to remove system properties from maps + * + * @param properties + */ + private void removeAuditProperties(Map before, Map after) + { + if (before != null) + { + before.keySet().removeAll(this.propertiesToBeRemoved); + } + if (after != null) + { + after.keySet().removeAll(this.propertiesToBeRemoved); + } + } + + /** + * A stateless transaction listener for RM auditing. This component picks up the data of modified nodes and generates the audit information. + *

+ * This class is not static so that the instances will have access to the action's implementation. + * + * @author Derek Hulley + * @since 3.2 + */ + private class RMAuditTxnListener extends TransactionListenerAdapter + { + private final Log logger = LogFactory.getLog(RecordsManagementAuditServiceImpl.class); + + /* + * Equality and hashcode generation are left unimplemented; we expect to only have a single + * instance of this class per action. + */ + + /** + * Get the action parameters from the transaction and audit them. + */ + @Override + public void afterCommit() + { + final Set auditedNodes = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS); + + // Start a *new* read-write transaction to audit in + RetryingTransactionCallback auditCallback = new RetryingTransactionCallback() + { + @Override + public Void execute() throws Throwable + { + auditInTxn(auditedNodes); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback, false, true); + } + + /** + * Do the actual auditing, assuming the presence of a viable transaction + * + * @param auditedNodes details of the nodes that were modified + */ + private void auditInTxn(Set auditedNodes) throws Throwable + { + // Go through all the audit information and audit it + boolean auditedSomething = false; + for (RMAuditNode auditedNode : auditedNodes) + { + NodeRef nodeRef = auditedNode.getNodeRef(); + + // If the node is gone, then do nothing + if (nodeRef != null && !nodeService.exists(nodeRef)) + { + continue; + } + + // build the audit map + Map auditMap = buildAuditMap(nodeRef, + auditedNode.getEventName(), + auditedNode.getNodePropertiesBefore(), + auditedNode.getNodePropertiesAfter(), + auditedNode.getRemoveIfNoPropertyChanged()); + // Audit it + if (logger.isDebugEnabled()) + { + logger.debug("RM Audit: Auditing values: \n" + auditMap); + } + auditMap = auditComponent.recordAuditValues(RM_AUDIT_PATH_ROOT, auditMap); + if (auditMap.isEmpty()) + { + if (logger.isDebugEnabled()) + { + logger.debug("RM Audit: Nothing was audited."); + } + } + else + { + if (logger.isDebugEnabled()) + { + logger.debug("RM Audit: Audited values: \n" + auditMap); + } + // We must commit the transaction to get the values in + auditedSomething = true; + } + } + // Check if anything was audited + if (!auditedSomething) + { + // Nothing was audited, so do nothing + RetryingTransactionHelper.getActiveUserTransaction().setRollbackOnly(); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public File getAuditTrailFile(RecordsManagementAuditQueryParameters params, ReportFormat format) + { + ParameterCheck.mandatory("params", params); + + Writer fileWriter = null; + try + { + File auditTrailFile = TempFileProvider.createTempFile(AUDIT_TRAIL_FILE_PREFIX, + format == ReportFormat.HTML ? AUDIT_TRAIL_HTML_FILE_SUFFIX : AUDIT_TRAIL_JSON_FILE_SUFFIX); + fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(auditTrailFile),"UTF8")); + // Get the results, dumping to file + getAuditTrailImpl(params, null, fileWriter, format); + // Done + return auditTrailFile; + } + catch (IOException e) + { + throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e); + } + finally + { + // close the writer + if (fileWriter != null) + { + try { fileWriter.close(); } catch (IOException closeEx) {} + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public List getAuditTrail(RecordsManagementAuditQueryParameters params) + { + ParameterCheck.mandatory("params", params); + + List entries = new ArrayList(50); + try + { + getAuditTrailImpl(params, entries, null, null); + // Done + return entries; + } + catch (IOException e) + { + // Should be + throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e); + } + } + + /** + * Get the audit trail, optionally dumping the results the the given writer dumping to a list. + * + * @param params the search parameters + * @param results the list to which individual results will be dumped + * @param writer Writer to write the audit trail + * @param reportFormat Format to write the audit trail in, ignored if writer is null + */ + private void getAuditTrailImpl( + final RecordsManagementAuditQueryParameters params, + final List results, + final Writer writer, + final ReportFormat reportFormat) + throws IOException + { + if (logger.isDebugEnabled()) + { + logger.debug("Retrieving audit trail in '" + reportFormat + "' format using parameters: " + params); + } + + // define the callback + AuditQueryCallback callback = new AuditQueryCallback() + { + private boolean firstEntry = true; + + + @Override + public boolean valuesRequired() + { + return true; + } + + /** + * Just log the error, but continue + */ + @Override + public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error) + { + logger.warn(errorMsg, error); + return true; + } + + @Override + @SuppressWarnings("unchecked") + public boolean handleAuditEntry( + Long entryId, + String applicationName, + String user, + long time, + Map values) + { + // Check for context shutdown + if (shutdown) + { + return false; + } + + + Date timestamp = new Date(time); + String eventName = null; + String fullName = null; + String userRoles = null; + NodeRef nodeRef = null; + String nodeName = null; + String nodeType = null; + String nodeIdentifier = null; + String namePath = null; + Map beforeProperties = null; + Map afterProperties = null; + + if (values.containsKey(RM_AUDIT_DATA_EVENT_NAME)) + { + // This data is /RM/event/... + eventName = (String) values.get(RM_AUDIT_DATA_EVENT_NAME); + fullName = (String) values.get(RM_AUDIT_DATA_PERSON_FULLNAME); + userRoles = (String) values.get(RM_AUDIT_DATA_PERSON_ROLES); + nodeRef = (NodeRef) values.get(RM_AUDIT_DATA_NODE_NODEREF); + nodeName = (String) values.get(RM_AUDIT_DATA_NODE_NAME); + QName nodeTypeQname = (QName) values.get(RM_AUDIT_DATA_NODE_TYPE); + nodeIdentifier = (String) values.get(RM_AUDIT_DATA_NODE_IDENTIFIER); + namePath = (String) values.get(RM_AUDIT_DATA_NODE_NAMEPATH); + beforeProperties = (Map) values.get(RM_AUDIT_DATA_NODE_CHANGES_BEFORE); + afterProperties = (Map) values.get(RM_AUDIT_DATA_NODE_CHANGES_AFTER); + + // Convert some of the values to recognizable forms + nodeType = null; + if (nodeTypeQname != null) + { + TypeDefinition typeDef = dictionaryService.getType(nodeTypeQname); + nodeType = (typeDef != null) ? typeDef.getTitle(dictionaryService) : null; + } + } + else if (values.containsKey(DOD5015_AUDIT_DATA_EVENT_NAME)) + { + // This data is /RM/event/... + eventName = (String) values.get(DOD5015_AUDIT_DATA_EVENT_NAME); + fullName = (String) values.get(DOD5015_AUDIT_DATA_PERSON_FULLNAME); + userRoles = (String) values.get(DOD5015_AUDIT_DATA_PERSON_ROLES); + nodeRef = (NodeRef) values.get(DOD5015_AUDIT_DATA_NODE_NODEREF); + nodeName = (String) values.get(DOD5015_AUDIT_DATA_NODE_NAME); + QName nodeTypeQname = (QName) values.get(DOD5015_AUDIT_DATA_NODE_TYPE); + nodeIdentifier = (String) values.get(DOD5015_AUDIT_DATA_NODE_IDENTIFIER); + namePath = (String) values.get(DOD5015_AUDIT_DATA_NODE_NAMEPATH); + beforeProperties = (Map) values.get( DOD5015_AUDIT_DATA_NODE_CHANGES_BEFORE); + afterProperties = (Map) values.get(DOD5015_AUDIT_DATA_NODE_CHANGES_AFTER); + + // Convert some of the values to recognizable forms + nodeType = null; + if (nodeTypeQname != null) + { + TypeDefinition typeDef = dictionaryService.getType(nodeTypeQname); + nodeType = (typeDef != null) ? typeDef.getTitle(dictionaryService) : null; + } + } + else if (values.containsKey(RM_AUDIT_DATA_LOGIN_USERNAME)) + { + user = (String) values.get(RM_AUDIT_DATA_LOGIN_USERNAME); + if (values.containsKey(RM_AUDIT_DATA_LOGIN_ERROR)) + { + eventName = RM_AUDIT_EVENT_LOGIN_FAILURE; + // The user didn't log in + fullName = user; + } + else + { + eventName = RM_AUDIT_EVENT_LOGIN_SUCCESS; + fullName = (String) values.get(RM_AUDIT_DATA_LOGIN_FULLNAME); + } + } + else if (values.containsKey(DOD5015_AUDIT_DATA_LOGIN_USERNAME)) + { + user = (String) values.get(DOD5015_AUDIT_DATA_LOGIN_USERNAME); + if (values.containsKey(DOD5015_AUDIT_DATA_LOGIN_ERROR)) + { + eventName = RM_AUDIT_EVENT_LOGIN_FAILURE; + // The user didn't log in + fullName = user; + } + else + { + eventName = RM_AUDIT_EVENT_LOGIN_SUCCESS; + fullName = (String) values.get(DOD5015_AUDIT_DATA_LOGIN_FULLNAME); + } + } + else + { + // This is not recognisable data + logger.warn( + "Unable to process audit entry for RM. Unexpected data: \n" + + " Entry: " + entryId + "\n" + + " Data: " + values); + // Skip it + return true; + } + + if(nodeRef != null && nodeService.exists(nodeRef) && + !AccessStatus.ALLOWED.equals( + capabilityService.getCapabilityAccessState(nodeRef, ACCESS_AUDIT_CAPABILITY))) + { + return true; + } + + // TODO: Refactor this to use the builder pattern + RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry( + timestamp, + user, + fullName, + // A concatenated string of roles + userRoles, + nodeRef, + nodeName, + nodeType, + eventName, + nodeIdentifier, + namePath, + beforeProperties, + afterProperties); + + // write out the entry to the file in requested format + writeEntryToFile(entry); + + if (results != null) + { + results.add(entry); + } + + if (logger.isDebugEnabled()) + { + logger.debug(" " + entry); + } + + // Keep going + return true; + } + + private void writeEntryToFile(RecordsManagementAuditEntry entry) + { + if (writer == null) + { + return; + } + try + { + if (!firstEntry) + { + if (reportFormat == ReportFormat.HTML) + { + writer.write("\n"); + } + else + { + writer.write(","); + } + } + else + { + firstEntry = false; + } + + // write the entry to the file + if (reportFormat == ReportFormat.JSON) + { + writer.write("\n\t\t"); + } + + writeAuditTrailEntry(writer, entry, reportFormat); + } + catch (IOException ioe) + { + throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, ioe); + } + } + }; + + String user = params.getUser(); + Long fromTime = getFromDateTime(params.getDateFrom()); + Long toTime = getToDateTime(params.getDateTo()); + NodeRef nodeRef = params.getNodeRef(); + int maxEntries = params.getMaxEntries(); + // Reverse order if the results are limited + boolean forward = maxEntries > 0 ? false : true; + + // start the audit trail report + writeAuditTrailHeader(writer, params, reportFormat); + + if (logger.isDebugEnabled()) + { + logger.debug("RM Audit: Issuing query: " + params); + } + + // Build audit query parameters + AuditQueryParameters dod5015AuditQueryParams = new AuditQueryParameters(); + dod5015AuditQueryParams.setForward(forward); + dod5015AuditQueryParams.setApplicationName(DOD5015_AUDIT_APPLICATION_NAME); + dod5015AuditQueryParams.setUser(user); + dod5015AuditQueryParams.setFromTime(fromTime); + dod5015AuditQueryParams.setToTime(toTime); + if (nodeRef != null) + { + dod5015AuditQueryParams.addSearchKey(DOD5015_AUDIT_DATA_NODE_NODEREF, nodeRef); + } + + // + AuditQueryParameters auditQueryParams = new AuditQueryParameters(); + auditQueryParams.setForward(forward); + auditQueryParams.setApplicationName(RM_AUDIT_APPLICATION_NAME); + auditQueryParams.setUser(user); + auditQueryParams.setFromTime(fromTime); + auditQueryParams.setToTime(toTime); + if (nodeRef != null) + { + auditQueryParams.addSearchKey(RM_AUDIT_DATA_NODE_NODEREF, nodeRef); + } + else if (params.getEvent() != null) + { + auditQueryParams.addSearchKey(RM_AUDIT_DATA_EVENT_NAME, params.getEvent()); + } + + // Get audit entries + auditService.auditQuery(callback, dod5015AuditQueryParams, maxEntries); + auditService.auditQuery(callback, auditQueryParams, maxEntries); + + // finish off the audit trail report + writeAuditTrailFooter(writer, reportFormat); + + // audit that the audit has been view'ed + if (nodeRef == null) + { + // grab the default file plan, but don't fail if it can't be found! + nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + auditEvent(nodeRef, AUDIT_EVENT_VIEW, null, null, true); + } + + /** + * Calculates the start of the given date. + * For example, if you had the date time of 12 Aug 2013 12:10:15.158 + * the result would be 12 Aug 2013 00:00:00.000. + * + * @param date The date for which the start should be calculated. + * @return Returns the start of the given date. + */ + private Date getStartOfDay(Date date) + { + return DateUtils.truncate(date == null ? new Date() : date, Calendar.DATE); + } + + /** + * Gets the start of the from date + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditServiceImpl.getStartOfDay() + * + * @param date The date for which the start should be retrieved. + * @return Returns null if the given date is null, otherwise the start of the given day. + */ + private Date getFromDate(Date date) + { + return date == null ? null : getStartOfDay(date); + } + + /** + * Returns the number of milliseconds for the "from date". + * + * @param date The date for which the number of milliseconds should retrieved. + * @return Returns null if the given date is null, otherwise the number of milliseconds for the given date. + */ + private Long getFromDateTime(Date date) + { + Long fromDateTime = null; + Date fromDate = getFromDate(date); + if (fromDate != null) + { + fromDateTime = Long.valueOf(fromDate.getTime()); + } + return fromDateTime; + } + + /** + * Calculates the end of the given date. + * For example, if you had the date time of 12 Aug 2013 12:10:15.158 + * the result would be 12 Aug 2013 23:59:59.999. + * + * @param date The date for which the end should be calculated. + * @return Returns the end of the given date. + */ + private Date getEndOfDay(Date date) + { + return DateUtils.addMilliseconds(DateUtils.ceiling(date == null ? new Date() : date, Calendar.DATE), -1); + } + + /** + * Gets the end of the from date + * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditServiceImpl.getEndOfDay() + * + * @param date The date for which the end should be retrieved. + * @return Returns null if the given date is null, otherwise the end of the given day. + */ + private Date getToDate(Date date) + { + return date == null ? null : getEndOfDay(date); + } + + /** + * Returns the number of milliseconds for the "to date". + * + * @param date The date for which the number of milliseconds should retrieved. + * @return Returns null if the given date is null, otherwise the number of milliseconds for the given date. + */ + private Long getToDateTime(Date date) + { + Long toDateTime = null; + Date toDate = getToDate(date); + if (toDate != null) + { + toDateTime = Long.valueOf(toDate.getTime()); + } + return toDateTime; + } + + /** + * {@inheritDoc} + */ + @Override + public NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, + NodeRef destination, ReportFormat format) + { + ParameterCheck.mandatory("params", params); + ParameterCheck.mandatory("destination", destination); + + // NOTE: the underlying RM services will check all the remaining pre-conditions + + NodeRef record = null; + + // get the audit trail for the provided parameters + File auditTrail = this.getAuditTrailFile(params, format); + + if (logger.isDebugEnabled()) + { + logger.debug("Filing audit trail in file " + auditTrail.getAbsolutePath() + + " as a record in record folder: " + destination); + } + + try + { + Map properties = new HashMap(1); + properties.put(ContentModel.PROP_NAME, auditTrail.getName()); + + // file the audit log as an undeclared record + record = this.nodeService.createNode(destination, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, + QName.createValidLocalName(auditTrail.getName())), + ContentModel.TYPE_CONTENT, properties).getChildRef(); + + // Set the content + ContentWriter writer = this.contentService.getWriter(record, ContentModel.PROP_CONTENT, true); + writer.setMimetype(format == ReportFormat.HTML ? MimetypeMap.MIMETYPE_HTML : MimetypeMap.MIMETYPE_JSON); + writer.setEncoding("UTF-8"); + writer.putContent(auditTrail); + } + finally + { + if (logger.isDebugEnabled()) + { + logger.debug("Audit trail report saved to temporary file: " + auditTrail.getAbsolutePath()); + } + else + { + auditTrail.delete(); + } + } + + return record; + } + + /** + * {@inheritDoc} + */ + @Override + public List getAuditEvents() + { + List listAuditEvents = new ArrayList(this.auditEvents.size()); + listAuditEvents.addAll(this.auditEvents.values()); + Collections.sort(listAuditEvents); + return listAuditEvents; + } + + /** + * Writes the start of the audit trail stream to the given writer + * + * @param writer The writer to write to + * @params params The parameters being used + * @param reportFormat The format to write the header in + * @throws IOException + */ + private void writeAuditTrailHeader(Writer writer, + RecordsManagementAuditQueryParameters params, + ReportFormat reportFormat) throws IOException + { + if (writer == null) + { + return; + } + + if (reportFormat == ReportFormat.HTML) + { + // write header as HTML + writer.write("\n"); + writer.write("\n\n"); + writer.write(""); + writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT)); + writer.write("\n"); + writer.write("\n"); + writer.write("\n

"); + writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT)); + writer.write("

\n"); + writer.write("
\n"); + + writer.write("From:"); + writer.write(""); + Date from = params.getDateFrom(); + writer.write(from == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(from.toString())); + writer.write(""); + + writer.write("To:"); + writer.write(""); + Date to = params.getDateTo(); + writer.write(to == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(to.toString())); + writer.write(""); + + writer.write("Property:"); + writer.write(""); + QName prop = params.getProperty(); + writer.write(prop == null ? "All" : StringEscapeUtils.escapeHtml(getPropertyLabel(prop))); + writer.write(""); + + writer.write("User:"); + writer.write(""); + writer.write(params.getUser() == null ? "All" : StringEscapeUtils.escapeHtml(params.getUser())); + writer.write(""); + + writer.write("Event:"); + writer.write(""); + writer.write(params.getEvent() == null ? "All" : StringEscapeUtils.escapeHtml(getAuditEventLabel(params.getEvent()))); + writer.write("\n"); + + writer.write("
\n"); + } + else + { + // write header as JSON + writer.write("{\n\t\"data\":\n\t{"); + writer.write("\n\t\t\"started\": \""); + writer.write(ISO8601DateFormat.format(getStartOfDay(params.getDateFrom()))); + writer.write("\",\n\t\t\"stopped\": \""); + writer.write(ISO8601DateFormat.format(getEndOfDay(params.getDateTo()))); + writer.write("\",\n\t\t\"enabled\": "); + writer.write(Boolean.toString(isEnabled())); + writer.write(",\n\t\t\"entries\":["); + } + } + + /** + * Writes an audit trail entry to the given writer + * + * @param writer The writer to write to + * @param entry The entry to write + * @param reportFormat The format to write the header in + * @throws IOException + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void writeAuditTrailEntry(Writer writer, RecordsManagementAuditEntry entry, + ReportFormat reportFormat) throws IOException + { + if (writer == null) + { + return; + } + + if (reportFormat == ReportFormat.HTML) + { + writer.write("
\n"); + writer.write("
"); + writer.write("Timestamp:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(entry.getTimestamp().toString())); + writer.write(""); + writer.write("User:"); + writer.write(""); + writer.write(entry.getFullName() != null ? + StringEscapeUtils.escapeHtml(entry.getFullName()) : + StringEscapeUtils.escapeHtml(entry.getUserName())); + writer.write(""); + if (entry.getUserRole() != null && entry.getUserRole().length() > 0) + { + writer.write("Role:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(entry.getUserRole())); + writer.write(""); + } + if (entry.getEvent() != null && entry.getEvent().length() > 0) + { + writer.write("Event:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(getAuditEventLabel(entry.getEvent()))); + writer.write("\n"); + } + writer.write("
\n"); + writer.write("
"); + if (entry.getIdentifier() != null && entry.getIdentifier().length() > 0) + { + writer.write("Identifier:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(entry.getIdentifier())); + writer.write(""); + } + if (entry.getNodeType() != null && entry.getNodeType().length() > 0) + { + writer.write("Type:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(entry.getNodeType())); + writer.write(""); + } + if (entry.getPath() != null && entry.getPath().length() > 0) + { + // we need to strip off the first part of the path + String path = entry.getPath(); + String displayPath = path; + int idx = path.indexOf('/', 1); + if (idx != -1) + { + displayPath = "/File Plan" + path.substring(idx); + } + + writer.write("Location:"); + writer.write(""); + writer.write(StringEscapeUtils.escapeHtml(displayPath)); + writer.write(""); + } + writer.write("
\n"); + + if (entry.getChangedProperties() != null) + { + writer.write(""); + writer.write(""); + + // create an entry for each property that changed + for (QName valueName : entry.getChangedProperties().keySet()) + { + Pair values = entry.getChangedProperties().get(valueName); + writer.write(""); + } + + writer.write("
PropertyPrevious ValueNew Value
"); + writer.write(getPropertyLabel(valueName)); + writer.write(""); + + // inspect the property to determine it's data type + QName propDataType = DataTypeDefinition.TEXT; + PropertyDefinition propDef = dictionaryService.getProperty(valueName); + if (propDef != null) + { + propDataType = propDef.getDataType().getName(); + } + + if(DataTypeDefinition.MLTEXT.equals(propDataType)) + { + writer.write(values.getFirst() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getFirst()).getDefaultValue())); + writer.write(""); + writer.write(values.getSecond() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getSecond()).getDefaultValue())); + } + else + { + Serializable oldValue = values.getFirst(); + writer.write(oldValue == null ? "<none>" : StringEscapeUtils.escapeHtml(oldValue.toString())); + writer.write(""); + Serializable newValue = values.getSecond(); + writer.write(newValue == null ? "<none>" : StringEscapeUtils.escapeHtml(newValue.toString())); + } + + writer.write("
\n"); + } + + writer.write("
"); + } + else + { + try + { + JSONObject json = new JSONObject(); + + json.put("timestamp", entry.getTimestampString()); + json.put("userName", entry.getUserName()); + json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole()); + json.put("fullName", entry.getFullName() == null ? "": entry.getFullName()); + json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef()); + + // TODO: Find another way for checking the event + if (entry.getEvent().equals("Create Person") && entry.getNodeRef() != null) + { + NodeRef nodeRef = entry.getNodeRef(); + String userName = ""; + if (nodeService.exists(nodeRef)) + { + userName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); + } + json.put("nodeName", userName == null ? "" : userName); + json.put("createPerson", true); + } + else + { + json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); + } + + // TODO: Find another way for checking the event + if (entry.getEvent().equals("Delete RM Object")) + { + json.put("deleteObject", true); + } + + 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()); + json.put("path", entry.getPath() == null ? "": entry.getPath()); + + JSONArray changedValues = new JSONArray(); + + if (entry.getChangedProperties() != null) + { + // create an entry for each property that changed + for (QName valueName : entry.getChangedProperties().keySet()) + { + Pair values = entry.getChangedProperties().get(valueName); + + JSONObject changedValue = new JSONObject(); + changedValue.put("name", getPropertyLabel(valueName)); + + // inspect the property to determine it's data type + QName propDataType = DataTypeDefinition.TEXT; + PropertyDefinition propDef = dictionaryService.getProperty(valueName); + if (propDef != null) + { + propDataType = propDef.getDataType().getName(); + } + + // handle output of mltext properties + if(DataTypeDefinition.MLTEXT.equals(propDataType)) + { + changedValue.put("previous", values.getFirst() == null ? "" : convertToMlText((Map)values.getFirst()).getDefaultValue()); + changedValue.put("new", values.getSecond() == null ? "" : convertToMlText((Map)values.getSecond()).getDefaultValue()); + } + else + { + changedValue.put("previous", values.getFirst() == null ? "" : values.getFirst().toString()); + changedValue.put("new", values.getSecond() == null ? "" : values.getSecond().toString()); + } + + changedValues.put(changedValue); + } + } + + json.put("changedValues", changedValues); + + writer.write(json.toString()); + } + catch (JSONException je) + { + writer.write("{}"); + } + } + } + + /** + * Helper method to convert value to MLText + * + * @param map map of locale's and values + * @return {@link MLText} multilingual text value + */ + private MLText convertToMlText(Map map) + { + MLText mlText = new MLText(); + mlText.putAll(map); + return mlText; + } + + /** + * Writes the end of the audit trail stream to the given writer + * + * @param writer The writer to write to + * @param reportFormat The format to write the footer in + * @throws IOException + */ + private void writeAuditTrailFooter(Writer writer, ReportFormat reportFormat) throws IOException + { + if (writer == null) + { + return; + } + + if (reportFormat == ReportFormat.HTML) + { + // write footer as HTML + writer.write("\n"); + } + else + { + // write footer as JSON + writer.write("\n\t\t]\n\t}\n}"); + } + } + + /** + * Returns the display label for a property QName + * + * @param property The property to get label for + * @param ddService DictionaryService instance + * @param namespaceService NamespaceService instance + * @return The label + */ + private String getPropertyLabel(QName property) + { + String label = null; + + PropertyDefinition propDef = this.dictionaryService.getProperty(property); + if (propDef != null) + { + label = propDef.getTitle(dictionaryService); + } + + if (label == null) + { + label = property.getLocalName(); + } + + return label; + } + + /** + * Returns the display label for the given audit event key + * + * @param eventKey The audit event key + * @return The display label or null if the key does not exist + */ + private String getAuditEventLabel(String eventKey) + { + String label = eventKey; + + AuditEvent event = this.auditEvents.get(eventKey); + if (event != null) + { + label = event.getLabel(); + } + + return label; + } + + /** + * A class to carry audit information through the transaction. + * + * @author Derek Hulley + * @since 3.2 + */ + private static class RMAuditNode + { + private NodeRef nodeRef; + private String eventName; + private Map nodePropertiesBefore; + private Map nodePropertiesAfter; + private boolean removeIfNoPropertyChanged = false; + + public NodeRef getNodeRef() + { + return nodeRef; + } + + public void setNodeRef(NodeRef nodeRef) + { + this.nodeRef = nodeRef; + } + + public String getEventName() + { + return eventName; + } + + public void setEventName(String eventName) + { + this.eventName = eventName; + } + + public Map getNodePropertiesBefore() + { + return nodePropertiesBefore; + } + + public void setNodePropertiesBefore(Map nodePropertiesBefore) + { + this.nodePropertiesBefore = nodePropertiesBefore; + } + + public Map getNodePropertiesAfter() + { + return nodePropertiesAfter; + } + + public void setNodePropertiesAfter(Map nodePropertiesAfter) + { + this.nodePropertiesAfter = nodePropertiesAfter; + } + + public boolean getRemoveIfNoPropertyChanged() + { + return removeIfNoPropertyChanged; + } + + public void setRemoveIfNoPropertyChanged(boolean removeIfNoPropertyChanged) + { + this.removeIfNoPropertyChanged = removeIfNoPropertyChanged; + } + } + + /** Deprecated Method Implementations **/ + + /** + * Helper method to get the default file plan + * + * @return NodRef default file plan + */ + private NodeRef getDefaultFilePlan() + { + NodeRef defaultFilePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (defaultFilePlan == null) + { + throw new AlfrescoRuntimeException("Default file plan could not be found."); + } + return defaultFilePlan; + } + + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public boolean isEnabled() + { + return isAuditLogEnabled(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + */ + @Deprecated + public void start() + { + startAuditLog(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public void stop() + { + stopAuditLog(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public Date getDateLastStarted() + { + return getDateAuditLogLastStarted(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public Date getDateLastStopped() + { + return getDateAuditLogLastStopped(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public void clear() + { + clearAuditLog(getDefaultFilePlan()); + } + + /** + * {@inheritDoc} + * @since 3.2 + * @deprecated since 2.1 + */ + @Override + @Deprecated + public void auditRMAction( + RecordsManagementAction action, + NodeRef nodeRef, + Map parameters) + { + auditEvent(nodeRef, action.getName()); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java index 3d45466ba3..054e372435 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java @@ -1,135 +1,135 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Class to represent an audit event - * - * @author Gavin Cornwell - * @author Roy Wetherall - * @since 1.0 - */ -public class AuditEvent implements RecordsManagementModel, Comparable -{ - /** Name */ - private String name; - - /** Label */ - private String label; - - /** Records management audit service */ - protected RecordsManagementAuditService recordsManagementAuditService; - - /** - * @param recordsManagementAuditService records management audit service - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) - { - this.recordsManagementAuditService = recordsManagementAuditService; - } - - /** - * Init method - */ - public void init() - { - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("label", label); - - recordsManagementAuditService.registerAuditEvent(this); - } - - /** - * Default constructor. - */ - public AuditEvent() - { - // do nothing - } - - /** - * Default constructor. - * - * @param name audit event name - * @param label audit event label (can be actual label or I18N lookup key) - */ - public AuditEvent(String name, String label) - { - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("label", label); - - setName(name); - setLabel(label); - } - - /** - * @return audit event name - */ - public String getName() - { - return this.name; - } - - /** - * @param name audit event name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @return audit event label - */ - public String getLabel() - { - String lookup = I18NUtil.getMessage(label); - if (StringUtils.isBlank(lookup)) - { - lookup = label; - } - return lookup; - } - - /** - * @param label audit event label - */ - public void setLabel(String label) - { - this.label = label; - } - - /** - * Compare by label. - * - * @param compare compare to audit event - * @return int - */ - @Override - public int compareTo(AuditEvent compare) - { - return getLabel().compareTo(compare.getLabel()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Class to represent an audit event + * + * @author Gavin Cornwell + * @author Roy Wetherall + * @since 1.0 + */ +public class AuditEvent implements RecordsManagementModel, Comparable +{ + /** Name */ + private String name; + + /** Label */ + private String label; + + /** Records management audit service */ + protected RecordsManagementAuditService recordsManagementAuditService; + + /** + * @param recordsManagementAuditService records management audit service + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) + { + this.recordsManagementAuditService = recordsManagementAuditService; + } + + /** + * Init method + */ + public void init() + { + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("label", label); + + recordsManagementAuditService.registerAuditEvent(this); + } + + /** + * Default constructor. + */ + public AuditEvent() + { + // do nothing + } + + /** + * Default constructor. + * + * @param name audit event name + * @param label audit event label (can be actual label or I18N lookup key) + */ + public AuditEvent(String name, String label) + { + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("label", label); + + setName(name); + setLabel(label); + } + + /** + * @return audit event name + */ + public String getName() + { + return this.name; + } + + /** + * @param name audit event name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @return audit event label + */ + public String getLabel() + { + String lookup = I18NUtil.getMessage(label); + if (StringUtils.isBlank(lookup)) + { + lookup = label; + } + return lookup; + } + + /** + * @param label audit event label + */ + public void setLabel(String label) + { + this.label = label; + } + + /** + * Compare by label. + * + * @param compare compare to audit event + * @return int + */ + @Override + public int compareTo(AuditEvent compare) + { + return getLabel().compareTo(compare.getLabel()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyToAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyToAuditEvent.java index ebe307aeea..1abd1eb3fe 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyToAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyToAuditEvent.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import java.util.Map; - -import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Copy audit event. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class CopyToAuditEvent extends AuditEvent implements OnCopyCompletePolicy -{ - /** - * Audit copy of file plan components - * - * @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy#onCopyComplete(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent" - ) - public void onCopyComplete(QName classRef, - NodeRef sourceNodeRef, - NodeRef targetNodeRef, - boolean copyToNewNode, - Map copyMap) - { - if (copyToNewNode) - { - recordsManagementAuditService.auditEvent(targetNodeRef, getName()); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import java.util.Map; + +import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Copy audit event. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class CopyToAuditEvent extends AuditEvent implements OnCopyCompletePolicy +{ + /** + * Audit copy of file plan components + * + * @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy#onCopyComplete(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void onCopyComplete(QName classRef, + NodeRef sourceNodeRef, + NodeRef targetNodeRef, + boolean copyToNewNode, + Map copyMap) + { + if (copyToNewNode) + { + recordsManagementAuditService.auditEvent(targetNodeRef, getName()); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java index 4c56114b02..d333a6ee7c 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.ChildAssociationRef; - -/** - * Audits the creation of file plan component objects - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class CreateObjectAuditEvent extends AuditEvent implements OnCreateNodePolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent" - ) - public void onCreateNode(ChildAssociationRef childAssocRef) - { - recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.ChildAssociationRef; + +/** + * Audits the creation of file plan component objects + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class CreateObjectAuditEvent extends AuditEvent implements OnCreateNodePolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void onCreateNode(ChildAssociationRef childAssocRef) + { + recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java index 0a80003eeb..21e095b5a5 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.ChildAssociationRef; - -/** - * Audits person creation. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class CreatePersonAuditEvent extends AuditEvent implements OnCreateNodePolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "cm:person" - ) - public void onCreateNode(ChildAssociationRef childAssocRef) - { - recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.ChildAssociationRef; + +/** + * Audits person creation. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class CreatePersonAuditEvent extends AuditEvent implements OnCreateNodePolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "cm:person" + ) + public void onCreateNode(ChildAssociationRef childAssocRef) + { + recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java index 225fbada7c..ca82744427 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Audits file plan component delete - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class DeleteObjectAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent" - ) - public void beforeDeleteNode(NodeRef nodeRef) - { - recordsManagementAuditService.auditEvent(nodeRef, getName(), null, null, true, false); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Audits file plan component delete + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class DeleteObjectAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void beforeDeleteNode(NodeRef nodeRef) + { + recordsManagementAuditService.auditEvent(nodeRef, getName(), null, null, true, false); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileToAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileToAuditEvent.java index 265d3e3320..164ab232b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileToAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileToAuditEvent.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * File audit event. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class FileToAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:record" - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - if (before.get(PROP_DATE_FILED) == null && after.get(PROP_DATE_FILED) != null) - { - // then we can assume that the record has just been filed - recordsManagementAuditService.auditEvent(nodeRef, getName()); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * File audit event. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class FileToAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:record" + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if (before.get(PROP_DATE_FILED) == null && after.get(PROP_DATE_FILED) != null) + { + // then we can assume that the record has just been filed + recordsManagementAuditService.auditEvent(nodeRef, getName()); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkToAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkToAuditEvent.java index 41a1adb7eb..7fe5547703 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkToAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkToAuditEvent.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.ChildAssociationRef; - -/** - * Link to audit event. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class LinkToAuditEvent extends AuditEvent implements OnCreateChildAssociationPolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - type = "rma:filePlanComponent" - ) - public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) - { - // only care about linking child associations - if (!childAssocRef.isPrimary()) - { - // TODO - // add some dummy properties to indicate the details of the link? - recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); - } - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.ChildAssociationRef; + +/** + * Link to audit event. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class LinkToAuditEvent extends AuditEvent implements OnCreateChildAssociationPolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + type = "rma:filePlanComponent" + ) + public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) + { + // only care about linking child associations + if (!childAssocRef.isPrimary()) + { + // TODO + // add some dummy properties to indicate the details of the link? + recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName()); + } + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveToAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveToAuditEvent.java index eef2fa7d55..7bfbcac2e6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveToAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveToAuditEvent.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.ChildAssociationRef; - -/** - * Move to audit event. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class MoveToAuditEvent extends AuditEvent implements OnMoveNodePolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent" - ) - public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - recordsManagementAuditService.auditEvent(newChildAssocRef.getChildRef(), getName()); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.ChildAssociationRef; + +/** + * Move to audit event. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class MoveToAuditEvent extends AuditEvent implements OnMoveNodePolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + recordsManagementAuditService.auditEvent(newChildAssocRef.getChildRef(), getName()); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/RecordableVersionPolicyAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/RecordableVersionPolicyAuditEvent.java index bcad9a0997..bd2b509252 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/RecordableVersionPolicyAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/RecordableVersionPolicyAuditEvent.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Audits recordable version policy property updates - * - * @author Tuna Aksoy - * @since 2.3 - */ -@BehaviourBean -public class RecordableVersionPolicyAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "cm:cmobject" - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - if (before.get(PROP_RECORDABLE_VERSION_POLICY) != after.get(PROP_RECORDABLE_VERSION_POLICY)) - { - recordsManagementAuditService.auditEvent(nodeRef, getName(), before, after, true, true); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Audits recordable version policy property updates + * + * @author Tuna Aksoy + * @since 2.3 + */ +@BehaviourBean +public class RecordableVersionPolicyAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "cm:cmobject" + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if (before.get(PROP_RECORDABLE_VERSION_POLICY) != after.get(PROP_RECORDABLE_VERSION_POLICY)) + { + recordsManagementAuditService.auditEvent(nodeRef, getName(), before, after, true, true); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java index cd5c3fea01..4508916aa4 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.event; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Audits file plan component property updates - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class UpdateObjectAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy -{ - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent" - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - recordsManagementAuditService.auditEvent(nodeRef, getName(), before, after, false, true); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Audits file plan component property updates + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class UpdateObjectAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy +{ + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + recordsManagementAuditService.auditEvent(nodeRef, getName(), before, after, false, true); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java index c01411aa73..6ff64a3a3d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java @@ -1,118 +1,118 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.extractor; - -import java.io.Serializable; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.audit.extractor.AbstractDataExtractor; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; - -/** - * An extractor that uses a node context to determine the currently-authenticated - * user's RM roles. This is not a data generator because it can only function in - * the context of a give node. - * - * @author Derek Hulley - * @since 3.2 - */ -public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtractor -{ - private NodeService nodeService; - private FilePlanService filePlanService; - private FilePlanRoleService filePlanRoleService; - - /** - * Used to check that the node in the context is a fileplan component - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @return Returns true if the data is a NodeRef and it represents - * a fileplan component - */ - public boolean isSupported(Serializable data) - { - if (!(data instanceof NodeRef)) - { - return false; - } - return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); - } - - /** - * @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable) - */ - public Serializable extractData(Serializable value) - { - NodeRef nodeRef = (NodeRef) value; - String user = AuthenticationUtil.getFullyAuthenticatedUser(); - if (user == null) - { - // No-one is authenticated - return null; - } - - StringBuilder sb = new StringBuilder(100); - - // Get the rm root - NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef); - - if (rmRootNodeRef != null) - { - Set roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user); - for (Role role : roles) - { - if (sb.length() > 0) - { - sb.append(", "); - } - sb.append(role.getDisplayLabel()); - } - } - - // Done - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.extractor; + +import java.io.Serializable; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.audit.extractor.AbstractDataExtractor; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; + +/** + * An extractor that uses a node context to determine the currently-authenticated + * user's RM roles. This is not a data generator because it can only function in + * the context of a give node. + * + * @author Derek Hulley + * @since 3.2 + */ +public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtractor +{ + private NodeService nodeService; + private FilePlanService filePlanService; + private FilePlanRoleService filePlanRoleService; + + /** + * Used to check that the node in the context is a fileplan component + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @return Returns true if the data is a NodeRef and it represents + * a fileplan component + */ + public boolean isSupported(Serializable data) + { + if (!(data instanceof NodeRef)) + { + return false; + } + return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + } + + /** + * @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable) + */ + public Serializable extractData(Serializable value) + { + NodeRef nodeRef = (NodeRef) value; + String user = AuthenticationUtil.getFullyAuthenticatedUser(); + if (user == null) + { + // No-one is authenticated + return null; + } + + StringBuilder sb = new StringBuilder(100); + + // Get the rm root + NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef); + + if (rmRootNodeRef != null) + { + Set roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user); + for (Role role : roles) + { + if (sb.length() > 0) + { + sb.append(", "); + } + sb.append(role.getDisplayLabel()); + } + } + + // Done + return sb.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanIdentifierDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanIdentifierDataExtractor.java index e8aebf0d9d..4ea70e9966 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanIdentifierDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanIdentifierDataExtractor.java @@ -1,70 +1,70 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.extractor; - -import java.io.Serializable; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.audit.extractor.AbstractDataExtractor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; - -/** - * An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property. - * This will only extract data if the node is a - * {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}. - * - * @author Derek Hulley - * @since 3.2 - */ -public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor -{ - private NodeService nodeService; - - /** - * Used to check that the node in the context is a fileplan component - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @return Returns true if the data is a NodeRef and it represents - * a fileplan component - */ - public boolean isSupported(Serializable data) - { - if (!(data instanceof NodeRef)) - { - return false; - } - return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID); - } - - public Serializable extractData(Serializable value) - { - NodeRef nodeRef = (NodeRef) value; - - String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER); - - // Done - return identifier; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.extractor; + +import java.io.Serializable; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.audit.extractor.AbstractDataExtractor; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; + +/** + * An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property. + * This will only extract data if the node is a + * {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}. + * + * @author Derek Hulley + * @since 3.2 + */ +public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor +{ + private NodeService nodeService; + + /** + * Used to check that the node in the context is a fileplan component + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @return Returns true if the data is a NodeRef and it represents + * a fileplan component + */ + public boolean isSupported(Serializable data) + { + if (!(data instanceof NodeRef)) + { + return false; + } + return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID); + } + + public Serializable extractData(Serializable value) + { + NodeRef nodeRef = (NodeRef) value; + + String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER); + + // Done + return identifier; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java index 4e267aa55a..964374fbcc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java @@ -1,120 +1,120 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.extractor; - -import java.io.Serializable; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.audit.extractor.AbstractDataExtractor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.rule.RuleService; - -/** - * An extractor that extracts the cm:name path from the RM root down to - * - and including - the node's own name. This will only extract data if the - * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. - * - * @see FilePlanService#getNodeRefPath(NodeRef) - * - * @author Derek Hulley - * @since 3.2 - */ -public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor -{ - private NodeService nodeService; - private FilePlanService filePlanService; - private RuleService ruleService; - - /** - * Used to check that the node in the context is a fileplan component - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param ruleService the ruleService to set - */ - public void setRuleService(RuleService ruleService) - { - this.ruleService = ruleService; - } - - /** - * @return Returns true if the data is a NodeRef and it represents - * a fileplan component - */ - public boolean isSupported(Serializable data) - { - if (!(data instanceof NodeRef)) - { - return false; - } - return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); - } - - /** - * @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable) - */ - public Serializable extractData(Serializable value) - { - String extractedData = null; - - ruleService.disableRules(); - try - { - NodeRef nodeRef = (NodeRef) value; - StringBuilder sb = new StringBuilder(128); - - if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - // Get path from the RM root - List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - - for (NodeRef pathNodeRef : nodeRefPath) - { - String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); - sb.append("/").append(name); - } - } - - // Done - extractedData = sb.toString(); - } - finally - { - ruleService.enableRules(); - } - - return extractedData; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.extractor; + +import java.io.Serializable; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.audit.extractor.AbstractDataExtractor; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.rule.RuleService; + +/** + * An extractor that extracts the cm:name path from the RM root down to + * - and including - the node's own name. This will only extract data if the + * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. + * + * @see FilePlanService#getNodeRefPath(NodeRef) + * + * @author Derek Hulley + * @since 3.2 + */ +public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor +{ + private NodeService nodeService; + private FilePlanService filePlanService; + private RuleService ruleService; + + /** + * Used to check that the node in the context is a fileplan component + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param ruleService the ruleService to set + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + + /** + * @return Returns true if the data is a NodeRef and it represents + * a fileplan component + */ + public boolean isSupported(Serializable data) + { + if (!(data instanceof NodeRef)) + { + return false; + } + return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + } + + /** + * @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable) + */ + public Serializable extractData(Serializable value) + { + String extractedData = null; + + ruleService.disableRules(); + try + { + NodeRef nodeRef = (NodeRef) value; + StringBuilder sb = new StringBuilder(128); + + if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + // Get path from the RM root + List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); + + for (NodeRef pathNodeRef : nodeRefPath) + { + String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); + sb.append("/").append(name); + } + } + + // Done + extractedData = sb.toString(); + } + finally + { + ruleService.enableRules(); + } + + return extractedData; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java index c00c143e5e..e86cae1674 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java @@ -1,106 +1,106 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.audit.extractor; - -import java.io.Serializable; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.audit.extractor.AbstractDataExtractor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.rule.RuleService; - -/** - * An extractor that extracts the NodeRef path from the RM root down to - * - and including - the node itself. This will only extract data if the - * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. - * - * @see FilePlanService#getNodeRefPath(NodeRef) - * - * @author Derek Hulley - * @since 1.0 - */ -public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtractor -{ - private NodeService nodeService; - private FilePlanService filePlanService; - private RuleService ruleService; - - /** - * Used to check that the node in the context is a fileplan component - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param ruleService the ruleService to set - */ - public void setRuleService(RuleService ruleService) - { - this.ruleService = ruleService; - } - - /** - * @return Returns true if the data is a NodeRef and it represents - * a fileplan component - */ - public boolean isSupported(Serializable data) - { - if (!(data instanceof NodeRef)) - { - return false; - } - return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); - } - - public Serializable extractData(Serializable value) - { - Serializable extractedData = null; - - ruleService.disableRules(); - try - { - NodeRef nodeRef = (NodeRef) value; - - // Get path from the RM root - List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - - // Done - extractedData = (Serializable) nodeRefPath; - } - finally - { - ruleService.enableRules(); - } - - return extractedData; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.audit.extractor; + +import java.io.Serializable; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.audit.extractor.AbstractDataExtractor; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.rule.RuleService; + +/** + * An extractor that extracts the NodeRef path from the RM root down to + * - and including - the node itself. This will only extract data if the + * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. + * + * @see FilePlanService#getNodeRefPath(NodeRef) + * + * @author Derek Hulley + * @since 1.0 + */ +public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtractor +{ + private NodeService nodeService; + private FilePlanService filePlanService; + private RuleService ruleService; + + /** + * Used to check that the node in the context is a fileplan component + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param ruleService the ruleService to set + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + + /** + * @return Returns true if the data is a NodeRef and it represents + * a fileplan component + */ + public boolean isSupported(Serializable data) + { + if (!(data instanceof NodeRef)) + { + return false; + } + return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + } + + public Serializable extractData(Serializable value) + { + Serializable extractedData = null; + + ruleService.disableRules(); + try + { + NodeRef nodeRef = (NodeRef) value; + + // Get path from the RM root + List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); + + // Done + extractedData = (Serializable) nodeRefPath; + } + finally + { + ruleService.enableRules(); + } + + return extractedData; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java index f204829fe6..e6fa8d4793 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java @@ -1,91 +1,91 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter; -import org.alfresco.repo.module.ImporterModuleComponent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; - -/** - * Custom implementation of module component importer - * - * @author Roy Wetherall - * @since 2.0 - */ -public class BootstrapImporterModuleComponent extends ImporterModuleComponent -{ - /** rm config folder name */ - private static final String CONFIG_NODEID = "rm_config_folder"; - - /** node service */ - private NodeService nodeService; - - /** module patch executer */ - private ModulePatchExecuter modulePatchExecuter; - - /** record contributors group bootstrap component */ - private RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param modulePatchExecuter module patch executer - */ - public void setModulePatchExecuter(ModulePatchExecuter modulePatchExecuter) - { - this.modulePatchExecuter = modulePatchExecuter; - } - - /** - * @param recordContributorsGroupBootstrapComponent record contributors group bootstrap component - */ - public void setRecordContributorsGroupBootstrapComponent(RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent) - { - this.recordContributorsGroupBootstrapComponent = recordContributorsGroupBootstrapComponent; - } - - /** - * Need to check whether this module has already been executed. - * - * @see org.alfresco.repo.module.ImporterModuleComponent#executeInternal() - */ - @Override - protected void executeInternal() throws Throwable - { - NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); - if (!nodeService.exists(nodeRef)) - { - super.executeInternal(); - - // bootstrap the record contributors group - recordContributorsGroupBootstrapComponent.createRecordContributorsGroup(); - - // init module schema number - modulePatchExecuter.initSchemaVersion(); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter; +import org.alfresco.repo.module.ImporterModuleComponent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; + +/** + * Custom implementation of module component importer + * + * @author Roy Wetherall + * @since 2.0 + */ +public class BootstrapImporterModuleComponent extends ImporterModuleComponent +{ + /** rm config folder name */ + private static final String CONFIG_NODEID = "rm_config_folder"; + + /** node service */ + private NodeService nodeService; + + /** module patch executer */ + private ModulePatchExecuter modulePatchExecuter; + + /** record contributors group bootstrap component */ + private RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param modulePatchExecuter module patch executer + */ + public void setModulePatchExecuter(ModulePatchExecuter modulePatchExecuter) + { + this.modulePatchExecuter = modulePatchExecuter; + } + + /** + * @param recordContributorsGroupBootstrapComponent record contributors group bootstrap component + */ + public void setRecordContributorsGroupBootstrapComponent(RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent) + { + this.recordContributorsGroupBootstrapComponent = recordContributorsGroupBootstrapComponent; + } + + /** + * Need to check whether this module has already been executed. + * + * @see org.alfresco.repo.module.ImporterModuleComponent#executeInternal() + */ + @Override + protected void executeInternal() throws Throwable + { + NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); + if (!nodeService.exists(nodeRef)) + { + super.executeInternal(); + + // bootstrap the record contributors group + recordContributorsGroupBootstrapComponent.createRecordContributorsGroup(); + + // init module schema number + modulePatchExecuter.initSchemaVersion(); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponent.java index 14482708b4..cc1ef4ddc5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponent.java @@ -1,73 +1,73 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; - -/** - * Record contributors group bootstrap component - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordContributorsGroupBootstrapComponent -{ - // default record contributors group - public static final String RECORD_CONTRIBUTORS = "RECORD_CONTRIBUTORS"; - public static final String GROUP_RECORD_CONTRIBUTORS = "GROUP_" + RECORD_CONTRIBUTORS; - - /** authority service */ - private AuthorityService authorityService; - - /** authentication utils */ - private AuthenticationUtil authenticationUtil; - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param authenticationUtil authentication util - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * Create record contributor group - */ - public void createRecordContributorsGroup() - { - if (!authorityService.authorityExists(GROUP_RECORD_CONTRIBUTORS)) - { - // create record contributors group - authorityService.createAuthority(AuthorityType.GROUP, RECORD_CONTRIBUTORS); - - // add the admin user - authorityService.addAuthority(GROUP_RECORD_CONTRIBUTORS, authenticationUtil.getAdminUserName()); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; + +/** + * Record contributors group bootstrap component + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordContributorsGroupBootstrapComponent +{ + // default record contributors group + public static final String RECORD_CONTRIBUTORS = "RECORD_CONTRIBUTORS"; + public static final String GROUP_RECORD_CONTRIBUTORS = "GROUP_" + RECORD_CONTRIBUTORS; + + /** authority service */ + private AuthorityService authorityService; + + /** authentication utils */ + private AuthenticationUtil authenticationUtil; + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param authenticationUtil authentication util + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * Create record contributor group + */ + public void createRecordContributorsGroup() + { + if (!authorityService.authorityExists(GROUP_RECORD_CONTRIBUTORS)) + { + // create record contributors group + authorityService.createAuthority(AuthorityType.GROUP, RECORD_CONTRIBUTORS); + + // add the admin user + authorityService.addAuthority(GROUP_RECORD_CONTRIBUTORS, authenticationUtil.getAdminUserName()); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java index 2dcfff5dd2..fa6ef347e9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java @@ -1,114 +1,114 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; -import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; -import org.alfresco.repo.action.parameter.NodeParameterSuggesterBootstrap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.transaction.TransactionService; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - - -/** - * RM module bootstrap - * - * @author janv - */ -public class RecordsManagementBootstrap extends AbstractLifecycleBean -{ - private TransactionService transactionService; - private RMCaveatConfigService caveatConfigService; - private CustomEmailMappingService customEmailMappingService; - private NodeParameterSuggesterBootstrap suggesterBootstrap; - - public NodeParameterSuggesterBootstrap getSuggesterBootstrap() - { - return suggesterBootstrap; - } - - public void setSuggesterBootstrap(NodeParameterSuggesterBootstrap suggesterBootstrap) - { - this.suggesterBootstrap = suggesterBootstrap; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setCaveatConfigService(RMCaveatConfigService caveatConfigService) - { - this.caveatConfigService = caveatConfigService; - } - - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - public CustomEmailMappingService getCustomEmailMappingService() - { - return customEmailMappingService; - } - - @Override - protected void onBootstrap(ApplicationEvent event) - { - // run as System on bootstrap - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() - { - // initialise caveat config - caveatConfigService.init(); - - // Initialize the suggester after the model - // in case it contains namespaces from custom models - suggesterBootstrap.init(); - - // Initialise the SplitEmailAction - SplitEmailAction action = (SplitEmailAction)getApplicationContext().getBean("splitEmail"); - action.bootstrap(); - - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(callback); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - // NOOP - } -} - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.alfresco.repo.action.parameter.NodeParameterSuggesterBootstrap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.transaction.TransactionService; +import org.springframework.context.ApplicationEvent; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; + + +/** + * RM module bootstrap + * + * @author janv + */ +public class RecordsManagementBootstrap extends AbstractLifecycleBean +{ + private TransactionService transactionService; + private RMCaveatConfigService caveatConfigService; + private CustomEmailMappingService customEmailMappingService; + private NodeParameterSuggesterBootstrap suggesterBootstrap; + + public NodeParameterSuggesterBootstrap getSuggesterBootstrap() + { + return suggesterBootstrap; + } + + public void setSuggesterBootstrap(NodeParameterSuggesterBootstrap suggesterBootstrap) + { + this.suggesterBootstrap = suggesterBootstrap; + } + + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + public void setCaveatConfigService(RMCaveatConfigService caveatConfigService) + { + this.caveatConfigService = caveatConfigService; + } + + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + public CustomEmailMappingService getCustomEmailMappingService() + { + return customEmailMappingService; + } + + @Override + protected void onBootstrap(ApplicationEvent event) + { + // run as System on bootstrap + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() + { + // initialise caveat config + caveatConfigService.init(); + + // Initialize the suggester after the model + // in case it contains namespaces from custom models + suggesterBootstrap.init(); + + // Initialise the SplitEmailAction + SplitEmailAction action = (SplitEmailAction)getApplicationContext().getBean("splitEmail"); + action.bootstrap(); + + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(callback); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + @Override + protected void onShutdown(ApplicationEvent event) + { + // NOOP + } +} + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java index 31901d53a8..c5b497c48d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java @@ -1,310 +1,310 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Abstract capability implementation. - * - * @author Andy Hind - * @author Roy Wetherall - */ -public abstract class AbstractCapability extends RMSecurityCommon - implements Capability, RecordsManagementModel, RMPermissionModel -{ - /** Capability service */ - protected CapabilityService capabilityService; - - /** Capability name */ - protected String name; - - /** Capability title and description */ - protected String title; - protected String description; - - /** Capability group */ - protected Group group; - - /** Capability index */ - protected int index; - - /** Indicates whether this is a private capability or not */ - protected boolean isPrivate = false; - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * Init method - */ - public void init() - { - capabilityService.registerCapability(this); - } - - /** - * @param name capability name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getName() - */ - @Override - public String getName() - { - return name; - } - - /** - * @param title capability title - */ - public void setTitle(String title) - { - this.title = title; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle() - */ - @Override - public String getTitle() - { - String title = this.title; - if (StringUtils.isBlank(title)) - { - title = I18NUtil.getMessage("capability." + getName() + ".title"); - if (StringUtils.isBlank(title)) - { - title = getName(); - } - - } - return title; - } - - /** - * @param description capability description - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @param descriptionId message id - */ - public void setDescriptionId(String descriptionId) - { - this.description = I18NUtil.getMessage(descriptionId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getDescription() - */ - @Override - public String getDescription() - { - return description; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate() - */ - public boolean isPrivate() - { - return isPrivate; - } - - /** - * @param isPrivate indicates whether the capability is private or not - */ - public void setPrivate(boolean isPrivate) - { - this.isPrivate = isPrivate; - } - - /** - * Translates the vote to an AccessStatus - * - * @param vote - * @return - */ - private AccessStatus translate(int vote) - { - switch (vote) - { - case AccessDecisionVoter.ACCESS_ABSTAIN: - return AccessStatus.UNDETERMINED; - case AccessDecisionVoter.ACCESS_GRANTED: - return AccessStatus.ALLOWED; - case AccessDecisionVoter.ACCESS_DENIED: - return AccessStatus.DENIED; - default: - return AccessStatus.UNDETERMINED; - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#hasPermission(org.alfresco.service.cmr.repository.NodeRef) - */ - public AccessStatus hasPermission(NodeRef nodeRef) - { - return translate(hasPermissionRaw(nodeRef)); - } - - /** - * Determines whether the current user has permission on this capability. - *

- * Returns the raw permission value. - * - * @param nodeRef node reference - * @return raw permission value - */ - public int hasPermissionRaw(NodeRef nodeRef) - { - String prefix = "hasPermissionRaw" + getName(); - int result = getTransactionCache(prefix, nodeRef); - if (result == NOSET_VALUE) - { - if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - else - { - result = hasPermissionImpl(nodeRef); - } - - result = setTransactionCache(prefix, nodeRef, result); - } - - // Log information about evaluated capability - RMMethodSecurityInterceptor.reportCapabilityStatus(getName(), result); - - return result; - } - - /** - * Default implementation. Override if different behaviour required. - * - * @param nodeRef - * @return - */ - protected int hasPermissionImpl(NodeRef nodeRef) - { - return evaluate(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - public int evaluate(NodeRef source, NodeRef target) - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroup() - */ - public Group getGroup() - { - return this.group; - } - - public void setGroup(Group group) - { - this.group = group; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getIndex() - */ - public int getIndex() - { - return this.index; - } - - public void setIndex(int index) - { - this.index = index; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final AbstractCapability other = (AbstractCapability) obj; - if (getName() == null) - { - if (other.getName() != null) - { - return false; - } - } - else if (!getName().equals(other.getName())) - { - return false; - } - return true; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Abstract capability implementation. + * + * @author Andy Hind + * @author Roy Wetherall + */ +public abstract class AbstractCapability extends RMSecurityCommon + implements Capability, RecordsManagementModel, RMPermissionModel +{ + /** Capability service */ + protected CapabilityService capabilityService; + + /** Capability name */ + protected String name; + + /** Capability title and description */ + protected String title; + protected String description; + + /** Capability group */ + protected Group group; + + /** Capability index */ + protected int index; + + /** Indicates whether this is a private capability or not */ + protected boolean isPrivate = false; + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * Init method + */ + public void init() + { + capabilityService.registerCapability(this); + } + + /** + * @param name capability name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getName() + */ + @Override + public String getName() + { + return name; + } + + /** + * @param title capability title + */ + public void setTitle(String title) + { + this.title = title; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle() + */ + @Override + public String getTitle() + { + String title = this.title; + if (StringUtils.isBlank(title)) + { + title = I18NUtil.getMessage("capability." + getName() + ".title"); + if (StringUtils.isBlank(title)) + { + title = getName(); + } + + } + return title; + } + + /** + * @param description capability description + */ + public void setDescription(String description) + { + this.description = description; + } + + /** + * @param descriptionId message id + */ + public void setDescriptionId(String descriptionId) + { + this.description = I18NUtil.getMessage(descriptionId); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getDescription() + */ + @Override + public String getDescription() + { + return description; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate() + */ + public boolean isPrivate() + { + return isPrivate; + } + + /** + * @param isPrivate indicates whether the capability is private or not + */ + public void setPrivate(boolean isPrivate) + { + this.isPrivate = isPrivate; + } + + /** + * Translates the vote to an AccessStatus + * + * @param vote + * @return + */ + private AccessStatus translate(int vote) + { + switch (vote) + { + case AccessDecisionVoter.ACCESS_ABSTAIN: + return AccessStatus.UNDETERMINED; + case AccessDecisionVoter.ACCESS_GRANTED: + return AccessStatus.ALLOWED; + case AccessDecisionVoter.ACCESS_DENIED: + return AccessStatus.DENIED; + default: + return AccessStatus.UNDETERMINED; + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#hasPermission(org.alfresco.service.cmr.repository.NodeRef) + */ + public AccessStatus hasPermission(NodeRef nodeRef) + { + return translate(hasPermissionRaw(nodeRef)); + } + + /** + * Determines whether the current user has permission on this capability. + *

+ * Returns the raw permission value. + * + * @param nodeRef node reference + * @return raw permission value + */ + public int hasPermissionRaw(NodeRef nodeRef) + { + String prefix = "hasPermissionRaw" + getName(); + int result = getTransactionCache(prefix, nodeRef); + if (result == NOSET_VALUE) + { + if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + else + { + result = hasPermissionImpl(nodeRef); + } + + result = setTransactionCache(prefix, nodeRef, result); + } + + // Log information about evaluated capability + RMMethodSecurityInterceptor.reportCapabilityStatus(getName(), result); + + return result; + } + + /** + * Default implementation. Override if different behaviour required. + * + * @param nodeRef + * @return + */ + protected int hasPermissionImpl(NodeRef nodeRef) + { + return evaluate(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + public int evaluate(NodeRef source, NodeRef target) + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroup() + */ + public Group getGroup() + { + return this.group; + } + + public void setGroup(Group group) + { + this.group = group; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getIndex() + */ + public int getIndex() + { + return this.index; + } + + public void setIndex(int index) + { + this.index = index; + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final AbstractCapability other = (AbstractCapability) obj; + if (getName() == null) + { + if (other.getName() != null) + { + return false; + } + } + else if (!getName().equals(other.getName())) + { + return false; + } + return true; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java index b97521eac2..dd67ab4e15 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java @@ -1,105 +1,105 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Capability Interface. - * - * @author andyh - * @author Roy Wetherall - */ -public interface Capability -{ - /** - * Does this capability apply to this nodeRef? - * @param nodeRef - * @return - */ - AccessStatus hasPermission(NodeRef nodeRef); - - /** - * - * @param nodeRef - * @return - */ - int hasPermissionRaw(NodeRef nodeRef); - - /** - * Evaluates the capability. - * - * @param nodeRef - * @return - */ - int evaluate(NodeRef nodeRef); - - /** - * Evaluates the capability, taking into account a target. - * - * @param source source node reference - * @param target target node reference - * @return int permission value - */ - int evaluate(NodeRef source, NodeRef target); - - /** - * Indicates whether this is a private capability or not. Private capabilities are used internally, otherwise - * they are made available to the user to assign to roles. - * - * @return boolean true if private, false otherwise - */ - boolean isPrivate(); - - /** - * Get the name of the capability - * - * @return String capability name - */ - String getName(); - - /** - * Get the title of the capability - * - * @return String capability title - */ - String getTitle(); - - /** - * Get the description of the capability - * - * @return String capability description - */ - String getDescription(); - - /** - * Gets the group of a capability - * - * @return Group capability group - */ - Group getGroup(); - - /** - * Gets the index of a capability - * - * @return int capability index - */ - int getIndex(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Capability Interface. + * + * @author andyh + * @author Roy Wetherall + */ +public interface Capability +{ + /** + * Does this capability apply to this nodeRef? + * @param nodeRef + * @return + */ + AccessStatus hasPermission(NodeRef nodeRef); + + /** + * + * @param nodeRef + * @return + */ + int hasPermissionRaw(NodeRef nodeRef); + + /** + * Evaluates the capability. + * + * @param nodeRef + * @return + */ + int evaluate(NodeRef nodeRef); + + /** + * Evaluates the capability, taking into account a target. + * + * @param source source node reference + * @param target target node reference + * @return int permission value + */ + int evaluate(NodeRef source, NodeRef target); + + /** + * Indicates whether this is a private capability or not. Private capabilities are used internally, otherwise + * they are made available to the user to assign to roles. + * + * @return boolean true if private, false otherwise + */ + boolean isPrivate(); + + /** + * Get the name of the capability + * + * @return String capability name + */ + String getName(); + + /** + * Get the title of the capability + * + * @return String capability title + */ + String getTitle(); + + /** + * Get the description of the capability + * + * @return String capability description + */ + String getDescription(); + + /** + * Gets the group of a capability + * + * @return Group capability group + */ + Group getGroup(); + + /** + * Gets the index of a capability + * + * @return int capability index + */ + int getIndex(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java index bf7955cc86..6789dc2054 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java @@ -1,143 +1,143 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Capability service implementation - * - * @author Roy Wetherall - * @since 2.0 - */ -public interface CapabilityService -{ - /** - * Register a capability - * - * @param capability capability - */ - void registerCapability(Capability capability); - - /** - * Get a named capability. - * - * @param name capability name - * @return {@link Capability} capability or null if not found - */ - Capability getCapability(String name); - - /** - * Get a list of all the assignable capabilities. - * - * @return {@link Set}<{@link Capability}> set of all the assignable capabilities - */ - Set getCapabilities(); - - /** - * Get a list of all the capabilities, optionally including those that are non-assignable. - * - * @param includePrivate indicates that the private, or non-assignable capabilities are included in the result - * @return {@link Set}<{@link Capability}> set of capabilities - */ - Set getCapabilities(boolean includePrivate); - - /** - * Get all the capabilities access state based on the current user for the assignable capabilities. - * - * @param nodeRef node reference - * @return - */ - Map getCapabilitiesAccessState(NodeRef nodeRef); - - /** - * Get all the capabilities access state based on the current user. - * - * @param nodeRef node reference - * @return - */ - Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate); - - /** - * - * @param nodeRef - * @param capabilityNames - * @return - */ - Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames); - - /** - * Helper method to get the access state for a single capability. - * - * @param nodeRef - * @param capabilityName - * @return - */ - AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName); - - /** - * Gets the list of all the capability groups (in index order) - * - * @return {@link List}<{@link Group}> List of all the capability groups (in index order) - */ - List getGroups(); - - /** - * Gets a list of capabilities for the given group id - * - * @param groupId The id of a group for which the list of capabilities should be retrieved - * @return {@link List}<{@link Capability}> List of capabilities for the given group - */ - List getCapabilitiesByGroupId(String groupId); - - /** - * Get a list of capabilities for the given group - * - * @param group The group for which the list of capabilities should be retrieved - * @return {@link List}<{@link Capability}> List of capabilities for the given group - */ - List getCapabilitiesByGroup(Group group); - - /** - * Gets a group from it's id - * - * @param groupId The id of the group which should be retrieved - * @return Group The group with the id groupId - */ - Group getGroup(String groupId); - - /** - * Adds a group to the list of groups - * - * @param group The group which should be added - */ - void addGroup(Group group); - - /** - * Removes a group from the list of groups - * - * @param group The group which should be removed - */ - void removeGroup(Group group); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Capability service implementation + * + * @author Roy Wetherall + * @since 2.0 + */ +public interface CapabilityService +{ + /** + * Register a capability + * + * @param capability capability + */ + void registerCapability(Capability capability); + + /** + * Get a named capability. + * + * @param name capability name + * @return {@link Capability} capability or null if not found + */ + Capability getCapability(String name); + + /** + * Get a list of all the assignable capabilities. + * + * @return {@link Set}<{@link Capability}> set of all the assignable capabilities + */ + Set getCapabilities(); + + /** + * Get a list of all the capabilities, optionally including those that are non-assignable. + * + * @param includePrivate indicates that the private, or non-assignable capabilities are included in the result + * @return {@link Set}<{@link Capability}> set of capabilities + */ + Set getCapabilities(boolean includePrivate); + + /** + * Get all the capabilities access state based on the current user for the assignable capabilities. + * + * @param nodeRef node reference + * @return + */ + Map getCapabilitiesAccessState(NodeRef nodeRef); + + /** + * Get all the capabilities access state based on the current user. + * + * @param nodeRef node reference + * @return + */ + Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate); + + /** + * + * @param nodeRef + * @param capabilityNames + * @return + */ + Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames); + + /** + * Helper method to get the access state for a single capability. + * + * @param nodeRef + * @param capabilityName + * @return + */ + AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName); + + /** + * Gets the list of all the capability groups (in index order) + * + * @return {@link List}<{@link Group}> List of all the capability groups (in index order) + */ + List getGroups(); + + /** + * Gets a list of capabilities for the given group id + * + * @param groupId The id of a group for which the list of capabilities should be retrieved + * @return {@link List}<{@link Capability}> List of capabilities for the given group + */ + List getCapabilitiesByGroupId(String groupId); + + /** + * Get a list of capabilities for the given group + * + * @param group The group for which the list of capabilities should be retrieved + * @return {@link List}<{@link Capability}> List of capabilities for the given group + */ + List getCapabilitiesByGroup(Group group); + + /** + * Gets a group from it's id + * + * @param groupId The id of the group which should be retrieved + * @return Group The group with the id groupId + */ + Group getGroup(String groupId); + + /** + * Adds a group to the list of groups + * + * @param group The group which should be added + */ + void addGroup(Group group); + + /** + * Removes a group from the list of groups + * + * @param group The group which should be removed + */ + void removeGroup(Group group); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java index 360a78b734..0ce1ae300e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java @@ -1,276 +1,276 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.util.ParameterCheck; - -/** - * @author Roy Wetherall - * @since 2.0 - */ -public class CapabilityServiceImpl implements CapabilityService -{ - /** Capabilities */ - private Map capabilities = new HashMap(57); - - /** Groups */ - private Map groups = new HashMap(13); - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String) - */ - @Override - public Capability getCapability(String name) - { - ParameterCheck.mandatoryString("name", name); - - return capabilities.get(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#registerCapability(org.alfresco.module.org_alfresco_module_rm.capability.Capability) - */ - @Override - public void registerCapability(Capability capability) - { - ParameterCheck.mandatory("capability", capability); - - capabilities.put(capability.getName(), capability); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities() - */ - @Override - public Set getCapabilities() - { - return getCapabilities(true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean) - */ - @Override - public Set getCapabilities(boolean includePrivate) - { - Set result = null; - if (includePrivate) - { - result = new HashSet(capabilities.values()); - } - else - { - result = new HashSet(capabilities.size()); - for (Capability capability : capabilities.values()) - { - if (!capability.isPrivate()) - { - result.add(capability); - } - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef) - */ - public Map getCapabilitiesAccessState(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return getCapabilitiesAccessState(nodeRef, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - Set listOfCapabilites = getCapabilities(includePrivate); - HashMap answer = new HashMap(); - for (Capability capability : listOfCapabilites) - { - AccessStatus status = capability.hasPermission(nodeRef); - if (answer.put(capability, status) != null) - { - throw new IllegalStateException(); - } - } - return answer; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, java.util.List) - */ - public Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("capabilityNames", capabilityNames); - - HashMap answer = new HashMap(); - for (String capabilityName : capabilityNames) - { - Capability capability = capabilities.get(capabilityName); - if (capability != null) - { - AccessStatus status = capability.hasPermission(nodeRef); - if (answer.put(capability, status) != null) - { - throw new IllegalStateException(); - } - } - } - return answer; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilityAccessState(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("capabilityName", capabilityName); - - AccessStatus result = AccessStatus.UNDETERMINED; - Capability capability = getCapability(capabilityName); - if (capability != null) - { - List list = Collections.singletonList(capabilityName); - Map map = getCapabilitiesAccessState(nodeRef, list); - result = map.get(capability); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroups() - */ - @Override - public List getGroups() - { - List groups = new ArrayList(); - for (Map.Entry entry : this.groups.entrySet()) - { - groups.add(entry.getValue()); - } - - Collections.sort(groups, new Comparator() - { - @Override - public int compare(Group g1, Group g2) - { - return g1.getIndex() - g2.getIndex(); - } - }); - - return groups; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroupId(java.lang.String) - */ - @Override - public List getCapabilitiesByGroupId(String groupId) - { - ParameterCheck.mandatoryString("groupId", groupId); - - String id = this.groups.get(groupId).getId(); - - List capabilities = new ArrayList(); - for (Capability capability : getCapabilities()) - { - Group group = capability.getGroup(); - if (group != null && group.getId().equalsIgnoreCase(id)) - { - capabilities.add(capability); - } - } - - Collections.sort(capabilities, new Comparator() - { - @Override - public int compare(Capability c1, Capability c2) - { - return c1.getIndex() - c2.getIndex(); - } - }); - - return capabilities; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) - */ - @Override - public List getCapabilitiesByGroup(Group group) - { - ParameterCheck.mandatory("group", group); - - return getCapabilitiesByGroupId(group.getId()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroup(java.lang.String) - */ - @Override - public Group getGroup(String groupId) - { - ParameterCheck.mandatoryString("groupId", groupId); - - return this.groups.get(groupId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#addGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) - */ - @Override - public void addGroup(Group group) - { - ParameterCheck.mandatory("group", group); - - groups.put(group.getId(), group); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#removeGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) - */ - @Override - public void removeGroup(Group group) - { - ParameterCheck.mandatory("group", group); - - groups.remove(group.getId()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.util.ParameterCheck; + +/** + * @author Roy Wetherall + * @since 2.0 + */ +public class CapabilityServiceImpl implements CapabilityService +{ + /** Capabilities */ + private Map capabilities = new HashMap(57); + + /** Groups */ + private Map groups = new HashMap(13); + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String) + */ + @Override + public Capability getCapability(String name) + { + ParameterCheck.mandatoryString("name", name); + + return capabilities.get(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#registerCapability(org.alfresco.module.org_alfresco_module_rm.capability.Capability) + */ + @Override + public void registerCapability(Capability capability) + { + ParameterCheck.mandatory("capability", capability); + + capabilities.put(capability.getName(), capability); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities() + */ + @Override + public Set getCapabilities() + { + return getCapabilities(true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean) + */ + @Override + public Set getCapabilities(boolean includePrivate) + { + Set result = null; + if (includePrivate) + { + result = new HashSet(capabilities.values()); + } + else + { + result = new HashSet(capabilities.size()); + for (Capability capability : capabilities.values()) + { + if (!capability.isPrivate()) + { + result.add(capability); + } + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef) + */ + public Map getCapabilitiesAccessState(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return getCapabilitiesAccessState(nodeRef, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + Set listOfCapabilites = getCapabilities(includePrivate); + HashMap answer = new HashMap(); + for (Capability capability : listOfCapabilites) + { + AccessStatus status = capability.hasPermission(nodeRef); + if (answer.put(capability, status) != null) + { + throw new IllegalStateException(); + } + } + return answer; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, java.util.List) + */ + public Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("capabilityNames", capabilityNames); + + HashMap answer = new HashMap(); + for (String capabilityName : capabilityNames) + { + Capability capability = capabilities.get(capabilityName); + if (capability != null) + { + AccessStatus status = capability.hasPermission(nodeRef); + if (answer.put(capability, status) != null) + { + throw new IllegalStateException(); + } + } + } + return answer; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilityAccessState(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("capabilityName", capabilityName); + + AccessStatus result = AccessStatus.UNDETERMINED; + Capability capability = getCapability(capabilityName); + if (capability != null) + { + List list = Collections.singletonList(capabilityName); + Map map = getCapabilitiesAccessState(nodeRef, list); + result = map.get(capability); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroups() + */ + @Override + public List getGroups() + { + List groups = new ArrayList(); + for (Map.Entry entry : this.groups.entrySet()) + { + groups.add(entry.getValue()); + } + + Collections.sort(groups, new Comparator() + { + @Override + public int compare(Group g1, Group g2) + { + return g1.getIndex() - g2.getIndex(); + } + }); + + return groups; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroupId(java.lang.String) + */ + @Override + public List getCapabilitiesByGroupId(String groupId) + { + ParameterCheck.mandatoryString("groupId", groupId); + + String id = this.groups.get(groupId).getId(); + + List capabilities = new ArrayList(); + for (Capability capability : getCapabilities()) + { + Group group = capability.getGroup(); + if (group != null && group.getId().equalsIgnoreCase(id)) + { + capabilities.add(capability); + } + } + + Collections.sort(capabilities, new Comparator() + { + @Override + public int compare(Capability c1, Capability c2) + { + return c1.getIndex() - c2.getIndex(); + } + }); + + return capabilities; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) + */ + @Override + public List getCapabilitiesByGroup(Group group) + { + ParameterCheck.mandatory("group", group); + + return getCapabilitiesByGroupId(group.getId()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroup(java.lang.String) + */ + @Override + public Group getGroup(String groupId) + { + ParameterCheck.mandatoryString("groupId", groupId); + + return this.groups.get(groupId); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#addGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) + */ + @Override + public void addGroup(Group group) + { + ParameterCheck.mandatory("group", group); + + groups.put(group.getId(), group); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#removeGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group) + */ + @Override + public void removeGroup(Group group) + { + ParameterCheck.mandatory("group", group); + + groups.remove(group.getId()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CompositeCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CompositeCapability.java index 2c671eaca9..c5d0ee60a8 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CompositeCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CompositeCapability.java @@ -1,37 +1,37 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.util.Set; - -/** - * Composite capability Interface. - * - * @author Roy Wetherall - * @since 2.2 - */ -public interface CompositeCapability extends Capability -{ - /** - * Get set of child capabilities. - * - * @return {@link Set}<{@link Capability}> set of child capabilities. - */ - Set getCapabilities(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.util.Set; + +/** + * Composite capability Interface. + * + * @author Roy Wetherall + * @since 2.2 + */ +public interface CompositeCapability extends Capability +{ + /** + * Get set of child capabilities. + * + * @return {@link Set}<{@link Capability}> set of child capabilities. + */ + Set getCapabilities(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Group.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Group.java index e7cabb4115..13210a00a7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Group.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Group.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -/** - * Group interface - * - * @author Tuna Aksoy - * @since 2.1 - */ -public interface Group -{ - /** - * Gets the id of a group (Get the id of the group) - * - * @return String the group id - */ - String getId(); - - /** - * Gets the title of a group - * - * @return String the group title - */ - String getTitle(); - - /** - * Gets the index of a group - * - * @return int the group index - */ - int getIndex(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +/** + * Group interface + * + * @author Tuna Aksoy + * @since 2.1 + */ +public interface Group +{ + /** + * Gets the id of a group (Get the id of the group) + * + * @return String the group id + */ + String getId(); + + /** + * Gets the title of a group + * + * @return String the group title + */ + String getTitle(); + + /** + * Gets the index of a group + * + * @return int the group index + */ + int getIndex(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java index 2f31adb63f..6c6e51997c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java @@ -1,105 +1,105 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Group implementation - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class GroupImpl implements Group -{ - /** The group id */ - private String id; - - /** The group title */ - private String title; - - /** The group index */ - private int index; - - /** Capability service */ - private CapabilityService capabilityService; - - /** - * Sets the capability service - * - * @param capabilityService the capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - public void init() - { - this.capabilityService.addGroup(this); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getId() - */ - @Override - public String getId() - { - return this.id; - } - - public void setId(String id) - { - this.id = id; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getTitle() - */ - @Override - public String getTitle() - { - String title = this.title; - if (StringUtils.isBlank(title)) - { - title = I18NUtil.getMessage("capability.group." + getId() + ".title"); - } - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getIndex() - */ - @Override - public int getIndex() - { - return this.index; - } - - public void setIndex(int index) - { - this.index = index; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Group implementation + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class GroupImpl implements Group +{ + /** The group id */ + private String id; + + /** The group title */ + private String title; + + /** The group index */ + private int index; + + /** Capability service */ + private CapabilityService capabilityService; + + /** + * Sets the capability service + * + * @param capabilityService the capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + public void init() + { + this.capabilityService.addGroup(this); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getId() + */ + @Override + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getTitle() + */ + @Override + public String getTitle() + { + String title = this.title; + if (StringUtils.isBlank(title)) + { + title = I18NUtil.getMessage("capability.group." + getId() + ".title"); + } + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getIndex() + */ + @Override + public int getIndex() + { + return this.index; + } + + public void setIndex(int index) + { + this.index = index; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/PolicyRegister.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/PolicyRegister.java index 56d21dea8f..68c2004095 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/PolicyRegister.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/PolicyRegister.java @@ -1,29 +1,29 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; - -/** - * @author Roy Wetherall - */ -public interface PolicyRegister -{ - void registerPolicy(Policy policy); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; + +/** + * @author Roy Wetherall + */ +public interface PolicyRegister +{ + void registerPolicy(Policy policy); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMActionProxyFactoryBean.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMActionProxyFactoryBean.java index ed2a64e6e3..6a6125c1d5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMActionProxyFactoryBean.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMActionProxyFactoryBean.java @@ -1,93 +1,93 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.repo.action.RuntimeActionService; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.springframework.aop.framework.ProxyFactoryBean; - -/** - * RM action proxy factory bean. - * - * @author Roy Wetherall - */ -public class RMActionProxyFactoryBean extends ProxyFactoryBean -{ - private static final long serialVersionUID = 539749542853266449L; - - /** Runtime action service */ - protected RuntimeActionService runtimeActionService; - - /** Records management action service */ - protected RecordsManagementActionService recordsManagementActionService; - - /** Records management audit service */ - protected RecordsManagementAuditService recordsManagementAuditService; - - /** - * Set action service - * - * @param actionService - */ - public void setRuntimeActionService(RuntimeActionService runtimeActionService) - { - this.runtimeActionService = runtimeActionService; - } - - /** - * Set records management service - * - * @param recordsManagementActionService - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * Set records management service - * - * @param recordsManagementAuditService - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) - { - this.recordsManagementAuditService = recordsManagementAuditService; - } - - /** - * Register the action - */ - public void registerAction() - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - RecordsManagementAction action = (RecordsManagementAction)getObject(); - recordsManagementActionService.register(action); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.repo.action.RuntimeActionService; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.springframework.aop.framework.ProxyFactoryBean; + +/** + * RM action proxy factory bean. + * + * @author Roy Wetherall + */ +public class RMActionProxyFactoryBean extends ProxyFactoryBean +{ + private static final long serialVersionUID = 539749542853266449L; + + /** Runtime action service */ + protected RuntimeActionService runtimeActionService; + + /** Records management action service */ + protected RecordsManagementActionService recordsManagementActionService; + + /** Records management audit service */ + protected RecordsManagementAuditService recordsManagementAuditService; + + /** + * Set action service + * + * @param actionService + */ + public void setRuntimeActionService(RuntimeActionService runtimeActionService) + { + this.runtimeActionService = runtimeActionService; + } + + /** + * Set records management service + * + * @param recordsManagementActionService + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * Set records management service + * + * @param recordsManagementAuditService + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) + { + this.recordsManagementAuditService = recordsManagementAuditService; + } + + /** + * Register the action + */ + public void registerAction() + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + RecordsManagementAction action = (RecordsManagementAction)getObject(); + recordsManagementActionService.register(action); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java index 437f1c4c08..5e8f12e920 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java @@ -1,962 +1,962 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -import net.sf.acegisecurity.AccessDeniedException; -import net.sf.acegisecurity.Authentication; -import net.sf.acegisecurity.ConfigAttribute; -import net.sf.acegisecurity.ConfigAttributeDefinition; -import net.sf.acegisecurity.afterinvocation.AfterInvocationProvider; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.search.SimpleResultSetMetaData; -import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet; -import org.alfresco.repo.search.impl.querymodel.QueryEngineResults; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.PermissionCheckCollection; -import org.alfresco.repo.security.permissions.PermissionCheckValue; -import org.alfresco.repo.security.permissions.PermissionCheckedCollection.PermissionCheckedCollectionMixin; -import org.alfresco.repo.security.permissions.PermissionCheckedValue; -import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; -import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.PermissionEvaluationMode; -import org.alfresco.service.cmr.search.ResultSet; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * RM After Invocation Provider - */ -@SuppressWarnings("unused") -public class RMAfterInvocationProvider extends RMSecurityCommon - implements AfterInvocationProvider, InitializingBean -{ - private static Log logger = LogFactory.getLog(RMAfterInvocationProvider.class); - - private static final String AFTER_RM = "AFTER_RM"; - - private int maxPermissionChecks; - - private long maxPermissionCheckTimeMillis; - - public boolean supports(ConfigAttribute configAttribute) - { - String attribute = configAttribute.getAttribute(); - return (StringUtils.isNotBlank(attribute) && attribute.startsWith(AFTER_RM)); - } - - @SuppressWarnings("rawtypes") - public boolean supports(Class clazz) - { - return (MethodInvocation.class.isAssignableFrom(clazz)); - } - - public void afterPropertiesSet() - { - } - - /** - * Default constructor - */ - public RMAfterInvocationProvider() - { - super(); - maxPermissionChecks = Integer.MAX_VALUE; - maxPermissionCheckTimeMillis = Long.MAX_VALUE; - } - - /** - * Set the max number of permission checks - * - * @param maxPermissionChecks - */ - public void setMaxPermissionChecks(int maxPermissionChecks) - { - this.maxPermissionChecks = maxPermissionChecks; - } - - /** - * Set the max time for permission checks - * - * @param maxPermissionCheckTimeMillis - */ - public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis) - { - this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis; - } - - @SuppressWarnings("rawtypes") - public Object decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object returnedObject) - { - if (logger.isDebugEnabled()) - { - MethodInvocation mi = (MethodInvocation) object; - if (mi == null) - { - logger.debug("Method is null."); - } - else - { - logger.debug("Method: " + mi.getMethod().toString()); - } - } - try - { - if (AuthenticationUtil.isRunAsUserTheSystemUser()) - { - if (logger.isDebugEnabled()) - { - logger.debug("Allowing system user access"); - } - return returnedObject; - } - else if (returnedObject == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Allowing null object access"); - } - return null; - } - else if (PermissionCheckedValue.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (PermissionCheckedValue) returnedObject); - } - else if (PermissionCheckValue.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (PermissionCheckValue) returnedObject); - } - else if (StoreRef.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, nodeService.getRootNode((StoreRef) returnedObject)).getStoreRef(); - } - else if (NodeRef.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (NodeRef) returnedObject); - } - else if (ChildAssociationRef.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (ChildAssociationRef) returnedObject); - } - else if (AssociationRef.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (AssociationRef) returnedObject); - } - else if (ResultSet.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (ResultSet) returnedObject); - } - else if (PagingLuceneResultSet.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (PagingLuceneResultSet) returnedObject); - } - else if (QueryEngineResults.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (QueryEngineResults) returnedObject); - } - else if (Collection.class.isAssignableFrom(returnedObject.getClass())) - { - return decide(authentication, object, config, (Collection) returnedObject); - } - else if (returnedObject.getClass().isArray()) - { - return decide(authentication, object, config, (Object[]) returnedObject); - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("Uncontrolled object - access allowed for " + object.getClass().getName()); - } - return returnedObject; - } - } - catch (AccessDeniedException ade) - { - if (logger.isDebugEnabled()) - { - logger.debug("Access denied: " + ade.getMessage()); - } - throw ade; - } - catch (RuntimeException re) - { - if (logger.isDebugEnabled()) - { - logger.debug("Access denied by runtime exception: " + re.getMessage()); - } - throw re; - } - - } - - private PermissionCheckedValue decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PermissionCheckedValue returnedObject) - { - // This passes as it has already been filtered - // TODO: Get the filter that was applied and double-check - return returnedObject; - } - - private PermissionCheckValue decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PermissionCheckValue returnedObject) - { - // Get the wrapped value - NodeRef nodeRef = returnedObject.getNodeRef(); - decide(authentication, object, config, nodeRef); - // This passes - return returnedObject; - } - - private NodeRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, NodeRef returnedObject) - { - if (returnedObject == null) - { - return null; - } - - if (isUnfiltered(returnedObject)) - { - return returnedObject; - } - - List supportedDefinitions = extractSupportedDefinitions(config); - if (supportedDefinitions.size() == 0) - { - return returnedObject; - } - - int parentResult = checkRead(nodeService.getPrimaryParent(returnedObject).getParentRef()); - int childResult = checkRead(returnedObject); - checkSupportedDefinitions(supportedDefinitions, parentResult, childResult); - - return returnedObject; - } - - private void checkSupportedDefinitions(List supportedDefinitions, int parentResult, int childResult) - { - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - if (cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED) - { - throw new AccessDeniedException("Access Denied"); - } - else if (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED) - { - throw new AccessDeniedException("Access Denied"); - } - } - } - - private boolean isUnfiltered(NodeRef nodeRef) - { - return !nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); - - } - - @SuppressWarnings("rawtypes") - private List extractSupportedDefinitions(ConfigAttributeDefinition config) - { - List definitions = new ArrayList<>(); - Iterator iter = config.getConfigAttributes(); - - while (iter.hasNext()) - { - ConfigAttribute attr = (ConfigAttribute) iter.next(); - - if (this.supports(attr)) - { - definitions.add(new ConfigAttributeDefintion(attr)); - } - - } - return definitions; - } - - private ChildAssociationRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ChildAssociationRef returnedObject) - { - if (returnedObject == null) - { - return null; - } - - List supportedDefinitions = extractSupportedDefinitions(config); - - if (supportedDefinitions.size() == 0) - { - return returnedObject; - } - - int parentReadCheck = checkRead(returnedObject.getParentRef()); - int childReadCheck = checkRead(returnedObject.getChildRef()); - - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - NodeRef testNodeRef = null; - - if (cad.parent) - { - testNodeRef = returnedObject.getParentRef(); - } - else - { - testNodeRef = returnedObject.getChildRef(); - } - - // Enforce Read Policy - - if (isUnfiltered(testNodeRef)) - { - continue; - } - - if (cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED) - { - throw new AccessDeniedException("Access Denied"); - } - else if (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED) - { - throw new AccessDeniedException("Access Denied"); - } - } - - return returnedObject; - } - - private AssociationRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, AssociationRef returnedObject) - { - if (returnedObject == null) - { - return null; - } - - List supportedDefinitions = extractSupportedDefinitions(config); - - if (supportedDefinitions.size() == 0) - { - return returnedObject; - } - - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - NodeRef testNodeRef = null; - - if (cad.parent) - { - testNodeRef = returnedObject.getSourceRef(); - } - else - { - testNodeRef = returnedObject.getTargetRef(); - } - - if (isUnfiltered(testNodeRef)) - { - continue; - } - - if (checkRead(testNodeRef) != AccessDecisionVoter.ACCESS_GRANTED) - { - throw new AccessDeniedException("Access Denied"); - } - - } - - return returnedObject; - } - - private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PagingLuceneResultSet returnedObject) - { - ResultSet raw = returnedObject.getWrapped(); - ResultSet filteredForPermissions = decide(authentication, object, config, raw); - return new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService); - } - - private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ResultSet returnedObject) - { - if (returnedObject == null) - { - return null; - } - - class RMFilteringResultSet extends FilteringResultSet - { - private long numberFound; - - public RMFilteringResultSet(ResultSet unfiltered, BitSet inclusionMask) - { - super(unfiltered, inclusionMask); - } - - @Override - public long getNumberFound() - { - return numberFound; - } - - private void setNumberFound(long numberFound) - { - this.numberFound = numberFound; - } - } - - BitSet inclusionMask = new BitSet(returnedObject.length()); - RMFilteringResultSet filteringResultSet = new RMFilteringResultSet(returnedObject, inclusionMask); - - List supportedDefinitions = extractSupportedDefinitions(config); - - Integer maxSize = null; - if (returnedObject.getResultSetMetaData().getSearchParameters().getMaxItems() >= 0) - { - maxSize = Integer.valueOf(returnedObject.getResultSetMetaData().getSearchParameters().getMaxItems()); - } - if ((maxSize == null) && (returnedObject.getResultSetMetaData().getSearchParameters().getLimitBy() == LimitBy.FINAL_SIZE)) - { - maxSize = Integer.valueOf(returnedObject.getResultSetMetaData().getSearchParameters().getLimit()); - } - // Allow for skip - if ((maxSize != null) && (returnedObject.getResultSetMetaData().getSearchParameters().getSkipCount() >= 0)) - { - maxSize = Integer.valueOf(maxSize + returnedObject.getResultSetMetaData().getSearchParameters().getSkipCount()); - } - - if (supportedDefinitions.size() == 0) - { - if (maxSize == null) - { - return returnedObject; - } - else if (returnedObject.length() > maxSize.intValue()) - { - for (int i = 0; i < maxSize.intValue(); i++) - { - inclusionMask.set(i, true); - } - filteringResultSet.setResultSetMetaData( - new SimpleResultSetMetaData( - returnedObject.getResultSetMetaData().getLimitedBy(), - PermissionEvaluationMode.EAGER, - returnedObject.getResultSetMetaData().getSearchParameters())); - return filteringResultSet; - } - else - { - for (int i = 0; i < returnedObject.length(); i++) - { - inclusionMask.set(i, true); - } - filteringResultSet.setResultSetMetaData( - new SimpleResultSetMetaData( - returnedObject.getResultSetMetaData().getLimitedBy(), - PermissionEvaluationMode.EAGER, - returnedObject.getResultSetMetaData().getSearchParameters())); - return filteringResultSet; - } - } - - // record the start time - long startTimeMillis = System.currentTimeMillis(); - - // set the default, unlimited resultset type - filteringResultSet.setResultSetMetaData( - new SimpleResultSetMetaData( - returnedObject.getResultSetMetaData().getLimitedBy(), - PermissionEvaluationMode.EAGER, - returnedObject.getResultSetMetaData().getSearchParameters())); - - for (int i = 0; i < returnedObject.length(); i++) - { - long currentTimeMillis = System.currentTimeMillis(); - - // All permission checks must pass - inclusionMask.set(i, true); - - if (!nodeService.exists(returnedObject.getNodeRef(i))) - { - inclusionMask.set(i, false); - } - else - { - int parentCheckRead = checkRead(returnedObject.getChildAssocRef(i).getParentRef()); - int childCheckRead = checkRead(returnedObject.getNodeRef(i)); - - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - NodeRef testNodeRef = returnedObject.getNodeRef(i); - int checkRead = childCheckRead; - if (cad.parent) - { - testNodeRef = returnedObject.getChildAssocRef(i).getParentRef(); - checkRead = parentCheckRead; - } - - if (isUnfiltered(testNodeRef)) - { - continue; - } - - if (inclusionMask.get(i) && (testNodeRef != null) && (checkRead != AccessDecisionVoter.ACCESS_GRANTED)) - { - inclusionMask.set(i, false); - } - } - } - - // Bug out if we are limiting by size - if ((maxSize != null) && (filteringResultSet.length() > maxSize.intValue())) - { - // Remove the last match to fix the correct size - inclusionMask.set(i, false); - filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.FINAL_SIZE, PermissionEvaluationMode.EAGER, returnedObject.getResultSetMetaData() - .getSearchParameters())); - break; - } - } - - filteringResultSet.setNumberFound(returnedObject.getNumberFound()); - - return filteringResultSet; - } - - private QueryEngineResults decide(Authentication authentication, Object object, ConfigAttributeDefinition config, QueryEngineResults returnedObject) - { - Map, ResultSet> map = returnedObject.getResults(); - Map, ResultSet> answer = new HashMap, ResultSet>(map.size(), 1.0f); - - for (Map.Entry, ResultSet> entry : map.entrySet()) - { - ResultSet raw = entry.getValue(); - ResultSet permed; - if (PagingLuceneResultSet.class.isAssignableFrom(raw.getClass())) - { - permed = decide(authentication, object, config, (PagingLuceneResultSet) raw); - } - else - { - permed = decide(authentication, object, config, raw); - } - answer.put(entry.getKey(), permed); - } - - return new QueryEngineResults(answer); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private Collection decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Collection returnedObject) - { - if (returnedObject == null) - { - return null; - } - - List supportedDefinitions = extractSupportedDefinitions(config); - if (logger.isDebugEnabled()) - { - logger.debug("Entries are " + supportedDefinitions); - } - - if (supportedDefinitions.size() == 0) - { - return returnedObject; - } - - // Default to the system-wide values and we'll see if they need to be reduced - long targetResultCount = returnedObject.size(); - int maxPermissionChecks = Integer.MAX_VALUE; - long maxPermissionCheckTimeMillis = this.maxPermissionCheckTimeMillis; - if (returnedObject instanceof PermissionCheckCollection) - { - PermissionCheckCollection permissionCheckCollection = (PermissionCheckCollection) returnedObject; - // Get values - targetResultCount = permissionCheckCollection.getTargetResultCount(); - if (permissionCheckCollection.getCutOffAfterCount() > 0) - { - maxPermissionChecks = permissionCheckCollection.getCutOffAfterCount(); - } - if (permissionCheckCollection.getCutOffAfterTimeMs() > 0) - { - maxPermissionCheckTimeMillis = permissionCheckCollection.getCutOffAfterTimeMs(); - } - } - - // Start timer and counter for cut-off - boolean cutoff = false; - long startTimeMillis = System.currentTimeMillis(); - int count = 0; - - // Keep values explicitly - List keepValues = new ArrayList(returnedObject.size()); - - for (Object nextObject : returnedObject) - { - // if the maximum result size or time has been exceeded, then we have to remove only - long currentTimeMillis = System.currentTimeMillis(); - - // NOTE: for reference - the "maxPermissionChecks" has never been honoured by this loop (since previously the count was not being incremented) - if (count >= targetResultCount) - { - // We have enough results. We stop without cutoff. - break; - } - else if (count >= maxPermissionChecks) - { - // We have been cut off by count - cutoff = true; - if (logger.isDebugEnabled()) - { - logger.debug("decide (collection) cut-off: " + count + " checks exceeded " + maxPermissionChecks + " checks"); - } - break; - } - else if ((currentTimeMillis - startTimeMillis) > maxPermissionCheckTimeMillis) - { - // We have been cut off by time - cutoff = true; - if (logger.isDebugEnabled()) - { - logger.debug("decide (collection) cut-off: " + (currentTimeMillis - startTimeMillis) + "ms exceeded " + maxPermissionCheckTimeMillis + "ms"); - } - break; - } - - boolean allowed = true; - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - if (cad.mode.equalsIgnoreCase("FilterNode")) - { - NodeRef testNodeRef = null; - if (cad.parent) - { - if (StoreRef.class.isAssignableFrom(nextObject.getClass())) - { - // Will be allowed - testNodeRef = null; - } - else if (NodeRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = nodeService.getPrimaryParent((NodeRef) nextObject).getParentRef(); - } - else if (ChildAssociationRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = ((ChildAssociationRef) nextObject).getParentRef(); - } - else if (AssociationRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = ((AssociationRef) nextObject).getSourceRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(nextObject.getClass())) - { - NodeRef nodeRef = ((PermissionCheckValue) nextObject).getNodeRef(); - testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - } - else - { - throw new ACLEntryVoterException("The specified parameter is recognized: " + nextObject.getClass()); - } - } - else - { - if (StoreRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = nodeService.getRootNode((StoreRef) nextObject); - } - else if (NodeRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = (NodeRef) nextObject; - } - else if (ChildAssociationRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = ((ChildAssociationRef) nextObject).getChildRef(); - } - else if (AssociationRef.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = ((AssociationRef) nextObject).getTargetRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(nextObject.getClass())) - { - testNodeRef = ((PermissionCheckValue) nextObject).getNodeRef(); - } - else - { - throw new ACLEntryVoterException("The specified parameter is recognized: " + nextObject.getClass()); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("\t" + cad.typeString + " test on " + testNodeRef + " from " + nextObject.getClass().getName()); - } - - // Null allows - if (isUnfiltered(testNodeRef)) - { - // Continue to next ConfigAttributeDefintion - continue; - } - - if (allowed && - testNodeRef != null && - checkRead(testNodeRef) != AccessDecisionVoter.ACCESS_GRANTED) - { - allowed = false; - // No point evaluating more ConfigAttributeDefintions - break; - } - } - } - - // Failure or success, increase the count - count++; - - if (allowed) - { - keepValues.add(nextObject); - } - } - // Work out how many were left unchecked (for whatever reason) - int sizeOriginal = returnedObject.size(); - int checksRemaining = sizeOriginal - count; - // Note: There are use-cases where unmodifiable collections are passing through. - // So make sure that the collection needs modification at all - if (keepValues.size() < sizeOriginal) - { - // There are values that need to be removed. We have to modify the collection. - try - { - returnedObject.clear(); - returnedObject.addAll(keepValues); - } - catch (UnsupportedOperationException e) - { - throw new AccessDeniedException("Permission-checked list must be modifiable", e); - } - } - - // Attach the extra permission-check data to the collection - return PermissionCheckedCollectionMixin.create(returnedObject, cutoff, checksRemaining, sizeOriginal); - } - - private Object[] decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object[] returnedObject) - { - // Assumption: value is not null - BitSet incudedSet = new BitSet(returnedObject.length); - - List supportedDefinitions = extractSupportedDefinitions(config); - - if (supportedDefinitions.size() == 0) - { - return returnedObject; - } - - for (int i = 0, l = returnedObject.length; i < l; i++) - { - Object current = returnedObject[i]; - - int parentReadCheck = checkRead(getParentReadCheckNode(current)); - int childReadChek = checkRead(getChildReadCheckNode(current)); - - for (ConfigAttributeDefintion cad : supportedDefinitions) - { - incudedSet.set(i, true); - NodeRef testNodeRef = null; - if (cad.parent) - { - if (StoreRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = null; - } - else if (NodeRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = nodeService.getPrimaryParent((NodeRef) current).getParentRef(); - } - else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((ChildAssociationRef) current).getParentRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) - { - NodeRef nodeRef = ((PermissionCheckValue) current).getNodeRef(); - testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - } - else - { - throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass()); - } - } - else - { - if (StoreRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = nodeService.getRootNode((StoreRef) current); - } - else if (NodeRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = (NodeRef) current; - } - else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((ChildAssociationRef) current).getChildRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((PermissionCheckValue) current).getNodeRef(); - } - else - { - throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass()); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("\t" + cad.typeString + " test on " + testNodeRef + " from " + current.getClass().getName()); - } - - if (isUnfiltered(testNodeRef)) - { - continue; - } - - int readCheck = childReadChek; - if (cad.parent) - { - readCheck = parentReadCheck; - } - - if (incudedSet.get(i) && (testNodeRef != null) && (readCheck != AccessDecisionVoter.ACCESS_GRANTED)) - { - incudedSet.set(i, false); - } - - } - } - - if (incudedSet.cardinality() == returnedObject.length) - { - return returnedObject; - } - else - { - Object[] answer = new Object[incudedSet.cardinality()]; - for (int i = incudedSet.nextSetBit(0), p = 0; i >= 0; i = incudedSet.nextSetBit(++i), p++) - { - answer[p] = returnedObject[i]; - } - return answer; - } - } - - private NodeRef getParentReadCheckNode(Object current) - { - NodeRef testNodeRef = null; - if (StoreRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = null; - } - else if (NodeRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = nodeService.getPrimaryParent((NodeRef) current).getParentRef(); - } - else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((ChildAssociationRef) current).getParentRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) - { - NodeRef nodeRef = ((PermissionCheckValue) current).getNodeRef(); - testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - } - else - { - throw new ACLEntryVoterException("The specified array is not of NodeRef or ChildAssociationRef"); - } - return testNodeRef; - } - - private NodeRef getChildReadCheckNode(Object current) - { - NodeRef testNodeRef = null; - if (StoreRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = nodeService.getRootNode((StoreRef) current); - } - else if (NodeRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = (NodeRef) current; - } - else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((ChildAssociationRef) current).getChildRef(); - } - else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) - { - testNodeRef = ((PermissionCheckValue) current).getNodeRef(); - } - else - { - throw new ACLEntryVoterException("The specified array is not of NodeRef or ChildAssociationRef"); - } - return testNodeRef; - } - - private class ConfigAttributeDefintion - { - - String typeString; - - String mode; - - boolean parent = false; - - ConfigAttributeDefintion(ConfigAttribute attr) - { - - StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false); - typeString = st.nextToken(); - if (!(typeString.equals(AFTER_RM))) - { - throw new ACLEntryVoterException("Invalid type: must be AFTER_RM"); - } - mode = st.nextToken(); - - if (st.hasMoreElements()) - { - parent = true; - } - } - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; + +import net.sf.acegisecurity.AccessDeniedException; +import net.sf.acegisecurity.Authentication; +import net.sf.acegisecurity.ConfigAttribute; +import net.sf.acegisecurity.ConfigAttributeDefinition; +import net.sf.acegisecurity.afterinvocation.AfterInvocationProvider; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.search.SimpleResultSetMetaData; +import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet; +import org.alfresco.repo.search.impl.querymodel.QueryEngineResults; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.permissions.PermissionCheckCollection; +import org.alfresco.repo.security.permissions.PermissionCheckValue; +import org.alfresco.repo.security.permissions.PermissionCheckedCollection.PermissionCheckedCollectionMixin; +import org.alfresco.repo.security.permissions.PermissionCheckedValue; +import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; +import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.LimitBy; +import org.alfresco.service.cmr.search.PermissionEvaluationMode; +import org.alfresco.service.cmr.search.ResultSet; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; + +/** + * RM After Invocation Provider + */ +@SuppressWarnings("unused") +public class RMAfterInvocationProvider extends RMSecurityCommon + implements AfterInvocationProvider, InitializingBean +{ + private static Log logger = LogFactory.getLog(RMAfterInvocationProvider.class); + + private static final String AFTER_RM = "AFTER_RM"; + + private int maxPermissionChecks; + + private long maxPermissionCheckTimeMillis; + + public boolean supports(ConfigAttribute configAttribute) + { + String attribute = configAttribute.getAttribute(); + return (StringUtils.isNotBlank(attribute) && attribute.startsWith(AFTER_RM)); + } + + @SuppressWarnings("rawtypes") + public boolean supports(Class clazz) + { + return (MethodInvocation.class.isAssignableFrom(clazz)); + } + + public void afterPropertiesSet() + { + } + + /** + * Default constructor + */ + public RMAfterInvocationProvider() + { + super(); + maxPermissionChecks = Integer.MAX_VALUE; + maxPermissionCheckTimeMillis = Long.MAX_VALUE; + } + + /** + * Set the max number of permission checks + * + * @param maxPermissionChecks + */ + public void setMaxPermissionChecks(int maxPermissionChecks) + { + this.maxPermissionChecks = maxPermissionChecks; + } + + /** + * Set the max time for permission checks + * + * @param maxPermissionCheckTimeMillis + */ + public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis) + { + this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis; + } + + @SuppressWarnings("rawtypes") + public Object decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object returnedObject) + { + if (logger.isDebugEnabled()) + { + MethodInvocation mi = (MethodInvocation) object; + if (mi == null) + { + logger.debug("Method is null."); + } + else + { + logger.debug("Method: " + mi.getMethod().toString()); + } + } + try + { + if (AuthenticationUtil.isRunAsUserTheSystemUser()) + { + if (logger.isDebugEnabled()) + { + logger.debug("Allowing system user access"); + } + return returnedObject; + } + else if (returnedObject == null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Allowing null object access"); + } + return null; + } + else if (PermissionCheckedValue.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (PermissionCheckedValue) returnedObject); + } + else if (PermissionCheckValue.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (PermissionCheckValue) returnedObject); + } + else if (StoreRef.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, nodeService.getRootNode((StoreRef) returnedObject)).getStoreRef(); + } + else if (NodeRef.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (NodeRef) returnedObject); + } + else if (ChildAssociationRef.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (ChildAssociationRef) returnedObject); + } + else if (AssociationRef.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (AssociationRef) returnedObject); + } + else if (ResultSet.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (ResultSet) returnedObject); + } + else if (PagingLuceneResultSet.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (PagingLuceneResultSet) returnedObject); + } + else if (QueryEngineResults.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (QueryEngineResults) returnedObject); + } + else if (Collection.class.isAssignableFrom(returnedObject.getClass())) + { + return decide(authentication, object, config, (Collection) returnedObject); + } + else if (returnedObject.getClass().isArray()) + { + return decide(authentication, object, config, (Object[]) returnedObject); + } + else + { + if (logger.isDebugEnabled()) + { + logger.debug("Uncontrolled object - access allowed for " + object.getClass().getName()); + } + return returnedObject; + } + } + catch (AccessDeniedException ade) + { + if (logger.isDebugEnabled()) + { + logger.debug("Access denied: " + ade.getMessage()); + } + throw ade; + } + catch (RuntimeException re) + { + if (logger.isDebugEnabled()) + { + logger.debug("Access denied by runtime exception: " + re.getMessage()); + } + throw re; + } + + } + + private PermissionCheckedValue decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PermissionCheckedValue returnedObject) + { + // This passes as it has already been filtered + // TODO: Get the filter that was applied and double-check + return returnedObject; + } + + private PermissionCheckValue decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PermissionCheckValue returnedObject) + { + // Get the wrapped value + NodeRef nodeRef = returnedObject.getNodeRef(); + decide(authentication, object, config, nodeRef); + // This passes + return returnedObject; + } + + private NodeRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, NodeRef returnedObject) + { + if (returnedObject == null) + { + return null; + } + + if (isUnfiltered(returnedObject)) + { + return returnedObject; + } + + List supportedDefinitions = extractSupportedDefinitions(config); + if (supportedDefinitions.size() == 0) + { + return returnedObject; + } + + int parentResult = checkRead(nodeService.getPrimaryParent(returnedObject).getParentRef()); + int childResult = checkRead(returnedObject); + checkSupportedDefinitions(supportedDefinitions, parentResult, childResult); + + return returnedObject; + } + + private void checkSupportedDefinitions(List supportedDefinitions, int parentResult, int childResult) + { + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + if (cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED) + { + throw new AccessDeniedException("Access Denied"); + } + else if (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED) + { + throw new AccessDeniedException("Access Denied"); + } + } + } + + private boolean isUnfiltered(NodeRef nodeRef) + { + return !nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + + } + + @SuppressWarnings("rawtypes") + private List extractSupportedDefinitions(ConfigAttributeDefinition config) + { + List definitions = new ArrayList<>(); + Iterator iter = config.getConfigAttributes(); + + while (iter.hasNext()) + { + ConfigAttribute attr = (ConfigAttribute) iter.next(); + + if (this.supports(attr)) + { + definitions.add(new ConfigAttributeDefintion(attr)); + } + + } + return definitions; + } + + private ChildAssociationRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ChildAssociationRef returnedObject) + { + if (returnedObject == null) + { + return null; + } + + List supportedDefinitions = extractSupportedDefinitions(config); + + if (supportedDefinitions.size() == 0) + { + return returnedObject; + } + + int parentReadCheck = checkRead(returnedObject.getParentRef()); + int childReadCheck = checkRead(returnedObject.getChildRef()); + + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + NodeRef testNodeRef = null; + + if (cad.parent) + { + testNodeRef = returnedObject.getParentRef(); + } + else + { + testNodeRef = returnedObject.getChildRef(); + } + + // Enforce Read Policy + + if (isUnfiltered(testNodeRef)) + { + continue; + } + + if (cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED) + { + throw new AccessDeniedException("Access Denied"); + } + else if (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED) + { + throw new AccessDeniedException("Access Denied"); + } + } + + return returnedObject; + } + + private AssociationRef decide(Authentication authentication, Object object, ConfigAttributeDefinition config, AssociationRef returnedObject) + { + if (returnedObject == null) + { + return null; + } + + List supportedDefinitions = extractSupportedDefinitions(config); + + if (supportedDefinitions.size() == 0) + { + return returnedObject; + } + + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + NodeRef testNodeRef = null; + + if (cad.parent) + { + testNodeRef = returnedObject.getSourceRef(); + } + else + { + testNodeRef = returnedObject.getTargetRef(); + } + + if (isUnfiltered(testNodeRef)) + { + continue; + } + + if (checkRead(testNodeRef) != AccessDecisionVoter.ACCESS_GRANTED) + { + throw new AccessDeniedException("Access Denied"); + } + + } + + return returnedObject; + } + + private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PagingLuceneResultSet returnedObject) + { + ResultSet raw = returnedObject.getWrapped(); + ResultSet filteredForPermissions = decide(authentication, object, config, raw); + return new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService); + } + + private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ResultSet returnedObject) + { + if (returnedObject == null) + { + return null; + } + + class RMFilteringResultSet extends FilteringResultSet + { + private long numberFound; + + public RMFilteringResultSet(ResultSet unfiltered, BitSet inclusionMask) + { + super(unfiltered, inclusionMask); + } + + @Override + public long getNumberFound() + { + return numberFound; + } + + private void setNumberFound(long numberFound) + { + this.numberFound = numberFound; + } + } + + BitSet inclusionMask = new BitSet(returnedObject.length()); + RMFilteringResultSet filteringResultSet = new RMFilteringResultSet(returnedObject, inclusionMask); + + List supportedDefinitions = extractSupportedDefinitions(config); + + Integer maxSize = null; + if (returnedObject.getResultSetMetaData().getSearchParameters().getMaxItems() >= 0) + { + maxSize = Integer.valueOf(returnedObject.getResultSetMetaData().getSearchParameters().getMaxItems()); + } + if ((maxSize == null) && (returnedObject.getResultSetMetaData().getSearchParameters().getLimitBy() == LimitBy.FINAL_SIZE)) + { + maxSize = Integer.valueOf(returnedObject.getResultSetMetaData().getSearchParameters().getLimit()); + } + // Allow for skip + if ((maxSize != null) && (returnedObject.getResultSetMetaData().getSearchParameters().getSkipCount() >= 0)) + { + maxSize = Integer.valueOf(maxSize + returnedObject.getResultSetMetaData().getSearchParameters().getSkipCount()); + } + + if (supportedDefinitions.size() == 0) + { + if (maxSize == null) + { + return returnedObject; + } + else if (returnedObject.length() > maxSize.intValue()) + { + for (int i = 0; i < maxSize.intValue(); i++) + { + inclusionMask.set(i, true); + } + filteringResultSet.setResultSetMetaData( + new SimpleResultSetMetaData( + returnedObject.getResultSetMetaData().getLimitedBy(), + PermissionEvaluationMode.EAGER, + returnedObject.getResultSetMetaData().getSearchParameters())); + return filteringResultSet; + } + else + { + for (int i = 0; i < returnedObject.length(); i++) + { + inclusionMask.set(i, true); + } + filteringResultSet.setResultSetMetaData( + new SimpleResultSetMetaData( + returnedObject.getResultSetMetaData().getLimitedBy(), + PermissionEvaluationMode.EAGER, + returnedObject.getResultSetMetaData().getSearchParameters())); + return filteringResultSet; + } + } + + // record the start time + long startTimeMillis = System.currentTimeMillis(); + + // set the default, unlimited resultset type + filteringResultSet.setResultSetMetaData( + new SimpleResultSetMetaData( + returnedObject.getResultSetMetaData().getLimitedBy(), + PermissionEvaluationMode.EAGER, + returnedObject.getResultSetMetaData().getSearchParameters())); + + for (int i = 0; i < returnedObject.length(); i++) + { + long currentTimeMillis = System.currentTimeMillis(); + + // All permission checks must pass + inclusionMask.set(i, true); + + if (!nodeService.exists(returnedObject.getNodeRef(i))) + { + inclusionMask.set(i, false); + } + else + { + int parentCheckRead = checkRead(returnedObject.getChildAssocRef(i).getParentRef()); + int childCheckRead = checkRead(returnedObject.getNodeRef(i)); + + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + NodeRef testNodeRef = returnedObject.getNodeRef(i); + int checkRead = childCheckRead; + if (cad.parent) + { + testNodeRef = returnedObject.getChildAssocRef(i).getParentRef(); + checkRead = parentCheckRead; + } + + if (isUnfiltered(testNodeRef)) + { + continue; + } + + if (inclusionMask.get(i) && (testNodeRef != null) && (checkRead != AccessDecisionVoter.ACCESS_GRANTED)) + { + inclusionMask.set(i, false); + } + } + } + + // Bug out if we are limiting by size + if ((maxSize != null) && (filteringResultSet.length() > maxSize.intValue())) + { + // Remove the last match to fix the correct size + inclusionMask.set(i, false); + filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.FINAL_SIZE, PermissionEvaluationMode.EAGER, returnedObject.getResultSetMetaData() + .getSearchParameters())); + break; + } + } + + filteringResultSet.setNumberFound(returnedObject.getNumberFound()); + + return filteringResultSet; + } + + private QueryEngineResults decide(Authentication authentication, Object object, ConfigAttributeDefinition config, QueryEngineResults returnedObject) + { + Map, ResultSet> map = returnedObject.getResults(); + Map, ResultSet> answer = new HashMap, ResultSet>(map.size(), 1.0f); + + for (Map.Entry, ResultSet> entry : map.entrySet()) + { + ResultSet raw = entry.getValue(); + ResultSet permed; + if (PagingLuceneResultSet.class.isAssignableFrom(raw.getClass())) + { + permed = decide(authentication, object, config, (PagingLuceneResultSet) raw); + } + else + { + permed = decide(authentication, object, config, raw); + } + answer.put(entry.getKey(), permed); + } + + return new QueryEngineResults(answer); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private Collection decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Collection returnedObject) + { + if (returnedObject == null) + { + return null; + } + + List supportedDefinitions = extractSupportedDefinitions(config); + if (logger.isDebugEnabled()) + { + logger.debug("Entries are " + supportedDefinitions); + } + + if (supportedDefinitions.size() == 0) + { + return returnedObject; + } + + // Default to the system-wide values and we'll see if they need to be reduced + long targetResultCount = returnedObject.size(); + int maxPermissionChecks = Integer.MAX_VALUE; + long maxPermissionCheckTimeMillis = this.maxPermissionCheckTimeMillis; + if (returnedObject instanceof PermissionCheckCollection) + { + PermissionCheckCollection permissionCheckCollection = (PermissionCheckCollection) returnedObject; + // Get values + targetResultCount = permissionCheckCollection.getTargetResultCount(); + if (permissionCheckCollection.getCutOffAfterCount() > 0) + { + maxPermissionChecks = permissionCheckCollection.getCutOffAfterCount(); + } + if (permissionCheckCollection.getCutOffAfterTimeMs() > 0) + { + maxPermissionCheckTimeMillis = permissionCheckCollection.getCutOffAfterTimeMs(); + } + } + + // Start timer and counter for cut-off + boolean cutoff = false; + long startTimeMillis = System.currentTimeMillis(); + int count = 0; + + // Keep values explicitly + List keepValues = new ArrayList(returnedObject.size()); + + for (Object nextObject : returnedObject) + { + // if the maximum result size or time has been exceeded, then we have to remove only + long currentTimeMillis = System.currentTimeMillis(); + + // NOTE: for reference - the "maxPermissionChecks" has never been honoured by this loop (since previously the count was not being incremented) + if (count >= targetResultCount) + { + // We have enough results. We stop without cutoff. + break; + } + else if (count >= maxPermissionChecks) + { + // We have been cut off by count + cutoff = true; + if (logger.isDebugEnabled()) + { + logger.debug("decide (collection) cut-off: " + count + " checks exceeded " + maxPermissionChecks + " checks"); + } + break; + } + else if ((currentTimeMillis - startTimeMillis) > maxPermissionCheckTimeMillis) + { + // We have been cut off by time + cutoff = true; + if (logger.isDebugEnabled()) + { + logger.debug("decide (collection) cut-off: " + (currentTimeMillis - startTimeMillis) + "ms exceeded " + maxPermissionCheckTimeMillis + "ms"); + } + break; + } + + boolean allowed = true; + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + if (cad.mode.equalsIgnoreCase("FilterNode")) + { + NodeRef testNodeRef = null; + if (cad.parent) + { + if (StoreRef.class.isAssignableFrom(nextObject.getClass())) + { + // Will be allowed + testNodeRef = null; + } + else if (NodeRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = nodeService.getPrimaryParent((NodeRef) nextObject).getParentRef(); + } + else if (ChildAssociationRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = ((ChildAssociationRef) nextObject).getParentRef(); + } + else if (AssociationRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = ((AssociationRef) nextObject).getSourceRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(nextObject.getClass())) + { + NodeRef nodeRef = ((PermissionCheckValue) nextObject).getNodeRef(); + testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); + } + else + { + throw new ACLEntryVoterException("The specified parameter is recognized: " + nextObject.getClass()); + } + } + else + { + if (StoreRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = nodeService.getRootNode((StoreRef) nextObject); + } + else if (NodeRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = (NodeRef) nextObject; + } + else if (ChildAssociationRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = ((ChildAssociationRef) nextObject).getChildRef(); + } + else if (AssociationRef.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = ((AssociationRef) nextObject).getTargetRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(nextObject.getClass())) + { + testNodeRef = ((PermissionCheckValue) nextObject).getNodeRef(); + } + else + { + throw new ACLEntryVoterException("The specified parameter is recognized: " + nextObject.getClass()); + } + } + + if (logger.isDebugEnabled()) + { + logger.debug("\t" + cad.typeString + " test on " + testNodeRef + " from " + nextObject.getClass().getName()); + } + + // Null allows + if (isUnfiltered(testNodeRef)) + { + // Continue to next ConfigAttributeDefintion + continue; + } + + if (allowed && + testNodeRef != null && + checkRead(testNodeRef) != AccessDecisionVoter.ACCESS_GRANTED) + { + allowed = false; + // No point evaluating more ConfigAttributeDefintions + break; + } + } + } + + // Failure or success, increase the count + count++; + + if (allowed) + { + keepValues.add(nextObject); + } + } + // Work out how many were left unchecked (for whatever reason) + int sizeOriginal = returnedObject.size(); + int checksRemaining = sizeOriginal - count; + // Note: There are use-cases where unmodifiable collections are passing through. + // So make sure that the collection needs modification at all + if (keepValues.size() < sizeOriginal) + { + // There are values that need to be removed. We have to modify the collection. + try + { + returnedObject.clear(); + returnedObject.addAll(keepValues); + } + catch (UnsupportedOperationException e) + { + throw new AccessDeniedException("Permission-checked list must be modifiable", e); + } + } + + // Attach the extra permission-check data to the collection + return PermissionCheckedCollectionMixin.create(returnedObject, cutoff, checksRemaining, sizeOriginal); + } + + private Object[] decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object[] returnedObject) + { + // Assumption: value is not null + BitSet incudedSet = new BitSet(returnedObject.length); + + List supportedDefinitions = extractSupportedDefinitions(config); + + if (supportedDefinitions.size() == 0) + { + return returnedObject; + } + + for (int i = 0, l = returnedObject.length; i < l; i++) + { + Object current = returnedObject[i]; + + int parentReadCheck = checkRead(getParentReadCheckNode(current)); + int childReadChek = checkRead(getChildReadCheckNode(current)); + + for (ConfigAttributeDefintion cad : supportedDefinitions) + { + incudedSet.set(i, true); + NodeRef testNodeRef = null; + if (cad.parent) + { + if (StoreRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = null; + } + else if (NodeRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = nodeService.getPrimaryParent((NodeRef) current).getParentRef(); + } + else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((ChildAssociationRef) current).getParentRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) + { + NodeRef nodeRef = ((PermissionCheckValue) current).getNodeRef(); + testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); + } + else + { + throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass()); + } + } + else + { + if (StoreRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = nodeService.getRootNode((StoreRef) current); + } + else if (NodeRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = (NodeRef) current; + } + else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((ChildAssociationRef) current).getChildRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((PermissionCheckValue) current).getNodeRef(); + } + else + { + throw new ACLEntryVoterException("The specified parameter is recognized: " + current.getClass()); + } + } + + if (logger.isDebugEnabled()) + { + logger.debug("\t" + cad.typeString + " test on " + testNodeRef + " from " + current.getClass().getName()); + } + + if (isUnfiltered(testNodeRef)) + { + continue; + } + + int readCheck = childReadChek; + if (cad.parent) + { + readCheck = parentReadCheck; + } + + if (incudedSet.get(i) && (testNodeRef != null) && (readCheck != AccessDecisionVoter.ACCESS_GRANTED)) + { + incudedSet.set(i, false); + } + + } + } + + if (incudedSet.cardinality() == returnedObject.length) + { + return returnedObject; + } + else + { + Object[] answer = new Object[incudedSet.cardinality()]; + for (int i = incudedSet.nextSetBit(0), p = 0; i >= 0; i = incudedSet.nextSetBit(++i), p++) + { + answer[p] = returnedObject[i]; + } + return answer; + } + } + + private NodeRef getParentReadCheckNode(Object current) + { + NodeRef testNodeRef = null; + if (StoreRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = null; + } + else if (NodeRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = nodeService.getPrimaryParent((NodeRef) current).getParentRef(); + } + else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((ChildAssociationRef) current).getParentRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) + { + NodeRef nodeRef = ((PermissionCheckValue) current).getNodeRef(); + testNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); + } + else + { + throw new ACLEntryVoterException("The specified array is not of NodeRef or ChildAssociationRef"); + } + return testNodeRef; + } + + private NodeRef getChildReadCheckNode(Object current) + { + NodeRef testNodeRef = null; + if (StoreRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = nodeService.getRootNode((StoreRef) current); + } + else if (NodeRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = (NodeRef) current; + } + else if (ChildAssociationRef.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((ChildAssociationRef) current).getChildRef(); + } + else if (PermissionCheckValue.class.isAssignableFrom(current.getClass())) + { + testNodeRef = ((PermissionCheckValue) current).getNodeRef(); + } + else + { + throw new ACLEntryVoterException("The specified array is not of NodeRef or ChildAssociationRef"); + } + return testNodeRef; + } + + private class ConfigAttributeDefintion + { + + String typeString; + + String mode; + + boolean parent = false; + + ConfigAttributeDefintion(ConfigAttribute attr) + { + + StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false); + typeString = st.nextToken(); + if (!(typeString.equals(AFTER_RM))) + { + throw new ACLEntryVoterException("Invalid type: must be AFTER_RM"); + } + mode = st.nextToken(); + + if (st.hasMoreElements()) + { + parent = true; + } + } + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java index a1684e100d..a0df0e5265 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java @@ -1,404 +1,404 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.sf.acegisecurity.Authentication; -import net.sf.acegisecurity.ConfigAttribute; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition; -import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; -import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; -import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * Records managment entry voter. - * - * @author Roy Wetherall, Andy Hind - */ -public class RMEntryVoter extends RMSecurityCommon - implements AccessDecisionVoter, InitializingBean, PolicyRegister -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RMEntryVoter.class); - - /** Namespace resolver */ - private NamespacePrefixResolver nspr; - - /** Capability Service */ - private CapabilityService capabilityService; - - /** Transactional Resource Helper */ - private TransactionalResourceHelper transactionalResourceHelper; - - /** Alfresco transaction support */ - private AlfrescoTransactionSupport alfrescoTransactionSupport; - - /** authentication util */ - private AuthenticationUtil authenticationUtil; - - /** Policy map */ - private Map policies = new HashMap(); - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param nspr namespace prefix resolver - */ - public void setNamespacePrefixResolver(NamespacePrefixResolver nspr) - { - this.nspr = nspr; - } - - /** - * @param transactionalResourceHelper transactional resource helper - */ - public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) - { - this.transactionalResourceHelper = transactionalResourceHelper; - } - - /** - * @param alfrescoTransactionSupport alfresco transaction support helper - */ - public void setAlfrescoTransactionSupport(AlfrescoTransactionSupport alfrescoTransactionSupport) - { - this.alfrescoTransactionSupport = alfrescoTransactionSupport; - } - - /** - * @param authenticationUtil authentication util - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * Register a policy the voter - * - * @param policy policy - */ - public void registerPolicy(Policy policy) - { - policies.put(policy.getName(), policy); - } - - /** - * @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(net.sf.acegisecurity.ConfigAttribute) - */ - @Override - public boolean supports(ConfigAttribute configAttribute) - { - boolean supports = false; - String attribute = configAttribute.getAttribute(); - if (StringUtils.isNotBlank(attribute) && - (attribute.equals(ConfigAttributeDefinition.RM_ABSTAIN) || - attribute.equals(ConfigAttributeDefinition.RM_QUERY) || - attribute.equals(ConfigAttributeDefinition.RM_ALLOW) || - attribute.equals(ConfigAttributeDefinition.RM_DENY) || - attribute.startsWith(ConfigAttributeDefinition.RM_CAP) || - attribute.startsWith(ConfigAttributeDefinition.RM))) - { - supports = true; - } - return supports; - } - - /** - * @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(java.lang.Class) - */ - @SuppressWarnings("rawtypes") - public boolean supports(Class clazz) - { - return (MethodInvocation.class.isAssignableFrom(clazz)); - } - - /** - * @see net.sf.acegisecurity.vote.AccessDecisionVoter#vote(net.sf.acegisecurity.Authentication, java.lang.Object, net.sf.acegisecurity.ConfigAttributeDefinition) - */ - @SuppressWarnings("rawtypes") - public int vote(Authentication authentication, Object object, net.sf.acegisecurity.ConfigAttributeDefinition config) - { - // logging - RMMethodSecurityInterceptor.isRMSecurityChecked(true); - - MethodInvocation mi = (MethodInvocation)object; - - if (transactionalResourceHelper.isResourcePresent("voting")) - { - if (logger.isDebugEnabled()) - { - logger.debug(" .. grant access already voting: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName()); - } - return AccessDecisionVoter.ACCESS_GRANTED; - } - - if (logger.isDebugEnabled()) - { - logger.debug("Method: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName()); - } - - alfrescoTransactionSupport.bindResource("voting", true); - try - { - // The system user can do anything - if (authenticationUtil.isRunAsUserTheSystemUser()) - { - if (logger.isDebugEnabled()) - { - logger.debug("Access granted for the system user"); - } - return AccessDecisionVoter.ACCESS_GRANTED; - } - - List supportedDefinitions = extractSupportedDefinitions(config); - - // No RM definitions so we do not vote - if (supportedDefinitions.size() == 0) - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - - // check we have an instance of a method invocation - if (!(object instanceof MethodInvocation)) - { - // we expect a method invocation - throw new AlfrescoRuntimeException("Passed object is not an instance of MethodInvocation as expected."); - } - - // get information about the method - MethodInvocation invocation = (MethodInvocation) object; - Method method = invocation.getMethod(); - Class[] params = method.getParameterTypes(); - - // If there are only capability (RM_CAP) and policy (RM) entries non must deny - // If any abstain we deny - // All present must vote to allow unless an explicit direction comes first (e.g. RM_ALLOW) - - for (ConfigAttributeDefinition cad : supportedDefinitions) - { - // Whatever is found first takes precedence - if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_DENY)) - { - // log message - RMMethodSecurityInterceptor.addMessage("RM_DENY: check that a security policy has been set for this method"); - - return AccessDecisionVoter.ACCESS_DENIED; - } - else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ABSTAIN)) - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ALLOW)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - // RM_QUERY is a special case - the entry is allowed and filtering sorts out the results - // It is distinguished from RM_ALLOW so query may have additional behaviour in the future - else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_QUERY)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - // Ignore config that references method arguments that do not exist - // Arguably we should deny here but that requires a full impact analysis - // These entries effectively abstain - else if (((cad.getParameters().get(0) != null) && (cad.getParameters().get(0) >= invocation.getArguments().length)) || - ((cad.getParameters().get(1) != null) && (cad.getParameters().get(1) >= invocation.getArguments().length))) - { - continue; - } - else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_CAP)) - { - switch(checkCapability(invocation, params, cad)) - { - case AccessDecisionVoter.ACCESS_DENIED: - { - return AccessDecisionVoter.ACCESS_DENIED; - } - case AccessDecisionVoter.ACCESS_ABSTAIN: - { - if(logger.isDebugEnabled()) - { - if(logger.isTraceEnabled()) - { - logger.trace("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod(), new IllegalStateException()); - } - else - { - logger.debug("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod()); - } - } - // abstain denies - return AccessDecisionVoter.ACCESS_DENIED; - } - case AccessDecisionVoter.ACCESS_GRANTED: - { - break; - } - } - } - else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM)) - { - switch(checkPolicy(invocation, params, cad)) - { - case AccessDecisionVoter.ACCESS_DENIED: - { - // log message - RMMethodSecurityInterceptor.addMessage("Policy " + cad.getPolicyName() + " denied."); - - return AccessDecisionVoter.ACCESS_DENIED; - } - case AccessDecisionVoter.ACCESS_ABSTAIN: - { - if(logger.isDebugEnabled()) - { - if(logger.isTraceEnabled()) - { - logger.trace("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod(), new IllegalStateException()); - } - else - { - logger.debug("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod()); - } - } - // abstain denies - return AccessDecisionVoter.ACCESS_DENIED; - } - case AccessDecisionVoter.ACCESS_GRANTED: - { - break; - } - } - } - } - } - finally - { - alfrescoTransactionSupport.unbindResource("voting"); - } - - // all voted to allow - return AccessDecisionVoter.ACCESS_GRANTED; - } - - /** - * Check the capability - * - * @param invocation method invocation - * @param params parameters - * @param cad config definition - * @return int evaluation result - */ - @SuppressWarnings("rawtypes") - private int checkCapability(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad) - { - NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - if (testNodeRef == null) - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - Capability capability = capabilityService.getCapability(cad.getRequired().getName()); - if (capability == null) - { - throw new AlfrescoRuntimeException("The capability '" + cad.getRequired().getName() + "' set on method '" + invocation.getMethod().getName() + "' does not exist."); - } - return capability.hasPermissionRaw(testNodeRef); - - } - - /** - * Evaluate policy to determine access - * - * @param invocation invocation information - * @param params parameters - * @param cad configuration attribute definition - * @return int policy evaluation - */ - @SuppressWarnings("rawtypes") - private int checkPolicy(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad) - { - // try to get the policy - Policy policy = policies.get(cad.getPolicyName()); - if (policy == null) - { - // throw an exception if the policy is invalid - throw new AlfrescoRuntimeException("The policy '" + cad.getPolicyName() + "' set on the method '" + invocation.getMethod().getName() + "' does not exist."); - } - else - { - // evaluate the policy - return policy.evaluate(invocation, params, cad); - } - } - - /** - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() - { - } - - /** - * - * @param config - * @return - */ - @SuppressWarnings("rawtypes") - private List extractSupportedDefinitions(net.sf.acegisecurity.ConfigAttributeDefinition config) - { - List definitions = new ArrayList(2); - Iterator iter = config.getConfigAttributes(); - - while (iter.hasNext()) - { - ConfigAttribute attr = (ConfigAttribute) iter.next(); - - if (this.supports(attr)) - { - definitions.add(new ConfigAttributeDefinition(attr, nspr)); - } - - } - return definitions; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.sf.acegisecurity.Authentication; +import net.sf.acegisecurity.ConfigAttribute; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition; +import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; +import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; +import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespacePrefixResolver; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; + +/** + * Records managment entry voter. + * + * @author Roy Wetherall, Andy Hind + */ +public class RMEntryVoter extends RMSecurityCommon + implements AccessDecisionVoter, InitializingBean, PolicyRegister +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RMEntryVoter.class); + + /** Namespace resolver */ + private NamespacePrefixResolver nspr; + + /** Capability Service */ + private CapabilityService capabilityService; + + /** Transactional Resource Helper */ + private TransactionalResourceHelper transactionalResourceHelper; + + /** Alfresco transaction support */ + private AlfrescoTransactionSupport alfrescoTransactionSupport; + + /** authentication util */ + private AuthenticationUtil authenticationUtil; + + /** Policy map */ + private Map policies = new HashMap(); + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param nspr namespace prefix resolver + */ + public void setNamespacePrefixResolver(NamespacePrefixResolver nspr) + { + this.nspr = nspr; + } + + /** + * @param transactionalResourceHelper transactional resource helper + */ + public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) + { + this.transactionalResourceHelper = transactionalResourceHelper; + } + + /** + * @param alfrescoTransactionSupport alfresco transaction support helper + */ + public void setAlfrescoTransactionSupport(AlfrescoTransactionSupport alfrescoTransactionSupport) + { + this.alfrescoTransactionSupport = alfrescoTransactionSupport; + } + + /** + * @param authenticationUtil authentication util + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * Register a policy the voter + * + * @param policy policy + */ + public void registerPolicy(Policy policy) + { + policies.put(policy.getName(), policy); + } + + /** + * @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(net.sf.acegisecurity.ConfigAttribute) + */ + @Override + public boolean supports(ConfigAttribute configAttribute) + { + boolean supports = false; + String attribute = configAttribute.getAttribute(); + if (StringUtils.isNotBlank(attribute) && + (attribute.equals(ConfigAttributeDefinition.RM_ABSTAIN) || + attribute.equals(ConfigAttributeDefinition.RM_QUERY) || + attribute.equals(ConfigAttributeDefinition.RM_ALLOW) || + attribute.equals(ConfigAttributeDefinition.RM_DENY) || + attribute.startsWith(ConfigAttributeDefinition.RM_CAP) || + attribute.startsWith(ConfigAttributeDefinition.RM))) + { + supports = true; + } + return supports; + } + + /** + * @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(java.lang.Class) + */ + @SuppressWarnings("rawtypes") + public boolean supports(Class clazz) + { + return (MethodInvocation.class.isAssignableFrom(clazz)); + } + + /** + * @see net.sf.acegisecurity.vote.AccessDecisionVoter#vote(net.sf.acegisecurity.Authentication, java.lang.Object, net.sf.acegisecurity.ConfigAttributeDefinition) + */ + @SuppressWarnings("rawtypes") + public int vote(Authentication authentication, Object object, net.sf.acegisecurity.ConfigAttributeDefinition config) + { + // logging + RMMethodSecurityInterceptor.isRMSecurityChecked(true); + + MethodInvocation mi = (MethodInvocation)object; + + if (transactionalResourceHelper.isResourcePresent("voting")) + { + if (logger.isDebugEnabled()) + { + logger.debug(" .. grant access already voting: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName()); + } + return AccessDecisionVoter.ACCESS_GRANTED; + } + + if (logger.isDebugEnabled()) + { + logger.debug("Method: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName()); + } + + alfrescoTransactionSupport.bindResource("voting", true); + try + { + // The system user can do anything + if (authenticationUtil.isRunAsUserTheSystemUser()) + { + if (logger.isDebugEnabled()) + { + logger.debug("Access granted for the system user"); + } + return AccessDecisionVoter.ACCESS_GRANTED; + } + + List supportedDefinitions = extractSupportedDefinitions(config); + + // No RM definitions so we do not vote + if (supportedDefinitions.size() == 0) + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + + // check we have an instance of a method invocation + if (!(object instanceof MethodInvocation)) + { + // we expect a method invocation + throw new AlfrescoRuntimeException("Passed object is not an instance of MethodInvocation as expected."); + } + + // get information about the method + MethodInvocation invocation = (MethodInvocation) object; + Method method = invocation.getMethod(); + Class[] params = method.getParameterTypes(); + + // If there are only capability (RM_CAP) and policy (RM) entries non must deny + // If any abstain we deny + // All present must vote to allow unless an explicit direction comes first (e.g. RM_ALLOW) + + for (ConfigAttributeDefinition cad : supportedDefinitions) + { + // Whatever is found first takes precedence + if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_DENY)) + { + // log message + RMMethodSecurityInterceptor.addMessage("RM_DENY: check that a security policy has been set for this method"); + + return AccessDecisionVoter.ACCESS_DENIED; + } + else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ABSTAIN)) + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ALLOW)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + // RM_QUERY is a special case - the entry is allowed and filtering sorts out the results + // It is distinguished from RM_ALLOW so query may have additional behaviour in the future + else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_QUERY)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + // Ignore config that references method arguments that do not exist + // Arguably we should deny here but that requires a full impact analysis + // These entries effectively abstain + else if (((cad.getParameters().get(0) != null) && (cad.getParameters().get(0) >= invocation.getArguments().length)) || + ((cad.getParameters().get(1) != null) && (cad.getParameters().get(1) >= invocation.getArguments().length))) + { + continue; + } + else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_CAP)) + { + switch(checkCapability(invocation, params, cad)) + { + case AccessDecisionVoter.ACCESS_DENIED: + { + return AccessDecisionVoter.ACCESS_DENIED; + } + case AccessDecisionVoter.ACCESS_ABSTAIN: + { + if(logger.isDebugEnabled()) + { + if(logger.isTraceEnabled()) + { + logger.trace("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod(), new IllegalStateException()); + } + else + { + logger.debug("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod()); + } + } + // abstain denies + return AccessDecisionVoter.ACCESS_DENIED; + } + case AccessDecisionVoter.ACCESS_GRANTED: + { + break; + } + } + } + else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM)) + { + switch(checkPolicy(invocation, params, cad)) + { + case AccessDecisionVoter.ACCESS_DENIED: + { + // log message + RMMethodSecurityInterceptor.addMessage("Policy " + cad.getPolicyName() + " denied."); + + return AccessDecisionVoter.ACCESS_DENIED; + } + case AccessDecisionVoter.ACCESS_ABSTAIN: + { + if(logger.isDebugEnabled()) + { + if(logger.isTraceEnabled()) + { + logger.trace("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod(), new IllegalStateException()); + } + else + { + logger.debug("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod()); + } + } + // abstain denies + return AccessDecisionVoter.ACCESS_DENIED; + } + case AccessDecisionVoter.ACCESS_GRANTED: + { + break; + } + } + } + } + } + finally + { + alfrescoTransactionSupport.unbindResource("voting"); + } + + // all voted to allow + return AccessDecisionVoter.ACCESS_GRANTED; + } + + /** + * Check the capability + * + * @param invocation method invocation + * @param params parameters + * @param cad config definition + * @return int evaluation result + */ + @SuppressWarnings("rawtypes") + private int checkCapability(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad) + { + NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + if (testNodeRef == null) + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + Capability capability = capabilityService.getCapability(cad.getRequired().getName()); + if (capability == null) + { + throw new AlfrescoRuntimeException("The capability '" + cad.getRequired().getName() + "' set on method '" + invocation.getMethod().getName() + "' does not exist."); + } + return capability.hasPermissionRaw(testNodeRef); + + } + + /** + * Evaluate policy to determine access + * + * @param invocation invocation information + * @param params parameters + * @param cad configuration attribute definition + * @return int policy evaluation + */ + @SuppressWarnings("rawtypes") + private int checkPolicy(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad) + { + // try to get the policy + Policy policy = policies.get(cad.getPolicyName()); + if (policy == null) + { + // throw an exception if the policy is invalid + throw new AlfrescoRuntimeException("The policy '" + cad.getPolicyName() + "' set on the method '" + invocation.getMethod().getName() + "' does not exist."); + } + else + { + // evaluate the policy + return policy.evaluate(invocation, params, cad); + } + } + + /** + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + public void afterPropertiesSet() + { + } + + /** + * + * @param config + * @return + */ + @SuppressWarnings("rawtypes") + private List extractSupportedDefinitions(net.sf.acegisecurity.ConfigAttributeDefinition config) + { + List definitions = new ArrayList(2); + Iterator iter = config.getConfigAttributes(); + + while (iter.hasNext()) + { + ConfigAttribute attr = (ConfigAttribute) iter.next(); + + if (this.supports(attr)) + { + definitions.add(new ConfigAttributeDefinition(attr, nspr)); + } + + } + return definitions; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java index 12d267d1b2..f0397f2b8c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java @@ -1,128 +1,128 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; - -/** - * Capability constants for the RM Permission Model - * - * @author andyh - */ -public interface RMPermissionModel -{ - // Assignment of Filing - String FILING = "Filing"; - String READ_RECORDS = "ReadRecords"; - String FILE_RECORDS = "FileRecords"; - - // Roles - /** - * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_USER} instead - */ - @Deprecated - String ROLE_NAME_USER = FilePlanRoleService.ROLE_USER; - /** - * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_POWER_USER} instead - */ - @Deprecated - String ROLE_NAME_POWER_USER = FilePlanRoleService.ROLE_POWER_USER; - /** - * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_SECURITY_OFFICER} instead - */ - @Deprecated - String ROLE_NAME_SECURITY_OFFICER = FilePlanRoleService.ROLE_SECURITY_OFFICER; - /** - * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_RECORDS_MANAGER} instead - */ - @Deprecated - String ROLE_NAME_RECORDS_MANAGER = FilePlanRoleService.ROLE_RECORDS_MANAGER; - /** - * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_ADMIN} instead - */ - @Deprecated - String ROLE_NAME_ADMINISTRATOR = FilePlanRoleService.ROLE_ADMIN; - String ROLE_ADMINISTRATOR = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, FilePlanRoleService.ROLE_ADMIN).toString(); - - // Capability permissions - String DECLARE_RECORDS = "DeclareRecords"; - String VIEW_RECORDS = "ViewRecords"; - String CREATE_RECORDS = "CreateRecords"; - String CREATE_MODIFY_DESTROY_FOLDERS = "CreateModifyDestroyFolders"; - String EDIT_RECORD_METADATA = "EditRecordMetadata"; - String EDIT_NON_RECORD_METADATA = "EditNonRecordMetadata"; - String ADD_MODIFY_EVENT_DATES = "AddModifyEventDates"; - String CLOSE_FOLDERS = "CloseFolders"; - String DECLARE_RECORDS_IN_CLOSED_FOLDERS = "DeclareRecordsInClosedFolders"; - String RE_OPEN_FOLDERS = "ReOpenFolders"; - String CYCLE_VITAL_RECORDS = "CycleVitalRecords"; - String PLANNING_REVIEW_CYCLES = "PlanningReviewCycles"; - String UPDATE_TRIGGER_DATES = "UpdateTriggerDates"; - String CREATE_MODIFY_DESTROY_EVENTS = "CreateModifyDestroyEvents"; - String MANAGE_ACCESS_RIGHTS = "ManageAccessRights"; - String MOVE_RECORDS = "MoveRecords"; - String CHANGE_OR_DELETE_REFERENCES = "ChangeOrDeleteReferences"; - String DELETE_LINKS = "DeleteLinks"; - String EDIT_DECLARED_RECORD_METADATA = "EditDeclaredRecordMetadata"; - String MANUALLY_CHANGE_DISPOSITION_DATES = "ManuallyChangeDispositionDates"; - String APPROVE_RECORDS_SCHEDULED_FOR_CUTOFF = "ApproveRecordsScheduledForCutoff"; - String CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS = "CreateModifyRecordsInCutoffFolders"; - String EXTEND_RETENTION_PERIOD_OR_FREEZE = "ExtendRetentionPeriodOrFreeze"; - String UNFREEZE = "Unfreeze"; - String VIEW_UPDATE_REASONS_FOR_FREEZE = "ViewUpdateReasonsForFreeze"; - String DESTROY_RECORDS_SCHEDULED_FOR_DESTRUCTION = "DestroyRecordsScheduledForDestruction"; - String DESTROY_RECORDS = "DestroyRecords"; - String UPDATE_VITAL_RECORD_CYCLE_INFORMATION = "UpdateVitalRecordCycleInformation"; - String UNDECLARE_RECORDS = "UndeclareRecords"; - String DECLARE_AUDIT_AS_RECORD = "DeclareAuditAsRecord"; - String DELETE_AUDIT = "DeleteAudit"; - String CREATE_MODIFY_DESTROY_TIMEFRAMES = "CreateModifyDestroyTimeframes"; - String AUTHORIZE_NOMINATED_TRANSFERS = "AuthorizeNominatedTransfers"; - String EDIT_SELECTION_LISTS = "EditSelectionLists"; - String AUTHORIZE_ALL_TRANSFERS = "AuthorizeAllTransfers"; - String CREATE_MODIFY_DESTROY_FILEPLAN_METADATA = "CreateModifyDestroyFileplanMetadata"; - String CREATE_AND_ASSOCIATE_SELECTION_LISTS = "CreateAndAssociateSelectionLists"; - String ATTACH_RULES_TO_METADATA_PROPERTIES = "AttachRulesToMetadataProperties"; - String CREATE_MODIFY_DESTROY_FILEPLAN_TYPES = "CreateModifyDestroyFileplanTypes"; - String CREATE_MODIFY_DESTROY_RECORD_TYPES = "CreateModifyDestroyRecordTypes"; - String MAKE_OPTIONAL_PARAMETERS_MANDATORY = "MakeOptionalParametersMandatory"; - String MAP_EMAIL_METADATA = "MapEmailMetadata"; - String DELETE_RECORDS = "DeleteRecords"; - String TRIGGER_AN_EVENT = "TriggerAnEvent"; - String CREATE_MODIFY_DESTROY_ROLES = "CreateModifyDestroyRoles"; - String CREATE_MODIFY_DESTROY_USERS_AND_GROUPS = "CreateModifyDestroyUsersAndGroups"; - String PASSWORD_CONTROL = "PasswordControl"; - String ENABLE_DISABLE_AUDIT_BY_TYPES = "EnableDisableAuditByTypes"; - String SELECT_AUDIT_METADATA = "SelectAuditMetadata"; - String DISPLAY_RIGHTS_REPORT = "DisplayRightsReport"; - String ACCESS_AUDIT = "AccessAudit"; - String EXPORT_AUDIT = "ExportAudit"; - String CREATE_MODIFY_DESTROY_REFERENCE_TYPES = "CreateModifyDestroyReferenceTypes"; - String UPDATE_CLASSIFICATION_DATES = "UpdateClassificationDates"; - String CREATE_MODIFY_DESTROY_CLASSIFICATION_GUIDES = "CreateModifyDestroyClassificationGuides"; - String UPGRADE_DOWNGRADE_AND_DECLASSIFY_RECORDS = "UpgradeDowngradeAndDeclassifyRecords"; - String UPDATE_EXEMPTION_CATEGORIES = "UpdateExemptionCategories"; - String MAP_CLASSIFICATION_GUIDE_METADATA = "MapClassificationGuideMetadata"; - String MANAGE_ACCESS_CONTROLS = "ManageAccessControls"; - String CREATE_HOLD = "CreateHold"; - String ADD_TO_HOLD = "AddToHold"; - String REMOVE_FROM_HOLD = "RemoveFromHold"; +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; + +/** + * Capability constants for the RM Permission Model + * + * @author andyh + */ +public interface RMPermissionModel +{ + // Assignment of Filing + String FILING = "Filing"; + String READ_RECORDS = "ReadRecords"; + String FILE_RECORDS = "FileRecords"; + + // Roles + /** + * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_USER} instead + */ + @Deprecated + String ROLE_NAME_USER = FilePlanRoleService.ROLE_USER; + /** + * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_POWER_USER} instead + */ + @Deprecated + String ROLE_NAME_POWER_USER = FilePlanRoleService.ROLE_POWER_USER; + /** + * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_SECURITY_OFFICER} instead + */ + @Deprecated + String ROLE_NAME_SECURITY_OFFICER = FilePlanRoleService.ROLE_SECURITY_OFFICER; + /** + * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_RECORDS_MANAGER} instead + */ + @Deprecated + String ROLE_NAME_RECORDS_MANAGER = FilePlanRoleService.ROLE_RECORDS_MANAGER; + /** + * @deprecated as of 2.1.0.3, please use {@link FilePlanRoleService.ROLE_ADMIN} instead + */ + @Deprecated + String ROLE_NAME_ADMINISTRATOR = FilePlanRoleService.ROLE_ADMIN; + String ROLE_ADMINISTRATOR = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, FilePlanRoleService.ROLE_ADMIN).toString(); + + // Capability permissions + String DECLARE_RECORDS = "DeclareRecords"; + String VIEW_RECORDS = "ViewRecords"; + String CREATE_RECORDS = "CreateRecords"; + String CREATE_MODIFY_DESTROY_FOLDERS = "CreateModifyDestroyFolders"; + String EDIT_RECORD_METADATA = "EditRecordMetadata"; + String EDIT_NON_RECORD_METADATA = "EditNonRecordMetadata"; + String ADD_MODIFY_EVENT_DATES = "AddModifyEventDates"; + String CLOSE_FOLDERS = "CloseFolders"; + String DECLARE_RECORDS_IN_CLOSED_FOLDERS = "DeclareRecordsInClosedFolders"; + String RE_OPEN_FOLDERS = "ReOpenFolders"; + String CYCLE_VITAL_RECORDS = "CycleVitalRecords"; + String PLANNING_REVIEW_CYCLES = "PlanningReviewCycles"; + String UPDATE_TRIGGER_DATES = "UpdateTriggerDates"; + String CREATE_MODIFY_DESTROY_EVENTS = "CreateModifyDestroyEvents"; + String MANAGE_ACCESS_RIGHTS = "ManageAccessRights"; + String MOVE_RECORDS = "MoveRecords"; + String CHANGE_OR_DELETE_REFERENCES = "ChangeOrDeleteReferences"; + String DELETE_LINKS = "DeleteLinks"; + String EDIT_DECLARED_RECORD_METADATA = "EditDeclaredRecordMetadata"; + String MANUALLY_CHANGE_DISPOSITION_DATES = "ManuallyChangeDispositionDates"; + String APPROVE_RECORDS_SCHEDULED_FOR_CUTOFF = "ApproveRecordsScheduledForCutoff"; + String CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS = "CreateModifyRecordsInCutoffFolders"; + String EXTEND_RETENTION_PERIOD_OR_FREEZE = "ExtendRetentionPeriodOrFreeze"; + String UNFREEZE = "Unfreeze"; + String VIEW_UPDATE_REASONS_FOR_FREEZE = "ViewUpdateReasonsForFreeze"; + String DESTROY_RECORDS_SCHEDULED_FOR_DESTRUCTION = "DestroyRecordsScheduledForDestruction"; + String DESTROY_RECORDS = "DestroyRecords"; + String UPDATE_VITAL_RECORD_CYCLE_INFORMATION = "UpdateVitalRecordCycleInformation"; + String UNDECLARE_RECORDS = "UndeclareRecords"; + String DECLARE_AUDIT_AS_RECORD = "DeclareAuditAsRecord"; + String DELETE_AUDIT = "DeleteAudit"; + String CREATE_MODIFY_DESTROY_TIMEFRAMES = "CreateModifyDestroyTimeframes"; + String AUTHORIZE_NOMINATED_TRANSFERS = "AuthorizeNominatedTransfers"; + String EDIT_SELECTION_LISTS = "EditSelectionLists"; + String AUTHORIZE_ALL_TRANSFERS = "AuthorizeAllTransfers"; + String CREATE_MODIFY_DESTROY_FILEPLAN_METADATA = "CreateModifyDestroyFileplanMetadata"; + String CREATE_AND_ASSOCIATE_SELECTION_LISTS = "CreateAndAssociateSelectionLists"; + String ATTACH_RULES_TO_METADATA_PROPERTIES = "AttachRulesToMetadataProperties"; + String CREATE_MODIFY_DESTROY_FILEPLAN_TYPES = "CreateModifyDestroyFileplanTypes"; + String CREATE_MODIFY_DESTROY_RECORD_TYPES = "CreateModifyDestroyRecordTypes"; + String MAKE_OPTIONAL_PARAMETERS_MANDATORY = "MakeOptionalParametersMandatory"; + String MAP_EMAIL_METADATA = "MapEmailMetadata"; + String DELETE_RECORDS = "DeleteRecords"; + String TRIGGER_AN_EVENT = "TriggerAnEvent"; + String CREATE_MODIFY_DESTROY_ROLES = "CreateModifyDestroyRoles"; + String CREATE_MODIFY_DESTROY_USERS_AND_GROUPS = "CreateModifyDestroyUsersAndGroups"; + String PASSWORD_CONTROL = "PasswordControl"; + String ENABLE_DISABLE_AUDIT_BY_TYPES = "EnableDisableAuditByTypes"; + String SELECT_AUDIT_METADATA = "SelectAuditMetadata"; + String DISPLAY_RIGHTS_REPORT = "DisplayRightsReport"; + String ACCESS_AUDIT = "AccessAudit"; + String EXPORT_AUDIT = "ExportAudit"; + String CREATE_MODIFY_DESTROY_REFERENCE_TYPES = "CreateModifyDestroyReferenceTypes"; + String UPDATE_CLASSIFICATION_DATES = "UpdateClassificationDates"; + String CREATE_MODIFY_DESTROY_CLASSIFICATION_GUIDES = "CreateModifyDestroyClassificationGuides"; + String UPGRADE_DOWNGRADE_AND_DECLASSIFY_RECORDS = "UpgradeDowngradeAndDeclassifyRecords"; + String UPDATE_EXEMPTION_CATEGORIES = "UpdateExemptionCategories"; + String MAP_CLASSIFICATION_GUIDE_METADATA = "MapClassificationGuideMetadata"; + String MANAGE_ACCESS_CONTROLS = "ManageAccessControls"; + String CREATE_HOLD = "CreateHold"; + String ADD_TO_HOLD = "AddToHold"; + String REMOVE_FROM_HOLD = "RemoveFromHold"; } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java index c97016896c..c44eb575bb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java @@ -1,396 +1,396 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import java.util.Map; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.util.Pair; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - - -/** - * Common security functions. - * - * TODO move methods to the appropriate services - * - * @author Roy Wetherall - * @since 2.0 - */ -public class RMSecurityCommon implements ApplicationContextAware -{ - /** No set value */ - protected static final int NOSET_VALUE = -100; - - /** Logger */ - private static Log logger = LogFactory.getLog(RMSecurityCommon.class); - - /** Services */ - //This is the internal NodeService -- no permission checks - protected NodeService nodeService; - protected PermissionService permissionService; - protected RMCaveatConfigComponent caveatConfigComponent; - private FilePlanService filePlanService; - - /** Application context */ - protected ApplicationContext applicationContext; - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - { - this.applicationContext = applicationContext; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param caveatConfigComponent caveat config service - */ - public void setCaveatConfigComponent(RMCaveatConfigComponent caveatConfigComponent) - { - this.caveatConfigComponent = caveatConfigComponent; - } - - /** - * @return FilePlanService file plan service - */ - protected FilePlanService getFilePlanService() - { - if (filePlanService == null) - { - filePlanService = (FilePlanService)applicationContext.getBean("filePlanService"); - } - return filePlanService; - } - - /** - * Sets a value into the transaction cache - * - * @param prefix - * @param nodeRef - * @param value - * @return - */ - protected int setTransactionCache(String prefix, NodeRef nodeRef, int value) - { - String user = AuthenticationUtil.getRunAsUser(); - AlfrescoTransactionSupport.bindResource(prefix + nodeRef.toString() + user, Integer.valueOf(value)); - return value; - } - - /** - * Gets a value from the transaction cache - * - * @param prefix - * @param nodeRef - * @return - */ - protected int getTransactionCache(String prefix, NodeRef nodeRef) - { - int result = NOSET_VALUE; - String user = AuthenticationUtil.getRunAsUser(); - Integer value = (Integer)AlfrescoTransactionSupport.getResource(prefix + nodeRef.toString() + user); - if (value != null) - { - result = value.intValue(); - } - return result; - } - - /** - * Check for RM read - * - * @param nodeRef - * @return - */ - public int checkRead(NodeRef nodeRef) - { - int result = AccessDecisionVoter.ACCESS_ABSTAIN; - if (nodeRef != null) - { - // now we know the node - we can abstain for certain types and aspects (eg, rm) - result = checkRead(nodeRef, false); - } - - return result; - } - - /** - * Check for RM read - * - * @param nodeRef - * @param allowDMRead - * @return - */ - public int checkRead(NodeRef nodeRef, boolean allowDMRead) - { - int result = AccessDecisionVoter.ACCESS_ABSTAIN; - - if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - result = checkRmRead(nodeRef); - } - else if (allowDMRead) - { - // Check DM read for copy etc - // DM does not grant - it can only deny - if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) - { - if (logger.isDebugEnabled()) - { - logger.debug("\t\tPermission is denied"); - Thread.dumpStack(); - } - result = AccessDecisionVoter.ACCESS_DENIED; - } - else - { - result = AccessDecisionVoter.ACCESS_GRANTED; - } - } - - return result; - } - - /** - * Core RM read check - * - * @param nodeRef node reference - * @return int see {@link AccessDecisionVoter} - */ - public int checkRmRead(NodeRef nodeRef) - { - int result = AccessDecisionVoter.ACCESS_ABSTAIN; - - Map, Integer> transactionCache = TransactionalResourceHelper.getMap("rm.security.checkRMRead"); - Pair key = new Pair(AuthenticationUtil.getRunAsUser(), nodeRef); - - if (transactionCache.containsKey(key)) - { - result = transactionCache.get(key); - } - else - { - if (permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS) == AccessStatus.DENIED) - { - if (logger.isDebugEnabled()) - { - logger.debug("\t\tUser does not have read record permission on node, access denied. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); - } - result = AccessDecisionVoter.ACCESS_DENIED; - } - else - { - // Get the file plan for the node - NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); - if (hasViewCapability(filePlan) == AccessStatus.DENIED) - { - if (logger.isDebugEnabled()) - { - logger.debug("\t\tUser does not have view records capability permission on node, access denied. (filePlan=" + filePlan.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); - } - result = AccessDecisionVoter.ACCESS_DENIED; - } - else if (!caveatConfigComponent.hasAccess(nodeRef)) - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - else - { - result = AccessDecisionVoter.ACCESS_GRANTED; - } - } - - // cache result - transactionCache.put(key, result); - } - - return result; - } - - /** - * Helper method to determine whether the current user has view capability on the file plan - * - * @param filePlan file plan - * @return {@link AccessStatus} - */ - private AccessStatus hasViewCapability(NodeRef filePlan) - { - Map, AccessStatus> transactionCache = TransactionalResourceHelper.getMap("rm.security.hasViewCapability"); - Pair key = new Pair(AuthenticationUtil.getRunAsUser(), filePlan); - - if (transactionCache.containsKey(key)) - { - return transactionCache.get(key); - } - else - { - AccessStatus result = permissionService.hasPermission(filePlan, ViewRecordsCapability.NAME); - transactionCache.put(key, result); - return result; - } - } - - @SuppressWarnings("rawtypes") - protected NodeRef getTestNode(MethodInvocation invocation, Class[] params, int position, boolean parent) - { - NodeRef testNodeRef = null; - if (position < 0) - { - if (logger.isDebugEnabled()) - { - logger.debug("\tNothing to test permission against."); - } - testNodeRef = null; - } - else if (StoreRef.class.isAssignableFrom(params[position])) - { - if (invocation.getArguments()[position] != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("\tPermission test against the store - using permissions on the root node"); - } - StoreRef storeRef = (StoreRef) invocation.getArguments()[position]; - if (nodeService.exists(storeRef)) - { - testNodeRef = nodeService.getRootNode(storeRef); - } - } - } - else if (NodeRef.class.isAssignableFrom(params[position])) - { - testNodeRef = (NodeRef) invocation.getArguments()[position]; - if (parent) - { - testNodeRef = nodeService.getPrimaryParent(testNodeRef).getParentRef(); - if (logger.isDebugEnabled()) - { - if (nodeService.exists(testNodeRef)) - { - logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef)); - } - else - { - logger.debug("\tPermission test for parent on non-existing node " + testNodeRef); - } - logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef)); - } - } - else - { - if (logger.isDebugEnabled()) - { - if (nodeService.exists(testNodeRef)) - { - logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); - } - else - { - logger.debug("\tPermission test on non-existing node " + testNodeRef); - } - } - } - } - else if (ChildAssociationRef.class.isAssignableFrom(params[position])) - { - if (invocation.getArguments()[position] != null) - { - if (parent) - { - testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getParentRef(); - } - else - { - testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getChildRef(); - } - if (logger.isDebugEnabled()) - { - if (nodeService.exists(testNodeRef)) - { - logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); - } - else - { - logger.debug("\tPermission test on non-existing node " + testNodeRef); - } - } - } - } - else if (AssociationRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) - { - if (parent) - { - testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getSourceRef(); - } - else - { - testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getTargetRef(); - } - if (logger.isDebugEnabled()) - { - if (nodeService.exists(testNodeRef)) - { - logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); - } - else - { - logger.debug("\tPermission test on non-existing node " + testNodeRef); - } - } - } - return testNodeRef; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import java.util.Map; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.util.Pair; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + + +/** + * Common security functions. + * + * TODO move methods to the appropriate services + * + * @author Roy Wetherall + * @since 2.0 + */ +public class RMSecurityCommon implements ApplicationContextAware +{ + /** No set value */ + protected static final int NOSET_VALUE = -100; + + /** Logger */ + private static Log logger = LogFactory.getLog(RMSecurityCommon.class); + + /** Services */ + //This is the internal NodeService -- no permission checks + protected NodeService nodeService; + protected PermissionService permissionService; + protected RMCaveatConfigComponent caveatConfigComponent; + private FilePlanService filePlanService; + + /** Application context */ + protected ApplicationContext applicationContext; + + /** + * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) + { + this.applicationContext = applicationContext; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param caveatConfigComponent caveat config service + */ + public void setCaveatConfigComponent(RMCaveatConfigComponent caveatConfigComponent) + { + this.caveatConfigComponent = caveatConfigComponent; + } + + /** + * @return FilePlanService file plan service + */ + protected FilePlanService getFilePlanService() + { + if (filePlanService == null) + { + filePlanService = (FilePlanService)applicationContext.getBean("filePlanService"); + } + return filePlanService; + } + + /** + * Sets a value into the transaction cache + * + * @param prefix + * @param nodeRef + * @param value + * @return + */ + protected int setTransactionCache(String prefix, NodeRef nodeRef, int value) + { + String user = AuthenticationUtil.getRunAsUser(); + AlfrescoTransactionSupport.bindResource(prefix + nodeRef.toString() + user, Integer.valueOf(value)); + return value; + } + + /** + * Gets a value from the transaction cache + * + * @param prefix + * @param nodeRef + * @return + */ + protected int getTransactionCache(String prefix, NodeRef nodeRef) + { + int result = NOSET_VALUE; + String user = AuthenticationUtil.getRunAsUser(); + Integer value = (Integer)AlfrescoTransactionSupport.getResource(prefix + nodeRef.toString() + user); + if (value != null) + { + result = value.intValue(); + } + return result; + } + + /** + * Check for RM read + * + * @param nodeRef + * @return + */ + public int checkRead(NodeRef nodeRef) + { + int result = AccessDecisionVoter.ACCESS_ABSTAIN; + if (nodeRef != null) + { + // now we know the node - we can abstain for certain types and aspects (eg, rm) + result = checkRead(nodeRef, false); + } + + return result; + } + + /** + * Check for RM read + * + * @param nodeRef + * @param allowDMRead + * @return + */ + public int checkRead(NodeRef nodeRef, boolean allowDMRead) + { + int result = AccessDecisionVoter.ACCESS_ABSTAIN; + + if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + result = checkRmRead(nodeRef); + } + else if (allowDMRead) + { + // Check DM read for copy etc + // DM does not grant - it can only deny + if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) + { + if (logger.isDebugEnabled()) + { + logger.debug("\t\tPermission is denied"); + Thread.dumpStack(); + } + result = AccessDecisionVoter.ACCESS_DENIED; + } + else + { + result = AccessDecisionVoter.ACCESS_GRANTED; + } + } + + return result; + } + + /** + * Core RM read check + * + * @param nodeRef node reference + * @return int see {@link AccessDecisionVoter} + */ + public int checkRmRead(NodeRef nodeRef) + { + int result = AccessDecisionVoter.ACCESS_ABSTAIN; + + Map, Integer> transactionCache = TransactionalResourceHelper.getMap("rm.security.checkRMRead"); + Pair key = new Pair(AuthenticationUtil.getRunAsUser(), nodeRef); + + if (transactionCache.containsKey(key)) + { + result = transactionCache.get(key); + } + else + { + if (permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS) == AccessStatus.DENIED) + { + if (logger.isDebugEnabled()) + { + logger.debug("\t\tUser does not have read record permission on node, access denied. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); + } + result = AccessDecisionVoter.ACCESS_DENIED; + } + else + { + // Get the file plan for the node + NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); + if (hasViewCapability(filePlan) == AccessStatus.DENIED) + { + if (logger.isDebugEnabled()) + { + logger.debug("\t\tUser does not have view records capability permission on node, access denied. (filePlan=" + filePlan.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); + } + result = AccessDecisionVoter.ACCESS_DENIED; + } + else if (!caveatConfigComponent.hasAccess(nodeRef)) + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + else + { + result = AccessDecisionVoter.ACCESS_GRANTED; + } + } + + // cache result + transactionCache.put(key, result); + } + + return result; + } + + /** + * Helper method to determine whether the current user has view capability on the file plan + * + * @param filePlan file plan + * @return {@link AccessStatus} + */ + private AccessStatus hasViewCapability(NodeRef filePlan) + { + Map, AccessStatus> transactionCache = TransactionalResourceHelper.getMap("rm.security.hasViewCapability"); + Pair key = new Pair(AuthenticationUtil.getRunAsUser(), filePlan); + + if (transactionCache.containsKey(key)) + { + return transactionCache.get(key); + } + else + { + AccessStatus result = permissionService.hasPermission(filePlan, ViewRecordsCapability.NAME); + transactionCache.put(key, result); + return result; + } + } + + @SuppressWarnings("rawtypes") + protected NodeRef getTestNode(MethodInvocation invocation, Class[] params, int position, boolean parent) + { + NodeRef testNodeRef = null; + if (position < 0) + { + if (logger.isDebugEnabled()) + { + logger.debug("\tNothing to test permission against."); + } + testNodeRef = null; + } + else if (StoreRef.class.isAssignableFrom(params[position])) + { + if (invocation.getArguments()[position] != null) + { + if (logger.isDebugEnabled()) + { + logger.debug("\tPermission test against the store - using permissions on the root node"); + } + StoreRef storeRef = (StoreRef) invocation.getArguments()[position]; + if (nodeService.exists(storeRef)) + { + testNodeRef = nodeService.getRootNode(storeRef); + } + } + } + else if (NodeRef.class.isAssignableFrom(params[position])) + { + testNodeRef = (NodeRef) invocation.getArguments()[position]; + if (parent) + { + testNodeRef = nodeService.getPrimaryParent(testNodeRef).getParentRef(); + if (logger.isDebugEnabled()) + { + if (nodeService.exists(testNodeRef)) + { + logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef)); + } + else + { + logger.debug("\tPermission test for parent on non-existing node " + testNodeRef); + } + logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef)); + } + } + else + { + if (logger.isDebugEnabled()) + { + if (nodeService.exists(testNodeRef)) + { + logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); + } + else + { + logger.debug("\tPermission test on non-existing node " + testNodeRef); + } + } + } + } + else if (ChildAssociationRef.class.isAssignableFrom(params[position])) + { + if (invocation.getArguments()[position] != null) + { + if (parent) + { + testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getParentRef(); + } + else + { + testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getChildRef(); + } + if (logger.isDebugEnabled()) + { + if (nodeService.exists(testNodeRef)) + { + logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); + } + else + { + logger.debug("\tPermission test on non-existing node " + testNodeRef); + } + } + } + } + else if (AssociationRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) + { + if (parent) + { + testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getSourceRef(); + } + else + { + testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getTargetRef(); + } + if (logger.isDebugEnabled()) + { + if (nodeService.exists(testNodeRef)) + { + logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef)); + } + else + { + logger.debug("\tPermission test on non-existing node " + testNodeRef); + } + } + } + return testNodeRef; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java index 09d1bec413..fe90dcd8b9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java @@ -1,170 +1,170 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative; - -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.PermissionService; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Abstract capability condition. - * - * @author Roy Wetherall - */ -public abstract class AbstractCapabilityCondition implements CapabilityCondition, - BeanNameAware, - RecordsManagementModel -{ - /** transaction cache key */ - private static final String KEY_EVALUATE = "rm.transaction.evaluate"; - - /** Capability condition name */ - protected String name; - - /** Services */ - protected RecordService recordService; - protected PermissionService permissionService; - protected NodeService nodeService; - protected FreezeService freezeService; - protected FilePlanService filePlanService; - protected DispositionService dispositionService; - protected RecordFolderService recordFolderService; - - /** transaction resource helper */ - private TransactionalResourceHelper transactionalResourceHelper; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param freezeService freeze service - */ - public void setFreezeService(FreezeService freezeService) - { - this.freezeService = freezeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param transactionalResourceHelper transactional resource helper - */ - public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) - { - this.transactionalResourceHelper = transactionalResourceHelper; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#getName() - */ - @Override - public String getName() - { - return name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluate(NodeRef nodeRef) - { - boolean result = false; - - // check transaction cache - Map map = transactionalResourceHelper.getMap(KEY_EVALUATE); - String key = getName() + "|" + nodeRef.toString() + "|" + AuthenticationUtil.getRunAsUser(); - if (map.containsKey(key)) - { - result = map.get(key); - } - else - { - result = evaluateImpl(nodeRef); - map.put(key, result); - } - - return result; - } - - public abstract boolean evaluateImpl(NodeRef nodeRef); - - /** - * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) - */ - @Override - public void setBeanName(String name) - { - this.name = name; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative; + +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.PermissionService; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Abstract capability condition. + * + * @author Roy Wetherall + */ +public abstract class AbstractCapabilityCondition implements CapabilityCondition, + BeanNameAware, + RecordsManagementModel +{ + /** transaction cache key */ + private static final String KEY_EVALUATE = "rm.transaction.evaluate"; + + /** Capability condition name */ + protected String name; + + /** Services */ + protected RecordService recordService; + protected PermissionService permissionService; + protected NodeService nodeService; + protected FreezeService freezeService; + protected FilePlanService filePlanService; + protected DispositionService dispositionService; + protected RecordFolderService recordFolderService; + + /** transaction resource helper */ + private TransactionalResourceHelper transactionalResourceHelper; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param freezeService freeze service + */ + public void setFreezeService(FreezeService freezeService) + { + this.freezeService = freezeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param transactionalResourceHelper transactional resource helper + */ + public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) + { + this.transactionalResourceHelper = transactionalResourceHelper; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#getName() + */ + @Override + public String getName() + { + return name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluate(NodeRef nodeRef) + { + boolean result = false; + + // check transaction cache + Map map = transactionalResourceHelper.getMap(KEY_EVALUATE); + String key = getName() + "|" + nodeRef.toString() + "|" + AuthenticationUtil.getRunAsUser(); + if (map.containsKey(key)) + { + result = map.get(key); + } + else + { + result = evaluateImpl(nodeRef); + map.put(key, result); + } + + return result; + } + + public abstract boolean evaluateImpl(NodeRef nodeRef); + + /** + * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) + */ + @Override + public void setBeanName(String name) + { + this.name = name; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/CapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/CapabilityCondition.java index 68c682c2fe..2ee094a702 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/CapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/CapabilityCondition.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Capability condition. - * - * @author Roy Wetherall - * @since 2.0 - */ -public interface CapabilityCondition -{ - /** - * Get capability condition name - * - * @return {@link String} capability condition name - */ - String getName(); - - /** - * Evaluates capability condition. - * - * @param nodeRef node reference - * @return boolean true if evaluate success, false otherwise - */ - boolean evaluate(NodeRef nodeRef); +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Capability condition. + * + * @author Roy Wetherall + * @since 2.0 + */ +public interface CapabilityCondition +{ + /** + * Get capability condition name + * + * @return {@link String} capability condition name + */ + String getName(); + + /** + * Evaluates capability condition. + * + * @param nodeRef node reference + * @return boolean true if evaluate success, false otherwise + */ + boolean evaluate(NodeRef nodeRef); } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCapability.java index 25dd968865..78f15618d5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCapability.java @@ -1,374 +1,374 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Declarative capability implementation. - * - * @author Roy Wetherall - */ -public class DeclarativeCapability extends AbstractCapability -{ - /** Logger */ - protected static final Log LOGGER = LogFactory.getLog(DeclarativeCapability.class); - - /** Required permissions */ - protected List permissions; - - /** Map of conditions and expected evaluation result */ - protected Map conditions; - - /** List of file plan component kinds one of which must be satisfied */ - protected List kinds; - - /** Capability to be evaluated against the target node reference */ - protected Capability targetCapability; - - /** Indicates whether to return an undetermined result */ - protected boolean isUndetermined = false; - - /** - * @param permissions permissions - */ - public void setPermissions(List permissions) - { - this.permissions = permissions; - } - - /** - * @param conditions conditions and expected values - */ - public void setConditions(Map conditions) - { - this.conditions = conditions; - } - - /** - * @return {@link Map} conditions and expected values - */ - public Map getConditions() - { - return conditions; - } - - /** - * @param kinds list of file plan component kinds - */ - public void setKinds(List kinds) - { - this.kinds = kinds; - } - - /** - * @return {@link List}<@link String> list of expected file plan component kinds - */ - public List getKinds() - { - return kinds; - } - - /** - * Helper method to set a single kind. - * - * @param kind file plan component kind - */ - public void setKind(String kind) - { - this.kinds = Collections.singletonList(kind); - } - - /** - * Sets whether the capability will return an undetermined result when evaluating permissions - * for a single node reference or not. The default is to return grant. - * - * @param isUndetermined true if undetermined result, false otherwise - */ - public void setUndetermined(boolean isUndetermined) - { - this.isUndetermined = isUndetermined; - } - - /** - * @return - */ - public boolean isUndetermined() - { - return isUndetermined; - } - - /** - * Helper @see #setPermissions(List) - * - * @param permission permission - */ - public void setPermission(String permission) - { - List permissions = new ArrayList(1); - permissions.add(permission); - this.permissions = permissions; - } - - /** - * @param targetCapability target capability - */ - public void setTargetCapability(Capability targetCapability) - { - this.targetCapability = targetCapability; - } - - /** - * Check the permissions passed. - * - * @param nodeRef node reference - * @return boolean true if the permissions are present, false otherwise - */ - protected boolean checkPermissionsImpl(NodeRef nodeRef, String ... permissions) - { - boolean result = true; - NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); - - for (String permission : permissions) - { - if (permissionService.hasPermission(filePlan, permission) != AccessStatus.ALLOWED) - { - result = false; - break; - } - } - - return result; - } - - /** - * Checks the permissions required for the capability. - * - * @param nodeRef - * @return - */ - protected boolean checkPermissions(NodeRef nodeRef) - { - boolean result = true; - if (permissions != null && !permissions.isEmpty()) - { - result = checkPermissionsImpl(nodeRef, (String[])permissions.toArray(new String[permissions.size()])); - } - return result; - } - - /** - * Checks the passed conditions. - * - * @param nodeRef - * @return - */ - protected boolean checkConditions(NodeRef nodeRef, Map conditions) - { - boolean result = true; - if (conditions != null) - { - for (Map.Entry entry : conditions.entrySet()) - { - boolean expected = entry.getValue().booleanValue(); - String conditionName = entry.getKey(); - - CapabilityCondition condition = (CapabilityCondition)applicationContext.getBean(conditionName); - if (condition == null) - { - throw new AlfrescoRuntimeException("Capability condition " + conditionName + " does not exist. Check the configuration of the capability " + name + "."); - } - - // determine the actual value - boolean actual = condition.evaluate(nodeRef); - - // report information about condition (for exception reporting) - RMMethodSecurityInterceptor.reportCapabilityCondition(getName(), condition.getName(), expected, actual); - - if (expected != actual) - { - result = false; - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("FAIL: Condition " + condition.getName() + " failed for capability " + getName() + " on nodeRef " + nodeRef.toString()); - } - - break; - } - } - } - return result; - } - - /** - * Checks the set conditions. - * - * @param nodeRef node reference - * @return boolean true if conditions satisfied, false otherwise - */ - protected boolean checkConditions(NodeRef nodeRef) - { - return checkConditions(nodeRef, conditions); - } - - /** - * Checks that the node ref is of the expected kind - * - * @param nodeRef - * @return - */ - protected boolean checkKinds(NodeRef nodeRef) - { - boolean result = false; - - FilePlanComponentKind actualKind = getFilePlanService().getFilePlanComponentKind(nodeRef); - - if (actualKind != null) - { - if (kinds != null && !kinds.isEmpty()) - { - // need to check the actual file plan kind is in the list specified - for (String kindString : kinds) - { - FilePlanComponentKind kind = FilePlanComponentKind.valueOf(kindString); - if (actualKind.equals(kind)) - { - result = true; - break; - } - } - } - else - { - // we don't have any specific kinds to check, so we pass since we have a file - // plan component in our hands - result = true; - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public int evaluate(NodeRef nodeRef) - { - int result = AccessDecisionVoter.ACCESS_ABSTAIN; - - // check transaction cache - Map map = TransactionalResourceHelper.getMap("rm.declarativeCapability"); - String key = getName() + "|" + nodeRef.toString() + "|" + AuthenticationUtil.getRunAsUser(); - if (map.containsKey(key)) - { - result = map.get(key); - } - else - { - // Check we are dealing with a file plan component - if (getFilePlanService().isFilePlanComponent(nodeRef)) - { - // Check the kind of the object, the permissions and the conditions - if (checkKinds(nodeRef) && checkPermissions(nodeRef) && checkConditions(nodeRef)) - { - // Opportunity for child implementations to extend - result = evaluateImpl(nodeRef); - } - else - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - } - - // Last chance for child implementations to veto/change the result - result = onEvaluate(nodeRef, result); - - // log access denied to help with debug - if (LOGGER.isDebugEnabled() && AccessDecisionVoter.ACCESS_DENIED == result) - { - LOGGER.debug("Capability " + getName() + " returned an Access Denied result during evaluation of node " + nodeRef.toString()); - } - - map.put(key, result); - } - - return result; - } - - @Override - public int evaluate(NodeRef source, NodeRef target) - { - int result = evaluate(source); - if (targetCapability != null && result != AccessDecisionVoter.ACCESS_DENIED) - { - result = targetCapability.evaluate(target); - } - return result; - } - - /** - * Default implementation. Given extending classes a hook point for further checks. - * - * @param nodeRef node reference - * @return - */ - protected int evaluateImpl(NodeRef nodeRef) - { - int result = AccessDecisionVoter.ACCESS_GRANTED; - if (isUndetermined) - { - result = AccessDecisionVoter.ACCESS_ABSTAIN; - } - return result; - } - - /** - * Default implementation. - * - * Called before evaluate completes. The result returned overwrites the already discovered result. - * Provides a hook point for child implementations that wish to veto the result. - * - * @param nodeRef - * @param result - * @return - */ - protected int onEvaluate(NodeRef nodeRef, int result) - { - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Declarative capability implementation. + * + * @author Roy Wetherall + */ +public class DeclarativeCapability extends AbstractCapability +{ + /** Logger */ + protected static final Log LOGGER = LogFactory.getLog(DeclarativeCapability.class); + + /** Required permissions */ + protected List permissions; + + /** Map of conditions and expected evaluation result */ + protected Map conditions; + + /** List of file plan component kinds one of which must be satisfied */ + protected List kinds; + + /** Capability to be evaluated against the target node reference */ + protected Capability targetCapability; + + /** Indicates whether to return an undetermined result */ + protected boolean isUndetermined = false; + + /** + * @param permissions permissions + */ + public void setPermissions(List permissions) + { + this.permissions = permissions; + } + + /** + * @param conditions conditions and expected values + */ + public void setConditions(Map conditions) + { + this.conditions = conditions; + } + + /** + * @return {@link Map} conditions and expected values + */ + public Map getConditions() + { + return conditions; + } + + /** + * @param kinds list of file plan component kinds + */ + public void setKinds(List kinds) + { + this.kinds = kinds; + } + + /** + * @return {@link List}<@link String> list of expected file plan component kinds + */ + public List getKinds() + { + return kinds; + } + + /** + * Helper method to set a single kind. + * + * @param kind file plan component kind + */ + public void setKind(String kind) + { + this.kinds = Collections.singletonList(kind); + } + + /** + * Sets whether the capability will return an undetermined result when evaluating permissions + * for a single node reference or not. The default is to return grant. + * + * @param isUndetermined true if undetermined result, false otherwise + */ + public void setUndetermined(boolean isUndetermined) + { + this.isUndetermined = isUndetermined; + } + + /** + * @return + */ + public boolean isUndetermined() + { + return isUndetermined; + } + + /** + * Helper @see #setPermissions(List) + * + * @param permission permission + */ + public void setPermission(String permission) + { + List permissions = new ArrayList(1); + permissions.add(permission); + this.permissions = permissions; + } + + /** + * @param targetCapability target capability + */ + public void setTargetCapability(Capability targetCapability) + { + this.targetCapability = targetCapability; + } + + /** + * Check the permissions passed. + * + * @param nodeRef node reference + * @return boolean true if the permissions are present, false otherwise + */ + protected boolean checkPermissionsImpl(NodeRef nodeRef, String ... permissions) + { + boolean result = true; + NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); + + for (String permission : permissions) + { + if (permissionService.hasPermission(filePlan, permission) != AccessStatus.ALLOWED) + { + result = false; + break; + } + } + + return result; + } + + /** + * Checks the permissions required for the capability. + * + * @param nodeRef + * @return + */ + protected boolean checkPermissions(NodeRef nodeRef) + { + boolean result = true; + if (permissions != null && !permissions.isEmpty()) + { + result = checkPermissionsImpl(nodeRef, (String[])permissions.toArray(new String[permissions.size()])); + } + return result; + } + + /** + * Checks the passed conditions. + * + * @param nodeRef + * @return + */ + protected boolean checkConditions(NodeRef nodeRef, Map conditions) + { + boolean result = true; + if (conditions != null) + { + for (Map.Entry entry : conditions.entrySet()) + { + boolean expected = entry.getValue().booleanValue(); + String conditionName = entry.getKey(); + + CapabilityCondition condition = (CapabilityCondition)applicationContext.getBean(conditionName); + if (condition == null) + { + throw new AlfrescoRuntimeException("Capability condition " + conditionName + " does not exist. Check the configuration of the capability " + name + "."); + } + + // determine the actual value + boolean actual = condition.evaluate(nodeRef); + + // report information about condition (for exception reporting) + RMMethodSecurityInterceptor.reportCapabilityCondition(getName(), condition.getName(), expected, actual); + + if (expected != actual) + { + result = false; + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("FAIL: Condition " + condition.getName() + " failed for capability " + getName() + " on nodeRef " + nodeRef.toString()); + } + + break; + } + } + } + return result; + } + + /** + * Checks the set conditions. + * + * @param nodeRef node reference + * @return boolean true if conditions satisfied, false otherwise + */ + protected boolean checkConditions(NodeRef nodeRef) + { + return checkConditions(nodeRef, conditions); + } + + /** + * Checks that the node ref is of the expected kind + * + * @param nodeRef + * @return + */ + protected boolean checkKinds(NodeRef nodeRef) + { + boolean result = false; + + FilePlanComponentKind actualKind = getFilePlanService().getFilePlanComponentKind(nodeRef); + + if (actualKind != null) + { + if (kinds != null && !kinds.isEmpty()) + { + // need to check the actual file plan kind is in the list specified + for (String kindString : kinds) + { + FilePlanComponentKind kind = FilePlanComponentKind.valueOf(kindString); + if (actualKind.equals(kind)) + { + result = true; + break; + } + } + } + else + { + // we don't have any specific kinds to check, so we pass since we have a file + // plan component in our hands + result = true; + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public int evaluate(NodeRef nodeRef) + { + int result = AccessDecisionVoter.ACCESS_ABSTAIN; + + // check transaction cache + Map map = TransactionalResourceHelper.getMap("rm.declarativeCapability"); + String key = getName() + "|" + nodeRef.toString() + "|" + AuthenticationUtil.getRunAsUser(); + if (map.containsKey(key)) + { + result = map.get(key); + } + else + { + // Check we are dealing with a file plan component + if (getFilePlanService().isFilePlanComponent(nodeRef)) + { + // Check the kind of the object, the permissions and the conditions + if (checkKinds(nodeRef) && checkPermissions(nodeRef) && checkConditions(nodeRef)) + { + // Opportunity for child implementations to extend + result = evaluateImpl(nodeRef); + } + else + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + } + + // Last chance for child implementations to veto/change the result + result = onEvaluate(nodeRef, result); + + // log access denied to help with debug + if (LOGGER.isDebugEnabled() && AccessDecisionVoter.ACCESS_DENIED == result) + { + LOGGER.debug("Capability " + getName() + " returned an Access Denied result during evaluation of node " + nodeRef.toString()); + } + + map.put(key, result); + } + + return result; + } + + @Override + public int evaluate(NodeRef source, NodeRef target) + { + int result = evaluate(source); + if (targetCapability != null && result != AccessDecisionVoter.ACCESS_DENIED) + { + result = targetCapability.evaluate(target); + } + return result; + } + + /** + * Default implementation. Given extending classes a hook point for further checks. + * + * @param nodeRef node reference + * @return + */ + protected int evaluateImpl(NodeRef nodeRef) + { + int result = AccessDecisionVoter.ACCESS_GRANTED; + if (isUndetermined) + { + result = AccessDecisionVoter.ACCESS_ABSTAIN; + } + return result; + } + + /** + * Default implementation. + * + * Called before evaluate completes. The result returned overwrites the already discovered result. + * Provides a hook point for child implementations that wish to veto the result. + * + * @param nodeRef + * @param result + * @return + */ + protected int onEvaluate(NodeRef nodeRef, int result) + { + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCompositeCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCompositeCapability.java index 60b750b5d3..1c89ba2adc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCompositeCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/DeclarativeCompositeCapability.java @@ -1,139 +1,139 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative; - -import java.util.Set; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CompositeCapability; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Generic implementation of a composite capability - * - * @author Roy Wetherall - */ -public class DeclarativeCompositeCapability extends DeclarativeCapability - implements CompositeCapability -{ - /** set of capabilities */ - private Set capabilities; - - /** - * @param capabilites set of capabilities - */ - public void setCapabilities(Set capabilities) - { - this.capabilities = capabilities; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CompositeCapability#getCapabilities() - */ - @Override - public Set getCapabilities() - { - return this.capabilities; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public int evaluateImpl(NodeRef nodeRef) - { - int result = AccessDecisionVoter.ACCESS_DENIED; - - // Check each capability using 'OR' logic - for (Capability capability : capabilities) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Evaluating child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name); - } - - int capabilityResult = capability.evaluate(nodeRef); - if (capabilityResult != AccessDecisionVoter.ACCESS_DENIED) - { - result = AccessDecisionVoter.ACCESS_ABSTAIN; - if (!isUndetermined() && capabilityResult == AccessDecisionVoter.ACCESS_GRANTED) - { - result = AccessDecisionVoter.ACCESS_GRANTED; - } - break; - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Access denied for child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name); - } - } - } - - return result; - } - - /** - * If a target capability is specified then we evaluate that. Otherwise we combine the results of the provided capabilities. - * - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public int evaluate(NodeRef source, NodeRef target) - { - int result = AccessDecisionVoter.ACCESS_ABSTAIN; - - // Check we are dealing with a file plan component - if (getFilePlanService().isFilePlanComponent(source) && - getFilePlanService().isFilePlanComponent(target)) - { - // Check the kind of the object, the permissions and the conditions - if (checkKinds(source) && checkPermissions(source) && checkConditions(source)) - { - if (targetCapability != null) - { - result = targetCapability.evaluate(target); - } - - if (AccessDecisionVoter.ACCESS_DENIED != result) - { - // Check each capability using 'OR' logic - for (Capability capability : capabilities) - { - result = capability.evaluate(source, target); - if (result == AccessDecisionVoter.ACCESS_GRANTED) - { - break; - } - } - - } - } - else - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative; + +import java.util.Set; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CompositeCapability; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Generic implementation of a composite capability + * + * @author Roy Wetherall + */ +public class DeclarativeCompositeCapability extends DeclarativeCapability + implements CompositeCapability +{ + /** set of capabilities */ + private Set capabilities; + + /** + * @param capabilites set of capabilities + */ + public void setCapabilities(Set capabilities) + { + this.capabilities = capabilities; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CompositeCapability#getCapabilities() + */ + @Override + public Set getCapabilities() + { + return this.capabilities; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public int evaluateImpl(NodeRef nodeRef) + { + int result = AccessDecisionVoter.ACCESS_DENIED; + + // Check each capability using 'OR' logic + for (Capability capability : capabilities) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Evaluating child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name); + } + + int capabilityResult = capability.evaluate(nodeRef); + if (capabilityResult != AccessDecisionVoter.ACCESS_DENIED) + { + result = AccessDecisionVoter.ACCESS_ABSTAIN; + if (!isUndetermined() && capabilityResult == AccessDecisionVoter.ACCESS_GRANTED) + { + result = AccessDecisionVoter.ACCESS_GRANTED; + } + break; + } + else + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Access denied for child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name); + } + } + } + + return result; + } + + /** + * If a target capability is specified then we evaluate that. Otherwise we combine the results of the provided capabilities. + * + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public int evaluate(NodeRef source, NodeRef target) + { + int result = AccessDecisionVoter.ACCESS_ABSTAIN; + + // Check we are dealing with a file plan component + if (getFilePlanService().isFilePlanComponent(source) && + getFilePlanService().isFilePlanComponent(target)) + { + // Check the kind of the object, the permissions and the conditions + if (checkKinds(source) && checkPermissions(source) && checkConditions(source)) + { + if (targetCapability != null) + { + result = targetCapability.evaluate(target); + } + + if (AccessDecisionVoter.ACCESS_DENIED != result) + { + // Check each capability using 'OR' logic + for (Capability capability : capabilities) + { + result = capability.evaluate(source, target); + if (result == AccessDecisionVoter.ACCESS_GRANTED) + { + break; + } + } + + } + } + else + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/AtLeastOneCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/AtLeastOneCondition.java index 5283e84e6c..2a1b079d78 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/AtLeastOneCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/AtLeastOneCondition.java @@ -1,79 +1,79 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Composite capability condition implementation that required at least one of the - * capability conditions to be true. - * - * @author Roy Wetherall - */ -public class AtLeastOneCondition extends AbstractCapabilityCondition -{ - /** capability conditions */ - private List conditions; - - /** - * @param conditions capability conditions - */ - public void setConditions(List conditions) - { - this.conditions = conditions; - } - - /** - * Don't use the transaction cache for the composite condition - * - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluate(NodeRef nodeRef) - { - return evaluateImpl(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - if (conditions != null) - { - for (CapabilityCondition condition : conditions) - { - if (condition.evaluate(nodeRef)) - { - result = true; - break; - } - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Composite capability condition implementation that required at least one of the + * capability conditions to be true. + * + * @author Roy Wetherall + */ +public class AtLeastOneCondition extends AbstractCapabilityCondition +{ + /** capability conditions */ + private List conditions; + + /** + * @param conditions capability conditions + */ + public void setConditions(List conditions) + { + this.conditions = conditions; + } + + /** + * Don't use the transaction cache for the composite condition + * + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluate(NodeRef nodeRef) + { + return evaluateImpl(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + if (conditions != null) + { + for (CapabilityCondition condition : conditions) + { + if (condition.evaluate(nodeRef)) + { + result = true; + break; + } + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java index 83f2b9a357..b5949129c6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * @author Roy Wetherall - */ -public class ClosedCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - if (recordFolderService.isRecordFolder(nodeRef)) - { - result = recordFolderService.isRecordFolderClosed(nodeRef); - } - else if (recordService.isRecord(nodeRef)) - { - final List assocs = nodeService.getParentAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - - result = AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Boolean doWork() - { - for (ChildAssociationRef assoc : assocs) - { - NodeRef parent = assoc.getParentRef(); - if (recordFolderService.isRecordFolder(parent) && recordFolderService.isRecordFolderClosed(parent)) - { - return true; - } - } - return false; - } - }); - - } - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * @author Roy Wetherall + */ +public class ClosedCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + if (recordFolderService.isRecordFolder(nodeRef)) + { + result = recordFolderService.isRecordFolderClosed(nodeRef); + } + else if (recordService.isRecord(nodeRef)) + { + final List assocs = nodeService.getParentAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + + result = AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Boolean doWork() + { + for (ChildAssociationRef assoc : assocs) + { + NodeRef parent = assoc.getParentRef(); + if (recordFolderService.isRecordFolder(parent) && recordFolderService.isRecordFolderClosed(parent)) + { + return true; + } + } + return false; + } + }); + + } + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java index d9392db42c..f3de447b36 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Cut off capability condition. - * - * @author Roy Wetherall - */ -public class CutoffCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - // determine whether the item is already cutt off - return dispositionService.isDisposableItemCutoff(nodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Cut off capability condition. + * + * @author Roy Wetherall + */ +public class CutoffCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + // determine whether the item is already cutt off + return dispositionService.isDisposableItemCutoff(nodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DeclaredCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DeclaredCapabilityCondition.java index ebd7f8cff1..d3f5a602d6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DeclaredCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DeclaredCapabilityCondition.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class DeclaredCapabilityCondition extends AbstractCapabilityCondition -{ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - if (FilePlanComponentKind.RECORD.equals(filePlanService.getFilePlanComponentKind(nodeRef))) - { - result = recordService.isDeclared(nodeRef); - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class DeclaredCapabilityCondition extends AbstractCapabilityCondition +{ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + if (FilePlanComponentKind.RECORD.equals(filePlanService.getFilePlanComponentKind(nodeRef))) + { + result = recordService.isDeclared(nodeRef); + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DestroyedCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DestroyedCapabilityCondition.java index fda8922fc1..b00aeb91dd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DestroyedCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/DestroyedCapabilityCondition.java @@ -1,36 +1,36 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Destroyed capability condition. - * - * @author Roy Wetherall - */ -public class DestroyedCapabilityCondition extends AbstractCapabilityCondition -{ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Destroyed capability condition. + * + * @author Roy Wetherall + */ +public class DestroyedCapabilityCondition extends AbstractCapabilityCondition +{ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FailCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FailCapabilityCondition.java index 37be9ba386..41b6517bbe 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FailCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FailCapabilityCondition.java @@ -1,37 +1,37 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Helper condition that always fails. Useful for deprecation of - * old capabilities. - * - * @author Roy Wetherall - */ -public class FailCapabilityCondition extends AbstractCapabilityCondition -{ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - return false; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Helper condition that always fails. Useful for deprecation of + * old capabilities. + * + * @author Roy Wetherall + */ +public class FailCapabilityCondition extends AbstractCapabilityCondition +{ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + return false; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FileableCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FileableCapabilityCondition.java index 60e01ad3eb..be8285fa41 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FileableCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FileableCapabilityCondition.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Fileable capability condition. Indicates whether a node is 'fileable', namely if it extends cm:content - * or extends rma:nonElectronicDocument - * - * @author Roy Wetherall - */ -public class FileableCapabilityCondition extends AbstractCapabilityCondition -{ - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - QName type = nodeService.getType(nodeRef); - // TODO and not already a record? - return (dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) || - dictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Fileable capability condition. Indicates whether a node is 'fileable', namely if it extends cm:content + * or extends rma:nonElectronicDocument + * + * @author Roy Wetherall + */ +public class FileableCapabilityCondition extends AbstractCapabilityCondition +{ + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + QName type = nodeService.getType(nodeRef); + // TODO and not already a record? + return (dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) || + dictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingCapabilityCondition.java index a443ed5d66..58bdd74514 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingCapabilityCondition.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Filling capability condition. - * - * @author Roy Wetherall - */ -public class FillingCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS) != AccessStatus.DENIED) - { - result = true; - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Filling capability condition. + * + * @author Roy Wetherall + */ +public class FillingCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS) != AccessStatus.DENIED) + { + result = true; + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityCondition.java index 391f81d74f..d304af8d3b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityCondition.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Filling capability for hold condition. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class FillingOnHoldContainerCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - NodeRef holdContainer = nodeRef; - - // if we have a file plan, go get the hold container - if (filePlanService.isFilePlan(nodeRef) == true) - { - holdContainer = filePlanService.getHoldContainer(nodeRef); - } - - // ensure we are dealing with a hold container - if (TYPE_HOLD_CONTAINER.equals(nodeService.getType(holdContainer))) - { - if (permissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS) != AccessStatus.DENIED) - { - result = true; - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Filling capability for hold condition. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class FillingOnHoldContainerCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + NodeRef holdContainer = nodeRef; + + // if we have a file plan, go get the hold container + if (filePlanService.isFilePlan(nodeRef) == true) + { + holdContainer = filePlanService.getHoldContainer(nodeRef); + } + + // ensure we are dealing with a hold container + if (TYPE_HOLD_CONTAINER.equals(nodeService.getType(holdContainer))) + { + if (permissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS) != AccessStatus.DENIED) + { + result = true; + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityCondition.java index a7b4e5132a..44e1f15a1c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityCondition.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether an item is held or not. - *

- * A hold object is by definition considered to be held. - * - * @author Roy Wetherall - */ -public class FrozenCapabilityCondition extends AbstractCapabilityCondition -{ - /** indicates whether children should be checked */ - private boolean checkChildren = false; - - /** hold service */ - private HoldService holdService; - - /** - * @param checkChildren true to check children, false otherwise - */ - public void setCheckChildren(boolean checkChildren) - { - this.checkChildren = checkChildren; - } - - /** - * @param holdService hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - // check whether we are working with a hold or not - if (holdService.isHold(nodeRef)) - { - result = true; - } - else - { - result = freezeService.isFrozen(nodeRef); - if (!result && checkChildren) - { - result = freezeService.hasFrozenChildren(nodeRef); - } - } - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether an item is held or not. + *

+ * A hold object is by definition considered to be held. + * + * @author Roy Wetherall + */ +public class FrozenCapabilityCondition extends AbstractCapabilityCondition +{ + /** indicates whether children should be checked */ + private boolean checkChildren = false; + + /** hold service */ + private HoldService holdService; + + /** + * @param checkChildren true to check children, false otherwise + */ + public void setCheckChildren(boolean checkChildren) + { + this.checkChildren = checkChildren; + } + + /** + * @param holdService hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + // check whether we are working with a hold or not + if (holdService.isHold(nodeRef)) + { + result = true; + } + else + { + result = freezeService.isFrozen(nodeRef); + if (!result && checkChildren) + { + result = freezeService.hasFrozenChildren(nodeRef); + } + } + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenOrHoldCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenOrHoldCondition.java index 12ada202ae..59434923c4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenOrHoldCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenOrHoldCondition.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether the node is either frozen or is a hold object - * - * @author Roy Wetherall - */ -public class FrozenOrHoldCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - return (freezeService.isFrozen(nodeRef) || - (kind != null && kind.equals(FilePlanComponentKind.HOLD))); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether the node is either frozen or is a hold object + * + * @author Roy Wetherall + */ +public class FrozenOrHoldCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + return (freezeService.isFrozen(nodeRef) || + (kind != null && kind.equals(FilePlanComponentKind.HOLD))); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasAspectCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasAspectCapabilityCondition.java index f4e23f88a1..6196da8e4c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasAspectCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasAspectCapabilityCondition.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - */ -public class HasAspectCapabilityCondition extends AbstractCapabilityCondition -{ - private String aspectName; - - private NamespaceService namespaceService; - - public void setAspectName(String aspectName) - { - this.aspectName = aspectName; - } - - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - if (aspectName != null) - { - QName aspect = QName.createQName(aspectName, namespaceService); - result = nodeService.hasAspect(nodeRef, aspect); - } - - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + */ +public class HasAspectCapabilityCondition extends AbstractCapabilityCondition +{ + private String aspectName; + + private NamespaceService namespaceService; + + public void setAspectName(String aspectName) + { + this.aspectName = aspectName; + } + + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + if (aspectName != null) + { + QName aspect = QName.createQName(aspectName, namespaceService); + result = nodeService.hasAspect(nodeRef, aspect); + } + + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasDispositionDateCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasDispositionDateCapabilityCondition.java index ad2a75eb65..a052e4231d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasDispositionDateCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasDispositionDateCapabilityCondition.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether a disposable item currently has a disposition date or not. - * - * @author Roy Wetherall - */ -public class HasDispositionDateCapabilityCondition extends AbstractCapabilityCondition -{ - /** Disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); - if (dispositionAction != null) - { - if (dispositionAction.getAsOfDate() != null) - { - result = true; - } - } - else if (filePlanService.isFilePlanComponent(nodeRef) && nodeService.getProperty(nodeRef, PROP_DISPOSITION_AS_OF) != null) - { - result = true; - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether a disposable item currently has a disposition date or not. + * + * @author Roy Wetherall + */ +public class HasDispositionDateCapabilityCondition extends AbstractCapabilityCondition +{ + /** Disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); + if (dispositionAction != null) + { + if (dispositionAction.getAsOfDate() != null) + { + result = true; + } + } + else if (filePlanService.isFilePlanComponent(nodeRef) && nodeService.getProperty(nodeRef, PROP_DISPOSITION_AS_OF) != null) + { + result = true; + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasEventsCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasEventsCapabilityCondition.java index 8b5cac1239..5d8a002404 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasEventsCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HasEventsCapabilityCondition.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether a scheduled record or folder has events or not. - * - * @author Roy Wetherall - */ -public class HasEventsCapabilityCondition extends AbstractCapabilityCondition -{ - /** Disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - if (dispositionService.isDisposableItem(nodeRef)) - { - DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); - if (da != null) - { - result = (!da.getEventCompletionDetails().isEmpty()); - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether a scheduled record or folder has events or not. + * + * @author Roy Wetherall + */ +public class HasEventsCapabilityCondition extends AbstractCapabilityCondition +{ + /** Disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + if (dispositionService.isDisposableItem(nodeRef)) + { + DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); + if (da != null) + { + result = (!da.getEventCompletionDetails().isEmpty()); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityCondition.java index 1f860ae8d0..4cad8d4d05 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityCondition.java @@ -1,85 +1,85 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Add to hold evaluator. - *

- * Determines whether the current user has access to any holds. - * - * @author Roy Wetherall - */ -public class HoldCapabilityCondition extends AbstractCapabilityCondition -{ - /** indicates whether to evaluate holds that the node is within or not within */ - private boolean includedInHold = false;; - - /** hold service */ - private HoldService holdService; - - /** - * @param includedInHold true if holds node within, false otherwise - */ - public void setIncludedInHold(boolean includedInHold) - { - this.includedInHold = includedInHold; - } - - /** - * @param holdService hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - if (holdService.isHold(nodeRef)) - { - result = AccessStatus.ALLOWED.equals(permissionService.hasPermission(nodeRef, RMPermissionModel.FILING)); - } - else - { - List holds = holdService.heldBy(nodeRef, includedInHold); - for (NodeRef hold : holds) - { - // return true as soon as we find one hold we have filling permission on - if (AccessStatus.ALLOWED.equals(permissionService.hasPermission(hold, RMPermissionModel.FILING))) - { - result = true; - break; - } - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Add to hold evaluator. + *

+ * Determines whether the current user has access to any holds. + * + * @author Roy Wetherall + */ +public class HoldCapabilityCondition extends AbstractCapabilityCondition +{ + /** indicates whether to evaluate holds that the node is within or not within */ + private boolean includedInHold = false;; + + /** hold service */ + private HoldService holdService; + + /** + * @param includedInHold true if holds node within, false otherwise + */ + public void setIncludedInHold(boolean includedInHold) + { + this.includedInHold = includedInHold; + } + + /** + * @param holdService hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + if (holdService.isHold(nodeRef)) + { + result = AccessStatus.ALLOWED.equals(permissionService.hasPermission(nodeRef, RMPermissionModel.FILING)); + } + else + { + List holds = holdService.heldBy(nodeRef, includedInHold); + for (NodeRef hold : holds) + { + // return true as soon as we find one hold we have filling permission on + if (AccessStatus.ALLOWED.equals(permissionService.hasPermission(hold, RMPermissionModel.FILING))) + { + result = true; + break; + } + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsClassifiedCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsClassifiedCapabilityCondition.java index a2e3c4fc82..d94a25d0a7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsClassifiedCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsClassifiedCapabilityCondition.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether the given node has an associated disposition schedule - * - * @author Craig Tan - * @since 2.1 - */ -public class IsClassifiedCapabilityCondition extends AbstractCapabilityCondition -{ - /** Disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef); - if (dispositionSchedule != null) - { - result = true; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether the given node has an associated disposition schedule + * + * @author Craig Tan + * @since 2.1 + */ +public class IsClassifiedCapabilityCondition extends AbstractCapabilityCondition +{ + /** Disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef); + if (dispositionSchedule != null) + { + result = true; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsPropertySetCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsPropertySetCondition.java index 3ed855e322..6286c6e180 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsPropertySetCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsPropertySetCondition.java @@ -1,88 +1,88 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; - -/** - * Indicates whether a property is set or not. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class IsPropertySetCondition extends AbstractCapabilityCondition -{ - /** property name (eg: rma:location) */ - private String propertyName; - private QName propertyQName; - - /** namespace service */ - private NamespaceService namespaceService; - - /** - * @param propertyName property name (eg: rma:location) - */ - public void setPropertyName(String propertyName) - { - this.propertyName = propertyName; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @return QName property qname - */ - protected QName getPropertyQName() - { - if (propertyQName == null) - { - propertyQName = QName.createQName(propertyName, namespaceService); - } - return propertyQName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - boolean result = false; - - if (nodeService.getProperty(nodeRef, getPropertyQName()) != null) - { - result = true; - } - - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; + +/** + * Indicates whether a property is set or not. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class IsPropertySetCondition extends AbstractCapabilityCondition +{ + /** property name (eg: rma:location) */ + private String propertyName; + private QName propertyQName; + + /** namespace service */ + private NamespaceService namespaceService; + + /** + * @param propertyName property name (eg: rma:location) + */ + public void setPropertyName(String propertyName) + { + this.propertyName = propertyName; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @return QName property qname + */ + protected QName getPropertyQName() + { + if (propertyQName == null) + { + propertyQName = QName.createQName(propertyName, namespaceService); + } + return propertyQName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + boolean result = false; + + if (nodeService.getProperty(nodeRef, getPropertyQName()) != null) + { + result = true; + } + + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCategoryCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCategoryCondition.java index 44198c4caa..4564aa549a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCategoryCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCategoryCondition.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; - -/** - * Indicates whether the given node is a record category or not. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class IsRecordCategoryCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return filePlanService.isRecordCategory(nodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.ParameterCheck; + +/** + * Indicates whether the given node is a record category or not. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class IsRecordCategoryCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return filePlanService.isRecordCategory(nodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCondition.java index 94dcdb4627..25f4f70477 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordCondition.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; - -/** - * Indicates whether the given node is a record or not. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class IsRecordCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return recordService.isRecord(nodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.ParameterCheck; + +/** + * Indicates whether the given node is a record or not. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class IsRecordCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return recordService.isRecord(nodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java index e3662049d6..978471a3e6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; - -/** - * Indicates whether the given node is a record folder or not. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class IsRecordFolderCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return recordFolderService.isRecordFolder(nodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.ParameterCheck; + +/** + * Indicates whether the given node is a record folder or not. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class IsRecordFolderCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return recordFolderService.isRecordFolder(nodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsScheduledCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsScheduledCapabilityCondition.java index 902e94314d..3d087aeadc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsScheduledCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsScheduledCapabilityCondition.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether the given disposition action is scheduled next - * - * @author Roy Wetherall - */ -public class IsScheduledCapabilityCondition extends AbstractCapabilityCondition -{ - /** Disposition action */ - private String dispositionAction; - - /** Disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionAction disposition action - */ - public void setDispositionAction(String dispositionAction) - { - this.dispositionAction = dispositionAction; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(nodeRef); - if (nextDispositionAction != null) - { - // Get the disposition actions name - String actionName = nextDispositionAction.getName(); - if (actionName.equals(dispositionAction) && - dispositionService.isNextDispositionActionEligible(nodeRef)) - { - result = true; - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether the given disposition action is scheduled next + * + * @author Roy Wetherall + */ +public class IsScheduledCapabilityCondition extends AbstractCapabilityCondition +{ + /** Disposition action */ + private String dispositionAction; + + /** Disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionAction disposition action + */ + public void setDispositionAction(String dispositionAction) + { + this.dispositionAction = dispositionAction; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(nodeRef); + if (nextDispositionAction != null) + { + // Get the disposition actions name + String actionName = nextDispositionAction.getName(); + if (actionName.equals(dispositionAction) && + dispositionService.isNextDispositionActionEligible(nodeRef)) + { + result = true; + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsTransferAccessionCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsTransferAccessionCapabilityCondition.java index d75c5ff719..e86134187d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsTransferAccessionCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsTransferAccessionCapabilityCondition.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class IsTransferAccessionCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - if (FilePlanComponentKind.TRANSFER.equals(kind)) - { - Boolean value = (Boolean)nodeService.getProperty(nodeRef, PROP_TRANSFER_ACCESSION_INDICATOR); - if (value != null) - { - result = value.booleanValue(); - } - } - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class IsTransferAccessionCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + if (FilePlanComponentKind.TRANSFER.equals(kind)) + { + Boolean value = (Boolean)nodeService.getProperty(nodeRef, PROP_TRANSFER_ACCESSION_INDICATOR); + if (value != null) + { + result = value.booleanValue(); + } + } + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/LastDispositionActionCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/LastDispositionActionCondition.java index b6281ac3c7..85c9e36c77 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/LastDispositionActionCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/LastDispositionActionCondition.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Last disposition action condition. - * - * @author Roy Wetherall - */ -public class LastDispositionActionCondition extends AbstractCapabilityCondition -{ - private DispositionService dispositionService; - - private String dispositionActionName; - - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - public void setDispositionActionName(String dispositionActionName) - { - this.dispositionActionName = dispositionActionName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - DispositionAction dispositionAction = dispositionService.getLastCompletedDispostionAction(nodeRef); - if (dispositionAction != null && - dispositionActionName.equals(dispositionAction.getName())) - { - result = true; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Last disposition action condition. + * + * @author Roy Wetherall + */ +public class LastDispositionActionCondition extends AbstractCapabilityCondition +{ + private DispositionService dispositionService; + + private String dispositionActionName; + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + public void setDispositionActionName(String dispositionActionName) + { + this.dispositionActionName = dispositionActionName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + DispositionAction dispositionAction = dispositionService.getLastCompletedDispostionAction(nodeRef); + if (dispositionAction != null && + dispositionActionName.equals(dispositionAction.getName())) + { + result = true; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java index 2a2523760d..bcbe3a2a1d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java @@ -1,101 +1,101 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether the given disposition action 'may' be scheduled in the future - * - * @author Roy Wetherall - */ -public class MayBeScheduledCapabilityCondition extends AbstractCapabilityCondition -{ - /** Disposition action */ - private String dispositionAction; - - /** Disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionAction disposition action - */ - public void setDispositionAction(String dispositionAction) - { - this.dispositionAction = dispositionAction; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef); - if (dispositionSchedule != null && checkDispositionLevel(nodeRef, dispositionSchedule)) - { - for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) - { - if (dispositionActionDefinition.getName().equals(dispositionAction)) - { - result = true; - break; - } - } - } - return result; - } - - /** - * Checks the disposition level - * - * @param nodeRef - * @param dispositionSchedule - * @return - */ - private boolean checkDispositionLevel(NodeRef nodeRef, DispositionSchedule dispositionSchedule) - { - boolean result = false; - boolean isRecordLevelDisposition = dispositionSchedule.isRecordLevelDisposition(); - if (recordService.isRecord(nodeRef) && isRecordLevelDisposition) - { - result = true; - } - else if (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition) - - { - result = true; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether the given disposition action 'may' be scheduled in the future + * + * @author Roy Wetherall + */ +public class MayBeScheduledCapabilityCondition extends AbstractCapabilityCondition +{ + /** Disposition action */ + private String dispositionAction; + + /** Disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionAction disposition action + */ + public void setDispositionAction(String dispositionAction) + { + this.dispositionAction = dispositionAction; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef); + if (dispositionSchedule != null && checkDispositionLevel(nodeRef, dispositionSchedule)) + { + for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) + { + if (dispositionActionDefinition.getName().equals(dispositionAction)) + { + result = true; + break; + } + } + } + return result; + } + + /** + * Checks the disposition level + * + * @param nodeRef + * @param dispositionSchedule + * @return + */ + private boolean checkDispositionLevel(NodeRef nodeRef, DispositionSchedule dispositionSchedule) + { + boolean result = false; + boolean isRecordLevelDisposition = dispositionSchedule.isRecordLevelDisposition(); + if (recordService.isRecord(nodeRef) && isRecordLevelDisposition) + { + result = true; + } + else if (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition) + + { + result = true; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/RecordFiledCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/RecordFiledCapabilityCondition.java index 4ab2be8ec4..35ee43fef1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/RecordFiledCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/RecordFiledCapabilityCondition.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Indicates whether a record is unfiled or not. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordFiledCapabilityCondition extends AbstractCapabilityCondition -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - return recordService.isFiled(nodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Indicates whether a record is unfiled or not. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordFiledCapabilityCondition extends AbstractCapabilityCondition +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + return recordService.isFiled(nodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/TransferredCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/TransferredCapabilityCondition.java index 7c19e3348a..3e59ac9cfb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/TransferredCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/TransferredCapabilityCondition.java @@ -1,35 +1,35 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class TransferredCapabilityCondition extends AbstractCapabilityCondition -{ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - return nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRED); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class TransferredCapabilityCondition extends AbstractCapabilityCondition +{ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + return nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRED); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java index 41071bd287..4ea08e7ed4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java @@ -1,52 +1,52 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class VitalRecordOrFolderCapabilityCondition extends AbstractCapabilityCondition -{ - @Override - public boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - if (recordService.isRecord(nodeRef)) - { - // Check the record for the vital record aspect - result = nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD); - } - else if (recordFolderService.isRecordFolder(nodeRef)) - { - // Check the folder for the vital record indicator - Boolean value = (Boolean)nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_VITAL_RECORD_INDICATOR); - if (value != null) - { - result = value.booleanValue(); - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class VitalRecordOrFolderCapabilityCondition extends AbstractCapabilityCondition +{ + @Override + public boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + if (recordService.isRecord(nodeRef)) + { + // Check the record for the vital record aspect + result = nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD); + } + else if (recordFolderService.isRecordFolder(nodeRef)) + { + // Check the folder for the vital record indicator + Boolean value = (Boolean)nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_VITAL_RECORD_INDICATOR); + if (value != null) + { + result = value.booleanValue(); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ChangeOrDeleteReferencesCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ChangeOrDeleteReferencesCapability.java index f050fc1ab9..532fe75670 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ChangeOrDeleteReferencesCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ChangeOrDeleteReferencesCapability.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Change or delete references capability - * - * @author Roy Wetherall - */ -public class ChangeOrDeleteReferencesCapability extends DeclarativeCapability -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - public int evaluate(NodeRef source, NodeRef target) - { - if (getFilePlanService().isFilePlanComponent(source)) - { - if (target != null) - { - if (getFilePlanService().isFilePlanComponent(target) && - checkConditions(source) && - checkConditions(target) && - checkPermissions(source) && - checkPermissions(target)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - } - else - { - if (checkConditions(source) && - checkPermissions(source)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - } - - return AccessDecisionVoter.ACCESS_DENIED; - } - else - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Change or delete references capability + * + * @author Roy Wetherall + */ +public class ChangeOrDeleteReferencesCapability extends DeclarativeCapability +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + public int evaluate(NodeRef source, NodeRef target) + { + if (getFilePlanService().isFilePlanComponent(source)) + { + if (target != null) + { + if (getFilePlanService().isFilePlanComponent(target) && + checkConditions(source) && + checkConditions(target) && + checkPermissions(source) && + checkPermissions(target)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + } + else + { + if (checkConditions(source) && + checkPermissions(source)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + } + + return AccessDecisionVoter.ACCESS_DENIED; + } + else + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java index e05aebda12..26a02328aa 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java @@ -1,181 +1,181 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import java.util.HashMap; -import java.util.Map; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; - -/** - * Create group capability implementation - * - * @author Andy Hind - */ -public class CreateCapability extends DeclarativeCapability -{ - /** record service */ - private RecordService recordService; - - /** record folder service */ - private RecordFolderService recordFolderService; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public int evaluate(NodeRef nodeRef) - { - return evaluate(nodeRef, null, null); - } - - /** - * Evaluate capability. - * - * @param destination destination node reference - * @param linkee linkee node reference, can be null - * @param assocType association type, can be null - * @return - */ - public int evaluate(NodeRef destination, NodeRef linkee, QName assocType) - { - if (linkee != null) - { - int state = checkRead(linkee, true); - if (state != AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_DENIED; - } - } - if (getFilePlanService().isFilePlanComponent(destination)) - { - if ((assocType == null) || !assocType.equals(ContentModel.ASSOC_CONTAINS)) - { - if (linkee == null) - { - if (recordService.isRecord(destination) && - !recordService.isDeclared(destination) && - permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - } - else - { - if (recordService.isRecord(linkee) && - recordService.isRecord(destination) && - !recordService.isDeclared(destination) && - permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - } - - } - - // Build the conditions map - Map conditions = new HashMap(5); - conditions.put("capabilityCondition.filling", Boolean.TRUE); - conditions.put("capabilityCondition.frozen", Boolean.FALSE); - conditions.put("capabilityCondition.closed", Boolean.FALSE); - conditions.put("capabilityCondition.cutoff", Boolean.FALSE); - - // if the destination folder is not a record folder and the user has filling capability on it, grant access to create the record - if (checkConditions(destination, conditions) && - !recordFolderService.isRecordFolder(destination) ) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - - if (checkConditions(destination, conditions) && - recordFolderService.isRecordFolder(destination) && - permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - - conditions.put("capabilityCondition.closed", Boolean.TRUE); - if (checkConditions(destination, conditions) && - recordFolderService.isRecordFolder(destination) && - permissionService.hasPermission(getFilePlanService().getFilePlan(destination), RMPermissionModel.DECLARE_RECORDS_IN_CLOSED_FOLDERS) == AccessStatus.ALLOWED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - - conditions.remove("capabilityCondition.closed"); - conditions.put("capabilityCondition.cutoff", Boolean.TRUE); - if (checkConditions(destination, conditions) && - recordFolderService.isRecordFolder(destination) && - permissionService.hasPermission(getFilePlanService().getFilePlan(destination), RMPermissionModel.CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS) == AccessStatus.ALLOWED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - } - if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_DESTROY_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - if (capabilityService.getCapability(RMPermissionModel.DECLARE_RECORDS_IN_CLOSED_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_DESTROY_FILEPLAN_METADATA).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - if (capabilityService.getCapability(RMPermissionModel.CREATE_HOLD).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - if (((ChangeOrDeleteReferencesCapability)capabilityService.getCapability(RMPermissionModel.CHANGE_OR_DELETE_REFERENCES)).evaluate(destination, linkee) == AccessDecisionVoter.ACCESS_GRANTED) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - return AccessDecisionVoter.ACCESS_DENIED; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import java.util.HashMap; +import java.util.Map; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; + +/** + * Create group capability implementation + * + * @author Andy Hind + */ +public class CreateCapability extends DeclarativeCapability +{ + /** record service */ + private RecordService recordService; + + /** record folder service */ + private RecordFolderService recordFolderService; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public int evaluate(NodeRef nodeRef) + { + return evaluate(nodeRef, null, null); + } + + /** + * Evaluate capability. + * + * @param destination destination node reference + * @param linkee linkee node reference, can be null + * @param assocType association type, can be null + * @return + */ + public int evaluate(NodeRef destination, NodeRef linkee, QName assocType) + { + if (linkee != null) + { + int state = checkRead(linkee, true); + if (state != AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_DENIED; + } + } + if (getFilePlanService().isFilePlanComponent(destination)) + { + if ((assocType == null) || !assocType.equals(ContentModel.ASSOC_CONTAINS)) + { + if (linkee == null) + { + if (recordService.isRecord(destination) && + !recordService.isDeclared(destination) && + permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + } + else + { + if (recordService.isRecord(linkee) && + recordService.isRecord(destination) && + !recordService.isDeclared(destination) && + permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + } + + } + + // Build the conditions map + Map conditions = new HashMap(5); + conditions.put("capabilityCondition.filling", Boolean.TRUE); + conditions.put("capabilityCondition.frozen", Boolean.FALSE); + conditions.put("capabilityCondition.closed", Boolean.FALSE); + conditions.put("capabilityCondition.cutoff", Boolean.FALSE); + + // if the destination folder is not a record folder and the user has filling capability on it, grant access to create the record + if (checkConditions(destination, conditions) && + !recordFolderService.isRecordFolder(destination) ) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + + if (checkConditions(destination, conditions) && + recordFolderService.isRecordFolder(destination) && + permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + + conditions.put("capabilityCondition.closed", Boolean.TRUE); + if (checkConditions(destination, conditions) && + recordFolderService.isRecordFolder(destination) && + permissionService.hasPermission(getFilePlanService().getFilePlan(destination), RMPermissionModel.DECLARE_RECORDS_IN_CLOSED_FOLDERS) == AccessStatus.ALLOWED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + + conditions.remove("capabilityCondition.closed"); + conditions.put("capabilityCondition.cutoff", Boolean.TRUE); + if (checkConditions(destination, conditions) && + recordFolderService.isRecordFolder(destination) && + permissionService.hasPermission(getFilePlanService().getFilePlan(destination), RMPermissionModel.CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS) == AccessStatus.ALLOWED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + } + if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_DESTROY_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + if (capabilityService.getCapability(RMPermissionModel.DECLARE_RECORDS_IN_CLOSED_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + if (capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_DESTROY_FILEPLAN_METADATA).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + if (capabilityService.getCapability(RMPermissionModel.CREATE_HOLD).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + if (((ChangeOrDeleteReferencesCapability)capabilityService.getCapability(RMPermissionModel.CHANGE_OR_DELETE_REFERENCES)).evaluate(destination, linkee) == AccessDecisionVoter.ACCESS_GRANTED) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + return AccessDecisionVoter.ACCESS_DENIED; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/DeleteLinksCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/DeleteLinksCapability.java index e08f019128..06bf985a1e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/DeleteLinksCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/DeleteLinksCapability.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Delete links capability. - * - * @author Roy Wetherall - */ -public class DeleteLinksCapability extends DeclarativeCapability -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public int evaluate(NodeRef nodeRef) - { - // no way to know ... - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - public int evaluate(NodeRef source, NodeRef target) - { - if (getFilePlanService().isFilePlanComponent(source) && - getFilePlanService().isFilePlanComponent(target)) - { - if (checkConditions(source) && - checkConditions(target) && - checkPermissions(source) && - checkPermissions(target)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - return AccessDecisionVoter.ACCESS_DENIED; - } - else - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Delete links capability. + * + * @author Roy Wetherall + */ +public class DeleteLinksCapability extends DeclarativeCapability +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public int evaluate(NodeRef nodeRef) + { + // no way to know ... + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + public int evaluate(NodeRef source, NodeRef target) + { + if (getFilePlanService().isFilePlanComponent(source) && + getFilePlanService().isFilePlanComponent(target)) + { + if (checkConditions(source) && + checkConditions(target) && + checkPermissions(source) && + checkPermissions(target)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + return AccessDecisionVoter.ACCESS_DENIED; + } + else + { + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordMetadataCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordMetadataCapability.java index fa1cc976c6..8416775912 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordMetadataCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordMetadataCapability.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl; -import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Edit non record metadata capability - * - * @author Roy Wetherall - * @since 2.3 - */ -public class EditNonRecordMetadataCapability extends DeclarativeCapability -{ - /** transaction resource helper */ - private TransactionalResourceHelper transactionalResourceHelper; - - /** - * @param transactionalResourceHelper transaction resource helper - */ - public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) - { - this.transactionalResourceHelper = transactionalResourceHelper; - } - - @Override - public int evaluate(NodeRef nodeRef) - { - // check if this node is a new record - if (transactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS).contains(nodeRef)) - { - // since this is a new record created within this transaction, ignore the usual capability check - // under the assumption that the user has CreateRecord - // @see https://issues.alfresco.com/jira/browse/RM-1956 - return AccessDecisionVoter.ACCESS_GRANTED; - } - - return super.evaluate(nodeRef); - } - - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl; +import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Edit non record metadata capability + * + * @author Roy Wetherall + * @since 2.3 + */ +public class EditNonRecordMetadataCapability extends DeclarativeCapability +{ + /** transaction resource helper */ + private TransactionalResourceHelper transactionalResourceHelper; + + /** + * @param transactionalResourceHelper transaction resource helper + */ + public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) + { + this.transactionalResourceHelper = transactionalResourceHelper; + } + + @Override + public int evaluate(NodeRef nodeRef) + { + // check if this node is a new record + if (transactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS).contains(nodeRef)) + { + // since this is a new record created within this transaction, ignore the usual capability check + // under the assumption that the user has CreateRecord + // @see https://issues.alfresco.com/jira/browse/RM-1956 + return AccessDecisionVoter.ACCESS_GRANTED; + } + + return super.evaluate(nodeRef); + } + + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/UpdateCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/UpdateCapability.java index 701a1da03b..24c24d4053 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/UpdateCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/UpdateCapability.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCompositeCapability; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Update capability implementation. - * - * @author andyh - */ -public class UpdateCapability extends DeclarativeCompositeCapability -{ - /** - * Evaluate capability - * - * @param nodeRef node reference - * @param aspectQName aspect qname - * @param properties property values - * @return - */ - public int evaluate(NodeRef nodeRef, QName aspectQName, Map properties) - { - return evaluate(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCompositeCapability; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Update capability implementation. + * + * @author andyh + */ +public class UpdateCapability extends DeclarativeCompositeCapability +{ + /** + * Evaluate capability + * + * @param nodeRef node reference + * @param aspectQName aspect qname + * @param properties property values + * @return + */ + public int evaluate(NodeRef nodeRef, QName aspectQName, Map properties) + { + return evaluate(nodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ViewRecordsCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ViewRecordsCapability.java index e53621d761..9d8437fbe4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ViewRecordsCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/ViewRecordsCapability.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.service.cmr.repository.NodeRef; - -public final class ViewRecordsCapability extends DeclarativeCapability -{ - /** capability name */ - public static final String NAME = "ViewRecords"; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef) - */ - public int evaluate(NodeRef nodeRef) - { - if (nodeRef != null) - { - if (getFilePlanService().isFilePlanComponent(nodeRef)) - { - return checkRmRead(nodeRef); - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("View Records capability abstains, because node is not a file plan component. (nodeRef=" + nodeRef.toString() + ")"); - } - } - } - - return AccessDecisionVoter.ACCESS_ABSTAIN; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.service.cmr.repository.NodeRef; + +public final class ViewRecordsCapability extends DeclarativeCapability +{ + /** capability name */ + public static final String NAME = "ViewRecords"; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef) + */ + public int evaluate(NodeRef nodeRef) + { + if (nodeRef != null) + { + if (getFilePlanService().isFilePlanComponent(nodeRef)) + { + return checkRmRead(nodeRef); + } + else + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("View Records capability abstains, because node is not a file plan component. (nodeRef=" + nodeRef.toString() + ")"); + } + } + } + + return AccessDecisionVoter.ACCESS_ABSTAIN; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AbstractBasePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AbstractBasePolicy.java index b0422e7466..5473d134cd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AbstractBasePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AbstractBasePolicy.java @@ -1,192 +1,192 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.PolicyRegister; -import org.alfresco.module.org_alfresco_module_rm.capability.RMSecurityCommon; -import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.aopalliance.intercept.MethodInvocation; - -/** - * Abstract base policy implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class AbstractBasePolicy extends RMSecurityCommon - implements Policy -{ - /** Capability service */ - private CapabilityService capabilityService; - - /** Policy register */ - private PolicyRegister policyRegister; - - /** Policy name */ - private String name; - - /** - * @param name policy name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy#getName() - */ - @Override - public String getName() - { - return name; - } - - /** - * @return Capability service - */ - protected CapabilityService getCapabilityService() - { - return this.capabilityService; - } - - /** - * @return Policy register - */ - protected PolicyRegister getPolicyRegister() - { - return this.policyRegister; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param policyRegister policy register - */ - public void setPolicyRegister(PolicyRegister policyRegister) - { - this.policyRegister = policyRegister; - } - - /** - * Init method - */ - public void init() - { - getPolicyRegister().registerPolicy(this); - } - - /** - * - * @param invocation - * @param params - * @param position - * @param parent - * @return - */ - @SuppressWarnings("rawtypes") - protected QName getType(MethodInvocation invocation, Class[] params, int position, boolean parent) - { - if (QName.class.isAssignableFrom(params[position])) - { - if (invocation.getArguments()[position] != null) - { - return (QName) invocation.getArguments()[position]; - } - } - else if (NodeRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) - { - NodeRef nodeRef = (NodeRef) invocation.getArguments()[position]; - return nodeService.getType(nodeRef); - } - - return null; - } - - /** - * - * @param invocation - * @param params - * @param position - * @return - */ - @SuppressWarnings("rawtypes") - protected QName getQName(MethodInvocation invocation, Class[] params, int position) - { - if (QName.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) - { - return (QName) invocation.getArguments()[position]; - } - throw new ACLEntryVoterException("Unknown type"); - } - - /** - * - * @param invocation - * @param params - * @param position - * @return - */ - @SuppressWarnings("rawtypes") - protected Serializable getProperty(MethodInvocation invocation, Class[] params, int position) - { - if (invocation.getArguments()[position] == null) - { - return null; - } - if (Serializable.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) - { - return (Serializable) invocation.getArguments()[position]; - } - throw new ACLEntryVoterException("Unknown type"); - } - - /** - * - * @param invocation - * @param params - * @param position - * @return - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected Map getProperties(MethodInvocation invocation, Class[] params, int position) - { - if (invocation.getArguments()[position] == null) - { - return null; - } - if (Map.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) - { - return (Map) invocation.getArguments()[position]; - } - throw new ACLEntryVoterException("Unknown type"); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.PolicyRegister; +import org.alfresco.module.org_alfresco_module_rm.capability.RMSecurityCommon; +import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.aopalliance.intercept.MethodInvocation; + +/** + * Abstract base policy implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class AbstractBasePolicy extends RMSecurityCommon + implements Policy +{ + /** Capability service */ + private CapabilityService capabilityService; + + /** Policy register */ + private PolicyRegister policyRegister; + + /** Policy name */ + private String name; + + /** + * @param name policy name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy#getName() + */ + @Override + public String getName() + { + return name; + } + + /** + * @return Capability service + */ + protected CapabilityService getCapabilityService() + { + return this.capabilityService; + } + + /** + * @return Policy register + */ + protected PolicyRegister getPolicyRegister() + { + return this.policyRegister; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param policyRegister policy register + */ + public void setPolicyRegister(PolicyRegister policyRegister) + { + this.policyRegister = policyRegister; + } + + /** + * Init method + */ + public void init() + { + getPolicyRegister().registerPolicy(this); + } + + /** + * + * @param invocation + * @param params + * @param position + * @param parent + * @return + */ + @SuppressWarnings("rawtypes") + protected QName getType(MethodInvocation invocation, Class[] params, int position, boolean parent) + { + if (QName.class.isAssignableFrom(params[position])) + { + if (invocation.getArguments()[position] != null) + { + return (QName) invocation.getArguments()[position]; + } + } + else if (NodeRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) + { + NodeRef nodeRef = (NodeRef) invocation.getArguments()[position]; + return nodeService.getType(nodeRef); + } + + return null; + } + + /** + * + * @param invocation + * @param params + * @param position + * @return + */ + @SuppressWarnings("rawtypes") + protected QName getQName(MethodInvocation invocation, Class[] params, int position) + { + if (QName.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) + { + return (QName) invocation.getArguments()[position]; + } + throw new ACLEntryVoterException("Unknown type"); + } + + /** + * + * @param invocation + * @param params + * @param position + * @return + */ + @SuppressWarnings("rawtypes") + protected Serializable getProperty(MethodInvocation invocation, Class[] params, int position) + { + if (invocation.getArguments()[position] == null) + { + return null; + } + if (Serializable.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) + { + return (Serializable) invocation.getArguments()[position]; + } + throw new ACLEntryVoterException("Unknown type"); + } + + /** + * + * @param invocation + * @param params + * @param position + * @return + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected Map getProperties(MethodInvocation invocation, Class[] params, int position) + { + if (invocation.getArguments()[position] == null) + { + return null; + } + if (Map.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) + { + return (Map) invocation.getArguments()[position]; + } + throw new ACLEntryVoterException("Unknown type"); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AssocPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AssocPolicy.java index 0db6c2f053..228c61b14d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AssocPolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/AssocPolicy.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -public class AssocPolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability(ViewRecordsCapability.NAME).evaluate(testNodeRef); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +public class AssocPolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + return getCapabilityService().getCapability(ViewRecordsCapability.NAME).evaluate(testNodeRef); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ConfigAttributeDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ConfigAttributeDefinition.java index 0427a00ad4..f5e2150b9b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ConfigAttributeDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ConfigAttributeDefinition.java @@ -1,146 +1,146 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -import net.sf.acegisecurity.ConfigAttribute; - -import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; -import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.QName; - -/** - * RM security configuration definition. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ConfigAttributeDefinition -{ - /** allowable RM security configurations */ - public static final String RM = "RM"; - public static final String RM_ALLOW = "RM_ALLOW"; - public static final String RM_DENY = "RM_DENY"; - public static final String RM_CAP = "RM_CAP"; - public static final String RM_ABSTAIN = "RM_ABSTAIN"; - public static final String RM_QUERY = "RM_QUERY"; - - /** security type */ - private String typeString; - - /** policy name */ - private String policyName; - - /** simple permission reference */ - private SimplePermissionReference required; - - /** parameter position map */ - private Map parameters = new HashMap(2, 1.0f); - - /** is parent */ - private boolean parent = false; - - /** - * Default constructor - * - * @param attr configuration attribute instance - * @param namespacePrefixResolver namespace prefix resolver - */ - public ConfigAttributeDefinition(ConfigAttribute attr, NamespacePrefixResolver namespacePrefixResolver) - { - // tokenize configuration string - StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false); - if (st.countTokens() < 1) - { - throw new ACLEntryVoterException("There must be at least one token in a config attribute"); - } - typeString = st.nextToken(); - - // check that the configuration is valid - if (!(typeString.equals(RM) || - typeString.equals(RM_ALLOW) || - typeString.equals(RM_CAP) || - typeString.equals(RM_DENY) || - typeString.equals(RM_QUERY) || - typeString.equals(RM_ABSTAIN))) - { - throw new ACLEntryVoterException("Invalid type: must be ACL_NODE, ACL_PARENT or ACL_ALLOW"); - } - - if (typeString.equals(RM)) - { - policyName = st.nextToken(); - int position = 0; - while (st.hasMoreElements()) - { - String numberString = st.nextToken(); - Integer value = Integer.parseInt(numberString); - parameters.put(position, value); - position++; - } - } - else if (typeString.equals(RM_CAP)) - { - String numberString = st.nextToken(); - String qNameString = st.nextToken(); - String permissionString = st.nextToken(); - - Integer value = Integer.parseInt(numberString); - parameters.put(0, value); - - QName qName = QName.createQName(qNameString, namespacePrefixResolver); - - required = SimplePermissionReference.getPermissionReference(qName, permissionString); - - if (st.hasMoreElements()) - { - parent = true; - } - } - } - - public String getTypeString() - { - return typeString; - } - - public String getPolicyName() - { - return policyName; - } - - public SimplePermissionReference getRequired() - { - return required; - } - - public Map getParameters() - { - return parameters; - } - - public boolean isParent() - { - return parent; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; + +import net.sf.acegisecurity.ConfigAttribute; + +import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; +import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException; +import org.alfresco.service.namespace.NamespacePrefixResolver; +import org.alfresco.service.namespace.QName; + +/** + * RM security configuration definition. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ConfigAttributeDefinition +{ + /** allowable RM security configurations */ + public static final String RM = "RM"; + public static final String RM_ALLOW = "RM_ALLOW"; + public static final String RM_DENY = "RM_DENY"; + public static final String RM_CAP = "RM_CAP"; + public static final String RM_ABSTAIN = "RM_ABSTAIN"; + public static final String RM_QUERY = "RM_QUERY"; + + /** security type */ + private String typeString; + + /** policy name */ + private String policyName; + + /** simple permission reference */ + private SimplePermissionReference required; + + /** parameter position map */ + private Map parameters = new HashMap(2, 1.0f); + + /** is parent */ + private boolean parent = false; + + /** + * Default constructor + * + * @param attr configuration attribute instance + * @param namespacePrefixResolver namespace prefix resolver + */ + public ConfigAttributeDefinition(ConfigAttribute attr, NamespacePrefixResolver namespacePrefixResolver) + { + // tokenize configuration string + StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false); + if (st.countTokens() < 1) + { + throw new ACLEntryVoterException("There must be at least one token in a config attribute"); + } + typeString = st.nextToken(); + + // check that the configuration is valid + if (!(typeString.equals(RM) || + typeString.equals(RM_ALLOW) || + typeString.equals(RM_CAP) || + typeString.equals(RM_DENY) || + typeString.equals(RM_QUERY) || + typeString.equals(RM_ABSTAIN))) + { + throw new ACLEntryVoterException("Invalid type: must be ACL_NODE, ACL_PARENT or ACL_ALLOW"); + } + + if (typeString.equals(RM)) + { + policyName = st.nextToken(); + int position = 0; + while (st.hasMoreElements()) + { + String numberString = st.nextToken(); + Integer value = Integer.parseInt(numberString); + parameters.put(position, value); + position++; + } + } + else if (typeString.equals(RM_CAP)) + { + String numberString = st.nextToken(); + String qNameString = st.nextToken(); + String permissionString = st.nextToken(); + + Integer value = Integer.parseInt(numberString); + parameters.put(0, value); + + QName qName = QName.createQName(qNameString, namespacePrefixResolver); + + required = SimplePermissionReference.getPermissionReference(qName, permissionString); + + if (st.hasMoreElements()) + { + parent = true; + } + } + } + + public String getTypeString() + { + return typeString; + } + + public String getPolicyName() + { + return policyName; + } + + public SimplePermissionReference getRequired() + { + return required; + } + + public Map getParameters() + { + return parameters; + } + + public boolean isParent() + { + return parent; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CreatePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CreatePolicy.java index 1021ae6f17..23f3247f0f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CreatePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CreatePolicy.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.module.org_alfresco_module_rm.capability.impl.CreateCapability; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.aopalliance.intercept.MethodInvocation; - -public class CreatePolicy extends AbstractBasePolicy -{ - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef linkee = null; - QName assocType = null; - - // get the destination node - NodeRef destination = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - - if (cad.getParameters().size() > 1) - { - // get the linkee when present - linkee = getTestNode(invocation, params, cad.getParameters().get(1), cad.isParent()); - - // get the assoc type - if(cad.getParameters().size() > 2) - { - assocType = getType(invocation, params, cad.getParameters().get(2), cad.isParent()); - } - } - - return ((CreateCapability) getCapabilityService().getCapability("Create")).evaluate(destination, linkee, assocType); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.module.org_alfresco_module_rm.capability.impl.CreateCapability; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.aopalliance.intercept.MethodInvocation; + +public class CreatePolicy extends AbstractBasePolicy +{ + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef linkee = null; + QName assocType = null; + + // get the destination node + NodeRef destination = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + + if (cad.getParameters().size() > 1) + { + // get the linkee when present + linkee = getTestNode(invocation, params, cad.getParameters().get(1), cad.isParent()); + + // get the assoc type + if(cad.getParameters().size() > 2) + { + assocType = getType(invocation, params, cad.getParameters().get(2), cad.isParent()); + } + } + + return ((CreateCapability) getCapabilityService().getCapability("Create")).evaluate(destination, linkee, assocType); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeclarePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeclarePolicy.java index ec52708380..18357fc55a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeclarePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeclarePolicy.java @@ -1,37 +1,37 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -public class DeclarePolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef declaree = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability("Declare").evaluate(declaree); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +public class DeclarePolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef declaree = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + return getCapabilityService().getCapability("Declare").evaluate(declaree); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeletePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeletePolicy.java index ef6dd7256c..4500f64ddc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeletePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/DeletePolicy.java @@ -1,52 +1,52 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -public class DeletePolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef deletee = null; - if (cad.getParameters().get(0) > -1) - { - deletee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - } - if (deletee != null) - { - - return getCapabilityService().getCapability("Delete").evaluate(deletee); - - } - else - { - return AccessDecisionVoter.ACCESS_DENIED; - } - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +public class DeletePolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef deletee = null; + if (cad.getParameters().get(0) > -1) + { + deletee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + } + if (deletee != null) + { + + return getCapabilityService().getCapability("Delete").evaluate(deletee); + + } + else + { + return AccessDecisionVoter.ACCESS_DENIED; + } + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/MovePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/MovePolicy.java index ef087cae9e..1f862fb94a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/MovePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/MovePolicy.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.aopalliance.intercept.MethodInvocation; - -public class MovePolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - - NodeRef movee = null; - if (cad.getParameters().get(0) > -1) - { - movee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - } - - NodeRef destination = null; - if (cad.getParameters().get(1) > -1) - { - destination = getTestNode(invocation, params, cad.getParameters().get(1), cad.isParent()); - } - - if ((movee != null) && (destination != null)) - { - // check that we aren't trying to move something from the DM into RM - if (nodeService.hasAspect(movee, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - return getCapabilityService().getCapability("Move").evaluate(movee, destination); - } - else - { - if (nodeService.hasAspect(destination, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) && - permissionService.hasPermission(destination, RMPermissionModel.FILING).equals(AccessStatus.ALLOWED)) - { - return AccessDecisionVoter.ACCESS_GRANTED; - } - else - { - return AccessDecisionVoter.ACCESS_DENIED; - } - } - } - else - { - return AccessDecisionVoter.ACCESS_DENIED; - } - - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.aopalliance.intercept.MethodInvocation; + +public class MovePolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + + NodeRef movee = null; + if (cad.getParameters().get(0) > -1) + { + movee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + } + + NodeRef destination = null; + if (cad.getParameters().get(1) > -1) + { + destination = getTestNode(invocation, params, cad.getParameters().get(1), cad.isParent()); + } + + if ((movee != null) && (destination != null)) + { + // check that we aren't trying to move something from the DM into RM + if (nodeService.hasAspect(movee, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + return getCapabilityService().getCapability("Move").evaluate(movee, destination); + } + else + { + if (nodeService.hasAspect(destination, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) && + permissionService.hasPermission(destination, RMPermissionModel.FILING).equals(AccessStatus.ALLOWED)) + { + return AccessDecisionVoter.ACCESS_GRANTED; + } + else + { + return AccessDecisionVoter.ACCESS_DENIED; + } + } + } + else + { + return AccessDecisionVoter.ACCESS_DENIED; + } + + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/Policy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/Policy.java index 54d109ef63..5d6f77a14b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/Policy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/Policy.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.aopalliance.intercept.MethodInvocation; - -/** - * Policy interface - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface Policy -{ - /** - * @return policy name - */ - String getName(); - - /** - * Evaluate the policy - * - * @param invocation - * @param params - * @param cad - * @return - */ - @SuppressWarnings("rawtypes") - int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad); +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.aopalliance.intercept.MethodInvocation; + +/** + * Policy interface + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface Policy +{ + /** + * @return policy name + */ + String getName(); + + /** + * Evaluate the policy + * + * @param invocation + * @param params + * @param cad + * @return + */ + @SuppressWarnings("rawtypes") + int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad); } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ReadPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ReadPolicy.java index d86971029e..f1e7e3e857 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ReadPolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/ReadPolicy.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -/** - * Read method security policy. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ReadPolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability(ViewRecordsCapability.NAME).evaluate(testNodeRef); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +/** + * Read method security policy. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ReadPolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + return getCapabilityService().getCapability(ViewRecordsCapability.NAME).evaluate(testNodeRef); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePolicy.java index 85a4413098..2abb48456f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePolicy.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.capability.impl.UpdateCapability; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.aopalliance.intercept.MethodInvocation; - -public class UpdatePolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - QName aspectQName = null; - if (cad.getParameters().size() > 1 && cad.getParameters().get(1) > -1) - { - aspectQName = getQName(invocation, params, cad.getParameters().get(1)); - } - Map properties = null; - if (cad.getParameters().size() > 2 && cad.getParameters().get(2) > -1) - { - properties = getProperties(invocation, params, cad.getParameters().get(2)); - } - - UpdateCapability updateCapability = (UpdateCapability) getCapabilityService().getCapability("Update"); - return updateCapability.evaluate(updatee, aspectQName, properties); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.capability.impl.UpdateCapability; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.aopalliance.intercept.MethodInvocation; + +public class UpdatePolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + QName aspectQName = null; + if (cad.getParameters().size() > 1 && cad.getParameters().get(1) > -1) + { + aspectQName = getQName(invocation, params, cad.getParameters().get(1)); + } + Map properties = null; + if (cad.getParameters().size() > 2 && cad.getParameters().get(2) > -1) + { + properties = getProperties(invocation, params, cad.getParameters().get(2)); + } + + UpdateCapability updateCapability = (UpdateCapability) getCapabilityService().getCapability("Update"); + return updateCapability.evaluate(updatee, aspectQName, properties); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePropertiesPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePropertiesPolicy.java index 02f30dbc1b..b54f0d0d11 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePropertiesPolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/UpdatePropertiesPolicy.java @@ -1,35 +1,35 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -public class UpdatePropertiesPolicy extends AbstractBasePolicy -{ - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef nodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability("UpdateProperties").evaluate(nodeRef); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +public class UpdatePropertiesPolicy extends AbstractBasePolicy +{ + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef nodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + return getCapabilityService().getCapability("UpdateProperties").evaluate(nodeRef); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/WriteContentPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/WriteContentPolicy.java index a9fc180400..08d11084f5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/WriteContentPolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/WriteContentPolicy.java @@ -1,37 +1,37 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.policy; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -public class WriteContentPolicy extends AbstractBasePolicy -{ - - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability("WriteContent").evaluate(updatee); - } - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.policy; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; + +public class WriteContentPolicy extends AbstractBasePolicy +{ + + @SuppressWarnings("rawtypes") + public int evaluate( + MethodInvocation invocation, + Class[] params, + ConfigAttributeDefinition cad) + { + NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); + return getCapabilityService().getCapability("WriteContent").evaluate(updatee); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/PivotUtil.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/PivotUtil.java index a16353e214..a197acb058 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/PivotUtil.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/PivotUtil.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/* package scope */ final class PivotUtil -{ - private PivotUtil() - { - // Will not be called - } - - static Map> getPivot(Map> source) - { - - Map> pivot = new HashMap>(); - - for (Map.Entry> entry : source.entrySet()) - { - Listvalues = entry.getValue(); - for (String value : values) - { - String authority = entry.getKey(); - if (pivot.containsKey(value)) - { - // already exists - List list = pivot.get(value); - list.add(authority ); - } - else - { - // New value - List list = new ArrayList(); - list.add(authority); - pivot.put(value, list); - } - } - } - - return pivot; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/* package scope */ final class PivotUtil +{ + private PivotUtil() + { + // Will not be called + } + + static Map> getPivot(Map> source) + { + + Map> pivot = new HashMap>(); + + for (Map.Entry> entry : source.entrySet()) + { + Listvalues = entry.getValue(); + for (String value : values) + { + String authority = entry.getKey(); + if (pivot.containsKey(value)) + { + // already exists + List list = pivot.get(value); + list.add(authority ); + } + else + { + // New value + List list = new ArrayList(); + list.add(authority); + pivot.put(value, list); + } + } + } + + return pivot; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponent.java index f528c1024b..2e5a9c683f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponent.java @@ -1,112 +1,112 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.io.File; -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public interface RMCaveatConfigComponent -{ - void init(); - - /** - * Get allowed values for given caveat list (for current user) - * - * @param constraintName - * @return - */ - List getRMAllowedValues(String constraintName); - - /** - * Get custom caveat models - * - * @return - */ - List getRMCaveatModels(); - - /** - * Check whether access to 'record component' node is vetoed for current user due to caveat(s) - * - * @param nodeRef - * @return false, if caveat(s) veto access otherwise return true - */ - boolean hasAccess(NodeRef nodeRef); - - /** - * Get RM constraint list - * - * @param listName the name of the RMConstraintList - */ - RMConstraintInfo getRMConstraint(String listName); - - /** - * Add RM constraint - */ - void addRMConstraint(String listName); - - /** - * Add RM constraint value for given authority - */ - void addRMConstraintListValue(String listName, String authorityName, String value); - - /** - * Update RM constraint values for given authority - */ - void updateRMConstraintListAuthority(String listName, String authorityName, Listvalues); - - /** - * Update RM constraint authorities for given value - */ - void updateRMConstraintListValue(String listName, String valueName, Listauthorities); - - /** - * Remove RM constraint value (all authorities) - */ - void removeRMConstraintListValue(String listName, String valueName); - - /** - * Remove RM constraint authority (all values) - */ - void removeRMConstraintListAuthority(String listName, String authorityName); - - /** - * Delete RM Constraint - * - * @param listName the name of the RMConstraintList - */ - void deleteRMConstraint(String listName); - - /** - * Get the details of a caveat list - * @param listName - * @return - */ - Map> getListDetails(String listName); - - NodeRef updateOrCreateCaveatConfig(File jsonFile); - - NodeRef updateOrCreateCaveatConfig(String jsonString); - - NodeRef updateOrCreateCaveatConfig(InputStream is); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.io.File; +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +public interface RMCaveatConfigComponent +{ + void init(); + + /** + * Get allowed values for given caveat list (for current user) + * + * @param constraintName + * @return + */ + List getRMAllowedValues(String constraintName); + + /** + * Get custom caveat models + * + * @return + */ + List getRMCaveatModels(); + + /** + * Check whether access to 'record component' node is vetoed for current user due to caveat(s) + * + * @param nodeRef + * @return false, if caveat(s) veto access otherwise return true + */ + boolean hasAccess(NodeRef nodeRef); + + /** + * Get RM constraint list + * + * @param listName the name of the RMConstraintList + */ + RMConstraintInfo getRMConstraint(String listName); + + /** + * Add RM constraint + */ + void addRMConstraint(String listName); + + /** + * Add RM constraint value for given authority + */ + void addRMConstraintListValue(String listName, String authorityName, String value); + + /** + * Update RM constraint values for given authority + */ + void updateRMConstraintListAuthority(String listName, String authorityName, Listvalues); + + /** + * Update RM constraint authorities for given value + */ + void updateRMConstraintListValue(String listName, String valueName, Listauthorities); + + /** + * Remove RM constraint value (all authorities) + */ + void removeRMConstraintListValue(String listName, String valueName); + + /** + * Remove RM constraint authority (all values) + */ + void removeRMConstraintListAuthority(String listName, String authorityName); + + /** + * Delete RM Constraint + * + * @param listName the name of the RMConstraintList + */ + void deleteRMConstraint(String listName); + + /** + * Get the details of a caveat list + * @param listName + * @return + */ + Map> getListDetails(String listName); + + NodeRef updateOrCreateCaveatConfig(File jsonFile); + + NodeRef updateOrCreateCaveatConfig(String jsonString); + + NodeRef updateOrCreateCaveatConfig(InputStream is); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java index 84f39925c5..7a566a708c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.caveat; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigService.java index 9a53593505..700edd3bc6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigService.java @@ -1,152 +1,152 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.io.File; -import java.io.InputStream; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; - -public interface RMCaveatConfigService -{ - void init(); - - /** - * Get allowed values for given caveat list (for current user) - * @param constraintName - * @return - */ - List getRMAllowedValues(String constraintName); - - /** - * Check whether access to 'record component' node is vetoed for current user due to caveat(s) - * - * @param nodeRef - * @return false, if caveat(s) veto access otherwise return true - */ - boolean hasAccess(NodeRef nodeRef); - - /* - * Get a single RM constraint - */ - RMConstraintInfo getRMConstraint(String listName); - - /* - * Get the names of all the caveat lists - */ - Set getAllRMConstraints(); - - /** - * Get the details of a caveat list - * @param listName - * @return - */ - Map> getListDetails(String listName); - - NodeRef updateOrCreateCaveatConfig(File jsonFile); - - NodeRef updateOrCreateCaveatConfig(String jsonString); - - NodeRef updateOrCreateCaveatConfig(InputStream is); - - /** - * add RM constraint list - * @param listName the name of the RMConstraintList - * @param listTitle - */ - RMConstraintInfo addRMConstraint(String listName, String listTitle, String[] allowedValues); - - /** - * update RM constraint list allowed values - * @param listName the name of the RMConstraintList - can not be changed - * @param allowedValues - */ - RMConstraintInfo updateRMConstraintAllowedValues(String listName, String[] allowedValues); - - /** - * update RM constraint Title - * @param listName the name of the RMConstraintList - can not be changed - * @param allowedValues - */ - RMConstraintInfo updateRMConstraintTitle(String listName, String newTitle); - - - /** - * delete RM Constraint - * - * @param listName the name of the RMConstraintList - */ - void deleteRMConstraint(String listName); - - /** - * Add a single value to an authority in a list. The existing values of the list remain. - * - * @param listName the name of the RMConstraintList - * @param authorityName - * @param values - * @throws AlfrescoRuntimeException if either the list or the authority do not already exist. - */ - void addRMConstraintListValue(String listName, String authorityName, String value); - - /** - * Replace the values for an authority in a list. - * The existing values are removed. - * - * If the authority does not already exist in the list, it will be added - * - * @param listName the name of the RMConstraintList - * @param authorityName - * @param values - */ - void updateRMConstraintListAuthority(String listName, String authorityName, Listvalues); - - /** - * Remove an authority from a list - * - * @param listName the name of the RMConstraintList - * @param authorityName - * @param values - */ - void removeRMConstraintListAuthority(String listName, String authorityName); - - /** - * Replace the values for an authority in a list. - * The existing values are removed. - * - * If the authority does not already exist in the list, it will be added - * - * @param listName the name of the RMConstraintList - * @param value - * @param authorities - */ - void updateRMConstraintListValue(String listName, String value, Listauthorities); - - /** - * Remove an authority from a list - * - * @param listName the name of the RMConstraintList - * @param authorityName - * @param value - */ - void removeRMConstraintListValue(String listName, String valueName); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.io.File; +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.repository.NodeRef; + +public interface RMCaveatConfigService +{ + void init(); + + /** + * Get allowed values for given caveat list (for current user) + * @param constraintName + * @return + */ + List getRMAllowedValues(String constraintName); + + /** + * Check whether access to 'record component' node is vetoed for current user due to caveat(s) + * + * @param nodeRef + * @return false, if caveat(s) veto access otherwise return true + */ + boolean hasAccess(NodeRef nodeRef); + + /* + * Get a single RM constraint + */ + RMConstraintInfo getRMConstraint(String listName); + + /* + * Get the names of all the caveat lists + */ + Set getAllRMConstraints(); + + /** + * Get the details of a caveat list + * @param listName + * @return + */ + Map> getListDetails(String listName); + + NodeRef updateOrCreateCaveatConfig(File jsonFile); + + NodeRef updateOrCreateCaveatConfig(String jsonString); + + NodeRef updateOrCreateCaveatConfig(InputStream is); + + /** + * add RM constraint list + * @param listName the name of the RMConstraintList + * @param listTitle + */ + RMConstraintInfo addRMConstraint(String listName, String listTitle, String[] allowedValues); + + /** + * update RM constraint list allowed values + * @param listName the name of the RMConstraintList - can not be changed + * @param allowedValues + */ + RMConstraintInfo updateRMConstraintAllowedValues(String listName, String[] allowedValues); + + /** + * update RM constraint Title + * @param listName the name of the RMConstraintList - can not be changed + * @param allowedValues + */ + RMConstraintInfo updateRMConstraintTitle(String listName, String newTitle); + + + /** + * delete RM Constraint + * + * @param listName the name of the RMConstraintList + */ + void deleteRMConstraint(String listName); + + /** + * Add a single value to an authority in a list. The existing values of the list remain. + * + * @param listName the name of the RMConstraintList + * @param authorityName + * @param values + * @throws AlfrescoRuntimeException if either the list or the authority do not already exist. + */ + void addRMConstraintListValue(String listName, String authorityName, String value); + + /** + * Replace the values for an authority in a list. + * The existing values are removed. + * + * If the authority does not already exist in the list, it will be added + * + * @param listName the name of the RMConstraintList + * @param authorityName + * @param values + */ + void updateRMConstraintListAuthority(String listName, String authorityName, Listvalues); + + /** + * Remove an authority from a list + * + * @param listName the name of the RMConstraintList + * @param authorityName + * @param values + */ + void removeRMConstraintListAuthority(String listName, String authorityName); + + /** + * Replace the values for an authority in a list. + * The existing values are removed. + * + * If the authority does not already exist in the list, it will be added + * + * @param listName the name of the RMConstraintList + * @param value + * @param authorities + */ + void updateRMConstraintListValue(String listName, String value, Listauthorities); + + /** + * Remove an authority from a list + * + * @param listName the name of the RMConstraintList + * @param authorityName + * @param value + */ + void removeRMConstraintListValue(String listName, String valueName); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigServiceImpl.java index b3e201d098..2718358013 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigServiceImpl.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.caveat; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMConstraintInfo.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMConstraintInfo.java index c5f68475ae..734c30c439 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMConstraintInfo.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMConstraintInfo.java @@ -1,79 +1,79 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.util.Arrays; - -public class RMConstraintInfo -{ - private String name; - private String title; - private boolean caseSensitive; - private String[] allowedValues; - - public void setName(String name) - { - this.name = name; - } - public String getName() - { - return name; - } - public void setTitle(String title) - { - this.title = title; - } - public String getTitle() - { - return title; - } - public void setCaseSensitive(boolean caseSensitive) - { - this.caseSensitive = caseSensitive; - } - public boolean isCaseSensitive() - { - return caseSensitive; - } - public void setAllowedValues(String[] values) - { - this.allowedValues = values.clone(); - } - public String[] getAllowedValues() - { - return allowedValues; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("RMConstraintInfo [name="); - builder.append(this.name); - builder.append(", title="); - builder.append(this.title); - builder.append(", caseSensitive="); - builder.append(this.caseSensitive); - builder.append(", allowedValues="); - builder.append(Arrays.toString(this.allowedValues)); - builder.append("]"); - return builder.toString(); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.util.Arrays; + +public class RMConstraintInfo +{ + private String name; + private String title; + private boolean caseSensitive; + private String[] allowedValues; + + public void setName(String name) + { + this.name = name; + } + public String getName() + { + return name; + } + public void setTitle(String title) + { + this.title = title; + } + public String getTitle() + { + return title; + } + public void setCaseSensitive(boolean caseSensitive) + { + this.caseSensitive = caseSensitive; + } + public boolean isCaseSensitive() + { + return caseSensitive; + } + public void setAllowedValues(String[] values) + { + this.allowedValues = values.clone(); + } + public String[] getAllowedValues() + { + return allowedValues; + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("RMConstraintInfo [name="); + builder.append(this.name); + builder.append(", title="); + builder.append(this.title); + builder.append(", caseSensitive="); + builder.append(this.caseSensitive); + builder.append(", allowedValues="); + builder.append(Arrays.toString(this.allowedValues)); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java index 356ac485bc..3251989683 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.caveat; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptAuthority.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptAuthority.java index 8ea2fdc57d..5c969381ac 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptAuthority.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptAuthority.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.io.Serializable; - - -public class ScriptAuthority implements Serializable -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String authorityTitle; - private String authorityName; - - public void setAuthorityName(String authorityName) - { - this.authorityName = authorityName; - } - public String getAuthorityName() - { - return authorityName; - } - public void setAuthorityTitle(String authorityName) - { - this.authorityTitle = authorityName; - } - public String getAuthorityTitle() - { - return authorityTitle; - } - - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.io.Serializable; + + +public class ScriptAuthority implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = 1L; + private String authorityTitle; + private String authorityName; + + public void setAuthorityName(String authorityName) + { + this.authorityName = authorityName; + } + public String getAuthorityName() + { + return authorityName; + } + public void setAuthorityTitle(String authorityName) + { + this.authorityTitle = authorityName; + } + public String getAuthorityTitle() + { + return authorityTitle; + } + + +} 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 7bf068013c..cb8b16809a 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 @@ -1,262 +1,262 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.io.Serializable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -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.authorityService = authorityService; - } - - public void setTitle(String title) - { - info.setTitle(title); - } - public String getTitle() - { - return info.getTitle(); - } - public void setName(String name) - { - info.setName(name); - } - - public String getName() - { - return info.getName().replace(":", "_"); - } - - 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); - } - - ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]); - - return retVal; - } - - /** - * updateTitle - */ - public void updateTitle(String newTitle) - { - info.setTitle(newTitle); - rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ; - } - - /** - * updateAllowedValues - */ - public void updateAllowedValues(String[] allowedValues) - { - info.setAllowedValues(allowedValues); - rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues); - } - - /** - * Update a value - * @param values - * @param authorities - */ - public void updateValues(JSONArray bodge) throws Exception - { - for(int i = 0; i < bodge.length(); i++) - { - - JSONObject obj = bodge.getJSONObject(i); - String value = obj.getString("value"); - JSONArray authorities = obj.getJSONArray("authorities"); - List aList = new ArrayList(); - for(int j = 0; j < authorities.length();j++) - { - aList.add(authorities.getString(j)); - } - rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList); - } - } - - /** - * Update a value - * @param values - * @param authorities - */ - public void updateValues(String value, String[] authorities) - { - List list = Arrays.asList(authorities); - 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 - * @param value - * @return - */ - public ScriptConstraintValue getValue(String value) - { - ScriptConstraintValue[] values = getValues(); - - for(ScriptConstraintValue val : values) - { - if(val.getValueName().equalsIgnoreCase(value)) - { - return val; - } - } - 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(StringUtils.isNotBlank(displayName)) - { - a.setAuthorityTitle(displayName); - } - else - { - a.setAuthorityTitle(authority); - } - sauth.add(a); - } - constraint.setAuthorities(sauth); - constraints.add(constraint); - } - - /** - * Now go through and add any "empty" values - */ - for(String value : info.getAllowedValues()) - { - if(!values.contains(value)) - { - ScriptConstraintValue constraint = new ScriptConstraintValue(); - constraint.setValueName(value); - constraint.setValueTitle(value); - List sauth = new ArrayList(); - constraint.setAuthorities(sauth); - constraints.add(constraint); - } - } - - return constraints.toArray(new ScriptConstraintValue[constraints.size()]); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.io.Serializable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +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.authorityService = authorityService; + } + + public void setTitle(String title) + { + info.setTitle(title); + } + public String getTitle() + { + return info.getTitle(); + } + public void setName(String name) + { + info.setName(name); + } + + public String getName() + { + return info.getName().replace(":", "_"); + } + + 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); + } + + ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]); + + return retVal; + } + + /** + * updateTitle + */ + public void updateTitle(String newTitle) + { + info.setTitle(newTitle); + rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ; + } + + /** + * updateAllowedValues + */ + public void updateAllowedValues(String[] allowedValues) + { + info.setAllowedValues(allowedValues); + rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues); + } + + /** + * Update a value + * @param values + * @param authorities + */ + public void updateValues(JSONArray bodge) throws Exception + { + for(int i = 0; i < bodge.length(); i++) + { + + JSONObject obj = bodge.getJSONObject(i); + String value = obj.getString("value"); + JSONArray authorities = obj.getJSONArray("authorities"); + List aList = new ArrayList(); + for(int j = 0; j < authorities.length();j++) + { + aList.add(authorities.getString(j)); + } + rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList); + } + } + + /** + * Update a value + * @param values + * @param authorities + */ + public void updateValues(String value, String[] authorities) + { + List list = Arrays.asList(authorities); + 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 + * @param value + * @return + */ + public ScriptConstraintValue getValue(String value) + { + ScriptConstraintValue[] values = getValues(); + + for(ScriptConstraintValue val : values) + { + if(val.getValueName().equalsIgnoreCase(value)) + { + return val; + } + } + 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(StringUtils.isNotBlank(displayName)) + { + a.setAuthorityTitle(displayName); + } + else + { + a.setAuthorityTitle(authority); + } + sauth.add(a); + } + constraint.setAuthorities(sauth); + constraints.add(constraint); + } + + /** + * Now go through and add any "empty" values + */ + for(String value : info.getAllowedValues()) + { + if(!values.contains(value)) + { + ScriptConstraintValue constraint = new ScriptConstraintValue(); + constraint.setValueName(value); + constraint.setValueTitle(value); + List sauth = new ArrayList(); + constraint.setAuthorities(sauth); + constraints.add(constraint); + } + } + + return constraints.toArray(new ScriptConstraintValue[constraints.size()]); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintAuthority.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintAuthority.java index 3e54ad06bd..86ab1699de 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintAuthority.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintAuthority.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.util.List; -import java.io.Serializable; - -public class ScriptConstraintAuthority implements Serializable -{ - /** - * - */ - private static final long serialVersionUID = -4659454215122271811L; - private String authorityName; - private Listvalues; - - public void setValues(List values) - { - this.values = values; - } - public List getValues() - { - return values; - } - public void setAuthorityName(String authorityName) - { - this.authorityName = authorityName; - } - public String getAuthorityName() - { - return authorityName; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.util.List; +import java.io.Serializable; + +public class ScriptConstraintAuthority implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = -4659454215122271811L; + private String authorityName; + private Listvalues; + + public void setValues(List values) + { + this.values = values; + } + public List getValues() + { + return values; + } + public void setAuthorityName(String authorityName) + { + this.authorityName = authorityName; + } + public String getAuthorityName() + { + return authorityName; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintValue.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintValue.java index 8b4a163df0..014ef67fa9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintValue.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraintValue.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.util.List; -import java.io.Serializable; - -public class ScriptConstraintValue implements Serializable -{ - /** - * - */ - private static final long serialVersionUID = -4659454215122271811L; - private String value; - private Listauthorities; - - public void setAuthorities(List values) - { - this.authorities = values; - } - public List getAuthorities() - { - return authorities; - } - public void setValueName(String authorityName) - { - this.value = authorityName; - } - public String getValueName() - { - return value; - } - public void setValueTitle(String authorityName) - { - this.value = authorityName; - } - public String getValueTitle() - { - return value; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.util.List; +import java.io.Serializable; + +public class ScriptConstraintValue implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = -4659454215122271811L; + private String value; + private Listauthorities; + + public void setAuthorities(List values) + { + this.authorities = values; + } + public List getAuthorities() + { + return authorities; + } + public void setValueName(String authorityName) + { + this.value = authorityName; + } + public String getValueName() + { + return value; + } + public void setValueTitle(String authorityName) + { + this.value = authorityName; + } + public String getValueTitle() + { + return value; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptRMCaveatConfigService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptRMCaveatConfigService.java index 4f186e673e..fff04ad18e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptRMCaveatConfigService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptRMCaveatConfigService.java @@ -1,165 +1,165 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.alfresco.repo.jscript.BaseScopableProcessorExtension; -import org.alfresco.service.cmr.security.AuthorityService; - -/** - * Script projection of RM Caveat Config Service - * - * @author Mark Rogers - */ -public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension -{ - private RMCaveatConfigService caveatConfigService; - private AuthorityService authorityService; - - public void setCaveatConfigService(RMCaveatConfigService rmCaveatConfigService) - { - this.caveatConfigService = rmCaveatConfigService; - } - - public RMCaveatConfigService getRmCaveatConfigService() - { - return caveatConfigService; - } - - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - public AuthorityService getAuthorityService() - { - return authorityService; - } - - public ScriptConstraint getConstraint(String listName) - { - //TODO Temporary conversion - String xxx = listName.replace("_", ":"); - - RMConstraintInfo info = caveatConfigService.getRMConstraint(xxx); - - if(info != null) - { - return new ScriptConstraint(info, caveatConfigService, getAuthorityService()); - } - - return null; - } - - public ScriptConstraint[] getAllConstraints() - { - return getConstraints(true); - } - - public ScriptConstraint[] getConstraintsWithoutEmptyList() - { - return getConstraints(false); - } - - private ScriptConstraint[] getConstraints(boolean includeEmptyList) - { - Set values = caveatConfigService.getAllRMConstraints(); - - List vals = new ArrayList(values.size()); - for(RMConstraintInfo value : values) - { - ScriptConstraint c = new ScriptConstraint(value, caveatConfigService, getAuthorityService()); - if (includeEmptyList) - { - vals.add(c); - } - else - { - if (c.getValues().length > 0) - { - vals.add(c); - } - } - } - - return vals.toArray(new ScriptConstraint[vals.size()]); - } - - /** - * Delete list - * @param listName - - */ - public void deleteConstraintList(String listName) - { - //TODO Temporary conversion - String xxx = listName.replace("_", ":"); - caveatConfigService.deleteRMConstraint(xxx); - } - - - - /** - * Update value - */ - public void updateConstraintValues(String listName, String authorityName, String[]values) - { - List vals = new ArrayList(); - caveatConfigService.updateRMConstraintListAuthority(listName, authorityName, vals); - } - - /** - * Delete the constraint values. i.e remove an authority from a constraint list - */ - public void deleteRMConstraintListAuthority(String listName, String authorityName) - { - //TODO Temporary conversion - String xxx = listName.replace("_", ":"); - - caveatConfigService.removeRMConstraintListAuthority(xxx, authorityName); - } - - /** - * Delete the constraint values. i.e remove a value from a constraint list - */ - public void deleteRMConstraintListValue(String listName, String valueName) - { - //TODO Temporary conversion - String xxx = listName.replace("_", ":"); - - caveatConfigService.removeRMConstraintListValue(xxx, valueName); - - } - - public ScriptConstraint createConstraint(String listName, String title, String[] allowedValues) - { - //TODO Temporary conversion - if(listName != null) - { - listName = listName.replace("_", ":"); - } - - RMConstraintInfo info = caveatConfigService.addRMConstraint(listName, title, allowedValues); - return new ScriptConstraint(info, caveatConfigService, getAuthorityService()); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.caveat; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.alfresco.repo.jscript.BaseScopableProcessorExtension; +import org.alfresco.service.cmr.security.AuthorityService; + +/** + * Script projection of RM Caveat Config Service + * + * @author Mark Rogers + */ +public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension +{ + private RMCaveatConfigService caveatConfigService; + private AuthorityService authorityService; + + public void setCaveatConfigService(RMCaveatConfigService rmCaveatConfigService) + { + this.caveatConfigService = rmCaveatConfigService; + } + + public RMCaveatConfigService getRmCaveatConfigService() + { + return caveatConfigService; + } + + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + public AuthorityService getAuthorityService() + { + return authorityService; + } + + public ScriptConstraint getConstraint(String listName) + { + //TODO Temporary conversion + String xxx = listName.replace("_", ":"); + + RMConstraintInfo info = caveatConfigService.getRMConstraint(xxx); + + if(info != null) + { + return new ScriptConstraint(info, caveatConfigService, getAuthorityService()); + } + + return null; + } + + public ScriptConstraint[] getAllConstraints() + { + return getConstraints(true); + } + + public ScriptConstraint[] getConstraintsWithoutEmptyList() + { + return getConstraints(false); + } + + private ScriptConstraint[] getConstraints(boolean includeEmptyList) + { + Set values = caveatConfigService.getAllRMConstraints(); + + List vals = new ArrayList(values.size()); + for(RMConstraintInfo value : values) + { + ScriptConstraint c = new ScriptConstraint(value, caveatConfigService, getAuthorityService()); + if (includeEmptyList) + { + vals.add(c); + } + else + { + if (c.getValues().length > 0) + { + vals.add(c); + } + } + } + + return vals.toArray(new ScriptConstraint[vals.size()]); + } + + /** + * Delete list + * @param listName + + */ + public void deleteConstraintList(String listName) + { + //TODO Temporary conversion + String xxx = listName.replace("_", ":"); + caveatConfigService.deleteRMConstraint(xxx); + } + + + + /** + * Update value + */ + public void updateConstraintValues(String listName, String authorityName, String[]values) + { + List vals = new ArrayList(); + caveatConfigService.updateRMConstraintListAuthority(listName, authorityName, vals); + } + + /** + * Delete the constraint values. i.e remove an authority from a constraint list + */ + public void deleteRMConstraintListAuthority(String listName, String authorityName) + { + //TODO Temporary conversion + String xxx = listName.replace("_", ":"); + + caveatConfigService.removeRMConstraintListAuthority(xxx, authorityName); + } + + /** + * Delete the constraint values. i.e remove a value from a constraint list + */ + public void deleteRMConstraintListValue(String listName, String valueName) + { + //TODO Temporary conversion + String xxx = listName.replace("_", ":"); + + caveatConfigService.removeRMConstraintListValue(xxx, valueName); + + } + + public ScriptConstraint createConstraint(String listName, String title, String[] allowedValues) + { + //TODO Temporary conversion + if(listName != null) + { + listName = listName.replace("_", ":"); + } + + RMConstraintInfo info = caveatConfigService.addRMConstraint(listName, title, allowedValues); + return new ScriptConstraint(info, caveatConfigService, getAuthorityService()); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSet.java index 6b1cd590c9..6197130ff8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSet.java @@ -1,27 +1,27 @@ -package org.alfresco.module.org_alfresco_module_rm.dataset; - -public interface DataSet -{ - - /** - * Gets the label of the data set - * - * @return String the label of the data set - */ - String getLabel(); - - /** - * Gets the id of the data set - * - * @return String the id of the data set - */ - String getId(); - - /** - * Gets the path of the data set - * - * @return String the path of the data set - */ - String getPath(); - -} +package org.alfresco.module.org_alfresco_module_rm.dataset; + +public interface DataSet +{ + + /** + * Gets the label of the data set + * + * @return String the label of the data set + */ + String getLabel(); + + /** + * Gets the id of the data set + * + * @return String the id of the data set + */ + String getId(); + + /** + * Gets the path of the data set + * + * @return String the path of the data set + */ + String getPath(); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java index 03ce9d5fd3..cd913777e7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java @@ -1,103 +1,103 @@ -package org.alfresco.module.org_alfresco_module_rm.dataset; - -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -public class DataSetBase implements DataSet -{ - - /** Data set service */ - private DataSetService dataSetService; - - /** Data set label */ - private String label; - - /** Data set id */ - private String id; - - /** Data set path */ - private String path; - - /** - * Sets the data set service - * - * @param dataSetService the data set service - */ - public void setDataSetService(DataSetService dataSetService) - { - this.dataSetService = dataSetService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getLabel() - */ - public String getLabel() - { - String label = this.label; - if (StringUtils.isBlank(label)) - { - String propertyKey = "dataset." + getId() + ".label"; - label = I18NUtil.getMessage(propertyKey); - if (StringUtils.isBlank(label)) - { - label = propertyKey; - } - } - return label; - } - - /** - * Sets the label of the data set service - * - * @param label the label - */ - public void setLabel(String label) - { - this.label = label; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getId() - */ - public String getId() - { - return this.id; - } - - /** - * Sets the id of the data set service - * - * @param id the id - */ - public void setId(String id) - { - this.id = id; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getPath() - */ - public String getPath() - { - return this.path; - } - - /** - * Sets the path of the data set service - * - * @param path the path - */ - public void setPath(String path) - { - this.path = path; - } - - /** - * Registers the data set implementation with the data set service. - */ - public void register() - { - this.dataSetService.register(this); - } - -} +package org.alfresco.module.org_alfresco_module_rm.dataset; + +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +public class DataSetBase implements DataSet +{ + + /** Data set service */ + private DataSetService dataSetService; + + /** Data set label */ + private String label; + + /** Data set id */ + private String id; + + /** Data set path */ + private String path; + + /** + * Sets the data set service + * + * @param dataSetService the data set service + */ + public void setDataSetService(DataSetService dataSetService) + { + this.dataSetService = dataSetService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getLabel() + */ + public String getLabel() + { + String label = this.label; + if (StringUtils.isBlank(label)) + { + String propertyKey = "dataset." + getId() + ".label"; + label = I18NUtil.getMessage(propertyKey); + if (StringUtils.isBlank(label)) + { + label = propertyKey; + } + } + return label; + } + + /** + * Sets the label of the data set service + * + * @param label the label + */ + public void setLabel(String label) + { + this.label = label; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getId() + */ + public String getId() + { + return this.id; + } + + /** + * Sets the id of the data set service + * + * @param id the id + */ + public void setId(String id) + { + this.id = id; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSet#getPath() + */ + public String getPath() + { + return this.path; + } + + /** + * Sets the path of the data set service + * + * @param path the path + */ + public void setPath(String path) + { + this.path = path; + } + + /** + * Registers the data set implementation with the data set service. + */ + public void register() + { + this.dataSetService.register(this); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetService.java index 4244038633..49977f674f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetService.java @@ -1,76 +1,76 @@ -package org.alfresco.module.org_alfresco_module_rm.dataset; - -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - -public interface DataSetService -{ - - /** - * Register a data set implementation with the service - * - * @param dataSet the data set - */ - void register(DataSet dataSet); - - /** - * Gets the details of all available data sets. - * - * @return Map details of all available data sets - */ - Map getDataSets(); - - /** - * Gets the details of all available data sets for a file plan depending on - * the parameter "excludeLoaded". - * - * @param filePlan the file plan for which the details should be retrieved - * @param excludeLoaded if true only data sets will be retrieved which has - * not been loaded - * @return Map details of the available data sets for a - * specified file plan depending on the parameter "excludeLoaded". - * The result could also be an empty map - */ - Map getDataSets(NodeRef filePlan, boolean excludeLoaded); - - /** - * Gets the details of all loaded data sets for a specified file plan - * - * @param filePlan the file plan for which the loaded data sets should be - * retrieved - * @return Map details of all loaded data sets or an empty - * map if there has not been any data sets loaded for the specified - * file plan - */ - Map getLoadedDataSets(NodeRef filePlan); - - /** - * Loads the data set with the specified id into the specified file plan - * - * @param filePlan the file plan which the data set will load into - * @param dataSetId the id of the data set which will be imported - */ - void loadDataSet(NodeRef filePlan, String dataSetId); - - /** - * Checks if a data set exists with the given data set id - * - * @param dataSetId the id of the data set which will be checked - * @return true if the data set exists, false otherwise - */ - boolean existsDataSet(String dataSetId); - - /** - * Checks if a data set with the id "dataSetId" has been loaded into the - * specified file plan - * - * @param filePlan the file plan for which the check should be done - * @param dataSetId the id of the data set which should be checked if it has - * been loaded to the file plan - * @return true if the data set with the specified id has been loaded into - * the specified file plan, false otherwise - */ - boolean isLoadedDataSet(NodeRef filePlan, String dataSetId); - -} +package org.alfresco.module.org_alfresco_module_rm.dataset; + +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + +public interface DataSetService +{ + + /** + * Register a data set implementation with the service + * + * @param dataSet the data set + */ + void register(DataSet dataSet); + + /** + * Gets the details of all available data sets. + * + * @return Map details of all available data sets + */ + Map getDataSets(); + + /** + * Gets the details of all available data sets for a file plan depending on + * the parameter "excludeLoaded". + * + * @param filePlan the file plan for which the details should be retrieved + * @param excludeLoaded if true only data sets will be retrieved which has + * not been loaded + * @return Map details of the available data sets for a + * specified file plan depending on the parameter "excludeLoaded". + * The result could also be an empty map + */ + Map getDataSets(NodeRef filePlan, boolean excludeLoaded); + + /** + * Gets the details of all loaded data sets for a specified file plan + * + * @param filePlan the file plan for which the loaded data sets should be + * retrieved + * @return Map details of all loaded data sets or an empty + * map if there has not been any data sets loaded for the specified + * file plan + */ + Map getLoadedDataSets(NodeRef filePlan); + + /** + * Loads the data set with the specified id into the specified file plan + * + * @param filePlan the file plan which the data set will load into + * @param dataSetId the id of the data set which will be imported + */ + void loadDataSet(NodeRef filePlan, String dataSetId); + + /** + * Checks if a data set exists with the given data set id + * + * @param dataSetId the id of the data set which will be checked + * @return true if the data set exists, false otherwise + */ + boolean existsDataSet(String dataSetId); + + /** + * Checks if a data set with the id "dataSetId" has been loaded into the + * specified file plan + * + * @param filePlan the file plan for which the check should be done + * @param dataSetId the id of the data set which should be checked if it has + * been loaded to the file plan + * @return true if the data set with the specified id has been loaded into + * the specified file plan, false otherwise + */ + boolean isLoadedDataSet(NodeRef filePlan, String dataSetId); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java index 54ce6c8c74..c73cdee074 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java @@ -1,497 +1,497 @@ -package org.alfresco.module.org_alfresco_module_rm.dataset; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authority.RMAuthority; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.view.ImporterService; -import org.alfresco.service.cmr.view.Location; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class DataSetServiceImpl implements DataSetService, RecordsManagementModel -{ - - /** Logger */ - private static Log logger = LogFactory.getLog(DataSetServiceImpl.class); - - /** Registered data set implementations */ - private Map dataSets = new HashMap(); - - /** Spaces store */ - private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - - /** Charset name */ - private static final String CHARSET_NAME = "UTF-8"; - - /** Importer service */ - private ImporterService importerService; - - /** Search service */ - private SearchService searchService; - - /** Node service */ - private NodeService nodeService; - - /** File plan service service */ - private FilePlanService filePlanService; - - /** Permission service */ - private PermissionService permissionService; - - /** Authority service */ - private AuthorityService authorityService; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** Records management search behaviour */ - private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** - * Set importer service - * - * @param importerService the importer service - */ - public void setImporterService(ImporterService importerService) - { - this.importerService = importerService; - } - - /** - * Set search service - * - * @param searchService the search service - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * Set node service - * - * @param nodeService the node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set file plan service - * - * @param filePlanService the file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Set permission service - * - * @param permissionService the permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * Set authority service - * - * @param authorityService the authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * Set records management search behaviour - * - * @param recordsManagementSearchBehaviour the records management search - * behaviour - */ - public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour recordsManagementSearchBehaviour) - { - this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour; - } - - /** - * Set disposition service - * - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Set record folder service - * - * @param recordFolderService the record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#register(org.alfresco.module.org_alfresco_module_rm.dataset.DataSet) - */ - @Override - public void register(DataSet dataSet) - { - ParameterCheck.mandatory("dataSet", dataSet); - - this.dataSets.put(dataSet.getId(), dataSet); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets() - */ - @Override - public Map getDataSets() - { - return this.dataSets; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets(NodeRef, - * boolean) - */ - @Override - public Map getDataSets(NodeRef filePlan, boolean excludeLoaded) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("excludeLoaded", excludeLoaded); - - // Get the list of all available data sets - Map dataSets = new HashMap(getDataSets()); - - // Should the list of unloaded data sets be retrieved - if (excludeLoaded) - { - dataSets.keySet().removeAll(getLoadedDataSets(filePlan).keySet()); - } - - // Return the (filtered) list of data sets - return dataSets; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#loadDataSet(java.lang.String, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void loadDataSet(NodeRef filePlan, String dataSetId) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatoryString("dataSetId", dataSetId); - - // Get the data set - DataSet dataSet = getDataSets().get(dataSetId); - - // Import the RM test data ACP into the the provided file plan node - // reference - InputStream is = null; - try - { - is = getClass().getClassLoader().getResourceAsStream(dataSet.getPath()); - if (is == null) { throw new AlfrescoRuntimeException("The '" + dataSet.getLabel() - + "' import file could not be found!"); } - - // Import view - Reader viewReader = new InputStreamReader(is, CHARSET_NAME); - Location location = new Location(filePlan); - importerService.importView(viewReader, location, null, null); - - // Patch data - patchLoadedData(); - - // Set the data set id into the file plan's custom aspect - setDataSetIdIntoFilePlan(dataSetId, filePlan); - } - catch (Exception ex) - { - throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex); - } - finally - { - if (is != null) - { - try - { - is.close(); - is = null; - } - catch (IOException ex) - { - throw new RuntimeException("Failed to close the input stream!", ex); - } - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#existsDataSet(java.lang.String) - */ - @Override - public boolean existsDataSet(String dataSetId) - { - ParameterCheck.mandatoryString("dataSetId", dataSetId); - - return getDataSets().containsKey(dataSetId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getLoadedDataSets(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Map getLoadedDataSets(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - - // Get the list of available data sets - Map availableDataSets = new HashMap(getDataSets()); - - // Get the property value of the aspect - Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); - // Check if any data has been loaded before - if (dataSetIds != null) - { - // Filter the data sets which have already been loaded - @SuppressWarnings("unchecked") - ArrayList loadedDataSetIds = (ArrayList) dataSetIds; - Iterator> iterator = availableDataSets.entrySet().iterator(); - while (iterator.hasNext()) - { - Entry entry = iterator.next(); - String key = entry.getKey(); - if (!loadedDataSetIds.contains(key)) - { - iterator.remove(); - } - } - return availableDataSets; - } - - return new HashMap(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#isLoadedDataSet(org.alfresco.service.cmr.repository.NodeRef, - * java.lang.String) - */ - @Override - public boolean isLoadedDataSet(NodeRef filePlan, String dataSetId) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("dataSetId", dataSetId); - - return getLoadedDataSets(filePlan).containsKey(dataSetId); - } - - /** - * Temp method to patch AMP'ed data - */ - private void patchLoadedData() - { - AuthenticationUtil.RunAsWork runAsWork = new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - Set rmRoots = filePlanService.getFilePlans(); - logger.info("Bootstraping " + rmRoots.size() + " rm roots ..."); - for (NodeRef rmRoot : rmRoots) - { - if (permissionService.getInheritParentPermissions(rmRoot)) - { - logger.info("Updating permissions for rm root: " + rmRoot); - permissionService.setInheritParentPermissions(rmRoot, false); - } - - String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId(); - String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName); - - if (!authorityService.authorityExists(allRoleGroupName)) - { - logger.info("Creating all roles group for root node: " + rmRoot.toString()); - - // Create "all" role group for root node - String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName, - RMAuthority.ALL_ROLES_DISPLAY_NAME, new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); - - // Put all the role groups in it - Set roles = filePlanRoleService.getRoles(rmRoot); - for (Role role : roles) - { - logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group"); - authorityService.addAuthority(allRoles, role.getRoleGroupName()); - } - - // Set the permissions - permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true); - } - } - - // Make sure all the containers do not inherit permissions - ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, - "TYPE:\"rma:recordsManagementContainer\""); - try - { - logger.info("Bootstraping " + rs.length() + " record containers ..."); - - for (NodeRef container : rs.getNodeRefs()) - { - String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME); - - // Set permissions - if (permissionService.getInheritParentPermissions(container)) - { - logger.info("Updating permissions for record container: " + containerName); - permissionService.setInheritParentPermissions(container, false); - } - } - } - finally - { - rs.close(); - } - - // fix up the test dataset to fire initial events for - // disposition - // schedules - rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\""); - try - { - logger.info("Bootstraping " + rs.length() + " record folders ..."); - - for (NodeRef recordFolder : rs.getNodeRefs()) - { - String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME); - - // Set permissions - if (permissionService.getInheritParentPermissions(recordFolder)) - { - logger.info("Updating permissions for record folder: " + folderName); - permissionService.setInheritParentPermissions(recordFolder, false); - } - - if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) - { - // See if the folder has a disposition schedule that - // needs - // to be applied - DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder); - if (ds != null) - { - // Fire action to "set-up" the folder correctly - logger.info("Setting up bootstraped record folder: " + folderName); - recordFolderService.setupRecordFolder(recordFolder); - } - } - - // fixup the search behaviour aspect for the record - // folder - logger.info("Setting up search aspect for record folder: " + folderName); - recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder); - } - } - finally - { - rs.close(); - } - - return null; - } - }; - - AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName()); - - } - - /** - * Helper method for setting the id of the imported data set into the file - * plan's aspect - * - * @param dataSetId The id of the imported data set - * @param filePlan The file plan into which the data set has been imported - */ - @SuppressWarnings("unchecked") - private void setDataSetIdIntoFilePlan(String dataSetId, NodeRef filePlan) - { - ArrayList loadedDataSetIds; - Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); - - // Check if any data set has been imported - if (dataSetIds == null) - { - Map aspectProperties = new HashMap(1); - aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) new ArrayList()); - nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties); - loadedDataSetIds = (ArrayList) nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); - } - else - { - loadedDataSetIds = (ArrayList) dataSetIds; - } - - // Add the new loaded data set id - loadedDataSetIds.add(dataSetId); - Map aspectProperties = new HashMap(1); - aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) loadedDataSetIds); - nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties); - } - -} +package org.alfresco.module.org_alfresco_module_rm.dataset; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.view.ImporterService; +import org.alfresco.service.cmr.view.Location; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class DataSetServiceImpl implements DataSetService, RecordsManagementModel +{ + + /** Logger */ + private static Log logger = LogFactory.getLog(DataSetServiceImpl.class); + + /** Registered data set implementations */ + private Map dataSets = new HashMap(); + + /** Spaces store */ + private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); + + /** Charset name */ + private static final String CHARSET_NAME = "UTF-8"; + + /** Importer service */ + private ImporterService importerService; + + /** Search service */ + private SearchService searchService; + + /** Node service */ + private NodeService nodeService; + + /** File plan service service */ + private FilePlanService filePlanService; + + /** Permission service */ + private PermissionService permissionService; + + /** Authority service */ + private AuthorityService authorityService; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** Records management search behaviour */ + private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** + * Set importer service + * + * @param importerService the importer service + */ + public void setImporterService(ImporterService importerService) + { + this.importerService = importerService; + } + + /** + * Set search service + * + * @param searchService the search service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * Set node service + * + * @param nodeService the node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set file plan service + * + * @param filePlanService the file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Set permission service + * + * @param permissionService the permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * Set authority service + * + * @param authorityService the authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * Set records management search behaviour + * + * @param recordsManagementSearchBehaviour the records management search + * behaviour + */ + public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour recordsManagementSearchBehaviour) + { + this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour; + } + + /** + * Set disposition service + * + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Set record folder service + * + * @param recordFolderService the record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#register(org.alfresco.module.org_alfresco_module_rm.dataset.DataSet) + */ + @Override + public void register(DataSet dataSet) + { + ParameterCheck.mandatory("dataSet", dataSet); + + this.dataSets.put(dataSet.getId(), dataSet); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets() + */ + @Override + public Map getDataSets() + { + return this.dataSets; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets(NodeRef, + * boolean) + */ + @Override + public Map getDataSets(NodeRef filePlan, boolean excludeLoaded) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("excludeLoaded", excludeLoaded); + + // Get the list of all available data sets + Map dataSets = new HashMap(getDataSets()); + + // Should the list of unloaded data sets be retrieved + if (excludeLoaded) + { + dataSets.keySet().removeAll(getLoadedDataSets(filePlan).keySet()); + } + + // Return the (filtered) list of data sets + return dataSets; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#loadDataSet(java.lang.String, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void loadDataSet(NodeRef filePlan, String dataSetId) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatoryString("dataSetId", dataSetId); + + // Get the data set + DataSet dataSet = getDataSets().get(dataSetId); + + // Import the RM test data ACP into the the provided file plan node + // reference + InputStream is = null; + try + { + is = getClass().getClassLoader().getResourceAsStream(dataSet.getPath()); + if (is == null) { throw new AlfrescoRuntimeException("The '" + dataSet.getLabel() + + "' import file could not be found!"); } + + // Import view + Reader viewReader = new InputStreamReader(is, CHARSET_NAME); + Location location = new Location(filePlan); + importerService.importView(viewReader, location, null, null); + + // Patch data + patchLoadedData(); + + // Set the data set id into the file plan's custom aspect + setDataSetIdIntoFilePlan(dataSetId, filePlan); + } + catch (Exception ex) + { + throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex); + } + finally + { + if (is != null) + { + try + { + is.close(); + is = null; + } + catch (IOException ex) + { + throw new RuntimeException("Failed to close the input stream!", ex); + } + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#existsDataSet(java.lang.String) + */ + @Override + public boolean existsDataSet(String dataSetId) + { + ParameterCheck.mandatoryString("dataSetId", dataSetId); + + return getDataSets().containsKey(dataSetId); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getLoadedDataSets(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Map getLoadedDataSets(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + + // Get the list of available data sets + Map availableDataSets = new HashMap(getDataSets()); + + // Get the property value of the aspect + Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); + // Check if any data has been loaded before + if (dataSetIds != null) + { + // Filter the data sets which have already been loaded + @SuppressWarnings("unchecked") + ArrayList loadedDataSetIds = (ArrayList) dataSetIds; + Iterator> iterator = availableDataSets.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + String key = entry.getKey(); + if (!loadedDataSetIds.contains(key)) + { + iterator.remove(); + } + } + return availableDataSets; + } + + return new HashMap(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#isLoadedDataSet(org.alfresco.service.cmr.repository.NodeRef, + * java.lang.String) + */ + @Override + public boolean isLoadedDataSet(NodeRef filePlan, String dataSetId) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("dataSetId", dataSetId); + + return getLoadedDataSets(filePlan).containsKey(dataSetId); + } + + /** + * Temp method to patch AMP'ed data + */ + private void patchLoadedData() + { + AuthenticationUtil.RunAsWork runAsWork = new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + Set rmRoots = filePlanService.getFilePlans(); + logger.info("Bootstraping " + rmRoots.size() + " rm roots ..."); + for (NodeRef rmRoot : rmRoots) + { + if (permissionService.getInheritParentPermissions(rmRoot)) + { + logger.info("Updating permissions for rm root: " + rmRoot); + permissionService.setInheritParentPermissions(rmRoot, false); + } + + String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId(); + String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName); + + if (!authorityService.authorityExists(allRoleGroupName)) + { + logger.info("Creating all roles group for root node: " + rmRoot.toString()); + + // Create "all" role group for root node + String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName, + RMAuthority.ALL_ROLES_DISPLAY_NAME, new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); + + // Put all the role groups in it + Set roles = filePlanRoleService.getRoles(rmRoot); + for (Role role : roles) + { + logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group"); + authorityService.addAuthority(allRoles, role.getRoleGroupName()); + } + + // Set the permissions + permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true); + } + } + + // Make sure all the containers do not inherit permissions + ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, + "TYPE:\"rma:recordsManagementContainer\""); + try + { + logger.info("Bootstraping " + rs.length() + " record containers ..."); + + for (NodeRef container : rs.getNodeRefs()) + { + String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME); + + // Set permissions + if (permissionService.getInheritParentPermissions(container)) + { + logger.info("Updating permissions for record container: " + containerName); + permissionService.setInheritParentPermissions(container, false); + } + } + } + finally + { + rs.close(); + } + + // fix up the test dataset to fire initial events for + // disposition + // schedules + rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\""); + try + { + logger.info("Bootstraping " + rs.length() + " record folders ..."); + + for (NodeRef recordFolder : rs.getNodeRefs()) + { + String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME); + + // Set permissions + if (permissionService.getInheritParentPermissions(recordFolder)) + { + logger.info("Updating permissions for record folder: " + folderName); + permissionService.setInheritParentPermissions(recordFolder, false); + } + + if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) + { + // See if the folder has a disposition schedule that + // needs + // to be applied + DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder); + if (ds != null) + { + // Fire action to "set-up" the folder correctly + logger.info("Setting up bootstraped record folder: " + folderName); + recordFolderService.setupRecordFolder(recordFolder); + } + } + + // fixup the search behaviour aspect for the record + // folder + logger.info("Setting up search aspect for record folder: " + folderName); + recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder); + } + } + finally + { + rs.close(); + } + + return null; + } + }; + + AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName()); + + } + + /** + * Helper method for setting the id of the imported data set into the file + * plan's aspect + * + * @param dataSetId The id of the imported data set + * @param filePlan The file plan into which the data set has been imported + */ + @SuppressWarnings("unchecked") + private void setDataSetIdIntoFilePlan(String dataSetId, NodeRef filePlan) + { + ArrayList loadedDataSetIds; + Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); + + // Check if any data set has been imported + if (dataSetIds == null) + { + Map aspectProperties = new HashMap(1); + aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) new ArrayList()); + nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties); + loadedDataSetIds = (ArrayList) nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); + } + else + { + loadedDataSetIds = (ArrayList) dataSetIds; + } + + // Add the new loaded data set id + loadedDataSetIds.add(dataSetId); + Map aspectProperties = new HashMap(1); + aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) loadedDataSetIds); + nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionAction.java index c4b9753dcb..d8b274bbdb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionAction.java @@ -1,144 +1,144 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.Date; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Disposition action interface. - * - * @author Roy Wetherall - * @since 1.0 - */ -public interface DispositionAction -{ - /** - * @return the node reference - */ - NodeRef getNodeRef(); - - /** - * @return the disposition action definition - */ - DispositionActionDefinition getDispositionActionDefinition(); - - /** - * @return the id of the action - */ - String getId(); - - /** - * @return the name of the action - */ - String getName(); - - /** - * @return the display label for the action - */ - String getLabel(); - - /** - * @return the dispostion action as of eligibility date - */ - Date getAsOfDate(); - - /** - * @return true if the events are complete (ie: enough events have been completed to make the disposition - * action - */ - boolean isEventsEligible(); - - /** - * @return the user that started the action - */ - String getStartedBy(); - - /** - * @return when the action was started - */ - Date getStartedAt(); - - /** - * @return the user that completed the action - */ - String getCompletedBy(); - - /** - * @return when the action was completed - */ - Date getCompletedAt(); - - /** - * @return List of events that need to be completed for the action - */ - List getEventCompletionDetails(); - - /** - * Get the event completion details for a named event. - * - * @param eventName event name - * @return {@link EventCompletionDetails} event completion details - * @since 2.2 - */ - EventCompletionDetails getEventCompletionDetails(String eventName); - - /** - * Add new completion details to the disposition action based on the provided - * event. - * - * @param event records management event - * @since 2.2 - */ - void addEventCompletionDetails(RecordsManagementEvent event); - - /** - * Complete an event. - *

- * If null is provided, the complete at date will be take as 'now' and the completed by user - * as the fully authenticated user. - * - * @param eventName event name - * @param completedAt completed at 'date', now if null - * @param completedBy completed by user, authenticated user if null - * @since 2.2 - */ - void completeEvent(String eventName, Date completedAt, String completedBy); - - /** - * Undo the completion of an event. - * - * @param eventName event name - * @since 2.2 - */ - void undoEvent(String eventName); - - /** - * Refresh events against current disposition action definition. - *

- * Called when disposition action definition has changed. - * - * @since 2.2 - */ - void refreshEvents(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.Date; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Disposition action interface. + * + * @author Roy Wetherall + * @since 1.0 + */ +public interface DispositionAction +{ + /** + * @return the node reference + */ + NodeRef getNodeRef(); + + /** + * @return the disposition action definition + */ + DispositionActionDefinition getDispositionActionDefinition(); + + /** + * @return the id of the action + */ + String getId(); + + /** + * @return the name of the action + */ + String getName(); + + /** + * @return the display label for the action + */ + String getLabel(); + + /** + * @return the dispostion action as of eligibility date + */ + Date getAsOfDate(); + + /** + * @return true if the events are complete (ie: enough events have been completed to make the disposition + * action + */ + boolean isEventsEligible(); + + /** + * @return the user that started the action + */ + String getStartedBy(); + + /** + * @return when the action was started + */ + Date getStartedAt(); + + /** + * @return the user that completed the action + */ + String getCompletedBy(); + + /** + * @return when the action was completed + */ + Date getCompletedAt(); + + /** + * @return List of events that need to be completed for the action + */ + List getEventCompletionDetails(); + + /** + * Get the event completion details for a named event. + * + * @param eventName event name + * @return {@link EventCompletionDetails} event completion details + * @since 2.2 + */ + EventCompletionDetails getEventCompletionDetails(String eventName); + + /** + * Add new completion details to the disposition action based on the provided + * event. + * + * @param event records management event + * @since 2.2 + */ + void addEventCompletionDetails(RecordsManagementEvent event); + + /** + * Complete an event. + *

+ * If null is provided, the complete at date will be take as 'now' and the completed by user + * as the fully authenticated user. + * + * @param eventName event name + * @param completedAt completed at 'date', now if null + * @param completedBy completed by user, authenticated user if null + * @since 2.2 + */ + void completeEvent(String eventName, Date completedAt, String completedBy); + + /** + * Undo the completion of an event. + * + * @param eventName event name + * @since 2.2 + */ + void undoEvent(String eventName); + + /** + * Refresh events against current disposition action definition. + *

+ * Called when disposition action definition has changed. + * + * @since 2.2 + */ + void refreshEvents(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinition.java index 91435183f2..b8489b7376 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinition.java @@ -1,123 +1,123 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.QName; - -/** - * Disposition action interface - * - * @author Roy Wetherall - */ -public interface DispositionActionDefinition -{ - /** - * Get the NodeRef that represents the disposition action definition - * - * @return NodeRef of disposition action definition - */ - NodeRef getNodeRef(); - - /** - * Get disposition action id - * - * @return String id - */ - String getId(); - - /** - * Get the index of the action within the disposition instructions - * - * @return int disposition action index - */ - int getIndex(); - - /** - * Get the name of disposition action - * - * @return String name - */ - String getName(); - - /** - * Get the display label of the disposition action - * - * @return String name's display label - */ - String getLabel(); - - /** - * Get the description of the disposition action - * - * @return String description - */ - String getDescription(); - - /** - * Get the period for the disposition action - * - * @return Period disposition period - */ - Period getPeriod(); - - /** - * Property to which the period is relative to - * - * @return QName property name - */ - QName getPeriodProperty(); - - /** - * List of events for the disposition - * - * @return List list of events - */ - List getEvents(); - - /** - * Indicates whether the disposition action is eligible when the earliest - * event is complete, otherwise all events must be complete before - * eligibility. - * - * @return boolean true if eligible on first action complete, false - * otherwise - */ - boolean eligibleOnFirstCompleteEvent(); - - /** - * Get the location of the disposition (can be null) - * - * @return String disposition location - */ - String getLocation(); - - /** - * Get the ghost on destroy from the disposition - * - * @return boolean the gost on destroy flag (on applicable to destroy - * actions) - */ - String getGhostOnDestroy(); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.QName; + +/** + * Disposition action interface + * + * @author Roy Wetherall + */ +public interface DispositionActionDefinition +{ + /** + * Get the NodeRef that represents the disposition action definition + * + * @return NodeRef of disposition action definition + */ + NodeRef getNodeRef(); + + /** + * Get disposition action id + * + * @return String id + */ + String getId(); + + /** + * Get the index of the action within the disposition instructions + * + * @return int disposition action index + */ + int getIndex(); + + /** + * Get the name of disposition action + * + * @return String name + */ + String getName(); + + /** + * Get the display label of the disposition action + * + * @return String name's display label + */ + String getLabel(); + + /** + * Get the description of the disposition action + * + * @return String description + */ + String getDescription(); + + /** + * Get the period for the disposition action + * + * @return Period disposition period + */ + Period getPeriod(); + + /** + * Property to which the period is relative to + * + * @return QName property name + */ + QName getPeriodProperty(); + + /** + * List of events for the disposition + * + * @return List list of events + */ + List getEvents(); + + /** + * Indicates whether the disposition action is eligible when the earliest + * event is complete, otherwise all events must be complete before + * eligibility. + * + * @return boolean true if eligible on first action complete, false + * otherwise + */ + boolean eligibleOnFirstCompleteEvent(); + + /** + * Get the location of the disposition (can be null) + * + * @return String disposition location + */ + String getLocation(); + + /** + * Get the ghost on destroy from the disposition + * + * @return boolean the gost on destroy flag (on applicable to destroy + * actions) + */ + String getGhostOnDestroy(); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinitionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinitionImpl.java index 9e4865d904..30ea8c9e6b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinitionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionDefinitionImpl.java @@ -1,246 +1,246 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.QName; - -/** - * Disposition action implementation - * - * @author Roy Wetherall - */ -public class DispositionActionDefinitionImpl implements DispositionActionDefinition, RecordsManagementModel -{ - /** Name */ - private String name; - - /** Description */ - private String description; - - /** Label */ - private String label; - - /** Node service */ - private NodeService nodeService; - - /** Records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** Records management event service */ - private RecordsManagementEventService recordsManagementEventService; - - /** Disposition action node reference */ - private NodeRef dispositionActionNodeRef; - - /** Action index */ - private int index; - - /** Ghost on detroy */ - private String ghostOnDestroy; - - /** - * Constructor - * - * @param services service registry - * @param nodeRef disposition action node reference - * @param index index of disposition action - */ - public DispositionActionDefinitionImpl(RecordsManagementEventService recordsManagementEventService, RecordsManagementActionService recordsManagementActionService, NodeService nodeService, NodeRef nodeRef, int index) - { - this.recordsManagementEventService = recordsManagementEventService; - this.recordsManagementActionService = recordsManagementActionService; - this.nodeService = nodeService; - this.dispositionActionNodeRef = nodeRef; - this.index = index; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getNodeRef() - */ - @Override - public NodeRef getNodeRef() - { - return this.dispositionActionNodeRef; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getIndex() - */ - @Override - public int getIndex() - { - return this.index; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getId() - */ - @Override - public String getId() - { - return this.dispositionActionNodeRef.getId(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getDescription() - */ - @Override - public String getDescription() - { - if (description == null) - { - description = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_DESCRIPTION); - } - return description; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getName() - */ - @Override - public String getName() - { - if (name == null) - { - name = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_ACTION_NAME); - } - return name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getLabel() - */ - @Override - public String getLabel() - { - if (label == null) - { - String name = getName(); - label = name; - - // get the disposition action from the RM action service - RecordsManagementAction action = recordsManagementActionService.getDispositionAction(name); - if (action != null) - { - label = action.getLabel(); - } - } - - return label; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getPeriod() - */ - @Override - public Period getPeriod() - { - return (Period)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_PERIOD); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getPeriodProperty() - */ - @Override - public QName getPeriodProperty() - { - QName result = null; - String value = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_PERIOD_PROPERTY); - if (value != null) - { - result = QName.createQName(value); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getEvents() - */ - @Override - @SuppressWarnings("unchecked") - public List getEvents() - { - List events = null; - Collection eventNames = (Collection)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_EVENT); - if (eventNames != null) - { - events = new ArrayList(eventNames.size()); - for (String eventName : eventNames) - { - RecordsManagementEvent event = recordsManagementEventService.getEvent(eventName); - events.add(event); - } - } - else - { - events = java.util.Collections.EMPTY_LIST; - } - return events; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#eligibleOnFirstCompleteEvent() - */ - @Override - public boolean eligibleOnFirstCompleteEvent() - { - boolean result = true; - String value = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_EVENT_COMBINATION); - if (value != null && value.equals("and")) - { - result = false; - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getLocation() - */ - @Override - public String getLocation() - { - return (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_LOCATION); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getGhostOnDestroy() - */ - @Override - public String getGhostOnDestroy() - { - if (ghostOnDestroy == null) - { - ghostOnDestroy = (String) nodeService.getProperty(this.dispositionActionNodeRef, - PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY); - } - return ghostOnDestroy; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.QName; + +/** + * Disposition action implementation + * + * @author Roy Wetherall + */ +public class DispositionActionDefinitionImpl implements DispositionActionDefinition, RecordsManagementModel +{ + /** Name */ + private String name; + + /** Description */ + private String description; + + /** Label */ + private String label; + + /** Node service */ + private NodeService nodeService; + + /** Records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** Records management event service */ + private RecordsManagementEventService recordsManagementEventService; + + /** Disposition action node reference */ + private NodeRef dispositionActionNodeRef; + + /** Action index */ + private int index; + + /** Ghost on detroy */ + private String ghostOnDestroy; + + /** + * Constructor + * + * @param services service registry + * @param nodeRef disposition action node reference + * @param index index of disposition action + */ + public DispositionActionDefinitionImpl(RecordsManagementEventService recordsManagementEventService, RecordsManagementActionService recordsManagementActionService, NodeService nodeService, NodeRef nodeRef, int index) + { + this.recordsManagementEventService = recordsManagementEventService; + this.recordsManagementActionService = recordsManagementActionService; + this.nodeService = nodeService; + this.dispositionActionNodeRef = nodeRef; + this.index = index; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getNodeRef() + */ + @Override + public NodeRef getNodeRef() + { + return this.dispositionActionNodeRef; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getIndex() + */ + @Override + public int getIndex() + { + return this.index; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getId() + */ + @Override + public String getId() + { + return this.dispositionActionNodeRef.getId(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getDescription() + */ + @Override + public String getDescription() + { + if (description == null) + { + description = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_DESCRIPTION); + } + return description; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getName() + */ + @Override + public String getName() + { + if (name == null) + { + name = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_ACTION_NAME); + } + return name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getLabel() + */ + @Override + public String getLabel() + { + if (label == null) + { + String name = getName(); + label = name; + + // get the disposition action from the RM action service + RecordsManagementAction action = recordsManagementActionService.getDispositionAction(name); + if (action != null) + { + label = action.getLabel(); + } + } + + return label; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getPeriod() + */ + @Override + public Period getPeriod() + { + return (Period)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_PERIOD); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getPeriodProperty() + */ + @Override + public QName getPeriodProperty() + { + QName result = null; + String value = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_PERIOD_PROPERTY); + if (value != null) + { + result = QName.createQName(value); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getEvents() + */ + @Override + @SuppressWarnings("unchecked") + public List getEvents() + { + List events = null; + Collection eventNames = (Collection)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_EVENT); + if (eventNames != null) + { + events = new ArrayList(eventNames.size()); + for (String eventName : eventNames) + { + RecordsManagementEvent event = recordsManagementEventService.getEvent(eventName); + events.add(event); + } + } + else + { + events = java.util.Collections.EMPTY_LIST; + } + return events; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#eligibleOnFirstCompleteEvent() + */ + @Override + public boolean eligibleOnFirstCompleteEvent() + { + boolean result = true; + String value = (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_EVENT_COMBINATION); + if (value != null && value.equals("and")) + { + result = false; + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getLocation() + */ + @Override + public String getLocation() + { + return (String)nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_LOCATION); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getGhostOnDestroy() + */ + @Override + public String getGhostOnDestroy() + { + if (ghostOnDestroy == null) + { + ghostOnDestroy = (String) nodeService.getProperty(this.dispositionActionNodeRef, + PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY); + } + return ghostOnDestroy; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java index 2661a5b61b..86e93d65ca 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java @@ -1,512 +1,512 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Disposition action implementation. - * - * @author Roy Wetherall - * @since 1.0 - */ -public class DispositionActionImpl implements DispositionAction, - RecordsManagementModel -{ - /** logger */ - private static Log logger = LogFactory.getLog(DispositionActionImpl.class); - - /** records management service registry */ - private RecordsManagementServiceRegistry services; - - /** disposition node reference */ - private NodeRef dispositionNodeRef; - - /** disposition action definition */ - private DispositionActionDefinition dispositionActionDefinition; - - /** - * Constructor - * - * @param services records management service registry - * @param dispositionActionNodeRef disposition action node reference - */ - public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef) - { - this.services = services; - this.dispositionNodeRef = dispositionActionNodeRef; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getDispositionActionDefinition() - */ - public DispositionActionDefinition getDispositionActionDefinition() - { - if (dispositionActionDefinition == null) - { - // Get the current action - String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); - - // Get the disposition instructions for the owning node - NodeRef recordNodeRef = services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef(); - if (recordNodeRef != null) - { - DispositionSchedule ds = services.getDispositionService().getDispositionSchedule(recordNodeRef); - - if (ds != null) - { - // Get the disposition action definition - dispositionActionDefinition = ds.getDispositionActionDefinition(id); - } - } - } - - return dispositionActionDefinition; - - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getNodeRef() - */ - public NodeRef getNodeRef() - { - return this.dispositionNodeRef; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getLabel() - */ - public String getLabel() - { - String name = getName(); - String label = name; - - // get the disposition action from the RM action service - RecordsManagementAction action = services.getRecordsManagementActionService().getDispositionAction(name); - if (action != null) - { - label = action.getLabel(); - } - - return label; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getId() - */ - public String getId() - { - return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getName() - */ - public String getName() - { - return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getAsOfDate() - */ - public Date getAsOfDate() - { - return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#isEventsEligible() - */ - public boolean isEventsEligible() - { - return ((Boolean)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedAt() - */ - public Date getCompletedAt() - { - return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedBy() - */ - public String getCompletedBy() - { - return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedAt() - */ - public Date getStartedAt() - { - return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedBy() - */ - public String getStartedBy() - { - return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getEventCompletionDetails() - */ - public List getEventCompletionDetails() - { - List assocs = services.getNodeService().getChildAssocs( - this.dispositionNodeRef, - ASSOC_EVENT_EXECUTIONS, - RegexQNamePattern.MATCH_ALL); - List result = new ArrayList(assocs.size()); - for (ChildAssociationRef assoc : assocs) - { - result.add(getEventCompletionDetailsFromNodeRef(assoc.getChildRef())); - } - - return result; - } - - /** - * Helper method to create object representation of event completed details from - * node reference. - * - * @param nodeRef node reference - * @return {@link EventCompletionDetails} event completion details - */ - private EventCompletionDetails getEventCompletionDetailsFromNodeRef(NodeRef nodeRef) - { - // get the properties - Map props = this.services.getNodeService().getProperties(nodeRef); - - // get the event name - String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME); - - // create event completion details - EventCompletionDetails ecd = new EventCompletionDetails( - nodeRef, - eventName, - services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(), - getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false), - getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false), - (Date)props.get(PROP_EVENT_EXECUTION_COMPLETED_AT), - (String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY)); - - return ecd; - } - - /** - * Helper method to deal with boolean values - * - * @param value - * @param defaultValue - * @return - */ - private boolean getBooleanValue(Object value, boolean defaultValue) - { - boolean result = defaultValue; - if (value instanceof Boolean) - { - result = ((Boolean)value).booleanValue(); - } - return result; - } - - /** - * Gets the event completion details for the named event. - *

- * Returns null if event can not be found. - * - * @param eventName name of the event - * @return {@link EventCompletionDetails} event completion details for named event, null otherwise - * - * @since 2.2 - */ - @Override - public EventCompletionDetails getEventCompletionDetails(String eventName) - { - EventCompletionDetails result = null; - List assocs = services.getNodeService().getChildAssocsByPropertyValue(dispositionNodeRef, PROP_EVENT_EXECUTION_NAME, eventName); - - if (!assocs.isEmpty()) - { - if (assocs.size() != 1) - { - throw new AlfrescoRuntimeException("Unable to get event completion details, because more than one child was found for event " + eventName); - } - - result = getEventCompletionDetailsFromNodeRef(assocs.get(0).getChildRef()); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#completeEvent(java.lang.String, java.util.Date, java.lang.String) - */ - @Override - public void completeEvent(final String eventName, final Date completedAt, final String completedBy) - { - final EventCompletionDetails event = getEventCompletionDetails(eventName); - if (event != null && !event.isEventComplete()) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // use "now" if no completed date set - Date completedAtValue = completedAt; - if (completedAt == null) - { - completedAtValue = new Date(); - } - - // use the currently authenticated user if none set - String completedByValue = completedBy; - if (completedBy == null) - { - completedByValue = AuthenticationUtil.getFullyAuthenticatedUser(); - } - - // Update the event so that it is complete - NodeRef eventNodeRef = event.getNodeRef(); - Map props = services.getNodeService().getProperties(eventNodeRef); - props.put(PROP_EVENT_EXECUTION_COMPLETE, true); - props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, completedAtValue); - props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue); - services.getNodeService().setProperties(eventNodeRef, props); - - // Check to see if the events eligible property needs to be updated - updateEventEligible(); - - return null; - } - }); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#undoEvent(java.lang.String) - */ - @Override - public void undoEvent(final String eventName) - { - final EventCompletionDetails event = getEventCompletionDetails(eventName); - if (event != null && event.isEventComplete()) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // Update the event so that it is undone - NodeRef eventNodeRef = event.getNodeRef(); - Map props = services.getNodeService().getProperties(eventNodeRef); - props.put(PROP_EVENT_EXECUTION_COMPLETE, false); - props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, null); - props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, null); - services.getNodeService().setProperties(eventNodeRef, props); - - // Check to see if the events eligible property needs to be updated - updateEventEligible(); - - return null; - } - }); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#refreshEvents() - */ - @SuppressWarnings("unchecked") - @Override - public void refreshEvents() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // go through the current events on the next action and remove any that are not present any more - List stepEvents = (List) services.getNodeService().getProperty(getDispositionActionDefinition().getNodeRef(), PROP_DISPOSITION_EVENT); - - List eventsList = getEventCompletionDetails(); - List nextActionEvents = new ArrayList(eventsList.size()); - - for (EventCompletionDetails event : eventsList) - { - // take note of the event names present on the next action - String eventName = event.getEventName(); - nextActionEvents.add(eventName); - - // if the event has been removed delete from next action - if (stepEvents != null && !stepEvents.contains(event.getEventName())) - { - // remove the child association representing the event - services.getNodeService().removeChild(getNodeRef(), event.getNodeRef()); - - if (logger.isDebugEnabled()) - { - logger.debug("Removed '" + eventName + "' from next action '" + getName() + - "' (" + getNodeRef() + ")"); - } - } - } - - // go through the disposition action definition step events and add any new ones - if (stepEvents != null) - { - for (String eventName : stepEvents) - { - if (!nextActionEvents.contains(eventName)) - { - // add the details of the new event - addEventCompletionDetails(services.getRecordsManagementEventService().getEvent(eventName)); - - if (logger.isDebugEnabled()) - { - logger.debug("Added '" + eventName + "' to next action '" + getName() + - "' (" + getNodeRef() + ")"); - } - } - } - } - - // NOTE: eventsList contains all the events that have been updated! - // TODO: manually update the search properties for the parent node! - - // finally since events may have changed re-calculate the events eligible flag - boolean eligible = updateEventEligible(); - - if (logger.isDebugEnabled()) - { - logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + getName() + - "' (" + getNodeRef() + ")"); - } - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#addEventCompletionDetails(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent) - */ - @Override - public void addEventCompletionDetails(RecordsManagementEvent event) - { - Map eventProps = new HashMap(7); - eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName()); - // TODO display label - eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, event.getRecordsManagementEventType().isAutomaticEvent()); - eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false); - - // Create the event execution object - services.getNodeService().createNode(getNodeRef(), - ASSOC_EVENT_EXECUTIONS, - ASSOC_EVENT_EXECUTIONS, - TYPE_EVENT_EXECUTION, - eventProps); - } - - - /** - * Calculates and updates the rma:dispositionEventsEligible - * property for the given next disposition action. - * - * @param nextAction The next disposition action - * @return The result of calculation - * - * @since 2.2 - */ - private boolean updateEventEligible() - { - boolean eligible = false; - - // get the events for the next disposition action - List events = getEventCompletionDetails(); - - if (!events.isEmpty()) - { - // get the disposition action definition - DispositionActionDefinition dispositionActionDefinition = getDispositionActionDefinition(); - if (dispositionActionDefinition != null) - { - if (!dispositionActionDefinition.eligibleOnFirstCompleteEvent()) - { - // if one event is complete then the disposition action is eligible - eligible = true; - for (EventCompletionDetails event : events) - { - if (!event.isEventComplete()) - { - eligible = false; - break; - } - } - } - else - { - // all events must be complete for the disposition action to be eligible - for (EventCompletionDetails event : events) - { - if (event.isEventComplete()) - { - eligible = true; - break; - } - } - } - } - } - - // Update the property with the eligible value - services.getNodeService().setProperty(getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible); - - return eligible; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Disposition action implementation. + * + * @author Roy Wetherall + * @since 1.0 + */ +public class DispositionActionImpl implements DispositionAction, + RecordsManagementModel +{ + /** logger */ + private static Log logger = LogFactory.getLog(DispositionActionImpl.class); + + /** records management service registry */ + private RecordsManagementServiceRegistry services; + + /** disposition node reference */ + private NodeRef dispositionNodeRef; + + /** disposition action definition */ + private DispositionActionDefinition dispositionActionDefinition; + + /** + * Constructor + * + * @param services records management service registry + * @param dispositionActionNodeRef disposition action node reference + */ + public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef) + { + this.services = services; + this.dispositionNodeRef = dispositionActionNodeRef; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getDispositionActionDefinition() + */ + public DispositionActionDefinition getDispositionActionDefinition() + { + if (dispositionActionDefinition == null) + { + // Get the current action + String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); + + // Get the disposition instructions for the owning node + NodeRef recordNodeRef = services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef(); + if (recordNodeRef != null) + { + DispositionSchedule ds = services.getDispositionService().getDispositionSchedule(recordNodeRef); + + if (ds != null) + { + // Get the disposition action definition + dispositionActionDefinition = ds.getDispositionActionDefinition(id); + } + } + } + + return dispositionActionDefinition; + + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getNodeRef() + */ + public NodeRef getNodeRef() + { + return this.dispositionNodeRef; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getLabel() + */ + public String getLabel() + { + String name = getName(); + String label = name; + + // get the disposition action from the RM action service + RecordsManagementAction action = services.getRecordsManagementActionService().getDispositionAction(name); + if (action != null) + { + label = action.getLabel(); + } + + return label; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getId() + */ + public String getId() + { + return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getName() + */ + public String getName() + { + return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getAsOfDate() + */ + public Date getAsOfDate() + { + return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#isEventsEligible() + */ + public boolean isEventsEligible() + { + return ((Boolean)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedAt() + */ + public Date getCompletedAt() + { + return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedBy() + */ + public String getCompletedBy() + { + return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedAt() + */ + public Date getStartedAt() + { + return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedBy() + */ + public String getStartedBy() + { + return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getEventCompletionDetails() + */ + public List getEventCompletionDetails() + { + List assocs = services.getNodeService().getChildAssocs( + this.dispositionNodeRef, + ASSOC_EVENT_EXECUTIONS, + RegexQNamePattern.MATCH_ALL); + List result = new ArrayList(assocs.size()); + for (ChildAssociationRef assoc : assocs) + { + result.add(getEventCompletionDetailsFromNodeRef(assoc.getChildRef())); + } + + return result; + } + + /** + * Helper method to create object representation of event completed details from + * node reference. + * + * @param nodeRef node reference + * @return {@link EventCompletionDetails} event completion details + */ + private EventCompletionDetails getEventCompletionDetailsFromNodeRef(NodeRef nodeRef) + { + // get the properties + Map props = this.services.getNodeService().getProperties(nodeRef); + + // get the event name + String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME); + + // create event completion details + EventCompletionDetails ecd = new EventCompletionDetails( + nodeRef, + eventName, + services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(), + getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false), + getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false), + (Date)props.get(PROP_EVENT_EXECUTION_COMPLETED_AT), + (String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY)); + + return ecd; + } + + /** + * Helper method to deal with boolean values + * + * @param value + * @param defaultValue + * @return + */ + private boolean getBooleanValue(Object value, boolean defaultValue) + { + boolean result = defaultValue; + if (value instanceof Boolean) + { + result = ((Boolean)value).booleanValue(); + } + return result; + } + + /** + * Gets the event completion details for the named event. + *

+ * Returns null if event can not be found. + * + * @param eventName name of the event + * @return {@link EventCompletionDetails} event completion details for named event, null otherwise + * + * @since 2.2 + */ + @Override + public EventCompletionDetails getEventCompletionDetails(String eventName) + { + EventCompletionDetails result = null; + List assocs = services.getNodeService().getChildAssocsByPropertyValue(dispositionNodeRef, PROP_EVENT_EXECUTION_NAME, eventName); + + if (!assocs.isEmpty()) + { + if (assocs.size() != 1) + { + throw new AlfrescoRuntimeException("Unable to get event completion details, because more than one child was found for event " + eventName); + } + + result = getEventCompletionDetailsFromNodeRef(assocs.get(0).getChildRef()); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#completeEvent(java.lang.String, java.util.Date, java.lang.String) + */ + @Override + public void completeEvent(final String eventName, final Date completedAt, final String completedBy) + { + final EventCompletionDetails event = getEventCompletionDetails(eventName); + if (event != null && !event.isEventComplete()) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // use "now" if no completed date set + Date completedAtValue = completedAt; + if (completedAt == null) + { + completedAtValue = new Date(); + } + + // use the currently authenticated user if none set + String completedByValue = completedBy; + if (completedBy == null) + { + completedByValue = AuthenticationUtil.getFullyAuthenticatedUser(); + } + + // Update the event so that it is complete + NodeRef eventNodeRef = event.getNodeRef(); + Map props = services.getNodeService().getProperties(eventNodeRef); + props.put(PROP_EVENT_EXECUTION_COMPLETE, true); + props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, completedAtValue); + props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue); + services.getNodeService().setProperties(eventNodeRef, props); + + // Check to see if the events eligible property needs to be updated + updateEventEligible(); + + return null; + } + }); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#undoEvent(java.lang.String) + */ + @Override + public void undoEvent(final String eventName) + { + final EventCompletionDetails event = getEventCompletionDetails(eventName); + if (event != null && event.isEventComplete()) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Update the event so that it is undone + NodeRef eventNodeRef = event.getNodeRef(); + Map props = services.getNodeService().getProperties(eventNodeRef); + props.put(PROP_EVENT_EXECUTION_COMPLETE, false); + props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, null); + props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, null); + services.getNodeService().setProperties(eventNodeRef, props); + + // Check to see if the events eligible property needs to be updated + updateEventEligible(); + + return null; + } + }); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#refreshEvents() + */ + @SuppressWarnings("unchecked") + @Override + public void refreshEvents() + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // go through the current events on the next action and remove any that are not present any more + List stepEvents = (List) services.getNodeService().getProperty(getDispositionActionDefinition().getNodeRef(), PROP_DISPOSITION_EVENT); + + List eventsList = getEventCompletionDetails(); + List nextActionEvents = new ArrayList(eventsList.size()); + + for (EventCompletionDetails event : eventsList) + { + // take note of the event names present on the next action + String eventName = event.getEventName(); + nextActionEvents.add(eventName); + + // if the event has been removed delete from next action + if (stepEvents != null && !stepEvents.contains(event.getEventName())) + { + // remove the child association representing the event + services.getNodeService().removeChild(getNodeRef(), event.getNodeRef()); + + if (logger.isDebugEnabled()) + { + logger.debug("Removed '" + eventName + "' from next action '" + getName() + + "' (" + getNodeRef() + ")"); + } + } + } + + // go through the disposition action definition step events and add any new ones + if (stepEvents != null) + { + for (String eventName : stepEvents) + { + if (!nextActionEvents.contains(eventName)) + { + // add the details of the new event + addEventCompletionDetails(services.getRecordsManagementEventService().getEvent(eventName)); + + if (logger.isDebugEnabled()) + { + logger.debug("Added '" + eventName + "' to next action '" + getName() + + "' (" + getNodeRef() + ")"); + } + } + } + } + + // NOTE: eventsList contains all the events that have been updated! + // TODO: manually update the search properties for the parent node! + + // finally since events may have changed re-calculate the events eligible flag + boolean eligible = updateEventEligible(); + + if (logger.isDebugEnabled()) + { + logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + getName() + + "' (" + getNodeRef() + ")"); + } + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#addEventCompletionDetails(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent) + */ + @Override + public void addEventCompletionDetails(RecordsManagementEvent event) + { + Map eventProps = new HashMap(7); + eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName()); + // TODO display label + eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, event.getRecordsManagementEventType().isAutomaticEvent()); + eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false); + + // Create the event execution object + services.getNodeService().createNode(getNodeRef(), + ASSOC_EVENT_EXECUTIONS, + ASSOC_EVENT_EXECUTIONS, + TYPE_EVENT_EXECUTION, + eventProps); + } + + + /** + * Calculates and updates the rma:dispositionEventsEligible + * property for the given next disposition action. + * + * @param nextAction The next disposition action + * @return The result of calculation + * + * @since 2.2 + */ + private boolean updateEventEligible() + { + boolean eligible = false; + + // get the events for the next disposition action + List events = getEventCompletionDetails(); + + if (!events.isEmpty()) + { + // get the disposition action definition + DispositionActionDefinition dispositionActionDefinition = getDispositionActionDefinition(); + if (dispositionActionDefinition != null) + { + if (!dispositionActionDefinition.eligibleOnFirstCompleteEvent()) + { + // if one event is complete then the disposition action is eligible + eligible = true; + for (EventCompletionDetails event : events) + { + if (!event.isEventComplete()) + { + eligible = false; + break; + } + } + } + else + { + // all events must be complete for the disposition action to be eligible + for (EventCompletionDetails event : events) + { + if (event.isEventComplete()) + { + eligible = true; + break; + } + } + } + } + } + + // Update the property with the eligible value + services.getNodeService().setProperty(getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible); + + return eligible; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSchedule.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSchedule.java index fac0cab599..1a717fbaed 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSchedule.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSchedule.java @@ -1,82 +1,82 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Disposition schedule interface - * - * @author Roy Wetherall - */ -public interface DispositionSchedule -{ - /** - * Get the NodeRef that represents the disposition schedule - * - * @return {@link NodeRef} of disposition schedule - */ - NodeRef getNodeRef(); - - /** - * Get the disposition authority - * - * @return {@link String} disposition authority - */ - String getDispositionAuthority(); - - /** - * Get the disposition instructions - * - * @return {@link String} disposition instructions - */ - String getDispositionInstructions(); - - /** - * Indicates whether the disposal occurs at record level or not - * - * @return boolean true if at record level, false otherwise - */ - boolean isRecordLevelDisposition(); - - /** - * Gets all the disposition action definitions for the schedule - * - * @return List<{@link DispositionActionDefinition}> disposition action definitions - */ - List getDispositionActionDefinitions(); - - /** - * Get the disposition action definition - * - * @param id the action definition id - * @return {@link DispositionActionDefinition} disposition action definition - */ - DispositionActionDefinition getDispositionActionDefinition(String id); - - /** - * Get the disposition action definition by the name of the disposition action - * - * @param name disposition action name - * @return {@link DispositionActionDefinition} disposition action definition, null if none - */ - DispositionActionDefinition getDispositionActionDefinitionByName(String name); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Disposition schedule interface + * + * @author Roy Wetherall + */ +public interface DispositionSchedule +{ + /** + * Get the NodeRef that represents the disposition schedule + * + * @return {@link NodeRef} of disposition schedule + */ + NodeRef getNodeRef(); + + /** + * Get the disposition authority + * + * @return {@link String} disposition authority + */ + String getDispositionAuthority(); + + /** + * Get the disposition instructions + * + * @return {@link String} disposition instructions + */ + String getDispositionInstructions(); + + /** + * Indicates whether the disposal occurs at record level or not + * + * @return boolean true if at record level, false otherwise + */ + boolean isRecordLevelDisposition(); + + /** + * Gets all the disposition action definitions for the schedule + * + * @return List<{@link DispositionActionDefinition}> disposition action definitions + */ + List getDispositionActionDefinitions(); + + /** + * Get the disposition action definition + * + * @param id the action definition id + * @return {@link DispositionActionDefinition} disposition action definition + */ + DispositionActionDefinition getDispositionActionDefinition(String id); + + /** + * Get the disposition action definition by the name of the disposition action + * + * @param name disposition action name + * @return {@link DispositionActionDefinition} disposition action definition, null if none + */ + DispositionActionDefinition getDispositionActionDefinitionByName(String name); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java index c018ebb2bf..5fb70aa0b1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java @@ -1,185 +1,185 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Disposition instructions implementation - * - * @author Roy Wetherall - */ -public class DispositionScheduleImpl implements DispositionSchedule, - RecordsManagementModel -{ - private NodeService nodeService; - private RecordsManagementServiceRegistry services; - private NodeRef dispositionDefinitionNodeRef; - - private List actions; - private Map actionsById; - - //If name is not the same as node-uuid, then action will be stored here too - //Fix for ALF-2588 - private Map actionsByName; - - /** Map of disposition definitions by disposition action name */ - private Map actionsByDispositionActionName; - - public DispositionScheduleImpl(RecordsManagementServiceRegistry services, NodeService nodeService, NodeRef nodeRef) - { - // TODO check that we have a disposition definition node reference - - this.dispositionDefinitionNodeRef = nodeRef; - this.nodeService = nodeService; - this.services = services; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getNodeRef() - */ - public NodeRef getNodeRef() - { - return this.dispositionDefinitionNodeRef; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionAuthority() - */ - public String getDispositionAuthority() - { - return (String)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_DISPOSITION_AUTHORITY); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionInstructions() - */ - public String getDispositionInstructions() - { - return (String)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_DISPOSITION_INSTRUCTIONS); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#isRecordLevelDisposition() - */ - public boolean isRecordLevelDisposition() - { - boolean result = false; - Boolean value = (Boolean)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_RECORD_LEVEL_DISPOSITION); - if (value != null) - { - result = value.booleanValue(); - } - return result; - } - - /** - * Get disposition action definition - * - * @param id action definition identifier - * @return DispositionActionDefinition disposition action definition - */ - public DispositionActionDefinition getDispositionActionDefinition(String id) - { - if (this.actions == null) - { - getDispositionActionsImpl(); - } - - DispositionActionDefinition actionDef = this.actionsById.get(id); - if (actionDef == null) - { - actionDef = this.actionsByName.get(id); - } - return actionDef; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionActionDefinitionByName(java.lang.String) - */ - @Override - public DispositionActionDefinition getDispositionActionDefinitionByName(String name) - { - if (this.actionsByDispositionActionName == null) - { - getDispositionActionsImpl(); - } - return actionsByDispositionActionName.get(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionActionDefinitions() - */ - public List getDispositionActionDefinitions() - { - if (this.actions == null) - { - getDispositionActionsImpl(); - } - - return this.actions; - } - - /** - * Get the disposition actions into the local cache - */ - private void getDispositionActionsImpl() - { - List assocs = this.nodeService.getChildAssocs( - this.dispositionDefinitionNodeRef, - ASSOC_DISPOSITION_ACTION_DEFINITIONS, - RegexQNamePattern.MATCH_ALL); - this.actions = new ArrayList(assocs.size()); - this.actionsById = new HashMap(assocs.size()); - this.actionsByName = new HashMap(assocs.size()); - this.actionsByDispositionActionName = new HashMap(assocs.size()); - int index = 0; - for (ChildAssociationRef assoc : assocs) - { - DispositionActionDefinition da = new DispositionActionDefinitionImpl(services.getRecordsManagementEventService(), services.getRecordsManagementActionService(), nodeService, assoc.getChildRef(), index); - actions.add(da); - actionsById.put(da.getId(), da); - index++; - - String actionNodeName = (String) nodeService.getProperty(assoc.getChildRef(), ContentModel.PROP_NAME); - if (!actionNodeName.equals(da.getId())) - { - //It was imported and now has new ID. Old ID may present in old files. - actionsByName.put(actionNodeName, da); - } - - String actionDefintionName = (String)nodeService.getProperty(assoc.getChildRef(), PROP_DISPOSITION_ACTION_NAME); - if (actionDefintionName != null) - { - actionsByDispositionActionName.put(actionDefintionName, da); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Disposition instructions implementation + * + * @author Roy Wetherall + */ +public class DispositionScheduleImpl implements DispositionSchedule, + RecordsManagementModel +{ + private NodeService nodeService; + private RecordsManagementServiceRegistry services; + private NodeRef dispositionDefinitionNodeRef; + + private List actions; + private Map actionsById; + + //If name is not the same as node-uuid, then action will be stored here too + //Fix for ALF-2588 + private Map actionsByName; + + /** Map of disposition definitions by disposition action name */ + private Map actionsByDispositionActionName; + + public DispositionScheduleImpl(RecordsManagementServiceRegistry services, NodeService nodeService, NodeRef nodeRef) + { + // TODO check that we have a disposition definition node reference + + this.dispositionDefinitionNodeRef = nodeRef; + this.nodeService = nodeService; + this.services = services; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getNodeRef() + */ + public NodeRef getNodeRef() + { + return this.dispositionDefinitionNodeRef; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionAuthority() + */ + public String getDispositionAuthority() + { + return (String)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_DISPOSITION_AUTHORITY); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionInstructions() + */ + public String getDispositionInstructions() + { + return (String)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_DISPOSITION_INSTRUCTIONS); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#isRecordLevelDisposition() + */ + public boolean isRecordLevelDisposition() + { + boolean result = false; + Boolean value = (Boolean)this.nodeService.getProperty(this.dispositionDefinitionNodeRef, PROP_RECORD_LEVEL_DISPOSITION); + if (value != null) + { + result = value.booleanValue(); + } + return result; + } + + /** + * Get disposition action definition + * + * @param id action definition identifier + * @return DispositionActionDefinition disposition action definition + */ + public DispositionActionDefinition getDispositionActionDefinition(String id) + { + if (this.actions == null) + { + getDispositionActionsImpl(); + } + + DispositionActionDefinition actionDef = this.actionsById.get(id); + if (actionDef == null) + { + actionDef = this.actionsByName.get(id); + } + return actionDef; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionActionDefinitionByName(java.lang.String) + */ + @Override + public DispositionActionDefinition getDispositionActionDefinitionByName(String name) + { + if (this.actionsByDispositionActionName == null) + { + getDispositionActionsImpl(); + } + return actionsByDispositionActionName.get(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule#getDispositionActionDefinitions() + */ + public List getDispositionActionDefinitions() + { + if (this.actions == null) + { + getDispositionActionsImpl(); + } + + return this.actions; + } + + /** + * Get the disposition actions into the local cache + */ + private void getDispositionActionsImpl() + { + List assocs = this.nodeService.getChildAssocs( + this.dispositionDefinitionNodeRef, + ASSOC_DISPOSITION_ACTION_DEFINITIONS, + RegexQNamePattern.MATCH_ALL); + this.actions = new ArrayList(assocs.size()); + this.actionsById = new HashMap(assocs.size()); + this.actionsByName = new HashMap(assocs.size()); + this.actionsByDispositionActionName = new HashMap(assocs.size()); + int index = 0; + for (ChildAssociationRef assoc : assocs) + { + DispositionActionDefinition da = new DispositionActionDefinitionImpl(services.getRecordsManagementEventService(), services.getRecordsManagementActionService(), nodeService, assoc.getChildRef(), index); + actions.add(da); + actionsById.put(da.getId(), da); + index++; + + String actionNodeName = (String) nodeService.getProperty(assoc.getChildRef(), ContentModel.PROP_NAME); + if (!actionNodeName.equals(da.getId())) + { + //It was imported and now has new ID. Old ID may present in old files. + actionsByName.put(actionNodeName, da); + } + + String actionDefintionName = (String)nodeService.getProperty(assoc.getChildRef(), PROP_DISPOSITION_ACTION_NAME); + if (actionDefintionName != null) + { + actionsByDispositionActionName.put(actionDefintionName, da); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSelectionStrategy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSelectionStrategy.java index 191468ee7c..d341c71295 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSelectionStrategy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionSelectionStrategy.java @@ -1,199 +1,199 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This class offers the default implementation of a strategy for selection of - * disposition schedule for a record when there is more than one which is applicable. - * An example of where this strategy might be used would be in the case of a record - * which was multiply filed. - * - * @author neilm - */ -public class DispositionSelectionStrategy implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(DispositionSelectionStrategy.class); - - /** Disposition service */ - private DispositionService dispositionService; - - /** - * Set the disposition service - * - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Select the disposition schedule to use given there is more than one - * - * @param recordFolders - * @return - */ - public NodeRef selectDispositionScheduleFrom(List recordFolders) - { - if (recordFolders == null || recordFolders.isEmpty()) - { - return null; - } - else - { - // 46 CHAPTER 2 - // Records assigned more than 1 disposition must be retained and linked to the record folder (category) with the longest - // retention period. - - // Assumption: an event-based disposition action has a longer retention - // period than a time-based one - as we cannot know when an event will occur - // TODO Automatic events? - - NodeRef recordFolder = null; - if (recordFolders.size() == 1) - { - recordFolder = recordFolders.get(0); - } - else - { - SortedSet sortedFolders = new TreeSet(new DispositionableNodeRefComparator()); - sortedFolders.addAll(recordFolders); - recordFolder = sortedFolders.first(); - } - - DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder); - - if (logger.isDebugEnabled()) - { - logger.debug("Selected disposition schedule: " + dispSchedule); - } - - NodeRef result = null; - if (dispSchedule != null) - { - result = dispSchedule.getNodeRef(); - } - return result; - } - } - - /** - * This class defines a natural comparison order between NodeRefs that have - * the dispositionLifecycle aspect applied. - * This order has the following meaning: NodeRefs with a 'lesser' value are considered - * to have a shorter retention period, although the actual retention period may - * not be straightforwardly determined in all cases. - */ - class DispositionableNodeRefComparator implements Comparator - { - public int compare(final NodeRef f1, final NodeRef f2) - { - // Run as admin user - return AuthenticationUtil.runAs(new RunAsWork() - { - public Integer doWork() - { - return compareImpl(f1, f2); - } - }, AuthenticationUtil.getAdminUserName()); - } - - private int compareImpl(NodeRef f1, NodeRef f2) - { - // quick check to see if the node references are the same - if (f1.equals(f2)) - { - return 0; - } - - // get the disposition schedules for the folders - DispositionSchedule ds1 = dispositionService.getDispositionSchedule(f1); - DispositionSchedule ds2 = dispositionService.getDispositionSchedule(f2); - - // make sure each folder has a disposition schedule - if (ds1 == null && ds2 != null) - { - return 1; - } - else if (ds1 != null && ds2 == null) - { - return -1; - } - else if (ds1 == null && ds2 == null) - { - return 0; - } - - // TODO this won't work correctly if we are trying to compare schedules that are record based!! - DispositionAction da1 = dispositionService.getNextDispositionAction(f1); - DispositionAction da2 = dispositionService.getNextDispositionAction(f2); - - if (da1 != null && da2 != null) - { - Date asOfDate1 = da1.getAsOfDate(); - Date asOfDate2 = da2.getAsOfDate(); - // If both record(Folder)s have asOfDates, then use these to compare - if (asOfDate1 != null && asOfDate2 != null) - { - return asOfDate1.compareTo(asOfDate2); - } - // If one has a date and the other doesn't, the one with the date is "less". - // (Defined date is 'shorter' than undefined date as an undefined date means it may be retained forever - theoretically) - else if (asOfDate1 != null || asOfDate2 != null) - { - return asOfDate1 == null ? +1 : -1; - } - else - { - // Neither has an asOfDate. (Somewhat arbitrarily) we'll use the number of events to compare now. - DispositionActionDefinition dad1 = da1.getDispositionActionDefinition(); - DispositionActionDefinition dad2 = da2.getDispositionActionDefinition(); - int eventsCount1 = 0; - int eventsCount2 = 0; - - if (dad1 != null) - { - eventsCount1 = dad1.getEvents().size(); - } - if (dad2 != null) - { - eventsCount2 = dad2.getEvents().size(); - } - return Integer.valueOf(eventsCount1).compareTo(eventsCount2); - } - } - - return 0; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class offers the default implementation of a strategy for selection of + * disposition schedule for a record when there is more than one which is applicable. + * An example of where this strategy might be used would be in the case of a record + * which was multiply filed. + * + * @author neilm + */ +public class DispositionSelectionStrategy implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(DispositionSelectionStrategy.class); + + /** Disposition service */ + private DispositionService dispositionService; + + /** + * Set the disposition service + * + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Select the disposition schedule to use given there is more than one + * + * @param recordFolders + * @return + */ + public NodeRef selectDispositionScheduleFrom(List recordFolders) + { + if (recordFolders == null || recordFolders.isEmpty()) + { + return null; + } + else + { + // 46 CHAPTER 2 + // Records assigned more than 1 disposition must be retained and linked to the record folder (category) with the longest + // retention period. + + // Assumption: an event-based disposition action has a longer retention + // period than a time-based one - as we cannot know when an event will occur + // TODO Automatic events? + + NodeRef recordFolder = null; + if (recordFolders.size() == 1) + { + recordFolder = recordFolders.get(0); + } + else + { + SortedSet sortedFolders = new TreeSet(new DispositionableNodeRefComparator()); + sortedFolders.addAll(recordFolders); + recordFolder = sortedFolders.first(); + } + + DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder); + + if (logger.isDebugEnabled()) + { + logger.debug("Selected disposition schedule: " + dispSchedule); + } + + NodeRef result = null; + if (dispSchedule != null) + { + result = dispSchedule.getNodeRef(); + } + return result; + } + } + + /** + * This class defines a natural comparison order between NodeRefs that have + * the dispositionLifecycle aspect applied. + * This order has the following meaning: NodeRefs with a 'lesser' value are considered + * to have a shorter retention period, although the actual retention period may + * not be straightforwardly determined in all cases. + */ + class DispositionableNodeRefComparator implements Comparator + { + public int compare(final NodeRef f1, final NodeRef f2) + { + // Run as admin user + return AuthenticationUtil.runAs(new RunAsWork() + { + public Integer doWork() + { + return compareImpl(f1, f2); + } + }, AuthenticationUtil.getAdminUserName()); + } + + private int compareImpl(NodeRef f1, NodeRef f2) + { + // quick check to see if the node references are the same + if (f1.equals(f2)) + { + return 0; + } + + // get the disposition schedules for the folders + DispositionSchedule ds1 = dispositionService.getDispositionSchedule(f1); + DispositionSchedule ds2 = dispositionService.getDispositionSchedule(f2); + + // make sure each folder has a disposition schedule + if (ds1 == null && ds2 != null) + { + return 1; + } + else if (ds1 != null && ds2 == null) + { + return -1; + } + else if (ds1 == null && ds2 == null) + { + return 0; + } + + // TODO this won't work correctly if we are trying to compare schedules that are record based!! + DispositionAction da1 = dispositionService.getNextDispositionAction(f1); + DispositionAction da2 = dispositionService.getNextDispositionAction(f2); + + if (da1 != null && da2 != null) + { + Date asOfDate1 = da1.getAsOfDate(); + Date asOfDate2 = da2.getAsOfDate(); + // If both record(Folder)s have asOfDates, then use these to compare + if (asOfDate1 != null && asOfDate2 != null) + { + return asOfDate1.compareTo(asOfDate2); + } + // If one has a date and the other doesn't, the one with the date is "less". + // (Defined date is 'shorter' than undefined date as an undefined date means it may be retained forever - theoretically) + else if (asOfDate1 != null || asOfDate2 != null) + { + return asOfDate1 == null ? +1 : -1; + } + else + { + // Neither has an asOfDate. (Somewhat arbitrarily) we'll use the number of events to compare now. + DispositionActionDefinition dad1 = da1.getDispositionActionDefinition(); + DispositionActionDefinition dad2 = da2.getDispositionActionDefinition(); + int eventsCount1 = 0; + int eventsCount2 = 0; + + if (dad1 != null) + { + eventsCount1 = dad1.getEvents().size(); + } + if (dad2 != null) + { + eventsCount2 = dad2.getEvents().size(); + } + return Integer.valueOf(eventsCount1).compareTo(eventsCount2); + } + } + + return 0; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index cc58ef6a4f..295397f1bd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -1,235 +1,235 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.io.Serializable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Disposition service interface. - * - * @author Roy Wetherall - * @since 2.0 - */ -public interface DispositionService -{ - /** ========= Disposition Property Methods ========= */ - - /** - * Register a disposition property. - * - * @param dispositionProperty disposition property - */ - void registerDispositionProperty(DispositionProperty dispositionProperty); - - /** - * Returns the list of disposition period properties that apply given the context provided. - * - * @return filtered list of disposition period properties - */ - Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction); - Collection getDispositionProperties(); - - - /** ========= Disposition Schedule Methods ========= */ - - /** - * Get the disposition schedule for a given record management node. Traverses the hierarchy to - * find the first disposition schedule in the primary hierarchy. - * - * @param nodeRef node reference to record category, record folder or record - * @return {@link DispositionSchedule} disposition schedule - */ - DispositionSchedule getDispositionSchedule(NodeRef nodeRef); - - // Gets all the disposition schedules, not just the first in the primary parent path. - // TODO List getAllDispositionSchedules(NodeRef nodeRef); - - /** - * Get the disposition schedule directly associated with the node specified. Returns - * null if none. - * - * @param nodeRef node reference - * @return {@link DispositionSchedule} disposition schedule directly associated with the node reference, null if none - */ - DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef); - - /** - * Gets the records management container that is directly associated with the disposition schedule. - * - * @param dispositionSchedule disposition schedule - * @return {@link NodeRef} node reference of the associated container - */ - NodeRef getAssociatedRecordsManagementContainer(DispositionSchedule dispositionSchedule); - - /** - * Indicates whether a disposition schedule has any disposable items under its management - * - * @param dispositionSchdule disposition schedule - * @return boolean true if there are disposable items being managed by, false otherwise - */ - boolean hasDisposableItems(DispositionSchedule dispositionSchdule); - - /** - * Gets a list of all the disposable items (records, record folders) that are under the control of - * the disposition schedule. - * - * @param dispositionSchedule disposition schedule - * @return {@link List}<{@link NodeRef}> list of disposable items - */ - List getDisposableItems(DispositionSchedule dispositionSchedule); - - /** - * Indicates whether the node is a disposable item or not (ie is under the control of a disposition schedule) - * - * @param nodeRef node reference - * @return boolean true if node is a disposable item, false otherwise - */ - boolean isDisposableItem(NodeRef nodeRef); - - /** - * Creates a disposition schedule on the given record category. - * - * @param recordCategory - * @param props - * @return {@link DispositionSchedule} - */ - DispositionSchedule createDispositionSchedule(NodeRef recordCategory, Map props); - - // TODO DispositionSchedule updateDispositionSchedule(DispositionScedule, Map props) - - // TODO void removeDispositionSchedule(NodeRef nodeRef); - can only remove if no disposition items - - /** ========= Disposition Action Definition Methods ========= */ - - /** - * Adds a new disposition action definition to the given disposition schedule. - * - * @param schedule The DispositionSchedule to add to - * @param actionDefinitionParams Map of parameters to use to create the action definition - */ - DispositionActionDefinition addDispositionActionDefinition( - DispositionSchedule schedule, - Map actionDefinitionParams); - - /** - * Removes the given disposition action definition from the given disposition - * schedule. - * - * @param schedule The DispositionSchedule to remove from - * @param actionDefinition The DispositionActionDefinition to remove - */ - void removeDispositionActionDefinition( - DispositionSchedule schedule, - DispositionActionDefinition actionDefinition); - - /** - * Updates the given disposition action definition belonging to the given disposition - * schedule. - * - * @param actionDefinition The DispositionActionDefinition to update - * @param actionDefinitionParams Map of parameters to use to update the action definition - * @return The updated DispositionActionDefinition - */ - DispositionActionDefinition updateDispositionActionDefinition( - DispositionActionDefinition actionDefinition, - Map actionDefinitionParams); - - - /** ========= Disposition Action Methods ========= */ - - /** - * Indicates whether the next disposition action is eligible or not. - * - * @param nodeRef node reference to disposable item - * @return boolean true if next disposition action is eligible, false otherwise - */ - boolean isNextDispositionActionEligible(NodeRef nodeRef); - - /** - * Gets the next disposition action for a given node - * - * @param nodeRef node reference to disposable item - * @return DispositionAction next disposition action, null if none - */ - DispositionAction getNextDispositionAction(NodeRef nodeRef); - - // TODO void startNextDispositionAction(NodeRef nodeRef); - - // TODO void completeNextDispositionAction(NodeRef nodeRef); - - - /** ========= Disposition Action History Methods ========= */ - - /** - * Gets a list of all the completed disposition action in the order they occured. - * - * @param nodeRef record/record folder - * @return List list of completed disposition actions - */ - List getCompletedDispositionActions(NodeRef nodeRef); - - /** - * Helper method to get the last completed disposition action. Returns null - * if there is none. - * - * @param nodeRef record/record folder - * @return DispositionAction last completed disposition action, null if none - */ - DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); - - /** - * Indicates whether the disposable item (records, record folders) is cutoff or not. - * - * @param nodeRef node reference - * @return boolean true if the disposable item is cutoff, false otherwise - * - * @since 2.0 - */ - boolean isDisposableItemCutoff(NodeRef nodeRef); - - /** - * Marks the disposable item (record or record folder) as cut off, calculating the cut off date - * - * @param nodeRef node reference - * - * @since 2.2 - */ - void cutoffDisposableItem(NodeRef nodeRef); - - /** - * Updates the next disposition action - * - * @param nodeRef node reference - */ - void updateNextDispositionAction(NodeRef nodeRef); - - /** - * Refreshes the disposition action details of the given node. - * - * @param nodeRef node reference - */ - void refreshDispositionAction(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Disposition service interface. + * + * @author Roy Wetherall + * @since 2.0 + */ +public interface DispositionService +{ + /** ========= Disposition Property Methods ========= */ + + /** + * Register a disposition property. + * + * @param dispositionProperty disposition property + */ + void registerDispositionProperty(DispositionProperty dispositionProperty); + + /** + * Returns the list of disposition period properties that apply given the context provided. + * + * @return filtered list of disposition period properties + */ + Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction); + Collection getDispositionProperties(); + + + /** ========= Disposition Schedule Methods ========= */ + + /** + * Get the disposition schedule for a given record management node. Traverses the hierarchy to + * find the first disposition schedule in the primary hierarchy. + * + * @param nodeRef node reference to record category, record folder or record + * @return {@link DispositionSchedule} disposition schedule + */ + DispositionSchedule getDispositionSchedule(NodeRef nodeRef); + + // Gets all the disposition schedules, not just the first in the primary parent path. + // TODO List getAllDispositionSchedules(NodeRef nodeRef); + + /** + * Get the disposition schedule directly associated with the node specified. Returns + * null if none. + * + * @param nodeRef node reference + * @return {@link DispositionSchedule} disposition schedule directly associated with the node reference, null if none + */ + DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef); + + /** + * Gets the records management container that is directly associated with the disposition schedule. + * + * @param dispositionSchedule disposition schedule + * @return {@link NodeRef} node reference of the associated container + */ + NodeRef getAssociatedRecordsManagementContainer(DispositionSchedule dispositionSchedule); + + /** + * Indicates whether a disposition schedule has any disposable items under its management + * + * @param dispositionSchdule disposition schedule + * @return boolean true if there are disposable items being managed by, false otherwise + */ + boolean hasDisposableItems(DispositionSchedule dispositionSchdule); + + /** + * Gets a list of all the disposable items (records, record folders) that are under the control of + * the disposition schedule. + * + * @param dispositionSchedule disposition schedule + * @return {@link List}<{@link NodeRef}> list of disposable items + */ + List getDisposableItems(DispositionSchedule dispositionSchedule); + + /** + * Indicates whether the node is a disposable item or not (ie is under the control of a disposition schedule) + * + * @param nodeRef node reference + * @return boolean true if node is a disposable item, false otherwise + */ + boolean isDisposableItem(NodeRef nodeRef); + + /** + * Creates a disposition schedule on the given record category. + * + * @param recordCategory + * @param props + * @return {@link DispositionSchedule} + */ + DispositionSchedule createDispositionSchedule(NodeRef recordCategory, Map props); + + // TODO DispositionSchedule updateDispositionSchedule(DispositionScedule, Map props) + + // TODO void removeDispositionSchedule(NodeRef nodeRef); - can only remove if no disposition items + + /** ========= Disposition Action Definition Methods ========= */ + + /** + * Adds a new disposition action definition to the given disposition schedule. + * + * @param schedule The DispositionSchedule to add to + * @param actionDefinitionParams Map of parameters to use to create the action definition + */ + DispositionActionDefinition addDispositionActionDefinition( + DispositionSchedule schedule, + Map actionDefinitionParams); + + /** + * Removes the given disposition action definition from the given disposition + * schedule. + * + * @param schedule The DispositionSchedule to remove from + * @param actionDefinition The DispositionActionDefinition to remove + */ + void removeDispositionActionDefinition( + DispositionSchedule schedule, + DispositionActionDefinition actionDefinition); + + /** + * Updates the given disposition action definition belonging to the given disposition + * schedule. + * + * @param actionDefinition The DispositionActionDefinition to update + * @param actionDefinitionParams Map of parameters to use to update the action definition + * @return The updated DispositionActionDefinition + */ + DispositionActionDefinition updateDispositionActionDefinition( + DispositionActionDefinition actionDefinition, + Map actionDefinitionParams); + + + /** ========= Disposition Action Methods ========= */ + + /** + * Indicates whether the next disposition action is eligible or not. + * + * @param nodeRef node reference to disposable item + * @return boolean true if next disposition action is eligible, false otherwise + */ + boolean isNextDispositionActionEligible(NodeRef nodeRef); + + /** + * Gets the next disposition action for a given node + * + * @param nodeRef node reference to disposable item + * @return DispositionAction next disposition action, null if none + */ + DispositionAction getNextDispositionAction(NodeRef nodeRef); + + // TODO void startNextDispositionAction(NodeRef nodeRef); + + // TODO void completeNextDispositionAction(NodeRef nodeRef); + + + /** ========= Disposition Action History Methods ========= */ + + /** + * Gets a list of all the completed disposition action in the order they occured. + * + * @param nodeRef record/record folder + * @return List list of completed disposition actions + */ + List getCompletedDispositionActions(NodeRef nodeRef); + + /** + * Helper method to get the last completed disposition action. Returns null + * if there is none. + * + * @param nodeRef record/record folder + * @return DispositionAction last completed disposition action, null if none + */ + DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); + + /** + * Indicates whether the disposable item (records, record folders) is cutoff or not. + * + * @param nodeRef node reference + * @return boolean true if the disposable item is cutoff, false otherwise + * + * @since 2.0 + */ + boolean isDisposableItemCutoff(NodeRef nodeRef); + + /** + * Marks the disposable item (record or record folder) as cut off, calculating the cut off date + * + * @param nodeRef node reference + * + * @since 2.2 + */ + void cutoffDisposableItem(NodeRef nodeRef); + + /** + * Updates the next disposition action + * + * @param nodeRef node reference + */ + void updateNextDispositionAction(NodeRef nodeRef); + + /** + * Refreshes the disposition action details of the given node. + * + * @param nodeRef node reference + */ + void refreshDispositionAction(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 05b994a87b..70f0a43957 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -1,1073 +1,1073 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Disposition service implementation. - * - * @author Roy Wetherall - */ -@BehaviourBean -public class DispositionServiceImpl extends ServiceBaseImpl - implements DispositionService, - RecordsManagementModel, - RecordsManagementPolicies.OnFileRecord -{ - /** Logger */ - private static Log logger = LogFactory.getLog(DispositionServiceImpl.class); - - /** Behaviour filter */ - private BehaviourFilter behaviourFilter; - - /** Records management service registry */ - private RecordsManagementServiceRegistry serviceRegistry; - - /** Disposition selection strategy */ - private DispositionSelectionStrategy dispositionSelectionStrategy; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Record Folder Service */ - private RecordFolderService recordFolderService; - - /** Record Service */ - private RecordService recordService; - - /** Freeze Service */ - private FreezeService freezeService; - - /** Disposition properties */ - private Map dispositionProperties = new HashMap(4); - - /** - * Set node service - * - * @param nodeService the node service - */ - @Override - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the dictionary service - * - * @param dictionaryServic the dictionary service - */ - @Override - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Set the behaviour filter. - * - * @param behaviourFilter the behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * Set the records management service registry - * - * @param serviceRegistry records management registry service - */ - public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry) - { - this.serviceRegistry = serviceRegistry; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param freezeService freeze service - */ - public void setFreezeService(FreezeService freezeService) - { - this.freezeService = freezeService; - } - - /** - * Set the dispositionSelectionStrategy bean. - * - * @param dispositionSelectionStrategy - */ - public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy) - { - this.dispositionSelectionStrategy = dispositionSelectionStrategy; - } - - /** - * Behavior to initialize the disposition schedule of a newly filed record. - * - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord#onFileRecord(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour(kind=BehaviourKind.CLASS, type="rma:record") - public void onFileRecord(NodeRef nodeRef) - { - // initialise disposition details - if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - DispositionSchedule di = getDispositionSchedule(nodeRef); - if (di != null && di.isRecordLevelDisposition()) - { - nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); - } - } - }; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#refreshDispositionAction(NodeRef) - */ - @Override - public void refreshDispositionAction(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // get this disposition instructions for the node - DispositionSchedule di = getDispositionSchedule(nodeRef); - if (di != null) - { - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); - if (!dispositionActionDefinitions.isEmpty()) - { - // get the first disposition action definition - DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0); - - // initialise the details of the next disposition action - initialiseDispositionAction(nodeRef, nextDispositionActionDefinition); - } - } - } - - /** ========= Disposition Property Methods ========= */ - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#registerDispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) - */ - @Override - public void registerDispositionProperty(DispositionProperty dispositionProperty) - { - dispositionProperties.put(dispositionProperty.getQName(), dispositionProperty); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties(boolean, java.lang.String) - */ - @Override - public Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction) - { - Collection values = dispositionProperties.values(); - List result = new ArrayList(values.size()); - for (DispositionProperty dispositionProperty : values) - { - boolean test = dispositionProperty.applies(isRecordLevel, dispositionAction); - if (test) - { - result.add(dispositionProperty); - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties() - */ - @Override - public Collection getDispositionProperties() - { - return dispositionProperties.values(); - } - - /** ========= Disposition Schedule Methods ========= */ - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public DispositionSchedule getDispositionSchedule(NodeRef nodeRef) - { - DispositionSchedule di = null; - NodeRef diNodeRef = null; - if (isRecord(nodeRef)) - { - // Get the record folders for the record - List recordFolders = recordFolderService.getRecordFolders(nodeRef); - // At this point, we may have disposition instruction objects from 1..n folders. - diNodeRef = dispositionSelectionStrategy.selectDispositionScheduleFrom(recordFolders); - } - else - { - // Get the disposition instructions for the node reference provided - diNodeRef = getDispositionScheduleImpl(nodeRef); - } - - if (diNodeRef != null) - { - di = new DispositionScheduleImpl(serviceRegistry, nodeService, diNodeRef); - } - - return di; - } - - /** - * This method returns a NodeRef - * Gets the disposition instructions - * - * @param nodeRef - * @return - */ - private NodeRef getDispositionScheduleImpl(NodeRef nodeRef) - { - NodeRef result = getAssociatedDispositionScheduleImpl(nodeRef); - - if (result == null) - { - NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef(); - if (parent != null && filePlanService.isRecordCategory(parent)) - { - result = getDispositionScheduleImpl(parent); - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef) - { - DispositionSchedule ds = null; - - // Check the noderef parameter - ParameterCheck.mandatory("nodeRef", nodeRef); - if (nodeService.exists(nodeRef)) - { - // Get the associated disposition schedule node reference - NodeRef dsNodeRef = getAssociatedDispositionScheduleImpl(nodeRef); - if (dsNodeRef != null) - { - // Cerate disposition schedule object - ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); - } - } - - return ds; - } - - /** - * Gets the node reference of the disposition schedule associated with the container. - * - * @param nodeRef node reference of the container - * @return {@link NodeRef} node reference of the disposition schedule, null if none - */ - private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) - { - NodeRef result = null; - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Make sure we are dealing with an RM node - if (!filePlanService.isFilePlanComponent(nodeRef)) - { - throw new AlfrescoRuntimeException("Can not find the associated disposition schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")"); - } - - if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) - { - List childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); - if (childAssocs.size() != 0) - { - ChildAssociationRef firstChildAssocRef = childAssocs.get(0); - result = firstChildAssocRef.getChildRef(); - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedRecordsManagementContainer(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) - */ - @Override - public NodeRef getAssociatedRecordsManagementContainer(DispositionSchedule dispositionSchedule) - { - ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); - NodeRef result = null; - - NodeRef dsNodeRef = dispositionSchedule.getNodeRef(); - if (nodeService.exists(dsNodeRef)) - { - List assocs = this.nodeService.getParentAssocs(dsNodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); - if (assocs.size() != 0) - { - if (assocs.size() != 1) - { - // TODO in the future we should be able to support disposition schedule reuse, but for now just warn that - // only the first disposition schedule will be considered - if (logger.isWarnEnabled()) - { - logger.warn("Disposition schedule has more than one associated records management container. " + - "This is not currently supported so only the first container will be considered. " + - "(dispositionScheduleNodeRef=" + dispositionSchedule.getNodeRef().toString() + ")"); - } - } - - // Get the container reference - ChildAssociationRef assoc = assocs.get(0); - result = assoc.getParentRef(); - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#hasDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) - */ - @Override - public boolean hasDisposableItems(DispositionSchedule dispositionSchdule) - { - return !getDisposableItems(dispositionSchdule).isEmpty(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) - */ - @Override - public List getDisposableItems(DispositionSchedule dispositionSchedule) - { - ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); - - // Get the associated container - NodeRef rmContainer = getAssociatedRecordsManagementContainer(dispositionSchedule); - - // Return the disposable items - return getDisposableItemsImpl(dispositionSchedule.isRecordLevelDisposition(), rmContainer); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItem(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isDisposableItem(NodeRef nodeRef) - { - return nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE); - } - - /** - * - * @param isRecordLevelDisposition - * @param rmContainer - * @param root - * @return - */ - private List getDisposableItemsImpl(boolean isRecordLevelDisposition, NodeRef rmContainer) - { - List items = filePlanService.getAllContained(rmContainer); - List result = new ArrayList(items.size()); - for (NodeRef item : items) - { - if (recordFolderService.isRecordFolder(item)) - { - if (isRecordLevelDisposition) - { - result.addAll(recordService.getRecords(item)); - } - else - { - result.add(item); - } - } - else if (filePlanService.isRecordCategory(item) && getAssociatedDispositionScheduleImpl(item) == null) - { - result.addAll(getDisposableItemsImpl(isRecordLevelDisposition, item)); - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#createDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) - */ - @Override - public DispositionSchedule createDispositionSchedule(NodeRef nodeRef, Map props) - { - NodeRef dsNodeRef = null; - - // Check mandatory parameters - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Check exists - if (!nodeService.exists(nodeRef)) - { - throw new AlfrescoRuntimeException("Unable to create disposition schedule, because node does not exist. (nodeRef=" + nodeRef.toString() + ")"); - } - - // Check is sub-type of rm:recordCategory - QName nodeRefType = nodeService.getType(nodeRef); - if (!TYPE_RECORD_CATEGORY.equals(nodeRefType) && - !dictionaryService.isSubClass(nodeRefType, TYPE_RECORD_CATEGORY)) - { - throw new AlfrescoRuntimeException("Unable to create disposition schedule on a node that is not a records management container."); - } - - behaviourFilter.disableBehaviour(nodeRef, ASPECT_SCHEDULED); - try - { - // Add the schedules aspect if required - if (!nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) - { - nodeService.addAspect(nodeRef, ASPECT_SCHEDULED, null); - } - - // Check whether there is already a disposition schedule object present - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); - if (assocs.size() == 0) - { - DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef); - if (currentDispositionSchdule != null) - { - List items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef); - if (items.size() != 0) - { - throw new AlfrescoRuntimeException("Can not create a disposition schedule if there are disposable items already under the control of an other disposition schedule"); - } - } - - // Create the disposition schedule object - dsNodeRef = nodeService.createNode( - nodeRef, - ASSOC_DISPOSITION_SCHEDULE, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("dispositionSchedule")), - TYPE_DISPOSITION_SCHEDULE, - props).getChildRef(); - } - else - { - // Error since the node already has a disposition schedule set - throw new AlfrescoRuntimeException("Unable to create disposition schedule on node that already has a disposition schedule."); - } - } - finally - { - behaviourFilter.enableBehaviour(nodeRef, ASPECT_SCHEDULED); - } - - // Create the return object - return new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); - } - - /** ========= Disposition Action Definition Methods ========= */ - - /** - * - */ - @Override - public DispositionActionDefinition addDispositionActionDefinition( - DispositionSchedule schedule, - Map actionDefinitionParams) - { - // make sure at least a name has been defined - String name = (String)actionDefinitionParams.get(PROP_DISPOSITION_ACTION_NAME); - if (name == null || name.length() == 0) - { - throw new IllegalArgumentException("'name' parameter is mandatory when creating a disposition action definition"); - } - - // TODO: also check the action name is valid? - - // create the child association from the schedule to the action definition - NodeRef actionNodeRef = this.nodeService.createNode(schedule.getNodeRef(), - RecordsManagementModel.ASSOC_DISPOSITION_ACTION_DEFINITIONS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - QName.createValidLocalName(name)), - RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION, actionDefinitionParams).getChildRef(); - - // get the updated disposition schedule and retrieve the new action definition - NodeRef scheduleParent = this.nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); - DispositionSchedule updatedSchedule = this.getDispositionSchedule(scheduleParent); - return updatedSchedule.getDispositionActionDefinition(actionNodeRef.getId()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#removeDispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule, org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) - */ - @Override - public void removeDispositionActionDefinition(DispositionSchedule schedule, DispositionActionDefinition actionDefinition) - { - // check first whether action definitions can be removed - if (hasDisposableItems(schedule)) - { - throw new AlfrescoRuntimeException("Can not remove action definitions from schedule '" + - schedule.getNodeRef() + "' as one or more record or record folders are present."); - } - - // remove the child node representing the action definition - this.nodeService.removeChild(schedule.getNodeRef(), actionDefinition.getNodeRef()); - } - - /** - * Updates the given disposition action definition belonging to the given disposition - * schedule. - * - * @param schedule The DispositionSchedule the action belongs to - * @param actionDefinition The DispositionActionDefinition to update - * @param actionDefinitionParams Map of parameters to use to update the action definition - * @return The updated DispositionActionDefinition - */ - @Override - public DispositionActionDefinition updateDispositionActionDefinition( - DispositionActionDefinition actionDefinition, - Map actionDefinitionParams) - { - // update the node with properties - this.nodeService.addProperties(actionDefinition.getNodeRef(), actionDefinitionParams); - - // get the updated disposition schedule and retrieve the updated action definition - NodeRef ds = this.nodeService.getPrimaryParent(actionDefinition.getNodeRef()).getParentRef(); - DispositionSchedule updatedSchedule = new DispositionScheduleImpl(serviceRegistry, nodeService, ds); - return updatedSchedule.getDispositionActionDefinition(actionDefinition.getId()); - } - - /** ========= Disposition Action Methods ========= */ - - /** - * Initialises the details of the next disposition action based on the details of a disposition - * action definition. - * - * @param nodeRef node reference - * @param dispositionActionDefinition disposition action definition - */ - private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition) - { - // Create the properties - Map props = new HashMap(10); - - // Calculate the asOf date - Date asOfDate = null; - Period period = dispositionActionDefinition.getPeriod(); - if (period != null) - { - Date contextDate = null; - - // Get the period properties value - QName periodProperty = dispositionActionDefinition.getPeriodProperty(); - if (periodProperty != null) - { - // 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 - contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); - } - else - { - // for now use 'NOW' as the default context date - // TODO set the default period property ... cut off date or last disposition date depending on context - contextDate = new Date(); - } - - // Calculate the as of date - if (contextDate != null) - { - asOfDate = period.getNextDate(contextDate); - } - } - - // Set the property values - props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId()); - props.put(PROP_DISPOSITION_ACTION, dispositionActionDefinition.getName()); - if (asOfDate != null) - { - props.put(PROP_DISPOSITION_AS_OF, asOfDate); - } - - // Create a new disposition action object - NodeRef dispositionActionNodeRef = this.nodeService.createNode( - nodeRef, - ASSOC_NEXT_DISPOSITION_ACTION, - ASSOC_NEXT_DISPOSITION_ACTION, - TYPE_DISPOSITION_ACTION, - props).getChildRef(); - DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); - - // Create the events - List events = dispositionActionDefinition.getEvents(); - for (RecordsManagementEvent event : events) - { - // For every event create an entry on the action - da.addEventCompletionDetails(event); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isNextDispositionActionEligible(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isNextDispositionActionEligible(NodeRef nodeRef) - { - boolean result = false; - - // Get the disposition instructions - DispositionSchedule di = getDispositionSchedule(nodeRef); - NodeRef nextDa = getNextDispositionActionNodeRef(nodeRef); - if (di != null && - this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) && - nextDa != null) - { - // If it has an asOf date and it is greater than now the action is eligible - Date asOf = (Date)this.nodeService.getProperty(nextDa, PROP_DISPOSITION_AS_OF); - if (asOf != null && - asOf.before(new Date())) - { - result = true; - } - - if (!result) - { - DispositionAction da = new DispositionActionImpl(serviceRegistry, nextDa); - DispositionActionDefinition dad = da.getDispositionActionDefinition(); - if (dad != null) - { - boolean firstComplete = dad.eligibleOnFirstCompleteEvent(); - - List assocs = this.nodeService.getChildAssocs(nextDa, ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef eventExecution = assoc.getChildRef(); - Boolean isCompleteValue = (Boolean)this.nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE); - boolean isComplete = false; - if (isCompleteValue != null) - { - isComplete = isCompleteValue.booleanValue(); - - // implement AND and OR combination of event completions - if (isComplete) - { - result = true; - if (firstComplete) - { - break; - } - } - else - { - result = false; - if (!firstComplete) - { - break; - } - } - } - } - } - } - } - - return result; - } - - /** - * Get the next disposition action node. Null if none present. - * - * @param nodeRef the disposable node reference - * @return NodeRef the next disposition action, null if none - */ - private NodeRef getNextDispositionActionNodeRef(NodeRef nodeRef) - { - NodeRef result = null; - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true); - if (assocs.size() != 0) - { - result = assocs.get(0).getChildRef(); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getNextDispositionAction(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public DispositionAction getNextDispositionAction(NodeRef nodeRef) - { - DispositionAction result = null; - NodeRef dispositionActionNodeRef = getNextDispositionActionNodeRef(nodeRef); - - if (dispositionActionNodeRef != null) - { - result = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); - } - return result; - } - - - /** ========= Disposition Action History Methods ========= */ - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getCompletedDispositionActions(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getCompletedDispositionActions(NodeRef nodeRef) - { - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, RegexQNamePattern.MATCH_ALL); - List result = new ArrayList(assocs.size()); - for (ChildAssociationRef assoc : assocs) - { - NodeRef dispositionActionNodeRef = assoc.getChildRef(); - result.add(new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef)); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getLastCompletedDispostionAction(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef) - { - DispositionAction result = null; - List list = getCompletedDispositionActions(nodeRef); - if (!list.isEmpty()) - { - // Get the last disposition action in the list - result = list.get(list.size()-1); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItemCutoff(NodeRef) - */ - @Override - public boolean isDisposableItemCutoff(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - return nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) - */ - @Override - public void updateNextDispositionAction(final NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - RunAsWork runAsWork = new RunAsWork() - { - /** - * @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork() - */ - @Override - public Void doWork() - { - // Get this disposition instructions for the node - DispositionSchedule di = getDispositionSchedule(nodeRef); - if (di != null) - { - // Get the current action node - NodeRef currentDispositionAction = null; - if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION); - if (assocs.size() > 0) - { - currentDispositionAction = assocs.get(0).getChildRef(); - } - } - - if (currentDispositionAction != null) - { - // Move it to the history association - nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); - } - - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); - DispositionActionDefinition currentDispositionActionDefinition = null; - DispositionActionDefinition nextDispositionActionDefinition = null; - - if (currentDispositionAction == null) - { - if (!dispositionActionDefinitions.isEmpty()) - { - // The next disposition action is the first action - nextDispositionActionDefinition = dispositionActionDefinitions.get(0); - } - } - else - { - // Get the current action - String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); - currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); - - // Get the next disposition action - int index = currentDispositionActionDefinition.getIndex(); - index++; - if (index < dispositionActionDefinitions.size()) - { - nextDispositionActionDefinition = dispositionActionDefinitions.get(index); - } - } - - if (nextDispositionActionDefinition != null) - { - if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - // Add the disposition life cycle aspect - nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); - } - - // Create the properties - Map props = new HashMap(10); - - // Calculate the asOf date - Date asOfDate = null; - Period period = nextDispositionActionDefinition.getPeriod(); - if (period != null) - { - Date contextDate = null; - - // Get the period properties value - QName periodProperty = nextDispositionActionDefinition.getPeriodProperty(); - if (periodProperty != null && - !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)) - { - // 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 - contextDate = (Date) nodeService.getProperty(nodeRef, periodProperty); - } - else - { - // for now use 'NOW' as the default context date - // TODO set the default period property ... cut off date or last disposition date depending on context - contextDate = new Date(); - } - - // Calculate the as of date - if (contextDate != null) - { - asOfDate = period.getNextDate(contextDate); - } - } - - // Set the property values - props.put(PROP_DISPOSITION_ACTION_ID, nextDispositionActionDefinition.getId()); - props.put(PROP_DISPOSITION_ACTION, nextDispositionActionDefinition.getName()); - if (asOfDate != null) - { - props.put(PROP_DISPOSITION_AS_OF, asOfDate); - } - - // Create a new disposition action object - NodeRef dispositionActionNodeRef = nodeService.createNode( - nodeRef, - ASSOC_NEXT_DISPOSITION_ACTION, - ASSOC_NEXT_DISPOSITION_ACTION, - TYPE_DISPOSITION_ACTION, - props).getChildRef(); - DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); - - // Create the events - List events = nextDispositionActionDefinition.getEvents(); - for (RecordsManagementEvent event : events) - { - // For every event create an entry on the action - da.addEventCompletionDetails(event); - } - } - } - - return null; - } - }; - - AuthenticationUtil.runAsSystem(runAsWork); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#cutoffDisposableItem(NodeRef) - */ - @Override - public void cutoffDisposableItem(final NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // check that the node ref is a filed record or record folder - if (FilePlanComponentKind.RECORD_FOLDER.equals(filePlanService.getFilePlanComponentKind(nodeRef)) || - FilePlanComponentKind.RECORD.equals(filePlanService.getFilePlanComponentKind(nodeRef))) - { - if (!isDisposableItemCutoff(nodeRef) && !isFrozenOrHasFrozenChildren(nodeRef)) - { - if (recordFolderService.isRecordFolder(nodeRef)) - { - // cut off all the children first - for (NodeRef record : recordService.getRecords(nodeRef)) - { - applyCutoff(record); - } - } - - // apply cut off - applyCutoff(nodeRef); - - // remove uncut off aspect if applied - if(nodeService.hasAspect(nodeRef, ASPECT_UNCUT_OFF)) - { - nodeService.removeAspect(nodeRef, ASPECT_UNCUT_OFF); - } - - // close the record folder if it isn't already closed! - if (recordFolderService.isRecordFolder(nodeRef) && - !recordFolderService.isRecordFolderClosed(nodeRef)) - { - // runAs system so that we can close a record that has already been cutoff - authenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - recordFolderService.closeRecordFolder(nodeRef); - return null; - } - }); - } - } - else - { - throw new AlfrescoRuntimeException("unable to perform cutoff, because node is frozen or has frozen children"); - } - } - else - { - throw new AlfrescoRuntimeException("Unable to peform cutoff, because node is not a disposible item. (nodeRef=" + nodeRef.toString() + ")"); - } - } - - /** - * Helper method to determine if a node is frozen or has frozen children - * - * @param nodeRef Node to be checked - * @return true if the node is frozen or has frozen children, false otherwise - */ - private boolean isFrozenOrHasFrozenChildren(NodeRef nodeRef) - { - boolean result = false; - - if (recordFolderService.isRecordFolder(nodeRef)) - { - result = freezeService.isFrozen(nodeRef) || freezeService.hasFrozenChildren(nodeRef); - } - else if (recordService.isRecord(nodeRef)) - { - result = freezeService.isFrozen(nodeRef); - } - else - { - throw new AlfrescoRuntimeException("The nodeRef '" + nodeRef + "' is neither a record nor a record folder."); - } - - return result; - } - - /** - * Helper method to apply the cut off - * - * @param nodeRef node to cut off - */ - private void applyCutoff(final NodeRef nodeRef) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // Apply the cut off aspect and set cut off date - Map cutOffProps = new HashMap(1); - cutOffProps.put(PROP_CUT_OFF_DATE, new Date()); - nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Disposition service implementation. + * + * @author Roy Wetherall + */ +@BehaviourBean +public class DispositionServiceImpl extends ServiceBaseImpl + implements DispositionService, + RecordsManagementModel, + RecordsManagementPolicies.OnFileRecord +{ + /** Logger */ + private static Log logger = LogFactory.getLog(DispositionServiceImpl.class); + + /** Behaviour filter */ + private BehaviourFilter behaviourFilter; + + /** Records management service registry */ + private RecordsManagementServiceRegistry serviceRegistry; + + /** Disposition selection strategy */ + private DispositionSelectionStrategy dispositionSelectionStrategy; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Record Folder Service */ + private RecordFolderService recordFolderService; + + /** Record Service */ + private RecordService recordService; + + /** Freeze Service */ + private FreezeService freezeService; + + /** Disposition properties */ + private Map dispositionProperties = new HashMap(4); + + /** + * Set node service + * + * @param nodeService the node service + */ + @Override + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set the dictionary service + * + * @param dictionaryServic the dictionary service + */ + @Override + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Set the behaviour filter. + * + * @param behaviourFilter the behaviour filter + */ + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * Set the records management service registry + * + * @param serviceRegistry records management registry service + */ + public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry) + { + this.serviceRegistry = serviceRegistry; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param freezeService freeze service + */ + public void setFreezeService(FreezeService freezeService) + { + this.freezeService = freezeService; + } + + /** + * Set the dispositionSelectionStrategy bean. + * + * @param dispositionSelectionStrategy + */ + public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy) + { + this.dispositionSelectionStrategy = dispositionSelectionStrategy; + } + + /** + * Behavior to initialize the disposition schedule of a newly filed record. + * + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord#onFileRecord(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour(kind=BehaviourKind.CLASS, type="rma:record") + public void onFileRecord(NodeRef nodeRef) + { + // initialise disposition details + if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + DispositionSchedule di = getDispositionSchedule(nodeRef); + if (di != null && di.isRecordLevelDisposition()) + { + nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); + } + } + }; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#refreshDispositionAction(NodeRef) + */ + @Override + public void refreshDispositionAction(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // get this disposition instructions for the node + DispositionSchedule di = getDispositionSchedule(nodeRef); + if (di != null) + { + List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + if (!dispositionActionDefinitions.isEmpty()) + { + // get the first disposition action definition + DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0); + + // initialise the details of the next disposition action + initialiseDispositionAction(nodeRef, nextDispositionActionDefinition); + } + } + } + + /** ========= Disposition Property Methods ========= */ + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#registerDispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) + */ + @Override + public void registerDispositionProperty(DispositionProperty dispositionProperty) + { + dispositionProperties.put(dispositionProperty.getQName(), dispositionProperty); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties(boolean, java.lang.String) + */ + @Override + public Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction) + { + Collection values = dispositionProperties.values(); + List result = new ArrayList(values.size()); + for (DispositionProperty dispositionProperty : values) + { + boolean test = dispositionProperty.applies(isRecordLevel, dispositionAction); + if (test) + { + result.add(dispositionProperty); + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties() + */ + @Override + public Collection getDispositionProperties() + { + return dispositionProperties.values(); + } + + /** ========= Disposition Schedule Methods ========= */ + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public DispositionSchedule getDispositionSchedule(NodeRef nodeRef) + { + DispositionSchedule di = null; + NodeRef diNodeRef = null; + if (isRecord(nodeRef)) + { + // Get the record folders for the record + List recordFolders = recordFolderService.getRecordFolders(nodeRef); + // At this point, we may have disposition instruction objects from 1..n folders. + diNodeRef = dispositionSelectionStrategy.selectDispositionScheduleFrom(recordFolders); + } + else + { + // Get the disposition instructions for the node reference provided + diNodeRef = getDispositionScheduleImpl(nodeRef); + } + + if (diNodeRef != null) + { + di = new DispositionScheduleImpl(serviceRegistry, nodeService, diNodeRef); + } + + return di; + } + + /** + * This method returns a NodeRef + * Gets the disposition instructions + * + * @param nodeRef + * @return + */ + private NodeRef getDispositionScheduleImpl(NodeRef nodeRef) + { + NodeRef result = getAssociatedDispositionScheduleImpl(nodeRef); + + if (result == null) + { + NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef(); + if (parent != null && filePlanService.isRecordCategory(parent)) + { + result = getDispositionScheduleImpl(parent); + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef) + { + DispositionSchedule ds = null; + + // Check the noderef parameter + ParameterCheck.mandatory("nodeRef", nodeRef); + if (nodeService.exists(nodeRef)) + { + // Get the associated disposition schedule node reference + NodeRef dsNodeRef = getAssociatedDispositionScheduleImpl(nodeRef); + if (dsNodeRef != null) + { + // Cerate disposition schedule object + ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); + } + } + + return ds; + } + + /** + * Gets the node reference of the disposition schedule associated with the container. + * + * @param nodeRef node reference of the container + * @return {@link NodeRef} node reference of the disposition schedule, null if none + */ + private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) + { + NodeRef result = null; + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Make sure we are dealing with an RM node + if (!filePlanService.isFilePlanComponent(nodeRef)) + { + throw new AlfrescoRuntimeException("Can not find the associated disposition schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")"); + } + + if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) + { + List childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); + if (childAssocs.size() != 0) + { + ChildAssociationRef firstChildAssocRef = childAssocs.get(0); + result = firstChildAssocRef.getChildRef(); + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedRecordsManagementContainer(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) + */ + @Override + public NodeRef getAssociatedRecordsManagementContainer(DispositionSchedule dispositionSchedule) + { + ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); + NodeRef result = null; + + NodeRef dsNodeRef = dispositionSchedule.getNodeRef(); + if (nodeService.exists(dsNodeRef)) + { + List assocs = this.nodeService.getParentAssocs(dsNodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); + if (assocs.size() != 0) + { + if (assocs.size() != 1) + { + // TODO in the future we should be able to support disposition schedule reuse, but for now just warn that + // only the first disposition schedule will be considered + if (logger.isWarnEnabled()) + { + logger.warn("Disposition schedule has more than one associated records management container. " + + "This is not currently supported so only the first container will be considered. " + + "(dispositionScheduleNodeRef=" + dispositionSchedule.getNodeRef().toString() + ")"); + } + } + + // Get the container reference + ChildAssociationRef assoc = assocs.get(0); + result = assoc.getParentRef(); + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#hasDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) + */ + @Override + public boolean hasDisposableItems(DispositionSchedule dispositionSchdule) + { + return !getDisposableItems(dispositionSchdule).isEmpty(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) + */ + @Override + public List getDisposableItems(DispositionSchedule dispositionSchedule) + { + ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); + + // Get the associated container + NodeRef rmContainer = getAssociatedRecordsManagementContainer(dispositionSchedule); + + // Return the disposable items + return getDisposableItemsImpl(dispositionSchedule.isRecordLevelDisposition(), rmContainer); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItem(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isDisposableItem(NodeRef nodeRef) + { + return nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE); + } + + /** + * + * @param isRecordLevelDisposition + * @param rmContainer + * @param root + * @return + */ + private List getDisposableItemsImpl(boolean isRecordLevelDisposition, NodeRef rmContainer) + { + List items = filePlanService.getAllContained(rmContainer); + List result = new ArrayList(items.size()); + for (NodeRef item : items) + { + if (recordFolderService.isRecordFolder(item)) + { + if (isRecordLevelDisposition) + { + result.addAll(recordService.getRecords(item)); + } + else + { + result.add(item); + } + } + else if (filePlanService.isRecordCategory(item) && getAssociatedDispositionScheduleImpl(item) == null) + { + result.addAll(getDisposableItemsImpl(isRecordLevelDisposition, item)); + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#createDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) + */ + @Override + public DispositionSchedule createDispositionSchedule(NodeRef nodeRef, Map props) + { + NodeRef dsNodeRef = null; + + // Check mandatory parameters + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Check exists + if (!nodeService.exists(nodeRef)) + { + throw new AlfrescoRuntimeException("Unable to create disposition schedule, because node does not exist. (nodeRef=" + nodeRef.toString() + ")"); + } + + // Check is sub-type of rm:recordCategory + QName nodeRefType = nodeService.getType(nodeRef); + if (!TYPE_RECORD_CATEGORY.equals(nodeRefType) && + !dictionaryService.isSubClass(nodeRefType, TYPE_RECORD_CATEGORY)) + { + throw new AlfrescoRuntimeException("Unable to create disposition schedule on a node that is not a records management container."); + } + + behaviourFilter.disableBehaviour(nodeRef, ASPECT_SCHEDULED); + try + { + // Add the schedules aspect if required + if (!nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) + { + nodeService.addAspect(nodeRef, ASPECT_SCHEDULED, null); + } + + // Check whether there is already a disposition schedule object present + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); + if (assocs.size() == 0) + { + DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef); + if (currentDispositionSchdule != null) + { + List items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef); + if (items.size() != 0) + { + throw new AlfrescoRuntimeException("Can not create a disposition schedule if there are disposable items already under the control of an other disposition schedule"); + } + } + + // Create the disposition schedule object + dsNodeRef = nodeService.createNode( + nodeRef, + ASSOC_DISPOSITION_SCHEDULE, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("dispositionSchedule")), + TYPE_DISPOSITION_SCHEDULE, + props).getChildRef(); + } + else + { + // Error since the node already has a disposition schedule set + throw new AlfrescoRuntimeException("Unable to create disposition schedule on node that already has a disposition schedule."); + } + } + finally + { + behaviourFilter.enableBehaviour(nodeRef, ASPECT_SCHEDULED); + } + + // Create the return object + return new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); + } + + /** ========= Disposition Action Definition Methods ========= */ + + /** + * + */ + @Override + public DispositionActionDefinition addDispositionActionDefinition( + DispositionSchedule schedule, + Map actionDefinitionParams) + { + // make sure at least a name has been defined + String name = (String)actionDefinitionParams.get(PROP_DISPOSITION_ACTION_NAME); + if (name == null || name.length() == 0) + { + throw new IllegalArgumentException("'name' parameter is mandatory when creating a disposition action definition"); + } + + // TODO: also check the action name is valid? + + // create the child association from the schedule to the action definition + NodeRef actionNodeRef = this.nodeService.createNode(schedule.getNodeRef(), + RecordsManagementModel.ASSOC_DISPOSITION_ACTION_DEFINITIONS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, + QName.createValidLocalName(name)), + RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION, actionDefinitionParams).getChildRef(); + + // get the updated disposition schedule and retrieve the new action definition + NodeRef scheduleParent = this.nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); + DispositionSchedule updatedSchedule = this.getDispositionSchedule(scheduleParent); + return updatedSchedule.getDispositionActionDefinition(actionNodeRef.getId()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#removeDispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule, org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) + */ + @Override + public void removeDispositionActionDefinition(DispositionSchedule schedule, DispositionActionDefinition actionDefinition) + { + // check first whether action definitions can be removed + if (hasDisposableItems(schedule)) + { + throw new AlfrescoRuntimeException("Can not remove action definitions from schedule '" + + schedule.getNodeRef() + "' as one or more record or record folders are present."); + } + + // remove the child node representing the action definition + this.nodeService.removeChild(schedule.getNodeRef(), actionDefinition.getNodeRef()); + } + + /** + * Updates the given disposition action definition belonging to the given disposition + * schedule. + * + * @param schedule The DispositionSchedule the action belongs to + * @param actionDefinition The DispositionActionDefinition to update + * @param actionDefinitionParams Map of parameters to use to update the action definition + * @return The updated DispositionActionDefinition + */ + @Override + public DispositionActionDefinition updateDispositionActionDefinition( + DispositionActionDefinition actionDefinition, + Map actionDefinitionParams) + { + // update the node with properties + this.nodeService.addProperties(actionDefinition.getNodeRef(), actionDefinitionParams); + + // get the updated disposition schedule and retrieve the updated action definition + NodeRef ds = this.nodeService.getPrimaryParent(actionDefinition.getNodeRef()).getParentRef(); + DispositionSchedule updatedSchedule = new DispositionScheduleImpl(serviceRegistry, nodeService, ds); + return updatedSchedule.getDispositionActionDefinition(actionDefinition.getId()); + } + + /** ========= Disposition Action Methods ========= */ + + /** + * Initialises the details of the next disposition action based on the details of a disposition + * action definition. + * + * @param nodeRef node reference + * @param dispositionActionDefinition disposition action definition + */ + private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition) + { + // Create the properties + Map props = new HashMap(10); + + // Calculate the asOf date + Date asOfDate = null; + Period period = dispositionActionDefinition.getPeriod(); + if (period != null) + { + Date contextDate = null; + + // Get the period properties value + QName periodProperty = dispositionActionDefinition.getPeriodProperty(); + if (periodProperty != null) + { + // 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 + contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); + } + else + { + // for now use 'NOW' as the default context date + // TODO set the default period property ... cut off date or last disposition date depending on context + contextDate = new Date(); + } + + // Calculate the as of date + if (contextDate != null) + { + asOfDate = period.getNextDate(contextDate); + } + } + + // Set the property values + props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId()); + props.put(PROP_DISPOSITION_ACTION, dispositionActionDefinition.getName()); + if (asOfDate != null) + { + props.put(PROP_DISPOSITION_AS_OF, asOfDate); + } + + // Create a new disposition action object + NodeRef dispositionActionNodeRef = this.nodeService.createNode( + nodeRef, + ASSOC_NEXT_DISPOSITION_ACTION, + ASSOC_NEXT_DISPOSITION_ACTION, + TYPE_DISPOSITION_ACTION, + props).getChildRef(); + DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); + + // Create the events + List events = dispositionActionDefinition.getEvents(); + for (RecordsManagementEvent event : events) + { + // For every event create an entry on the action + da.addEventCompletionDetails(event); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isNextDispositionActionEligible(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isNextDispositionActionEligible(NodeRef nodeRef) + { + boolean result = false; + + // Get the disposition instructions + DispositionSchedule di = getDispositionSchedule(nodeRef); + NodeRef nextDa = getNextDispositionActionNodeRef(nodeRef); + if (di != null && + this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) && + nextDa != null) + { + // If it has an asOf date and it is greater than now the action is eligible + Date asOf = (Date)this.nodeService.getProperty(nextDa, PROP_DISPOSITION_AS_OF); + if (asOf != null && + asOf.before(new Date())) + { + result = true; + } + + if (!result) + { + DispositionAction da = new DispositionActionImpl(serviceRegistry, nextDa); + DispositionActionDefinition dad = da.getDispositionActionDefinition(); + if (dad != null) + { + boolean firstComplete = dad.eligibleOnFirstCompleteEvent(); + + List assocs = this.nodeService.getChildAssocs(nextDa, ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef eventExecution = assoc.getChildRef(); + Boolean isCompleteValue = (Boolean)this.nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE); + boolean isComplete = false; + if (isCompleteValue != null) + { + isComplete = isCompleteValue.booleanValue(); + + // implement AND and OR combination of event completions + if (isComplete) + { + result = true; + if (firstComplete) + { + break; + } + } + else + { + result = false; + if (!firstComplete) + { + break; + } + } + } + } + } + } + } + + return result; + } + + /** + * Get the next disposition action node. Null if none present. + * + * @param nodeRef the disposable node reference + * @return NodeRef the next disposition action, null if none + */ + private NodeRef getNextDispositionActionNodeRef(NodeRef nodeRef) + { + NodeRef result = null; + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true); + if (assocs.size() != 0) + { + result = assocs.get(0).getChildRef(); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getNextDispositionAction(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public DispositionAction getNextDispositionAction(NodeRef nodeRef) + { + DispositionAction result = null; + NodeRef dispositionActionNodeRef = getNextDispositionActionNodeRef(nodeRef); + + if (dispositionActionNodeRef != null) + { + result = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); + } + return result; + } + + + /** ========= Disposition Action History Methods ========= */ + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getCompletedDispositionActions(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getCompletedDispositionActions(NodeRef nodeRef) + { + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, RegexQNamePattern.MATCH_ALL); + List result = new ArrayList(assocs.size()); + for (ChildAssociationRef assoc : assocs) + { + NodeRef dispositionActionNodeRef = assoc.getChildRef(); + result.add(new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef)); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getLastCompletedDispostionAction(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef) + { + DispositionAction result = null; + List list = getCompletedDispositionActions(nodeRef); + if (!list.isEmpty()) + { + // Get the last disposition action in the list + result = list.get(list.size()-1); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItemCutoff(NodeRef) + */ + @Override + public boolean isDisposableItemCutoff(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) + */ + @Override + public void updateNextDispositionAction(final NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + RunAsWork runAsWork = new RunAsWork() + { + /** + * @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork() + */ + @Override + public Void doWork() + { + // Get this disposition instructions for the node + DispositionSchedule di = getDispositionSchedule(nodeRef); + if (di != null) + { + // Get the current action node + NodeRef currentDispositionAction = null; + if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION); + if (assocs.size() > 0) + { + currentDispositionAction = assocs.get(0).getChildRef(); + } + } + + if (currentDispositionAction != null) + { + // Move it to the history association + nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); + } + + List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + DispositionActionDefinition currentDispositionActionDefinition = null; + DispositionActionDefinition nextDispositionActionDefinition = null; + + if (currentDispositionAction == null) + { + if (!dispositionActionDefinitions.isEmpty()) + { + // The next disposition action is the first action + nextDispositionActionDefinition = dispositionActionDefinitions.get(0); + } + } + else + { + // Get the current action + String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); + currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); + + // Get the next disposition action + int index = currentDispositionActionDefinition.getIndex(); + index++; + if (index < dispositionActionDefinitions.size()) + { + nextDispositionActionDefinition = dispositionActionDefinitions.get(index); + } + } + + if (nextDispositionActionDefinition != null) + { + if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + // Add the disposition life cycle aspect + nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); + } + + // Create the properties + Map props = new HashMap(10); + + // Calculate the asOf date + Date asOfDate = null; + Period period = nextDispositionActionDefinition.getPeriod(); + if (period != null) + { + Date contextDate = null; + + // Get the period properties value + QName periodProperty = nextDispositionActionDefinition.getPeriodProperty(); + if (periodProperty != null && + !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)) + { + // 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 + contextDate = (Date) nodeService.getProperty(nodeRef, periodProperty); + } + else + { + // for now use 'NOW' as the default context date + // TODO set the default period property ... cut off date or last disposition date depending on context + contextDate = new Date(); + } + + // Calculate the as of date + if (contextDate != null) + { + asOfDate = period.getNextDate(contextDate); + } + } + + // Set the property values + props.put(PROP_DISPOSITION_ACTION_ID, nextDispositionActionDefinition.getId()); + props.put(PROP_DISPOSITION_ACTION, nextDispositionActionDefinition.getName()); + if (asOfDate != null) + { + props.put(PROP_DISPOSITION_AS_OF, asOfDate); + } + + // Create a new disposition action object + NodeRef dispositionActionNodeRef = nodeService.createNode( + nodeRef, + ASSOC_NEXT_DISPOSITION_ACTION, + ASSOC_NEXT_DISPOSITION_ACTION, + TYPE_DISPOSITION_ACTION, + props).getChildRef(); + DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef); + + // Create the events + List events = nextDispositionActionDefinition.getEvents(); + for (RecordsManagementEvent event : events) + { + // For every event create an entry on the action + da.addEventCompletionDetails(event); + } + } + } + + return null; + } + }; + + AuthenticationUtil.runAsSystem(runAsWork); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#cutoffDisposableItem(NodeRef) + */ + @Override + public void cutoffDisposableItem(final NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // check that the node ref is a filed record or record folder + if (FilePlanComponentKind.RECORD_FOLDER.equals(filePlanService.getFilePlanComponentKind(nodeRef)) || + FilePlanComponentKind.RECORD.equals(filePlanService.getFilePlanComponentKind(nodeRef))) + { + if (!isDisposableItemCutoff(nodeRef) && !isFrozenOrHasFrozenChildren(nodeRef)) + { + if (recordFolderService.isRecordFolder(nodeRef)) + { + // cut off all the children first + for (NodeRef record : recordService.getRecords(nodeRef)) + { + applyCutoff(record); + } + } + + // apply cut off + applyCutoff(nodeRef); + + // remove uncut off aspect if applied + if(nodeService.hasAspect(nodeRef, ASPECT_UNCUT_OFF)) + { + nodeService.removeAspect(nodeRef, ASPECT_UNCUT_OFF); + } + + // close the record folder if it isn't already closed! + if (recordFolderService.isRecordFolder(nodeRef) && + !recordFolderService.isRecordFolderClosed(nodeRef)) + { + // runAs system so that we can close a record that has already been cutoff + authenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() throws Exception + { + recordFolderService.closeRecordFolder(nodeRef); + return null; + } + }); + } + } + else + { + throw new AlfrescoRuntimeException("unable to perform cutoff, because node is frozen or has frozen children"); + } + } + else + { + throw new AlfrescoRuntimeException("Unable to peform cutoff, because node is not a disposible item. (nodeRef=" + nodeRef.toString() + ")"); + } + } + + /** + * Helper method to determine if a node is frozen or has frozen children + * + * @param nodeRef Node to be checked + * @return true if the node is frozen or has frozen children, false otherwise + */ + private boolean isFrozenOrHasFrozenChildren(NodeRef nodeRef) + { + boolean result = false; + + if (recordFolderService.isRecordFolder(nodeRef)) + { + result = freezeService.isFrozen(nodeRef) || freezeService.hasFrozenChildren(nodeRef); + } + else if (recordService.isRecord(nodeRef)) + { + result = freezeService.isFrozen(nodeRef); + } + else + { + throw new AlfrescoRuntimeException("The nodeRef '" + nodeRef + "' is neither a record nor a record folder."); + } + + return result; + } + + /** + * Helper method to apply the cut off + * + * @param nodeRef node to cut off + */ + private void applyCutoff(final NodeRef nodeRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Apply the cut off aspect and set cut off date + Map cutOffProps = new HashMap(1); + cutOffProps.put(PROP_CUT_OFF_DATE, new Date()); + nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps); + + return null; + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/property/DispositionProperty.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/property/DispositionProperty.java index 0cd4b92f32..642efc6265 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/property/DispositionProperty.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/property/DispositionProperty.java @@ -1,267 +1,267 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.disposition.property; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Disposition property implementation bean. - * - * @author Roy Wetherall - */ -@BehaviourBean -public class DispositionProperty extends BaseBehaviourBean - implements NodeServicePolicies.OnUpdatePropertiesPolicy -{ - /** Property QName */ - private QName propertyName; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Indicates whether this disposition property applies to a folder level disposition */ - private boolean appliesToFolderLevel = true; - - /** Indicates whether this disposition property applies to a record level disposition */ - private boolean appliesToRecordLevel = true; - - /** Set of disposition actions this property does not apply to */ - private Set excludedDispositionActions; - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param propertyName property name (as string) - */ - public void setName(String propertyName) - { - this.propertyName = QName.createQName(propertyName, namespaceService); - } - - /** - * @return property QName - */ - public QName getQName() - { - return this.propertyName; - } - - /** - * @return property definition - */ - public PropertyDefinition getPropertyDefinition() - { - return dictionaryService.getProperty(propertyName); - } - - /** - * @param excludedDispositionActions list of excluded disposition actions - */ - public void setExcludedDispositionActions(Set excludedDispositionActions) - { - this.excludedDispositionActions = excludedDispositionActions; - } - - /** - * @param appliesToFolderLevel - */ - public void setAppliesToFolderLevel(boolean appliesToFolderLevel) - { - this.appliesToFolderLevel = appliesToFolderLevel; - } - - /** - * @param appliesToRecordLevel - */ - public void setAppliesToRecordLevel(boolean appliesToRecordLevel) - { - this.appliesToRecordLevel = appliesToRecordLevel; - } - - /** - * Bean initialisation method - */ - public void init() - { - // register with disposition service - dispositionService.registerDispositionProperty(this); - } - - /** - * Indicates whether the disposition property applies given the context. - * - * @param isRecordLevel true if record level disposition schedule, false otherwise - * @param dispositionAction disposition action name - * @return boolean true if applies, false otherwise - */ - public boolean applies(boolean isRecordLevel, String dispositionAction) - { - boolean result = false; - - if ((isRecordLevel && appliesToRecordLevel) || - (!isRecordLevel && appliesToFolderLevel)) - { - if (excludedDispositionActions != null && excludedDispositionActions.size() != 0) - { - if (!excludedDispositionActions.contains(dispositionAction)) - { - result = true; - } - } - else - { - result = true; - } - } - - return result; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:dispositionLifecycle", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onUpdateProperties( - final NodeRef nodeRef, - final Map before, - final Map after) - { - if (nodeService.exists(nodeRef)) - { - // has the property we care about changed? - if (isPropertyUpdated(before, after)) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - Date updatedDateValue = (Date)after.get(propertyName); - if (updatedDateValue != null) - { - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); - if (dispositionAction != null) - { - DispositionActionDefinition daDefinition = dispositionAction.getDispositionActionDefinition(); - // check whether the next disposition action matches this disposition property - if (daDefinition != null && propertyName.equals(daDefinition.getPeriodProperty())) - { - Period period = daDefinition.getPeriod(); - Date updatedAsOf = period.getNextDate(updatedDateValue); - - // update asOf date on the disposition action based on the new property value - NodeRef daNodeRef = dispositionAction.getNodeRef(); - nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf); - } - } - } - else - { - // throw an exception if the property is being 'cleared' - if (before.get(propertyName) != null) - { - throw new AlfrescoRuntimeException( - "Error updating property " + propertyName.toPrefixString(namespaceService) + - " to null, because property is being used to determine a disposition date."); - } - } - - return null; - } - - }, AuthenticationUtil.getSystemUserName()); - } - } - } - - /** - * Indicates whether the property has been updated or not. - * - * @param before - * @param after - * @return - */ - private boolean isPropertyUpdated(Map before, Map after) - { - boolean result = false; - - Serializable beforeValue = before.get(propertyName); - Serializable afterValue = after.get(propertyName); - - if (beforeValue == null && afterValue != null) - { - result = true; - } - else if (beforeValue != null && afterValue == null) - { - result = true; - } - else if (beforeValue != null && afterValue != null && - !beforeValue.equals(afterValue)) - { - result = true; - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.disposition.property; + +import java.io.Serializable; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Disposition property implementation bean. + * + * @author Roy Wetherall + */ +@BehaviourBean +public class DispositionProperty extends BaseBehaviourBean + implements NodeServicePolicies.OnUpdatePropertiesPolicy +{ + /** Property QName */ + private QName propertyName; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Indicates whether this disposition property applies to a folder level disposition */ + private boolean appliesToFolderLevel = true; + + /** Indicates whether this disposition property applies to a record level disposition */ + private boolean appliesToRecordLevel = true; + + /** Set of disposition actions this property does not apply to */ + private Set excludedDispositionActions; + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param propertyName property name (as string) + */ + public void setName(String propertyName) + { + this.propertyName = QName.createQName(propertyName, namespaceService); + } + + /** + * @return property QName + */ + public QName getQName() + { + return this.propertyName; + } + + /** + * @return property definition + */ + public PropertyDefinition getPropertyDefinition() + { + return dictionaryService.getProperty(propertyName); + } + + /** + * @param excludedDispositionActions list of excluded disposition actions + */ + public void setExcludedDispositionActions(Set excludedDispositionActions) + { + this.excludedDispositionActions = excludedDispositionActions; + } + + /** + * @param appliesToFolderLevel + */ + public void setAppliesToFolderLevel(boolean appliesToFolderLevel) + { + this.appliesToFolderLevel = appliesToFolderLevel; + } + + /** + * @param appliesToRecordLevel + */ + public void setAppliesToRecordLevel(boolean appliesToRecordLevel) + { + this.appliesToRecordLevel = appliesToRecordLevel; + } + + /** + * Bean initialisation method + */ + public void init() + { + // register with disposition service + dispositionService.registerDispositionProperty(this); + } + + /** + * Indicates whether the disposition property applies given the context. + * + * @param isRecordLevel true if record level disposition schedule, false otherwise + * @param dispositionAction disposition action name + * @return boolean true if applies, false otherwise + */ + public boolean applies(boolean isRecordLevel, String dispositionAction) + { + boolean result = false; + + if ((isRecordLevel && appliesToRecordLevel) || + (!isRecordLevel && appliesToFolderLevel)) + { + if (excludedDispositionActions != null && excludedDispositionActions.size() != 0) + { + if (!excludedDispositionActions.contains(dispositionAction)) + { + result = true; + } + } + else + { + result = true; + } + } + + return result; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:dispositionLifecycle", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onUpdateProperties( + final NodeRef nodeRef, + final Map before, + final Map after) + { + if (nodeService.exists(nodeRef)) + { + // has the property we care about changed? + if (isPropertyUpdated(before, after)) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + Date updatedDateValue = (Date)after.get(propertyName); + if (updatedDateValue != null) + { + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); + if (dispositionAction != null) + { + DispositionActionDefinition daDefinition = dispositionAction.getDispositionActionDefinition(); + // check whether the next disposition action matches this disposition property + if (daDefinition != null && propertyName.equals(daDefinition.getPeriodProperty())) + { + Period period = daDefinition.getPeriod(); + Date updatedAsOf = period.getNextDate(updatedDateValue); + + // update asOf date on the disposition action based on the new property value + NodeRef daNodeRef = dispositionAction.getNodeRef(); + nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf); + } + } + } + else + { + // throw an exception if the property is being 'cleared' + if (before.get(propertyName) != null) + { + throw new AlfrescoRuntimeException( + "Error updating property " + propertyName.toPrefixString(namespaceService) + + " to null, because property is being used to determine a disposition date."); + } + } + + return null; + } + + }, AuthenticationUtil.getSystemUserName()); + } + } + } + + /** + * Indicates whether the property has been updated or not. + * + * @param before + * @param after + * @return + */ + private boolean isPropertyUpdated(Map before, Map after) + { + boolean result = false; + + Serializable beforeValue = before.get(propertyName); + Serializable afterValue = after.get(propertyName); + + if (beforeValue == null && afterValue != null) + { + result = true; + } + else if (beforeValue != null && afterValue == null) + { + result = true; + } + else if (beforeValue != null && afterValue != null && + !beforeValue.equals(afterValue)) + { + result = true; + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015FilePlanTypeBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015FilePlanTypeBootstrap.java index 330c3aeab1..3d1eb449e4 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015FilePlanTypeBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015FilePlanTypeBootstrap.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.dod5015; - -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; - -/** - * Bootstrap bean that registers the dod:filePlan for creation when - * a dod:site is created. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class DOD5015FilePlanTypeBootstrap implements DOD5015Model -{ - /** RM site type bean */ - private RmSiteType rmSiteType; - - /** - * @param rmSiteType RM site type bean - */ - public void setRmSiteType(RmSiteType rmSiteType) - { - this.rmSiteType = rmSiteType; - } - - /** - * Init method - */ - public void init() - { - // register dod file plan type for the dod site type - rmSiteType.registerFilePlanType(TYPE_DOD_5015_SITE, TYPE_DOD_5015_FILE_PLAN); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.dod5015; + +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; + +/** + * Bootstrap bean that registers the dod:filePlan for creation when + * a dod:site is created. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class DOD5015FilePlanTypeBootstrap implements DOD5015Model +{ + /** RM site type bean */ + private RmSiteType rmSiteType; + + /** + * @param rmSiteType RM site type bean + */ + public void setRmSiteType(RmSiteType rmSiteType) + { + this.rmSiteType = rmSiteType; + } + + /** + * Init method + */ + public void init() + { + // register dod file plan type for the dod site type + rmSiteType.registerFilePlanType(TYPE_DOD_5015_SITE, TYPE_DOD_5015_FILE_PLAN); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015Model.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015Model.java index 3fcc87ac46..ed763f2156 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015Model.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/DOD5015Model.java @@ -1,91 +1,91 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.dod5015; - -import org.alfresco.service.namespace.QName; - - -/** - * Helper class containing DOD 5015 model qualified names - * - * @author Roy Wetherall - */ -public interface DOD5015Model -{ - // Namespace details - String DOD_URI = "http://www.alfresco.org/model/dod5015/1.0"; - String DOD_PREFIX = "dod"; - - // DOD Site - QName TYPE_DOD_5015_SITE = QName.createQName(DOD_URI, "site"); - - // DOD File Plan - QName TYPE_DOD_5015_FILE_PLAN = QName.createQName(DOD_URI, "filePlan"); - - // DOD Record - QName ASPECT_DOD_5015_RECORD = QName.createQName(DOD_URI, "dod5015record"); - QName PROP_ORIGINATOR = QName.createQName(DOD_URI, "originator"); - QName PROP_ORIGINATING_ORGANIZATION = QName.createQName(DOD_URI, "originatingOrganization"); - QName PROP_PUBLICATION_DATE = QName.createQName(DOD_URI, "publicationDate"); - QName PROP_MEDIA_TYPE = QName.createQName(DOD_URI, "mediaType"); - QName PROP_FORMAT = QName.createQName(DOD_URI, "format"); - QName PROP_DATE_RECEIVED = QName.createQName(DOD_URI, "dateReceived"); - QName PROP_ADDRESS = QName.createQName(DOD_URI, "address"); - QName PROP_OTHER_ADDRESS = QName.createQName(DOD_URI, "otherAddress"); - - // Scanned Record - QName ASPECT_SCANNED_RECORD = QName.createQName(DOD_URI, "scannedRecord"); - QName PROP_SCANNED_FORMAT = QName.createQName(DOD_URI, "scannedFormat"); - QName PROP_SCANNED_FORMAT_VERSION = QName.createQName(DOD_URI, "scannedFormatVersion"); - QName PROP_RESOLUTION_X = QName.createQName(DOD_URI, "resolutionX"); - QName PROP_RESOLUTION_Y = QName.createQName(DOD_URI, "resolutionY"); - QName PROP_SCANNED_BIT_DEPTH = QName.createQName(DOD_URI, "scannedBitDepth"); - - // PDF Record - QName ASPECT_PDF_RECORD = QName.createQName(DOD_URI, "pdfRecord"); - QName PROP_PRODUCING_APPLICATION = QName.createQName(DOD_URI, "producingApplication"); - QName PROP_PRODUCING_APPLICATION_VERSION = QName.createQName(DOD_URI, "producingApplicationVersion"); - QName PROP_PDF_VERSION = QName.createQName(DOD_URI, "pdfVersion"); - QName PROP_CREATING_APPLICATION = QName.createQName(DOD_URI, "creatingApplication"); - QName PROP_DOCUMENT_SECURITY_SETTINGS = QName.createQName(DOD_URI, "documentSecuritySettings"); - - // Digital Photograph Record - QName ASPECT_DIGITAL_PHOTOGRAPH_RECORD = QName.createQName(DOD_URI, "digitalPhotographRecord"); - QName PROP_CAPTION = QName.createQName(DOD_URI, "caption"); - QName PROP_PHOTOGRAPHER = QName.createQName(DOD_URI, "photographer"); - QName PROP_COPYRIGHT = QName.createQName(DOD_URI, "copyright"); - QName PROP_BIT_DEPTH = QName.createQName(DOD_URI, "bitDepth"); - QName PROP_IMAGE_SIZE_X = QName.createQName(DOD_URI, "imageSizeX"); - QName PROP_IMAGE_SIZE_Y = QName.createQName(DOD_URI, "imageSizeY"); - QName PROP_IMAGE_SOURCE = QName.createQName(DOD_URI, "imageSource"); - QName PROP_COMPRESSION = QName.createQName(DOD_URI, "compression"); - QName PROP_ICC_ICM_PROFILE = QName.createQName(DOD_URI, "iccIcmProfile"); - QName PROP_EXIF_INFORMATION = QName.createQName(DOD_URI, "exifInformation"); - - // Web Record - QName ASPECT_WEB_RECORD = QName.createQName(DOD_URI, "webRecord"); - QName PROP_WEB_FILE_NAME = QName.createQName(DOD_URI, "webFileName"); - QName PROP_WEB_PLATFORM = QName.createQName(DOD_URI, "webPlatform"); - QName PROP_WEBSITE_NAME = QName.createQName(DOD_URI, "webSiteName"); - QName PROP_WEB_SITE_URL = QName.createQName(DOD_URI, "webSiteURL"); - QName PROP_CAPTURE_METHOD = QName.createQName(DOD_URI, "captureMethod"); - QName PROP_CAPTURE_DATE = QName.createQName(DOD_URI, "captureDate"); - QName PROP_CONTACT = QName.createQName(DOD_URI, "contact"); - QName PROP_CONTENT_MANAGEMENT_SYSTEM = QName.createQName(DOD_URI, "contentManagementSystem"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.dod5015; + +import org.alfresco.service.namespace.QName; + + +/** + * Helper class containing DOD 5015 model qualified names + * + * @author Roy Wetherall + */ +public interface DOD5015Model +{ + // Namespace details + String DOD_URI = "http://www.alfresco.org/model/dod5015/1.0"; + String DOD_PREFIX = "dod"; + + // DOD Site + QName TYPE_DOD_5015_SITE = QName.createQName(DOD_URI, "site"); + + // DOD File Plan + QName TYPE_DOD_5015_FILE_PLAN = QName.createQName(DOD_URI, "filePlan"); + + // DOD Record + QName ASPECT_DOD_5015_RECORD = QName.createQName(DOD_URI, "dod5015record"); + QName PROP_ORIGINATOR = QName.createQName(DOD_URI, "originator"); + QName PROP_ORIGINATING_ORGANIZATION = QName.createQName(DOD_URI, "originatingOrganization"); + QName PROP_PUBLICATION_DATE = QName.createQName(DOD_URI, "publicationDate"); + QName PROP_MEDIA_TYPE = QName.createQName(DOD_URI, "mediaType"); + QName PROP_FORMAT = QName.createQName(DOD_URI, "format"); + QName PROP_DATE_RECEIVED = QName.createQName(DOD_URI, "dateReceived"); + QName PROP_ADDRESS = QName.createQName(DOD_URI, "address"); + QName PROP_OTHER_ADDRESS = QName.createQName(DOD_URI, "otherAddress"); + + // Scanned Record + QName ASPECT_SCANNED_RECORD = QName.createQName(DOD_URI, "scannedRecord"); + QName PROP_SCANNED_FORMAT = QName.createQName(DOD_URI, "scannedFormat"); + QName PROP_SCANNED_FORMAT_VERSION = QName.createQName(DOD_URI, "scannedFormatVersion"); + QName PROP_RESOLUTION_X = QName.createQName(DOD_URI, "resolutionX"); + QName PROP_RESOLUTION_Y = QName.createQName(DOD_URI, "resolutionY"); + QName PROP_SCANNED_BIT_DEPTH = QName.createQName(DOD_URI, "scannedBitDepth"); + + // PDF Record + QName ASPECT_PDF_RECORD = QName.createQName(DOD_URI, "pdfRecord"); + QName PROP_PRODUCING_APPLICATION = QName.createQName(DOD_URI, "producingApplication"); + QName PROP_PRODUCING_APPLICATION_VERSION = QName.createQName(DOD_URI, "producingApplicationVersion"); + QName PROP_PDF_VERSION = QName.createQName(DOD_URI, "pdfVersion"); + QName PROP_CREATING_APPLICATION = QName.createQName(DOD_URI, "creatingApplication"); + QName PROP_DOCUMENT_SECURITY_SETTINGS = QName.createQName(DOD_URI, "documentSecuritySettings"); + + // Digital Photograph Record + QName ASPECT_DIGITAL_PHOTOGRAPH_RECORD = QName.createQName(DOD_URI, "digitalPhotographRecord"); + QName PROP_CAPTION = QName.createQName(DOD_URI, "caption"); + QName PROP_PHOTOGRAPHER = QName.createQName(DOD_URI, "photographer"); + QName PROP_COPYRIGHT = QName.createQName(DOD_URI, "copyright"); + QName PROP_BIT_DEPTH = QName.createQName(DOD_URI, "bitDepth"); + QName PROP_IMAGE_SIZE_X = QName.createQName(DOD_URI, "imageSizeX"); + QName PROP_IMAGE_SIZE_Y = QName.createQName(DOD_URI, "imageSizeY"); + QName PROP_IMAGE_SOURCE = QName.createQName(DOD_URI, "imageSource"); + QName PROP_COMPRESSION = QName.createQName(DOD_URI, "compression"); + QName PROP_ICC_ICM_PROFILE = QName.createQName(DOD_URI, "iccIcmProfile"); + QName PROP_EXIF_INFORMATION = QName.createQName(DOD_URI, "exifInformation"); + + // Web Record + QName ASPECT_WEB_RECORD = QName.createQName(DOD_URI, "webRecord"); + QName PROP_WEB_FILE_NAME = QName.createQName(DOD_URI, "webFileName"); + QName PROP_WEB_PLATFORM = QName.createQName(DOD_URI, "webPlatform"); + QName PROP_WEBSITE_NAME = QName.createQName(DOD_URI, "webSiteName"); + QName PROP_WEB_SITE_URL = QName.createQName(DOD_URI, "webSiteURL"); + QName PROP_CAPTURE_METHOD = QName.createQName(DOD_URI, "captureMethod"); + QName PROP_CAPTURE_DATE = QName.createQName(DOD_URI, "captureDate"); + QName PROP_CONTACT = QName.createQName(DOD_URI, "contact"); + QName PROP_CONTENT_MANAGEMENT_SYSTEM = QName.createQName(DOD_URI, "contentManagementSystem"); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/model/dod/aspect/DOD5015RecordAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/model/dod/aspect/DOD5015RecordAspect.java index be61a1ca47..326fe760c0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/model/dod/aspect/DOD5015RecordAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dod5015/model/dod/aspect/DOD5015RecordAspect.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.dod5015.model.dod.aspect; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * dod:dod5015record behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -public class DOD5015RecordAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnAddAspectPolicy, - DOD5015Model -{ - /** file plan service */ - private FilePlanService filePlanService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Ensure that the DOD record aspect meta-data is applied. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Behaviour - ( - kind=BehaviourKind.CLASS, - type="rma:record", - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - @Override - public void onAddAspect(NodeRef nodeRef, QName aspect) - { - if (nodeService.exists(nodeRef) && - !nodeService.hasAspect(nodeRef, ASPECT_DOD_5015_RECORD) && - isDODFilePlan(nodeRef)) - { - nodeService.addAspect(nodeRef, ASPECT_DOD_5015_RECORD, null); - } - } - - /** - * Helper method to indicate whether the records file plan is a DOD one or not. - * - * @param record record node reference - * @return boolean true if in DOD file plan, false otherwise - */ - private boolean isDODFilePlan(NodeRef record) - { - boolean result = false; - - NodeRef filePlan = filePlanService.getFilePlan(record); - if (filePlan != null && nodeService.exists(filePlan)) - { - result = TYPE_DOD_5015_FILE_PLAN.equals(nodeService.getType(filePlan)); - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.dod5015.model.dod.aspect; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * dod:dod5015record behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +public class DOD5015RecordAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnAddAspectPolicy, + DOD5015Model +{ + /** file plan service */ + private FilePlanService filePlanService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Ensure that the DOD record aspect meta-data is applied. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Behaviour + ( + kind=BehaviourKind.CLASS, + type="rma:record", + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + @Override + public void onAddAspect(NodeRef nodeRef, QName aspect) + { + if (nodeService.exists(nodeRef) && + !nodeService.hasAspect(nodeRef, ASPECT_DOD_5015_RECORD) && + isDODFilePlan(nodeRef)) + { + nodeService.addAspect(nodeRef, ASPECT_DOD_5015_RECORD, null); + } + } + + /** + * Helper method to indicate whether the records file plan is a DOD one or not. + * + * @param record record node reference + * @return boolean true if in DOD file plan, false otherwise + */ + private boolean isDODFilePlan(NodeRef record) + { + boolean result = false; + + NodeRef filePlan = filePlanService.getFilePlan(record); + if (filePlan != null && nodeService.exists(filePlan)) + { + result = TYPE_DOD_5015_FILE_PLAN.equals(nodeService.getType(filePlan)); + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java index 9724a0d05d..e4cb81b571 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.email; - -import java.util.List; -import java.util.Set; - -/** - * Custom EMail Mapping Service - */ -public interface CustomEmailMappingService -{ - /** - * Get the list of custom mappings - * - * @return {@link Set}<{@link CustomMapping}> - */ - Set getCustomMappings(); - - /** - * Add custom mapping - * - * @param from - * @param to - */ - void addCustomMapping(String from, String to); - - /** - * Delete custom mapping - * - * @param from - * @param to - */ - void deleteCustomMapping(String from, String to); - - /** - * Gets the list of email mapping keys - * - * @return Email mapping keys - */ - List getEmailMappingKeys(); - - /** - * Registers an email mapping key with the existing list of email mapping keys - * - * @param emailMappingKey emailMappingKey to register - */ - void registerEMailMappingKey(String emailMappingKey); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.email; + +import java.util.List; +import java.util.Set; + +/** + * Custom EMail Mapping Service + */ +public interface CustomEmailMappingService +{ + /** + * Get the list of custom mappings + * + * @return {@link Set}<{@link CustomMapping}> + */ + Set getCustomMappings(); + + /** + * Add custom mapping + * + * @param from + * @param to + */ + void addCustomMapping(String from, String to); + + /** + * Delete custom mapping + * + * @param from + * @param to + */ + void deleteCustomMapping(String from, String to); + + /** + * Gets the list of email mapping keys + * + * @return Email mapping keys + */ + List getEmailMappingKeys(); + + /** + * Registers an email mapping key with the existing list of email mapping keys + * + * @param emailMappingKey emailMappingKey to register + */ + void registerEMailMappingKey(String emailMappingKey); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java index 904e9e50c0..f751dd2670 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java @@ -1,486 +1,486 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.email; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.metadata.RFC822MetadataExtracter; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -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.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * Custom Email Mapping Service - */ -public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean implements CustomEmailMappingService -{ - /** Logger */ - private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class); - - /** Node reference's to configuration elements */ - private static final NodeRef CONFIG_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_emailmapping_config"); - private static final NodeRef CONFIG_FOLDER_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); - - /** Config file name */ - private static final String CONFIG_NAME = "imapConfig.json"; - - /** Default custom mappings (TODO move to spring config) */ - private static final CustomMapping[] DEFAULT_MAPPINGS = - { - new CustomMapping("Date", "dod:dateReceived"), - new CustomMapping("messageTo", "dod:address"), - new CustomMapping("messageFrom", "dod:originator"), - new CustomMapping("messageSent", "dod:publicationDate"), - new CustomMapping("messageCc", "dod:otherAddress") - }; - - /** Extractor */ - private RFC822MetadataExtracter extracter; - - /** Services */ - private NodeService nodeService; - private NamespacePrefixResolver nspr; - private ContentService contentService; - private TransactionService transactionService; - - /** Transient set of custom mappings */ - private Set customMappings; - - /** List of email mapping keys */ - private List emailMappingKeys; - - /** - * @param nspr namespace service - */ - public void setNamespacePrefixResolver(NamespacePrefixResolver nspr) - { - this.nspr = nspr; - } - - /** - * @param extractor extractor component - */ - public void setExtracter(RFC822MetadataExtracter extractor) - { - this.extracter = extractor; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param transactionService transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * @param emailMappingKeys email mapping keys - */ - public void setEmailMappingKeys(List emailMappingKeys) - { - this.emailMappingKeys = emailMappingKeys; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getCustomMappings() - */ - public Set getCustomMappings() - { - if (customMappings == null) - { - // if we have a config file - if (nodeService.exists(CONFIG_NODE_REF)) - { - // load the contents of the config file - customMappings = loadConfig(); - } - else - { - customMappings = new HashSet(); - - // load the contents of the extractors property file - Map> currentMapping = extracter.getCurrentMapping(); - for (Map.Entry> entry : currentMapping.entrySet()) - { - Set set = entry.getValue(); - - for (QName qname : set) - { - CustomMapping value = new CustomMapping(); - value.setFrom(entry.getKey()); - QName resolvedQname = qname.getPrefixedQName(nspr); - value.setTo(resolvedQname.toPrefixString()); - customMappings.add(value); - } - } - - // if we have an old config file - NodeRef oldConfigNode = getOldConfigNode(); - if (oldConfigNode != null) - { - // load the contents of the old config file - Set oldMappings = readOldConfig(oldConfigNode); - customMappings.addAll(oldMappings); - } - - // load the hard coded mappings - for(CustomMapping mapping : DEFAULT_MAPPINGS) - { - customMappings.add(mapping); - } - - // create the config file - saveConfig(customMappings); - } - } - - return customMappings; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#addCustomMapping(java.lang.String, java.lang.String) - */ - public void addCustomMapping(String from, String to) - { - if (StringUtils.isBlank(from) || StringUtils.isBlank(to)) - { - throw new AlfrescoRuntimeException("Invalid values for from/to."); - } - - // create custom mapping - CustomMapping customMapping = new CustomMapping(from, to); - - // check whether we already have this mapping or not - Set customMappings = getCustomMappings(); - if (customMappings.contains(customMapping)) - { - throw new AlfrescoRuntimeException("Can not add custom email mapping, because duplicate mapping already exists."); - } - - // else add the custom mapping (since we have already called getCustomMapping we can be sure - // the member variable is populated) - customMappings.add(customMapping); - - // save the changes into the config file - saveConfig(customMappings); - - // update the extractors configuration - updateExtractor(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#deleteCustomMapping(java.lang.String, java.lang.String) - */ - public void deleteCustomMapping(String from, String to) - { - if (StringUtils.isBlank(from) || StringUtils.isBlank(to)) - { - throw new AlfrescoRuntimeException("Invalid values for from/to."); - } - - // create custom mapping - CustomMapping customMapping = new CustomMapping(from, to); - - // check whether we already have this mapping or not - Set customMappings = getCustomMappings(); - if (customMappings.contains(customMapping)) - { - // else remove the custom mapping (since we have already called getCustomMapping we can be sure - // the member variable is populated) - customMappings.remove(customMapping); - - // save the changes into the config file - saveConfig(customMappings); - - // update the extractors configuration - updateExtractor(); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getEmailMappingKeys() - */ - @Override - public List getEmailMappingKeys() - { - return emailMappingKeys; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService#registerEMailMappingKey(java.lang.String) - */ - @Override - public void registerEMailMappingKey(String emailMappingKey) - { - ParameterCheck.mandatoryString("emailMappingKey", emailMappingKey); - - emailMappingKeys.add(emailMappingKey); - } - - /** - * Updates the extractor with the custom configuration. - */ - private void updateExtractor() - { - // convert the mapping information into the form understood by the extractor - Map> newMapping = new HashMap>(17); - for(CustomMapping mapping : getCustomMappings()) - { - QName newQName = QName.createQName(mapping.getTo(), nspr); - Set values = newMapping.get(mapping.getFrom()); - if(values == null) - { - values = new HashSet(); - newMapping.put(mapping.getFrom(), values); - } - values.add(newQName); - } - - // update the metadata extracter - extracter.setMapping(newMapping); - } - - /** - * Loads the custom mappings from the configuration file. - * - * @return - */ - private Set loadConfig() - { - Set result = new HashSet(); - ContentReader cr = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT); - if (cr != null) - { - String text = cr.getContentString(); - - try - { - JSONArray jsonArray = new JSONArray(new JSONTokener(text)); - for(int i = 0 ; i < jsonArray.length(); i++) - { - JSONObject obj = jsonArray.getJSONObject(i); - CustomMapping mapping = new CustomMapping(); - mapping.setFrom(obj.getString("from")); - mapping.setTo(obj.getString("to")); - result.add(mapping); - } - } - catch (JSONException je) - { - throw new AlfrescoRuntimeException("Unable to read custom email configuration", je); - } - } - - return result; - } - - /** - * - * @param customMappingsToSave - */ - private void saveConfig(Set customMappingsToSave) - { - if (!nodeService.exists(CONFIG_NODE_REF)) - { - // create the config node - Map properties = new HashMap(2); - properties.put(ContentModel.PROP_NAME, CONFIG_NAME); - properties.put(ContentModel.PROP_NODE_UUID, CONFIG_NODE_REF.getId()); - nodeService.createNode( - CONFIG_FOLDER_NODE_REF, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, CONFIG_NAME), - ContentModel.TYPE_CONTENT, - properties); - } - - // build JSON array of mappings - JSONArray jsonMappings = new JSONArray(); - try - { - for(CustomMapping mapping : customMappingsToSave) - { - JSONObject obj = new JSONObject(); - obj.put("from", mapping.getFrom()); - obj.put("to", mapping.getTo()); - jsonMappings.put(obj); - } - } - catch (JSONException je) - { - throw new AlfrescoRuntimeException("Unable to create JSON email mapping configuration during save.", je); - } - - // update the content - ContentWriter writer = this.contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - writer.putContent(jsonMappings.toString()); - } - - /** - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) - */ - @Override - protected void onBootstrap(ApplicationEvent event) - { - // run as System on bootstrap - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() - { - try - { - // update the extractor with the custom mappings - updateExtractor(); - } - catch (RuntimeException e) - { - // log a warning - if (logger.isWarnEnabled()) - { - logger.warn(e.getMessage()); - } - - // reset the mappings - customMappings = null; - - // rethrow - throw e; - } - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(callback); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) - */ - @Override - protected void onShutdown(ApplicationEvent arg0) - { - // No implementation - } - - /** - * Helper method to get the old configuration node. This is used during the migration - * from 1.0 to 2.0. - *

- * Returns null if it does not exist. - * - * @return {@link NodeRef} node reference of the old configuration node, null otherwise - */ - private NodeRef getOldConfigNode() - { - NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - return nodeService.getChildByName(rootNode, RecordsManagementModel.ASSOC_EMAIL_CONFIG, CONFIG_NAME); - } - - /** - * Reads the old configuration node. This is used during the migration from 1.0 to 2.0. - * - * @param nodeRef the old configuration node reference - * @return {@link Set}<{@link CustomMapping}> set of the custom mappings stored in the old configuration - */ - private Set readOldConfig(NodeRef nodeRef) - { - Set newMappings = new HashSet(); - - ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - if (cr != null) - { - String text = cr.getContentString(); - - try - { - JSONArray jsonArray = new JSONArray(new JSONTokener(text)); - for(int i = 0 ; i < jsonArray.length(); i++) - { - JSONObject obj = jsonArray.getJSONObject(i); - CustomMapping mapping = new CustomMapping(); - mapping.setFrom(obj.getString("from")); - mapping.setTo(obj.getString("to")); - newMappings.add(mapping); - } - return newMappings; - } - catch (JSONException je) - { - logger.warn("unable to read custom email configuration", je); - return newMappings; - } - - } - return newMappings; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.email; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.content.metadata.RFC822MetadataExtracter; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +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.service.namespace.NamespacePrefixResolver; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.context.ApplicationEvent; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; + +/** + * Custom Email Mapping Service + */ +public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean implements CustomEmailMappingService +{ + /** Logger */ + private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class); + + /** Node reference's to configuration elements */ + private static final NodeRef CONFIG_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_emailmapping_config"); + private static final NodeRef CONFIG_FOLDER_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); + + /** Config file name */ + private static final String CONFIG_NAME = "imapConfig.json"; + + /** Default custom mappings (TODO move to spring config) */ + private static final CustomMapping[] DEFAULT_MAPPINGS = + { + new CustomMapping("Date", "dod:dateReceived"), + new CustomMapping("messageTo", "dod:address"), + new CustomMapping("messageFrom", "dod:originator"), + new CustomMapping("messageSent", "dod:publicationDate"), + new CustomMapping("messageCc", "dod:otherAddress") + }; + + /** Extractor */ + private RFC822MetadataExtracter extracter; + + /** Services */ + private NodeService nodeService; + private NamespacePrefixResolver nspr; + private ContentService contentService; + private TransactionService transactionService; + + /** Transient set of custom mappings */ + private Set customMappings; + + /** List of email mapping keys */ + private List emailMappingKeys; + + /** + * @param nspr namespace service + */ + public void setNamespacePrefixResolver(NamespacePrefixResolver nspr) + { + this.nspr = nspr; + } + + /** + * @param extractor extractor component + */ + public void setExtracter(RFC822MetadataExtracter extractor) + { + this.extracter = extractor; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * @param emailMappingKeys email mapping keys + */ + public void setEmailMappingKeys(List emailMappingKeys) + { + this.emailMappingKeys = emailMappingKeys; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getCustomMappings() + */ + public Set getCustomMappings() + { + if (customMappings == null) + { + // if we have a config file + if (nodeService.exists(CONFIG_NODE_REF)) + { + // load the contents of the config file + customMappings = loadConfig(); + } + else + { + customMappings = new HashSet(); + + // load the contents of the extractors property file + Map> currentMapping = extracter.getCurrentMapping(); + for (Map.Entry> entry : currentMapping.entrySet()) + { + Set set = entry.getValue(); + + for (QName qname : set) + { + CustomMapping value = new CustomMapping(); + value.setFrom(entry.getKey()); + QName resolvedQname = qname.getPrefixedQName(nspr); + value.setTo(resolvedQname.toPrefixString()); + customMappings.add(value); + } + } + + // if we have an old config file + NodeRef oldConfigNode = getOldConfigNode(); + if (oldConfigNode != null) + { + // load the contents of the old config file + Set oldMappings = readOldConfig(oldConfigNode); + customMappings.addAll(oldMappings); + } + + // load the hard coded mappings + for(CustomMapping mapping : DEFAULT_MAPPINGS) + { + customMappings.add(mapping); + } + + // create the config file + saveConfig(customMappings); + } + } + + return customMappings; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#addCustomMapping(java.lang.String, java.lang.String) + */ + public void addCustomMapping(String from, String to) + { + if (StringUtils.isBlank(from) || StringUtils.isBlank(to)) + { + throw new AlfrescoRuntimeException("Invalid values for from/to."); + } + + // create custom mapping + CustomMapping customMapping = new CustomMapping(from, to); + + // check whether we already have this mapping or not + Set customMappings = getCustomMappings(); + if (customMappings.contains(customMapping)) + { + throw new AlfrescoRuntimeException("Can not add custom email mapping, because duplicate mapping already exists."); + } + + // else add the custom mapping (since we have already called getCustomMapping we can be sure + // the member variable is populated) + customMappings.add(customMapping); + + // save the changes into the config file + saveConfig(customMappings); + + // update the extractors configuration + updateExtractor(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#deleteCustomMapping(java.lang.String, java.lang.String) + */ + public void deleteCustomMapping(String from, String to) + { + if (StringUtils.isBlank(from) || StringUtils.isBlank(to)) + { + throw new AlfrescoRuntimeException("Invalid values for from/to."); + } + + // create custom mapping + CustomMapping customMapping = new CustomMapping(from, to); + + // check whether we already have this mapping or not + Set customMappings = getCustomMappings(); + if (customMappings.contains(customMapping)) + { + // else remove the custom mapping (since we have already called getCustomMapping we can be sure + // the member variable is populated) + customMappings.remove(customMapping); + + // save the changes into the config file + saveConfig(customMappings); + + // update the extractors configuration + updateExtractor(); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getEmailMappingKeys() + */ + @Override + public List getEmailMappingKeys() + { + return emailMappingKeys; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService#registerEMailMappingKey(java.lang.String) + */ + @Override + public void registerEMailMappingKey(String emailMappingKey) + { + ParameterCheck.mandatoryString("emailMappingKey", emailMappingKey); + + emailMappingKeys.add(emailMappingKey); + } + + /** + * Updates the extractor with the custom configuration. + */ + private void updateExtractor() + { + // convert the mapping information into the form understood by the extractor + Map> newMapping = new HashMap>(17); + for(CustomMapping mapping : getCustomMappings()) + { + QName newQName = QName.createQName(mapping.getTo(), nspr); + Set values = newMapping.get(mapping.getFrom()); + if(values == null) + { + values = new HashSet(); + newMapping.put(mapping.getFrom(), values); + } + values.add(newQName); + } + + // update the metadata extracter + extracter.setMapping(newMapping); + } + + /** + * Loads the custom mappings from the configuration file. + * + * @return + */ + private Set loadConfig() + { + Set result = new HashSet(); + ContentReader cr = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT); + if (cr != null) + { + String text = cr.getContentString(); + + try + { + JSONArray jsonArray = new JSONArray(new JSONTokener(text)); + for(int i = 0 ; i < jsonArray.length(); i++) + { + JSONObject obj = jsonArray.getJSONObject(i); + CustomMapping mapping = new CustomMapping(); + mapping.setFrom(obj.getString("from")); + mapping.setTo(obj.getString("to")); + result.add(mapping); + } + } + catch (JSONException je) + { + throw new AlfrescoRuntimeException("Unable to read custom email configuration", je); + } + } + + return result; + } + + /** + * + * @param customMappingsToSave + */ + private void saveConfig(Set customMappingsToSave) + { + if (!nodeService.exists(CONFIG_NODE_REF)) + { + // create the config node + Map properties = new HashMap(2); + properties.put(ContentModel.PROP_NAME, CONFIG_NAME); + properties.put(ContentModel.PROP_NODE_UUID, CONFIG_NODE_REF.getId()); + nodeService.createNode( + CONFIG_FOLDER_NODE_REF, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, CONFIG_NAME), + ContentModel.TYPE_CONTENT, + properties); + } + + // build JSON array of mappings + JSONArray jsonMappings = new JSONArray(); + try + { + for(CustomMapping mapping : customMappingsToSave) + { + JSONObject obj = new JSONObject(); + obj.put("from", mapping.getFrom()); + obj.put("to", mapping.getTo()); + jsonMappings.put(obj); + } + } + catch (JSONException je) + { + throw new AlfrescoRuntimeException("Unable to create JSON email mapping configuration during save.", je); + } + + // update the content + ContentWriter writer = this.contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.setEncoding("UTF-8"); + writer.putContent(jsonMappings.toString()); + } + + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onBootstrap(ApplicationEvent event) + { + // run as System on bootstrap + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() + { + try + { + // update the extractor with the custom mappings + updateExtractor(); + } + catch (RuntimeException e) + { + // log a warning + if (logger.isWarnEnabled()) + { + logger.warn(e.getMessage()); + } + + // reset the mappings + customMappings = null; + + // rethrow + throw e; + } + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(callback); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onShutdown(ApplicationEvent arg0) + { + // No implementation + } + + /** + * Helper method to get the old configuration node. This is used during the migration + * from 1.0 to 2.0. + *

+ * Returns null if it does not exist. + * + * @return {@link NodeRef} node reference of the old configuration node, null otherwise + */ + private NodeRef getOldConfigNode() + { + NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + return nodeService.getChildByName(rootNode, RecordsManagementModel.ASSOC_EMAIL_CONFIG, CONFIG_NAME); + } + + /** + * Reads the old configuration node. This is used during the migration from 1.0 to 2.0. + * + * @param nodeRef the old configuration node reference + * @return {@link Set}<{@link CustomMapping}> set of the custom mappings stored in the old configuration + */ + private Set readOldConfig(NodeRef nodeRef) + { + Set newMappings = new HashSet(); + + ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); + if (cr != null) + { + String text = cr.getContentString(); + + try + { + JSONArray jsonArray = new JSONArray(new JSONTokener(text)); + for(int i = 0 ; i < jsonArray.length(); i++) + { + JSONObject obj = jsonArray.getJSONObject(i); + CustomMapping mapping = new CustomMapping(); + mapping.setFrom(obj.getString("from")); + mapping.setTo(obj.getString("to")); + newMappings.add(mapping); + } + return newMappings; + } + catch (JSONException je) + { + logger.warn("unable to read custom email configuration", je); + return newMappings; + } + + } + return newMappings; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java index 3467b3e57f..b12a75c0f9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.email; - -/** - * Custom EMail Mapping - */ -public class CustomMapping -{ - private String from; - private String to; - - /** - * Default constructor. - */ - public CustomMapping() - { - } - - /** - * Default constructor. - * @param from - * @param to - */ - public CustomMapping(String from, String to) - { - this.from = from; - this.to = to; - } - - public void setFrom(String from) - { - this.from = from; - } - - public String getFrom() - { - return from; - } - - public void setTo(String to) - { - this.to = to; - } - - public String getTo() - { - return to; - } - - public int hashCode() - { - if(from != null && to != null) - { - return (from + to).hashCode(); - } - else - { - return 1; - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - - final CustomMapping other = (CustomMapping) obj; - - if (!from.equals(other.getFrom())) - { - return false; - } - if (!to.equals(other.getTo())) - { - return false; - } - return true; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.email; + +/** + * Custom EMail Mapping + */ +public class CustomMapping +{ + private String from; + private String to; + + /** + * Default constructor. + */ + public CustomMapping() + { + } + + /** + * Default constructor. + * @param from + * @param to + */ + public CustomMapping(String from, String to) + { + this.from = from; + this.to = to; + } + + public void setFrom(String from) + { + this.from = from; + } + + public String getFrom() + { + return from; + } + + public void setTo(String to) + { + this.to = to; + } + + public String getTo() + { + return to; + } + + public int hashCode() + { + if(from != null && to != null) + { + return (from + to).hashCode(); + } + else + { + return 1; + } + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + + final CustomMapping other = (CustomMapping) obj; + + if (!from.equals(other.getFrom())) + { + return false; + } + if (!to.equals(other.getTo())) + { + return false; + } + return true; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomisableEmailMappingKeyBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomisableEmailMappingKeyBootstrap.java index c2c7c3689b..f05e84a986 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomisableEmailMappingKeyBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomisableEmailMappingKeyBootstrap.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.email; - -import java.util.List; - -/** - * Bootstrap bean that indicates that the specified mappings are customisable - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class CustomisableEmailMappingKeyBootstrap -{ - /** List of mappings to register as customisable */ - private List customisable; - - /** Custom email mapping service */ - private CustomEmailMappingService customEmailMappingService; - - /** - * @param customizable list of mappings to register as customisable - */ - public void setCustomisable(List customisable) - { - this.customisable = customisable; - } - - /** - * Custom email mapping service - * - * @param customEmailMappingService the custom email mapping service - */ - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - /** - * Bean initialisation method - */ - public void init() - { - for (String customEmailMappingKey : customisable) - { - customEmailMappingService.registerEMailMappingKey(customEmailMappingKey); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.email; + +import java.util.List; + +/** + * Bootstrap bean that indicates that the specified mappings are customisable + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class CustomisableEmailMappingKeyBootstrap +{ + /** List of mappings to register as customisable */ + private List customisable; + + /** Custom email mapping service */ + private CustomEmailMappingService customEmailMappingService; + + /** + * @param customizable list of mappings to register as customisable + */ + public void setCustomisable(List customisable) + { + this.customisable = customisable; + } + + /** + * Custom email mapping service + * + * @param customEmailMappingService the custom email mapping service + */ + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + /** + * Bean initialisation method + */ + public void init() + { + for (String customEmailMappingKey : customisable) + { + customEmailMappingService.registerEMailMappingKey(customEmailMappingKey); + } + } +} 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 2d2981f846..b2fd04b047 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 @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.email; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; - -/** - * Extended RFC822 Metadata Extractor that is sensitive to whether we are in a RM - * site or not. - * - * @author Roy Wetherall - */ -public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata.RFC822MetadataExtracter -{ - /** Reference to default properties */ - private static final String PROPERTIES_URL = "alfresco/metadata/RFC822MetadataExtracter.properties"; - - /** Node service */ - private NodeService nodeService; - - /** - * Sets the node service - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#filterSystemProperties(java.util.Map, java.util.Map) - */ - @Override - protected void filterSystemProperties(Map systemProperties, Map targetProperties) - { - NodeRef nodeRef = getNodeRef(targetProperties); - if (nodeRef == null || !nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_RECORD)) - { - // Remove all rm namespace properties from the system map - Map clone = new HashMap(systemProperties); - for (QName propName : clone.keySet()) - { - if (RecordsManagementModel.RM_URI.equals(propName.getNamespaceURI())) - { - systemProperties.remove(propName); - } - } - } - } - - /** - * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#getDefaultMapping() - */ - protected Map> getDefaultMapping() - { - // Attempt to load the properties - return readMappingProperties(PROPERTIES_URL); - } - - /** - * Given a set of properties, try and retrieve the node reference - * @param properties node properties - * @return NodeRef null if none, otherwise valid node reference - */ - private NodeRef getNodeRef(Map properties) - { - NodeRef result = null; - - // Get the elements of the node reference - String storeProto = (String)properties.get(ContentModel.PROP_STORE_PROTOCOL); - String storeId = (String)properties.get(ContentModel.PROP_STORE_IDENTIFIER); - String nodeId = (String)properties.get(ContentModel.PROP_NODE_UUID); - - if (storeProto != null && storeProto.length() != 0 && - storeId != null && storeId.length() != 0 && - nodeId != null && nodeId.length() != 0) - - { - // Create the node reference - result = new NodeRef(new StoreRef(storeProto, storeId), nodeId); - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.email; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; + +/** + * Extended RFC822 Metadata Extractor that is sensitive to whether we are in a RM + * site or not. + * + * @author Roy Wetherall + */ +public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata.RFC822MetadataExtracter +{ + /** Reference to default properties */ + private static final String PROPERTIES_URL = "alfresco/metadata/RFC822MetadataExtracter.properties"; + + /** Node service */ + private NodeService nodeService; + + /** + * Sets the node service + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#filterSystemProperties(java.util.Map, java.util.Map) + */ + @Override + protected void filterSystemProperties(Map systemProperties, Map targetProperties) + { + NodeRef nodeRef = getNodeRef(targetProperties); + if (nodeRef == null || !nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_RECORD)) + { + // Remove all rm namespace properties from the system map + Map clone = new HashMap(systemProperties); + for (QName propName : clone.keySet()) + { + if (RecordsManagementModel.RM_URI.equals(propName.getNamespaceURI())) + { + systemProperties.remove(propName); + } + } + } + } + + /** + * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#getDefaultMapping() + */ + protected Map> getDefaultMapping() + { + // Attempt to load the properties + return readMappingProperties(PROPERTIES_URL); + } + + /** + * Given a set of properties, try and retrieve the node reference + * @param properties node properties + * @return NodeRef null if none, otherwise valid node reference + */ + private NodeRef getNodeRef(Map properties) + { + NodeRef result = null; + + // Get the elements of the node reference + String storeProto = (String)properties.get(ContentModel.PROP_STORE_PROTOCOL); + String storeId = (String)properties.get(ContentModel.PROP_STORE_IDENTIFIER); + String nodeId = (String)properties.get(ContentModel.PROP_NODE_UUID); + + if (storeProto != null && storeProto.length() != 0 && + storeId != null && storeId.length() != 0 && + nodeId != null && nodeId.length() != 0) + + { + // Create the node reference + result = new NodeRef(new StoreRef(storeProto, storeId), nodeId); + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/EventCompletionDetails.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/EventCompletionDetails.java index ec9f0ec77c..28a6970b1c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/EventCompletionDetails.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/EventCompletionDetails.java @@ -1,167 +1,167 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import java.util.Date; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Event completion details - * - * @author Roy Wetherall - */ -public class EventCompletionDetails -{ - /** node reference */ - private NodeRef nodeRef; - - /** event name */ - private String eventName; - private String eventLabel; - private boolean eventExecutionAutomatic; - private boolean eventComplete; - private Date eventCompletedAt; - private String eventCompletedBy; - - - /** - * Constructor - * - * @param nodeRef node reference - * @param eventName event name - * @param eventLabel event label - * @param eventExecutionAutomatic indicates whether the event is executed automatically or not - * @param eventComplete indicates whether the event is complete or not - * @param eventCompletedAt when the event was completed - * @param eventCompletedBy who completed the event - */ - public EventCompletionDetails( NodeRef nodeRef, - String eventName, - String eventLabel, - boolean eventExecutionAutomatic, - boolean eventComplete, - Date eventCompletedAt, - String eventCompletedBy) - { - this.nodeRef = nodeRef; - this.eventName = eventName; - this.eventLabel = eventLabel; - this.eventExecutionAutomatic = eventExecutionAutomatic; - this.eventComplete = eventComplete; - this.eventCompletedAt = eventCompletedAt; - this.eventCompletedBy = eventCompletedBy; - } - - /** - * @return the node reference - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * @return the eventName - */ - public String getEventName() - { - return eventName; - } - - /** - * @param eventName the eventName to set - */ - public void setEventName(String eventName) - { - this.eventName = eventName; - } - - /** - * @return The display label of the event - */ - public String getEventLabel() - { - return this.eventLabel; - } - - /** - * @return the eventExecutionAutomatic - */ - public boolean isEventExecutionAutomatic() - { - return eventExecutionAutomatic; - } - - /** - * @param eventExecutionAutomatic the eventExecutionAutomatic to set - */ - public void setEventExecutionAutomatic(boolean eventExecutionAutomatic) - { - this.eventExecutionAutomatic = eventExecutionAutomatic; - } - - /** - * @return the eventComplete - */ - public boolean isEventComplete() - { - return eventComplete; - } - - /** - * @param eventComplete the eventComplete to set - */ - public void setEventComplete(boolean eventComplete) - { - this.eventComplete = eventComplete; - } - - /** - * @return the eventCompletedAt - */ - public Date getEventCompletedAt() - { - return eventCompletedAt; - } - - /** - * @param eventCompletedAt the eventCompletedAt to set - */ - public void setEventCompletedAt(Date eventCompletedAt) - { - this.eventCompletedAt = eventCompletedAt; - } - - /** - * @return the eventCompletedBy - */ - public String getEventCompletedBy() - { - return eventCompletedBy; - } - - /** - * @param eventCompletedBy the eventCompletedBy to set - */ - public void setEventCompletedBy(String eventCompletedBy) - { - this.eventCompletedBy = eventCompletedBy; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import java.util.Date; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Event completion details + * + * @author Roy Wetherall + */ +public class EventCompletionDetails +{ + /** node reference */ + private NodeRef nodeRef; + + /** event name */ + private String eventName; + private String eventLabel; + private boolean eventExecutionAutomatic; + private boolean eventComplete; + private Date eventCompletedAt; + private String eventCompletedBy; + + + /** + * Constructor + * + * @param nodeRef node reference + * @param eventName event name + * @param eventLabel event label + * @param eventExecutionAutomatic indicates whether the event is executed automatically or not + * @param eventComplete indicates whether the event is complete or not + * @param eventCompletedAt when the event was completed + * @param eventCompletedBy who completed the event + */ + public EventCompletionDetails( NodeRef nodeRef, + String eventName, + String eventLabel, + boolean eventExecutionAutomatic, + boolean eventComplete, + Date eventCompletedAt, + String eventCompletedBy) + { + this.nodeRef = nodeRef; + this.eventName = eventName; + this.eventLabel = eventLabel; + this.eventExecutionAutomatic = eventExecutionAutomatic; + this.eventComplete = eventComplete; + this.eventCompletedAt = eventCompletedAt; + this.eventCompletedBy = eventCompletedBy; + } + + /** + * @return the node reference + */ + public NodeRef getNodeRef() + { + return nodeRef; + } + + /** + * @return the eventName + */ + public String getEventName() + { + return eventName; + } + + /** + * @param eventName the eventName to set + */ + public void setEventName(String eventName) + { + this.eventName = eventName; + } + + /** + * @return The display label of the event + */ + public String getEventLabel() + { + return this.eventLabel; + } + + /** + * @return the eventExecutionAutomatic + */ + public boolean isEventExecutionAutomatic() + { + return eventExecutionAutomatic; + } + + /** + * @param eventExecutionAutomatic the eventExecutionAutomatic to set + */ + public void setEventExecutionAutomatic(boolean eventExecutionAutomatic) + { + this.eventExecutionAutomatic = eventExecutionAutomatic; + } + + /** + * @return the eventComplete + */ + public boolean isEventComplete() + { + return eventComplete; + } + + /** + * @param eventComplete the eventComplete to set + */ + public void setEventComplete(boolean eventComplete) + { + this.eventComplete = eventComplete; + } + + /** + * @return the eventCompletedAt + */ + public Date getEventCompletedAt() + { + return eventCompletedAt; + } + + /** + * @param eventCompletedAt the eventCompletedAt to set + */ + public void setEventCompletedAt(Date eventCompletedAt) + { + this.eventCompletedAt = eventCompletedAt; + } + + /** + * @return the eventCompletedBy + */ + public String getEventCompletedBy() + { + return eventCompletedBy; + } + + /** + * @param eventCompletedBy the eventCompletedBy to set + */ + public void setEventCompletedBy(String eventCompletedBy) + { + this.eventCompletedBy = eventCompletedBy; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java index 4ddd5eab00..3cf6ed5a49 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java @@ -1,144 +1,144 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * On reference create event type - * - * @author Roy Wetherall - */ -@BehaviourBean -public class OnReferenceCreateEventType extends SimpleRecordsManagementEventTypeImpl - implements RecordsManagementModel, - OnCreateReference -{ - /** Records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Reference */ - private QName reference; - - /** - * @param dispositionService the disposition service to set - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordsManagementActionService the recordsManagementActionService to set - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * Set the reference - * - * @param reference - */ - public void setReferenceName(String reference) - { - this.reference = QName.createQName(reference); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent() - */ - @Override - public boolean isAutomaticEvent() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:record", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateReference(final NodeRef fromNodeRef, final NodeRef toNodeRef, final QName reference) - { - AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - // Check whether it is the reference type we care about - if (reference.equals(OnReferenceCreateEventType.this.reference)) - { - DispositionAction da = dispositionService.getNextDispositionAction(toNodeRef); - if (da != null) - { - List events = da.getEventCompletionDetails(); - for (EventCompletionDetails event : events) - { - RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName()); - if (!event.isEventComplete() && - rmEvent.getType().equals(getName())) - { - // Complete the event - Map params = new HashMap(3); - params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName()); - params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); - params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); - recordsManagementActionService.executeRecordsManagementAction(toNodeRef, "completeEvent", params); - - break; - } - } - } - } - - return null; - } - }; - - AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * On reference create event type + * + * @author Roy Wetherall + */ +@BehaviourBean +public class OnReferenceCreateEventType extends SimpleRecordsManagementEventTypeImpl + implements RecordsManagementModel, + OnCreateReference +{ + /** Records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Reference */ + private QName reference; + + /** + * @param dispositionService the disposition service to set + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordsManagementActionService the recordsManagementActionService to set + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * Set the reference + * + * @param reference + */ + public void setReferenceName(String reference) + { + this.reference = QName.createQName(reference); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent() + */ + @Override + public boolean isAutomaticEvent() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:record", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateReference(final NodeRef fromNodeRef, final NodeRef toNodeRef, final QName reference) + { + AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + // Check whether it is the reference type we care about + if (reference.equals(OnReferenceCreateEventType.this.reference)) + { + DispositionAction da = dispositionService.getNextDispositionAction(toNodeRef); + if (da != null) + { + List events = da.getEventCompletionDetails(); + for (EventCompletionDetails event : events) + { + RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName()); + if (!event.isEventComplete() && + rmEvent.getType().equals(getName())) + { + // Complete the event + Map params = new HashMap(3); + params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName()); + params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); + params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); + recordsManagementActionService.executeRecordsManagementAction(toNodeRef, "completeEvent", params); + + break; + } + } + } + } + + return null; + } + }; + + AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java index 37f039aeb2..c9664cd7f2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java @@ -1,251 +1,251 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Behaviour executed when a references record is actioned upon. - * - * @author Roy Wetherall - */ -@BehaviourBean -public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEventTypeImpl - implements RecordsManagementModel, - BeforeRMActionExecution - -{ - /** Disposition service */ - private DispositionService dispositionService; - - /** Records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** Node service */ - private NodeService nodeService; - - /** Record service */ - private RecordService recordService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** Action name */ - private String actionName; - - /** Reference */ - private QName reference; - - /** - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordsManagementActionService the recordsManagementActionService to set - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param reference reference name - */ - public void setReferenceName(String reference) - { - this.reference = QName.createQName(reference); - } - - /** - * @param actionName action name - */ - public void setActionName(String actionName) - { - this.actionName = actionName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent() - */ - @Override - public boolean isAutomaticEvent() - { - return true; - } - - /** - * Before action exeuction behaviour. - * - * @param nodeRef - * @param name - * @param parameters - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "rma:filePlanComponent", - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void beforeRMActionExecution(final NodeRef nodeRef, final String name, final Map parameters) - { - AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - if (nodeService.exists(nodeRef) && name.equals(actionName)) - { - QName type = nodeService.getType(nodeRef); - if (TYPE_TRANSFER.equals(type)) - { - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - processRecordFolder(assoc.getChildRef()); - } - } - else - { - processRecordFolder(nodeRef); - } - } - - return null; - } - }; - - AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); - - } - - private void processRecordFolder(NodeRef recordFolder) - { - if (recordService.isRecord(recordFolder)) - { - processRecord(recordFolder); - } - else if (recordFolderService.isRecordFolder(recordFolder)) - { - for (NodeRef record : recordService.getRecords(recordFolder)) - { - processRecord(record); - } - } - } - - private void processRecord(NodeRef record) - { - List fromAssocs = nodeService.getTargetAssocs(record, RegexQNamePattern.MATCH_ALL); - for (AssociationRef fromAssoc : fromAssocs) - { - if (reference.equals(fromAssoc.getTypeQName())) - { - NodeRef nodeRef = fromAssoc.getTargetRef(); - doEventComplete(nodeRef); - } - } - - List toAssocs = nodeService.getSourceAssocs(record, RegexQNamePattern.MATCH_ALL); - for (AssociationRef toAssoc : toAssocs) - { - if (reference.equals(toAssoc.getTypeQName())) - { - NodeRef nodeRef = toAssoc.getSourceRef(); - doEventComplete(nodeRef); - } - } - } - - private void doEventComplete(NodeRef nodeRef) - { - DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); - if (da != null) - { - List events = da.getEventCompletionDetails(); - for (EventCompletionDetails event : events) - { - RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName()); - if (!event.isEventComplete() && - rmEvent.getType().equals(getName())) - { - // Complete the event - Map params = new HashMap(3); - params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName()); - params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); - params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); - recordsManagementActionService.executeRecordsManagementAction(nodeRef, "completeEvent", params); - - break; - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Behaviour executed when a references record is actioned upon. + * + * @author Roy Wetherall + */ +@BehaviourBean +public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEventTypeImpl + implements RecordsManagementModel, + BeforeRMActionExecution + +{ + /** Disposition service */ + private DispositionService dispositionService; + + /** Records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** Node service */ + private NodeService nodeService; + + /** Record service */ + private RecordService recordService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Action name */ + private String actionName; + + /** Reference */ + private QName reference; + + /** + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordsManagementActionService the recordsManagementActionService to set + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param reference reference name + */ + public void setReferenceName(String reference) + { + this.reference = QName.createQName(reference); + } + + /** + * @param actionName action name + */ + public void setActionName(String actionName) + { + this.actionName = actionName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent() + */ + @Override + public boolean isAutomaticEvent() + { + return true; + } + + /** + * Before action exeuction behaviour. + * + * @param nodeRef + * @param name + * @param parameters + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent", + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void beforeRMActionExecution(final NodeRef nodeRef, final String name, final Map parameters) + { + AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + if (nodeService.exists(nodeRef) && name.equals(actionName)) + { + QName type = nodeService.getType(nodeRef); + if (TYPE_TRANSFER.equals(type)) + { + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + processRecordFolder(assoc.getChildRef()); + } + } + else + { + processRecordFolder(nodeRef); + } + } + + return null; + } + }; + + AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); + + } + + private void processRecordFolder(NodeRef recordFolder) + { + if (recordService.isRecord(recordFolder)) + { + processRecord(recordFolder); + } + else if (recordFolderService.isRecordFolder(recordFolder)) + { + for (NodeRef record : recordService.getRecords(recordFolder)) + { + processRecord(record); + } + } + } + + private void processRecord(NodeRef record) + { + List fromAssocs = nodeService.getTargetAssocs(record, RegexQNamePattern.MATCH_ALL); + for (AssociationRef fromAssoc : fromAssocs) + { + if (reference.equals(fromAssoc.getTypeQName())) + { + NodeRef nodeRef = fromAssoc.getTargetRef(); + doEventComplete(nodeRef); + } + } + + List toAssocs = nodeService.getSourceAssocs(record, RegexQNamePattern.MATCH_ALL); + for (AssociationRef toAssoc : toAssocs) + { + if (reference.equals(toAssoc.getTypeQName())) + { + NodeRef nodeRef = toAssoc.getSourceRef(); + doEventComplete(nodeRef); + } + } + } + + private void doEventComplete(NodeRef nodeRef) + { + DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); + if (da != null) + { + List events = da.getEventCompletionDetails(); + for (EventCompletionDetails event : events) + { + RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName()); + if (!event.isEventComplete() && + rmEvent.getType().equals(getName())) + { + // Complete the event + Map params = new HashMap(3); + params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName()); + params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); + params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); + recordsManagementActionService.executeRecordsManagementAction(nodeRef, "completeEvent", params); + + break; + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEvent.java index 8f16cb7584..40c1faa879 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEvent.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import org.alfresco.util.ParameterCheck; - -/** - * Records management event - * - * @author Roy Wetherall - * @since 1.0 - */ -public class RecordsManagementEvent -{ - /** Records management event type */ - private RecordsManagementEventType type; - - /** Records management event name */ - private String name; - - /** Records management display label */ - private String displayLabel; - - /** - * Constructor - * - * @param type event type - * @param name event name - * @param displayLabel event display label - */ - public RecordsManagementEvent(RecordsManagementEventType type, String name, String displayLabel) - { - ParameterCheck.mandatory("type", type); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("displayLabel", displayLabel); - - this.type = type; - this.name = name; - this.displayLabel = displayLabel; - } - - /** - * Get records management type name - * - * @return String records management event type name - */ - public String getType() - { - return type.getName(); - } - - /** - * Get the records management event type. - * - * @return {@link RecordsManagementEventType} records management event type - * - * @since 2.2 - */ - public RecordsManagementEventType getRecordsManagementEventType() - { - return type; - } - - /** - * Event name - * - * @return String event name - */ - public String getName() - { - return this.name; - } - - /** - * - * @return - */ - public String getDisplayLabel() - { - return displayLabel; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import org.alfresco.util.ParameterCheck; + +/** + * Records management event + * + * @author Roy Wetherall + * @since 1.0 + */ +public class RecordsManagementEvent +{ + /** Records management event type */ + private RecordsManagementEventType type; + + /** Records management event name */ + private String name; + + /** Records management display label */ + private String displayLabel; + + /** + * Constructor + * + * @param type event type + * @param name event name + * @param displayLabel event display label + */ + public RecordsManagementEvent(RecordsManagementEventType type, String name, String displayLabel) + { + ParameterCheck.mandatory("type", type); + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("displayLabel", displayLabel); + + this.type = type; + this.name = name; + this.displayLabel = displayLabel; + } + + /** + * Get records management type name + * + * @return String records management event type name + */ + public String getType() + { + return type.getName(); + } + + /** + * Get the records management event type. + * + * @return {@link RecordsManagementEventType} records management event type + * + * @since 2.2 + */ + public RecordsManagementEventType getRecordsManagementEventType() + { + return type; + } + + /** + * Event name + * + * @return String event name + */ + public String getName() + { + return this.name; + } + + /** + * + * @return + */ + public String getDisplayLabel() + { + return displayLabel; + } +} 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 6c841bf99c..e0e66376c6 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 @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -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 - */ - 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 particular 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 can be created. Returns true if it is possible, false otherwise. - * - * @param eventDisplayLabel event display label - * @param eventName event name - * @return true if the event can be created, false otherwise - */ - 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 - * @param eventType event type - * @return true if the event can be edited, false otherwise - */ - boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType); - - /** - * 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); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +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 + */ + 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 particular 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 can be created. Returns true if it is possible, false otherwise. + * + * @param eventDisplayLabel event display label + * @param eventName event name + * @return true if the event can be created, false otherwise + */ + 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 + * @param eventType event type + * @return true if the event can be edited, false otherwise + */ + boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType); + + /** + * 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); + +} 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 8e31bf1f6f..28852ae5c1 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 @@ -1,379 +1,379 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -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; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Records management event service implementation - * - * @author Roy Wetherall - */ -public class RecordsManagementEventServiceImpl implements RecordsManagementEventService -{ - /** 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) - { - this.contentService = contentService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#registerEventType(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType) - */ - public void registerEventType(RecordsManagementEventType eventType) - { - this.eventTypes.put(eventType.getName(), eventType); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEventTypes() - */ - public List getEventTypes() - { - return new ArrayList(this.eventTypes.values()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEvents() - */ - public List getEvents() - { - 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) - { - if (!getEventMap().containsKey(eventName)) { throw new AlfrescoRuntimeException("The event " - + eventName + " does not exist."); } - return getEventMap().get(eventName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEvent(java.lang.String) - */ - public boolean existsEvent(String eventName) - { - return getEventMap().containsKey(eventName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEventDisplayLabel(java.lang.String) - */ - public boolean existsEventDisplayLabel(String eventDisplayLabel) - { - for (RecordsManagementEvent recordsManagementEvent : getEventMap().values()) - { - 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)) - { - canCreateEvent = false; - } - - if (canCreateEvent) - { - 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, java.lang.String) - */ - @SuppressWarnings("rawtypes") - public boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) - { - ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel); - ParameterCheck.mandatoryString("eventName", eventName); - ParameterCheck.mandatoryString("eventType", eventType); - - boolean canEditEvent = true; - - if (!existsEvent(eventName)) - { - 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)) - { - if (!recordsManagementEvent.getType().equalsIgnoreCase(eventType)) - { - canEditEvent = true; - } - else - { - 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) - */ - public RecordsManagementEvent addEvent(String eventType, String eventName, String eventDisplayLabel) - { - // Check that the eventType is valid - if (!eventTypes.containsKey(eventType)) - { - throw new AlfrescoRuntimeException( - "Can not add event because event " + - eventName + - " has an undefined eventType. (" - + eventType + ")"); - } - - // Create event and add to map - RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); - getEventMap().put(event.getName(), event); - - // Persist the changes to the event list - saveEvents(); - - return new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#removeEvent(java.lang.String) - */ - public void removeEvent(String eventName) - { - // 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() - { - if (this.events == null) - { - loadEvents(); - } - return this.events; - } - - /** - * Load the events from the persistant storage - */ - private void loadEvents() - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() throws Exception - { - // Get the event config node - if (!nodeService.exists(CONFIG_NODE_REF)) - { - 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"); - String translated = I18NUtil.getMessage(eventDisplayLabel); - if (translated != null) - { - eventDisplayLabel = translated; - } - - - // Check that the eventType is valid - if (!eventTypes.containsKey(eventType)) - { - throw new AlfrescoRuntimeException( - "Can not load rm event configuration because event " + - eventName + - " has an undefined eventType. (" - + eventType + ")"); - } - - // Create event and add to map - RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); - events.put(event.getName(), event); - } - return null; - } - - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Save the events to the peristant storage - */ - private void saveEvents() - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() throws Exception - { - // Get the event config node - if (!nodeService.exists(CONFIG_NODE_REF)) - { - throw new AlfrescoRuntimeException("Unable to find records management event configuration node."); - } - - JSONObject configJSON = new JSONObject(); - JSONArray eventsJSON = new JSONArray(); - - int index = 0; - for (RecordsManagementEvent event : events.values()) - { - JSONObject eventJSON = new JSONObject(); - 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()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEventType(java.lang.String) - */ - public RecordsManagementEventType getEventType(String eventTypeName) - { - return this.eventTypes.get(eventTypeName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +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; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Records management event service implementation + * + * @author Roy Wetherall + */ +public class RecordsManagementEventServiceImpl implements RecordsManagementEventService +{ + /** 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) + { + this.contentService = contentService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#registerEventType(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType) + */ + public void registerEventType(RecordsManagementEventType eventType) + { + this.eventTypes.put(eventType.getName(), eventType); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEventTypes() + */ + public List getEventTypes() + { + return new ArrayList(this.eventTypes.values()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEvents() + */ + public List getEvents() + { + 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) + { + if (!getEventMap().containsKey(eventName)) { throw new AlfrescoRuntimeException("The event " + + eventName + " does not exist."); } + return getEventMap().get(eventName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEvent(java.lang.String) + */ + public boolean existsEvent(String eventName) + { + return getEventMap().containsKey(eventName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEventDisplayLabel(java.lang.String) + */ + public boolean existsEventDisplayLabel(String eventDisplayLabel) + { + for (RecordsManagementEvent recordsManagementEvent : getEventMap().values()) + { + 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)) + { + canCreateEvent = false; + } + + if (canCreateEvent) + { + 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, java.lang.String) + */ + @SuppressWarnings("rawtypes") + public boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) + { + ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel); + ParameterCheck.mandatoryString("eventName", eventName); + ParameterCheck.mandatoryString("eventType", eventType); + + boolean canEditEvent = true; + + if (!existsEvent(eventName)) + { + 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)) + { + if (!recordsManagementEvent.getType().equalsIgnoreCase(eventType)) + { + canEditEvent = true; + } + else + { + 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) + */ + public RecordsManagementEvent addEvent(String eventType, String eventName, String eventDisplayLabel) + { + // Check that the eventType is valid + if (!eventTypes.containsKey(eventType)) + { + throw new AlfrescoRuntimeException( + "Can not add event because event " + + eventName + + " has an undefined eventType. (" + + eventType + ")"); + } + + // Create event and add to map + RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); + getEventMap().put(event.getName(), event); + + // Persist the changes to the event list + saveEvents(); + + return new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#removeEvent(java.lang.String) + */ + public void removeEvent(String eventName) + { + // 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() + { + if (this.events == null) + { + loadEvents(); + } + return this.events; + } + + /** + * Load the events from the persistant storage + */ + private void loadEvents() + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() throws Exception + { + // Get the event config node + if (!nodeService.exists(CONFIG_NODE_REF)) + { + 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"); + String translated = I18NUtil.getMessage(eventDisplayLabel); + if (translated != null) + { + eventDisplayLabel = translated; + } + + + // Check that the eventType is valid + if (!eventTypes.containsKey(eventType)) + { + throw new AlfrescoRuntimeException( + "Can not load rm event configuration because event " + + eventName + + " has an undefined eventType. (" + + eventType + ")"); + } + + // Create event and add to map + RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel); + events.put(event.getName(), event); + } + return null; + } + + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Save the events to the peristant storage + */ + private void saveEvents() + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() throws Exception + { + // Get the event config node + if (!nodeService.exists(CONFIG_NODE_REF)) + { + throw new AlfrescoRuntimeException("Unable to find records management event configuration node."); + } + + JSONObject configJSON = new JSONObject(); + JSONArray eventsJSON = new JSONArray(); + + int index = 0; + for (RecordsManagementEvent event : events.values()) + { + JSONObject eventJSON = new JSONObject(); + 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()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEventType(java.lang.String) + */ + public RecordsManagementEventType getEventType(String eventTypeName) + { + return this.eventTypes.get(eventTypeName); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventType.java index f362800ccf..5dcd85ad61 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventType.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -/** - * Records management event type interface - * - * @author Roy Wetherall - */ -public interface RecordsManagementEventType -{ - /** - * Get the name of the records management event type - * - * @return String event type name - */ - String getName(); - - /** - * Gets the display label of the event type - * - * @return String display label - */ - String getDisplayLabel(); - - /** - * Indicates whether the event is automatic or not - * - * @return boolean true if automatic, false otherwise - */ - boolean isAutomaticEvent(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +/** + * Records management event type interface + * + * @author Roy Wetherall + */ +public interface RecordsManagementEventType +{ + /** + * Get the name of the records management event type + * + * @return String event type name + */ + String getName(); + + /** + * Gets the display label of the event type + * + * @return String display label + */ + String getDisplayLabel(); + + /** + * Indicates whether the event is automatic or not + * + * @return boolean true if automatic, false otherwise + */ + boolean isAutomaticEvent(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java index fe146b1950..0e333233c1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java @@ -1,100 +1,100 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.event; - -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Simple records management event type implementation - * - * @author Roy Wetherall - */ -public class SimpleRecordsManagementEventTypeImpl implements RecordsManagementEventType, BeanNameAware -{ - /** Display label lookup prefix */ - protected static final String LOOKUP_PREFIX = "rmeventservice."; - - /** Name */ - public static final String NAME = "rmEventType.simple"; - - /** Records management event service */ - private RecordsManagementEventService recordsManagementEventService; - - /** Name */ - private String name; - - /** - * @return Records management event service - */ - protected RecordsManagementEventService getRecordsManagementEventService() - { - return this.recordsManagementEventService; - } - - /** - * Set the records management event service - * - * @param recordsManagementEventService records management service - */ - public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) - { - this.recordsManagementEventService = recordsManagementEventService; - } - - /** - * Initialisation method - */ - public void init() - { - getRecordsManagementEventService().registerEventType(this); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#isAutomaticEvent() - */ - public boolean isAutomaticEvent() - { - return false; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#getName() - */ - public String getName() - { - return this.name; - } - - /** - * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) - */ - public void setBeanName(String name) - { - this.name = name; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#getDisplayLabel() - */ - public String getDisplayLabel() - { - return I18NUtil.getMessage(LOOKUP_PREFIX + getName()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.event; + +import org.springframework.beans.factory.BeanNameAware; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Simple records management event type implementation + * + * @author Roy Wetherall + */ +public class SimpleRecordsManagementEventTypeImpl implements RecordsManagementEventType, BeanNameAware +{ + /** Display label lookup prefix */ + protected static final String LOOKUP_PREFIX = "rmeventservice."; + + /** Name */ + public static final String NAME = "rmEventType.simple"; + + /** Records management event service */ + private RecordsManagementEventService recordsManagementEventService; + + /** Name */ + private String name; + + /** + * @return Records management event service + */ + protected RecordsManagementEventService getRecordsManagementEventService() + { + return this.recordsManagementEventService; + } + + /** + * Set the records management event service + * + * @param recordsManagementEventService records management service + */ + public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) + { + this.recordsManagementEventService = recordsManagementEventService; + } + + /** + * Initialisation method + */ + public void init() + { + getRecordsManagementEventService().registerEventType(this); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#isAutomaticEvent() + */ + public boolean isAutomaticEvent() + { + return false; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#getName() + */ + public String getName() + { + return this.name; + } + + /** + * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) + */ + public void setBeanName(String name) + { + this.name = name; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#getDisplayLabel() + */ + public String getDisplayLabel() + { + return I18NUtil.getMessage(LOOKUP_PREFIX + getName()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanComponentKind.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanComponentKind.java index 4ce0819b98..6089d92e46 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanComponentKind.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanComponentKind.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.fileplan; - -/** - * File plan component kind enumeration class. - *
- * Helpful when trying to determine the characteristics of a kind - * of file plan component. - * - * @author Roy Wetherall - */ -public enum FilePlanComponentKind -{ - FILE_PLAN_COMPONENT, - FILE_PLAN, - RECORD_CATEGORY, - RECORD_FOLDER, - RECORD, - TRANSFER, - TRANSFER_CONTAINER, - HOLD, - HOLD_CONTAINER, - DISPOSITION_SCHEDULE, - UNFILED_RECORD_CONTAINER, - UNFILED_RECORD_FOLDER; -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.fileplan; + +/** + * File plan component kind enumeration class. + *
+ * Helpful when trying to determine the characteristics of a kind + * of file plan component. + * + * @author Roy Wetherall + */ +public enum FilePlanComponentKind +{ + FILE_PLAN_COMPONENT, + FILE_PLAN, + RECORD_CATEGORY, + RECORD_FOLDER, + RECORD, + TRANSFER, + TRANSFER_CONTAINER, + HOLD, + HOLD_CONTAINER, + DISPOSITION_SCHEDULE, + UNFILED_RECORD_CONTAINER, + UNFILED_RECORD_FOLDER; +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index 4336b9e7e2..5964172207 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -1,338 +1,338 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.fileplan; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; - -/** - * File plan service interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface FilePlanService -{ - /** - * Default RM site id. - * Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node. - * */ - String DEFAULT_RM_SITE_ID = "rm"; - - /** - * Indicates whether the given node is a file plan component or not. - * - * @param nodeRef node reference - * @return boolean true if a file plan component, false otherwise - */ - boolean isFilePlanComponent(NodeRef nodeRef); - - /** - * Returns the 'kind' of file plan component the node reference is. - *

- * Returns null if the given node reference is not a - * file plan component. - * - * @param nodeRef node reference - * @return FilePlanComponentKind the kind of file plan component the node is - */ - FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); - - /** - * Returns the file plan component 'kind' that relates to the passed - * content type. - *

- * Returns null if the type does not relate to a file plan component. - * - * @param type qualified name of content type - * @return FilePlanComponentKind the kind relating to the passed type - */ - FilePlanComponentKind getFilePlanComponentKindFromType(QName type); - - /** - * Indicates whether the given node is file plan node or not. - * - * @param nodeRef node reference - * @return boolean true if node is a file plan node - */ - boolean isFilePlan(NodeRef nodeRef); - - /** - * Gets all the file plan nodes. - * Looks in the SpacesStore by default. - * - * @return Set set of file plan nodes - */ - Set getFilePlans(); - - /** - * Getse all the file plan nodes in a store. - * - * @param storeRef store reference - * @return Set set of file plan nodes - */ - Set getFilePlans(StoreRef storeRef); - - /** - * Gets the file plan the node is in. - * - * @return {@link NodeRef} file node reference, null if none - */ - NodeRef getFilePlan(NodeRef nodeRef); - - /** - * Gets a file plan by site id. Assumes the site is a RM site and that the file plan node, ie - * the document library container, has been already created. Otherwise returns null. - * - * @param siteId records management site id - * @return NodeRef file plan, null if can't be found - */ - NodeRef getFilePlanBySiteId(String siteId); - - /** - * Indicates whether the unfiled container exists for a given file plan or not. - * - * @param filePlan file plan - * @return boolean true if unfiled container exists, false otherwise - */ - boolean existsUnfiledContainer(NodeRef filePlan); - - /** - * Gets the unfiled container for a given file plan. Returns null if - * none. - * - * @param filePlan file plan - * @return {@link NodeRef} unfiled container, null if none - */ - NodeRef getUnfiledContainer(NodeRef filePlan); - - /** - * Creates, and returns, a unfiled container for a given file plan. - * - * @param filePlan file plan - * @return {@link Node} unfiled container - */ - NodeRef createUnfiledContainer(NodeRef filePlan); - - /** - * Gets the hold container for a given file plan. Returns - * null if none. - * - * @param filePlan - * @return - */ - NodeRef getHoldContainer(NodeRef filePlan); - - /** - * - * @param filePlan - * @return - */ - NodeRef createHoldContainer(NodeRef filePlan); - - /** - * - * @param filePlan - * @return - */ - NodeRef getTransferContainer(NodeRef filePlan); - - /** - * - * @param filePlan - * @return - */ - NodeRef createTransferContainer(NodeRef filePlan); - - /** - * Creates a file plan as a child of the given parent node, with the name - * provided. - * - * @param parent parent node reference - * @param name file plan name - * @param type type, must be rma:filePlan or sub-type of - * @return NodeRef file plan node reference - */ - NodeRef createFilePlan(NodeRef parent, String name, QName type); - - /** - * Specifies the properties to be set on the created file plan. - * - * @see #createFilePlan(NodeRef, String, QName) - * - * @param parent parent node reference - * @param name file plan name - * @param type type, must be rma:filePlan or sub-type of - * @param properties file plan properties - * @return NodeRef file plan node reference - */ - NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); - - /** - * Creates a file plan with the default type. - * - * @see #createFilePlan(NodeRef, String, QName) - * - * @param parent parent node reference - * @param name file plan name - * @return NodeRef file plan node reference - */ - NodeRef createFilePlan(NodeRef parent, String name); - - /** - * Creates a file plan with the default type, specifying properties. - * - * @see #createFilePlan(NodeRef, String, QName) - * - * @param parent parent node reference - * @param name file plan name - * @param properties file plan properties - * @return NodeRef file plan node reference - */ - NodeRef createFilePlan(NodeRef parent, String name, Map properties); - - // TODO deleteFilePlan - - /** - * Gets the NodeRef sequence from the {@link #getFilePlan(NodeRef) root} - * down to the fileplan component given. The array will start with the NodeRef of the root - * and end with the name of the fileplan component node given. - * - * @param nodeRef a fileplan component - * @return Returns a NodeRef path starting with the file plan - */ - List getNodeRefPath(NodeRef nodeRef); - - /** - * Indicates whether the given node is a file plan container or not. - *

- * This includes file plan and record category nodes. - * - * @param nodeRef node reference - * @return boolean true if node is a file plan container, false otherwise. - */ - boolean isFilePlanContainer(NodeRef nodeRef); - - /** - * Indicates whether the given node is a record category or not. - * - * @param nodeRef node reference - * @return boolean true if records category, false otherwise - */ - boolean isRecordCategory(NodeRef nodeRef); - - /** - * Get all the items contained within a container. This will include record folders and other record categories. - * - * @param recordCategory record category node reference - * @param deep if true then return all children including sub-categories and their children in turn, if false then just - * return the immediate children - * @return {@link List}<{@link NodeRef>} list of contained node references - */ - List getAllContained(NodeRef recordCategory, boolean deep); - - /** - * Only return the immediate children. - * - * @param recordCategory record category node reference - * @return {@link List}<{@link NodeRef>} list of contained node references - */ - List getAllContained(NodeRef recordCategory); - - /** - * Get all the record categories within a record category. - * - * @param recordCategory record category node reference - * @param deep if true then return all children including sub-categories and their children in turn, if false then just - * return the immediate children - * @return {@link List}<{@link NodeRef>} list of container node references - */ - List getContainedRecordCategories(NodeRef recordCategory, boolean deep); - - /** - * Only return immediate children. - * - * @param recordCategory container node reference - * @return {@link List}<{@link NodeRef>} list of container node references - */ - List getContainedRecordCategories(NodeRef recordCategory); - - /** - * Get all the record folders contained within a container - * - * @param container container node reference - * @param deep if true then return all children including sub-containers and their children in turn, if false then just - * return the immediate children - * @return {@link List}<{@link NodeRef>} list of record folder node references - */ - List getContainedRecordFolders(NodeRef container, boolean deep); - - /** - * Only return immediate children. - * - * @param container container node reference - * @return {@link List}<{@link NodeRef>} list of record folder node references - */ - List getContainedRecordFolders(NodeRef container); - - /** - * Create a record category. - * - * @param parent parent node reference, must be a record category or file plan. - * @param name name of the new record category - * @param type type of container to create, must be a sub-type of rm:recordCategory - * @return NodeRef node reference of the created record category - */ - NodeRef createRecordCategory(NodeRef parent, String name, QName type); - - /** - * - * @param parent - * @param name - * @param type - * @param properties - * @return - */ - NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); - - /** - * Creates a record category of type rma:recordCategory - * - * @param parent parent node reference, must be a record category or file plan. - * @param name name of the record category - * @return NodeRef node reference of the created record category - */ - NodeRef createRecordCategory(NodeRef parent, String name); - - /** - * - * @param parent - * @param name - * @param properties - * @return - */ - NodeRef createRecordCategory(NodeRef parent, String name, Map properties); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.fileplan; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; + +/** + * File plan service interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface FilePlanService +{ + /** + * Default RM site id. + * Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node. + * */ + String DEFAULT_RM_SITE_ID = "rm"; + + /** + * Indicates whether the given node is a file plan component or not. + * + * @param nodeRef node reference + * @return boolean true if a file plan component, false otherwise + */ + boolean isFilePlanComponent(NodeRef nodeRef); + + /** + * Returns the 'kind' of file plan component the node reference is. + *

+ * Returns null if the given node reference is not a + * file plan component. + * + * @param nodeRef node reference + * @return FilePlanComponentKind the kind of file plan component the node is + */ + FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); + + /** + * Returns the file plan component 'kind' that relates to the passed + * content type. + *

+ * Returns null if the type does not relate to a file plan component. + * + * @param type qualified name of content type + * @return FilePlanComponentKind the kind relating to the passed type + */ + FilePlanComponentKind getFilePlanComponentKindFromType(QName type); + + /** + * Indicates whether the given node is file plan node or not. + * + * @param nodeRef node reference + * @return boolean true if node is a file plan node + */ + boolean isFilePlan(NodeRef nodeRef); + + /** + * Gets all the file plan nodes. + * Looks in the SpacesStore by default. + * + * @return Set set of file plan nodes + */ + Set getFilePlans(); + + /** + * Getse all the file plan nodes in a store. + * + * @param storeRef store reference + * @return Set set of file plan nodes + */ + Set getFilePlans(StoreRef storeRef); + + /** + * Gets the file plan the node is in. + * + * @return {@link NodeRef} file node reference, null if none + */ + NodeRef getFilePlan(NodeRef nodeRef); + + /** + * Gets a file plan by site id. Assumes the site is a RM site and that the file plan node, ie + * the document library container, has been already created. Otherwise returns null. + * + * @param siteId records management site id + * @return NodeRef file plan, null if can't be found + */ + NodeRef getFilePlanBySiteId(String siteId); + + /** + * Indicates whether the unfiled container exists for a given file plan or not. + * + * @param filePlan file plan + * @return boolean true if unfiled container exists, false otherwise + */ + boolean existsUnfiledContainer(NodeRef filePlan); + + /** + * Gets the unfiled container for a given file plan. Returns null if + * none. + * + * @param filePlan file plan + * @return {@link NodeRef} unfiled container, null if none + */ + NodeRef getUnfiledContainer(NodeRef filePlan); + + /** + * Creates, and returns, a unfiled container for a given file plan. + * + * @param filePlan file plan + * @return {@link Node} unfiled container + */ + NodeRef createUnfiledContainer(NodeRef filePlan); + + /** + * Gets the hold container for a given file plan. Returns + * null if none. + * + * @param filePlan + * @return + */ + NodeRef getHoldContainer(NodeRef filePlan); + + /** + * + * @param filePlan + * @return + */ + NodeRef createHoldContainer(NodeRef filePlan); + + /** + * + * @param filePlan + * @return + */ + NodeRef getTransferContainer(NodeRef filePlan); + + /** + * + * @param filePlan + * @return + */ + NodeRef createTransferContainer(NodeRef filePlan); + + /** + * Creates a file plan as a child of the given parent node, with the name + * provided. + * + * @param parent parent node reference + * @param name file plan name + * @param type type, must be rma:filePlan or sub-type of + * @return NodeRef file plan node reference + */ + NodeRef createFilePlan(NodeRef parent, String name, QName type); + + /** + * Specifies the properties to be set on the created file plan. + * + * @see #createFilePlan(NodeRef, String, QName) + * + * @param parent parent node reference + * @param name file plan name + * @param type type, must be rma:filePlan or sub-type of + * @param properties file plan properties + * @return NodeRef file plan node reference + */ + NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); + + /** + * Creates a file plan with the default type. + * + * @see #createFilePlan(NodeRef, String, QName) + * + * @param parent parent node reference + * @param name file plan name + * @return NodeRef file plan node reference + */ + NodeRef createFilePlan(NodeRef parent, String name); + + /** + * Creates a file plan with the default type, specifying properties. + * + * @see #createFilePlan(NodeRef, String, QName) + * + * @param parent parent node reference + * @param name file plan name + * @param properties file plan properties + * @return NodeRef file plan node reference + */ + NodeRef createFilePlan(NodeRef parent, String name, Map properties); + + // TODO deleteFilePlan + + /** + * Gets the NodeRef sequence from the {@link #getFilePlan(NodeRef) root} + * down to the fileplan component given. The array will start with the NodeRef of the root + * and end with the name of the fileplan component node given. + * + * @param nodeRef a fileplan component + * @return Returns a NodeRef path starting with the file plan + */ + List getNodeRefPath(NodeRef nodeRef); + + /** + * Indicates whether the given node is a file plan container or not. + *

+ * This includes file plan and record category nodes. + * + * @param nodeRef node reference + * @return boolean true if node is a file plan container, false otherwise. + */ + boolean isFilePlanContainer(NodeRef nodeRef); + + /** + * Indicates whether the given node is a record category or not. + * + * @param nodeRef node reference + * @return boolean true if records category, false otherwise + */ + boolean isRecordCategory(NodeRef nodeRef); + + /** + * Get all the items contained within a container. This will include record folders and other record categories. + * + * @param recordCategory record category node reference + * @param deep if true then return all children including sub-categories and their children in turn, if false then just + * return the immediate children + * @return {@link List}<{@link NodeRef>} list of contained node references + */ + List getAllContained(NodeRef recordCategory, boolean deep); + + /** + * Only return the immediate children. + * + * @param recordCategory record category node reference + * @return {@link List}<{@link NodeRef>} list of contained node references + */ + List getAllContained(NodeRef recordCategory); + + /** + * Get all the record categories within a record category. + * + * @param recordCategory record category node reference + * @param deep if true then return all children including sub-categories and their children in turn, if false then just + * return the immediate children + * @return {@link List}<{@link NodeRef>} list of container node references + */ + List getContainedRecordCategories(NodeRef recordCategory, boolean deep); + + /** + * Only return immediate children. + * + * @param recordCategory container node reference + * @return {@link List}<{@link NodeRef>} list of container node references + */ + List getContainedRecordCategories(NodeRef recordCategory); + + /** + * Get all the record folders contained within a container + * + * @param container container node reference + * @param deep if true then return all children including sub-containers and their children in turn, if false then just + * return the immediate children + * @return {@link List}<{@link NodeRef>} list of record folder node references + */ + List getContainedRecordFolders(NodeRef container, boolean deep); + + /** + * Only return immediate children. + * + * @param container container node reference + * @return {@link List}<{@link NodeRef>} list of record folder node references + */ + List getContainedRecordFolders(NodeRef container); + + /** + * Create a record category. + * + * @param parent parent node reference, must be a record category or file plan. + * @param name name of the new record category + * @param type type of container to create, must be a sub-type of rm:recordCategory + * @return NodeRef node reference of the created record category + */ + NodeRef createRecordCategory(NodeRef parent, String name, QName type); + + /** + * + * @param parent + * @param name + * @param type + * @param properties + * @return + */ + NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); + + /** + * Creates a record category of type rma:recordCategory + * + * @param parent parent node reference, must be a record category or file plan. + * @param name name of the record category + * @return NodeRef node reference of the created record category + */ + NodeRef createRecordCategory(NodeRef parent, String name); + + /** + * + * @param parent + * @param name + * @param properties + * @return + */ + NodeRef createRecordCategory(NodeRef parent, String name, Map properties); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 7bc57fb327..174ba54c7c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -1,630 +1,630 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.fileplan; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.domain.node.NodeDAO; -import org.alfresco.repo.rule.RuleModel; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * File plan service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FilePlanServiceImpl extends ServiceBaseImpl - implements FilePlanService, - RecordsManagementModel -{ - /** I18N */ - private static final String MSG_DUP_ROOT = "rm.service.dup-root"; - private static final String MSG_ROOT_TYPE = "rm.service.root-type"; - private static final String MSG_PATH_NODE = "rm.service.path-node"; - private static final String MSG_NO_ROOT = "rm.service.no-root"; - private static final String MSG_CONTAINER_PARENT_TYPE= "rm.service.container-parent-type"; - private static final String MSG_CONTAINER_TYPE = "rm.service.container-type"; - private static final String MSG_CONTAINER_EXPECTED = "rm.service.container-expected"; - - /** File plan containers */ - private static final String NAME_UNFILED_CONTAINER = "Unfiled Records"; - private static final String NAME_HOLD_CONTAINER = "Holds"; - private static final String NAME_TRANSFER_CONTAINER = "Transfers"; - - /** RM site file plan container */ - private static final String FILE_PLAN_CONTAINER = "documentLibrary"; - - /** root container cache */ - private SimpleCache, NodeRef> rootContainerCache; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** Permission service */ - private PermissionService permissionService; - - /** Node DAO */ - private NodeDAO nodeDAO; - - /** Site service */ - private SiteService siteService; - - /** - * Gets the file plan role service - * - * @return The file plan role service - */ - public FilePlanRoleService getFilePlanRoleService() - { - if (filePlanRoleService == null) - { - filePlanRoleService = (FilePlanRoleService) applicationContext.getBean("FilePlanRoleService"); - } - return filePlanRoleService; - } - - /** - * Gets the permission service - * - * @return The permission service - */ - public PermissionService getPermissionService() - { - if (permissionService == null) - { - permissionService = (PermissionService) applicationContext.getBean("permissionService"); - } - return permissionService; - } - - /** - * Gets the node DAO - * - * @return The node DAO - */ - public NodeDAO getNodeDAO() - { - if (nodeDAO == null) - { - nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); - } - return nodeDAO; - } - - /** - * Gets the site service - * - * @return The site service - */ - public SiteService getSiteService() - { - if (siteService == null) - { - siteService = (SiteService) applicationContext.getBean("SiteService"); - } - return siteService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans() - */ - @Override - public Set getFilePlans() - { - return getFilePlans(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - } - - /** - * @param rootContainerCache root container cache - */ - public void setRootContainerCache(SimpleCache, NodeRef> rootContainerCache) - { - this.rootContainerCache = rootContainerCache; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef) - */ - @Override - public Set getFilePlans(final StoreRef storeRef) - { - ParameterCheck.mandatory("storeRef", storeRef); - - final Set results = new HashSet(); - Set aspects = new HashSet(1); - aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); - getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() - { - @Override - public boolean handle(Pair nodePair) - { - NodeRef nodeRef = nodePair.getSecond(); - if (storeRef.equals(nodeRef.getStoreRef())) - { - results.add(nodeRef); - } - - return true; - } - }); - return results; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanBySiteId(java.lang.String) - */ - @Override - public NodeRef getFilePlanBySiteId(String siteId) - { - NodeRef filePlan = null; - - SiteInfo siteInfo = getSiteService().getSite(siteId); - if (siteInfo != null && getSiteService().hasContainer(siteId, FILE_PLAN_CONTAINER)) - { - NodeRef nodeRef = getSiteService().getContainer(siteId, FILE_PLAN_CONTAINER); - if (instanceOf(nodeRef, TYPE_FILE_PLAN)) - { - filePlan = nodeRef; - } - } - - return filePlan; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#existsUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean existsUnfiledContainer(NodeRef filePlan) - { - return (getUnfiledContainer(filePlan) != null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef getUnfiledContainer(NodeRef filePlan) - { - return getFilePlanRootContainer(filePlan, NAME_UNFILED_CONTAINER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getHoldContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef getHoldContainer(NodeRef filePlan) - { - return getFilePlanRootContainer(filePlan, NAME_HOLD_CONTAINER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getTransferContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef getTransferContainer(NodeRef filePlan) - { - return getFilePlanRootContainer(filePlan, NAME_TRANSFER_CONTAINER); - } - - /** - * Get the file root container for the given type. - * - * @param filePlan file plan - * @param containerName container type - * @return {@link NodeRef} file plan container - */ - private NodeRef getFilePlanRootContainer(NodeRef filePlan, String containerName) - { - ParameterCheck.mandatory("filePlan", filePlan); - if (!isFilePlan(filePlan)) - { - throw new AlfrescoRuntimeException("Unable to get the container " + containerName + ", because passed node is not a file plan."); - } - - NodeRef result = null; - Pair key = new Pair(filePlan, containerName); - - if (!rootContainerCache.contains(key)) - { - // try and get the unfiled record container - List assocs = nodeService.getChildAssocs(filePlan, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, containerName)); - if (assocs.size() > 1) - { - throw new AlfrescoRuntimeException("Unable to get unfiled conatiner " + containerName + "."); - } - else if (assocs.size() == 1) - { - result = assocs.get(0).getChildRef(); - rootContainerCache.put(key, result); - } - } - else - { - result = rootContainerCache.get(key); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - public NodeRef createUnfiledContainer(NodeRef filePlan) - { - return createFilePlanRootContainer(filePlan, TYPE_UNFILED_RECORD_CONTAINER, NAME_UNFILED_CONTAINER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createHoldContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef createHoldContainer(NodeRef filePlan) - { - return createFilePlanRootContainer(filePlan, TYPE_HOLD_CONTAINER, NAME_HOLD_CONTAINER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createTransferContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef createTransferContainer(NodeRef filePlan) - { - return createFilePlanRootContainer(filePlan, TYPE_TRANSFER_CONTAINER, NAME_TRANSFER_CONTAINER); - } - - /** - * - * @param filePlan - * @param containerType - * @param containerName - * @param inheritPermissions - * @return - */ - private NodeRef createFilePlanRootContainer(NodeRef filePlan, QName containerType, String containerName) - { - ParameterCheck.mandatory("filePlan", filePlan); - if (!isFilePlan(filePlan)) - { - throw new AlfrescoRuntimeException("Unable to create file plan root container, because passed node is not a file plan."); - } - - String allRoles = getFilePlanRoleService().getAllRolesContainerGroup(filePlan); - - // create the properties map - Map properties = new HashMap(1); - properties.put(ContentModel.PROP_NAME, containerName); - - // create the unfiled container - NodeRef container = nodeService.createNode( - filePlan, - ContentModel.ASSOC_CONTAINS, - QName.createQName(RM_URI, containerName), - containerType, - properties).getChildRef(); - - // set inheritance to false - getPermissionService().setInheritParentPermissions(container, false); - getPermissionService().setPermission(container, allRoles, RMPermissionModel.READ_RECORDS, true); - - // prevent inheritance of rules - nodeService.addAspect(container, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null); - - return container; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) - */ - public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) - { - ParameterCheck.mandatory("parent", parent); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("type", type); - - // Check the parent is not already an RM component node - // ie: you can't create a rm root in an existing rm hierarchy - if (isFilePlanComponent(parent)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DUP_ROOT)); - } - - // Check that the passed type is a sub-type of rma:filePlan - if (!TYPE_FILE_PLAN.equals(type) && - !dictionaryService.isSubClass(type, TYPE_FILE_PLAN)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ROOT_TYPE, type.toString())); - } - - // Build map of properties - Map rmRootProps = new HashMap(1); - if (properties != null && properties.size() != 0) - { - rmRootProps.putAll(properties); - } - rmRootProps.put(ContentModel.PROP_NAME, name); - - // Create the root - ChildAssociationRef assocRef = nodeService.createNode( - parent, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), - type, - rmRootProps); - - // TODO do we need to create role and security groups or is this done automatically? - - return assocRef.getChildRef(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) - */ - public NodeRef createFilePlan(NodeRef parent, String name, Map properties) - { - return createFilePlan(parent, name, TYPE_FILE_PLAN, properties); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public NodeRef createFilePlan(NodeRef parent, String name) - { - return createFilePlan(parent, name, TYPE_FILE_PLAN, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) - */ - @Override - public NodeRef createFilePlan(NodeRef parent, String name, QName type) - { - return createFilePlan(parent, name, type, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getNodeRefPath(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getNodeRefPath(NodeRef nodeRef) - { - LinkedList nodeRefPath = new LinkedList(); - try - { - getNodeRefPathRecursive(nodeRef, nodeRefPath); - } - catch (RuntimeException e) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PATH_NODE, nodeRef), e); - } - return nodeRefPath; - } - - /** - * Helper method to build a NodeRef path from the node to the RM root - */ - private void getNodeRefPathRecursive(NodeRef nodeRef, Deque nodeRefPath) - { - if (isFilePlanComponent(nodeRef)) - { - // Prepend it to the path - nodeRefPath.addFirst(nodeRef); - // Are we not at the root - if (!isFilePlan(nodeRef)) - { - ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); - if (assocRef == null) - { - // We hit the top of the store - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_ROOT)); - } - // Recurse - nodeRef = assocRef.getParentRef(); - getNodeRefPathRecursive(nodeRef, nodeRefPath); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) - */ - public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) - { - ParameterCheck.mandatory("parent", parent); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("type", type); - - // Check that the parent is a container - QName parentType = nodeService.getType(parent); - if (!TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) && - !dictionaryService.isSubClass(parentType, TYPE_RECORDS_MANAGEMENT_CONTAINER)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString())); - } - - // Check that the the provided type is a sub-type of rm:recordCategory - if (!TYPE_RECORD_CATEGORY.equals(type) && - !dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString())); - } - - // Set the properties for the record category - Map props = new HashMap(1); - if (properties != null && properties.size() != 0) - { - props.putAll(properties); - } - props.put(ContentModel.PROP_NAME, name); - - return nodeService.createNode( - parent, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, (name.length() > QName.MAX_LENGTH ? name.substring(0, QName.MAX_LENGTH) : name)), - type, - props).getChildRef(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public NodeRef createRecordCategory(NodeRef parent, String name) - { - return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) - */ - public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) - { - return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY, properties); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) - */ - public NodeRef createRecordCategory(NodeRef parent, String name, QName type) - { - return createRecordCategory(parent, name, type, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getAllContained(NodeRef container) - { - return getAllContained(container, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public List getAllContained(NodeRef container, boolean deep) - { - return getContained(container, null, deep); - } - - /** - * Get contained nodes of a particular type. If null return all. - * - * @param container container node reference - * @param typeFilter type filter, null if none - * @return {@link List}<{@link NodeRef> list of contained node references - */ - private List getContained(NodeRef container, QName typeFilter, boolean deep) - { - // Parameter check - ParameterCheck.mandatory("container", container); - - // Check we have a container in our hands - if (!isRecordCategory(container)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED)); - } - - List result = new ArrayList(1); - List assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef child = assoc.getChildRef(); - QName childType = nodeService.getType(child); - if (typeFilter == null || - typeFilter.equals(childType) || - dictionaryService.isSubClass(childType, typeFilter)) - { - result.add(child); - } - - // Inspect the containers and add children if deep - if (deep && - (TYPE_RECORD_CATEGORY.equals(childType) || - dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY))) - { - result.addAll(getContained(child, typeFilter, deep)); - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getContainedRecordCategories(NodeRef container) - { - return getContainedRecordCategories(container, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public List getContainedRecordCategories(NodeRef container, boolean deep) - { - return getContained(container, TYPE_RECORD_CATEGORY, deep); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getContainedRecordFolders(NodeRef container) - { - return getContainedRecordFolders(container, false); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public List getContainedRecordFolders(NodeRef container, boolean deep) - { - return getContained(container, TYPE_RECORD_FOLDER, deep); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.fileplan; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.rule.RuleModel; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * File plan service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FilePlanServiceImpl extends ServiceBaseImpl + implements FilePlanService, + RecordsManagementModel +{ + /** I18N */ + private static final String MSG_DUP_ROOT = "rm.service.dup-root"; + private static final String MSG_ROOT_TYPE = "rm.service.root-type"; + private static final String MSG_PATH_NODE = "rm.service.path-node"; + private static final String MSG_NO_ROOT = "rm.service.no-root"; + private static final String MSG_CONTAINER_PARENT_TYPE= "rm.service.container-parent-type"; + private static final String MSG_CONTAINER_TYPE = "rm.service.container-type"; + private static final String MSG_CONTAINER_EXPECTED = "rm.service.container-expected"; + + /** File plan containers */ + private static final String NAME_UNFILED_CONTAINER = "Unfiled Records"; + private static final String NAME_HOLD_CONTAINER = "Holds"; + private static final String NAME_TRANSFER_CONTAINER = "Transfers"; + + /** RM site file plan container */ + private static final String FILE_PLAN_CONTAINER = "documentLibrary"; + + /** root container cache */ + private SimpleCache, NodeRef> rootContainerCache; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** Permission service */ + private PermissionService permissionService; + + /** Node DAO */ + private NodeDAO nodeDAO; + + /** Site service */ + private SiteService siteService; + + /** + * Gets the file plan role service + * + * @return The file plan role service + */ + public FilePlanRoleService getFilePlanRoleService() + { + if (filePlanRoleService == null) + { + filePlanRoleService = (FilePlanRoleService) applicationContext.getBean("FilePlanRoleService"); + } + return filePlanRoleService; + } + + /** + * Gets the permission service + * + * @return The permission service + */ + public PermissionService getPermissionService() + { + if (permissionService == null) + { + permissionService = (PermissionService) applicationContext.getBean("permissionService"); + } + return permissionService; + } + + /** + * Gets the node DAO + * + * @return The node DAO + */ + public NodeDAO getNodeDAO() + { + if (nodeDAO == null) + { + nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); + } + return nodeDAO; + } + + /** + * Gets the site service + * + * @return The site service + */ + public SiteService getSiteService() + { + if (siteService == null) + { + siteService = (SiteService) applicationContext.getBean("SiteService"); + } + return siteService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans() + */ + @Override + public Set getFilePlans() + { + return getFilePlans(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + } + + /** + * @param rootContainerCache root container cache + */ + public void setRootContainerCache(SimpleCache, NodeRef> rootContainerCache) + { + this.rootContainerCache = rootContainerCache; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef) + */ + @Override + public Set getFilePlans(final StoreRef storeRef) + { + ParameterCheck.mandatory("storeRef", storeRef); + + final Set results = new HashSet(); + Set aspects = new HashSet(1); + aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); + getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() + { + @Override + public boolean handle(Pair nodePair) + { + NodeRef nodeRef = nodePair.getSecond(); + if (storeRef.equals(nodeRef.getStoreRef())) + { + results.add(nodeRef); + } + + return true; + } + }); + return results; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanBySiteId(java.lang.String) + */ + @Override + public NodeRef getFilePlanBySiteId(String siteId) + { + NodeRef filePlan = null; + + SiteInfo siteInfo = getSiteService().getSite(siteId); + if (siteInfo != null && getSiteService().hasContainer(siteId, FILE_PLAN_CONTAINER)) + { + NodeRef nodeRef = getSiteService().getContainer(siteId, FILE_PLAN_CONTAINER); + if (instanceOf(nodeRef, TYPE_FILE_PLAN)) + { + filePlan = nodeRef; + } + } + + return filePlan; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#existsUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean existsUnfiledContainer(NodeRef filePlan) + { + return (getUnfiledContainer(filePlan) != null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef getUnfiledContainer(NodeRef filePlan) + { + return getFilePlanRootContainer(filePlan, NAME_UNFILED_CONTAINER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getHoldContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef getHoldContainer(NodeRef filePlan) + { + return getFilePlanRootContainer(filePlan, NAME_HOLD_CONTAINER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getTransferContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef getTransferContainer(NodeRef filePlan) + { + return getFilePlanRootContainer(filePlan, NAME_TRANSFER_CONTAINER); + } + + /** + * Get the file root container for the given type. + * + * @param filePlan file plan + * @param containerName container type + * @return {@link NodeRef} file plan container + */ + private NodeRef getFilePlanRootContainer(NodeRef filePlan, String containerName) + { + ParameterCheck.mandatory("filePlan", filePlan); + if (!isFilePlan(filePlan)) + { + throw new AlfrescoRuntimeException("Unable to get the container " + containerName + ", because passed node is not a file plan."); + } + + NodeRef result = null; + Pair key = new Pair(filePlan, containerName); + + if (!rootContainerCache.contains(key)) + { + // try and get the unfiled record container + List assocs = nodeService.getChildAssocs(filePlan, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, containerName)); + if (assocs.size() > 1) + { + throw new AlfrescoRuntimeException("Unable to get unfiled conatiner " + containerName + "."); + } + else if (assocs.size() == 1) + { + result = assocs.get(0).getChildRef(); + rootContainerCache.put(key, result); + } + } + else + { + result = rootContainerCache.get(key); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + public NodeRef createUnfiledContainer(NodeRef filePlan) + { + return createFilePlanRootContainer(filePlan, TYPE_UNFILED_RECORD_CONTAINER, NAME_UNFILED_CONTAINER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createHoldContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef createHoldContainer(NodeRef filePlan) + { + return createFilePlanRootContainer(filePlan, TYPE_HOLD_CONTAINER, NAME_HOLD_CONTAINER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createTransferContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef createTransferContainer(NodeRef filePlan) + { + return createFilePlanRootContainer(filePlan, TYPE_TRANSFER_CONTAINER, NAME_TRANSFER_CONTAINER); + } + + /** + * + * @param filePlan + * @param containerType + * @param containerName + * @param inheritPermissions + * @return + */ + private NodeRef createFilePlanRootContainer(NodeRef filePlan, QName containerType, String containerName) + { + ParameterCheck.mandatory("filePlan", filePlan); + if (!isFilePlan(filePlan)) + { + throw new AlfrescoRuntimeException("Unable to create file plan root container, because passed node is not a file plan."); + } + + String allRoles = getFilePlanRoleService().getAllRolesContainerGroup(filePlan); + + // create the properties map + Map properties = new HashMap(1); + properties.put(ContentModel.PROP_NAME, containerName); + + // create the unfiled container + NodeRef container = nodeService.createNode( + filePlan, + ContentModel.ASSOC_CONTAINS, + QName.createQName(RM_URI, containerName), + containerType, + properties).getChildRef(); + + // set inheritance to false + getPermissionService().setInheritParentPermissions(container, false); + getPermissionService().setPermission(container, allRoles, RMPermissionModel.READ_RECORDS, true); + + // prevent inheritance of rules + nodeService.addAspect(container, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null); + + return container; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) + */ + public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) + { + ParameterCheck.mandatory("parent", parent); + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("type", type); + + // Check the parent is not already an RM component node + // ie: you can't create a rm root in an existing rm hierarchy + if (isFilePlanComponent(parent)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DUP_ROOT)); + } + + // Check that the passed type is a sub-type of rma:filePlan + if (!TYPE_FILE_PLAN.equals(type) && + !dictionaryService.isSubClass(type, TYPE_FILE_PLAN)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ROOT_TYPE, type.toString())); + } + + // Build map of properties + Map rmRootProps = new HashMap(1); + if (properties != null && properties.size() != 0) + { + rmRootProps.putAll(properties); + } + rmRootProps.put(ContentModel.PROP_NAME, name); + + // Create the root + ChildAssociationRef assocRef = nodeService.createNode( + parent, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), + type, + rmRootProps); + + // TODO do we need to create role and security groups or is this done automatically? + + return assocRef.getChildRef(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) + */ + public NodeRef createFilePlan(NodeRef parent, String name, Map properties) + { + return createFilePlan(parent, name, TYPE_FILE_PLAN, properties); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + public NodeRef createFilePlan(NodeRef parent, String name) + { + return createFilePlan(parent, name, TYPE_FILE_PLAN, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) + */ + @Override + public NodeRef createFilePlan(NodeRef parent, String name, QName type) + { + return createFilePlan(parent, name, type, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getNodeRefPath(org.alfresco.service.cmr.repository.NodeRef) + */ + public List getNodeRefPath(NodeRef nodeRef) + { + LinkedList nodeRefPath = new LinkedList(); + try + { + getNodeRefPathRecursive(nodeRef, nodeRefPath); + } + catch (RuntimeException e) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PATH_NODE, nodeRef), e); + } + return nodeRefPath; + } + + /** + * Helper method to build a NodeRef path from the node to the RM root + */ + private void getNodeRefPathRecursive(NodeRef nodeRef, Deque nodeRefPath) + { + if (isFilePlanComponent(nodeRef)) + { + // Prepend it to the path + nodeRefPath.addFirst(nodeRef); + // Are we not at the root + if (!isFilePlan(nodeRef)) + { + ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); + if (assocRef == null) + { + // We hit the top of the store + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_ROOT)); + } + // Recurse + nodeRef = assocRef.getParentRef(); + getNodeRefPathRecursive(nodeRef, nodeRefPath); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) + */ + public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) + { + ParameterCheck.mandatory("parent", parent); + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("type", type); + + // Check that the parent is a container + QName parentType = nodeService.getType(parent); + if (!TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) && + !dictionaryService.isSubClass(parentType, TYPE_RECORDS_MANAGEMENT_CONTAINER)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString())); + } + + // Check that the the provided type is a sub-type of rm:recordCategory + if (!TYPE_RECORD_CATEGORY.equals(type) && + !dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString())); + } + + // Set the properties for the record category + Map props = new HashMap(1); + if (properties != null && properties.size() != 0) + { + props.putAll(properties); + } + props.put(ContentModel.PROP_NAME, name); + + return nodeService.createNode( + parent, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, (name.length() > QName.MAX_LENGTH ? name.substring(0, QName.MAX_LENGTH) : name)), + type, + props).getChildRef(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + public NodeRef createRecordCategory(NodeRef parent, String name) + { + return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) + */ + public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) + { + return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY, properties); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) + */ + public NodeRef createRecordCategory(NodeRef parent, String name, QName type) + { + return createRecordCategory(parent, name, type, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getAllContained(NodeRef container) + { + return getAllContained(container, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public List getAllContained(NodeRef container, boolean deep) + { + return getContained(container, null, deep); + } + + /** + * Get contained nodes of a particular type. If null return all. + * + * @param container container node reference + * @param typeFilter type filter, null if none + * @return {@link List}<{@link NodeRef> list of contained node references + */ + private List getContained(NodeRef container, QName typeFilter, boolean deep) + { + // Parameter check + ParameterCheck.mandatory("container", container); + + // Check we have a container in our hands + if (!isRecordCategory(container)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED)); + } + + List result = new ArrayList(1); + List assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef child = assoc.getChildRef(); + QName childType = nodeService.getType(child); + if (typeFilter == null || + typeFilter.equals(childType) || + dictionaryService.isSubClass(childType, typeFilter)) + { + result.add(child); + } + + // Inspect the containers and add children if deep + if (deep && + (TYPE_RECORD_CATEGORY.equals(childType) || + dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY))) + { + result.addAll(getContained(child, typeFilter, deep)); + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getContainedRecordCategories(NodeRef container) + { + return getContainedRecordCategories(container, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public List getContainedRecordCategories(NodeRef container, boolean deep) + { + return getContained(container, TYPE_RECORD_CATEGORY, deep); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getContainedRecordFolders(NodeRef container) + { + return getContainedRecordFolders(container, false); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public List getContainedRecordFolders(NodeRef container, boolean deep) + { + return getContained(container, TYPE_RECORD_FOLDER, deep); + } +} 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 846c16cd05..3996690a57 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 @@ -1,184 +1,184 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.forms; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.forms.Field; -import org.alfresco.repo.forms.FieldGroup; -import org.alfresco.repo.forms.Form; -import org.alfresco.repo.forms.FormData; -import org.alfresco.repo.forms.processor.AbstractFilter; -import org.alfresco.repo.forms.processor.node.FieldUtils; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Abstract base class for records management related form filter - * implementations. - * - * @author Gavin Cornwell - */ -public abstract class RecordsManagementFormFilter extends AbstractFilter -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RecordsManagementFormFilter.class); - - public static final String CUSTOM_RM_FIELD_GROUP_ID = "rm-custom"; - public static final String RM_METADATA_PREFIX = "rm-metadata-"; - - protected NamespaceService namespaceService; - protected NodeService nodeService; - protected RecordsManagementServiceRegistry rmServiceRegistry; - protected RecordsManagementAdminService rmAdminService; - protected RecordService recordService; - protected DictionaryService dictionaryService; - - /** - * Sets the NamespaceService instance - * - * @param namespaceService The NamespaceService instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Sets the node service - * - * @param nodeService The NodeService instance - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Sets the RecordsManagementServiceRegistry instance - * - * @param rmServiceRegistry The RecordsManagementServiceRegistry instance - */ - public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry rmServiceRegistry) - { - this.rmServiceRegistry = rmServiceRegistry; - } - - /** - * Sets the RecordsManagementAdminService instance - * - * @param rmAdminService The RecordsManagementAdminService instance - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) - { - this.rmAdminService = rmAdminService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Add property fields to group - * - * @param form - * @param props - * @param setId - */ - protected void addPropertyFieldsToGroup(Form form, Map props, String setId, String setLabel) - { - if (props != null) - { - for (Map.Entry entry : props.entrySet()) - { - PropertyDefinition prop = entry.getValue(); - - String id = form.getItem().getId(); - id = id.replaceFirst("/", "://"); - NodeRef nodeRef = new NodeRef(id); - Serializable value = nodeService.getProperty(nodeRef, entry.getKey()); - - FieldGroup group = new FieldGroup(setId, setLabel, false, false, null); - Field field = FieldUtils.makePropertyField(prop, value, group, namespaceService, dictionaryService); - - form.addField(field); - - if (logger.isDebugEnabled()) - { - logger.debug("Adding custom property .. " + prop.getName().toString() + " .. with value " + value + ".. to group .. " + setId); - } - } - } - } - - /** - * @see - * org.alfresco.repo.forms.processor.Filter#beforePersist(java.lang.Object, - * org.alfresco.repo.forms.FormData) - */ - public void beforePersist(ItemType item, FormData data) - { - // ignored - } - - /** - * @see - * org.alfresco.repo.forms.processor.Filter#beforeGenerate(java.lang.Object, - * java.util.List, java.util.List, org.alfresco.repo.forms.Form, - * java.util.Map) - */ - public void beforeGenerate(ItemType item, List fields, List forcedFields, Form form, - Map context) - { - // ignored - } - - /** - * @see - * org.alfresco.repo.forms.processor.Filter#afterPersist(java.lang.Object, - * org.alfresco.repo.forms.FormData, java.lang.Object) - */ - public void afterPersist(ItemType item, FormData data, NodeRef persistedObject) - { - // ignored - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.forms; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.forms.Field; +import org.alfresco.repo.forms.FieldGroup; +import org.alfresco.repo.forms.Form; +import org.alfresco.repo.forms.FormData; +import org.alfresco.repo.forms.processor.AbstractFilter; +import org.alfresco.repo.forms.processor.node.FieldUtils; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Abstract base class for records management related form filter + * implementations. + * + * @author Gavin Cornwell + */ +public abstract class RecordsManagementFormFilter extends AbstractFilter +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RecordsManagementFormFilter.class); + + public static final String CUSTOM_RM_FIELD_GROUP_ID = "rm-custom"; + public static final String RM_METADATA_PREFIX = "rm-metadata-"; + + protected NamespaceService namespaceService; + protected NodeService nodeService; + protected RecordsManagementServiceRegistry rmServiceRegistry; + protected RecordsManagementAdminService rmAdminService; + protected RecordService recordService; + protected DictionaryService dictionaryService; + + /** + * Sets the NamespaceService instance + * + * @param namespaceService The NamespaceService instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Sets the node service + * + * @param nodeService The NodeService instance + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Sets the RecordsManagementServiceRegistry instance + * + * @param rmServiceRegistry The RecordsManagementServiceRegistry instance + */ + public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry rmServiceRegistry) + { + this.rmServiceRegistry = rmServiceRegistry; + } + + /** + * Sets the RecordsManagementAdminService instance + * + * @param rmAdminService The RecordsManagementAdminService instance + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) + { + this.rmAdminService = rmAdminService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Add property fields to group + * + * @param form + * @param props + * @param setId + */ + protected void addPropertyFieldsToGroup(Form form, Map props, String setId, String setLabel) + { + if (props != null) + { + for (Map.Entry entry : props.entrySet()) + { + PropertyDefinition prop = entry.getValue(); + + String id = form.getItem().getId(); + id = id.replaceFirst("/", "://"); + NodeRef nodeRef = new NodeRef(id); + Serializable value = nodeService.getProperty(nodeRef, entry.getKey()); + + FieldGroup group = new FieldGroup(setId, setLabel, false, false, null); + Field field = FieldUtils.makePropertyField(prop, value, group, namespaceService, dictionaryService); + + form.addField(field); + + if (logger.isDebugEnabled()) + { + logger.debug("Adding custom property .. " + prop.getName().toString() + " .. with value " + value + ".. to group .. " + setId); + } + } + } + } + + /** + * @see + * org.alfresco.repo.forms.processor.Filter#beforePersist(java.lang.Object, + * org.alfresco.repo.forms.FormData) + */ + public void beforePersist(ItemType item, FormData data) + { + // ignored + } + + /** + * @see + * org.alfresco.repo.forms.processor.Filter#beforeGenerate(java.lang.Object, + * java.util.List, java.util.List, org.alfresco.repo.forms.Form, + * java.util.Map) + */ + public void beforeGenerate(ItemType item, List fields, List forcedFields, Form form, + Map context) + { + // ignored + } + + /** + * @see + * org.alfresco.repo.forms.processor.Filter#afterPersist(java.lang.Object, + * org.alfresco.repo.forms.FormData, java.lang.Object) + */ + public void afterPersist(ItemType item, FormData data, NodeRef persistedObject) + { + // ignored + } +} 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 389fb05a39..452cfd37cd 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 @@ -1,410 +1,410 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.forms; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ImapModel; -import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -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.Form; -import org.alfresco.repo.forms.PropertyFieldDefinition; -import org.alfresco.repo.forms.processor.node.FieldUtils; -import org.alfresco.repo.forms.processor.node.FormFieldConstants; -import org.alfresco.repo.i18n.StaticMessageLookup; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Implementation of a form processor Filter. - *

- * The filter ensures that any custom properties defined for the records - * management type are provided as part of the Form and also assigned to the - * same field group. - *

- * - * @author Gavin Cornwell - */ -public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel, DOD5015Model -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RecordsManagementNodeFormFilter.class); - - protected static final String TRANSIENT_DECLARED = "rmDeclared"; - protected static final String TRANSIENT_CATEGORY_ID = "rmCategoryIdentifier"; - protected static final String TRANSIENT_DISPOSITION_INSTRUCTIONS = "rmDispositionInstructions"; - - /** Disposition service */ - private DispositionService dispositionService; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** - * Returns the disposition service - * - * @return Disposition service - */ - protected DispositionService getDispositionService() - { - return this.dispositionService; - } - - /** - * Returns the file plan service - * - * @return File plan service - */ - protected FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * Sets the disposition service - * - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, java.util.List, java.util.List, org.alfresco.repo.forms.Form, java.util.Map) - */ - @Override - public void afterGenerate( - NodeRef nodeRef, - List fields, - List forcedFields, - Form form, - Map context) - { - if (getFilePlanService().isFilePlanComponent(nodeRef)) - { - // add all the custom properties - addCustomPropertyFieldsToGroup(form, nodeRef); - - FilePlanComponentKind kind = getFilePlanService().getFilePlanComponentKind(nodeRef); - if (FilePlanComponentKind.RECORD.equals(kind)) - { - // add all the record meta-data aspect properties - addRecordMetadataPropertyFieldsToGroup(form, nodeRef); - - // add required transient properties - addTransientProperties(form, nodeRef); - - // add the supplemental marking list property - forceSupplementalMarkingListProperty(form, nodeRef); - - // protect uneditable properties - protectRecordProperties(form, nodeRef); - - // if the record is the result of an email we need to 'protect' some fields - if (this.nodeService.hasAspect(nodeRef, ImapModel.ASPECT_IMAP_CONTENT)) - { - protectEmailExtractedFields(form, nodeRef); - } - } - else if (FilePlanComponentKind.RECORD_FOLDER.equals(kind)) - { - // add the supplemental marking list property - forceSupplementalMarkingListProperty(form, nodeRef); - - // add required transient properties - addTransientProperties(form, nodeRef); - } - else if (FilePlanComponentKind.DISPOSITION_SCHEDULE.equals(kind)) - { - // use the same mechanism used to determine whether steps can be removed from the - // schedule to determine whether the disposition level can be changed i.e. record - // level or folder level. - DispositionSchedule schedule = new DispositionScheduleImpl(this.rmServiceRegistry, this.nodeService, nodeRef); - if (getDispositionService().hasDisposableItems(schedule)) - { - protectRecordLevelDispositionPropertyField(form); - } - } - - } - } - - /** - * - * @param form - * @param nodeRef - */ - protected void addCustomPropertyFieldsToGroup(Form form, NodeRef nodeRef) - { - Set customisables = rmAdminService.getCustomisable(nodeRef); - - // Compatibility support: don't show category properties if node of type series - QName type = nodeService.getType(nodeRef); - if (CompatibilityModel.TYPE_RECORD_SERIES.equals(type)) - { - // remove record category from the list of customisable types to apply to the form - customisables.remove(TYPE_RECORD_CATEGORY); - } - - for (QName customisable : customisables) - { - addPropertyFieldsToGroup(form, rmAdminService.getCustomPropertyDefinitions(customisable), CUSTOM_RM_FIELD_GROUP_ID, null); - } - } - - /** - * - * @param form - * @param nodeRef - */ - protected void addRecordMetadataPropertyFieldsToGroup(Form form, NodeRef nodeRef) - { - Set aspects = recordService.getRecordMetadataAspects(nodeRef); - - for (QName aspect : aspects) - { - if (nodeService.hasAspect(nodeRef, aspect)) - { - String aspectName = aspect.getPrefixedQName(namespaceService).toPrefixString().replace(":", "-"); - String setId = RM_METADATA_PREFIX + aspectName; - - String setLabel = null; - AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); - if (aspectDefinition != null) - { - setLabel = aspectDefinition.getTitle(new StaticMessageLookup()); - } - - addPropertyFieldsToGroup(form, dictionaryService.getPropertyDefs(aspect), setId, setLabel); - } - } - } - - /** - * Forces the "rmc:supplementalMarkingList" property to be present, if it is - * already on the given node this method does nothing, otherwise a property - * field definition is generated for the property. - * - * @param form The Form instance to add the property to - * @param nodeRef The node the form is being generated for - */ - protected void forceSupplementalMarkingListProperty(Form form, NodeRef nodeRef) - { - if (!this.nodeService.hasAspect(nodeRef, - RecordsManagementCustomModel.ASPECT_SUPPLEMENTAL_MARKING_LIST)) - { - PropertyDefinition propDef = this.dictionaryService.getProperty( - RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST); - - if (propDef != null) - { - Field field = FieldUtils.makePropertyField(propDef, null, null, namespaceService, dictionaryService); - form.addField(field); - } - else if (logger.isWarnEnabled()) - { - logger.warn("Could not add " + - RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST.getLocalName() + - " property as it's definition could not be found"); - } - } - } - - /** - * - * @param form - * @param nodeRef - */ - protected void addTransientProperties(Form form, NodeRef nodeRef) - { - if (recordService.isRecord(nodeRef)) - { - addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef)); - } - - DispositionSchedule ds = getDispositionService().getDispositionSchedule(nodeRef); - if (ds != null) - { - String instructions = ds.getDispositionInstructions(); - if (instructions != null) - { - addTransientPropertyField(form, TRANSIENT_DISPOSITION_INSTRUCTIONS, DataTypeDefinition.TEXT, instructions); - } - - NodeRef recordCategory = getDispositionService().getAssociatedRecordsManagementContainer(ds); - if (recordCategory != null) - { - String categoryId = (String)nodeService.getProperty(recordCategory, PROP_IDENTIFIER); - if (categoryId != null) - { - addTransientPropertyField(form, TRANSIENT_CATEGORY_ID, DataTypeDefinition.TEXT, categoryId); - } - } - } - } - - /** - * - * @param form - * @param name - * @param type - * @param value - */ - protected void addTransientPropertyField(Form form, String name, QName type, Object value) - { - String dataKeyName = FormFieldConstants.PROP_DATA_PREFIX + name; - PropertyFieldDefinition declaredField = new PropertyFieldDefinition(name, type.getLocalName()); - declaredField.setLabel(name); - declaredField.setDescription(name); - declaredField.setProtectedField(true); - declaredField.setDataKeyName(dataKeyName); - form.addFieldDefinition(declaredField); - form.addData(dataKeyName, value); - } - - /** - * - * @param form - * @param nodeRef - */ - protected void protectRecordProperties(Form form, NodeRef nodeRef) - { - List fieldDefs = form.getFieldDefinitions(); - for (FieldDefinition fieldDef : fieldDefs) - { - if (!fieldDef.isProtectedField()) - { - String name = fieldDef.getName(); - String prefixName = null; - if ("size".equals(name) || "mimetype".equals(name) || "encoding".equals(name)) - { - prefixName = "cm:content"; - } - else - { - prefixName = fieldDef.getName(); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Checking property " + prefixName + " is editable by user " + AuthenticationUtil.getFullyAuthenticatedUser()); - } - - QName qname = QName.createQName(prefixName, namespaceService); - if (!recordService.isPropertyEditable(nodeRef, qname)) - { - if (logger.isDebugEnabled()) - { - logger.debug(" ... protected property"); - } - fieldDef.setProtectedField(true); - } - } - } - } - - /** - * Marks all the fields that contain data extracted from an email - * as protected fields. - * - * @param form The Form instance to add the property to - * @param nodeRef The node the form is being generated for - */ - protected void protectEmailExtractedFields(Form form, NodeRef nodeRef) - { - // iterate round existing fields and set email fields as protected - List fieldDefs = form.getFieldDefinitions(); - for (FieldDefinition fieldDef : fieldDefs) - { - String prefixName = fieldDef.getName(); - - // check the value of the property, if empty then do not mark property - // as read only - QName qname = QName.createQName(prefixName, namespaceService); - Serializable value = nodeService.getProperty(nodeRef, qname); - if (value != null && - (prefixName.equals("cm:title") || - prefixName.equals("cm:author") || - prefixName.equals("dod:originator") || - prefixName.equals("dod:publicationDate") || - prefixName.equals("dod:dateReceived") || - prefixName.equals("dod:address") || - prefixName.equals("dod:otherAddress"))) - { - fieldDef.setProtectedField(true); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("Set email related fields to be protected"); - } - } - - /** - * Marks the recordLevelDisposition property as protected to disable editing - * - * @param form The Form instance - */ - protected void protectRecordLevelDispositionPropertyField(Form form) - { - List fieldDefs = form.getFieldDefinitions(); - for (FieldDefinition fieldDef : fieldDefs) - { - if (fieldDef.getName().equals(RecordsManagementModel.PROP_RECORD_LEVEL_DISPOSITION.toPrefixString( - this.namespaceService))) - { - fieldDef.setProtectedField(true); - break; - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present"); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.forms; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ImapModel; +import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +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.Form; +import org.alfresco.repo.forms.PropertyFieldDefinition; +import org.alfresco.repo.forms.processor.node.FieldUtils; +import org.alfresco.repo.forms.processor.node.FormFieldConstants; +import org.alfresco.repo.i18n.StaticMessageLookup; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Implementation of a form processor Filter. + *

+ * The filter ensures that any custom properties defined for the records + * management type are provided as part of the Form and also assigned to the + * same field group. + *

+ * + * @author Gavin Cornwell + */ +public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel, DOD5015Model +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RecordsManagementNodeFormFilter.class); + + protected static final String TRANSIENT_DECLARED = "rmDeclared"; + protected static final String TRANSIENT_CATEGORY_ID = "rmCategoryIdentifier"; + protected static final String TRANSIENT_DISPOSITION_INSTRUCTIONS = "rmDispositionInstructions"; + + /** Disposition service */ + private DispositionService dispositionService; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** + * Returns the disposition service + * + * @return Disposition service + */ + protected DispositionService getDispositionService() + { + return this.dispositionService; + } + + /** + * Returns the file plan service + * + * @return File plan service + */ + protected FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * Sets the disposition service + * + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, java.util.List, java.util.List, org.alfresco.repo.forms.Form, java.util.Map) + */ + @Override + public void afterGenerate( + NodeRef nodeRef, + List fields, + List forcedFields, + Form form, + Map context) + { + if (getFilePlanService().isFilePlanComponent(nodeRef)) + { + // add all the custom properties + addCustomPropertyFieldsToGroup(form, nodeRef); + + FilePlanComponentKind kind = getFilePlanService().getFilePlanComponentKind(nodeRef); + if (FilePlanComponentKind.RECORD.equals(kind)) + { + // add all the record meta-data aspect properties + addRecordMetadataPropertyFieldsToGroup(form, nodeRef); + + // add required transient properties + addTransientProperties(form, nodeRef); + + // add the supplemental marking list property + forceSupplementalMarkingListProperty(form, nodeRef); + + // protect uneditable properties + protectRecordProperties(form, nodeRef); + + // if the record is the result of an email we need to 'protect' some fields + if (this.nodeService.hasAspect(nodeRef, ImapModel.ASPECT_IMAP_CONTENT)) + { + protectEmailExtractedFields(form, nodeRef); + } + } + else if (FilePlanComponentKind.RECORD_FOLDER.equals(kind)) + { + // add the supplemental marking list property + forceSupplementalMarkingListProperty(form, nodeRef); + + // add required transient properties + addTransientProperties(form, nodeRef); + } + else if (FilePlanComponentKind.DISPOSITION_SCHEDULE.equals(kind)) + { + // use the same mechanism used to determine whether steps can be removed from the + // schedule to determine whether the disposition level can be changed i.e. record + // level or folder level. + DispositionSchedule schedule = new DispositionScheduleImpl(this.rmServiceRegistry, this.nodeService, nodeRef); + if (getDispositionService().hasDisposableItems(schedule)) + { + protectRecordLevelDispositionPropertyField(form); + } + } + + } + } + + /** + * + * @param form + * @param nodeRef + */ + protected void addCustomPropertyFieldsToGroup(Form form, NodeRef nodeRef) + { + Set customisables = rmAdminService.getCustomisable(nodeRef); + + // Compatibility support: don't show category properties if node of type series + QName type = nodeService.getType(nodeRef); + if (CompatibilityModel.TYPE_RECORD_SERIES.equals(type)) + { + // remove record category from the list of customisable types to apply to the form + customisables.remove(TYPE_RECORD_CATEGORY); + } + + for (QName customisable : customisables) + { + addPropertyFieldsToGroup(form, rmAdminService.getCustomPropertyDefinitions(customisable), CUSTOM_RM_FIELD_GROUP_ID, null); + } + } + + /** + * + * @param form + * @param nodeRef + */ + protected void addRecordMetadataPropertyFieldsToGroup(Form form, NodeRef nodeRef) + { + Set aspects = recordService.getRecordMetadataAspects(nodeRef); + + for (QName aspect : aspects) + { + if (nodeService.hasAspect(nodeRef, aspect)) + { + String aspectName = aspect.getPrefixedQName(namespaceService).toPrefixString().replace(":", "-"); + String setId = RM_METADATA_PREFIX + aspectName; + + String setLabel = null; + AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); + if (aspectDefinition != null) + { + setLabel = aspectDefinition.getTitle(new StaticMessageLookup()); + } + + addPropertyFieldsToGroup(form, dictionaryService.getPropertyDefs(aspect), setId, setLabel); + } + } + } + + /** + * Forces the "rmc:supplementalMarkingList" property to be present, if it is + * already on the given node this method does nothing, otherwise a property + * field definition is generated for the property. + * + * @param form The Form instance to add the property to + * @param nodeRef The node the form is being generated for + */ + protected void forceSupplementalMarkingListProperty(Form form, NodeRef nodeRef) + { + if (!this.nodeService.hasAspect(nodeRef, + RecordsManagementCustomModel.ASPECT_SUPPLEMENTAL_MARKING_LIST)) + { + PropertyDefinition propDef = this.dictionaryService.getProperty( + RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST); + + if (propDef != null) + { + Field field = FieldUtils.makePropertyField(propDef, null, null, namespaceService, dictionaryService); + form.addField(field); + } + else if (logger.isWarnEnabled()) + { + logger.warn("Could not add " + + RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST.getLocalName() + + " property as it's definition could not be found"); + } + } + } + + /** + * + * @param form + * @param nodeRef + */ + protected void addTransientProperties(Form form, NodeRef nodeRef) + { + if (recordService.isRecord(nodeRef)) + { + addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef)); + } + + DispositionSchedule ds = getDispositionService().getDispositionSchedule(nodeRef); + if (ds != null) + { + String instructions = ds.getDispositionInstructions(); + if (instructions != null) + { + addTransientPropertyField(form, TRANSIENT_DISPOSITION_INSTRUCTIONS, DataTypeDefinition.TEXT, instructions); + } + + NodeRef recordCategory = getDispositionService().getAssociatedRecordsManagementContainer(ds); + if (recordCategory != null) + { + String categoryId = (String)nodeService.getProperty(recordCategory, PROP_IDENTIFIER); + if (categoryId != null) + { + addTransientPropertyField(form, TRANSIENT_CATEGORY_ID, DataTypeDefinition.TEXT, categoryId); + } + } + } + } + + /** + * + * @param form + * @param name + * @param type + * @param value + */ + protected void addTransientPropertyField(Form form, String name, QName type, Object value) + { + String dataKeyName = FormFieldConstants.PROP_DATA_PREFIX + name; + PropertyFieldDefinition declaredField = new PropertyFieldDefinition(name, type.getLocalName()); + declaredField.setLabel(name); + declaredField.setDescription(name); + declaredField.setProtectedField(true); + declaredField.setDataKeyName(dataKeyName); + form.addFieldDefinition(declaredField); + form.addData(dataKeyName, value); + } + + /** + * + * @param form + * @param nodeRef + */ + protected void protectRecordProperties(Form form, NodeRef nodeRef) + { + List fieldDefs = form.getFieldDefinitions(); + for (FieldDefinition fieldDef : fieldDefs) + { + if (!fieldDef.isProtectedField()) + { + String name = fieldDef.getName(); + String prefixName = null; + if ("size".equals(name) || "mimetype".equals(name) || "encoding".equals(name)) + { + prefixName = "cm:content"; + } + else + { + prefixName = fieldDef.getName(); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Checking property " + prefixName + " is editable by user " + AuthenticationUtil.getFullyAuthenticatedUser()); + } + + QName qname = QName.createQName(prefixName, namespaceService); + if (!recordService.isPropertyEditable(nodeRef, qname)) + { + if (logger.isDebugEnabled()) + { + logger.debug(" ... protected property"); + } + fieldDef.setProtectedField(true); + } + } + } + } + + /** + * Marks all the fields that contain data extracted from an email + * as protected fields. + * + * @param form The Form instance to add the property to + * @param nodeRef The node the form is being generated for + */ + protected void protectEmailExtractedFields(Form form, NodeRef nodeRef) + { + // iterate round existing fields and set email fields as protected + List fieldDefs = form.getFieldDefinitions(); + for (FieldDefinition fieldDef : fieldDefs) + { + String prefixName = fieldDef.getName(); + + // check the value of the property, if empty then do not mark property + // as read only + QName qname = QName.createQName(prefixName, namespaceService); + Serializable value = nodeService.getProperty(nodeRef, qname); + if (value != null && + (prefixName.equals("cm:title") || + prefixName.equals("cm:author") || + prefixName.equals("dod:originator") || + prefixName.equals("dod:publicationDate") || + prefixName.equals("dod:dateReceived") || + prefixName.equals("dod:address") || + prefixName.equals("dod:otherAddress"))) + { + fieldDef.setProtectedField(true); + } + } + + if (logger.isDebugEnabled()) + { + logger.debug("Set email related fields to be protected"); + } + } + + /** + * Marks the recordLevelDisposition property as protected to disable editing + * + * @param form The Form instance + */ + protected void protectRecordLevelDispositionPropertyField(Form form) + { + List fieldDefs = form.getFieldDefinitions(); + for (FieldDefinition fieldDef : fieldDefs) + { + if (fieldDef.getName().equals(RecordsManagementModel.PROP_RECORD_LEVEL_DISPOSITION.toPrefixString( + this.namespaceService))) + { + fieldDef.setProtectedField(true); + break; + } + } + + if (logger.isDebugEnabled()) + { + logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present"); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java index 31e8ddf37b..f11526a59e 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 @@ -1,182 +1,182 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.forms; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -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; -import org.alfresco.repo.forms.processor.node.FieldUtils; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Implementation of a form processor Filter. - *

- * The filter implements the afterGenerate method to ensure a - * default unique identifier is provided for the rma:identifier - * property. - *

- *

- * The filter also ensures that any custom properties defined for the records - * management type are provided as part of the Form. - *

- * - * @author Gavin Cornwell - */ -public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RecordsManagementTypeFormFilter.class); - - protected static final String NAME_FIELD_GROUP_ID = "name"; - protected static final String TITLE_FIELD_GROUP_ID = "title"; - protected static final String DESC_FIELD_GROUP_ID = "description"; - protected static final String OTHER_FIELD_GROUP_ID = "other"; - - protected static final FieldGroup NAME_FIELD_GROUP = new FieldGroup(NAME_FIELD_GROUP_ID, null, false, false, null); - protected static final FieldGroup TITLE_FIELD_GROUP = new FieldGroup(TITLE_FIELD_GROUP_ID, null, false, false, null); - protected static final FieldGroup DESC_FIELD_GROUP = new FieldGroup(DESC_FIELD_GROUP_ID, null, false, false, null); - protected static final FieldGroup OTHER_FIELD_GROUP = new FieldGroup(OTHER_FIELD_GROUP_ID, null, false, false, null); - - /** Identifier service */ - protected IdentifierService identifierService; - - /** - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /* - * @see - * org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, - * 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) - { - QName typeName = type.getName(); - if (rmAdminService.isCustomisable(typeName)) - { - addCustomRMProperties(typeName, form); - } - - // What about any mandatory aspects? - Set aspects = type.getDefaultAspectNames(); - for (QName aspect : aspects) - { - if (rmAdminService.isCustomisable(aspect)) - { - addCustomRMProperties(aspect, 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); - } - // NOTE: we set these defaults in the form for backwards compatibility reasons (RM-753) - else if (prefixName.equals("rma:vitalRecordIndicator")) - { - fieldDef.setDefaultValue(Boolean.FALSE.toString()); - } - else if (prefixName.equals("rma:reviewPeriod")) - { - fieldDef.setDefaultValue("none|0"); - } - } - } - - /** - * Adds a property definition for each of the custom properties for the - * given RM type to the given form. - * - * @param rmTypeCustomAspect Enum representing the RM type to add custom - * properties for - * @param form The form to add the properties to - */ - protected void addCustomRMProperties(QName customisableType, Form form) - { - ParameterCheck.mandatory("customisableType", customisableType); - ParameterCheck.mandatory("form", form); - - Map customProps = rmAdminService.getCustomPropertyDefinitions(customisableType); - - if (customProps != null && !customProps.isEmpty()) - { - if (logger.isDebugEnabled()) - { - logger.debug("Found " + customProps.size() + " custom properties for customisable type " + customisableType); - } - - // setup field definition for each custom property - Collection properties = customProps.values(); - FieldGroup group = new FieldGroup(CUSTOM_RM_FIELD_GROUP_ID, null, false, false, null); - List fields = FieldUtils.makePropertyFields(properties, group, namespaceService, dictionaryService); - form.addFields(fields); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementFormFilter#beforePersist(java.lang.Object, org.alfresco.repo.forms.FormData) - */ - @Override - public void beforePersist(TypeDefinition item, FormData data) - { - recordService.disablePropertyEditableCheck(); - super.beforePersist(item, data); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementFormFilter#afterPersist(java.lang.Object, org.alfresco.repo.forms.FormData, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void afterPersist(TypeDefinition item, FormData data, NodeRef persistedObject) - { - super.afterPersist(item, data, persistedObject); - recordService.enablePropertyEditableCheck(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.forms; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +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; +import org.alfresco.repo.forms.processor.node.FieldUtils; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.ParameterCheck; + +/** + * Implementation of a form processor Filter. + *

+ * The filter implements the afterGenerate method to ensure a + * default unique identifier is provided for the rma:identifier + * property. + *

+ *

+ * The filter also ensures that any custom properties defined for the records + * management type are provided as part of the Form. + *

+ * + * @author Gavin Cornwell + */ +public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RecordsManagementTypeFormFilter.class); + + protected static final String NAME_FIELD_GROUP_ID = "name"; + protected static final String TITLE_FIELD_GROUP_ID = "title"; + protected static final String DESC_FIELD_GROUP_ID = "description"; + protected static final String OTHER_FIELD_GROUP_ID = "other"; + + protected static final FieldGroup NAME_FIELD_GROUP = new FieldGroup(NAME_FIELD_GROUP_ID, null, false, false, null); + protected static final FieldGroup TITLE_FIELD_GROUP = new FieldGroup(TITLE_FIELD_GROUP_ID, null, false, false, null); + protected static final FieldGroup DESC_FIELD_GROUP = new FieldGroup(DESC_FIELD_GROUP_ID, null, false, false, null); + protected static final FieldGroup OTHER_FIELD_GROUP = new FieldGroup(OTHER_FIELD_GROUP_ID, null, false, false, null); + + /** Identifier service */ + protected IdentifierService identifierService; + + /** + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /* + * @see + * org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, + * 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) + { + QName typeName = type.getName(); + if (rmAdminService.isCustomisable(typeName)) + { + addCustomRMProperties(typeName, form); + } + + // What about any mandatory aspects? + Set aspects = type.getDefaultAspectNames(); + for (QName aspect : aspects) + { + if (rmAdminService.isCustomisable(aspect)) + { + addCustomRMProperties(aspect, 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); + } + // NOTE: we set these defaults in the form for backwards compatibility reasons (RM-753) + else if (prefixName.equals("rma:vitalRecordIndicator")) + { + fieldDef.setDefaultValue(Boolean.FALSE.toString()); + } + else if (prefixName.equals("rma:reviewPeriod")) + { + fieldDef.setDefaultValue("none|0"); + } + } + } + + /** + * Adds a property definition for each of the custom properties for the + * given RM type to the given form. + * + * @param rmTypeCustomAspect Enum representing the RM type to add custom + * properties for + * @param form The form to add the properties to + */ + protected void addCustomRMProperties(QName customisableType, Form form) + { + ParameterCheck.mandatory("customisableType", customisableType); + ParameterCheck.mandatory("form", form); + + Map customProps = rmAdminService.getCustomPropertyDefinitions(customisableType); + + if (customProps != null && !customProps.isEmpty()) + { + if (logger.isDebugEnabled()) + { + logger.debug("Found " + customProps.size() + " custom properties for customisable type " + customisableType); + } + + // setup field definition for each custom property + Collection properties = customProps.values(); + FieldGroup group = new FieldGroup(CUSTOM_RM_FIELD_GROUP_ID, null, false, false, null); + List fields = FieldUtils.makePropertyFields(properties, group, namespaceService, dictionaryService); + form.addFields(fields); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementFormFilter#beforePersist(java.lang.Object, org.alfresco.repo.forms.FormData) + */ + @Override + public void beforePersist(TypeDefinition item, FormData data) + { + recordService.disablePropertyEditableCheck(); + super.beforePersist(item, data); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementFormFilter#afterPersist(java.lang.Object, org.alfresco.repo.forms.FormData, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void afterPersist(TypeDefinition item, FormData data, NodeRef persistedObject) + { + super.afterPersist(item, data, persistedObject); + recordService.enablePropertyEditableCheck(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java index e167e24e2e..23788a173c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java @@ -1,140 +1,140 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.freeze; - -import java.util.Date; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Freeze Service Interface - * - * TODO should be deprecated and methods moved to the HoldService with "hold, held, etc" style names - * - * @author Roy Wetherall - * @since 2.0 - */ -public interface FreezeService -{ - /** - * Indicates whether the passed node reference is frozen. - * - * @param nodeRef node reference - * @return boolean true if frozen, false otherwise - */ - boolean isFrozen(NodeRef nodeRef); - - /** - * Checks whether or not the given node has frozen children - * - * @param nodeRef The nodeRef for which will be checked if it has frozen children - * @return true if the given nodeRef has frozen children, false otherwise - */ - boolean hasFrozenChildren(NodeRef nodeRef); - - /** - * Gets the date of the freeze for the given node, null if the node is not frozen - * - * @param nodeRef The nodeRef for which the date check will be performed - * @return Date The of the freeze or null - */ - Date getFreezeDate(NodeRef nodeRef); - - /** - * Gets the initiator of the freeze for the given node, null if the node is not frozen - * - * @param nodeRef The nodeRef for which the initiator check will be performed - * @return String The initiator of the freeze or null - */ - String getFreezeInitiator(NodeRef nodeRef); - - /** - * @deprecated as of 2.2, use {@link HoldService#isHold(NodeRef)} instead. - */ - @Deprecated - boolean isHold(NodeRef nodeRef); - - /** - * @deprecated as of 2.2, use {@link HoldService#getHeld(NodeRef)} instead. - */ - @Deprecated - Set getFrozen(NodeRef hold); - - /** - * @deprecated as of 2.2, use {@link HoldService#createHold(NodeRef, String, String, String)} and {@link HoldService#addToHold(NodeRef, NodeRef)} instead. - */ - @Deprecated - NodeRef freeze(String reason, NodeRef nodeRef); - - /** - * @deprecated as of 2.2, use {@link HoldService#addToHold(NodeRef, NodeRef)} instead. - */ - @Deprecated - void freeze(NodeRef hold, NodeRef nodeRef); - - /** - * @deprecated as of 2.2, use {@link HoldService#createHold(NodeRef, String, String, String)} and {@link HoldService#addToHold(NodeRef, List)} instead. - */ - @Deprecated - NodeRef freeze(String reason, Set nodeRefs); - - /** - * @deprecated as of 2.2, use {@link HoldService#addToHold(NodeRef, List)} instead. - */ - @Deprecated - void freeze(NodeRef hold, Set nodeRefs); - - /** - * @deprecated as of 2.2, use {@link HoldService#removeFromHold(NodeRef, NodeRef)} instead. - */ - @Deprecated - void unFreeze(NodeRef nodeRef); - - /** - * @deprecated as of 2.2, use {@link HoldService#removeFromHolds(java.util.List, NodeRef)} instead. - */ - @Deprecated - void unFreeze(Set nodeRefs); - - /** - * @deprecated as of 2.2, use {@link HoldService#deleteHold(NodeRef)} instead. - */ - @Deprecated - void relinquish(NodeRef hold); - - /** - * @deprecated as of 2.2, use {@link HoldService#getHoldReason(NodeRef)} instead. - */ - @Deprecated - String getReason(NodeRef hold); - - /** - * @deprecated as of 2.2, use {@link HoldService#setHoldReason(NodeRef, String)} instead. - */ - @Deprecated - void updateReason(NodeRef hold, String reason); - - /** - * @deprecated as of 2.2, use {@link HoldService#getHolds(NodeRef)} instead. - */ - @Deprecated - Set getHolds(NodeRef filePlan); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.freeze; + +import java.util.Date; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Freeze Service Interface + * + * TODO should be deprecated and methods moved to the HoldService with "hold, held, etc" style names + * + * @author Roy Wetherall + * @since 2.0 + */ +public interface FreezeService +{ + /** + * Indicates whether the passed node reference is frozen. + * + * @param nodeRef node reference + * @return boolean true if frozen, false otherwise + */ + boolean isFrozen(NodeRef nodeRef); + + /** + * Checks whether or not the given node has frozen children + * + * @param nodeRef The nodeRef for which will be checked if it has frozen children + * @return true if the given nodeRef has frozen children, false otherwise + */ + boolean hasFrozenChildren(NodeRef nodeRef); + + /** + * Gets the date of the freeze for the given node, null if the node is not frozen + * + * @param nodeRef The nodeRef for which the date check will be performed + * @return Date The of the freeze or null + */ + Date getFreezeDate(NodeRef nodeRef); + + /** + * Gets the initiator of the freeze for the given node, null if the node is not frozen + * + * @param nodeRef The nodeRef for which the initiator check will be performed + * @return String The initiator of the freeze or null + */ + String getFreezeInitiator(NodeRef nodeRef); + + /** + * @deprecated as of 2.2, use {@link HoldService#isHold(NodeRef)} instead. + */ + @Deprecated + boolean isHold(NodeRef nodeRef); + + /** + * @deprecated as of 2.2, use {@link HoldService#getHeld(NodeRef)} instead. + */ + @Deprecated + Set getFrozen(NodeRef hold); + + /** + * @deprecated as of 2.2, use {@link HoldService#createHold(NodeRef, String, String, String)} and {@link HoldService#addToHold(NodeRef, NodeRef)} instead. + */ + @Deprecated + NodeRef freeze(String reason, NodeRef nodeRef); + + /** + * @deprecated as of 2.2, use {@link HoldService#addToHold(NodeRef, NodeRef)} instead. + */ + @Deprecated + void freeze(NodeRef hold, NodeRef nodeRef); + + /** + * @deprecated as of 2.2, use {@link HoldService#createHold(NodeRef, String, String, String)} and {@link HoldService#addToHold(NodeRef, List)} instead. + */ + @Deprecated + NodeRef freeze(String reason, Set nodeRefs); + + /** + * @deprecated as of 2.2, use {@link HoldService#addToHold(NodeRef, List)} instead. + */ + @Deprecated + void freeze(NodeRef hold, Set nodeRefs); + + /** + * @deprecated as of 2.2, use {@link HoldService#removeFromHold(NodeRef, NodeRef)} instead. + */ + @Deprecated + void unFreeze(NodeRef nodeRef); + + /** + * @deprecated as of 2.2, use {@link HoldService#removeFromHolds(java.util.List, NodeRef)} instead. + */ + @Deprecated + void unFreeze(Set nodeRefs); + + /** + * @deprecated as of 2.2, use {@link HoldService#deleteHold(NodeRef)} instead. + */ + @Deprecated + void relinquish(NodeRef hold); + + /** + * @deprecated as of 2.2, use {@link HoldService#getHoldReason(NodeRef)} instead. + */ + @Deprecated + String getReason(NodeRef hold); + + /** + * @deprecated as of 2.2, use {@link HoldService#setHoldReason(NodeRef, String)} instead. + */ + @Deprecated + void updateReason(NodeRef hold, String reason); + + /** + * @deprecated as of 2.2, use {@link HoldService#getHolds(NodeRef)} instead. + */ + @Deprecated + Set getHolds(NodeRef filePlan); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java index 4bc3466ab5..ad08962a23 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java @@ -1,382 +1,382 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.freeze; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Freeze Service Implementation - * - * @author Roy Wetherall - * @author Tuna Aksoy - * @since 2.1 - */ -public class FreezeServiceImpl extends ServiceBaseImpl - implements FreezeService, - RecordsManagementModel -{ - /** I18N */ - private static final String MSG_HOLD_NAME = "rm.hold.name"; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** Hold service */ - private HoldService holdService; - - /** - * @return File plan service - */ - protected FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * @return Hold service - */ - protected HoldService getHoldService() - { - return this.holdService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param holdService hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#isFrozen(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isFrozen(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return nodeService.hasAspect(nodeRef, ASPECT_FROZEN); - } - - /** - * Deprecated Method Implementations - */ - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFrozen(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public Set getFrozen(NodeRef hold) - { - return new HashSet(getHoldService().getHeld(hold)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(java.lang.String, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public NodeRef freeze(String reason, NodeRef nodeRef) - { - NodeRef hold = createHold(nodeRef, reason); - getHoldService().addToHold(hold, nodeRef); - return hold; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public void freeze(NodeRef hold, NodeRef nodeRef) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("nodeRef", nodeRef); - - getHoldService().addToHold(hold, nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(java.lang.String, - * java.util.Set) - */ - @Override - @Deprecated - public NodeRef freeze(String reason, Set nodeRefs) - { - NodeRef hold = null; - if (!nodeRefs.isEmpty()) - { - List list = new ArrayList(nodeRefs); - hold = createHold(list.get(0), reason); - getHoldService().addToHold(hold, list); - } - return hold; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(org.alfresco.service.cmr.repository.NodeRef, - * java.util.Set) - */ - @Override - @Deprecated - public void freeze(NodeRef hold, Set nodeRefs) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - freeze(hold, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#unFreeze(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public void unFreeze(NodeRef nodeRef) - { - List holds = getHoldService().heldBy(nodeRef, true); - for (NodeRef hold : holds) - { - getHoldService().removeFromHold(hold, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#unFreeze(java.util.Set) - */ - @Override - @Deprecated - public void unFreeze(Set nodeRefs) - { - ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - unFreeze(nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#relinquish(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public void relinquish(NodeRef hold) - { - getHoldService().deleteHold(hold); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getReason(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Deprecated - public String getReason(NodeRef hold) - { - return getHoldService().getHoldReason(hold); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#updateReason(org.alfresco.service.cmr.repository.NodeRef, - * java.lang.String) - */ - @Override - @Deprecated - public void updateReason(NodeRef hold, String reason) - { - getHoldService().setHoldReason(hold, reason); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getHold(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Set getHolds(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - - return new HashSet(getHoldService().getHolds(filePlan)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#hasFrozenChildren(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean hasFrozenChildren(final NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - boolean result = false; - - // check that we are dealing with a record folder - if (isRecordFolder(nodeRef)) - { - int heldCount = 0; - - if (nodeService.hasAspect(nodeRef, ASPECT_HELD_CHILDREN)) - { - heldCount = (Integer)getInternalNodeService().getProperty(nodeRef, PROP_HELD_CHILDREN_COUNT); - } - else - { - final TransactionService transactionService = (TransactionService)applicationContext.getBean("transactionService"); - - heldCount = AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Integer doWork() - { - return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - int heldCount = 0; - - // NOTE: this process remains to 'patch' older systems to improve performance next time around - List childAssocs = getInternalNodeService().getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, null); - if (childAssocs != null && !childAssocs.isEmpty()) - { - for (ChildAssociationRef childAssociationRef : childAssocs) - { - NodeRef record = childAssociationRef.getChildRef(); - if (childAssociationRef.isPrimary() && isRecord(record) && isFrozen(record)) - { - heldCount ++; - } - } - } - - // add aspect and set count - Map props = new HashMap(1); - props.put(PROP_HELD_CHILDREN_COUNT, heldCount); - getInternalNodeService().addAspect(nodeRef, ASPECT_HELD_CHILDREN, props); - - return heldCount; - } - }, - false, true); - } - }); - } - - // true if more than one child held - result = (heldCount > 0); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFreezeDate(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Date getFreezeDate(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (isFrozen(nodeRef)) - { - Serializable property = nodeService.getProperty(nodeRef, PROP_FROZEN_AT); - if (property != null) { return (Date) property; } - } - - return null; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFreezeInitiator(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String getFreezeInitiator(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (isFrozen(nodeRef)) - { - Serializable property = nodeService.getProperty(nodeRef, PROP_FROZEN_BY); - if (property != null) { return (String) property; } - } - - return null; - } - - /** - * Helper Methods - */ - - /** - * Creates a hold using the given nodeRef and reason - * - * @param nodeRef the nodeRef which will be frozen - * @param reason the reason why the record will be frozen - * @return NodeRef of the created hold - */ - private NodeRef createHold(NodeRef nodeRef, String reason) - { - // get the hold container - final NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); - NodeRef holdContainer = getFilePlanService().getHoldContainer(filePlan); - - // calculate the hold name - int nextCount = getNextCount(holdContainer); - String holdName = I18NUtil.getMessage(MSG_HOLD_NAME) + " " + StringUtils.leftPad(Integer.toString(nextCount), 10, "0"); - - // create hold - return getHoldService().createHold(filePlan, holdName, reason, null); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.freeze; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Freeze Service Implementation + * + * @author Roy Wetherall + * @author Tuna Aksoy + * @since 2.1 + */ +public class FreezeServiceImpl extends ServiceBaseImpl + implements FreezeService, + RecordsManagementModel +{ + /** I18N */ + private static final String MSG_HOLD_NAME = "rm.hold.name"; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** Hold service */ + private HoldService holdService; + + /** + * @return File plan service + */ + protected FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * @return Hold service + */ + protected HoldService getHoldService() + { + return this.holdService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param holdService hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#isFrozen(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isFrozen(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return nodeService.hasAspect(nodeRef, ASPECT_FROZEN); + } + + /** + * Deprecated Method Implementations + */ + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFrozen(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public Set getFrozen(NodeRef hold) + { + return new HashSet(getHoldService().getHeld(hold)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(java.lang.String, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public NodeRef freeze(String reason, NodeRef nodeRef) + { + NodeRef hold = createHold(nodeRef, reason); + getHoldService().addToHold(hold, nodeRef); + return hold; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(org.alfresco.service.cmr.repository.NodeRef, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public void freeze(NodeRef hold, NodeRef nodeRef) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("nodeRef", nodeRef); + + getHoldService().addToHold(hold, nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(java.lang.String, + * java.util.Set) + */ + @Override + @Deprecated + public NodeRef freeze(String reason, Set nodeRefs) + { + NodeRef hold = null; + if (!nodeRefs.isEmpty()) + { + List list = new ArrayList(nodeRefs); + hold = createHold(list.get(0), reason); + getHoldService().addToHold(hold, list); + } + return hold; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#freeze(org.alfresco.service.cmr.repository.NodeRef, + * java.util.Set) + */ + @Override + @Deprecated + public void freeze(NodeRef hold, Set nodeRefs) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + freeze(hold, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#unFreeze(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public void unFreeze(NodeRef nodeRef) + { + List holds = getHoldService().heldBy(nodeRef, true); + for (NodeRef hold : holds) + { + getHoldService().removeFromHold(hold, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#unFreeze(java.util.Set) + */ + @Override + @Deprecated + public void unFreeze(Set nodeRefs) + { + ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + unFreeze(nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#relinquish(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public void relinquish(NodeRef hold) + { + getHoldService().deleteHold(hold); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getReason(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public String getReason(NodeRef hold) + { + return getHoldService().getHoldReason(hold); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#updateReason(org.alfresco.service.cmr.repository.NodeRef, + * java.lang.String) + */ + @Override + @Deprecated + public void updateReason(NodeRef hold, String reason) + { + getHoldService().setHoldReason(hold, reason); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getHold(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Set getHolds(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + + return new HashSet(getHoldService().getHolds(filePlan)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#hasFrozenChildren(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean hasFrozenChildren(final NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + boolean result = false; + + // check that we are dealing with a record folder + if (isRecordFolder(nodeRef)) + { + int heldCount = 0; + + if (nodeService.hasAspect(nodeRef, ASPECT_HELD_CHILDREN)) + { + heldCount = (Integer)getInternalNodeService().getProperty(nodeRef, PROP_HELD_CHILDREN_COUNT); + } + else + { + final TransactionService transactionService = (TransactionService)applicationContext.getBean("transactionService"); + + heldCount = AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Integer doWork() + { + return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() + { + public Integer execute() throws Throwable + { + int heldCount = 0; + + // NOTE: this process remains to 'patch' older systems to improve performance next time around + List childAssocs = getInternalNodeService().getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, null); + if (childAssocs != null && !childAssocs.isEmpty()) + { + for (ChildAssociationRef childAssociationRef : childAssocs) + { + NodeRef record = childAssociationRef.getChildRef(); + if (childAssociationRef.isPrimary() && isRecord(record) && isFrozen(record)) + { + heldCount ++; + } + } + } + + // add aspect and set count + Map props = new HashMap(1); + props.put(PROP_HELD_CHILDREN_COUNT, heldCount); + getInternalNodeService().addAspect(nodeRef, ASPECT_HELD_CHILDREN, props); + + return heldCount; + } + }, + false, true); + } + }); + } + + // true if more than one child held + result = (heldCount > 0); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFreezeDate(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Date getFreezeDate(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + if (isFrozen(nodeRef)) + { + Serializable property = nodeService.getProperty(nodeRef, PROP_FROZEN_AT); + if (property != null) { return (Date) property; } + } + + return null; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#getFreezeInitiator(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String getFreezeInitiator(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + if (isFrozen(nodeRef)) + { + Serializable property = nodeService.getProperty(nodeRef, PROP_FROZEN_BY); + if (property != null) { return (String) property; } + } + + return null; + } + + /** + * Helper Methods + */ + + /** + * Creates a hold using the given nodeRef and reason + * + * @param nodeRef the nodeRef which will be frozen + * @param reason the reason why the record will be frozen + * @return NodeRef of the created hold + */ + private NodeRef createHold(NodeRef nodeRef, String reason) + { + // get the hold container + final NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); + NodeRef holdContainer = getFilePlanService().getHoldContainer(filePlan); + + // calculate the hold name + int nextCount = getNextCount(holdContainer); + String holdName = I18NUtil.getMessage(MSG_HOLD_NAME) + " " + StringUtils.leftPad(Integer.toString(nextCount), 10, "0"); + + // create hold + return getHoldService().createHold(filePlan, holdName, reason, null); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldService.java index d7e2589c54..581eafd173 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldService.java @@ -1,187 +1,187 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.hold; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Hold service interface. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public interface HoldService -{ - /** - * Indicates whether the passed node reference is a hold. A hold is a container for a group of frozen object and contains the freeze - * reason. - * - * @param nodeRef hold node reference - * @return boolean true if hold, false otherwise - */ - boolean isHold(NodeRef nodeRef); - - /** - * Gets the list of all the holds within the holds container in the given file plan - * - * @param filePlan The {@link NodeRef} of the file plan - * @return List of hold node references - */ - List getHolds(NodeRef filePlan); - - /** - * Gets the node reference for the hold with the given name in the given file plan - * - * @param name {@link String} The name of the hold - * @return {@link NodeRef} of the hold with the given name - */ - NodeRef getHold(NodeRef filePlan, String name); - - /** - * Gets the list of all the holds within the holds container for the given node reference - * - * @param nodeRef The {@link NodeRef} of the record / record folder - * @param includedInHold true to retrieve the list of hold node references which will include the node reference - * false to get a list of node references which will not have the given node reference - * @return List of hold node references - */ - List heldBy(NodeRef nodeRef, boolean includedInHold); - - /** - * Gets the list of item node references which are in the given hold - * - * @param hold {@link NodeRef} of the hold - * @return Lost of item {@link NodeRef}s which are in the given hold - */ - List getHeld(NodeRef hold); - - /** - * Creates a hold with the given name, reason and description for the given file plan - * - * @param filePlan The {@link NodeRef} of the file plan - * @param name {@link String} The name of the hold - * @param reason {@link String} The reason of the hold - * @param description {@link String} The description of the hold - * @return The {@link NodeRef} of the created hold - */ - NodeRef createHold(NodeRef filePlan, String name, String reason, String description); - - /** - * Gets the hold reason for the given hold node reference - * - * @param hold The {@link NodeRef} of the hold - * @return {@link String} The reason of the hold - */ - String getHoldReason(NodeRef hold); - - /** - * Sets the hold reason - * - * @param hold The {@link NodeRef} of the hold - * @param reason {@link String} The reason for the hold - */ - void setHoldReason(NodeRef hold, String reason); - - /** - * Deletes the hold - * - * @param hold The {@link NodeRef} of the hold - */ - void deleteHold(NodeRef hold); - - /** - * Adds the record to the given hold - * - * @param hold The {@link NodeRef} of the hold - * @param nodeRef The {@link NodeRef} of the record / record folder which will be added to the given hold - */ - void addToHold(NodeRef hold, NodeRef nodeRef); - - /** - * Adds the items to the the given hold - * - * @param hold The {@link NodeRef} of the hold to which the items will be added - * @param nodeRefs The item {@link NodeRef}s which will be added to the hold - */ - void addToHold(NodeRef hold, List nodeRefs); - - /** - * Adds the record to the given list of holds - * - * @param holds The list of {@link NodeRef}s of the holds - * @param nodeRef The {@link NodeRef} of the record / record folder which will be added to the given holds - */ - void addToHolds(List holds, NodeRef nodeRef); - - /** - * Adds the given items to the given list of holds - * - * @param holds List of holds to which the given items will be added - * @param nodeRefs The list of items which will be added to the given holds - */ - void addToHolds(List holds, List nodeRefs); - - /** - * Removes the record from the given hold - * - * @param hold The {@link NodeRef} of the hold - * @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given hold - */ - void removeFromHold(NodeRef hold, NodeRef nodeRef); - - /** - * Removes the given items from the given hold - * - * @param hold The hold {@link NodeRef} from which the given items will be removed - * @param nodeRefs The list of items which will be removed from the given holds - */ - void removeFromHold(NodeRef hold, List nodeRefs); - - /** - * Removes the item from the given list of hold - * - * @param holds The list {@link NodeRef}s of the holds - * @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given holds - */ - void removeFromHolds(List holds, NodeRef nodeRef); - - /** - * Removes the items from the given holds - * - * @param holds List of hold {@link NodeRef}s from which the items will be removed - * @param nodeRefs List of item {@link NodeRef}s which will be removed from the given holds - */ - void removeFromHolds(List holds, List nodeRefs); - - /** - * Removes the given {@link NodeRef} from all the holds - * - * @param nodeRef The {@link NodeRef} of item which will be removed from all the holds - */ - void removeFromAllHolds(NodeRef nodeRef); - - /** - * Removes the given list of {@link NodeRef}s from all the holds - * - * @param nodeRefs The list of item {@link NodeRef}s which will be removed from all the holds - */ - void removeFromAllHolds(List nodeRefs); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.hold; + +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Hold service interface. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public interface HoldService +{ + /** + * Indicates whether the passed node reference is a hold. A hold is a container for a group of frozen object and contains the freeze + * reason. + * + * @param nodeRef hold node reference + * @return boolean true if hold, false otherwise + */ + boolean isHold(NodeRef nodeRef); + + /** + * Gets the list of all the holds within the holds container in the given file plan + * + * @param filePlan The {@link NodeRef} of the file plan + * @return List of hold node references + */ + List getHolds(NodeRef filePlan); + + /** + * Gets the node reference for the hold with the given name in the given file plan + * + * @param name {@link String} The name of the hold + * @return {@link NodeRef} of the hold with the given name + */ + NodeRef getHold(NodeRef filePlan, String name); + + /** + * Gets the list of all the holds within the holds container for the given node reference + * + * @param nodeRef The {@link NodeRef} of the record / record folder + * @param includedInHold true to retrieve the list of hold node references which will include the node reference + * false to get a list of node references which will not have the given node reference + * @return List of hold node references + */ + List heldBy(NodeRef nodeRef, boolean includedInHold); + + /** + * Gets the list of item node references which are in the given hold + * + * @param hold {@link NodeRef} of the hold + * @return Lost of item {@link NodeRef}s which are in the given hold + */ + List getHeld(NodeRef hold); + + /** + * Creates a hold with the given name, reason and description for the given file plan + * + * @param filePlan The {@link NodeRef} of the file plan + * @param name {@link String} The name of the hold + * @param reason {@link String} The reason of the hold + * @param description {@link String} The description of the hold + * @return The {@link NodeRef} of the created hold + */ + NodeRef createHold(NodeRef filePlan, String name, String reason, String description); + + /** + * Gets the hold reason for the given hold node reference + * + * @param hold The {@link NodeRef} of the hold + * @return {@link String} The reason of the hold + */ + String getHoldReason(NodeRef hold); + + /** + * Sets the hold reason + * + * @param hold The {@link NodeRef} of the hold + * @param reason {@link String} The reason for the hold + */ + void setHoldReason(NodeRef hold, String reason); + + /** + * Deletes the hold + * + * @param hold The {@link NodeRef} of the hold + */ + void deleteHold(NodeRef hold); + + /** + * Adds the record to the given hold + * + * @param hold The {@link NodeRef} of the hold + * @param nodeRef The {@link NodeRef} of the record / record folder which will be added to the given hold + */ + void addToHold(NodeRef hold, NodeRef nodeRef); + + /** + * Adds the items to the the given hold + * + * @param hold The {@link NodeRef} of the hold to which the items will be added + * @param nodeRefs The item {@link NodeRef}s which will be added to the hold + */ + void addToHold(NodeRef hold, List nodeRefs); + + /** + * Adds the record to the given list of holds + * + * @param holds The list of {@link NodeRef}s of the holds + * @param nodeRef The {@link NodeRef} of the record / record folder which will be added to the given holds + */ + void addToHolds(List holds, NodeRef nodeRef); + + /** + * Adds the given items to the given list of holds + * + * @param holds List of holds to which the given items will be added + * @param nodeRefs The list of items which will be added to the given holds + */ + void addToHolds(List holds, List nodeRefs); + + /** + * Removes the record from the given hold + * + * @param hold The {@link NodeRef} of the hold + * @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given hold + */ + void removeFromHold(NodeRef hold, NodeRef nodeRef); + + /** + * Removes the given items from the given hold + * + * @param hold The hold {@link NodeRef} from which the given items will be removed + * @param nodeRefs The list of items which will be removed from the given holds + */ + void removeFromHold(NodeRef hold, List nodeRefs); + + /** + * Removes the item from the given list of hold + * + * @param holds The list {@link NodeRef}s of the holds + * @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given holds + */ + void removeFromHolds(List holds, NodeRef nodeRef); + + /** + * Removes the items from the given holds + * + * @param holds List of hold {@link NodeRef}s from which the items will be removed + * @param nodeRefs List of item {@link NodeRef}s which will be removed from the given holds + */ + void removeFromHolds(List holds, List nodeRefs); + + /** + * Removes the given {@link NodeRef} from all the holds + * + * @param nodeRef The {@link NodeRef} of item which will be removed from all the holds + */ + void removeFromAllHolds(NodeRef nodeRef); + + /** + * Removes the given list of {@link NodeRef}s from all the holds + * + * @param nodeRefs The list of item {@link NodeRef}s which will be removed from all the holds + */ + void removeFromAllHolds(List nodeRefs); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java index 68f57529bd..4b0eb78b94 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java @@ -1,763 +1,763 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.hold; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.collections.ListUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Hold service implementation - * - * @author Tuna Aksoy - * @since 2.2 - */ -@BehaviourBean -public class HoldServiceImpl extends ServiceBaseImpl - implements HoldService, - NodeServicePolicies.BeforeDeleteNodePolicy, - RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(HoldServiceImpl.class); - - /** Audit event keys */ - private static final String AUDIT_ADD_TO_HOLD = "addToHold"; - private static final String AUDIT_REMOVE_FROM_HOLD = "removeFromHold"; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** Record Service */ - private RecordService recordService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** Permission service */ - private PermissionService permissionService; - - /** records management audit service */ - private RecordsManagementAuditService recordsManagementAuditService; - - /** - * Set the file plan service - * - * @param filePlanService the file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Set the node service - * - * @param nodeService the node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the record service - * - * @param recordService the record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * Set the record folder service - * - * @param recordFolderService the record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * Set the permission service - * - * @param permissionService the permission services - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param recordsManagementAuditService records management audit service - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) - { - this.recordsManagementAuditService = recordsManagementAuditService; - } - - /** - * Initialise hold service - */ - public void init() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - recordsManagementAuditService.registerAuditEvent(new AuditEvent(AUDIT_ADD_TO_HOLD, "capability.AddToHold.title")); - recordsManagementAuditService.registerAuditEvent(new AuditEvent(AUDIT_REMOVE_FROM_HOLD, "capability.RemoveFromHold.title")); - return null; - } - }); - } - - /** - * Behaviour unfreezes node's that will no longer he held after delete. - * - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Behaviour(kind=BehaviourKind.CLASS, type="rma:hold", notificationFrequency=NotificationFrequency.EVERY_EVENT) - @Override - public void beforeDeleteNode(final NodeRef hold) - { - if (nodeService.exists(hold) && isHold(hold)) - { - RunAsWork work = new RunAsWork() - { - @Override - public Void doWork() - { - List frozenNodes = getHeld(hold); - for (NodeRef frozenNode : frozenNodes) - { - removeFreezeAspect(frozenNode, 1); - } - - return null; - } - }; - - // run as system user - authenticationUtil.runAsSystem(work); - } - } - - /** - * Helper method removes the freeze aspect from the record and record folder if it is no longer - * in a hold. - * - * @param nodeRef - */ - private void removeFreezeAspect(NodeRef nodeRef, int index) - { - List otherHolds = heldBy(nodeRef, true); - if (otherHolds.size() == index) - { - if (nodeService.hasAspect(nodeRef, ASPECT_FROZEN)) - { - // remove the freeze aspect from the node - nodeService.removeAspect(nodeRef, ASPECT_FROZEN); - } - - if (isRecordFolder(nodeRef)) - { - List records = recordService.getRecords(nodeRef); - for (NodeRef record : records) - { - if (nodeService.hasAspect(record, ASPECT_FROZEN)) - { - List recordsOtherHolds = heldBy(record, true); - if (recordsOtherHolds.size() == index) - { - // remove the freeze aspect from the node - nodeService.removeAspect(record, ASPECT_FROZEN); - } - } - } - } - } - - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getHolds(NodeRef filePlan) - { - ParameterCheck.mandatory("filePlan", filePlan); - - List holds = new ArrayList(); - - // get the root hold container - NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); - - if (holdContainer != null) - { - // get the children of the root hold container - List holdsAssocs = nodeService.getChildAssocs(holdContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef holdAssoc : holdsAssocs) - { - NodeRef hold = holdAssoc.getChildRef(); - if (isHold(hold)) - { - // add to list of holds - holds.add(hold); - } - } - } - - return holds; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#heldBy(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @SuppressWarnings("unchecked") - @Override - public List heldBy(NodeRef nodeRef, boolean includedInHold) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - List result = null; - - // get all the immediate parent holds - Set holdsNotIncludingNodeRef = getParentHolds(nodeRef); - - // check whether the record is held by vitue of it's record folder - if (isRecord(nodeRef)) - { - List recordFolders = recordFolderService.getRecordFolders(nodeRef); - for (NodeRef recordFolder : recordFolders) - { - holdsNotIncludingNodeRef.addAll(getParentHolds(recordFolder)); - } - } - - if (!includedInHold) - { - // invert list to get list of holds that do not contain this node - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - List allHolds = getHolds(filePlan); - result = ListUtils.subtract(allHolds, new ArrayList(holdsNotIncludingNodeRef)); - } - else - { - result = new ArrayList(holdsNotIncludingNodeRef); - } - - return result; - } - - /** - * Helper method to get holds that are direct parents of the given node. - * - * @param nodeRef node reference - * @return Set<{@link NodeRef}> set of parent holds - */ - private Set getParentHolds(NodeRef nodeRef) - { - List holdsAssocs = nodeService.getParentAssocs(nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - Set holds = new HashSet(holdsAssocs.size()); - for (ChildAssociationRef holdAssoc : holdsAssocs) - { - holds.add(holdAssoc.getParentRef()); - } - - return holds; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHold(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public NodeRef getHold(NodeRef filePlan, String name) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("name", name); - - // get the root hold container - NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); - - // get the hold by name - NodeRef hold = nodeService.getChildByName(holdContainer, ContentModel.ASSOC_CONTAINS, name); - if (hold != null && !isHold(hold)) - { - throw new AlfrescoRuntimeException("Can not get hold, because the named node reference isn't a hold."); - } - - return hold; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHeld(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getHeld(NodeRef hold) - { - ParameterCheck.mandatory("hold", hold); - List children = new ArrayList(); - - if (!isHold(hold)) - { - throw new AlfrescoRuntimeException("Can't get the node's held, because passed node reference isn't a hold. (hold=" + hold.toString() + ")"); - } - - List childAssocs = nodeService.getChildAssocs(hold, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL); - if (childAssocs != null && !childAssocs.isEmpty()) - { - for (ChildAssociationRef childAssociationRef : childAssocs) - { - children.add(childAssociationRef.getChildRef()); - } - } - - return children; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#createHold(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public NodeRef createHold(NodeRef filePlan, String name, String reason, String description) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("reason", reason); - - // get the root hold container - NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); - - // create map of properties - Map properties = new HashMap(3); - properties.put(ContentModel.PROP_NAME, name); - properties.put(PROP_HOLD_REASON, reason); - if (description != null && !description.isEmpty()) - { - properties.put(ContentModel.PROP_DESCRIPTION, description); - } - - // create assoc name - QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name); - - // create hold - ChildAssociationRef childAssocRef = nodeService.createNode(holdContainer, ContentModel.ASSOC_CONTAINS, assocName, TYPE_HOLD, properties); - - return childAssocRef.getChildRef(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHoldReason(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String getHoldReason(NodeRef hold) - { - ParameterCheck.mandatory("hold", hold); - - String reason = null; - - if (nodeService.exists(hold) && isHold(hold)) - { - // get the reason - reason = (String)nodeService.getProperty(hold, PROP_HOLD_REASON); - } - - return reason; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#setHoldReason(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public void setHoldReason(NodeRef hold, String reason) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("reason", reason); - - if (nodeService.exists(hold) && isHold(hold)) - { - nodeService.setProperty(hold, PROP_HOLD_REASON, reason); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#deleteHold(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void deleteHold(final NodeRef hold) - { - ParameterCheck.mandatory("hold", hold); - - if (!isHold(hold)) - { - throw new AlfrescoRuntimeException("Can't delete hold, becuase passed node is not a hold. (hold=" + hold.toString() + ")"); - } - - List held = AuthenticationUtil.runAsSystem(new RunAsWork>() - { - @Override - public List doWork() - { - return getHeld(hold); - } - }); - - List heldNames = new ArrayList(); - for (NodeRef nodeRef : held) - { - try - { - if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.DENIED) - { - heldNames.add((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME)); - } - } - catch (AccessDeniedException ade) - { - throw new AlfrescoRuntimeException("Can't delete hold, because you don't have filling permissions on all the items held within the hold.", ade); - } - } - - if (heldNames.size() > 0) - { - StringBuilder sb = new StringBuilder(); - for (String name : heldNames) - { - sb.append("\n "); - sb.append("'"); - sb.append(name); - sb.append("'"); - } - throw new AlfrescoRuntimeException("Can't delete hold, because filing permissions for the following items are needed: " + sb.toString()); - } - - // delete the hold node - nodeService.deleteNode(hold); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHold(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void addToHold(NodeRef hold, NodeRef nodeRef) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("nodeRef", nodeRef); - - List holds = new ArrayList(1); - holds.add(hold); - addToHolds(Collections.unmodifiableList(holds), nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHold(org.alfresco.service.cmr.repository.NodeRef, java.util.List) - */ - @Override - public void addToHold(NodeRef hold, List nodeRefs) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - addToHold(hold, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void addToHolds(final List holds, final NodeRef nodeRef) - { - ParameterCheck.mandatoryCollection("holds", holds); - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (!isRecord(nodeRef) && !isRecordFolder(nodeRef)) - { - String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - throw new AlfrescoRuntimeException("'" + nodeName + "' is neither a record nor a record folder. Only records or record folders can be added to a hold."); - } - - if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.DENIED) - { - String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - throw new AlfrescoRuntimeException("Filing permission on '" + nodeName + "' is needed."); - } - - for (final NodeRef hold : holds) - { - if (!isHold(hold)) - { - String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME); - throw new AlfrescoRuntimeException("'" + holdName + "' is not a hold so record folders/records cannot be added."); - } - - if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.DENIED) - { - String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME); - throw new AlfrescoRuntimeException("'" + nodeName + "' can't be added to the hold container as filing permission for '" + holdName + "' is needed."); - } - - // check that the node isn't already in the hold - if (!getHeld(hold).contains(nodeRef)) - { - // run as system to ensure we have all the appropriate permissions to perform the manipulations we require - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // gather freeze properties - Map props = new HashMap(2); - props.put(PROP_FROZEN_AT, new Date()); - props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser()); - - if (!nodeService.hasAspect(nodeRef, ASPECT_FROZEN)) - { - // add freeze aspect - nodeService.addAspect(nodeRef, ASPECT_FROZEN, props); - - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Frozen aspect applied to '").append(nodeRef).append("'."); - logger.debug(msg.toString()); - } - } - - // Link the record to the hold - nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - - // audit item being added to the hold - recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD); - - // Mark all the folders contents as frozen - if (isRecordFolder(nodeRef)) - { - List records = recordService.getRecords(nodeRef); - for (NodeRef record : records) - { - // no need to freeze if already frozen! - if (!nodeService.hasAspect(record, ASPECT_FROZEN)) - { - nodeService.addAspect(record, ASPECT_FROZEN, props); - - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Frozen aspect applied to '").append(record).append("'."); - logger.debug(msg.toString()); - } - } - } - } - - return null; - } - }); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, java.util.List) - */ - @Override - public void addToHolds(List holds, List nodeRefs) - { - ParameterCheck.mandatoryCollection("holds", holds); - ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - addToHolds(holds, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHold(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void removeFromHold(NodeRef hold, NodeRef nodeRef) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("nodeRef", nodeRef); - - List holds = new ArrayList(1); - holds.add(hold); - removeFromHolds(Collections.unmodifiableList(holds), nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHold(org.alfresco.service.cmr.repository.NodeRef, java.util.List) - */ - @Override - public void removeFromHold(NodeRef hold, List nodeRefs) - { - ParameterCheck.mandatory("hold", hold); - ParameterCheck.mandatory("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - removeFromHold(hold, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHolds(java.util.List, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void removeFromHolds(List holds, final NodeRef nodeRef) - { - ParameterCheck.mandatory("holds", holds); - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (holds != null && !holds.isEmpty()) - { - for (final NodeRef hold : holds) - { - if (!instanceOf(hold, TYPE_HOLD)) - { - throw new AlfrescoRuntimeException("Can't remove from hold, because it isn't a hold. (hold=" + hold + ")"); - } - - if (getHeld(hold).contains(nodeRef)) - { - // run as system so we don't run into further permission issues - // we already know we have to have the correct capability to get here - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // remove from hold - nodeService.removeChild(hold, nodeRef); - - // audit that the node has been remove from the hold - // TODO add details of the hold that the node was removed from - recordsManagementAuditService.auditEvent(nodeRef, AUDIT_REMOVE_FROM_HOLD); - - return null; - } - }); - } - } - - // run as system as we can't be sure if have remove aspect rights on node - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - removeFreezeAspect(nodeRef, 0); - return null; - } - }); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHolds(java.util.List, java.util.List) - */ - @Override - public void removeFromHolds(List holds, List nodeRefs) - { - ParameterCheck.mandatoryCollection("holds", holds); - ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - removeFromHolds(holds, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromAllHolds(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void removeFromAllHolds(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // remove the node from all the holds it's held by - List holds = heldBy(nodeRef, true); - for (NodeRef hold : holds) - { - // remove node from hold - removeFromHold(hold, nodeRef); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromAllHolds(java.util.List) - */ - @Override - public void removeFromAllHolds(List nodeRefs) - { - ParameterCheck.mandatory("nodeRefs", nodeRefs); - - for (NodeRef nodeRef : nodeRefs) - { - removeFromAllHolds(nodeRef); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.hold; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.collections.ListUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Hold service implementation + * + * @author Tuna Aksoy + * @since 2.2 + */ +@BehaviourBean +public class HoldServiceImpl extends ServiceBaseImpl + implements HoldService, + NodeServicePolicies.BeforeDeleteNodePolicy, + RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(HoldServiceImpl.class); + + /** Audit event keys */ + private static final String AUDIT_ADD_TO_HOLD = "addToHold"; + private static final String AUDIT_REMOVE_FROM_HOLD = "removeFromHold"; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** Record Service */ + private RecordService recordService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Permission service */ + private PermissionService permissionService; + + /** records management audit service */ + private RecordsManagementAuditService recordsManagementAuditService; + + /** + * Set the file plan service + * + * @param filePlanService the file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Set the node service + * + * @param nodeService the node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set the record service + * + * @param recordService the record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * Set the record folder service + * + * @param recordFolderService the record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * Set the permission service + * + * @param permissionService the permission services + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param recordsManagementAuditService records management audit service + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService) + { + this.recordsManagementAuditService = recordsManagementAuditService; + } + + /** + * Initialise hold service + */ + public void init() + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + recordsManagementAuditService.registerAuditEvent(new AuditEvent(AUDIT_ADD_TO_HOLD, "capability.AddToHold.title")); + recordsManagementAuditService.registerAuditEvent(new AuditEvent(AUDIT_REMOVE_FROM_HOLD, "capability.RemoveFromHold.title")); + return null; + } + }); + } + + /** + * Behaviour unfreezes node's that will no longer he held after delete. + * + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Behaviour(kind=BehaviourKind.CLASS, type="rma:hold", notificationFrequency=NotificationFrequency.EVERY_EVENT) + @Override + public void beforeDeleteNode(final NodeRef hold) + { + if (nodeService.exists(hold) && isHold(hold)) + { + RunAsWork work = new RunAsWork() + { + @Override + public Void doWork() + { + List frozenNodes = getHeld(hold); + for (NodeRef frozenNode : frozenNodes) + { + removeFreezeAspect(frozenNode, 1); + } + + return null; + } + }; + + // run as system user + authenticationUtil.runAsSystem(work); + } + } + + /** + * Helper method removes the freeze aspect from the record and record folder if it is no longer + * in a hold. + * + * @param nodeRef + */ + private void removeFreezeAspect(NodeRef nodeRef, int index) + { + List otherHolds = heldBy(nodeRef, true); + if (otherHolds.size() == index) + { + if (nodeService.hasAspect(nodeRef, ASPECT_FROZEN)) + { + // remove the freeze aspect from the node + nodeService.removeAspect(nodeRef, ASPECT_FROZEN); + } + + if (isRecordFolder(nodeRef)) + { + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + if (nodeService.hasAspect(record, ASPECT_FROZEN)) + { + List recordsOtherHolds = heldBy(record, true); + if (recordsOtherHolds.size() == index) + { + // remove the freeze aspect from the node + nodeService.removeAspect(record, ASPECT_FROZEN); + } + } + } + } + } + + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getHolds(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + + List holds = new ArrayList(); + + // get the root hold container + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + + if (holdContainer != null) + { + // get the children of the root hold container + List holdsAssocs = nodeService.getChildAssocs(holdContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef holdAssoc : holdsAssocs) + { + NodeRef hold = holdAssoc.getChildRef(); + if (isHold(hold)) + { + // add to list of holds + holds.add(hold); + } + } + } + + return holds; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#heldBy(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @SuppressWarnings("unchecked") + @Override + public List heldBy(NodeRef nodeRef, boolean includedInHold) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + List result = null; + + // get all the immediate parent holds + Set holdsNotIncludingNodeRef = getParentHolds(nodeRef); + + // check whether the record is held by vitue of it's record folder + if (isRecord(nodeRef)) + { + List recordFolders = recordFolderService.getRecordFolders(nodeRef); + for (NodeRef recordFolder : recordFolders) + { + holdsNotIncludingNodeRef.addAll(getParentHolds(recordFolder)); + } + } + + if (!includedInHold) + { + // invert list to get list of holds that do not contain this node + NodeRef filePlan = filePlanService.getFilePlan(nodeRef); + List allHolds = getHolds(filePlan); + result = ListUtils.subtract(allHolds, new ArrayList(holdsNotIncludingNodeRef)); + } + else + { + result = new ArrayList(holdsNotIncludingNodeRef); + } + + return result; + } + + /** + * Helper method to get holds that are direct parents of the given node. + * + * @param nodeRef node reference + * @return Set<{@link NodeRef}> set of parent holds + */ + private Set getParentHolds(NodeRef nodeRef) + { + List holdsAssocs = nodeService.getParentAssocs(nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + Set holds = new HashSet(holdsAssocs.size()); + for (ChildAssociationRef holdAssoc : holdsAssocs) + { + holds.add(holdAssoc.getParentRef()); + } + + return holds; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHold(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public NodeRef getHold(NodeRef filePlan, String name) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("name", name); + + // get the root hold container + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + + // get the hold by name + NodeRef hold = nodeService.getChildByName(holdContainer, ContentModel.ASSOC_CONTAINS, name); + if (hold != null && !isHold(hold)) + { + throw new AlfrescoRuntimeException("Can not get hold, because the named node reference isn't a hold."); + } + + return hold; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHeld(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getHeld(NodeRef hold) + { + ParameterCheck.mandatory("hold", hold); + List children = new ArrayList(); + + if (!isHold(hold)) + { + throw new AlfrescoRuntimeException("Can't get the node's held, because passed node reference isn't a hold. (hold=" + hold.toString() + ")"); + } + + List childAssocs = nodeService.getChildAssocs(hold, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL); + if (childAssocs != null && !childAssocs.isEmpty()) + { + for (ChildAssociationRef childAssociationRef : childAssocs) + { + children.add(childAssociationRef.getChildRef()); + } + } + + return children; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#createHold(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public NodeRef createHold(NodeRef filePlan, String name, String reason, String description) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("reason", reason); + + // get the root hold container + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + + // create map of properties + Map properties = new HashMap(3); + properties.put(ContentModel.PROP_NAME, name); + properties.put(PROP_HOLD_REASON, reason); + if (description != null && !description.isEmpty()) + { + properties.put(ContentModel.PROP_DESCRIPTION, description); + } + + // create assoc name + QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name); + + // create hold + ChildAssociationRef childAssocRef = nodeService.createNode(holdContainer, ContentModel.ASSOC_CONTAINS, assocName, TYPE_HOLD, properties); + + return childAssocRef.getChildRef(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#getHoldReason(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String getHoldReason(NodeRef hold) + { + ParameterCheck.mandatory("hold", hold); + + String reason = null; + + if (nodeService.exists(hold) && isHold(hold)) + { + // get the reason + reason = (String)nodeService.getProperty(hold, PROP_HOLD_REASON); + } + + return reason; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#setHoldReason(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public void setHoldReason(NodeRef hold, String reason) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("reason", reason); + + if (nodeService.exists(hold) && isHold(hold)) + { + nodeService.setProperty(hold, PROP_HOLD_REASON, reason); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#deleteHold(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void deleteHold(final NodeRef hold) + { + ParameterCheck.mandatory("hold", hold); + + if (!isHold(hold)) + { + throw new AlfrescoRuntimeException("Can't delete hold, becuase passed node is not a hold. (hold=" + hold.toString() + ")"); + } + + List held = AuthenticationUtil.runAsSystem(new RunAsWork>() + { + @Override + public List doWork() + { + return getHeld(hold); + } + }); + + List heldNames = new ArrayList(); + for (NodeRef nodeRef : held) + { + try + { + if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.DENIED) + { + heldNames.add((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME)); + } + } + catch (AccessDeniedException ade) + { + throw new AlfrescoRuntimeException("Can't delete hold, because you don't have filling permissions on all the items held within the hold.", ade); + } + } + + if (heldNames.size() > 0) + { + StringBuilder sb = new StringBuilder(); + for (String name : heldNames) + { + sb.append("\n "); + sb.append("'"); + sb.append(name); + sb.append("'"); + } + throw new AlfrescoRuntimeException("Can't delete hold, because filing permissions for the following items are needed: " + sb.toString()); + } + + // delete the hold node + nodeService.deleteNode(hold); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHold(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void addToHold(NodeRef hold, NodeRef nodeRef) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("nodeRef", nodeRef); + + List holds = new ArrayList(1); + holds.add(hold); + addToHolds(Collections.unmodifiableList(holds), nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHold(org.alfresco.service.cmr.repository.NodeRef, java.util.List) + */ + @Override + public void addToHold(NodeRef hold, List nodeRefs) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + addToHold(hold, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void addToHolds(final List holds, final NodeRef nodeRef) + { + ParameterCheck.mandatoryCollection("holds", holds); + ParameterCheck.mandatory("nodeRef", nodeRef); + + if (!isRecord(nodeRef) && !isRecordFolder(nodeRef)) + { + String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + throw new AlfrescoRuntimeException("'" + nodeName + "' is neither a record nor a record folder. Only records or record folders can be added to a hold."); + } + + if (permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.DENIED) + { + String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + throw new AlfrescoRuntimeException("Filing permission on '" + nodeName + "' is needed."); + } + + for (final NodeRef hold : holds) + { + if (!isHold(hold)) + { + String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME); + throw new AlfrescoRuntimeException("'" + holdName + "' is not a hold so record folders/records cannot be added."); + } + + if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.DENIED) + { + String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME); + throw new AlfrescoRuntimeException("'" + nodeName + "' can't be added to the hold container as filing permission for '" + holdName + "' is needed."); + } + + // check that the node isn't already in the hold + if (!getHeld(hold).contains(nodeRef)) + { + // run as system to ensure we have all the appropriate permissions to perform the manipulations we require + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // gather freeze properties + Map props = new HashMap(2); + props.put(PROP_FROZEN_AT, new Date()); + props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser()); + + if (!nodeService.hasAspect(nodeRef, ASPECT_FROZEN)) + { + // add freeze aspect + nodeService.addAspect(nodeRef, ASPECT_FROZEN, props); + + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Frozen aspect applied to '").append(nodeRef).append("'."); + logger.debug(msg.toString()); + } + } + + // Link the record to the hold + nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + + // audit item being added to the hold + recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD); + + // Mark all the folders contents as frozen + if (isRecordFolder(nodeRef)) + { + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + // no need to freeze if already frozen! + if (!nodeService.hasAspect(record, ASPECT_FROZEN)) + { + nodeService.addAspect(record, ASPECT_FROZEN, props); + + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Frozen aspect applied to '").append(record).append("'."); + logger.debug(msg.toString()); + } + } + } + } + + return null; + } + }); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, java.util.List) + */ + @Override + public void addToHolds(List holds, List nodeRefs) + { + ParameterCheck.mandatoryCollection("holds", holds); + ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + addToHolds(holds, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHold(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void removeFromHold(NodeRef hold, NodeRef nodeRef) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("nodeRef", nodeRef); + + List holds = new ArrayList(1); + holds.add(hold); + removeFromHolds(Collections.unmodifiableList(holds), nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHold(org.alfresco.service.cmr.repository.NodeRef, java.util.List) + */ + @Override + public void removeFromHold(NodeRef hold, List nodeRefs) + { + ParameterCheck.mandatory("hold", hold); + ParameterCheck.mandatory("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + removeFromHold(hold, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHolds(java.util.List, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void removeFromHolds(List holds, final NodeRef nodeRef) + { + ParameterCheck.mandatory("holds", holds); + ParameterCheck.mandatory("nodeRef", nodeRef); + + if (holds != null && !holds.isEmpty()) + { + for (final NodeRef hold : holds) + { + if (!instanceOf(hold, TYPE_HOLD)) + { + throw new AlfrescoRuntimeException("Can't remove from hold, because it isn't a hold. (hold=" + hold + ")"); + } + + if (getHeld(hold).contains(nodeRef)) + { + // run as system so we don't run into further permission issues + // we already know we have to have the correct capability to get here + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // remove from hold + nodeService.removeChild(hold, nodeRef); + + // audit that the node has been remove from the hold + // TODO add details of the hold that the node was removed from + recordsManagementAuditService.auditEvent(nodeRef, AUDIT_REMOVE_FROM_HOLD); + + return null; + } + }); + } + } + + // run as system as we can't be sure if have remove aspect rights on node + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + removeFreezeAspect(nodeRef, 0); + return null; + } + }); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHolds(java.util.List, java.util.List) + */ + @Override + public void removeFromHolds(List holds, List nodeRefs) + { + ParameterCheck.mandatoryCollection("holds", holds); + ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + removeFromHolds(holds, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromAllHolds(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void removeFromAllHolds(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // remove the node from all the holds it's held by + List holds = heldBy(nodeRef, true); + for (NodeRef hold : holds) + { + // remove node from hold + removeFromHold(hold, nodeRef); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromAllHolds(java.util.List) + */ + @Override + public void removeFromAllHolds(List nodeRefs) + { + ParameterCheck.mandatory("nodeRefs", nodeRefs); + + for (NodeRef nodeRef : nodeRefs) + { + removeFromAllHolds(nodeRef); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/BasicIdentifierGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/BasicIdentifierGenerator.java index 5627b7d95d..4aa0a1e898 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/BasicIdentifierGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/BasicIdentifierGenerator.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.identifier; - -import java.io.Serializable; -import java.util.Calendar; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Basic identifier generator implementation. - * - * @author Roy Wetherall - */ -public class BasicIdentifierGenerator extends IdentifierGeneratorBase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator#generateId(java.util.Map) - */ - @Override - public String generateId(Map context) - { - NodeRef nodeRef = (NodeRef)context.get(IdentifierService.CONTEXT_NODEREF); - Long dbId = 0l; - if (nodeRef != null) - { - dbId = (Long)nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID); - } - else - { - dbId = System.currentTimeMillis(); - } - - Calendar fileCalendar = Calendar.getInstance(); - String year = Integer.toString(fileCalendar.get(Calendar.YEAR)); - return year + "-" + padString(dbId.toString(), 10); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.identifier; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Basic identifier generator implementation. + * + * @author Roy Wetherall + */ +public class BasicIdentifierGenerator extends IdentifierGeneratorBase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator#generateId(java.util.Map) + */ + @Override + public String generateId(Map context) + { + NodeRef nodeRef = (NodeRef)context.get(IdentifierService.CONTEXT_NODEREF); + Long dbId = 0l; + if (nodeRef != null) + { + dbId = (Long)nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID); + } + else + { + dbId = System.currentTimeMillis(); + } + + Calendar fileCalendar = Calendar.getInstance(); + String year = Integer.toString(fileCalendar.get(Calendar.YEAR)); + return year + "-" + padString(dbId.toString(), 10); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGenerator.java index c360f38394..dab34e828f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGenerator.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.identifier; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.namespace.QName; - -/** - * Generates an identifier for a content type from a given context. - * - * @author Roy Wetherall - */ -public interface IdentifierGenerator -{ - /** - * The content type this generator is applicible to. - * @return QName the type - */ - QName getType(); - - /** - * Generates the next id based on the provided context. - * @param context map of context values - * @return String the next id - */ - String generateId(Map context); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.identifier; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.service.namespace.QName; + +/** + * Generates an identifier for a content type from a given context. + * + * @author Roy Wetherall + */ +public interface IdentifierGenerator +{ + /** + * The content type this generator is applicible to. + * @return QName the type + */ + QName getType(); + + /** + * Generates the next id based on the provided context. + * @param context map of context values + * @return String the next id + */ + String generateId(Map context); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGeneratorBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGeneratorBase.java index 37d686a809..5e2cc684d3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGeneratorBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierGeneratorBase.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.identifier; - -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - */ -public abstract class IdentifierGeneratorBase implements IdentifierGenerator -{ - /** Identifier service */ - private IdentifierService identifierService; - - /** Node service */ - protected NodeService nodeService; - - /** Content type */ - private QName type; - - /** - * Initialisation method - */ - public void init() - { - identifierService.register(this); - } - - /** - * Set identifier service. - * - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /** - * Set the node service - * - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set type. - * - * @param type content type - */ - public void setTypeAsString(String type) - { - this.type = QName.createQName(type); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator#getType() - */ - @Override - public QName getType() - { - return type; - } - - /** - * Function to pad a string with zero '0' characters to the required length - * - * @param s String to pad with leading zero '0' characters - * @param len Length to pad to - * @return padded string or the original if already at >=len characters - */ - protected String padString(String s, int len) - { - String result = s; - - for (int i = 0; i < (len - s.length()); i++) - { - result = "0" + result; - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.identifier; + +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + */ +public abstract class IdentifierGeneratorBase implements IdentifierGenerator +{ + /** Identifier service */ + private IdentifierService identifierService; + + /** Node service */ + protected NodeService nodeService; + + /** Content type */ + private QName type; + + /** + * Initialisation method + */ + public void init() + { + identifierService.register(this); + } + + /** + * Set identifier service. + * + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /** + * Set the node service + * + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set type. + * + * @param type content type + */ + public void setTypeAsString(String type) + { + this.type = QName.createQName(type); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator#getType() + */ + @Override + public QName getType() + { + return type; + } + + /** + * Function to pad a string with zero '0' characters to the required length + * + * @param s String to pad with leading zero '0' characters + * @param len Length to pad to + * @return padded string or the original if already at >=len characters + */ + protected String padString(String s, int len) + { + String result = s; + + for (int i = 0; i < (len - s.length()); i++) + { + result = "0" + result; + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierService.java index f97e3a46a0..d775a8093c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierService.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.identifier; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Records management identifier service - * - * @author Roy Wetherall - */ -public interface IdentifierService -{ - /** Context value names */ - String CONTEXT_NODEREF = "noderef"; - String CONTEXT_PARENT_NODEREF = "parentndoeref"; - String CONTEXT_ORIG_TYPE = "origionaltype"; - - /** - * Register an identifier generator implementation with the service. - * - * @param identifierGenerator identifier generator implementation - */ - void register(IdentifierGenerator identifierGenerator); - - /** - * Generate an identifier for a node with the given type and parent. - * - * @param type type of the node - * @param parent parent of the ndoe - * @return String generated identifier - */ - String generateIdentifier(QName type, NodeRef parent); - - /** - * Generate an identifier for the given node. - * - * @param nodeRef node reference - * @return String generated identifier - */ - String generateIdentifier(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.identifier; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Records management identifier service + * + * @author Roy Wetherall + */ +public interface IdentifierService +{ + /** Context value names */ + String CONTEXT_NODEREF = "noderef"; + String CONTEXT_PARENT_NODEREF = "parentndoeref"; + String CONTEXT_ORIG_TYPE = "origionaltype"; + + /** + * Register an identifier generator implementation with the service. + * + * @param identifierGenerator identifier generator implementation + */ + void register(IdentifierGenerator identifierGenerator); + + /** + * Generate an identifier for a node with the given type and parent. + * + * @param type type of the node + * @param parent parent of the ndoe + * @return String generated identifier + */ + String generateIdentifier(QName type, NodeRef parent); + + /** + * Generate an identifier for the given node. + * + * @param nodeRef node reference + * @return String generated identifier + */ + String generateIdentifier(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierServiceImpl.java index 2c95030460..82080b8a8b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/identifier/IdentifierServiceImpl.java @@ -1,196 +1,196 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.identifier; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Roy Wetherall - */ -public class IdentifierServiceImpl implements IdentifierService -{ - /** Logger */ - private static Log logger = LogFactory.getLog(IdentifierServiceImpl.class); - - /** Registry map */ - private Map register = new HashMap(5); - - /** Node service */ - private NodeService nodeService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** - * Set the node service - * - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the dictionary service - * - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#generateIdentifier(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String generateIdentifier(QName type, NodeRef parent) - { - ParameterCheck.mandatory("type", type); - - // Build the context - Map context = new HashMap(2); - if (parent != null) - { - context.put(CONTEXT_PARENT_NODEREF, parent); - } - context.put(CONTEXT_ORIG_TYPE, type); - - // Generate the id - return generateIdentifier(type, context); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#generateIdentifier(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String generateIdentifier(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - Map context = new HashMap(3); - - // Set the original type - QName type = nodeService.getType(nodeRef); - context.put(CONTEXT_ORIG_TYPE, type); - - // Set the parent reference - ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); - if (assocRef != null && assocRef.getParentRef() != null) - { - context.put(CONTEXT_PARENT_NODEREF, assocRef.getParentRef()); - } - - // Set the node reference - context.put(CONTEXT_NODEREF, nodeRef); - - // Generate the identifier - return generateIdentifier(type, context); - - } - - /** - * Generate an identifier for a given type of object with the accompanying context. - * - * @param type content type - * @param context context - * @return String identifier - */ - private String generateIdentifier(QName type, Map context) - { - ParameterCheck.mandatory("type", type); - ParameterCheck.mandatory("context", context); - - // Get the identifier generator - IdentifierGenerator idGen = lookupGenerator(type); - if (idGen == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Unable to generate id for object of type " + type.toString() + ", because no identifier generator was found."); - } - throw new AlfrescoRuntimeException("Unable to generate id for object of type " + type.toString() + ", because no identifier generator was found."); - } - - // Generate the identifier - return idGen.generateId(context); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#register(org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator) - */ - public void register(IdentifierGenerator idGen) - { - register.put(idGen.getType(), idGen); - } - - /** - * - * @param type content type (could be aspect or type) - * @return - */ - private IdentifierGenerator lookupGenerator(QName type) - { - ParameterCheck.mandatory("type", type); - - if (logger.isDebugEnabled()) - { - logger.debug("Looking for idGenerator for type " + type.toString()); - } - - // Look for the generator related to the type - IdentifierGenerator result = register.get(type); - if (result == null) - { - // Check the parent type - ClassDefinition typeDef = dictionaryService.getClass(type); - if (typeDef != null) - { - QName parentType = typeDef.getParentName(); - if (parentType != null) - { - // Recurse to find parent type generator - result = lookupGenerator(parentType); - } - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("Unable to find type definition for " + type.toString() + " when generating identifier."); - } - } - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.identifier; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.dictionary.ClassDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author Roy Wetherall + */ +public class IdentifierServiceImpl implements IdentifierService +{ + /** Logger */ + private static Log logger = LogFactory.getLog(IdentifierServiceImpl.class); + + /** Registry map */ + private Map register = new HashMap(5); + + /** Node service */ + private NodeService nodeService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** + * Set the node service + * + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set the dictionary service + * + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#generateIdentifier(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String generateIdentifier(QName type, NodeRef parent) + { + ParameterCheck.mandatory("type", type); + + // Build the context + Map context = new HashMap(2); + if (parent != null) + { + context.put(CONTEXT_PARENT_NODEREF, parent); + } + context.put(CONTEXT_ORIG_TYPE, type); + + // Generate the id + return generateIdentifier(type, context); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#generateIdentifier(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String generateIdentifier(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + Map context = new HashMap(3); + + // Set the original type + QName type = nodeService.getType(nodeRef); + context.put(CONTEXT_ORIG_TYPE, type); + + // Set the parent reference + ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); + if (assocRef != null && assocRef.getParentRef() != null) + { + context.put(CONTEXT_PARENT_NODEREF, assocRef.getParentRef()); + } + + // Set the node reference + context.put(CONTEXT_NODEREF, nodeRef); + + // Generate the identifier + return generateIdentifier(type, context); + + } + + /** + * Generate an identifier for a given type of object with the accompanying context. + * + * @param type content type + * @param context context + * @return String identifier + */ + private String generateIdentifier(QName type, Map context) + { + ParameterCheck.mandatory("type", type); + ParameterCheck.mandatory("context", context); + + // Get the identifier generator + IdentifierGenerator idGen = lookupGenerator(type); + if (idGen == null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Unable to generate id for object of type " + type.toString() + ", because no identifier generator was found."); + } + throw new AlfrescoRuntimeException("Unable to generate id for object of type " + type.toString() + ", because no identifier generator was found."); + } + + // Generate the identifier + return idGen.generateId(context); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService#register(org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierGenerator) + */ + public void register(IdentifierGenerator idGen) + { + register.put(idGen.getType(), idGen); + } + + /** + * + * @param type content type (could be aspect or type) + * @return + */ + private IdentifierGenerator lookupGenerator(QName type) + { + ParameterCheck.mandatory("type", type); + + if (logger.isDebugEnabled()) + { + logger.debug("Looking for idGenerator for type " + type.toString()); + } + + // Look for the generator related to the type + IdentifierGenerator result = register.get(type); + if (result == null) + { + // Check the parent type + ClassDefinition typeDef = dictionaryService.getClass(type); + if (typeDef != null) + { + QName parentType = typeDef.getParentName(); + if (parentType != null) + { + // Recurse to find parent type generator + result = lookupGenerator(parentType); + } + } + else + { + if (logger.isDebugEnabled()) + { + logger.debug("Unable to find type definition for " + type.toString() + " when generating identifier."); + } + } + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java index 665c95910b..9bb24cd993 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java @@ -1,231 +1,231 @@ -/* - * Copyright (C) 2009-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.job; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * The Disposition Lifecycle Job Finds all disposition action nodes which are - * for disposition actions specified Where asOf > now OR - * dispositionEventsEligible = true; - * - * Runs the cut off or retain action for - * eligible records. - * - * @author mrogers - * @author Roy Wetherall - */ -public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecuter -{ - /** logger */ - private static Log logger = LogFactory.getLog(DispositionLifecycleJobExecuter.class); - - /** list of disposition actions to automatically execute */ - private List dispositionActions; - - /** query string */ - private String query; - - /** records management action service */ - private RecordsManagementActionService recordsManagementActionService; - - /** node service */ - private NodeService nodeService; - - /** search service */ - private SearchService searchService; - - /** - * List of disposition actions to automatically execute when eligible. - * - * @param dispositionActions disposition actions - */ - public void setDispositionActions(List dispositionActions) - { - this.dispositionActions = dispositionActions; - } - - /** - * @param recordsManagementActionService records management action service - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param searchService search service - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * Get the search query string. - * - * @return job query string - */ - protected String getQuery() - { - if (query == null) - { - StringBuilder sb = new StringBuilder(); - - sb.append("TYPE:\"rma:dispositionAction\" + "); - sb.append("(@rma\\:dispositionAction:("); - - boolean bFirst = true; - for (String dispositionAction : dispositionActions) - { - if (bFirst) - { - bFirst = false; - } - else - { - sb.append(" OR "); - } - - sb.append("\"").append(dispositionAction).append("\""); - } - - sb.append("))"); - sb.append(" AND ISUNSET:\"rma:dispositionActionCompletedAt\" "); - sb.append(" AND ( "); - sb.append("@rma\\:dispositionEventsEligible:true "); - sb.append("OR @rma\\:dispositionAsOf:[MIN TO NOW] "); - sb.append(") "); - - query = sb.toString(); - } - - return query; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#execute() - */ - public void executeImpl() - { - try - { - logger.debug("Job Starting"); - - if (dispositionActions != null && !dispositionActions.isEmpty()) - { - // execute search - ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, getQuery()); - List resultNodes = results.getNodeRefs(); - results.close(); - - if (logger.isDebugEnabled()) - { - logger.debug("Processing " + resultNodes.size() + " nodes"); - } - - // process search results - for (NodeRef node : resultNodes) - { - final NodeRef currentNode = node; - - RetryingTransactionCallback processTranCB = new RetryingTransactionCallback() - { - public Boolean execute() - { - final String dispAction = (String) nodeService.getProperty(currentNode, RecordsManagementModel.PROP_DISPOSITION_ACTION); - - // Run disposition action - if (dispAction != null && dispositionActions.contains(dispAction)) - { - ChildAssociationRef parent = nodeService.getPrimaryParent(currentNode); - if (parent.getTypeQName().equals(RecordsManagementModel.ASSOC_NEXT_DISPOSITION_ACTION)) - { - Map props = new HashMap(1); - props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE); - - try - { - // execute disposition action - recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction, props); - - if (logger.isDebugEnabled()) - { - logger.debug("Processed action: " + dispAction + "on" + parent); - } - } - catch (AlfrescoRuntimeException exception) - { - if (logger.isDebugEnabled()) - { - logger.debug(exception); - } - } - } - } - - return Boolean.TRUE; - } - }; - - // if exists - if (nodeService.exists(currentNode)) - { - retryingTransactionHelper.doInTransaction(processTranCB); - } - } - } - - logger.debug("Job Finished"); - } - catch (AlfrescoRuntimeException exception) - { - if (logger.isDebugEnabled()) - { - logger.debug(exception); - } - } - } -} +/* + * Copyright (C) 2009-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.job; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The Disposition Lifecycle Job Finds all disposition action nodes which are + * for disposition actions specified Where asOf > now OR + * dispositionEventsEligible = true; + * + * Runs the cut off or retain action for + * eligible records. + * + * @author mrogers + * @author Roy Wetherall + */ +public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecuter +{ + /** logger */ + private static Log logger = LogFactory.getLog(DispositionLifecycleJobExecuter.class); + + /** list of disposition actions to automatically execute */ + private List dispositionActions; + + /** query string */ + private String query; + + /** records management action service */ + private RecordsManagementActionService recordsManagementActionService; + + /** node service */ + private NodeService nodeService; + + /** search service */ + private SearchService searchService; + + /** + * List of disposition actions to automatically execute when eligible. + * + * @param dispositionActions disposition actions + */ + public void setDispositionActions(List dispositionActions) + { + this.dispositionActions = dispositionActions; + } + + /** + * @param recordsManagementActionService records management action service + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param searchService search service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * Get the search query string. + * + * @return job query string + */ + protected String getQuery() + { + if (query == null) + { + StringBuilder sb = new StringBuilder(); + + sb.append("TYPE:\"rma:dispositionAction\" + "); + sb.append("(@rma\\:dispositionAction:("); + + boolean bFirst = true; + for (String dispositionAction : dispositionActions) + { + if (bFirst) + { + bFirst = false; + } + else + { + sb.append(" OR "); + } + + sb.append("\"").append(dispositionAction).append("\""); + } + + sb.append("))"); + sb.append(" AND ISUNSET:\"rma:dispositionActionCompletedAt\" "); + sb.append(" AND ( "); + sb.append("@rma\\:dispositionEventsEligible:true "); + sb.append("OR @rma\\:dispositionAsOf:[MIN TO NOW] "); + sb.append(") "); + + query = sb.toString(); + } + + return query; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#execute() + */ + public void executeImpl() + { + try + { + logger.debug("Job Starting"); + + if (dispositionActions != null && !dispositionActions.isEmpty()) + { + // execute search + ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, getQuery()); + List resultNodes = results.getNodeRefs(); + results.close(); + + if (logger.isDebugEnabled()) + { + logger.debug("Processing " + resultNodes.size() + " nodes"); + } + + // process search results + for (NodeRef node : resultNodes) + { + final NodeRef currentNode = node; + + RetryingTransactionCallback processTranCB = new RetryingTransactionCallback() + { + public Boolean execute() + { + final String dispAction = (String) nodeService.getProperty(currentNode, RecordsManagementModel.PROP_DISPOSITION_ACTION); + + // Run disposition action + if (dispAction != null && dispositionActions.contains(dispAction)) + { + ChildAssociationRef parent = nodeService.getPrimaryParent(currentNode); + if (parent.getTypeQName().equals(RecordsManagementModel.ASSOC_NEXT_DISPOSITION_ACTION)) + { + Map props = new HashMap(1); + props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE); + + try + { + // execute disposition action + recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction, props); + + if (logger.isDebugEnabled()) + { + logger.debug("Processed action: " + dispAction + "on" + parent); + } + } + catch (AlfrescoRuntimeException exception) + { + if (logger.isDebugEnabled()) + { + logger.debug(exception); + } + } + } + } + + return Boolean.TRUE; + } + }; + + // if exists + if (nodeService.exists(currentNode)) + { + retryingTransactionHelper.doInTransaction(processTranCB); + } + } + } + + logger.debug("Job Finished"); + } + catch (AlfrescoRuntimeException exception) + { + if (logger.isDebugEnabled()) + { + logger.debug(exception); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java index 61bf37c158..0838a31372 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2009-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 + * Copyright (C) 2009-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 . */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/PublishUpdatesJobExecuter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/PublishUpdatesJobExecuter.java index ff5a985dad..8d14cc3780 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/PublishUpdatesJobExecuter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/PublishUpdatesJobExecuter.java @@ -1,408 +1,408 @@ -/* - * Copyright (C) 2009-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.job; - -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor; -import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.QueryConsistency; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.cmr.search.SearchService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Job to publish any pending updates on marked node references. - * - * @author Roy Wetherall - */ -public class PublishUpdatesJobExecuter extends RecordsManagementJobExecuter -{ - /** Logger */ - private static Log logger = LogFactory.getLog(PublishUpdatesJobExecuter.class); - - /** Node service */ - private NodeService nodeService; - - /** Search service */ - private SearchService searchService; - - /** Publish executor register */ - private PublishExecutorRegistry publishExecutorRegistry; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Behaviour filter */ - private BehaviourFilter behaviourFilter; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param searchService search service - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param publishExecutorRegistry public executor registry - */ - public void setPublishExecutorRegistry(PublishExecutorRegistry publishExecutorRegistry) - { - this.publishExecutorRegistry = publishExecutorRegistry; - } - - /** - * @param behaviourFilter behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#executeImpl() - */ - public void executeImpl() - { - if (logger.isDebugEnabled()) - { - logger.debug("Job Starting"); - } - - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - if (rmLoaded()) - { - // Get a list of the nodes that have updates that need to be published - List nodeRefs = getUpdatedNodes(); - - // Deal with each updated disposition action in turn - for (NodeRef nodeRef : nodeRefs) - { - if (nodeService.exists(nodeRef)) - { - boolean publishing = ((Boolean)nodeService.getProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS)).booleanValue(); - if (!publishing) - { - // Mark the update node as publishing in progress - markPublishInProgress(nodeRef); - try - { - Date start = new Date(); - if (logger.isDebugEnabled()) - { - logger.debug("Starting publish of updates ..."); - logger.debug(" - for " + nodeRef.toString()); - logger.debug(" - at " + start.toString()); - } - - // Publish updates - publishUpdates(nodeRef); - - - if (logger.isDebugEnabled()) - { - Date end = new Date(); - long duration = end.getTime() - start.getTime(); - logger.debug("Completed publish of updates ..."); - logger.debug(" - for " + nodeRef.toString()); - logger.debug(" - at " + end.toString()); - logger.debug(" - duration " + Long.toString(duration)); - } - } - finally - { - // Ensure the update node has either completed the publish or is marked as no longer in progress - unmarkPublishInProgress(nodeRef); - } - } - } - } - } - return null; - }; - }, AuthenticationUtil.getSystemUserName()); - - if (logger.isDebugEnabled()) - { - logger.debug("Job Finished"); - } - } - - /** - * Helper method to determine whether the RM content model has been loaded yet. - * - * @return boolean true if RM content model loaded, false otherwise - */ - private boolean rmLoaded() - { - boolean result = false; - - // ensure that the rm content model has been loaded - if (dictionaryService != null && - dictionaryService.getAspect(ASPECT_UNPUBLISHED_UPDATE) != null) - { - result = true; - } - - return result; - } - - /** - * Get a list of the nodes with updates pending publish - * @return List list of node refences with updates pending publication - */ - private List getUpdatedNodes() - { - RetryingTransactionCallback> execution = - new RetryingTransactionHelper.RetryingTransactionCallback>() - { - @Override - public List execute() - { - // Build the query string - StringBuilder sb = new StringBuilder(); - sb.append("ASPECT:\"rma:").append(ASPECT_UNPUBLISHED_UPDATE.getLocalName()).append("\""); - String query = sb.toString(); - - if (logger.isDebugEnabled()) - { - logger.debug("Executing query " + query); - } - - // Execute query to find updates awaiting publishing - List resultNodes = null; - - SearchParameters searchParameters = new SearchParameters(); - searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL); - searchParameters.setQuery(query); - searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); - - try - { - ResultSet results = searchService.query(searchParameters); - try - { - resultNodes = results.getNodeRefs(); - } - finally - { - results.close(); - } - } - catch (AlfrescoRuntimeException exception) - { - if (logger.isDebugEnabled()) - { - logger.debug("Error executing query, " + exception.getMessage()); - } - throw exception; - } - - if (logger.isDebugEnabled()) - { - logger.debug("Found " + resultNodes.size() + " disposition action definitions updates awaiting publishing."); - } - - return resultNodes; - } - }; - return retryingTransactionHelper.doInTransaction(execution, true); - } - - /** - * Mark the node as publish in progress. This is often used as a marker to prevent any further updates - * to a node. - * @param nodeRef node reference - */ - private void markPublishInProgress(final NodeRef nodeRef) - { - RetryingTransactionHelper.RetryingTransactionCallback execution = - new RetryingTransactionHelper.RetryingTransactionCallback() - { - @Override - public Void execute() - { - if (logger.isDebugEnabled()) - { - logger.debug("Marking updated node as publish in progress. (node=" + nodeRef.toString() + ")"); - } - - behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - try - { - if (nodeService.exists(nodeRef)) - { - // Mark the node as publish in progress - nodeService.setProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS, true); - } - } - finally - { - behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - } - return null; - } - }; - retryingTransactionHelper.doInTransaction(execution); - } - - /** - * Publish the updates made to the node. - * @param nodeRef node reference - */ - private void publishUpdates(final NodeRef nodeRef) - { - RetryingTransactionHelper.RetryingTransactionCallback execution = - new RetryingTransactionHelper.RetryingTransactionCallback() - { - @Override - public Void execute() - { - behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - try - { - // Get the update to value for the node - String updateTo = (String)nodeService.getProperty(nodeRef, PROP_UPDATE_TO); - - if (updateTo != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Node update to " + updateTo + " (noderef=" + nodeRef.toString() + ")"); - } - - // Get the publish executor - PublishExecutor executor = publishExecutorRegistry.get(updateTo); - if (executor == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")"); - } - throw new AlfrescoRuntimeException("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")"); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Attempting to publish updates. (nodeRef=" + nodeRef.toString() + ")"); - } - - // Publish - executor.publish(nodeRef); - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("Unable to publish, because publish executor is not set."); - } - } - - // Remove the unpublished update aspect - nodeService.removeAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE); - - if (logger.isDebugEnabled()) - { - logger.debug("Publish updates complete. (nodeRef=" + nodeRef.toString() + ")"); - } - } - finally - { - behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - } - - return null; - } - }; - retryingTransactionHelper.doInTransaction(execution); - } - - /** - * Unmark node as publish in progress, assuming publish failed. - * @param nodeRef node reference - */ - private void unmarkPublishInProgress(final NodeRef nodeRef) - { - RetryingTransactionHelper.RetryingTransactionCallback execution = - new RetryingTransactionHelper.RetryingTransactionCallback() - { - @Override - public Void execute() - { - behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - try - { - // Assuming the node still has unpublished information, then unmark it in progress - if (nodeService.exists(nodeRef) && - nodeService.hasAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Removing publish in progress marker from updated node, because update was not successful. (node=" + nodeRef.toString() + ")"); - } - - nodeService.setProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS, false); - } - } - finally - { - behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); - } - - return null; - } - }; - retryingTransactionHelper.doInTransaction(execution); - } -} +/* + * Copyright (C) 2009-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.job; + +import java.util.Date; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor; +import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.QueryConsistency; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchParameters; +import org.alfresco.service.cmr.search.SearchService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Job to publish any pending updates on marked node references. + * + * @author Roy Wetherall + */ +public class PublishUpdatesJobExecuter extends RecordsManagementJobExecuter +{ + /** Logger */ + private static Log logger = LogFactory.getLog(PublishUpdatesJobExecuter.class); + + /** Node service */ + private NodeService nodeService; + + /** Search service */ + private SearchService searchService; + + /** Publish executor register */ + private PublishExecutorRegistry publishExecutorRegistry; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** Behaviour filter */ + private BehaviourFilter behaviourFilter; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param searchService search service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * @param publishExecutorRegistry public executor registry + */ + public void setPublishExecutorRegistry(PublishExecutorRegistry publishExecutorRegistry) + { + this.publishExecutorRegistry = publishExecutorRegistry; + } + + /** + * @param behaviourFilter behaviour filter + */ + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#executeImpl() + */ + public void executeImpl() + { + if (logger.isDebugEnabled()) + { + logger.debug("Job Starting"); + } + + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + if (rmLoaded()) + { + // Get a list of the nodes that have updates that need to be published + List nodeRefs = getUpdatedNodes(); + + // Deal with each updated disposition action in turn + for (NodeRef nodeRef : nodeRefs) + { + if (nodeService.exists(nodeRef)) + { + boolean publishing = ((Boolean)nodeService.getProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS)).booleanValue(); + if (!publishing) + { + // Mark the update node as publishing in progress + markPublishInProgress(nodeRef); + try + { + Date start = new Date(); + if (logger.isDebugEnabled()) + { + logger.debug("Starting publish of updates ..."); + logger.debug(" - for " + nodeRef.toString()); + logger.debug(" - at " + start.toString()); + } + + // Publish updates + publishUpdates(nodeRef); + + + if (logger.isDebugEnabled()) + { + Date end = new Date(); + long duration = end.getTime() - start.getTime(); + logger.debug("Completed publish of updates ..."); + logger.debug(" - for " + nodeRef.toString()); + logger.debug(" - at " + end.toString()); + logger.debug(" - duration " + Long.toString(duration)); + } + } + finally + { + // Ensure the update node has either completed the publish or is marked as no longer in progress + unmarkPublishInProgress(nodeRef); + } + } + } + } + } + return null; + }; + }, AuthenticationUtil.getSystemUserName()); + + if (logger.isDebugEnabled()) + { + logger.debug("Job Finished"); + } + } + + /** + * Helper method to determine whether the RM content model has been loaded yet. + * + * @return boolean true if RM content model loaded, false otherwise + */ + private boolean rmLoaded() + { + boolean result = false; + + // ensure that the rm content model has been loaded + if (dictionaryService != null && + dictionaryService.getAspect(ASPECT_UNPUBLISHED_UPDATE) != null) + { + result = true; + } + + return result; + } + + /** + * Get a list of the nodes with updates pending publish + * @return List list of node refences with updates pending publication + */ + private List getUpdatedNodes() + { + RetryingTransactionCallback> execution = + new RetryingTransactionHelper.RetryingTransactionCallback>() + { + @Override + public List execute() + { + // Build the query string + StringBuilder sb = new StringBuilder(); + sb.append("ASPECT:\"rma:").append(ASPECT_UNPUBLISHED_UPDATE.getLocalName()).append("\""); + String query = sb.toString(); + + if (logger.isDebugEnabled()) + { + logger.debug("Executing query " + query); + } + + // Execute query to find updates awaiting publishing + List resultNodes = null; + + SearchParameters searchParameters = new SearchParameters(); + searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL); + searchParameters.setQuery(query); + searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); + + try + { + ResultSet results = searchService.query(searchParameters); + try + { + resultNodes = results.getNodeRefs(); + } + finally + { + results.close(); + } + } + catch (AlfrescoRuntimeException exception) + { + if (logger.isDebugEnabled()) + { + logger.debug("Error executing query, " + exception.getMessage()); + } + throw exception; + } + + if (logger.isDebugEnabled()) + { + logger.debug("Found " + resultNodes.size() + " disposition action definitions updates awaiting publishing."); + } + + return resultNodes; + } + }; + return retryingTransactionHelper.doInTransaction(execution, true); + } + + /** + * Mark the node as publish in progress. This is often used as a marker to prevent any further updates + * to a node. + * @param nodeRef node reference + */ + private void markPublishInProgress(final NodeRef nodeRef) + { + RetryingTransactionHelper.RetryingTransactionCallback execution = + new RetryingTransactionHelper.RetryingTransactionCallback() + { + @Override + public Void execute() + { + if (logger.isDebugEnabled()) + { + logger.debug("Marking updated node as publish in progress. (node=" + nodeRef.toString() + ")"); + } + + behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + try + { + if (nodeService.exists(nodeRef)) + { + // Mark the node as publish in progress + nodeService.setProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS, true); + } + } + finally + { + behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + } + return null; + } + }; + retryingTransactionHelper.doInTransaction(execution); + } + + /** + * Publish the updates made to the node. + * @param nodeRef node reference + */ + private void publishUpdates(final NodeRef nodeRef) + { + RetryingTransactionHelper.RetryingTransactionCallback execution = + new RetryingTransactionHelper.RetryingTransactionCallback() + { + @Override + public Void execute() + { + behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + try + { + // Get the update to value for the node + String updateTo = (String)nodeService.getProperty(nodeRef, PROP_UPDATE_TO); + + if (updateTo != null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Node update to " + updateTo + " (noderef=" + nodeRef.toString() + ")"); + } + + // Get the publish executor + PublishExecutor executor = publishExecutorRegistry.get(updateTo); + if (executor == null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")"); + } + throw new AlfrescoRuntimeException("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")"); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Attempting to publish updates. (nodeRef=" + nodeRef.toString() + ")"); + } + + // Publish + executor.publish(nodeRef); + } + else + { + if (logger.isDebugEnabled()) + { + logger.debug("Unable to publish, because publish executor is not set."); + } + } + + // Remove the unpublished update aspect + nodeService.removeAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE); + + if (logger.isDebugEnabled()) + { + logger.debug("Publish updates complete. (nodeRef=" + nodeRef.toString() + ")"); + } + } + finally + { + behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + } + + return null; + } + }; + retryingTransactionHelper.doInTransaction(execution); + } + + /** + * Unmark node as publish in progress, assuming publish failed. + * @param nodeRef node reference + */ + private void unmarkPublishInProgress(final NodeRef nodeRef) + { + RetryingTransactionHelper.RetryingTransactionCallback execution = + new RetryingTransactionHelper.RetryingTransactionCallback() + { + @Override + public Void execute() + { + behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + try + { + // Assuming the node still has unpublished information, then unmark it in progress + if (nodeService.exists(nodeRef) && + nodeService.hasAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Removing publish in progress marker from updated node, because update was not successful. (node=" + nodeRef.toString() + ")"); + } + + nodeService.setProperty(nodeRef, PROP_PUBLISH_IN_PROGRESS, false); + } + } + finally + { + behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION); + } + + return null; + } + }; + retryingTransactionHelper.doInTransaction(execution); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java index 5cfebeb67c..2897d428d6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java @@ -1,159 +1,159 @@ -/* - * Copyright (C) 2009-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.job; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.lock.JobLockService; -import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback; -import org.alfresco.repo.lock.LockAcquisitionException; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * Base records management job implementation. - *

- * Delegates job execution and ensures locking - * is enforced. - * - * @author Roy Wetherall - */ -public class RecordsManagementJob implements Job -{ - private static Log logger = LogFactory.getLog(RecordsManagementJob.class); - - private static final long DEFAULT_TIME = 30000L; - - private JobLockService jobLockService; - - private RecordsManagementJobExecuter jobExecuter; - - private String jobName; - - private QName getLockQName() - { - return QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, jobName); - } - - private class LockCallback implements JobLockRefreshCallback - { - final AtomicBoolean running = new AtomicBoolean(true); - - @Override - public boolean isActive() - { - return running.get(); - } - - @Override - public void lockReleased() - { - running.set(false); - } - } - - - /** - * Attempts to get the lock. If the lock couldn't be taken, then null is returned. - * - * @return Returns the lock token or null - */ - private String getLock() - { - try - { - return jobLockService.getLock(getLockQName(), DEFAULT_TIME); - } - catch (LockAcquisitionException e) - { - return null; - } - } - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException - { - // get the job lock service - jobLockService = (JobLockService)context.getJobDetail().getJobDataMap().get("jobLockService"); - if (jobLockService == null) - { - throw new AlfrescoRuntimeException("Job lock service has not been specified."); - } - - // get the job executer - jobExecuter = (RecordsManagementJobExecuter)context.getJobDetail().getJobDataMap().get("jobExecuter"); - if (jobExecuter == null) - { - throw new AlfrescoRuntimeException("Job executer has not been specified."); - } - - // get the job name - jobName = (String)context.getJobDetail().getJobDataMap().get("jobName"); - if (jobName == null) - { - throw new AlfrescoRuntimeException("Job name has not been specified."); - } - - final LockCallback lockCallback = new LockCallback(); - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - // try and get the lock - String lockToken = getLock(); - if (lockToken != null) - { - try - { - jobLockService.refreshLock(lockToken, getLockQName(), DEFAULT_TIME, lockCallback); - // do work - jobExecuter.execute(); - } - finally - { - try - { - lockCallback.running.set(false); - jobLockService.releaseLock(lockToken, getLockQName()); - } - catch (LockAcquisitionException e) - { - // Ignore - if (logger.isDebugEnabled()) - { - logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "(" + e.getMessage() + ")"); - } - } - } - } - - // return - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } -} +/* + * Copyright (C) 2009-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.job; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.lock.JobLockService; +import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback; +import org.alfresco.repo.lock.LockAcquisitionException; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * Base records management job implementation. + *

+ * Delegates job execution and ensures locking + * is enforced. + * + * @author Roy Wetherall + */ +public class RecordsManagementJob implements Job +{ + private static Log logger = LogFactory.getLog(RecordsManagementJob.class); + + private static final long DEFAULT_TIME = 30000L; + + private JobLockService jobLockService; + + private RecordsManagementJobExecuter jobExecuter; + + private String jobName; + + private QName getLockQName() + { + return QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, jobName); + } + + private class LockCallback implements JobLockRefreshCallback + { + final AtomicBoolean running = new AtomicBoolean(true); + + @Override + public boolean isActive() + { + return running.get(); + } + + @Override + public void lockReleased() + { + running.set(false); + } + } + + + /** + * Attempts to get the lock. If the lock couldn't be taken, then null is returned. + * + * @return Returns the lock token or null + */ + private String getLock() + { + try + { + return jobLockService.getLock(getLockQName(), DEFAULT_TIME); + } + catch (LockAcquisitionException e) + { + return null; + } + } + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException + { + // get the job lock service + jobLockService = (JobLockService)context.getJobDetail().getJobDataMap().get("jobLockService"); + if (jobLockService == null) + { + throw new AlfrescoRuntimeException("Job lock service has not been specified."); + } + + // get the job executer + jobExecuter = (RecordsManagementJobExecuter)context.getJobDetail().getJobDataMap().get("jobExecuter"); + if (jobExecuter == null) + { + throw new AlfrescoRuntimeException("Job executer has not been specified."); + } + + // get the job name + jobName = (String)context.getJobDetail().getJobDataMap().get("jobName"); + if (jobName == null) + { + throw new AlfrescoRuntimeException("Job name has not been specified."); + } + + final LockCallback lockCallback = new LockCallback(); + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() + { + // try and get the lock + String lockToken = getLock(); + if (lockToken != null) + { + try + { + jobLockService.refreshLock(lockToken, getLockQName(), DEFAULT_TIME, lockCallback); + // do work + jobExecuter.execute(); + } + finally + { + try + { + lockCallback.running.set(false); + jobLockService.releaseLock(lockToken, getLockQName()); + } + catch (LockAcquisitionException e) + { + // Ignore + if (logger.isDebugEnabled()) + { + logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "(" + e.getMessage() + ")"); + } + } + } + } + + // return + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJobExecuter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJobExecuter.java index 9d6632774d..9c8fed5903 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJobExecuter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJobExecuter.java @@ -1,80 +1,80 @@ -/* - * Copyright (C) 2009-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.job; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.admin.RepositoryState; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; - -/** - * Records management job executer base class. - * - * @author Roy Wetherall - */ -public abstract class RecordsManagementJobExecuter implements RecordsManagementModel -{ - /** Retrying transaction helper */ - protected RetryingTransactionHelper retryingTransactionHelper; - - /** Repository state helper */ - protected RepositoryState repositoryState; - - /** - * @param retryingTransactionHelper retrying transaction helper - */ - public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @param repositoryState repository state helper component - */ - public void setRepositoryState(RepositoryState repositoryState) - { - this.repositoryState = repositoryState; - } - - /** - * Executes the jobs work. - */ - public void execute() - { - // jobs not allowed to execute unless bootstrap is complete - if (!repositoryState.isBootstrapping()) - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Void execute() - { - executeImpl(); - - return null; - } - }, false, true); - } - } - - /** - * Jobs work implementation. - */ - public abstract void executeImpl(); -} +/* + * Copyright (C) 2009-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.job; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.admin.RepositoryState; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; + +/** + * Records management job executer base class. + * + * @author Roy Wetherall + */ +public abstract class RecordsManagementJobExecuter implements RecordsManagementModel +{ + /** Retrying transaction helper */ + protected RetryingTransactionHelper retryingTransactionHelper; + + /** Repository state helper */ + protected RepositoryState repositoryState; + + /** + * @param retryingTransactionHelper retrying transaction helper + */ + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + /** + * @param repositoryState repository state helper component + */ + public void setRepositoryState(RepositoryState repositoryState) + { + this.repositoryState = repositoryState; + } + + /** + * Executes the jobs work. + */ + public void execute() + { + // jobs not allowed to execute unless bootstrap is complete + if (!repositoryState.isBootstrapping()) + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Void execute() + { + executeImpl(); + + return null; + } + }, false, true); + } + } + + /** + * Jobs work implementation. + */ + public abstract void executeImpl(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/BasePublishExecutor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/BasePublishExecutor.java index f216fd3701..a46dc0877f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/BasePublishExecutor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/BasePublishExecutor.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2009-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.job.publish; - -/** - * Base publish executor implementation - * - * @author Roy Wetherall - */ -public abstract class BasePublishExecutor implements PublishExecutor -{ - /** Publish executor registry */ - public PublishExecutorRegistry registry; - - /** - * Set publish executor registry - * @param registry publish executor registry - */ - public void setPublishExecutorRegistry(PublishExecutorRegistry registry) - { - this.registry = registry; - } - - /** - * Init method - */ - public void init() - { - registry.register(this); - } -} +/* + * Copyright (C) 2009-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.job.publish; + +/** + * Base publish executor implementation + * + * @author Roy Wetherall + */ +public abstract class BasePublishExecutor implements PublishExecutor +{ + /** Publish executor registry */ + public PublishExecutorRegistry registry; + + /** + * Set publish executor registry + * @param registry publish executor registry + */ + public void setPublishExecutorRegistry(PublishExecutorRegistry registry) + { + this.registry = registry; + } + + /** + * Init method + */ + public void init() + { + registry.register(this); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java index 3bd99c376d..38cb81d543 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java @@ -1,88 +1,88 @@ -/* - * Copyright (C) 2009-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.job.publish; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.action.impl.BroadcastDispositionActionDefinitionUpdateAction; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; - -/** - * Disposition action definition publish executor - * - * @author Roy Wetherall - */ -public class DispositionActionDefinitionPublishExecutor extends BasePublishExecutor -{ - /** Node service */ - private NodeService nodeService; - - /** Records management action service */ - private RecordsManagementActionService rmActionService; - - /** - * Set node service - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set records management service - * @param rmActionService records management service - */ - public void setRmActionService(RecordsManagementActionService rmActionService) - { - this.rmActionService = rmActionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor#getName() - */ - @Override - public String getName() - { - return RecordsManagementModel.UPDATE_TO_DISPOSITION_ACTION_DEFINITION; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor#publish(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - public void publish(NodeRef nodeRef) - { - List updatedProps = (List)nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_UPDATED_PROPERTIES); - if (updatedProps != null) - { - Map params = new HashMap(); - params.put(BroadcastDispositionActionDefinitionUpdateAction.CHANGED_PROPERTIES, (Serializable)updatedProps); - rmActionService.executeRecordsManagementAction(nodeRef, BroadcastDispositionActionDefinitionUpdateAction.NAME, params); - } - } -} +/* + * Copyright (C) 2009-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.job.publish; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.action.impl.BroadcastDispositionActionDefinitionUpdateAction; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Disposition action definition publish executor + * + * @author Roy Wetherall + */ +public class DispositionActionDefinitionPublishExecutor extends BasePublishExecutor +{ + /** Node service */ + private NodeService nodeService; + + /** Records management action service */ + private RecordsManagementActionService rmActionService; + + /** + * Set node service + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set records management service + * @param rmActionService records management service + */ + public void setRmActionService(RecordsManagementActionService rmActionService) + { + this.rmActionService = rmActionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor#getName() + */ + @Override + public String getName() + { + return RecordsManagementModel.UPDATE_TO_DISPOSITION_ACTION_DEFINITION; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor#publish(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + public void publish(NodeRef nodeRef) + { + List updatedProps = (List)nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_UPDATED_PROPERTIES); + if (updatedProps != null) + { + Map params = new HashMap(); + params.put(BroadcastDispositionActionDefinitionUpdateAction.CHANGED_PROPERTIES, (Serializable)updatedProps); + rmActionService.executeRecordsManagementAction(nodeRef, BroadcastDispositionActionDefinitionUpdateAction.NAME, params); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutor.java index e2496de335..c2e8b74f71 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutor.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2009-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.job.publish; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Publish executor interface. - * - * @author Roy Wetherall - */ -public interface PublishExecutor -{ - /** - * @return publish exector name - */ - String getName(); - - /** - * Publish changes to node. - * - * @param nodeRef node reference - */ - void publish(NodeRef nodeRef); -} +/* + * Copyright (C) 2009-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.job.publish; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Publish executor interface. + * + * @author Roy Wetherall + */ +public interface PublishExecutor +{ + /** + * @return publish exector name + */ + String getName(); + + /** + * Publish changes to node. + * + * @param nodeRef node reference + */ + void publish(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutorRegistry.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutorRegistry.java index a109bd1046..09762086dd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutorRegistry.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/PublishExecutorRegistry.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2009-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.job.publish; - -import java.util.HashMap; -import java.util.Map; - -/** - * Publish executor register. - * - * @author Roy Wetherall - */ -public class PublishExecutorRegistry -{ - /** Map of publish executors */ - private Map publishExectors = new HashMap(3); - - /** - * Register a publish executor - * - * @param publishExecutor publish executor - */ - public void register(PublishExecutor publishExecutor) - { - publishExectors.put(publishExecutor.getName(), publishExecutor); - } - - /** - * Get registered publish executor by name. - * - * @param name name - * @return {@link PublishExecutor}] - */ - public PublishExecutor get(String name) - { - return publishExectors.get(name); - } -} +/* + * Copyright (C) 2009-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.job.publish; + +import java.util.HashMap; +import java.util.Map; + +/** + * Publish executor register. + * + * @author Roy Wetherall + */ +public class PublishExecutorRegistry +{ + /** Map of publish executors */ + private Map publishExectors = new HashMap(3); + + /** + * Register a publish executor + * + * @param publishExecutor publish executor + */ + public void register(PublishExecutor publishExecutor) + { + publishExectors.put(publishExecutor.getName(), publishExecutor); + } + + /** + * Get registered publish executor by name. + * + * @param name name + * @return {@link PublishExecutor}] + */ + public PublishExecutor get(String name) + { + return publishExectors.get(name); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptCapability.java index de79832559..6a45a9c9d9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptCapability.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript; - -/** - * @author Roy Wetherall - */ -public class ScriptCapability -{ - private String name; - private String displayLabel; - private String[] actions; - - /** - * @param name - * @param displayLabel - * @param actions - */ - protected ScriptCapability(String name, String displayLabel, String[] actions) - { - this.name = name; - this.displayLabel = displayLabel; - this.actions = actions.clone(); - } - - /** - * @return the name - */ - public String getName() - { - return name; - } - - /** - * @return the displayLabel - */ - public String getDisplayLabel() - { - return displayLabel; - } - - /** - * @return the actions - */ - public String[] getActions() - { - return actions; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript; + +/** + * @author Roy Wetherall + */ +public class ScriptCapability +{ + private String name; + private String displayLabel; + private String[] actions; + + /** + * @param name + * @param displayLabel + * @param actions + */ + protected ScriptCapability(String name, String displayLabel, String[] actions) + { + this.name = name; + this.displayLabel = displayLabel; + this.actions = actions.clone(); + } + + /** + * @return the name + */ + public String getName() + { + return name; + } + + /** + * @return the displayLabel + */ + public String getDisplayLabel() + { + return displayLabel; + } + + /** + * @return the actions + */ + public String[] getActions() + { + return actions; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentNode.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentNode.java index 254c7c5afc..c96303a3dc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentNode.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentNode.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript; - -import java.util.Collections; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.mozilla.javascript.Scriptable; - -/** - * Base records management script node - * - * NOTE: this could be removed, but is being kept as a place holder for future development - * - * @author Roy Wetherall - */ -public class ScriptRecordsManagmentNode extends ScriptNode -{ - private static final long serialVersionUID = 8872385533440938353L; - - private RecordsManagementServiceRegistry rmServices; - - public ScriptRecordsManagmentNode(NodeRef nodeRef, RecordsManagementServiceRegistry services, Scriptable scope) - { - super(nodeRef, services, scope); - rmServices = services; - } - - public ScriptRecordsManagmentNode(NodeRef nodeRef, RecordsManagementServiceRegistry services) - { - super(nodeRef, services); - rmServices = services; - } - - public boolean hasCapability(String capabilityName) - { - boolean result = false; - - CapabilityService capabilityService = (CapabilityService)rmServices.getCapabilityService(); - Capability capability = capabilityService.getCapability(capabilityName); - if (capability != null) - { - Map map = capabilityService.getCapabilitiesAccessState(nodeRef, Collections.singletonList(capabilityName)); - if (map.containsKey(capability)) - { - AccessStatus accessStatus = map.get(capability); - if (!accessStatus.equals(AccessStatus.DENIED)) - { - result = true; - } - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript; + +import java.util.Collections; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.repo.jscript.ScriptNode; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.mozilla.javascript.Scriptable; + +/** + * Base records management script node + * + * NOTE: this could be removed, but is being kept as a place holder for future development + * + * @author Roy Wetherall + */ +public class ScriptRecordsManagmentNode extends ScriptNode +{ + private static final long serialVersionUID = 8872385533440938353L; + + private RecordsManagementServiceRegistry rmServices; + + public ScriptRecordsManagmentNode(NodeRef nodeRef, RecordsManagementServiceRegistry services, Scriptable scope) + { + super(nodeRef, services, scope); + rmServices = services; + } + + public ScriptRecordsManagmentNode(NodeRef nodeRef, RecordsManagementServiceRegistry services) + { + super(nodeRef, services); + rmServices = services; + } + + public boolean hasCapability(String capabilityName) + { + boolean result = false; + + CapabilityService capabilityService = (CapabilityService)rmServices.getCapabilityService(); + Capability capability = capabilityService.getCapability(capabilityName); + if (capability != null) + { + Map map = capabilityService.getCapabilitiesAccessState(nodeRef, Collections.singletonList(capabilityName)); + if (map.containsKey(capability)) + { + AccessStatus accessStatus = map.get(capability); + if (!accessStatus.equals(AccessStatus.DENIED)) + { + result = true; + } + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentService.java index 786e4de0e9..2f3e20de84 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/ScriptRecordsManagmentService.java @@ -1,122 +1,122 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.repo.jscript.BaseScopableProcessorExtension; -import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.scripts.ScriptException; - -/** - * Records management service - * - * @author Roy Wetherall - */ -public class ScriptRecordsManagmentService extends BaseScopableProcessorExtension - implements RecordsManagementModel -{ - /** Records management service registry */ - private RecordsManagementServiceRegistry rmServices; - - /** Records management notification helper */ - private RecordsManagementNotificationHelper notificationHelper; - - /** - * Set records management service registry - * - * @param rmServices records management service registry - */ - public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry rmServices) - { - this.rmServices = rmServices; - } - - /** - * Sets the notification helper - * - * @param notificationHelper notification helper - */ - public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) - { - this.notificationHelper = notificationHelper; - } - - /** - * Get records management node - * - * @param node script node - * @return ScriptRecordsManagementNode records management script node - */ - public ScriptRecordsManagmentNode getRecordsManagementNode(ScriptNode node) - { - ScriptRecordsManagmentNode result = null; - - if (rmServices.getNodeService().hasAspect(node.getNodeRef(), ASPECT_FILE_PLAN_COMPONENT)) - { - // TODO .. at this point determine what type of records management node is it and - // create the appropriate sub-type - result = new ScriptRecordsManagmentNode(node.getNodeRef(), rmServices); - } - else - { - throw new ScriptException("Node is not a records management node type."); - } - - return result; - } - - /** - * Set the RM permission - * - * @param node - * @param permission - * @param authority - */ - public void setPermission(ScriptNode node, String permission, String authority) - { - FilePlanPermissionService filePlanPermissionService = rmServices.getFilePlanPermissionService(); - filePlanPermissionService.setPermission(node.getNodeRef(), authority, permission); - } - - /** - * Delete the RM permission - * - * @param node - * @param permission - * @param authority - */ - public void deletePermission(ScriptNode node, String permission, String authority) - { - FilePlanPermissionService filePlanPermissionService = rmServices.getFilePlanPermissionService(); - filePlanPermissionService.deletePermission(node.getNodeRef(), authority, permission); - } - - /** - * Send superseded notification - * - * @param record superseded record - */ - public void sendSupersededNotification(ScriptNode record) - { - notificationHelper.recordSupersededEmailNotification(record.getNodeRef()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.repo.jscript.BaseScopableProcessorExtension; +import org.alfresco.repo.jscript.ScriptNode; +import org.alfresco.scripts.ScriptException; + +/** + * Records management service + * + * @author Roy Wetherall + */ +public class ScriptRecordsManagmentService extends BaseScopableProcessorExtension + implements RecordsManagementModel +{ + /** Records management service registry */ + private RecordsManagementServiceRegistry rmServices; + + /** Records management notification helper */ + private RecordsManagementNotificationHelper notificationHelper; + + /** + * Set records management service registry + * + * @param rmServices records management service registry + */ + public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry rmServices) + { + this.rmServices = rmServices; + } + + /** + * Sets the notification helper + * + * @param notificationHelper notification helper + */ + public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) + { + this.notificationHelper = notificationHelper; + } + + /** + * Get records management node + * + * @param node script node + * @return ScriptRecordsManagementNode records management script node + */ + public ScriptRecordsManagmentNode getRecordsManagementNode(ScriptNode node) + { + ScriptRecordsManagmentNode result = null; + + if (rmServices.getNodeService().hasAspect(node.getNodeRef(), ASPECT_FILE_PLAN_COMPONENT)) + { + // TODO .. at this point determine what type of records management node is it and + // create the appropriate sub-type + result = new ScriptRecordsManagmentNode(node.getNodeRef(), rmServices); + } + else + { + throw new ScriptException("Node is not a records management node type."); + } + + return result; + } + + /** + * Set the RM permission + * + * @param node + * @param permission + * @param authority + */ + public void setPermission(ScriptNode node, String permission, String authority) + { + FilePlanPermissionService filePlanPermissionService = rmServices.getFilePlanPermissionService(); + filePlanPermissionService.setPermission(node.getNodeRef(), authority, permission); + } + + /** + * Delete the RM permission + * + * @param node + * @param permission + * @param authority + */ + public void deletePermission(ScriptNode node, String permission, String authority) + { + FilePlanPermissionService filePlanPermissionService = rmServices.getFilePlanPermissionService(); + filePlanPermissionService.deletePermission(node.getNodeRef(), authority, permission); + } + + /** + * Send superseded notification + * + * @param record superseded record + */ + public void sendSupersededNotification(ScriptNode record) + { + notificationHelper.recordSupersededEmailNotification(record.getNodeRef()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java index 093d643400..02f3bdd4dc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java @@ -1,267 +1,267 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.NamespaceService; - -/** - * Base evaluator. - * - * @author Roy Wetherall - */ -public abstract class BaseEvaluator implements RecordsManagementModel -{ - /** Name */ - protected String name; - - /** JSON conversion component */ - protected JSONConversionComponent jsonConversionComponent; - - /** Record service */ - protected RecordService recordService; - - /** Node service */ - protected NodeService nodeService; - - /** Namespace service */ - protected NamespaceService namespaceService; - - /** Capability service */ - protected CapabilityService capabilityService; - - /** File plan component kinds */ - protected Set kinds; - - /** Capabilities */ - protected List capabilities; - - /** File plan service */ - protected FilePlanService filePlanService; - - /** Disposition service */ - protected DispositionService dispositionService; - - /** Record folder service */ - protected RecordFolderService recordFolderService; - - /** - * @param jsonConversionComponent json conversion component - */ - public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) - { - this.jsonConversionComponent = jsonConversionComponent; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @return - */ - public String getName() - { - return this.name; - } - - /** - * @param kinds - */ - public void setKinds(Set kinds) - { - this.kinds = kinds; - } - - /** - * @param capabilties - */ - public void setCapabilities(List capabilties) - { - this.capabilities = capabilties; - } - - /** - * Helper method which sets on capability. - * - * @param capability capability name - */ - public void setCapability(String capability) - { - List list = new ArrayList(1); - list.add(capability); - this.capabilities = list; - } - - /** - * Registers this instance as an indicator (evaluator) - */ - public void registerIndicator() - { - jsonConversionComponent.registerIndicator(this); - } - - /** - * Registers this instance as an action (evaluator) - */ - public void registerAction() - { - jsonConversionComponent.registerAction(this); - } - - /** - * Executes the evaluation. - * - * @param nodeRef - * @return - */ - public boolean evaluate(NodeRef nodeRef) - { - boolean result = false; - - // Check that we are dealing with the correct kind of RM object - if ((kinds == null || checkKinds(nodeRef)) && - // Check we have the required capabilities - (capabilities == null || checkCapabilities(nodeRef))) - { - result = evaluateImpl(nodeRef); - } - - return result; - } - - /** - * Checks the file plan component kind. - * - * @param nodeRef - * @return - */ - private boolean checkKinds(NodeRef nodeRef) - { - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - return kinds.contains(kind); - } - - /** - * Checks the capabilities. - * - * @param nodeRef - * @return - */ - private boolean checkCapabilities(NodeRef nodeRef) - { - boolean result = true; - if (capabilities != null && !capabilities.isEmpty()) - { - Map accessStatus = capabilityService.getCapabilitiesAccessState(nodeRef, capabilities); - for (AccessStatus value : accessStatus.values()) - { - if (AccessStatus.DENIED.equals(value)) - { - result = false; - break; - } - } - } - return result; - } - - /** - * Evaluation execution implementation. - * - * @param nodeRef - * @return - */ - protected abstract boolean evaluateImpl(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.NamespaceService; + +/** + * Base evaluator. + * + * @author Roy Wetherall + */ +public abstract class BaseEvaluator implements RecordsManagementModel +{ + /** Name */ + protected String name; + + /** JSON conversion component */ + protected JSONConversionComponent jsonConversionComponent; + + /** Record service */ + protected RecordService recordService; + + /** Node service */ + protected NodeService nodeService; + + /** Namespace service */ + protected NamespaceService namespaceService; + + /** Capability service */ + protected CapabilityService capabilityService; + + /** File plan component kinds */ + protected Set kinds; + + /** Capabilities */ + protected List capabilities; + + /** File plan service */ + protected FilePlanService filePlanService; + + /** Disposition service */ + protected DispositionService dispositionService; + + /** Record folder service */ + protected RecordFolderService recordFolderService; + + /** + * @param jsonConversionComponent json conversion component + */ + public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) + { + this.jsonConversionComponent = jsonConversionComponent; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @return + */ + public String getName() + { + return this.name; + } + + /** + * @param kinds + */ + public void setKinds(Set kinds) + { + this.kinds = kinds; + } + + /** + * @param capabilties + */ + public void setCapabilities(List capabilties) + { + this.capabilities = capabilties; + } + + /** + * Helper method which sets on capability. + * + * @param capability capability name + */ + public void setCapability(String capability) + { + List list = new ArrayList(1); + list.add(capability); + this.capabilities = list; + } + + /** + * Registers this instance as an indicator (evaluator) + */ + public void registerIndicator() + { + jsonConversionComponent.registerIndicator(this); + } + + /** + * Registers this instance as an action (evaluator) + */ + public void registerAction() + { + jsonConversionComponent.registerAction(this); + } + + /** + * Executes the evaluation. + * + * @param nodeRef + * @return + */ + public boolean evaluate(NodeRef nodeRef) + { + boolean result = false; + + // Check that we are dealing with the correct kind of RM object + if ((kinds == null || checkKinds(nodeRef)) && + // Check we have the required capabilities + (capabilities == null || checkCapabilities(nodeRef))) + { + result = evaluateImpl(nodeRef); + } + + return result; + } + + /** + * Checks the file plan component kind. + * + * @param nodeRef + * @return + */ + private boolean checkKinds(NodeRef nodeRef) + { + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + return kinds.contains(kind); + } + + /** + * Checks the capabilities. + * + * @param nodeRef + * @return + */ + private boolean checkCapabilities(NodeRef nodeRef) + { + boolean result = true; + if (capabilities != null && !capabilities.isEmpty()) + { + Map accessStatus = capabilityService.getCapabilitiesAccessState(nodeRef, capabilities); + for (AccessStatus value : accessStatus.values()) + { + if (AccessStatus.DENIED.equals(value)) + { + result = false; + break; + } + } + } + return result; + } + + /** + * Evaluation execution implementation. + * + * @param nodeRef + * @return + */ + protected abstract boolean evaluateImpl(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 931752d6ef..a63879bc4d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -1,579 +1,579 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.PathUtil; -import org.apache.commons.lang.ArrayUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -/** - * Extend JSON conversion component to include RM specifics. - * - * @author Roy Wetherall - */ -public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent - implements NodeServicePolicies.OnDeleteNodePolicy, - NodeServicePolicies.OnCreateNodePolicy -{ - /** JSON values */ - private static final String IS_RM_NODE = "isRmNode"; - private static final String RM_NODE = "rmNode"; - private static final String IS_RM_SITE_CREATED = "isRmSiteCreated"; - private static final String IS_RECORD_CONTRIBUTOR_GROUP_ENABLED = "isRecordContributorGroupEnabled"; - private static final String RECORD_CONTRIBUTOR_GROUP_NAME = "recordContributorGroupName"; - - /** true if record contributor group is enabled, false otherwise */ - private boolean isRecordContributorsGroupEnabled = false; - - /** record contributors group */ - private String recordContributorsGroupName = "RECORD_CONTRIBUTORS"; - - /** Record service */ - private RecordService recordService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Capability service */ - private CapabilityService capabilityService; - - /** dictionary service */ - private DictionaryService dictionaryService; - - /** site service */ - private SiteService siteService; - - /** Indicators */ - private List indicators = new ArrayList(); - - /** Actions */ - private List actions = new ArrayList(); - - /** The policy component */ - private PolicyComponent policyComponent; - - /** JSON conversion component cache */ - private SimpleCache jsonConversionComponentCache; - - /** Constant for checking the cache */ - private static final String RM_SITE_EXISTS = "rmSiteExists"; - - /** - * @param enabled true if enabled, false otherwise - */ - public void setRecordContributorsGroupEnabled(boolean enabled) - { - isRecordContributorsGroupEnabled = enabled; - } - - /** - * @param recordContributorsGroupName record contributors group name - */ - public void setRecordContributorsGroupName(String recordContributorsGroupName) - { - this.recordContributorsGroupName = recordContributorsGroupName; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param indicator registered indicator - */ - public void registerIndicator(BaseEvaluator indicator) - { - indicators.add(indicator); - } - - /** - * @param action registered action - */ - public void registerAction(BaseEvaluator action) - { - actions.add(action); - } - - /** - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * Gets the json conversion component cache - * - * @return The json conversion component cache - */ - protected SimpleCache getJsonConversionComponentCache() - { - return this.jsonConversionComponentCache; - } - - /** - * Sets the json conversion component cache - * - * @param jsonConversionComponentCache The json conversion component cache - */ - public void setJsonConversionComponentCache(SimpleCache jsonConversionComponentCache) - { - this.jsonConversionComponentCache = jsonConversionComponentCache; - } - - /** - * The initialise method - */ - public void init() - { - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), - RecordsManagementModel.TYPE_RM_SITE, - new JavaBehaviour(this, "onDeleteNode")); - - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - RecordsManagementModel.TYPE_RM_SITE, - new JavaBehaviour(this, "onCreateNode")); - } - - /** - * @see org.alfresco.repo.jscript.app.JSONConversionComponent#setRootValues(org.alfresco.service.cmr.model.FileInfo, - * org.json.simple.JSONObject, boolean) - */ - @SuppressWarnings("unchecked") - @Override - protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames) - { - if (nodeInfo != null) - { - // Set the base root values - super.setRootValues(nodeInfo, rootJSONObject, useShortQNames); - - // check the exisitance of the RM site - checkRmSiteExistence(rootJSONObject); - - // get the record contributor information - rootJSONObject.put(IS_RECORD_CONTRIBUTOR_GROUP_ENABLED, isRecordContributorsGroupEnabled); - rootJSONObject.put(RECORD_CONTRIBUTOR_GROUP_NAME, recordContributorsGroupName); - - // Get the node reference for convenience - NodeRef nodeRef = nodeInfo.getNodeRef(); - - if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, ViewRecordsCapability.NAME))) - { - // Indicate whether the node is a RM object or not - boolean isFilePlanComponent = filePlanService.isFilePlanComponent(nodeInfo.getNodeRef()); - rootJSONObject.put(IS_RM_NODE, isFilePlanComponent); - - if (isFilePlanComponent) - { - rootJSONObject.put(RM_NODE, setRmNodeValues(nodeRef, useShortQNames)); - - // FIXME: Is this the right place to add the information? - addInfo(nodeInfo, rootJSONObject); - } - } - } - } - - /** - * Checks for the existance of the RM site - * - * @param rootJSONObject the root JSON object - */ - @SuppressWarnings("unchecked") - private void checkRmSiteExistence(JSONObject rootJSONObject) - { - if (!getJsonConversionComponentCache().contains(RM_SITE_EXISTS)) - { - SiteInfo site = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID); - if (site != null) - { - getJsonConversionComponentCache().put(RM_SITE_EXISTS, true); - rootJSONObject.put(IS_RM_SITE_CREATED, true); - } - else - { - getJsonConversionComponentCache().put(RM_SITE_EXISTS, false); - rootJSONObject.put(IS_RM_SITE_CREATED, false); - } - } - else - { - rootJSONObject.put(IS_RM_SITE_CREATED, getJsonConversionComponentCache().get(RM_SITE_EXISTS)); - } - } - - /** - * Helper method to add information about node - * - * @param nodeInfo node information - * @param rootJSONObject root JSON object - */ - @SuppressWarnings("unchecked") - private void addInfo(final FileInfo nodeInfo, JSONObject rootJSONObject) - { - String itemType = (String) rootJSONObject.get("type"); - final QName itemTypeQName = QName.createQName(itemType, namespaceService); - - NodeRef originatingLocation = AuthenticationUtil.runAsSystem(new RunAsWork() - { - public NodeRef doWork() - { - NodeRef originatingLocation = null; - - if (dictionaryService.isSubClass(itemTypeQName, ContentModel.TYPE_CONTENT)) - { - NodeRef nodeRef = nodeInfo.getNodeRef(); - List parentAssocs = nodeService.getParentAssocs(nodeRef); - - for (ChildAssociationRef parent : parentAssocs) - { - // FIXME: What if there is more than a secondary parent? - if (!parent.isPrimary()) - { - originatingLocation = parent.getParentRef(); - - // only consider the non-RM parent otherwise we can - // run into issues with frozen or transferring records - if (!nodeService.hasAspect(originatingLocation, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - // assume we have found the correct in-place location - // FIXME when we support multiple in-place locations - break; - } - } - } - } - - return originatingLocation; - } - }); - - if (originatingLocation != null) - { - // add the originating location (if there is one) - String pathSeparator = "/"; - String displayPath = getDisplayPath(originatingLocation); - String[] displayPathElements = displayPath.split(pathSeparator); - Object[] subPath = ArrayUtils.subarray(displayPathElements, 5, displayPathElements.length); - StringBuffer originatingLocationPath = new StringBuffer(); - for (int i = 0; i < subPath.length; i++) - { - originatingLocationPath.append(pathSeparator).append(subPath[i]); - } - rootJSONObject.put("originatingLocationPath", originatingLocationPath.toString()); - } - } - - /** - * Helper method to get the display path. - * - * @param nodeRef node reference - * @return String display path - */ - private String getDisplayPath(final NodeRef nodeRef) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - public String doWork() throws Exception - { - return PathUtil.getDisplayPath(nodeService.getPath(nodeRef), true); - } - }, AuthenticationUtil.getAdminUserName()); - } - - /** - * Helper method to set the RM node values - * - * @param nodeRef node reference - * @param useShortQName indicates whether the short QName are used or not - * @return {@link JSONObject} JSON object containing values - */ - @SuppressWarnings("unchecked") - private JSONObject setRmNodeValues(final NodeRef nodeRef, final boolean useShortQName) - { - JSONObject rmNodeValues = new JSONObject(); - - // UI convenience type - rmNodeValues.put("uiType", getUIType(nodeRef)); - - // Get the 'kind' of the file plan component - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - rmNodeValues.put("kind", kind.toString()); - - // set the primary parent node reference - ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); - if (assoc != null) - { - rmNodeValues.put("primaryParentNodeRef", assoc.getParentRef().toString()); - } - - Map values = AuthenticationUtil.runAsSystem(new RunAsWork>() - { - public Map doWork() throws Exception - { - Map result = new HashMap(); - - // File plan node reference - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - result.put("filePlan", filePlan.toString()); - - // Unfiled container node reference - NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); - if (unfiledRecordContainer != null) - { - result.put("unfiledRecordContainer", unfiledRecordContainer.toString()); - result.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName)); - QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); - result.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); - } - - return result; - } - }); - - rmNodeValues.putAll(values); - - // Set the indicators array - setIndicators(rmNodeValues, nodeRef); - - // Set the actions array - setActions(rmNodeValues, nodeRef); - - return rmNodeValues; - } - - @SuppressWarnings("unchecked") - private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef) - { - if (indicators != null && !indicators.isEmpty()) - { - JSONArray jsonIndicators = new JSONArray(); - - for (BaseEvaluator indicator : indicators) - { - if (indicator.evaluate(nodeRef)) - { - jsonIndicators.add(indicator.getName()); - } - } - - rmNodeValues.put("indicators", jsonIndicators); - } - } - - @SuppressWarnings("unchecked") - private void setActions(JSONObject rmNodeValues, NodeRef nodeRef) - { - if (actions != null && !actions.isEmpty()) - { - JSONArray jsonActions = new JSONArray(); - - for (BaseEvaluator action : actions) - { - if (action.evaluate(nodeRef)) - { - jsonActions.add(action.getName()); - } - } - - rmNodeValues.put("actions", jsonActions); - } - } - - /** - * @see org.alfresco.repo.jscript.app.JSONConversionComponent#permissionsToJSON(org.alfresco.service.cmr.repository.NodeRef) - */ - protected JSONObject permissionsToJSON(final NodeRef nodeRef) - { - JSONObject permissionsJSON = null; - if (!filePlanService.isFilePlanComponent(nodeRef)) - { - permissionsJSON = super.permissionsToJSON(nodeRef); - } - else - { - permissionsJSON = new JSONObject(); - } - return permissionsJSON; - } - - /** - * Gets the rm 'type' used as a UI convenience and compatibility flag. - */ - private String getUIType(NodeRef nodeRef) - { - String result = "unknown"; - - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - if (kind != null) - { - switch (kind) - { - case FILE_PLAN: - { - result = "fileplan"; - break; - } - case RECORD_CATEGORY: - { - result = "record-category"; - break; - } - case RECORD_FOLDER: - { - if (recordService.isMetadataStub(nodeRef)) - { - result = "metadata-stub-folder"; - } - else - { - result = "record-folder"; - } - break; - } - case RECORD: - { - if (recordService.isMetadataStub(nodeRef)) - { - result = "metadata-stub"; - } - else - { - if (recordService.isDeclared(nodeRef)) - { - result = "record"; - } - else - { - result = "undeclared-record"; - } - } - break; - } - case HOLD: - { - result = "hold"; - break; - } - case TRANSFER: - { - result = "transfer-container"; - break; - } - case UNFILED_RECORD_FOLDER: - { - result = "unfiled-record-folder"; - break; - } - default: - { - break; - } - } - } - - return result; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) - { - getJsonConversionComponentCache().put(RM_SITE_EXISTS, false); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - public void onCreateNode(ChildAssociationRef childAssocRef) - { - getJsonConversionComponentCache().put(RM_SITE_EXISTS, true); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.PathUtil; +import org.apache.commons.lang.ArrayUtils; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; + +/** + * Extend JSON conversion component to include RM specifics. + * + * @author Roy Wetherall + */ +public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent + implements NodeServicePolicies.OnDeleteNodePolicy, + NodeServicePolicies.OnCreateNodePolicy +{ + /** JSON values */ + private static final String IS_RM_NODE = "isRmNode"; + private static final String RM_NODE = "rmNode"; + private static final String IS_RM_SITE_CREATED = "isRmSiteCreated"; + private static final String IS_RECORD_CONTRIBUTOR_GROUP_ENABLED = "isRecordContributorGroupEnabled"; + private static final String RECORD_CONTRIBUTOR_GROUP_NAME = "recordContributorGroupName"; + + /** true if record contributor group is enabled, false otherwise */ + private boolean isRecordContributorsGroupEnabled = false; + + /** record contributors group */ + private String recordContributorsGroupName = "RECORD_CONTRIBUTORS"; + + /** Record service */ + private RecordService recordService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Capability service */ + private CapabilityService capabilityService; + + /** dictionary service */ + private DictionaryService dictionaryService; + + /** site service */ + private SiteService siteService; + + /** Indicators */ + private List indicators = new ArrayList(); + + /** Actions */ + private List actions = new ArrayList(); + + /** The policy component */ + private PolicyComponent policyComponent; + + /** JSON conversion component cache */ + private SimpleCache jsonConversionComponentCache; + + /** Constant for checking the cache */ + private static final String RM_SITE_EXISTS = "rmSiteExists"; + + /** + * @param enabled true if enabled, false otherwise + */ + public void setRecordContributorsGroupEnabled(boolean enabled) + { + isRecordContributorsGroupEnabled = enabled; + } + + /** + * @param recordContributorsGroupName record contributors group name + */ + public void setRecordContributorsGroupName(String recordContributorsGroupName) + { + this.recordContributorsGroupName = recordContributorsGroupName; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param indicator registered indicator + */ + public void registerIndicator(BaseEvaluator indicator) + { + indicators.add(indicator); + } + + /** + * @param action registered action + */ + public void registerAction(BaseEvaluator action) + { + actions.add(action); + } + + /** + * @param policyComponent policy component + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * Gets the json conversion component cache + * + * @return The json conversion component cache + */ + protected SimpleCache getJsonConversionComponentCache() + { + return this.jsonConversionComponentCache; + } + + /** + * Sets the json conversion component cache + * + * @param jsonConversionComponentCache The json conversion component cache + */ + public void setJsonConversionComponentCache(SimpleCache jsonConversionComponentCache) + { + this.jsonConversionComponentCache = jsonConversionComponentCache; + } + + /** + * The initialise method + */ + public void init() + { + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), + RecordsManagementModel.TYPE_RM_SITE, + new JavaBehaviour(this, "onDeleteNode")); + + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + RecordsManagementModel.TYPE_RM_SITE, + new JavaBehaviour(this, "onCreateNode")); + } + + /** + * @see org.alfresco.repo.jscript.app.JSONConversionComponent#setRootValues(org.alfresco.service.cmr.model.FileInfo, + * org.json.simple.JSONObject, boolean) + */ + @SuppressWarnings("unchecked") + @Override + protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames) + { + if (nodeInfo != null) + { + // Set the base root values + super.setRootValues(nodeInfo, rootJSONObject, useShortQNames); + + // check the exisitance of the RM site + checkRmSiteExistence(rootJSONObject); + + // get the record contributor information + rootJSONObject.put(IS_RECORD_CONTRIBUTOR_GROUP_ENABLED, isRecordContributorsGroupEnabled); + rootJSONObject.put(RECORD_CONTRIBUTOR_GROUP_NAME, recordContributorsGroupName); + + // Get the node reference for convenience + NodeRef nodeRef = nodeInfo.getNodeRef(); + + if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, ViewRecordsCapability.NAME))) + { + // Indicate whether the node is a RM object or not + boolean isFilePlanComponent = filePlanService.isFilePlanComponent(nodeInfo.getNodeRef()); + rootJSONObject.put(IS_RM_NODE, isFilePlanComponent); + + if (isFilePlanComponent) + { + rootJSONObject.put(RM_NODE, setRmNodeValues(nodeRef, useShortQNames)); + + // FIXME: Is this the right place to add the information? + addInfo(nodeInfo, rootJSONObject); + } + } + } + } + + /** + * Checks for the existance of the RM site + * + * @param rootJSONObject the root JSON object + */ + @SuppressWarnings("unchecked") + private void checkRmSiteExistence(JSONObject rootJSONObject) + { + if (!getJsonConversionComponentCache().contains(RM_SITE_EXISTS)) + { + SiteInfo site = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID); + if (site != null) + { + getJsonConversionComponentCache().put(RM_SITE_EXISTS, true); + rootJSONObject.put(IS_RM_SITE_CREATED, true); + } + else + { + getJsonConversionComponentCache().put(RM_SITE_EXISTS, false); + rootJSONObject.put(IS_RM_SITE_CREATED, false); + } + } + else + { + rootJSONObject.put(IS_RM_SITE_CREATED, getJsonConversionComponentCache().get(RM_SITE_EXISTS)); + } + } + + /** + * Helper method to add information about node + * + * @param nodeInfo node information + * @param rootJSONObject root JSON object + */ + @SuppressWarnings("unchecked") + private void addInfo(final FileInfo nodeInfo, JSONObject rootJSONObject) + { + String itemType = (String) rootJSONObject.get("type"); + final QName itemTypeQName = QName.createQName(itemType, namespaceService); + + NodeRef originatingLocation = AuthenticationUtil.runAsSystem(new RunAsWork() + { + public NodeRef doWork() + { + NodeRef originatingLocation = null; + + if (dictionaryService.isSubClass(itemTypeQName, ContentModel.TYPE_CONTENT)) + { + NodeRef nodeRef = nodeInfo.getNodeRef(); + List parentAssocs = nodeService.getParentAssocs(nodeRef); + + for (ChildAssociationRef parent : parentAssocs) + { + // FIXME: What if there is more than a secondary parent? + if (!parent.isPrimary()) + { + originatingLocation = parent.getParentRef(); + + // only consider the non-RM parent otherwise we can + // run into issues with frozen or transferring records + if (!nodeService.hasAspect(originatingLocation, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + // assume we have found the correct in-place location + // FIXME when we support multiple in-place locations + break; + } + } + } + } + + return originatingLocation; + } + }); + + if (originatingLocation != null) + { + // add the originating location (if there is one) + String pathSeparator = "/"; + String displayPath = getDisplayPath(originatingLocation); + String[] displayPathElements = displayPath.split(pathSeparator); + Object[] subPath = ArrayUtils.subarray(displayPathElements, 5, displayPathElements.length); + StringBuffer originatingLocationPath = new StringBuffer(); + for (int i = 0; i < subPath.length; i++) + { + originatingLocationPath.append(pathSeparator).append(subPath[i]); + } + rootJSONObject.put("originatingLocationPath", originatingLocationPath.toString()); + } + } + + /** + * Helper method to get the display path. + * + * @param nodeRef node reference + * @return String display path + */ + private String getDisplayPath(final NodeRef nodeRef) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + public String doWork() throws Exception + { + return PathUtil.getDisplayPath(nodeService.getPath(nodeRef), true); + } + }, AuthenticationUtil.getAdminUserName()); + } + + /** + * Helper method to set the RM node values + * + * @param nodeRef node reference + * @param useShortQName indicates whether the short QName are used or not + * @return {@link JSONObject} JSON object containing values + */ + @SuppressWarnings("unchecked") + private JSONObject setRmNodeValues(final NodeRef nodeRef, final boolean useShortQName) + { + JSONObject rmNodeValues = new JSONObject(); + + // UI convenience type + rmNodeValues.put("uiType", getUIType(nodeRef)); + + // Get the 'kind' of the file plan component + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + rmNodeValues.put("kind", kind.toString()); + + // set the primary parent node reference + ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); + if (assoc != null) + { + rmNodeValues.put("primaryParentNodeRef", assoc.getParentRef().toString()); + } + + Map values = AuthenticationUtil.runAsSystem(new RunAsWork>() + { + public Map doWork() throws Exception + { + Map result = new HashMap(); + + // File plan node reference + NodeRef filePlan = filePlanService.getFilePlan(nodeRef); + result.put("filePlan", filePlan.toString()); + + // Unfiled container node reference + NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); + if (unfiledRecordContainer != null) + { + result.put("unfiledRecordContainer", unfiledRecordContainer.toString()); + result.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName)); + QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); + result.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); + } + + return result; + } + }); + + rmNodeValues.putAll(values); + + // Set the indicators array + setIndicators(rmNodeValues, nodeRef); + + // Set the actions array + setActions(rmNodeValues, nodeRef); + + return rmNodeValues; + } + + @SuppressWarnings("unchecked") + private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef) + { + if (indicators != null && !indicators.isEmpty()) + { + JSONArray jsonIndicators = new JSONArray(); + + for (BaseEvaluator indicator : indicators) + { + if (indicator.evaluate(nodeRef)) + { + jsonIndicators.add(indicator.getName()); + } + } + + rmNodeValues.put("indicators", jsonIndicators); + } + } + + @SuppressWarnings("unchecked") + private void setActions(JSONObject rmNodeValues, NodeRef nodeRef) + { + if (actions != null && !actions.isEmpty()) + { + JSONArray jsonActions = new JSONArray(); + + for (BaseEvaluator action : actions) + { + if (action.evaluate(nodeRef)) + { + jsonActions.add(action.getName()); + } + } + + rmNodeValues.put("actions", jsonActions); + } + } + + /** + * @see org.alfresco.repo.jscript.app.JSONConversionComponent#permissionsToJSON(org.alfresco.service.cmr.repository.NodeRef) + */ + protected JSONObject permissionsToJSON(final NodeRef nodeRef) + { + JSONObject permissionsJSON = null; + if (!filePlanService.isFilePlanComponent(nodeRef)) + { + permissionsJSON = super.permissionsToJSON(nodeRef); + } + else + { + permissionsJSON = new JSONObject(); + } + return permissionsJSON; + } + + /** + * Gets the rm 'type' used as a UI convenience and compatibility flag. + */ + private String getUIType(NodeRef nodeRef) + { + String result = "unknown"; + + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + if (kind != null) + { + switch (kind) + { + case FILE_PLAN: + { + result = "fileplan"; + break; + } + case RECORD_CATEGORY: + { + result = "record-category"; + break; + } + case RECORD_FOLDER: + { + if (recordService.isMetadataStub(nodeRef)) + { + result = "metadata-stub-folder"; + } + else + { + result = "record-folder"; + } + break; + } + case RECORD: + { + if (recordService.isMetadataStub(nodeRef)) + { + result = "metadata-stub"; + } + else + { + if (recordService.isDeclared(nodeRef)) + { + result = "record"; + } + else + { + result = "undeclared-record"; + } + } + break; + } + case HOLD: + { + result = "hold"; + break; + } + case TRANSFER: + { + result = "transfer-container"; + break; + } + case UNFILED_RECORD_FOLDER: + { + result = "unfiled-record-folder"; + break; + } + default: + { + break; + } + } + } + + return result; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + getJsonConversionComponentCache().put(RM_SITE_EXISTS, false); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + public void onCreateNode(ChildAssociationRef childAssocRef) + { + getJsonConversionComponentCache().put(RM_SITE_EXISTS, true); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java index 4ec8c1e610..5b4b73099f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Cutoff indicator - * - * @author Roy Wetherall - */ -public class CutoffEvaluator extends BaseEvaluator -{ - private boolean isCutoff = true; - - public void setCutoff(boolean isCutoff) - { - this.isCutoff = isCutoff; - } - - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - return (dispositionService.isDisposableItemCutoff(nodeRef) == isCutoff); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Cutoff indicator + * + * @author Roy Wetherall + */ +public class CutoffEvaluator extends BaseEvaluator +{ + private boolean isCutoff = true; + + public void setCutoff(boolean isCutoff) + { + this.isCutoff = isCutoff; + } + + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + return (dispositionService.isDisposableItemCutoff(nodeRef) == isCutoff); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/EditRecordMetadataActionEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/EditRecordMetadataActionEvaluator.java index c71133e35b..55a862e026 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/EditRecordMetadataActionEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/EditRecordMetadataActionEvaluator.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Additional action evaluator, disabling action if there are no record metadata aspects - * available for the node. - * - * @author Roy Wetherall - */ -public class EditRecordMetadataActionEvaluator extends BaseEvaluator -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - return !recordService.getRecordMetadataAspects(nodeRef).isEmpty(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Additional action evaluator, disabling action if there are no record metadata aspects + * available for the node. + * + * @author Roy Wetherall + */ +public class EditRecordMetadataActionEvaluator extends BaseEvaluator +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + return !recordService.getRecordMetadataAspects(nodeRef).isEmpty(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java index a922775f47..ab8104332d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class FolderOpenClosedEvaluator extends BaseEvaluator -{ - private boolean expected = true; - - public void setExpected(boolean expected) - { - this.expected = expected; - } - - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - return (recordFolderService.isRecordFolderClosed(nodeRef) == expected); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class FolderOpenClosedEvaluator extends BaseEvaluator +{ + private boolean expected = true; + + public void setExpected(boolean expected) + { + this.expected = expected; + } + + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + return (recordFolderService.isRecordFolderClosed(nodeRef) == expected); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluator.java index b646fbf966..150982bbc5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluator.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Freeze indicator. - *

- * Only shows as frozen if the user can 'read' the holds - * that hold the nodeRef. - * - * @author Roy Wetherall - */ -public class FrozenEvaluator extends BaseEvaluator -{ - /** hold service */ - private HoldService holdService; - - /** - * @param holdService hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - /** - * Only indicate the node is frozen if the user can 'read' at least one of the holds - * - * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - List heldBy = holdService.heldBy(nodeRef, true); - return !heldBy.isEmpty(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Freeze indicator. + *

+ * Only shows as frozen if the user can 'read' the holds + * that hold the nodeRef. + * + * @author Roy Wetherall + */ +public class FrozenEvaluator extends BaseEvaluator +{ + /** hold service */ + private HoldService holdService; + + /** + * @param holdService hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * Only indicate the node is frozen if the user can 'read' at least one of the holds + * + * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + List heldBy = holdService.heldBy(nodeRef, true); + return !heldBy.isEmpty(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/HasAspectEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/HasAspectEvaluator.java index ded433c691..9740bda348 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/HasAspectEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/HasAspectEvaluator.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Transfered indicator - * - * @author Roy Wetherall - */ -public class HasAspectEvaluator extends BaseEvaluator -{ - private String prefixAspectQNameString; - - public void setAspect(String aspect) - { - prefixAspectQNameString = aspect; - } - - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - QName aspect = QName.createQName(prefixAspectQNameString, namespaceService); - return nodeService.hasAspect(nodeRef, aspect); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Transfered indicator + * + * @author Roy Wetherall + */ +public class HasAspectEvaluator extends BaseEvaluator +{ + private String prefixAspectQNameString; + + public void setAspect(String aspect) + { + prefixAspectQNameString = aspect; + } + + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + QName aspect = QName.createQName(prefixAspectQNameString, namespaceService); + return nodeService.hasAspect(nodeRef, aspect); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/MultiParentEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/MultiParentEvaluator.java index a3c3ca8d29..c4de941feb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/MultiParentEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/MultiParentEvaluator.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Determines whether a node has multiple parents within a file plan - * - * @author Roy Wetherall - * @since 2.0 - */ -public class MultiParentEvaluator extends BaseEvaluator -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(final NodeRef nodeRef) - { - return AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Boolean doWork() - { - - // get parent associations - List parents = nodeService.getParentAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - int count = 0; - for (ChildAssociationRef parent : parents) - { - // count file plan component parents - if (nodeService.hasAspect(parent.getParentRef(), ASPECT_FILE_PLAN_COMPONENT)) - { - count++; - } - } - - // return true if more than one - return (count > 1); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Determines whether a node has multiple parents within a file plan + * + * @author Roy Wetherall + * @since 2.0 + */ +public class MultiParentEvaluator extends BaseEvaluator +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(final NodeRef nodeRef) + { + return AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Boolean doWork() + { + + // get parent associations + List parents = nodeService.getParentAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + int count = 0; + for (ChildAssociationRef parent : parents) + { + // count file plan component parents + if (nodeService.hasAspect(parent.getParentRef(), ASPECT_FILE_PLAN_COMPONENT)) + { + count++; + } + } + + // return true if more than one + return (count > 1); + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/NonElectronicEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/NonElectronicEvaluator.java index 6d16ccf243..267713a8f1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/NonElectronicEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/NonElectronicEvaluator.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - */ -public class NonElectronicEvaluator extends BaseEvaluator -{ - private DictionaryService dictionaryService; - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - QName qName = nodeService.getType(nodeRef); - if (qName != null && dictionaryService.isSubClass(qName, TYPE_NON_ELECTRONIC_DOCUMENT)) - { - result = true; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + */ +public class NonElectronicEvaluator extends BaseEvaluator +{ + private DictionaryService dictionaryService; + + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + QName qName = nodeService.getType(nodeRef); + if (qName != null && dictionaryService.isSubClass(qName, TYPE_NON_ELECTRONIC_DOCUMENT)) + { + result = true; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/SplitEmailActionEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/SplitEmailActionEvaluator.java index 83d31c0001..aae5361353 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/SplitEmailActionEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/SplitEmailActionEvaluator.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Split EMail action evaluator - * - * @author Roy Wetherall - */ -public class SplitEmailActionEvaluator extends BaseEvaluator -{ - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - if (!recordService.isDeclared(nodeRef)) - { - ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); - if (contentData != null) - { - String mimetype = contentData.getMimetype(); - if (mimetype != null && - (MimetypeMap.MIMETYPE_RFC822.equals(mimetype) || - MimetypeMap.MIMETYPE_OUTLOOK_MSG.equals(mimetype))) - { - result = true; - } - } - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Split EMail action evaluator + * + * @author Roy Wetherall + */ +public class SplitEmailActionEvaluator extends BaseEvaluator +{ + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + if (!recordService.isDeclared(nodeRef)) + { + ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); + if (contentData != null) + { + String mimetype = contentData.getMimetype(); + if (mimetype != null && + (MimetypeMap.MIMETYPE_RFC822.equals(mimetype) || + MimetypeMap.MIMETYPE_OUTLOOK_MSG.equals(mimetype))) + { + result = true; + } + } + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluator.java index 56cb735b6a..ac76ddaf8b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluator.java @@ -1,116 +1,116 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Evaluates whether the node in question is transferring is either a transfer or accession. - * - * @author Roy Wetherall - */ -public class TransferEvaluator extends BaseEvaluator -{ - /** Logger */ - private static Log logger = LogFactory.getLog(TransferEvaluator.class); - - /** indicates whether we are looking for accessions or transfers */ - private boolean transferAccessionIndicator = false; - - /** - * @param transferAccessionIndicator true if accession, false otherwise - */ - public void setTransferAccessionIndicator(boolean transferAccessionIndicator) - { - this.transferAccessionIndicator = transferAccessionIndicator; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - boolean result = false; - - NodeRef transfer = getTransferNodeRef(nodeRef); - if (transfer != null) - { - try - { - boolean actual = ((Boolean)nodeService.getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR)).booleanValue(); - result = (actual == transferAccessionIndicator); - } - catch (AccessDeniedException ade) - { - logger.info("The user '" - + AuthenticationUtil.getFullyAuthenticatedUser() - + "' does not have permissions on the node '" - + transfer + "'."); - } - } - - return result; - } - - /** - * Helper method to get the transfer node reference. - *

- * Takes into account records in tranferred record folders. - * - * @param nodeRef node reference - * @return {@link NodeRef} transfer node - */ - private NodeRef getTransferNodeRef(NodeRef nodeRef) - { - NodeRef result = null; - - List parents = nodeService.getParentAssocs(nodeRef, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - if (parents.size() == 1) - { - result = parents.get(0).getParentRef(); - } - else - { - if (recordService.isRecord(nodeRef)) - { - for (NodeRef recordFolder : recordFolderService.getRecordFolders(nodeRef)) - { - result = getTransferNodeRef(recordFolder); - if (result != null) - { - break; - } - } - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Evaluates whether the node in question is transferring is either a transfer or accession. + * + * @author Roy Wetherall + */ +public class TransferEvaluator extends BaseEvaluator +{ + /** Logger */ + private static Log logger = LogFactory.getLog(TransferEvaluator.class); + + /** indicates whether we are looking for accessions or transfers */ + private boolean transferAccessionIndicator = false; + + /** + * @param transferAccessionIndicator true if accession, false otherwise + */ + public void setTransferAccessionIndicator(boolean transferAccessionIndicator) + { + this.transferAccessionIndicator = transferAccessionIndicator; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + boolean result = false; + + NodeRef transfer = getTransferNodeRef(nodeRef); + if (transfer != null) + { + try + { + boolean actual = ((Boolean)nodeService.getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR)).booleanValue(); + result = (actual == transferAccessionIndicator); + } + catch (AccessDeniedException ade) + { + logger.info("The user '" + + AuthenticationUtil.getFullyAuthenticatedUser() + + "' does not have permissions on the node '" + + transfer + "'."); + } + } + + return result; + } + + /** + * Helper method to get the transfer node reference. + *

+ * Takes into account records in tranferred record folders. + * + * @param nodeRef node reference + * @return {@link NodeRef} transfer node + */ + private NodeRef getTransferNodeRef(NodeRef nodeRef) + { + NodeRef result = null; + + List parents = nodeService.getParentAssocs(nodeRef, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + if (parents.size() == 1) + { + result = parents.get(0).getParentRef(); + } + else + { + if (recordService.isRecord(nodeRef)) + { + for (NodeRef recordFolder : recordFolderService.getRecordFolders(nodeRef)) + { + result = getTransferNodeRef(recordFolder); + if (result != null) + { + break; + } + } + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TrueEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TrueEvaluator.java index b4ca723257..326d9cd833 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TrueEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TrueEvaluator.java @@ -1,36 +1,36 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Cutoff indicator - * - * @author Roy Wetherall - */ -public class TrueEvaluator extends BaseEvaluator -{ - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - return true; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Cutoff indicator + * + * @author Roy Wetherall + */ +public class TrueEvaluator extends BaseEvaluator +{ + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + return true; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/VitalRecordEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/VitalRecordEvaluator.java index a7cb201d88..499a29eddc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/VitalRecordEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/VitalRecordEvaluator.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - */ -public class VitalRecordEvaluator extends BaseEvaluator -{ - private VitalRecordService vitalRecordService; - - public void setVitalRecordService(VitalRecordService vitalRecordService) - { - this.vitalRecordService = vitalRecordService; - } - - @Override - protected boolean evaluateImpl(NodeRef nodeRef) - { - return vitalRecordService.isVitalRecord(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.BaseEvaluator; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public class VitalRecordEvaluator extends BaseEvaluator +{ + private VitalRecordService vitalRecordService; + + public void setVitalRecordService(VitalRecordService vitalRecordService) + { + this.vitalRecordService = vitalRecordService; + } + + @Override + protected boolean evaluateImpl(NodeRef nodeRef) + { + return vitalRecordService.isVitalRecord(nodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/BaseBehaviourBean.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/BaseBehaviourBean.java index a75a6607fa..d582a8c115 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/BaseBehaviourBean.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/BaseBehaviourBean.java @@ -1,66 +1,66 @@ -/** - * - */ -package org.alfresco.module.org_alfresco_module_rm.model; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.policy.annotation.BehaviourRegistry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Convenient base class for behaviour beans. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class BaseBehaviourBean extends ServiceBaseImpl - implements RecordsManagementModel, - BehaviourRegistry -{ - /** Logger */ - protected static final Log LOGGER = LogFactory.getLog(BaseBehaviourBean.class); - - /** behaviour filter */ - protected BehaviourFilter behaviourFilter; - - /** behaviour map */ - protected Map behaviours = new HashMap(7); - - /** - * @param behaviourFilter behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * @see org.alfresco.repo.policy.annotation.BehaviourRegistry#registerBehaviour(java.lang.String, org.alfresco.repo.policy.Behaviour) - */ - @Override - public void registerBehaviour(String name, org.alfresco.repo.policy.Behaviour behaviour) - { - if (behaviours.containsKey(name)) - { - throw new AlfrescoRuntimeException("Can not register behaviour, because name " + name + "has already been used."); - } - - behaviours.put(name, behaviour); - } - - /** - * @see org.alfresco.repo.policy.annotation.BehaviourRegistry#getBehaviour(java.lang.String) - */ - @Override - public org.alfresco.repo.policy.Behaviour getBehaviour(String name) - { - return behaviours.get(name); - } - -} +/** + * + */ +package org.alfresco.module.org_alfresco_module_rm.model; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.policy.annotation.BehaviourRegistry; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Convenient base class for behaviour beans. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class BaseBehaviourBean extends ServiceBaseImpl + implements RecordsManagementModel, + BehaviourRegistry +{ + /** Logger */ + protected static final Log LOGGER = LogFactory.getLog(BaseBehaviourBean.class); + + /** behaviour filter */ + protected BehaviourFilter behaviourFilter; + + /** behaviour map */ + protected Map behaviours = new HashMap(7); + + /** + * @param behaviourFilter behaviour filter + */ + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * @see org.alfresco.repo.policy.annotation.BehaviourRegistry#registerBehaviour(java.lang.String, org.alfresco.repo.policy.Behaviour) + */ + @Override + public void registerBehaviour(String name, org.alfresco.repo.policy.Behaviour behaviour) + { + if (behaviours.containsKey(name)) + { + throw new AlfrescoRuntimeException("Can not register behaviour, because name " + name + "has already been used."); + } + + behaviours.put(name, behaviour); + } + + /** + * @see org.alfresco.repo.policy.annotation.BehaviourRegistry#getBehaviour(java.lang.String) + */ + @Override + public org.alfresco.repo.policy.Behaviour getBehaviour(String name) + { + return behaviours.get(name); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/CustomisableTypesBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/CustomisableTypesBootstrap.java index f1e908c2af..b6a0af97e5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/CustomisableTypesBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/CustomisableTypesBootstrap.java @@ -1,80 +1,80 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Bootstrap bean that indicates that the specified types or aspects are - * customizable. - * - * @author Roy Wetherall - * @since 2.0 - */ -public class CustomisableTypesBootstrap -{ - /** Records management admin service */ - private RecordsManagementAdminService recordsManagementAdminService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** List of types and aspects to register as customisable */ - private List customisable; - - /** - * @param recordsManagementAdminService records management admin service - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) - { - this.recordsManagementAdminService = recordsManagementAdminService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param customizable list of types and aspects to register as customisable - */ - public void setCustomisable(List customisable) - { - this.customisable = customisable; - } - - /** - * Bean initialisation method - */ - public void init() - { - for (String customType : customisable) - { - QName customTypeQName = QName.createQName(customType, namespaceService); - recordsManagementAdminService.makeCustomisable(customTypeQName); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Bootstrap bean that indicates that the specified types or aspects are + * customizable. + * + * @author Roy Wetherall + * @since 2.0 + */ +public class CustomisableTypesBootstrap +{ + /** Records management admin service */ + private RecordsManagementAdminService recordsManagementAdminService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** List of types and aspects to register as customisable */ + private List customisable; + + /** + * @param recordsManagementAdminService records management admin service + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) + { + this.recordsManagementAdminService = recordsManagementAdminService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param customizable list of types and aspects to register as customisable + */ + public void setCustomisable(List customisable) + { + this.customisable = customisable; + } + + /** + * Bean initialisation method + */ + public void init() + { + for (String customType : customisable) + { + QName customTypeQName = QName.createQName(customType, namespaceService); + recordsManagementAdminService.makeCustomisable(customTypeQName); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementCustomModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementCustomModel.java index 9a217e43c9..a616266520 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementCustomModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementCustomModel.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model; - -import org.alfresco.service.namespace.QName; - -/** - * Helper class containing records management custom model qualified names - * - * @author Gavin Cornwell - */ -public interface RecordsManagementCustomModel -{ - // Namespace details - String RM_CUSTOM_URI = "http://www.alfresco.org/model/rmcustom/1.0"; - String RM_CUSTOM_PREFIX = "rmc"; - - // Model - QName RM_CUSTOM_MODEL = QName.createQName(RM_CUSTOM_URI, "rmcustom"); - - // Custom constraint for Supplemental Marking List - QName CONSTRAINT_CUSTOM_SMLIST = QName.createQName(RM_CUSTOM_URI, "smList"); - - // Custom property for for Supplemental Marking List - QName PROP_SUPPLEMENTAL_MARKING_LIST = QName.createQName(RM_CUSTOM_URI, "supplementalMarkingList"); - - // Supplemental Marking List aspect - QName ASPECT_SUPPLEMENTAL_MARKING_LIST = QName.createQName(RM_CUSTOM_URI, "customSupplementalMarkingList"); - - // Custom associations aspect - QName ASPECT_CUSTOM_ASSOCIATIONS = QName.createQName(RM_CUSTOM_URI, "customAssocs"); - - // Some Custom references which are present on system startup. - QName CUSTOM_REF_VERSIONS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "versions"); - QName CUSTOM_REF_SUPERSEDES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supersedes"); - QName CUSTOM_REF_OBSOLETES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "obsoletes"); - QName CUSTOM_REF_SUPPORTS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supports"); - QName CUSTOM_REF_CROSSREFERENCE = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "crossreference"); - QName CUSTOM_REF_RENDITION = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "rendition"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model; + +import org.alfresco.service.namespace.QName; + +/** + * Helper class containing records management custom model qualified names + * + * @author Gavin Cornwell + */ +public interface RecordsManagementCustomModel +{ + // Namespace details + String RM_CUSTOM_URI = "http://www.alfresco.org/model/rmcustom/1.0"; + String RM_CUSTOM_PREFIX = "rmc"; + + // Model + QName RM_CUSTOM_MODEL = QName.createQName(RM_CUSTOM_URI, "rmcustom"); + + // Custom constraint for Supplemental Marking List + QName CONSTRAINT_CUSTOM_SMLIST = QName.createQName(RM_CUSTOM_URI, "smList"); + + // Custom property for for Supplemental Marking List + QName PROP_SUPPLEMENTAL_MARKING_LIST = QName.createQName(RM_CUSTOM_URI, "supplementalMarkingList"); + + // Supplemental Marking List aspect + QName ASPECT_SUPPLEMENTAL_MARKING_LIST = QName.createQName(RM_CUSTOM_URI, "customSupplementalMarkingList"); + + // Custom associations aspect + QName ASPECT_CUSTOM_ASSOCIATIONS = QName.createQName(RM_CUSTOM_URI, "customAssocs"); + + // Some Custom references which are present on system startup. + QName CUSTOM_REF_VERSIONS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "versions"); + QName CUSTOM_REF_SUPERSEDES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supersedes"); + QName CUSTOM_REF_OBSOLETES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "obsoletes"); + QName CUSTOM_REF_SUPPORTS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supports"); + QName CUSTOM_REF_CROSSREFERENCE = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "crossreference"); + QName CUSTOM_REF_RENDITION = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "rendition"); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java index 2736a86f08..406282d648 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java @@ -1,270 +1,270 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model; - -import org.alfresco.service.namespace.QName; - -/** - * Helper class containing records management qualified names - * - * @author Roy Wetherall - */ -public interface RecordsManagementModel extends RecordsManagementCustomModel -{ - // Namespace details - String RM_URI = "http://www.alfresco.org/model/recordsmanagement/1.0"; - String RM_PREFIX = "rma"; - - // Model - QName RM_MODEL = QName.createQName(RM_URI, "recordsmanagement"); - - // RM Site - QName TYPE_RM_SITE = QName.createQName(RM_URI, "rmsite"); - - // Caveat config - QName TYPE_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfig"); - - QName ASPECT_CAVEAT_CONFIG_ROOT = QName.createQName(RM_URI, "caveatConfigRoot"); - QName ASSOC_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfigAssoc"); - - // Email config - QName TYPE_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfig"); - QName ASPECT_EMAIL_CONFIG_ROOT = QName.createQName(RM_URI, "emailConfigRoot"); - QName ASSOC_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfigAssoc"); - - // Records management container - QName TYPE_RECORDS_MANAGEMENT_CONTAINER = QName.createQName(RM_URI, "recordsManagementContainer"); - - // Record Category - QName TYPE_RECORD_CATEGORY = QName.createQName(RM_URI, "recordCategory"); - - // Records management root container - QName TYPE_FILE_PLAN = QName.createQName(RM_URI, "filePlan"); - - // Unfiled record container - QName TYPE_UNFILED_RECORD_CONTAINER = QName.createQName(RM_URI, "unfiledRecordContainer"); - - // Unfiled record folder - QName TYPE_UNFILED_RECORD_FOLDER = QName.createQName(RM_URI, "unfiledRecordFolder"); - - // Hold container - QName TYPE_HOLD_CONTAINER = QName.createQName(RM_URI, "holdContainer"); - - // Transfer container - QName TYPE_TRANSFER_CONTAINER = QName.createQName(RM_URI, "transferContainer"); - - // Disposition instructions aspect - QName ASPECT_SCHEDULED = QName.createQName(RM_URI, "scheduled"); - QName ASSOC_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule"); - - // Disposition definition type - QName TYPE_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule"); - QName PROP_DISPOSITION_AUTHORITY = QName.createQName(RM_URI, "dispositionAuthority"); - QName PROP_DISPOSITION_INSTRUCTIONS = QName.createQName(RM_URI, "dispositionInstructions"); - QName PROP_RECORD_LEVEL_DISPOSITION = QName.createQName(RM_URI, "recordLevelDisposition"); - QName ASSOC_DISPOSITION_ACTION_DEFINITIONS = QName.createQName(RM_URI, "dispositionActionDefinitions"); - - // Disposition action type - QName TYPE_DISPOSITION_ACTION_DEFINITION = QName.createQName(RM_URI, "dispositionActionDefinition"); - QName PROP_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "dispositionActionName"); - QName PROP_DISPOSITION_DESCRIPTION = QName.createQName(RM_URI, "dispositionDescription"); - QName PROP_DISPOSITION_PERIOD = QName.createQName(RM_URI, "dispositionPeriod"); - QName PROP_DISPOSITION_PERIOD_PROPERTY = QName.createQName(RM_URI, "dispositionPeriodProperty"); - QName PROP_DISPOSITION_EVENT = QName.createQName(RM_URI, "dispositionEvent"); - QName PROP_DISPOSITION_EVENT_COMBINATION = QName.createQName(RM_URI, "dispositionEventCombination"); - QName PROP_DISPOSITION_LOCATION = QName.createQName(RM_URI, "dispositionLocation"); - QName PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY = QName.createQName(RM_URI, "dispositionActionGhostOnDestroy"); - - // Records folder - QName TYPE_RECORD_FOLDER = QName.createQName(RM_URI, "recordFolder"); - QName PROP_IS_CLOSED = QName.createQName(RM_URI, "isClosed"); - - // Declared record aspect - QName ASPECT_DECLARED_RECORD = QName.createQName(RM_URI, "declaredRecord"); - QName PROP_DECLARED_AT = QName.createQName(RM_URI, "declaredAt"); - QName PROP_DECLARED_BY = QName.createQName(RM_URI, "declaredBy"); - - // Record aspect - QName ASPECT_RECORD = QName.createQName(RM_URI, "record"); - QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled"); - QName PROP_ORIGIONAL_NAME = QName.createQName(RM_URI, "origionalName"); - - // Common record details - QName PROP_LOCATION = QName.createQName(RM_URI, "location"); - - // Fileable aspect - QName ASPECT_FILABLE = QName.createQName(RM_URI, "fileable"); - - // Record component identifier aspect - QName ASPECT_RECORD_COMPONENT_ID = QName.createQName(RM_URI, "recordComponentIdentifier"); - QName PROP_IDENTIFIER = QName.createQName(RM_URI, "identifier"); - QName PROP_DB_UNIQUENESS_ID = QName.createQName(RM_URI, "dbUniquenessId"); - - // Vital record definition aspect - QName ASPECT_VITAL_RECORD_DEFINITION = QName.createQName(RM_URI, "vitalRecordDefinition"); - QName PROP_VITAL_RECORD_INDICATOR = QName.createQName(RM_URI, "vitalRecordIndicator"); - QName PROP_REVIEW_PERIOD = QName.createQName(RM_URI, "reviewPeriod"); - - // Vital record aspect - QName ASPECT_VITAL_RECORD = QName.createQName(RM_URI, "vitalRecord"); - QName PROP_REVIEW_AS_OF = QName.createQName(RM_URI, "reviewAsOf"); - QName PROP_NOTIFICATION_ISSUED = QName.createQName(RM_URI, "notificationIssued"); - - // Cut off aspect - QName ASPECT_CUT_OFF = QName.createQName(RM_URI, "cutOff"); - QName PROP_CUT_OFF_DATE = QName.createQName(RM_URI, "cutOffDate"); - - // Uncut off aspect - QName ASPECT_UNCUT_OFF = QName.createQName(RM_URI, "uncutOff"); - - // Transferred aspect - QName ASPECT_TRANSFERRED = QName.createQName(RM_URI, "transferred"); - - // Ascended aspect - QName ASPECT_ASCENDED = QName.createQName(RM_URI, "ascended"); - - // Disposition schedule aspect - QName ASPECT_DISPOSITION_LIFECYCLE = QName.createQName(RM_URI, "dispositionLifecycle"); - QName ASSOC_NEXT_DISPOSITION_ACTION = QName.createQName(RM_URI, "nextDispositionAction"); - QName ASSOC_DISPOSITION_ACTION_HISTORY = QName.createQName(RM_URI, "dispositionActionHistory"); - - // Disposition action type - QName TYPE_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction"); - QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId"); - QName PROP_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction"); - QName PROP_DISPOSITION_AS_OF = QName.createQName(RM_URI, "dispositionAsOf"); - QName PROP_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "dispositionEventsEligible"); - QName PROP_DISPOSITION_ACTION_STARTED_AT = QName.createQName(RM_URI, "dispositionActionStartedAt"); - QName PROP_DISPOSITION_ACTION_STARTED_BY = QName.createQName(RM_URI, "dispositionActionStartedBy"); - QName PROP_DISPOSITION_ACTION_COMPLETED_AT = QName.createQName(RM_URI, "dispositionActionCompletedAt"); - QName PROP_DISPOSITION_ACTION_COMPLETED_BY = QName.createQName(RM_URI, "dispositionActionCompletedBy"); - QName ASSOC_EVENT_EXECUTIONS = QName.createQName(RM_URI, "eventExecutions"); - - // Event execution type - QName TYPE_EVENT_EXECUTION = QName.createQName(RM_URI, "eventExecution"); - QName PROP_EVENT_EXECUTION_NAME = QName.createQName(RM_URI, "eventExecutionName"); - QName PROP_EVENT_EXECUTION_AUTOMATIC = QName.createQName(RM_URI, "eventExecutionAutomatic"); - QName PROP_EVENT_EXECUTION_COMPLETE = QName.createQName(RM_URI, "eventExecutionComplete"); - QName PROP_EVENT_EXECUTION_COMPLETED_BY = QName.createQName(RM_URI, "eventExecutionCompletedBy"); - QName PROP_EVENT_EXECUTION_COMPLETED_AT = QName.createQName(RM_URI, "eventExecutionCompletedAt"); - - // Custom RM data aspect - QName ASPECT_CUSTOM_RM_DATA = QName.createQName(RM_URI, "customRMData"); - - // marker aspect on all RM objercts (except caveat root) - QName ASPECT_FILE_PLAN_COMPONENT = QName.createQName(RM_URI, "filePlanComponent"); - QName PROP_ROOT_NODEREF = QName.createQName(RM_URI, "rootNodeRef"); - - // Non-electronic document - QName TYPE_NON_ELECTRONIC_DOCUMENT = QName.createQName(RM_URI, "nonElectronicDocument"); - - // Records management root aspect - QName ASPECT_RECORDS_MANAGEMENT_ROOT = QName.createQName(RM_URI, "recordsManagementRoot"); - // since 2.1 - @Deprecated - QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds"); - // since 2.1 - @Deprecated - QName ASSOC_TRANSFERS = QName.createQName(RM_URI, "transfers"); - - // Hold type - QName TYPE_HOLD = QName.createQName(RM_URI, "hold"); - QName PROP_HOLD_REASON = QName.createQName(RM_URI, "holdReason"); - QName ASSOC_FROZEN_RECORDS = QName.createQName(RM_URI, "frozenRecords"); - - // Record meta data aspect - QName ASPECT_RECORD_META_DATA = QName.createQName(RM_URI, "recordMetaData"); - - // Frozen aspect - QName ASPECT_FROZEN = QName.createQName(RM_URI, "frozen"); - QName PROP_FROZEN_AT = QName.createQName(RM_URI, "frozenAt"); - QName PROP_FROZEN_BY = QName.createQName(RM_URI, "frozenBy"); - - // Transfer aspect - QName TYPE_TRANSFER = QName.createQName(RM_URI, "transfer"); - QName PROP_TRANSFER_ACCESSION_INDICATOR = QName.createQName(RM_URI, "transferAccessionIndicator"); - QName PROP_TRANSFER_PDF_INDICATOR = QName.createQName(RM_URI, "transferPDFIndicator"); - QName PROP_TRANSFER_LOCATION = QName.createQName(RM_URI, "transferLocation"); - QName ASSOC_TRANSFERRED = QName.createQName(RM_URI, "transferred"); - - // Transferring aspect - QName ASPECT_TRANSFERRING = QName.createQName(RM_URI, "transferring"); - - // Versioned record aspect - QName ASPECT_VERSIONED_RECORD = QName.createQName(RM_URI, "versionedRecord"); - - // Unpublished update aspect - QName ASPECT_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate"); - QName PROP_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate"); - QName PROP_UPDATE_TO = QName.createQName(RM_URI, "updateTo"); - QName PROP_UPDATED_PROPERTIES = QName.createQName(RM_URI, "updatedProperties"); - QName PROP_PUBLISH_IN_PROGRESS = QName.createQName(RM_URI, "publishInProgress"); - String UPDATE_TO_DISPOSITION_ACTION_DEFINITION = "dispositionActionDefinition"; - - // Ghosted aspect - QName ASPECT_GHOSTED = QName.createQName(RM_URI, "ghosted"); - - // Search rollup aspect - QName ASPECT_RM_SEARCH = QName.createQName(RM_URI, "recordSearch"); - QName PROP_RS_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "recordSearchDispositionActionName"); - QName PROP_RS_DISPOSITION_ACTION_AS_OF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf"); - QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible"); - QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents"); - QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod"); - QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression"); - QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod"); - QName PROP_RS_DISPOSITION_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchDispositionPeriodExpression"); - QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule"); - QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions"); - QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority"); - /** @depreacted as of 2.2, because disposable items can now be in multiple holds */ - @Deprecated - QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason"); - - // Loaded Data Set Ids - QName ASPECT_LOADED_DATA_SET_ID = QName.createQName(RM_URI, "loadedDataSetId"); - QName PROP_LOADED_DATA_SET_IDS = QName.createQName(RM_URI, "loadedDataSetIds"); - - // Extended security aspect - // @deprecated as of 2.5, because of performance issues - @Deprecated QName ASPECT_EXTENDED_SECURITY = QName.createQName(RM_URI, "extendedSecurity"); - @Deprecated QName PROP_READERS = QName.createQName(RM_URI, "readers"); - @Deprecated QName PROP_WRITERS = QName.createQName(RM_URI, "writers"); - - // Originating details of a record - QName ASPECT_RECORD_ORIGINATING_DETAILS = QName.createQName(RM_URI, "recordOriginatingDetails"); - QName PROP_RECORD_ORIGINATING_USER_ID = QName.createQName(RM_URI, "recordOriginatingUserId"); - QName PROP_RECORD_ORIGINATING_CREATION_DATE = QName.createQName(RM_URI, "recordOriginatingCreationDate"); - QName PROP_RECORD_ORIGINATING_LOCATION = QName.createQName(RM_URI, "recordOriginatingLocation"); - - // Rejection details of a record - QName ASPECT_RECORD_REJECTION_DETAILS = QName.createQName(RM_URI, "recordRejectionDetails"); - QName PROP_RECORD_REJECTION_USER_ID = QName.createQName(RM_URI, "recordRejectionUserId"); - QName PROP_RECORD_REJECTION_DATE = QName.createQName(RM_URI, "recordRejectionDate"); - QName PROP_RECORD_REJECTION_REASON = QName.createQName(RM_URI, "recordRejectionReason"); - - // Held children aspect - // @since 2.2 - QName ASPECT_HELD_CHILDREN = QName.createQName(RM_URI, "heldChildren"); - QName PROP_HELD_CHILDREN_COUNT = QName.createQName(RM_URI, "heldChildrenCount"); - - // Countable aspect - QName ASPECT_COUNTABLE = QName.createQName(RM_URI, "countable"); - QName PROP_COUNT = QName.createQName(RM_URI, "count"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model; + +import org.alfresco.service.namespace.QName; + +/** + * Helper class containing records management qualified names + * + * @author Roy Wetherall + */ +public interface RecordsManagementModel extends RecordsManagementCustomModel +{ + // Namespace details + String RM_URI = "http://www.alfresco.org/model/recordsmanagement/1.0"; + String RM_PREFIX = "rma"; + + // Model + QName RM_MODEL = QName.createQName(RM_URI, "recordsmanagement"); + + // RM Site + QName TYPE_RM_SITE = QName.createQName(RM_URI, "rmsite"); + + // Caveat config + QName TYPE_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfig"); + + QName ASPECT_CAVEAT_CONFIG_ROOT = QName.createQName(RM_URI, "caveatConfigRoot"); + QName ASSOC_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfigAssoc"); + + // Email config + QName TYPE_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfig"); + QName ASPECT_EMAIL_CONFIG_ROOT = QName.createQName(RM_URI, "emailConfigRoot"); + QName ASSOC_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfigAssoc"); + + // Records management container + QName TYPE_RECORDS_MANAGEMENT_CONTAINER = QName.createQName(RM_URI, "recordsManagementContainer"); + + // Record Category + QName TYPE_RECORD_CATEGORY = QName.createQName(RM_URI, "recordCategory"); + + // Records management root container + QName TYPE_FILE_PLAN = QName.createQName(RM_URI, "filePlan"); + + // Unfiled record container + QName TYPE_UNFILED_RECORD_CONTAINER = QName.createQName(RM_URI, "unfiledRecordContainer"); + + // Unfiled record folder + QName TYPE_UNFILED_RECORD_FOLDER = QName.createQName(RM_URI, "unfiledRecordFolder"); + + // Hold container + QName TYPE_HOLD_CONTAINER = QName.createQName(RM_URI, "holdContainer"); + + // Transfer container + QName TYPE_TRANSFER_CONTAINER = QName.createQName(RM_URI, "transferContainer"); + + // Disposition instructions aspect + QName ASPECT_SCHEDULED = QName.createQName(RM_URI, "scheduled"); + QName ASSOC_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule"); + + // Disposition definition type + QName TYPE_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule"); + QName PROP_DISPOSITION_AUTHORITY = QName.createQName(RM_URI, "dispositionAuthority"); + QName PROP_DISPOSITION_INSTRUCTIONS = QName.createQName(RM_URI, "dispositionInstructions"); + QName PROP_RECORD_LEVEL_DISPOSITION = QName.createQName(RM_URI, "recordLevelDisposition"); + QName ASSOC_DISPOSITION_ACTION_DEFINITIONS = QName.createQName(RM_URI, "dispositionActionDefinitions"); + + // Disposition action type + QName TYPE_DISPOSITION_ACTION_DEFINITION = QName.createQName(RM_URI, "dispositionActionDefinition"); + QName PROP_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "dispositionActionName"); + QName PROP_DISPOSITION_DESCRIPTION = QName.createQName(RM_URI, "dispositionDescription"); + QName PROP_DISPOSITION_PERIOD = QName.createQName(RM_URI, "dispositionPeriod"); + QName PROP_DISPOSITION_PERIOD_PROPERTY = QName.createQName(RM_URI, "dispositionPeriodProperty"); + QName PROP_DISPOSITION_EVENT = QName.createQName(RM_URI, "dispositionEvent"); + QName PROP_DISPOSITION_EVENT_COMBINATION = QName.createQName(RM_URI, "dispositionEventCombination"); + QName PROP_DISPOSITION_LOCATION = QName.createQName(RM_URI, "dispositionLocation"); + QName PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY = QName.createQName(RM_URI, "dispositionActionGhostOnDestroy"); + + // Records folder + QName TYPE_RECORD_FOLDER = QName.createQName(RM_URI, "recordFolder"); + QName PROP_IS_CLOSED = QName.createQName(RM_URI, "isClosed"); + + // Declared record aspect + QName ASPECT_DECLARED_RECORD = QName.createQName(RM_URI, "declaredRecord"); + QName PROP_DECLARED_AT = QName.createQName(RM_URI, "declaredAt"); + QName PROP_DECLARED_BY = QName.createQName(RM_URI, "declaredBy"); + + // Record aspect + QName ASPECT_RECORD = QName.createQName(RM_URI, "record"); + QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled"); + QName PROP_ORIGIONAL_NAME = QName.createQName(RM_URI, "origionalName"); + + // Common record details + QName PROP_LOCATION = QName.createQName(RM_URI, "location"); + + // Fileable aspect + QName ASPECT_FILABLE = QName.createQName(RM_URI, "fileable"); + + // Record component identifier aspect + QName ASPECT_RECORD_COMPONENT_ID = QName.createQName(RM_URI, "recordComponentIdentifier"); + QName PROP_IDENTIFIER = QName.createQName(RM_URI, "identifier"); + QName PROP_DB_UNIQUENESS_ID = QName.createQName(RM_URI, "dbUniquenessId"); + + // Vital record definition aspect + QName ASPECT_VITAL_RECORD_DEFINITION = QName.createQName(RM_URI, "vitalRecordDefinition"); + QName PROP_VITAL_RECORD_INDICATOR = QName.createQName(RM_URI, "vitalRecordIndicator"); + QName PROP_REVIEW_PERIOD = QName.createQName(RM_URI, "reviewPeriod"); + + // Vital record aspect + QName ASPECT_VITAL_RECORD = QName.createQName(RM_URI, "vitalRecord"); + QName PROP_REVIEW_AS_OF = QName.createQName(RM_URI, "reviewAsOf"); + QName PROP_NOTIFICATION_ISSUED = QName.createQName(RM_URI, "notificationIssued"); + + // Cut off aspect + QName ASPECT_CUT_OFF = QName.createQName(RM_URI, "cutOff"); + QName PROP_CUT_OFF_DATE = QName.createQName(RM_URI, "cutOffDate"); + + // Uncut off aspect + QName ASPECT_UNCUT_OFF = QName.createQName(RM_URI, "uncutOff"); + + // Transferred aspect + QName ASPECT_TRANSFERRED = QName.createQName(RM_URI, "transferred"); + + // Ascended aspect + QName ASPECT_ASCENDED = QName.createQName(RM_URI, "ascended"); + + // Disposition schedule aspect + QName ASPECT_DISPOSITION_LIFECYCLE = QName.createQName(RM_URI, "dispositionLifecycle"); + QName ASSOC_NEXT_DISPOSITION_ACTION = QName.createQName(RM_URI, "nextDispositionAction"); + QName ASSOC_DISPOSITION_ACTION_HISTORY = QName.createQName(RM_URI, "dispositionActionHistory"); + + // Disposition action type + QName TYPE_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction"); + QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId"); + QName PROP_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction"); + QName PROP_DISPOSITION_AS_OF = QName.createQName(RM_URI, "dispositionAsOf"); + QName PROP_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "dispositionEventsEligible"); + QName PROP_DISPOSITION_ACTION_STARTED_AT = QName.createQName(RM_URI, "dispositionActionStartedAt"); + QName PROP_DISPOSITION_ACTION_STARTED_BY = QName.createQName(RM_URI, "dispositionActionStartedBy"); + QName PROP_DISPOSITION_ACTION_COMPLETED_AT = QName.createQName(RM_URI, "dispositionActionCompletedAt"); + QName PROP_DISPOSITION_ACTION_COMPLETED_BY = QName.createQName(RM_URI, "dispositionActionCompletedBy"); + QName ASSOC_EVENT_EXECUTIONS = QName.createQName(RM_URI, "eventExecutions"); + + // Event execution type + QName TYPE_EVENT_EXECUTION = QName.createQName(RM_URI, "eventExecution"); + QName PROP_EVENT_EXECUTION_NAME = QName.createQName(RM_URI, "eventExecutionName"); + QName PROP_EVENT_EXECUTION_AUTOMATIC = QName.createQName(RM_URI, "eventExecutionAutomatic"); + QName PROP_EVENT_EXECUTION_COMPLETE = QName.createQName(RM_URI, "eventExecutionComplete"); + QName PROP_EVENT_EXECUTION_COMPLETED_BY = QName.createQName(RM_URI, "eventExecutionCompletedBy"); + QName PROP_EVENT_EXECUTION_COMPLETED_AT = QName.createQName(RM_URI, "eventExecutionCompletedAt"); + + // Custom RM data aspect + QName ASPECT_CUSTOM_RM_DATA = QName.createQName(RM_URI, "customRMData"); + + // marker aspect on all RM objercts (except caveat root) + QName ASPECT_FILE_PLAN_COMPONENT = QName.createQName(RM_URI, "filePlanComponent"); + QName PROP_ROOT_NODEREF = QName.createQName(RM_URI, "rootNodeRef"); + + // Non-electronic document + QName TYPE_NON_ELECTRONIC_DOCUMENT = QName.createQName(RM_URI, "nonElectronicDocument"); + + // Records management root aspect + QName ASPECT_RECORDS_MANAGEMENT_ROOT = QName.createQName(RM_URI, "recordsManagementRoot"); + // since 2.1 + @Deprecated + QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds"); + // since 2.1 + @Deprecated + QName ASSOC_TRANSFERS = QName.createQName(RM_URI, "transfers"); + + // Hold type + QName TYPE_HOLD = QName.createQName(RM_URI, "hold"); + QName PROP_HOLD_REASON = QName.createQName(RM_URI, "holdReason"); + QName ASSOC_FROZEN_RECORDS = QName.createQName(RM_URI, "frozenRecords"); + + // Record meta data aspect + QName ASPECT_RECORD_META_DATA = QName.createQName(RM_URI, "recordMetaData"); + + // Frozen aspect + QName ASPECT_FROZEN = QName.createQName(RM_URI, "frozen"); + QName PROP_FROZEN_AT = QName.createQName(RM_URI, "frozenAt"); + QName PROP_FROZEN_BY = QName.createQName(RM_URI, "frozenBy"); + + // Transfer aspect + QName TYPE_TRANSFER = QName.createQName(RM_URI, "transfer"); + QName PROP_TRANSFER_ACCESSION_INDICATOR = QName.createQName(RM_URI, "transferAccessionIndicator"); + QName PROP_TRANSFER_PDF_INDICATOR = QName.createQName(RM_URI, "transferPDFIndicator"); + QName PROP_TRANSFER_LOCATION = QName.createQName(RM_URI, "transferLocation"); + QName ASSOC_TRANSFERRED = QName.createQName(RM_URI, "transferred"); + + // Transferring aspect + QName ASPECT_TRANSFERRING = QName.createQName(RM_URI, "transferring"); + + // Versioned record aspect + QName ASPECT_VERSIONED_RECORD = QName.createQName(RM_URI, "versionedRecord"); + + // Unpublished update aspect + QName ASPECT_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate"); + QName PROP_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate"); + QName PROP_UPDATE_TO = QName.createQName(RM_URI, "updateTo"); + QName PROP_UPDATED_PROPERTIES = QName.createQName(RM_URI, "updatedProperties"); + QName PROP_PUBLISH_IN_PROGRESS = QName.createQName(RM_URI, "publishInProgress"); + String UPDATE_TO_DISPOSITION_ACTION_DEFINITION = "dispositionActionDefinition"; + + // Ghosted aspect + QName ASPECT_GHOSTED = QName.createQName(RM_URI, "ghosted"); + + // Search rollup aspect + QName ASPECT_RM_SEARCH = QName.createQName(RM_URI, "recordSearch"); + QName PROP_RS_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "recordSearchDispositionActionName"); + QName PROP_RS_DISPOSITION_ACTION_AS_OF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf"); + QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible"); + QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents"); + QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod"); + QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression"); + QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod"); + QName PROP_RS_DISPOSITION_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchDispositionPeriodExpression"); + QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule"); + QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions"); + QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority"); + /** @depreacted as of 2.2, because disposable items can now be in multiple holds */ + @Deprecated + QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason"); + + // Loaded Data Set Ids + QName ASPECT_LOADED_DATA_SET_ID = QName.createQName(RM_URI, "loadedDataSetId"); + QName PROP_LOADED_DATA_SET_IDS = QName.createQName(RM_URI, "loadedDataSetIds"); + + // Extended security aspect + // @deprecated as of 2.5, because of performance issues + @Deprecated QName ASPECT_EXTENDED_SECURITY = QName.createQName(RM_URI, "extendedSecurity"); + @Deprecated QName PROP_READERS = QName.createQName(RM_URI, "readers"); + @Deprecated QName PROP_WRITERS = QName.createQName(RM_URI, "writers"); + + // Originating details of a record + QName ASPECT_RECORD_ORIGINATING_DETAILS = QName.createQName(RM_URI, "recordOriginatingDetails"); + QName PROP_RECORD_ORIGINATING_USER_ID = QName.createQName(RM_URI, "recordOriginatingUserId"); + QName PROP_RECORD_ORIGINATING_CREATION_DATE = QName.createQName(RM_URI, "recordOriginatingCreationDate"); + QName PROP_RECORD_ORIGINATING_LOCATION = QName.createQName(RM_URI, "recordOriginatingLocation"); + + // Rejection details of a record + QName ASPECT_RECORD_REJECTION_DETAILS = QName.createQName(RM_URI, "recordRejectionDetails"); + QName PROP_RECORD_REJECTION_USER_ID = QName.createQName(RM_URI, "recordRejectionUserId"); + QName PROP_RECORD_REJECTION_DATE = QName.createQName(RM_URI, "recordRejectionDate"); + QName PROP_RECORD_REJECTION_REASON = QName.createQName(RM_URI, "recordRejectionReason"); + + // Held children aspect + // @since 2.2 + QName ASPECT_HELD_CHILDREN = QName.createQName(RM_URI, "heldChildren"); + QName PROP_HELD_CHILDREN_COUNT = QName.createQName(RM_URI, "heldChildrenCount"); + + // Countable aspect + QName ASPECT_COUNTABLE = QName.createQName(RM_URI, "countable"); + QName PROP_COUNT = QName.createQName(RM_URI, "count"); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/AbstractDisposableItem.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/AbstractDisposableItem.java index 5a8d161bd7..d6b8a62e71 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/AbstractDisposableItem.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/AbstractDisposableItem.java @@ -1,65 +1,65 @@ -/** - * - */ -package org.alfresco.module.org_alfresco_module_rm.model.behaviour; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; - -/** - * Abstract disposable item, containing commonality between record and record folder. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class AbstractDisposableItem extends BaseBehaviourBean -{ - /** unwanted aspects */ - protected QName[] unwantedAspects = - { - ASPECT_VITAL_RECORD, - ASPECT_DISPOSITION_LIFECYCLE, - RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH - }; - - /** disposition service */ - protected DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Removes unwanted aspects - * - * @param nodeService - * @param nodeRef - */ - protected void cleanDisposableItem(NodeService nodeService, NodeRef nodeRef) - { - // Remove unwanted aspects - for (QName aspect : unwantedAspects) - { - if (nodeService.hasAspect(nodeRef, aspect)) - { - nodeService.removeAspect(nodeRef, aspect); - } - } - - // remove the current disposition action (if there is one) - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); - if (dispositionAction != null) - { - nodeService.deleteNode(dispositionAction.getNodeRef()); - } - } - -} +/** + * + */ +package org.alfresco.module.org_alfresco_module_rm.model.behaviour; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Abstract disposable item, containing commonality between record and record folder. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class AbstractDisposableItem extends BaseBehaviourBean +{ + /** unwanted aspects */ + protected QName[] unwantedAspects = + { + ASPECT_VITAL_RECORD, + ASPECT_DISPOSITION_LIFECYCLE, + RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH + }; + + /** disposition service */ + protected DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Removes unwanted aspects + * + * @param nodeService + * @param nodeRef + */ + protected void cleanDisposableItem(NodeService nodeService, NodeRef nodeRef) + { + // Remove unwanted aspects + for (QName aspect : unwantedAspects) + { + if (nodeService.hasAspect(nodeRef, aspect)) + { + nodeService.removeAspect(nodeRef, aspect); + } + } + + // remove the current disposition action (if there is one) + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef); + if (dispositionAction != null) + { + nodeService.deleteNode(dispositionAction.getNodeRef()); + } + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 320b84c629..80e3aec4b4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -1,904 +1,904 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.behaviour; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionImpl; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Search behaviour class. - * - * Manages the collapse of data onto the supporting aspect on the record/record folder. - * - * @author Roy Wetherall - * @since 1.0 - */ -public class RecordsManagementSearchBehaviour implements RecordsManagementModel -{ - /** logger */ - private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class); - - /** Policy component */ - private PolicyComponent policyComponent; - - /** Node service */ - private NodeService nodeService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Records management service registry */ - private RecordsManagementServiceRegistry recordsManagementServiceRegistry; - - /** Vital record service */ - private VitalRecordService vitalRecordService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** Record service*/ - private RecordService recordService; - - /** - * @param nodeService the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param policyComponent the policyComponent to set - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * @param recordsManagementServiceRegistry the records management service registry - */ - public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry recordsManagementServiceRegistry) - { - this.recordsManagementServiceRegistry = recordsManagementServiceRegistry; - } - - /** - * @param vitalRecordService vital record service - */ - public void setVitalRecordService(VitalRecordService vitalRecordService) - { - this.vitalRecordService = vitalRecordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** on add search aspect behaviour */ - private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT); - - /** disposition action behaviours */ - private JavaBehaviour jbDispositionActionCreate = new JavaBehaviour(this, "dispositionActionCreate", NotificationFrequency.TRANSACTION_COMMIT); - private JavaBehaviour jbDispositionActionPropertiesUpdate = new JavaBehaviour(this, "dispositionActionPropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); - - /** disposition lifecycle behaviours */ - private JavaBehaviour jbDispositionLifeCycleAspect = new JavaBehaviour(this, "onAddDispositionLifecycleAspect", NotificationFrequency.TRANSACTION_COMMIT); - - /** disposition schedule behaviours */ - private JavaBehaviour jbDispositionSchedulePropertiesUpdate = new JavaBehaviour(this, "dispositionSchedulePropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); - - /** event update behaviours */ - private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT); - private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT); - - /** Array of behaviours related to disposition schedule artifacts */ - private JavaBehaviour[] jbDispositionBehaviours = - { - jbDispositionActionCreate, - jbDispositionActionPropertiesUpdate, - jbDispositionSchedulePropertiesUpdate, - jbEventExecutionUpdate, - jbEventExecutionDelete, - jbDispositionLifeCycleAspect - }; - - /** - * Initialisation method - */ - public void init() - { - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - TYPE_DISPOSITION_ACTION, - jbDispositionActionCreate); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - TYPE_DISPOSITION_ACTION, - jbDispositionActionPropertiesUpdate); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - TYPE_DISPOSITION_SCHEDULE, - jbDispositionSchedulePropertiesUpdate); - - this.policyComponent.bindAssociationBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), - TYPE_DISPOSITION_ACTION, - ASSOC_EVENT_EXECUTIONS, - jbEventExecutionUpdate); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), - TYPE_EVENT_EXECUTION, - jbEventExecutionDelete); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_RM_SEARCH, - onAddSearchAspect); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_DISPOSITION_LIFECYCLE, - jbDispositionLifeCycleAspect); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_RECORD, - new JavaBehaviour(this, "onAddRecordAspect", NotificationFrequency.TRANSACTION_COMMIT)); - - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - TYPE_RECORD_FOLDER, - new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT)); - - // Vital Records Review Details Rollup - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_VITAL_RECORD_DEFINITION, - new JavaBehaviour(this, "vitalRecordDefintionAddAspect", NotificationFrequency.TRANSACTION_COMMIT)); - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - ASPECT_VITAL_RECORD_DEFINITION, - new JavaBehaviour(this, "vitalRecordDefintionUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT)); - } - - /** - * Disabled disposition schedule behaviour - */ - public void disableDispositionScheduleBehaviour() - { - for (JavaBehaviour jb : jbDispositionBehaviours) - { - jb.disable(); - } - } - - /** - * Enables disposition schedule behaviour - */ - public void enableDispositionScheduleBehaviour() - { - for (JavaBehaviour jb : jbDispositionBehaviours) - { - jb.enable(); - } - } - - /** - * Ensures the search aspect for the given node is present, complete and correct. - * - * @param recordOrFolder node reference to record or record folder - */ - public void fixupSearchAspect(NodeRef recordOrFolder) - { - // for now only deal with record folders - if (recordFolderService.isRecordFolder(recordOrFolder)) - { - // ensure the search aspect is applied - applySearchAspect(recordOrFolder); - - // setup the properties relating to the disposition schedule - setupDispositionScheduleProperties(recordOrFolder); - - // setup the properties relating to the disposition lifecycle - DispositionAction da = dispositionService.getNextDispositionAction(recordOrFolder); - if (da != null) - { - updateDispositionActionProperties(recordOrFolder, da.getNodeRef()); - setupDispositionActionEvents(recordOrFolder, da); - } - - // setup the properties relating to the vital record indicator - setVitalRecordDefintionDetails(recordOrFolder); - } - } - - /** - * Updates the disposition action properties - * - * @param nodeRef node reference - * @param before value of properties before - * @param after value of properties after - */ - public void dispositionActionPropertiesUpdate(final NodeRef nodeRef, final Map before, final Map after) - { - if (nodeService.exists(nodeRef)) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); - if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) - { - // Get the record (or record folder) - NodeRef record = assoc.getParentRef(); - - // Apply the search aspect - applySearchAspect(record); - - // Update disposition properties - updateDispositionActionProperties(record, nodeRef); - } - - return null; - - }}, AuthenticationUtil.getSystemUserName()); - } - } - - /** - * Helper method to apply the search aspect - * - * @param nodeRef node reference - */ - private void applySearchAspect(NodeRef nodeRef) - { - onAddSearchAspect.disable(); - try - { - if (!nodeService.hasAspect(nodeRef, ASPECT_RM_SEARCH)) - { - nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null); - - if (logger.isDebugEnabled()) - { - logger.debug("Added search aspect to node: " + nodeRef); - } - } - } - finally - { - onAddSearchAspect.enable(); - } - } - - /** - * On add record aspect behaviour implementation - * - * @param nodeRef node reference - * @param aspectTypeQName aspect type qname - */ - public void onAddRecordAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, ASPECT_RECORD)) - { - applySearchAspect(nodeRef); - setupDispositionScheduleProperties(nodeRef); - } - - return null; - } - }); - } - - /** - * On addition of the disposition lifecycle aspect - * @param nodeRef - * @param aspectTypeQName - */ - public void onAddDispositionLifecycleAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, ASPECT_RECORD)) - { - applySearchAspect(nodeRef); - setupDispositionScheduleProperties(nodeRef); - } - - return null; - } - }); - } - - /** - * On create record folder behaviour implmentation - * - * @param childAssocRef child association reference - */ - public void recordFolderCreate(final ChildAssociationRef childAssocRef) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() throws Exception - { - NodeRef nodeRef = childAssocRef.getChildRef(); - if (nodeService.exists(nodeRef)) - { - applySearchAspect(nodeRef); - setupDispositionScheduleProperties(nodeRef); - } - - return null; - } - }); - } - - /** - * Helper method to setup the disposition schedule properties - * - * @param recordOrFolder node reference of record or record folder - */ - private void setupDispositionScheduleProperties(NodeRef recordOrFolder) - { - if (!methodCached("setupDispositionScheduleProperties", recordOrFolder)) - { - DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder); - if (ds == null) - { - nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, false); - } - else - { - nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, true); - setDispositionScheduleProperties(recordOrFolder, ds); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder + - " to: " + (ds != null)); - } - } - } - - /** - * On disposition action create behaviour implementation - * - * @param childAssocRef child association reference - */ - public void dispositionActionCreate(final ChildAssociationRef childAssocRef) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - NodeRef child = childAssocRef.getChildRef(); - if (nodeService.exists(child) && - childAssocRef.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) - { - // Get the record (or record folder) - NodeRef record = childAssocRef.getParentRef(); - - // Apply the search aspect - applySearchAspect(record); - - // Update disposition properties - updateDispositionActionProperties(record, childAssocRef.getChildRef()); - - // Clear the events - nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null); - } - - return null; - } - }); - } - - /** - * Helper method to determine whether a method has been called in this transaction - * already, or not. - *

- * Prevents work if we get unexpected behaviours firing. - * - * @param method method name (can be any unique string) - * @return boolean true if already called in this transaction, false otherwise - */ - private boolean methodCached(String method, NodeRef nodeRef) - { - boolean result = true; - Set methods = TransactionalResourceHelper.getSet("rm.seachrollup.methodCache"); - String key = method + "|" + nodeRef; - if (!methods.contains(key)) - { - result = false; - methods.add(key); - } - return result; - } - - /** - * On update disposition action properties behaviour implementation - * - * @param record record node reference - * @param dispositionAction disposition action - */ - private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) - { - if (!methodCached("updateDispositionActionProperties", record)) - { - Map props = nodeService.getProperties(record); - - DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); - props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); - props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); - if (daDefinition != null) - { - Period period = daDefinition.getPeriod(); - if (period != null) - { - props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); - } - else - { - props.put(PROP_RS_DISPOSITION_PERIOD, null); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); - } - } - - nodeService.setProperties(record, props); - - if (logger.isDebugEnabled()) - { - logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_NAME)); - logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD)); - logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); - } - } - } - - /** - * On update of event execution information behaviour\ - * - * @param childAssocRef child association reference - * @param isNewNode true if a new node, false otherwise - */ - @SuppressWarnings("unchecked") - public void eventExecutionUpdate(ChildAssociationRef childAssocRef, boolean isNewNode) - { - NodeRef dispositionAction = childAssocRef.getParentRef(); - NodeRef eventExecution = childAssocRef.getChildRef(); - - if (nodeService.exists(dispositionAction) && - nodeService.exists(eventExecution)) - { - ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionAction); - if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) - { - // Get the record (or record folder) - NodeRef record = assoc.getParentRef(); - - // Apply the search aspect - applySearchAspect(record); - - Collection events = (List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS); - if (events == null) - { - events = new ArrayList(1); - } - events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); - nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); - } - } - } - - /** - * On event execution delete behaviour implementation. - * - * @param childAssocRef child association reference - * @param isNodeArchived true if node is archived on delete, false otherwise - */ - public void eventExecutionDelete(ChildAssociationRef childAssocRef, boolean isNodeArchived) - { - NodeRef dispositionActionNode = childAssocRef.getParentRef(); - - if (nodeService.exists(dispositionActionNode)) - { - ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionActionNode); - if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) - { - // Get the record (or record folder) - NodeRef record = assoc.getParentRef(); - - // Apply the search aspect - applySearchAspect(record); - - // make sure the list of events match the action definition - setupDispositionActionEvents(record, dispositionService.getNextDispositionAction(record)); - } - } - } - - /** - * Helper method to setup disposition action events. - * - * @param nodeRef node reference - * @param da disposition action - */ - private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da) - { - if (!methodCached("setupDispositionActionEvents", nodeRef)) - { - if (da != null) - { - List eventNames = null; - List eventsList = da.getEventCompletionDetails(); - if (eventsList.size() > 0) - { - eventNames = new ArrayList(eventsList.size()); - for (EventCompletionDetails event : eventsList) - { - eventNames.add(event.getEventName()); - } - } - - // set the property - nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames); - - if (logger.isDebugEnabled()) - { - logger.debug("Set rma:recordSearchDispositionEvents for node " + nodeRef + " to: " + eventNames); - } - } - } - } - - /** - * On add search aspect behaviour implementation. - * - * @param nodeRef node reference - * @param aspectTypeQName aspect type qname - */ - public void rmSearchAspectAdd(final NodeRef nodeRef, final QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef)) - { - // Initialise the search parameteres as required - setVitalRecordDefintionDetails(nodeRef); - } - - return null; - } - }); - } - - /** - * On add aspect vital record defintion behaviour implementation. - * - * @param nodeRef node reference - * @param aspectTypeQName aspect tyep qname - */ - public void vitalRecordDefintionAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() - { - // Only care about record folders - if (nodeService.exists(nodeRef) && recordFolderService.isRecordFolder(nodeRef)) - { - updateVitalRecordDefinitionValues(nodeRef); - } - - return null; - } - }); - } - - /** - * On update vital record definition properties behaviour implementation. - * - * @param nodeRef node reference - * @param before before properties - * @param after after properties - */ - public void vitalRecordDefintionUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - @Override - public Void doWork() - { - // Only care about record folders - if (nodeService.exists(nodeRef) && recordFolderService.isRecordFolder(nodeRef)) - { - Set props = new HashSet(1); - props.add(PROP_REVIEW_PERIOD); - Set changed = determineChangedProps(before, after); - changed.retainAll(props); - if (!changed.isEmpty()) - { - updateVitalRecordDefinitionValues(nodeRef); - } - } - - return null; - } - }); - } - - /** - * Helper method to update the vital record defintion values - * - * @param nodeRef node reference - */ - private void updateVitalRecordDefinitionValues(NodeRef nodeRef) - { - if (!methodCached("updateVitalRecordDefinitionValues", nodeRef)) - { - // ensure the folder itself reflects the correct details - applySearchAspect(nodeRef); - setVitalRecordDefintionDetails(nodeRef); - - List records = recordService.getRecords(nodeRef); - for (NodeRef record : records) - { - // Apply the search aspect - applySearchAspect(record); - - // Set the vital record definition details - setVitalRecordDefintionDetails(record); - } - } - } - - /** - * Helper method to set vital record definition details. - * - * @param nodeRef node reference - */ - private void setVitalRecordDefintionDetails(NodeRef nodeRef) - { - if (!methodCached("setVitalRecordDefinitionDetails", nodeRef)) - { - VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef); - - if (vrd != null && vrd.isEnabled() && vrd.getReviewPeriod() != null) - { - // Set the property values - nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, vrd.getReviewPeriod().getPeriodType()); - nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, vrd.getReviewPeriod().getExpression()); - - if (logger.isDebugEnabled()) - { - logger.debug("Set rma:recordSearchVitalRecordReviewPeriod for node " + nodeRef + " to: " + - vrd.getReviewPeriod().getPeriodType()); - logger.debug("Set rma:recordSearchVitalRecordReviewPeriodExpression for node " + nodeRef + " to: " + - vrd.getReviewPeriod().getExpression()); - } - } - else - { - // Clear the vital record properties - nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, null); - nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null); - } - } - } - - /** - * Updates the disposition schedule properties - * - * @param nodeRef node reference - * @param before properties before - * @param after properties after - */ - public void dispositionSchedulePropertiesUpdate(NodeRef nodeRef, Map before, Map after) - { - if (nodeService.exists(nodeRef)) - { - // create the schedule object and get the record category for it - DispositionSchedule schedule = new DispositionScheduleImpl(recordsManagementServiceRegistry, nodeService, nodeRef); - NodeRef recordCategoryNode = nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); - - if (schedule.isRecordLevelDisposition()) - { - for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) - { - for (NodeRef record : recordService.getRecords(recordFolder)) - { - applySearchAspect(record); - setDispositionScheduleProperties(record, schedule); - } - } - } - else - { - for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) - { - applySearchAspect(recordFolder); - setDispositionScheduleProperties(recordFolder, schedule); - } - } - } - } - - /** - * Helper method to set disposition schedule properties - * - * @param recordOrFolder node reference - * @param schedule dispostion schedule - */ - private void setDispositionScheduleProperties(NodeRef recordOrFolder, DispositionSchedule schedule) - { - if (schedule != null) - { - nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_AUTHORITY, schedule.getDispositionAuthority()); - nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_INSTRUCTIONS, schedule.getDispositionInstructions()); - - if (logger.isDebugEnabled()) - { - logger.debug("Set rma:recordSearchDispositionAuthority for node " + recordOrFolder + " to: " + schedule.getDispositionAuthority()); - logger.debug("Set rma:recordSearchDispositionInstructions for node " + recordOrFolder + " to: " + schedule.getDispositionInstructions()); - } - } - } - - /** - * This method compares the oldProps map against the newProps map and returns - * a set of QNames of the properties that have changed. Changed here means one of - *

    - *
  • the property has been removed
  • - *
  • the property has had its value changed
  • - *
  • the property has been added
  • - *
- */ - private Set determineChangedProps(Map oldProps, Map newProps) - { - Set result = new HashSet(); - for (Map.Entry entry : oldProps.entrySet()) - { - QName qn = entry.getKey(); - if (newProps.get(qn) == null || !newProps.get(qn).equals(entry.getValue())) - { - result.add(qn); - } - } - for (QName qn : newProps.keySet()) - { - if (oldProps.get(qn) == null) - { - result.add(qn); - } - } - - return result; - } - - /** - * Helper method to get the record folders contained in the provided record category. - * - * @param recordCategoryNode record category node reference - * @return List contained record folders - */ - private List getRecordFolders(NodeRef recordCategoryNode) - { - List results = new ArrayList(8); - - List folderAssocs = nodeService.getChildAssocs(recordCategoryNode, - ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef folderAssoc : folderAssocs) - { - NodeRef folder = folderAssoc.getChildRef(); - if (recordFolderService.isRecordFolder(folder)) - { - results.add(folder); - } - } - - return results; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.behaviour; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionImpl; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Search behaviour class. + * + * Manages the collapse of data onto the supporting aspect on the record/record folder. + * + * @author Roy Wetherall + * @since 1.0 + */ +public class RecordsManagementSearchBehaviour implements RecordsManagementModel +{ + /** logger */ + private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class); + + /** Policy component */ + private PolicyComponent policyComponent; + + /** Node service */ + private NodeService nodeService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Records management service registry */ + private RecordsManagementServiceRegistry recordsManagementServiceRegistry; + + /** Vital record service */ + private VitalRecordService vitalRecordService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Record service*/ + private RecordService recordService; + + /** + * @param nodeService the nodeService to set + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param policyComponent the policyComponent to set + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * @param recordsManagementServiceRegistry the records management service registry + */ + public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry recordsManagementServiceRegistry) + { + this.recordsManagementServiceRegistry = recordsManagementServiceRegistry; + } + + /** + * @param vitalRecordService vital record service + */ + public void setVitalRecordService(VitalRecordService vitalRecordService) + { + this.vitalRecordService = vitalRecordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** on add search aspect behaviour */ + private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT); + + /** disposition action behaviours */ + private JavaBehaviour jbDispositionActionCreate = new JavaBehaviour(this, "dispositionActionCreate", NotificationFrequency.TRANSACTION_COMMIT); + private JavaBehaviour jbDispositionActionPropertiesUpdate = new JavaBehaviour(this, "dispositionActionPropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); + + /** disposition lifecycle behaviours */ + private JavaBehaviour jbDispositionLifeCycleAspect = new JavaBehaviour(this, "onAddDispositionLifecycleAspect", NotificationFrequency.TRANSACTION_COMMIT); + + /** disposition schedule behaviours */ + private JavaBehaviour jbDispositionSchedulePropertiesUpdate = new JavaBehaviour(this, "dispositionSchedulePropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); + + /** event update behaviours */ + private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT); + private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT); + + /** Array of behaviours related to disposition schedule artifacts */ + private JavaBehaviour[] jbDispositionBehaviours = + { + jbDispositionActionCreate, + jbDispositionActionPropertiesUpdate, + jbDispositionSchedulePropertiesUpdate, + jbEventExecutionUpdate, + jbEventExecutionDelete, + jbDispositionLifeCycleAspect + }; + + /** + * Initialisation method + */ + public void init() + { + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + TYPE_DISPOSITION_ACTION, + jbDispositionActionCreate); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + TYPE_DISPOSITION_ACTION, + jbDispositionActionPropertiesUpdate); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + TYPE_DISPOSITION_SCHEDULE, + jbDispositionSchedulePropertiesUpdate); + + this.policyComponent.bindAssociationBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), + TYPE_DISPOSITION_ACTION, + ASSOC_EVENT_EXECUTIONS, + jbEventExecutionUpdate); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), + TYPE_EVENT_EXECUTION, + jbEventExecutionDelete); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_RM_SEARCH, + onAddSearchAspect); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_DISPOSITION_LIFECYCLE, + jbDispositionLifeCycleAspect); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_RECORD, + new JavaBehaviour(this, "onAddRecordAspect", NotificationFrequency.TRANSACTION_COMMIT)); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + TYPE_RECORD_FOLDER, + new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT)); + + // Vital Records Review Details Rollup + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_VITAL_RECORD_DEFINITION, + new JavaBehaviour(this, "vitalRecordDefintionAddAspect", NotificationFrequency.TRANSACTION_COMMIT)); + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + ASPECT_VITAL_RECORD_DEFINITION, + new JavaBehaviour(this, "vitalRecordDefintionUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT)); + } + + /** + * Disabled disposition schedule behaviour + */ + public void disableDispositionScheduleBehaviour() + { + for (JavaBehaviour jb : jbDispositionBehaviours) + { + jb.disable(); + } + } + + /** + * Enables disposition schedule behaviour + */ + public void enableDispositionScheduleBehaviour() + { + for (JavaBehaviour jb : jbDispositionBehaviours) + { + jb.enable(); + } + } + + /** + * Ensures the search aspect for the given node is present, complete and correct. + * + * @param recordOrFolder node reference to record or record folder + */ + public void fixupSearchAspect(NodeRef recordOrFolder) + { + // for now only deal with record folders + if (recordFolderService.isRecordFolder(recordOrFolder)) + { + // ensure the search aspect is applied + applySearchAspect(recordOrFolder); + + // setup the properties relating to the disposition schedule + setupDispositionScheduleProperties(recordOrFolder); + + // setup the properties relating to the disposition lifecycle + DispositionAction da = dispositionService.getNextDispositionAction(recordOrFolder); + if (da != null) + { + updateDispositionActionProperties(recordOrFolder, da.getNodeRef()); + setupDispositionActionEvents(recordOrFolder, da); + } + + // setup the properties relating to the vital record indicator + setVitalRecordDefintionDetails(recordOrFolder); + } + } + + /** + * Updates the disposition action properties + * + * @param nodeRef node reference + * @param before value of properties before + * @param after value of properties after + */ + public void dispositionActionPropertiesUpdate(final NodeRef nodeRef, final Map before, final Map after) + { + if (nodeService.exists(nodeRef)) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); + if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) + { + // Get the record (or record folder) + NodeRef record = assoc.getParentRef(); + + // Apply the search aspect + applySearchAspect(record); + + // Update disposition properties + updateDispositionActionProperties(record, nodeRef); + } + + return null; + + }}, AuthenticationUtil.getSystemUserName()); + } + } + + /** + * Helper method to apply the search aspect + * + * @param nodeRef node reference + */ + private void applySearchAspect(NodeRef nodeRef) + { + onAddSearchAspect.disable(); + try + { + if (!nodeService.hasAspect(nodeRef, ASPECT_RM_SEARCH)) + { + nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null); + + if (logger.isDebugEnabled()) + { + logger.debug("Added search aspect to node: " + nodeRef); + } + } + } + finally + { + onAddSearchAspect.enable(); + } + } + + /** + * On add record aspect behaviour implementation + * + * @param nodeRef node reference + * @param aspectTypeQName aspect type qname + */ + public void onAddRecordAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, ASPECT_RECORD)) + { + applySearchAspect(nodeRef); + setupDispositionScheduleProperties(nodeRef); + } + + return null; + } + }); + } + + /** + * On addition of the disposition lifecycle aspect + * @param nodeRef + * @param aspectTypeQName + */ + public void onAddDispositionLifecycleAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, ASPECT_RECORD)) + { + applySearchAspect(nodeRef); + setupDispositionScheduleProperties(nodeRef); + } + + return null; + } + }); + } + + /** + * On create record folder behaviour implmentation + * + * @param childAssocRef child association reference + */ + public void recordFolderCreate(final ChildAssociationRef childAssocRef) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() throws Exception + { + NodeRef nodeRef = childAssocRef.getChildRef(); + if (nodeService.exists(nodeRef)) + { + applySearchAspect(nodeRef); + setupDispositionScheduleProperties(nodeRef); + } + + return null; + } + }); + } + + /** + * Helper method to setup the disposition schedule properties + * + * @param recordOrFolder node reference of record or record folder + */ + private void setupDispositionScheduleProperties(NodeRef recordOrFolder) + { + if (!methodCached("setupDispositionScheduleProperties", recordOrFolder)) + { + DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder); + if (ds == null) + { + nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, false); + } + else + { + nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, true); + setDispositionScheduleProperties(recordOrFolder, ds); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder + + " to: " + (ds != null)); + } + } + } + + /** + * On disposition action create behaviour implementation + * + * @param childAssocRef child association reference + */ + public void dispositionActionCreate(final ChildAssociationRef childAssocRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() throws Exception + { + NodeRef child = childAssocRef.getChildRef(); + if (nodeService.exists(child) && + childAssocRef.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) + { + // Get the record (or record folder) + NodeRef record = childAssocRef.getParentRef(); + + // Apply the search aspect + applySearchAspect(record); + + // Update disposition properties + updateDispositionActionProperties(record, childAssocRef.getChildRef()); + + // Clear the events + nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null); + } + + return null; + } + }); + } + + /** + * Helper method to determine whether a method has been called in this transaction + * already, or not. + *

+ * Prevents work if we get unexpected behaviours firing. + * + * @param method method name (can be any unique string) + * @return boolean true if already called in this transaction, false otherwise + */ + private boolean methodCached(String method, NodeRef nodeRef) + { + boolean result = true; + Set methods = TransactionalResourceHelper.getSet("rm.seachrollup.methodCache"); + String key = method + "|" + nodeRef; + if (!methods.contains(key)) + { + result = false; + methods.add(key); + } + return result; + } + + /** + * On update disposition action properties behaviour implementation + * + * @param record record node reference + * @param dispositionAction disposition action + */ + private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) + { + if (!methodCached("updateDispositionActionProperties", record)) + { + Map props = nodeService.getProperties(record); + + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); + + props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); + props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); + props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + if (daDefinition != null) + { + Period period = daDefinition.getPeriod(); + if (period != null) + { + props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); + } + else + { + props.put(PROP_RS_DISPOSITION_PERIOD, null); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); + } + } + + nodeService.setProperties(record, props); + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_NAME)); + logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD)); + logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + } + } + } + + /** + * On update of event execution information behaviour\ + * + * @param childAssocRef child association reference + * @param isNewNode true if a new node, false otherwise + */ + @SuppressWarnings("unchecked") + public void eventExecutionUpdate(ChildAssociationRef childAssocRef, boolean isNewNode) + { + NodeRef dispositionAction = childAssocRef.getParentRef(); + NodeRef eventExecution = childAssocRef.getChildRef(); + + if (nodeService.exists(dispositionAction) && + nodeService.exists(eventExecution)) + { + ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionAction); + if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) + { + // Get the record (or record folder) + NodeRef record = assoc.getParentRef(); + + // Apply the search aspect + applySearchAspect(record); + + Collection events = (List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS); + if (events == null) + { + events = new ArrayList(1); + } + events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); + nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); + } + } + } + + /** + * On event execution delete behaviour implementation. + * + * @param childAssocRef child association reference + * @param isNodeArchived true if node is archived on delete, false otherwise + */ + public void eventExecutionDelete(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + NodeRef dispositionActionNode = childAssocRef.getParentRef(); + + if (nodeService.exists(dispositionActionNode)) + { + ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionActionNode); + if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) + { + // Get the record (or record folder) + NodeRef record = assoc.getParentRef(); + + // Apply the search aspect + applySearchAspect(record); + + // make sure the list of events match the action definition + setupDispositionActionEvents(record, dispositionService.getNextDispositionAction(record)); + } + } + } + + /** + * Helper method to setup disposition action events. + * + * @param nodeRef node reference + * @param da disposition action + */ + private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da) + { + if (!methodCached("setupDispositionActionEvents", nodeRef)) + { + if (da != null) + { + List eventNames = null; + List eventsList = da.getEventCompletionDetails(); + if (eventsList.size() > 0) + { + eventNames = new ArrayList(eventsList.size()); + for (EventCompletionDetails event : eventsList) + { + eventNames.add(event.getEventName()); + } + } + + // set the property + nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames); + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchDispositionEvents for node " + nodeRef + " to: " + eventNames); + } + } + } + } + + /** + * On add search aspect behaviour implementation. + * + * @param nodeRef node reference + * @param aspectTypeQName aspect type qname + */ + public void rmSearchAspectAdd(final NodeRef nodeRef, final QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef)) + { + // Initialise the search parameteres as required + setVitalRecordDefintionDetails(nodeRef); + } + + return null; + } + }); + } + + /** + * On add aspect vital record defintion behaviour implementation. + * + * @param nodeRef node reference + * @param aspectTypeQName aspect tyep qname + */ + public void vitalRecordDefintionAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + // Only care about record folders + if (nodeService.exists(nodeRef) && recordFolderService.isRecordFolder(nodeRef)) + { + updateVitalRecordDefinitionValues(nodeRef); + } + + return null; + } + }); + } + + /** + * On update vital record definition properties behaviour implementation. + * + * @param nodeRef node reference + * @param before before properties + * @param after after properties + */ + public void vitalRecordDefintionUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + // Only care about record folders + if (nodeService.exists(nodeRef) && recordFolderService.isRecordFolder(nodeRef)) + { + Set props = new HashSet(1); + props.add(PROP_REVIEW_PERIOD); + Set changed = determineChangedProps(before, after); + changed.retainAll(props); + if (!changed.isEmpty()) + { + updateVitalRecordDefinitionValues(nodeRef); + } + } + + return null; + } + }); + } + + /** + * Helper method to update the vital record defintion values + * + * @param nodeRef node reference + */ + private void updateVitalRecordDefinitionValues(NodeRef nodeRef) + { + if (!methodCached("updateVitalRecordDefinitionValues", nodeRef)) + { + // ensure the folder itself reflects the correct details + applySearchAspect(nodeRef); + setVitalRecordDefintionDetails(nodeRef); + + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + // Apply the search aspect + applySearchAspect(record); + + // Set the vital record definition details + setVitalRecordDefintionDetails(record); + } + } + } + + /** + * Helper method to set vital record definition details. + * + * @param nodeRef node reference + */ + private void setVitalRecordDefintionDetails(NodeRef nodeRef) + { + if (!methodCached("setVitalRecordDefinitionDetails", nodeRef)) + { + VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef); + + if (vrd != null && vrd.isEnabled() && vrd.getReviewPeriod() != null) + { + // Set the property values + nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, vrd.getReviewPeriod().getPeriodType()); + nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, vrd.getReviewPeriod().getExpression()); + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchVitalRecordReviewPeriod for node " + nodeRef + " to: " + + vrd.getReviewPeriod().getPeriodType()); + logger.debug("Set rma:recordSearchVitalRecordReviewPeriodExpression for node " + nodeRef + " to: " + + vrd.getReviewPeriod().getExpression()); + } + } + else + { + // Clear the vital record properties + nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, null); + nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null); + } + } + } + + /** + * Updates the disposition schedule properties + * + * @param nodeRef node reference + * @param before properties before + * @param after properties after + */ + public void dispositionSchedulePropertiesUpdate(NodeRef nodeRef, Map before, Map after) + { + if (nodeService.exists(nodeRef)) + { + // create the schedule object and get the record category for it + DispositionSchedule schedule = new DispositionScheduleImpl(recordsManagementServiceRegistry, nodeService, nodeRef); + NodeRef recordCategoryNode = nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); + + if (schedule.isRecordLevelDisposition()) + { + for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) + { + for (NodeRef record : recordService.getRecords(recordFolder)) + { + applySearchAspect(record); + setDispositionScheduleProperties(record, schedule); + } + } + } + else + { + for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) + { + applySearchAspect(recordFolder); + setDispositionScheduleProperties(recordFolder, schedule); + } + } + } + } + + /** + * Helper method to set disposition schedule properties + * + * @param recordOrFolder node reference + * @param schedule dispostion schedule + */ + private void setDispositionScheduleProperties(NodeRef recordOrFolder, DispositionSchedule schedule) + { + if (schedule != null) + { + nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_AUTHORITY, schedule.getDispositionAuthority()); + nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_INSTRUCTIONS, schedule.getDispositionInstructions()); + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchDispositionAuthority for node " + recordOrFolder + " to: " + schedule.getDispositionAuthority()); + logger.debug("Set rma:recordSearchDispositionInstructions for node " + recordOrFolder + " to: " + schedule.getDispositionInstructions()); + } + } + } + + /** + * This method compares the oldProps map against the newProps map and returns + * a set of QNames of the properties that have changed. Changed here means one of + *

    + *
  • the property has been removed
  • + *
  • the property has had its value changed
  • + *
  • the property has been added
  • + *
+ */ + private Set determineChangedProps(Map oldProps, Map newProps) + { + Set result = new HashSet(); + for (Map.Entry entry : oldProps.entrySet()) + { + QName qn = entry.getKey(); + if (newProps.get(qn) == null || !newProps.get(qn).equals(entry.getValue())) + { + result.add(qn); + } + } + for (QName qn : newProps.keySet()) + { + if (oldProps.get(qn) == null) + { + result.add(qn); + } + } + + return result; + } + + /** + * Helper method to get the record folders contained in the provided record category. + * + * @param recordCategoryNode record category node reference + * @return List contained record folders + */ + private List getRecordFolders(NodeRef recordCategoryNode) + { + List results = new ArrayList(8); + + List folderAssocs = nodeService.getChildAssocs(recordCategoryNode, + ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef folderAssoc : folderAssocs) + { + NodeRef folder = folderAssoc.getChildRef(); + if (recordFolderService.isRecordFolder(folder)) + { + results.add(folder); + } + } + + return results; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessor.java index f4a0904da7..96306f7f14 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessor.java @@ -1,39 +1,39 @@ -package org.alfresco.module.org_alfresco_module_rm.model.compatibility; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; - -/** - * Dictionary bootstap post processor. - *

- * Ensures compatibility with 4.2 and 4.2.1 as well as 4.2.2. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class DictionaryBootstrapPostProcessor implements BeanFactoryPostProcessor -{ - /** bean id's */ - private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap"; - private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap"; - - /** - * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) - */ - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) - { - // if the site service bootstrap bean and the RM dictionary bean are present in the bean factory - if (beanFactory.containsBean(BEAN_SITESERVICE_BOOTSTRAP) && - beanFactory.containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP)) - { - // get the RM dictionary bootstrap bean definition - BeanDefinition beanDef = beanFactory.getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); - - // set the dependency - beanDef.setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP}); - } - } - -} +package org.alfresco.module.org_alfresco_module_rm.model.compatibility; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; + +/** + * Dictionary bootstap post processor. + *

+ * Ensures compatibility with 4.2 and 4.2.1 as well as 4.2.2. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class DictionaryBootstrapPostProcessor implements BeanFactoryPostProcessor +{ + /** bean id's */ + private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap"; + private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap"; + + /** + * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) + */ + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) + { + // if the site service bootstrap bean and the RM dictionary bean are present in the bean factory + if (beanFactory.containsBean(BEAN_SITESERVICE_BOOTSTRAP) && + beanFactory.containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP)) + { + // get the RM dictionary bootstrap bean definition + BeanDefinition beanDef = beanFactory.getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); + + // set the dependency + beanDef.setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP}); + } + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/AccendedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/AccendedAspect.java index a20184ad50..e6cd835bb0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/AccendedAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/AccendedAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:ascended behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:ascended" -) -public class AccendedAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:ascended behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:ascended" +) +public class AccendedAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/CutoffAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/CutoffAspect.java index 5cd310678b..0793466bb9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/CutoffAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/CutoffAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:cutoff behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:cutOff" -) -public class CutoffAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Cutoff aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:cutoff behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:cutOff" +) +public class CutoffAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Cutoff aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DeclaredRecordAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DeclaredRecordAspect.java index 2299e34100..64397ba340 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DeclaredRecordAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DeclaredRecordAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:declaredRecord behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:declaredRecord" -) -public class DeclaredRecordAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:declaredRecord behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:declaredRecord" +) +public class DeclaredRecordAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java index fce16e9a4b..77a7b82289 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java @@ -1,97 +1,97 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * rma:dispositionLifecycle behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:dispositionLifecycle" -) -public class DispositionLifecycleAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnAddAspectPolicy -{ - /** disposition service */ - protected DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Copy callback for disposition lifecycle - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT - ) - public void onAddAspect(final NodeRef nodeRef, final QName aspect) - { - if (nodeService.exists(nodeRef)) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - dispositionService.refreshDispositionAction(nodeRef); - return null; - } - }); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * rma:dispositionLifecycle behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:dispositionLifecycle" +) +public class DispositionLifecycleAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnAddAspectPolicy +{ + /** disposition service */ + protected DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Copy callback for disposition lifecycle + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.EVERY_EVENT + ) + public void onAddAspect(final NodeRef nodeRef, final QName aspect) + { + if (nodeService.exists(nodeRef)) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + dispositionService.refreshDispositionAction(nodeRef); + return null; + } + }); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java index a35d5cdd82..553fd5a20b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:extendedSecurity behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:extendedSecurity" -) -public class ExtendedSecurityAspect extends BaseBehaviourBean -{ - /** extended security service */ - protected ExtendedSecurityService extendedSecurityService; - - /** - * @param extendedSecurityService extended security service - */ - public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) - { - this.extendedSecurityService = extendedSecurityService; - } - - /** - * Copy callback. - * - * Aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:extendedSecurity behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:extendedSecurity" +) +public class ExtendedSecurityAspect extends BaseBehaviourBean +{ + /** extended security service */ + protected ExtendedSecurityService extendedSecurityService; + + /** + * @param extendedSecurityService extended security service + */ + public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) + { + this.extendedSecurityService = extendedSecurityService; + } + + /** + * Copy callback. + * + * Aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java index c8590ce24c..4d510fe0de 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java @@ -1,332 +1,332 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.AbstractCopyBehaviourCallback; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.ScriptService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.PropertyMap; - -/** - * rma:filePlanComponent behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:filePlanComponent" -) -public class FilePlanComponentAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnUpdatePropertiesPolicy, - NodeServicePolicies.OnAddAspectPolicy, - NodeServicePolicies.OnMoveNodePolicy - - -{ - /** Well-known location of the scripts folder. */ - private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_behavior_scripts"); - - /** script service */ - private ScriptService scriptService; - - /** namespace service */ - private NamespaceService namespaceService; - - /** file plan service */ - private FilePlanService filePlanService; - - /** rendition service */ - private RenditionService renditionService; - - /** - * @param scriptService set script service - */ - public void setScriptService(ScriptService scriptService) - { - this.scriptService = scriptService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param renditionService rendition service - */ - public void setRenditionService(RenditionService service) - { - this.renditionService = service; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef)) - { - lookupAndExecuteScripts(nodeRef, before, after); - } - - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - /** - * This method examines the old and new property sets and for those properties which - * have changed, looks for script resources corresponding to those properties. - * Those scripts are then called via the ScriptService. - * - * @param nodeWithChangedProperties the node whose properties have changed. - * @param oldProps the old properties and their values. - * @param newProps the new properties and their values. - * - * @see #lookupScripts(Map, Map) - */ - private void lookupAndExecuteScripts(NodeRef nodeWithChangedProperties, - Map oldProps, - Map newProps) - { - List scriptRefs = lookupScripts(oldProps, newProps); - - Map objectModel = new HashMap(1); - objectModel.put("node", nodeWithChangedProperties); - objectModel.put("oldProperties", oldProps); - objectModel.put("newProperties", newProps); - for (NodeRef scriptRef : scriptRefs) - { - scriptService.executeScript(scriptRef, null, objectModel); - } - } - - /** - * This method determines which properties have changed and for each such property - * looks for a script resource in a well-known location. - * - * @param oldProps the old properties and their values. - * @param newProps the new properties and their values. - * @return A list of nodeRefs corresponding to the Script resources. - * - * @see #determineChangedProps(Map, Map) - */ - private List lookupScripts(Map oldProps, Map newProps) - { - List result = new ArrayList(); - - Map changedProps = PropertyMap.getChangedProperties(oldProps, newProps); - for (QName propQName : changedProps.keySet()) - { - QName prefixedQName = propQName.getPrefixedQName(namespaceService); - - String [] splitQName = QName.splitPrefixedQName(prefixedQName.toPrefixString()); - final String shortPrefix = splitQName[0]; - final String localName = splitQName[1]; - - // This is the filename pattern which is assumed. - // e.g. a script file cm_name.js would be called for changed to cm:name - String expectedScriptName = shortPrefix + "_" + localName + ".js"; - - NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); - if (nextElement != null) - { - result.add(nextElement); - } - } - - return result; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef)) - { - // Look up the root and set on the aspect if found - NodeRef root = filePlanService.getFilePlan(nodeRef); - if (root != null) - { - nodeService.setProperty(nodeRef, PROP_ROOT_NODEREF, root); - } - - // If the node has any renditions, they inherit the file plan from their source node. - List renditions = renditionService.getRenditions(nodeRef); - NodeRef rendition; - for (ChildAssociationRef chAssRef : renditions) - { - rendition = chAssRef.getChildRef(); - if (nodeService.exists(rendition)) - { - // Apply file plan component aspect to node's renditions - nodeService.addAspect(rendition, ASPECT_FILE_PLAN_COMPONENT, null); - } - } - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(newChildAssocRef.getParentRef()) && - nodeService.exists(newChildAssocRef.getChildRef())) - { - // Look up the root and re-set the value currently stored on the aspect - NodeRef root = filePlanService.getFilePlan(newChildAssocRef.getParentRef()); - // NOTE: set the null value if no root found - nodeService.setProperty(newChildAssocRef.getChildRef(), PROP_ROOT_NODEREF, root); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Copy behaviour call back - * - * @param classRef class reference - * @param copyDetail details of the information being copied - * @return CopyBehaviourCallback - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new AbstractCopyBehaviourCallback() - { - /** - * @see org.alfresco.repo.copy.CopyBehaviourCallback#getChildAssociationCopyAction(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails, org.alfresco.repo.copy.CopyBehaviourCallback.CopyChildAssociationDetails) - */ - public ChildAssocCopyAction getChildAssociationCopyAction( - QName classQName, - CopyDetails copyDetails, - CopyChildAssociationDetails childAssocCopyDetails) - { - // Do not copy the associations - return null; - } - - /** - * @see org.alfresco.repo.copy.CopyBehaviourCallback#getCopyProperties(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails, java.util.Map) - */ - public Map getCopyProperties( - QName classQName, - CopyDetails copyDetails, - Map properties) - { - // Only copy the root node reference if the new value can be looked up via the parent - NodeRef root = filePlanService.getFilePlan(copyDetails.getTargetParentNodeRef()); - if (root != null) - { - properties.put(PROP_ROOT_NODEREF, root); - } - return properties; - } - - /** - * @see org.alfresco.repo.copy.CopyBehaviourCallback#getMustCopy(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails) - */ - public boolean getMustCopy(QName classQName, CopyDetails copyDetails) - { - // Ensure the aspect is copied - return true; - } - }; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.AbstractCopyBehaviourCallback; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.rendition.RenditionService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.ScriptService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.PropertyMap; + +/** + * rma:filePlanComponent behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:filePlanComponent" +) +public class FilePlanComponentAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnUpdatePropertiesPolicy, + NodeServicePolicies.OnAddAspectPolicy, + NodeServicePolicies.OnMoveNodePolicy + + +{ + /** Well-known location of the scripts folder. */ + private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_behavior_scripts"); + + /** script service */ + private ScriptService scriptService; + + /** namespace service */ + private NamespaceService namespaceService; + + /** file plan service */ + private FilePlanService filePlanService; + + /** rendition service */ + private RenditionService renditionService; + + /** + * @param scriptService set script service + */ + public void setScriptService(ScriptService scriptService) + { + this.scriptService = scriptService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param renditionService rendition service + */ + public void setRenditionService(RenditionService service) + { + this.renditionService = service; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef)) + { + lookupAndExecuteScripts(nodeRef, before, after); + } + + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + /** + * This method examines the old and new property sets and for those properties which + * have changed, looks for script resources corresponding to those properties. + * Those scripts are then called via the ScriptService. + * + * @param nodeWithChangedProperties the node whose properties have changed. + * @param oldProps the old properties and their values. + * @param newProps the new properties and their values. + * + * @see #lookupScripts(Map, Map) + */ + private void lookupAndExecuteScripts(NodeRef nodeWithChangedProperties, + Map oldProps, + Map newProps) + { + List scriptRefs = lookupScripts(oldProps, newProps); + + Map objectModel = new HashMap(1); + objectModel.put("node", nodeWithChangedProperties); + objectModel.put("oldProperties", oldProps); + objectModel.put("newProperties", newProps); + for (NodeRef scriptRef : scriptRefs) + { + scriptService.executeScript(scriptRef, null, objectModel); + } + } + + /** + * This method determines which properties have changed and for each such property + * looks for a script resource in a well-known location. + * + * @param oldProps the old properties and their values. + * @param newProps the new properties and their values. + * @return A list of nodeRefs corresponding to the Script resources. + * + * @see #determineChangedProps(Map, Map) + */ + private List lookupScripts(Map oldProps, Map newProps) + { + List result = new ArrayList(); + + Map changedProps = PropertyMap.getChangedProperties(oldProps, newProps); + for (QName propQName : changedProps.keySet()) + { + QName prefixedQName = propQName.getPrefixedQName(namespaceService); + + String [] splitQName = QName.splitPrefixedQName(prefixedQName.toPrefixString()); + final String shortPrefix = splitQName[0]; + final String localName = splitQName[1]; + + // This is the filename pattern which is assumed. + // e.g. a script file cm_name.js would be called for changed to cm:name + String expectedScriptName = shortPrefix + "_" + localName + ".js"; + + NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); + if (nextElement != null) + { + result.add(nextElement); + } + } + + return result; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef)) + { + // Look up the root and set on the aspect if found + NodeRef root = filePlanService.getFilePlan(nodeRef); + if (root != null) + { + nodeService.setProperty(nodeRef, PROP_ROOT_NODEREF, root); + } + + // If the node has any renditions, they inherit the file plan from their source node. + List renditions = renditionService.getRenditions(nodeRef); + NodeRef rendition; + for (ChildAssociationRef chAssRef : renditions) + { + rendition = chAssRef.getChildRef(); + if (nodeService.exists(rendition)) + { + // Apply file plan component aspect to node's renditions + nodeService.addAspect(rendition, ASPECT_FILE_PLAN_COMPONENT, null); + } + } + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(newChildAssocRef.getParentRef()) && + nodeService.exists(newChildAssocRef.getChildRef())) + { + // Look up the root and re-set the value currently stored on the aspect + NodeRef root = filePlanService.getFilePlan(newChildAssocRef.getParentRef()); + // NOTE: set the null value if no root found + nodeService.setProperty(newChildAssocRef.getChildRef(), PROP_ROOT_NODEREF, root); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Copy behaviour call back + * + * @param classRef class reference + * @param copyDetail details of the information being copied + * @return CopyBehaviourCallback + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new AbstractCopyBehaviourCallback() + { + /** + * @see org.alfresco.repo.copy.CopyBehaviourCallback#getChildAssociationCopyAction(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails, org.alfresco.repo.copy.CopyBehaviourCallback.CopyChildAssociationDetails) + */ + public ChildAssocCopyAction getChildAssociationCopyAction( + QName classQName, + CopyDetails copyDetails, + CopyChildAssociationDetails childAssocCopyDetails) + { + // Do not copy the associations + return null; + } + + /** + * @see org.alfresco.repo.copy.CopyBehaviourCallback#getCopyProperties(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails, java.util.Map) + */ + public Map getCopyProperties( + QName classQName, + CopyDetails copyDetails, + Map properties) + { + // Only copy the root node reference if the new value can be looked up via the parent + NodeRef root = filePlanService.getFilePlan(copyDetails.getTargetParentNodeRef()); + if (root != null) + { + properties.put(PROP_ROOT_NODEREF, root); + } + return properties; + } + + /** + * @see org.alfresco.repo.copy.CopyBehaviourCallback#getMustCopy(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails) + */ + public boolean getMustCopy(QName classQName, CopyDetails copyDetails) + { + // Ensure the aspect is copied + return true; + } + }; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java index 15a8111362..a970752b43 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java @@ -1,205 +1,205 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * rma:frozen behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:frozen" -) -public class FrozenAspect extends BaseBehaviourBean - implements NodeServicePolicies.BeforeDeleteNodePolicy, - NodeServicePolicies.OnAddAspectPolicy, - NodeServicePolicies.OnRemoveAspectPolicy -{ - /** file plan service */ - protected FilePlanService filePlanService; - - /** freeze service */ - protected FreezeService freezeService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param freezeService freeze service - */ - public void setFreezeService(FreezeService freezeService) - { - this.freezeService = freezeService; - } - - /** - * Ensure that no frozen node is deleted. - * - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void beforeDeleteNode(final NodeRef nodeRef) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(nodeRef) && - filePlanService.isFilePlanComponent(nodeRef)) - { - if (freezeService.isFrozen(nodeRef)) - { - // never allowed to delete a frozen node - throw new AccessDeniedException("Frozen nodes can not be deleted."); - } - - // check children - checkChildren(nodeService.getChildAssocs(nodeRef)); - } - return null; - } - }); - } - - /** - * Checks the children for frozen nodes. Throws security error if any are - * found. - * - * @param assocs - */ - private void checkChildren(List assocs) - { - for (ChildAssociationRef assoc : assocs) - { - // we only care about primary children - if (assoc.isPrimary()) - { - NodeRef nodeRef = assoc.getChildRef(); - if (freezeService.isFrozen(nodeRef)) - { - // never allowed to delete a node with a frozen child - throw new AccessDeniedException("Can not delete node, because it contains a frozen child node."); - } - - // check children - checkChildren(nodeService.getChildAssocs(nodeRef)); - } - } - } - - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onAddAspect(final NodeRef record, final QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(record) && - isRecord(record)) - { - // get the owning record folder - NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); - // check that the aspect has been added - if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)) - { - // increment current count - int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT); - currentCount = currentCount + 1; - nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount); - } - } - return null; - } - }); - } - - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onRemoveAspect(final NodeRef record, QName aspectTypeQName) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - if (nodeService.exists(record) && - isRecord(record)) - { - // get the owning record folder - NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); - - // check that the aspect has been added - if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)) - { - // decrement current count - int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT); - if (currentCount > 0) - { - currentCount = currentCount - 1; - nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount); - } - } - } - return null; - } - }); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * rma:frozen behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:frozen" +) +public class FrozenAspect extends BaseBehaviourBean + implements NodeServicePolicies.BeforeDeleteNodePolicy, + NodeServicePolicies.OnAddAspectPolicy, + NodeServicePolicies.OnRemoveAspectPolicy +{ + /** file plan service */ + protected FilePlanService filePlanService; + + /** freeze service */ + protected FreezeService freezeService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param freezeService freeze service + */ + public void setFreezeService(FreezeService freezeService) + { + this.freezeService = freezeService; + } + + /** + * Ensure that no frozen node is deleted. + * + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void beforeDeleteNode(final NodeRef nodeRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(nodeRef) && + filePlanService.isFilePlanComponent(nodeRef)) + { + if (freezeService.isFrozen(nodeRef)) + { + // never allowed to delete a frozen node + throw new AccessDeniedException("Frozen nodes can not be deleted."); + } + + // check children + checkChildren(nodeService.getChildAssocs(nodeRef)); + } + return null; + } + }); + } + + /** + * Checks the children for frozen nodes. Throws security error if any are + * found. + * + * @param assocs + */ + private void checkChildren(List assocs) + { + for (ChildAssociationRef assoc : assocs) + { + // we only care about primary children + if (assoc.isPrimary()) + { + NodeRef nodeRef = assoc.getChildRef(); + if (freezeService.isFrozen(nodeRef)) + { + // never allowed to delete a node with a frozen child + throw new AccessDeniedException("Can not delete node, because it contains a frozen child node."); + } + + // check children + checkChildren(nodeService.getChildAssocs(nodeRef)); + } + } + } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onAddAspect(final NodeRef record, final QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(record) && + isRecord(record)) + { + // get the owning record folder + NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); + // check that the aspect has been added + if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)) + { + // increment current count + int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT); + currentCount = currentCount + 1; + nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount); + } + } + return null; + } + }); + } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onRemoveAspect(final NodeRef record, QName aspectTypeQName) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(record) && + isRecord(record)) + { + // get the owning record folder + NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); + + // check that the aspect has been added + if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)) + { + // decrement current count + int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT); + if (currentCount > 0) + { + currentCount = currentCount - 1; + nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount); + } + } + } + return null; + } + }); + + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java index 6b96e61fc6..4133abafea 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java @@ -1,73 +1,73 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.content.ContentServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * rma:ghosted behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - // optional - defaultType = "rma:ghosted" -) -public class GhostedAspect extends BaseBehaviourBean - implements ContentServicePolicies.OnContentUpdatePolicy -{ - /** I18N */ - private static final String MSG_GHOSTED_PROP_UPDATE = "rm.action.ghosted-prop-update"; - - /** - * Ensure that the content of a ghosted node can not be updated. - * - * @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - @Behaviour - ( - // required, use ASSOC for association behaviors - kind = BehaviourKind.CLASS, - // (defaults to EVERY_EVENT) - notificationFrequency = NotificationFrequency.EVERY_EVENT, - // (defaults to alf:) - policy = "alf:onContentUpdate", - // required, unless defaultType set - type = "rma:ghosted" - - // isService (default false) - // name (only needs to specified if associated behvaiour object needs to be accessed) - // assocType (defaults to cm:contains, used with BehaviourKind.ASSOC) - ) - public void onContentUpdate(NodeRef content, boolean bNew) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_GHOSTED_PROP_UPDATE)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.content.ContentServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * rma:ghosted behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + // optional + defaultType = "rma:ghosted" +) +public class GhostedAspect extends BaseBehaviourBean + implements ContentServicePolicies.OnContentUpdatePolicy +{ + /** I18N */ + private static final String MSG_GHOSTED_PROP_UPDATE = "rm.action.ghosted-prop-update"; + + /** + * Ensure that the content of a ghosted node can not be updated. + * + * @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + @Behaviour + ( + // required, use ASSOC for association behaviors + kind = BehaviourKind.CLASS, + // (defaults to EVERY_EVENT) + notificationFrequency = NotificationFrequency.EVERY_EVENT, + // (defaults to alf:) + policy = "alf:onContentUpdate", + // required, unless defaultType set + type = "rma:ghosted" + + // isService (default false) + // name (only needs to specified if associated behvaiour object needs to be accessed) + // assocType (defaults to cm:contains, used with BehaviourKind.ASSOC) + ) + public void onContentUpdate(NodeRef content, boolean bNew) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_GHOSTED_PROP_UPDATE)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index 91159b6096..c0db7a81ce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -1,321 +1,321 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.CopyServicePolicies; -import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.ScriptService; -import org.alfresco.service.namespace.QName; - -/** - * rma:record behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:record" -) -public class RecordAspect extends AbstractDisposableItem - implements NodeServicePolicies.OnCreateChildAssociationPolicy, - RecordsManagementPolicies.OnCreateReference, - RecordsManagementPolicies.OnRemoveReference, - NodeServicePolicies.OnMoveNodePolicy, - CopyServicePolicies.OnCopyCompletePolicy -{ - /** Well-known location of the scripts folder. */ - // TODO make configurable - private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_behavior_scripts"); - - /** extended security service */ - protected ExtendedSecurityService extendedSecurityService; - - /** script service */ - protected ScriptService scriptService; - - /** record service */ - protected RecordService recordService; - - /** - * @param extendedSecurityService extended security service - */ - public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) - { - this.extendedSecurityService = extendedSecurityService; - } - - /** - * @param scriptService script service - */ - public void setScriptService(ScriptService scriptService) - { - this.scriptService = scriptService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * Behaviour to ensure renditions have the appropriate extended security. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - assocType = "rn:rendition", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean bNew) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - NodeRef thumbnail = childAssocRef.getChildRef(); - - if (nodeService.exists(thumbnail)) - { - // apply file plan component aspect to thumbnail - nodeService.addAspect(thumbnail, ASPECT_FILE_PLAN_COMPONENT, null); - - // manage any extended readers - NodeRef parent = childAssocRef.getParentRef(); - Set readers = extendedSecurityService.getReaders(parent); - Set writers = extendedSecurityService.getWriters(parent); - if (readers != null && readers.size() != 0) - { - extendedSecurityService.set(thumbnail, readers, writers); - } - } - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) - { - // Deal with versioned records - if (reference.equals(CUSTOM_REF_VERSIONS)) - { - // Apply the versioned aspect to the from node - nodeService.addAspect(fromNodeRef, ASPECT_VERSIONED_RECORD, null); - } - - // Execute script if for the reference event - executeReferenceScript("onCreate", reference, fromNodeRef, toNodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRemoveReference#onRemoveReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onRemoveReference(final NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) - { - // Deal with versioned records - if (reference.equals(CUSTOM_REF_VERSIONS)) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // Apply the versioned aspect to the from node - nodeService.removeAspect(fromNodeRef, ASPECT_VERSIONED_RECORD); - - return null; - } - }); - } - - // Execute script if for the reference event - executeReferenceScript("onRemove", reference, fromNodeRef, toNodeRef); - } - - /** - * Record copy callback - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(final QName classRef, final CopyDetails copyDetails) - { - return new DefaultCopyBehaviourCallback() - { - - @Override - public Map getCopyProperties(QName classRef, CopyDetails copyDetails, - Map properties) - { - Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); - - // Remove the Date Filed property from record properties on copy. - // It will be generated for the copy - if (sourceProperties.containsKey(PROP_DATE_FILED)) - { - sourceProperties.remove(PROP_DATE_FILED); - } - - return sourceProperties; - } - - }; - } - - /** - * Record move behaviour - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - // check the records parent has actually changed - if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef()) && - isFilePlanComponent(oldChildAssocRef.getParentRef())) - { - final NodeRef record = newChildAssocRef.getChildRef(); - authenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - if (nodeService.exists(record) && - recordService.isFiled(record)) - { - // clean record - cleanDisposableItem(nodeService, record); - - // re-file in the new folder - recordService.file(record); - } - - return null; - } - }, authenticationUtil.getAdminUserName()); - } - } - - /** - * Executes a reference script if present - * - * @param policy policy - * @param reference reference - * @param from reference from - * @param to reference to - */ - private void executeReferenceScript(String policy, QName reference, NodeRef from, NodeRef to) - { - String referenceId = reference.getLocalName(); - - // This is the filename pattern which is assumed. - // e.g. a script file onCreate_superceded.js for the creation of a superseded reference - String expectedScriptName = policy + "_" + referenceId + ".js"; - - NodeRef scriptNodeRef = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); - if (scriptNodeRef != null) - { - Map objectModel = new HashMap(1); - objectModel.put("node", from); - objectModel.put("toNode", to); - objectModel.put("policy", policy); - objectModel.put("reference", referenceId); - - scriptService.executeScript(scriptNodeRef, null, objectModel); - } - } - - /** - * On copy complete behaviour for record aspect. - * - * @param classRef - * @param sourceNodeRef - * @param targetNodeRef - * @param copyToNewNode - * @param copyMap - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS - ) - public void onCopyComplete(QName classRef, - NodeRef sourceNodeRef, - NodeRef targetNodeRef, - boolean copyToNewNode, - Map copyMap) - { - // given the node exists and is a record - if (nodeService.exists(targetNodeRef) && - nodeService.hasAspect(targetNodeRef, ASPECT_RECORD)) - { - // then remove any extended security from the newly copied record - extendedSecurityService.remove(targetNodeRef); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.CopyServicePolicies; +import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.ScriptService; +import org.alfresco.service.namespace.QName; + +/** + * rma:record behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:record" +) +public class RecordAspect extends AbstractDisposableItem + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + RecordsManagementPolicies.OnCreateReference, + RecordsManagementPolicies.OnRemoveReference, + NodeServicePolicies.OnMoveNodePolicy, + CopyServicePolicies.OnCopyCompletePolicy +{ + /** Well-known location of the scripts folder. */ + // TODO make configurable + private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_behavior_scripts"); + + /** extended security service */ + protected ExtendedSecurityService extendedSecurityService; + + /** script service */ + protected ScriptService scriptService; + + /** record service */ + protected RecordService recordService; + + /** + * @param extendedSecurityService extended security service + */ + public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) + { + this.extendedSecurityService = extendedSecurityService; + } + + /** + * @param scriptService script service + */ + public void setScriptService(ScriptService scriptService) + { + this.scriptService = scriptService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * Behaviour to ensure renditions have the appropriate extended security. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + assocType = "rn:rendition", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean bNew) + { + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + NodeRef thumbnail = childAssocRef.getChildRef(); + + if (nodeService.exists(thumbnail)) + { + // apply file plan component aspect to thumbnail + nodeService.addAspect(thumbnail, ASPECT_FILE_PLAN_COMPONENT, null); + + // manage any extended readers + NodeRef parent = childAssocRef.getParentRef(); + Set readers = extendedSecurityService.getReaders(parent); + Set writers = extendedSecurityService.getWriters(parent); + if (readers != null && readers.size() != 0) + { + extendedSecurityService.set(thumbnail, readers, writers); + } + } + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) + { + // Deal with versioned records + if (reference.equals(CUSTOM_REF_VERSIONS)) + { + // Apply the versioned aspect to the from node + nodeService.addAspect(fromNodeRef, ASPECT_VERSIONED_RECORD, null); + } + + // Execute script if for the reference event + executeReferenceScript("onCreate", reference, fromNodeRef, toNodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRemoveReference#onRemoveReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onRemoveReference(final NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) + { + // Deal with versioned records + if (reference.equals(CUSTOM_REF_VERSIONS)) + { + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Apply the versioned aspect to the from node + nodeService.removeAspect(fromNodeRef, ASPECT_VERSIONED_RECORD); + + return null; + } + }); + } + + // Execute script if for the reference event + executeReferenceScript("onRemove", reference, fromNodeRef, toNodeRef); + } + + /** + * Record copy callback + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(final QName classRef, final CopyDetails copyDetails) + { + return new DefaultCopyBehaviourCallback() + { + + @Override + public Map getCopyProperties(QName classRef, CopyDetails copyDetails, + Map properties) + { + Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); + + // Remove the Date Filed property from record properties on copy. + // It will be generated for the copy + if (sourceProperties.containsKey(PROP_DATE_FILED)) + { + sourceProperties.remove(PROP_DATE_FILED); + } + + return sourceProperties; + } + + }; + } + + /** + * Record move behaviour + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + // check the records parent has actually changed + if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef()) && + isFilePlanComponent(oldChildAssocRef.getParentRef())) + { + final NodeRef record = newChildAssocRef.getChildRef(); + authenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + if (nodeService.exists(record) && + recordService.isFiled(record)) + { + // clean record + cleanDisposableItem(nodeService, record); + + // re-file in the new folder + recordService.file(record); + } + + return null; + } + }, authenticationUtil.getAdminUserName()); + } + } + + /** + * Executes a reference script if present + * + * @param policy policy + * @param reference reference + * @param from reference from + * @param to reference to + */ + private void executeReferenceScript(String policy, QName reference, NodeRef from, NodeRef to) + { + String referenceId = reference.getLocalName(); + + // This is the filename pattern which is assumed. + // e.g. a script file onCreate_superceded.js for the creation of a superseded reference + String expectedScriptName = policy + "_" + referenceId + ".js"; + + NodeRef scriptNodeRef = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); + if (scriptNodeRef != null) + { + Map objectModel = new HashMap(1); + objectModel.put("node", from); + objectModel.put("toNode", to); + objectModel.put("policy", policy); + objectModel.put("reference", referenceId); + + scriptService.executeScript(scriptNodeRef, null, objectModel); + } + } + + /** + * On copy complete behaviour for record aspect. + * + * @param classRef + * @param sourceNodeRef + * @param targetNodeRef + * @param copyToNewNode + * @param copyMap + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS + ) + public void onCopyComplete(QName classRef, + NodeRef sourceNodeRef, + NodeRef targetNodeRef, + boolean copyToNewNode, + Map copyMap) + { + // given the node exists and is a record + if (nodeService.exists(targetNodeRef) && + nodeService.hasAspect(targetNodeRef, ASPECT_RECORD)) + { + // then remove any extended security from the newly copied record + extendedSecurityService.remove(targetNodeRef); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java index 979171ac9d..76efa8271a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java @@ -1,232 +1,232 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.CopyServicePolicies; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * rma:recordComponentIdentifier behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordComponentIdentifier" -) -public class RecordComponentIdentifierAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnUpdatePropertiesPolicy, - NodeServicePolicies.BeforeDeleteNodePolicy, - CopyServicePolicies.OnCopyCompletePolicy -{ - /** I18N */ - private static final String MSG_SET_ID = "rm.service.set-id"; - - /** attribute context value */ - private static final String CONTEXT_VALUE = "rma:identifier"; - - /** file plan service */ - private FilePlanService filePlanService; - - /** attribute service */ - private AttributeService attributeService; - - /** identifier service */ - private IdentifierService identifierService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param attributeService attribute service - */ - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - /** - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /** - * Ensures that the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property remains - * unique within the context of the parent node. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT - ) - public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - String newIdValue = (String)after.get(PROP_IDENTIFIER); - if (newIdValue != null) - { - String oldIdValue = (String)before.get(PROP_IDENTIFIER); - if (oldIdValue != null && !oldIdValue.equals(newIdValue)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SET_ID, nodeRef.toString())); - } - - // update uniqueness - updateUniqueness(nodeRef, oldIdValue, newIdValue); - } - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Cleans up the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property unique triplet. - * - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT - ) - public void beforeDeleteNode(final NodeRef nodeRef) - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - String beforeId = (String) nodeService.getProperty(nodeRef, PROP_IDENTIFIER); - updateUniqueness(nodeRef, beforeId, null); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Record component identifier aspect copy callback - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } - - @SuppressWarnings("rawtypes") - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode, Map copyMap) - { - //Generate the id for the copy - String id = identifierService.generateIdentifier( - nodeService.getType(nodeService.getPrimaryParent(targetNodeRef).getParentRef()), - nodeService.getPrimaryParent(targetNodeRef).getParentRef()); - - //We need to allow the id to be overwritten disable the policy protecting changes to the id - behaviourFilter.disableBehaviour(); - try - { - nodeService.setProperty(targetNodeRef, PROP_IDENTIFIER, id); - } - finally - { - behaviourFilter.enableBehaviour(); - } - } - - /** - * Updates the uniqueness check using the values provided. If the after value is null - * then this is considered to be a removal. - * - * @param nodeRef node reference - * @param beforeId id before - * @param afterId id after - */ - private void updateUniqueness(NodeRef nodeRef, String beforeId, String afterId) - { - NodeRef contextNodeRef = filePlanService.getFilePlan(nodeRef); - - if (beforeId == null) - { - if (afterId != null) - { - // Just create it - attributeService.createAttribute(null, CONTEXT_VALUE, contextNodeRef, afterId); - } - } - else if (afterId == null) - { - // The before value was not null, so remove it - attributeService.removeAttribute(CONTEXT_VALUE, contextNodeRef, beforeId); - // Do a blanket removal in case this is a contextual nodes - attributeService.removeAttributes(CONTEXT_VALUE, nodeRef); - } - else - { - // This is a full update - attributeService.updateOrCreateAttribute( - CONTEXT_VALUE, contextNodeRef, beforeId, - CONTEXT_VALUE, contextNodeRef, afterId); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.CopyServicePolicies; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.attributes.AttributeService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * rma:recordComponentIdentifier behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordComponentIdentifier" +) +public class RecordComponentIdentifierAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnUpdatePropertiesPolicy, + NodeServicePolicies.BeforeDeleteNodePolicy, + CopyServicePolicies.OnCopyCompletePolicy +{ + /** I18N */ + private static final String MSG_SET_ID = "rm.service.set-id"; + + /** attribute context value */ + private static final String CONTEXT_VALUE = "rma:identifier"; + + /** file plan service */ + private FilePlanService filePlanService; + + /** attribute service */ + private AttributeService attributeService; + + /** identifier service */ + private IdentifierService identifierService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param attributeService attribute service + */ + public void setAttributeService(AttributeService attributeService) + { + this.attributeService = attributeService; + } + + /** + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /** + * Ensures that the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property remains + * unique within the context of the parent node. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.EVERY_EVENT + ) + public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) + { + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + String newIdValue = (String)after.get(PROP_IDENTIFIER); + if (newIdValue != null) + { + String oldIdValue = (String)before.get(PROP_IDENTIFIER); + if (oldIdValue != null && !oldIdValue.equals(newIdValue)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SET_ID, nodeRef.toString())); + } + + // update uniqueness + updateUniqueness(nodeRef, oldIdValue, newIdValue); + } + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Cleans up the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property unique triplet. + * + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.EVERY_EVENT + ) + public void beforeDeleteNode(final NodeRef nodeRef) + { + AuthenticationUtil.runAs(new RunAsWork() + { + public Object doWork() + { + String beforeId = (String) nodeService.getProperty(nodeRef, PROP_IDENTIFIER); + updateUniqueness(nodeRef, beforeId, null); + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Record component identifier aspect copy callback + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } + + @SuppressWarnings("rawtypes") + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode, Map copyMap) + { + //Generate the id for the copy + String id = identifierService.generateIdentifier( + nodeService.getType(nodeService.getPrimaryParent(targetNodeRef).getParentRef()), + nodeService.getPrimaryParent(targetNodeRef).getParentRef()); + + //We need to allow the id to be overwritten disable the policy protecting changes to the id + behaviourFilter.disableBehaviour(); + try + { + nodeService.setProperty(targetNodeRef, PROP_IDENTIFIER, id); + } + finally + { + behaviourFilter.enableBehaviour(); + } + } + + /** + * Updates the uniqueness check using the values provided. If the after value is null + * then this is considered to be a removal. + * + * @param nodeRef node reference + * @param beforeId id before + * @param afterId id after + */ + private void updateUniqueness(NodeRef nodeRef, String beforeId, String afterId) + { + NodeRef contextNodeRef = filePlanService.getFilePlan(nodeRef); + + if (beforeId == null) + { + if (afterId != null) + { + // Just create it + attributeService.createAttribute(null, CONTEXT_VALUE, contextNodeRef, afterId); + } + } + else if (afterId == null) + { + // The before value was not null, so remove it + attributeService.removeAttribute(CONTEXT_VALUE, contextNodeRef, beforeId); + // Do a blanket removal in case this is a contextual nodes + attributeService.removeAttributes(CONTEXT_VALUE, nodeRef); + } + else + { + // This is a full update + attributeService.updateOrCreateAttribute( + CONTEXT_VALUE, contextNodeRef, beforeId, + CONTEXT_VALUE, contextNodeRef, afterId); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordOriginatingDetailsAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordOriginatingDetailsAspect.java index 5b69d1d5e7..76077403c2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordOriginatingDetailsAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordOriginatingDetailsAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:recordOriginatingDetails behaviour bean - * - * @author Mark Hibbins - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordOriginatingDetails" -) -public class RecordOriginatingDetailsAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Record originating details aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:recordOriginatingDetails behaviour bean + * + * @author Mark Hibbins + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordOriginatingDetails" +) +public class RecordOriginatingDetailsAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Record originating details aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordSearchAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordSearchAspect.java index 6b178b50bd..7afa4e8e68 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordSearchAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordSearchAspect.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:recordSearch behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordSearch" -) -public class RecordSearchAspect extends BaseBehaviourBean -{ - /** - * Copy callback for record search - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:recordSearch behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordSearch" +) +public class RecordSearchAspect extends BaseBehaviourBean +{ + /** + * Copy callback for record search + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ScheduledAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ScheduledAspect.java index 7576764a0f..2bca5c91f5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ScheduledAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ScheduledAspect.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Behaviour associated with the scheduled aspect - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:scheduled" -) -public class ScheduledAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnAddAspectPolicy -{ - /** disposition service */ - private DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) - { - if (nodeService.exists(nodeRef) && - dispositionService.getAssociatedDispositionSchedule(nodeRef) == null) - { - dispositionService.createDispositionSchedule(nodeRef, null); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Behaviour associated with the scheduled aspect + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:scheduled" +) +public class ScheduledAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnAddAspectPolicy +{ + /** disposition service */ + private DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) + { + if (nodeService.exists(nodeRef) && + dispositionService.getAssociatedDispositionSchedule(nodeRef) == null) + { + dispositionService.createDispositionSchedule(nodeRef, null); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferredAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferredAspect.java index dcf26dd4bb..667d866648 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferredAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferredAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:transferred behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:transferred" -) -public class TransferredAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:transferred behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:transferred" +) +public class TransferredAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferringAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferringAspect.java index 24158470a1..c8292f773e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferringAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/TransferringAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:transferring behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:transferring" -) -public class TransferringAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:transferring behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:transferring" +) +public class TransferringAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/UncutoffAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/UncutoffAspect.java index f417ba639e..40012caa88 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/UncutoffAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/UncutoffAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:uncutoff behaviour bean - * - * @author Mark Hibbins - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:uncutOff" -) -public class UncutoffAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Uncutoff aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:uncutoff behaviour bean + * + * @author Mark Hibbins + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:uncutOff" +) +public class UncutoffAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Uncutoff aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspect.java index 3eb9e0865d..9e2213249d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspect.java @@ -1,123 +1,123 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; - -/** - * rmv:versionRecord behaviour bean - * - * @author Roy Wetherall - * @since 2.3.1 - */ -@BehaviourBean -( - defaultType = "rmv:versionRecord" -) -public class VersionRecordAspect extends BaseBehaviourBean - implements NodeServicePolicies.BeforeDeleteNodePolicy -{ - /** recordable version service */ - private RecordableVersionService recordableVersionService; - - /** relationship service */ - private RelationshipService relationshipService; - - /** - * @param recordableVersionService recordable version service - */ - public void setRecordableVersionService(RecordableVersionService recordableVersionService) - { - this.recordableVersionService = recordableVersionService; - } - - /** - * @param relationshipService relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * If the record is a version record then delete the associated version entry - * - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour (kind = BehaviourKind.CLASS) - public void beforeDeleteNode(final NodeRef nodeRef) - { - final Version version = recordableVersionService.getRecordedVersion(nodeRef); - if (version != null) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - behaviourFilter.disableBehaviour(); - try - { - // mark the associated version as destroyed - recordableVersionService.destroyRecordedVersion(version); - - // re-organise the versions relationships ... - // if there is only one "to" reference since a version can only have one predecessor - Set tos = relationshipService.getRelationshipsTo(nodeRef, RelationshipService.RELATIONSHIP_VERSIONS); - if (!tos.isEmpty() && tos.size() == 1) - { - // if there is some "from" references - Set froms = relationshipService.getRelationshipsFrom(nodeRef, RelationshipService.RELATIONSHIP_VERSIONS); - if (!froms.isEmpty()) - { - // get predecessor version relationship - Relationship to = tos.iterator().next(); - - for (Relationship from : froms) - { - // point the "to" the all the "from's" - relationshipService.addRelationship(RelationshipService.RELATIONSHIP_VERSIONS, to.getSource(), from.getTarget()); - } - } - } - } - finally - { - behaviourFilter.enableBehaviour(); - } - - return null; - } - }); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; + +/** + * rmv:versionRecord behaviour bean + * + * @author Roy Wetherall + * @since 2.3.1 + */ +@BehaviourBean +( + defaultType = "rmv:versionRecord" +) +public class VersionRecordAspect extends BaseBehaviourBean + implements NodeServicePolicies.BeforeDeleteNodePolicy +{ + /** recordable version service */ + private RecordableVersionService recordableVersionService; + + /** relationship service */ + private RelationshipService relationshipService; + + /** + * @param recordableVersionService recordable version service + */ + public void setRecordableVersionService(RecordableVersionService recordableVersionService) + { + this.recordableVersionService = recordableVersionService; + } + + /** + * @param relationshipService relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * If the record is a version record then delete the associated version entry + * + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour (kind = BehaviourKind.CLASS) + public void beforeDeleteNode(final NodeRef nodeRef) + { + final Version version = recordableVersionService.getRecordedVersion(nodeRef); + if (version != null) + { + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + behaviourFilter.disableBehaviour(); + try + { + // mark the associated version as destroyed + recordableVersionService.destroyRecordedVersion(version); + + // re-organise the versions relationships ... + // if there is only one "to" reference since a version can only have one predecessor + Set tos = relationshipService.getRelationshipsTo(nodeRef, RelationshipService.RELATIONSHIP_VERSIONS); + if (!tos.isEmpty() && tos.size() == 1) + { + // if there is some "from" references + Set froms = relationshipService.getRelationshipsFrom(nodeRef, RelationshipService.RELATIONSHIP_VERSIONS); + if (!froms.isEmpty()) + { + // get predecessor version relationship + Relationship to = tos.iterator().next(); + + for (Relationship from : froms) + { + // point the "to" the all the "from's" + relationshipService.addRelationship(RelationshipService.RELATIONSHIP_VERSIONS, to.getSource(), from.getTarget()); + } + } + } + } + finally + { + behaviourFilter.enableBehaviour(); + } + + return null; + } + }); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordAspect.java index a5c00a74ad..7fa3acbb1f 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordAspect.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rma:vitalRecord behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:vitalRecord" -) -public class VitalRecordAspect extends BaseBehaviourBean -{ - /** - * Copy callback for vital record - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rma:vitalRecord behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:vitalRecord" +) +public class VitalRecordAspect extends BaseBehaviourBean +{ + /** + * Copy callback for vital record + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordDefinitionAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordDefinitionAspect.java index 55d84c0b76..69e7a9844b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordDefinitionAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VitalRecordDefinitionAspect.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.PropertyMap; - -/** - * rma:ghosted behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:vitalRecordDefinition" -) -public class VitalRecordDefinitionAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnUpdatePropertiesPolicy -{ - /** records management action service */ - protected RecordsManagementActionService recordsManagementActionService; - - /** - * @param recordsManagementActionService records management action service - */ - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() - { - if (nodeService.exists(nodeRef) && - nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT)) - { - // check that vital record definition has been changed in the first place - Map changedProps = PropertyMap.getChangedProperties(before, after); - if (changedProps.containsKey(PROP_VITAL_RECORD_INDICATOR) || - changedProps.containsKey(PROP_REVIEW_PERIOD)) - { - recordsManagementActionService.executeRecordsManagementAction(nodeRef, "broadcastVitalRecordDefinition"); - } - } - return null; - } - }); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.PropertyMap; + +/** + * rma:ghosted behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:vitalRecordDefinition" +) +public class VitalRecordDefinitionAspect extends BaseBehaviourBean + implements NodeServicePolicies.OnUpdatePropertiesPolicy +{ + /** records management action service */ + protected RecordsManagementActionService recordsManagementActionService; + + /** + * @param recordsManagementActionService records management action service + */ + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() + { + if (nodeService.exists(nodeRef) && + nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT)) + { + // check that vital record definition has been changed in the first place + Map changedProps = PropertyMap.getChangedProperties(before, after); + if (changedProps.containsKey(PROP_VITAL_RECORD_INDICATOR) || + changedProps.containsKey(PROP_REVIEW_PERIOD)) + { + recordsManagementActionService.executeRecordsManagementAction(nodeRef, "broadcastVitalRecordDefinition"); + } + } + return null; + } + }); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/CmObjectType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/CmObjectType.java index bcafbfc2e8..9755ba6948 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/CmObjectType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/CmObjectType.java @@ -1,165 +1,165 @@ -/* - * Copyright (C) 2005-2015 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.model.rma.type; - -import static org.alfresco.util.ParameterCheck.mandatory; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyServicePolicies; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * cm:cmobject behaviour bean - * - * @author Tuna Aksoy - * @since 2.3 - */ -@BehaviourBean -( - defaultType = "cm:cmobject" -) -public class CmObjectType extends BaseBehaviourBean implements NodeServicePolicies.OnMoveNodePolicy, CopyServicePolicies.BeforeCopyPolicy -{ - /** Move behaviour name */ - private static final String MOVE_BEHAVIOUR_NAME = "onMoveCmObjectType"; - - /** Copy behaviour name */ - private static final String COPY_BEHAVIOUR_NAME = "onCopyCmObjectType"; - - /** - * Disable the move behaviour for this transaction - * - */ - public void disableMove() - { - getBehaviour(MOVE_BEHAVIOUR_NAME).disable(); - } - - /** - * Enable the move behaviour for this transaction - * - */ - public void enableMove() - { - getBehaviour(MOVE_BEHAVIOUR_NAME).enable(); - } - - /** - * Disable the copy behaviour for this transaction - * - */ - public void disableCopy() - { - getBehaviour(COPY_BEHAVIOUR_NAME).disable(); - } - - /** - * Enable the copy behaviour for this transaction - * - */ - public void enableCopy() - { - getBehaviour(COPY_BEHAVIOUR_NAME).enable(); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - name = MOVE_BEHAVIOUR_NAME - ) - public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - mandatory("oldChildAssocRef", oldChildAssocRef); - mandatory("newChildAssocRef", newChildAssocRef); - - NodeRef sourceParent = oldChildAssocRef.getParentRef(); - boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParent); - - NodeRef targetParent = newChildAssocRef.getParentRef(); - boolean isTargetParentFilePlanComponent = isFilePlanComponent(targetParent); - - // If we are doing the move operation within the RM site then we can stop here - // The method should just check move operations from outside of RM into the RM site - if (isSourceParentFilePlanComponent && isTargetParentFilePlanComponent) - { - return; - } - - NodeRef object = oldChildAssocRef.getChildRef(); - QName objectType = nodeService.getType(object); - - // Only documents can be moved into the RM site - if (!objectType.equals(ContentModel.TYPE_CONTENT) && isTargetParentFilePlanComponent) - { - throw new AlfrescoRuntimeException("Only documents can be moved from a collaboration site into a RM site."); - } - - // Documents can be moved only into a RM folder - if (isTargetParentFilePlanComponent && !isRecordFolder(targetParent)) - { - throw new AlfrescoRuntimeException("A document can only be moved into a folder in RM site."); - } - } - - /** - * @see org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy#beforeCopy(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - name = COPY_BEHAVIOUR_NAME - ) - public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef) - { - mandatory("sourceNodeRef", sourceNodeRef); - mandatory("targetNodeRef", targetNodeRef); - - NodeRef sourceParentNodeRef = nodeService.getPrimaryParent(sourceNodeRef).getParentRef(); - boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParentNodeRef); - - NodeRef targetParentNodeRef = nodeService.getPrimaryParent(targetNodeRef).getParentRef(); - boolean isTargetNodeParentFilePlanComponent = isFilePlanComponent(targetParentNodeRef); - - // If we are doing the copy operation within the RM site then we can stop here - // The method should just check copy operations from outside of RM into the RM site - if (isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) - { - return; - } - - // Do not allow to copy anything outside of RM site into the RM site - if (!isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) - { - throw new AlfrescoRuntimeException("Nothing can be copied from a collaboration site into a RM site."); - } - } -} +/* + * Copyright (C) 2005-2015 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.model.rma.type; + +import static org.alfresco.util.ParameterCheck.mandatory; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyServicePolicies; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * cm:cmobject behaviour bean + * + * @author Tuna Aksoy + * @since 2.3 + */ +@BehaviourBean +( + defaultType = "cm:cmobject" +) +public class CmObjectType extends BaseBehaviourBean implements NodeServicePolicies.OnMoveNodePolicy, CopyServicePolicies.BeforeCopyPolicy +{ + /** Move behaviour name */ + private static final String MOVE_BEHAVIOUR_NAME = "onMoveCmObjectType"; + + /** Copy behaviour name */ + private static final String COPY_BEHAVIOUR_NAME = "onCopyCmObjectType"; + + /** + * Disable the move behaviour for this transaction + * + */ + public void disableMove() + { + getBehaviour(MOVE_BEHAVIOUR_NAME).disable(); + } + + /** + * Enable the move behaviour for this transaction + * + */ + public void enableMove() + { + getBehaviour(MOVE_BEHAVIOUR_NAME).enable(); + } + + /** + * Disable the copy behaviour for this transaction + * + */ + public void disableCopy() + { + getBehaviour(COPY_BEHAVIOUR_NAME).disable(); + } + + /** + * Enable the copy behaviour for this transaction + * + */ + public void enableCopy() + { + getBehaviour(COPY_BEHAVIOUR_NAME).enable(); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = MOVE_BEHAVIOUR_NAME + ) + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + mandatory("oldChildAssocRef", oldChildAssocRef); + mandatory("newChildAssocRef", newChildAssocRef); + + NodeRef sourceParent = oldChildAssocRef.getParentRef(); + boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParent); + + NodeRef targetParent = newChildAssocRef.getParentRef(); + boolean isTargetParentFilePlanComponent = isFilePlanComponent(targetParent); + + // If we are doing the move operation within the RM site then we can stop here + // The method should just check move operations from outside of RM into the RM site + if (isSourceParentFilePlanComponent && isTargetParentFilePlanComponent) + { + return; + } + + NodeRef object = oldChildAssocRef.getChildRef(); + QName objectType = nodeService.getType(object); + + // Only documents can be moved into the RM site + if (!objectType.equals(ContentModel.TYPE_CONTENT) && isTargetParentFilePlanComponent) + { + throw new AlfrescoRuntimeException("Only documents can be moved from a collaboration site into a RM site."); + } + + // Documents can be moved only into a RM folder + if (isTargetParentFilePlanComponent && !isRecordFolder(targetParent)) + { + throw new AlfrescoRuntimeException("A document can only be moved into a folder in RM site."); + } + } + + /** + * @see org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy#beforeCopy(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = COPY_BEHAVIOUR_NAME + ) + public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef) + { + mandatory("sourceNodeRef", sourceNodeRef); + mandatory("targetNodeRef", targetNodeRef); + + NodeRef sourceParentNodeRef = nodeService.getPrimaryParent(sourceNodeRef).getParentRef(); + boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParentNodeRef); + + NodeRef targetParentNodeRef = nodeService.getPrimaryParent(targetNodeRef).getParentRef(); + boolean isTargetNodeParentFilePlanComponent = isFilePlanComponent(targetParentNodeRef); + + // If we are doing the copy operation within the RM site then we can stop here + // The method should just check copy operations from outside of RM into the RM site + if (isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) + { + return; + } + + // Do not allow to copy anything outside of RM site into the RM site + if (!isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) + { + throw new AlfrescoRuntimeException("Nothing can be copied from a collaboration site into a RM site."); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/DispositionActionDefinitionType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/DispositionActionDefinitionType.java index 513953385b..6a5fa51e34 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/DispositionActionDefinitionType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/DispositionActionDefinitionType.java @@ -1,99 +1,99 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.PropertyMap; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * rma:dispositionActionDefinition behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:dispositionActionDefinition" -) -public class DispositionActionDefinitionType extends BaseBehaviourBean - implements NodeServicePolicies.OnUpdatePropertiesPolicy -{ - /** I18N */ - private static final String MSG_UPDATE_DISP_ACT_DEF = "rm.service.update-disposition-action-def"; - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - if (nodeService.exists(nodeRef)) - { - // Determine the properties that have changed - Set changedProps = new HashSet(PropertyMap.getChangedProperties(before, after).keySet()); - changedProps.addAll(PropertyMap.getAddedProperties(before, after).keySet()); - - if (!nodeService.hasAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE)) - { - // Apply the unpublished aspect - Map props = new HashMap(); - props.put(PROP_UPDATE_TO, UPDATE_TO_DISPOSITION_ACTION_DEFINITION); - props.put(PROP_UPDATED_PROPERTIES, (Serializable)changedProps); - nodeService.addAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE, props); - } - else - { - Map props = nodeService.getProperties(nodeRef); - - // Check that there isn't a update currently being published - if ((Boolean)props.get(PROP_PUBLISH_IN_PROGRESS).equals(Boolean.TRUE)) - { - // Can not update the disposition schedule since there is an outstanding update being published - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UPDATE_DISP_ACT_DEF)); - } - - // Update the update information - props.put(PROP_UPDATE_TO, UPDATE_TO_DISPOSITION_ACTION_DEFINITION); - props.put(PROP_UPDATED_PROPERTIES, (Serializable)changedProps); - nodeService.setProperties(nodeRef, props); - } - } - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.PropertyMap; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * rma:dispositionActionDefinition behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:dispositionActionDefinition" +) +public class DispositionActionDefinitionType extends BaseBehaviourBean + implements NodeServicePolicies.OnUpdatePropertiesPolicy +{ + /** I18N */ + private static final String MSG_UPDATE_DISP_ACT_DEF = "rm.service.update-disposition-action-def"; + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if (nodeService.exists(nodeRef)) + { + // Determine the properties that have changed + Set changedProps = new HashSet(PropertyMap.getChangedProperties(before, after).keySet()); + changedProps.addAll(PropertyMap.getAddedProperties(before, after).keySet()); + + if (!nodeService.hasAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE)) + { + // Apply the unpublished aspect + Map props = new HashMap(); + props.put(PROP_UPDATE_TO, UPDATE_TO_DISPOSITION_ACTION_DEFINITION); + props.put(PROP_UPDATED_PROPERTIES, (Serializable)changedProps); + nodeService.addAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE, props); + } + else + { + Map props = nodeService.getProperties(nodeRef); + + // Check that there isn't a update currently being published + if ((Boolean)props.get(PROP_PUBLISH_IN_PROGRESS).equals(Boolean.TRUE)) + { + // Can not update the disposition schedule since there is an outstanding update being published + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UPDATE_DISP_ACT_DEF)); + } + + // Update the update information + props.put(PROP_UPDATE_TO, UPDATE_TO_DISPOSITION_ACTION_DEFINITION); + props.put(PROP_UPDATED_PROPERTIES, (Serializable)changedProps); + nodeService.setProperties(nodeRef, props); + } + } + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index b0217a063f..cdf455bcdd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -1,202 +1,202 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * rma:filePlan behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:filePlan" -) -public class FilePlanType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy, - NodeServicePolicies.OnCreateNodePolicy, - NodeServicePolicies.OnDeleteNodePolicy -{ - /** file plan service */ - private FilePlanService filePlanService; - - /** record folder service */ - private RecordFolderService recordFolderService; - - /** identifier service */ - private IdentifierService identifierService; - - /** file plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** - * @return File plan service - */ - protected FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * @return Record folder service - */ - protected RecordFolderService getRecordFolderService() - { - return this.recordFolderService; - } - - /** - * @return Identifier service - */ - protected IdentifierService getIdentifierService() - { - return this.identifierService; - } - - /** - * @return File plan role service - */ - protected FilePlanRoleService getFilePlanRoleService() - { - return this.filePlanRoleService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION - ) - @Override - public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) - { - // ensure we are not trying to put content in the file plan root node - NodeRef nodeRef = childAssocRef.getChildRef(); - if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT)) - { - throw new AlfrescoRuntimeException("Operation failed, because you can't place content in the root of the file plan."); - } - - // ensure we are not trying to put a record folder in the root of the file plan - NodeRef parent = childAssocRef.getParentRef(); - if (getFilePlanService().isFilePlan(parent) && getRecordFolderService().isRecordFolder(nodeRef)) - { - throw new AlfrescoRuntimeException("Operation failed, because you can not place a record folder in the root of the file plan."); - } - - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - @Override - public void onCreateNode(final ChildAssociationRef childAssocRef) - { - final NodeRef filePlan = childAssocRef.getChildRef(); - - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Object doWork() - { - if (nodeService.hasAspect(filePlan, ASPECT_FILE_PLAN_COMPONENT) && - nodeService.getProperty(filePlan, PROP_IDENTIFIER) == null) - { - String id = getIdentifierService().generateIdentifier(filePlan); - nodeService.setProperty(filePlan, RecordsManagementModel.PROP_IDENTIFIER, id); - } - - return null; - } - }); - - // setup the file plan roles - getFilePlanRoleService().setupFilePlanRoles(filePlan); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - @Override - public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived) - { - // tear down the file plan roles - getFilePlanRoleService().tearDownFilePlanRoles(childAssocRef.getChildRef()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * rma:filePlan behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:filePlan" +) +public class FilePlanType extends BaseBehaviourBean + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnCreateNodePolicy, + NodeServicePolicies.OnDeleteNodePolicy +{ + /** file plan service */ + private FilePlanService filePlanService; + + /** record folder service */ + private RecordFolderService recordFolderService; + + /** identifier service */ + private IdentifierService identifierService; + + /** file plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** + * @return File plan service + */ + protected FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * @return Record folder service + */ + protected RecordFolderService getRecordFolderService() + { + return this.recordFolderService; + } + + /** + * @return Identifier service + */ + protected IdentifierService getIdentifierService() + { + return this.identifierService; + } + + /** + * @return File plan role service + */ + protected FilePlanRoleService getFilePlanRoleService() + { + return this.filePlanRoleService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION + ) + @Override + public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) + { + // ensure we are not trying to put content in the file plan root node + NodeRef nodeRef = childAssocRef.getChildRef(); + if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT)) + { + throw new AlfrescoRuntimeException("Operation failed, because you can't place content in the root of the file plan."); + } + + // ensure we are not trying to put a record folder in the root of the file plan + NodeRef parent = childAssocRef.getParentRef(); + if (getFilePlanService().isFilePlan(parent) && getRecordFolderService().isRecordFolder(nodeRef)) + { + throw new AlfrescoRuntimeException("Operation failed, because you can not place a record folder in the root of the file plan."); + } + + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + @Override + public void onCreateNode(final ChildAssociationRef childAssocRef) + { + final NodeRef filePlan = childAssocRef.getChildRef(); + + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Object doWork() + { + if (nodeService.hasAspect(filePlan, ASPECT_FILE_PLAN_COMPONENT) && + nodeService.getProperty(filePlan, PROP_IDENTIFIER) == null) + { + String id = getIdentifierService().generateIdentifier(filePlan); + nodeService.setProperty(filePlan, RecordsManagementModel.PROP_IDENTIFIER, id); + } + + return null; + } + }); + + // setup the file plan roles + getFilePlanRoleService().setupFilePlanRoles(filePlan); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + @Override + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived) + { + // tear down the file plan roles + getFilePlanRoleService().tearDownFilePlanRoles(childAssocRef.getChildRef()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java index db3dce550f..33bb52b1a8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java @@ -1,207 +1,207 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * rma:recordCategory behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordCategory" -) -public class RecordCategoryType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy, - NodeServicePolicies.OnCreateNodePolicy -{ - /** vital record service */ - protected VitalRecordService vitalRecordService; - - /** file plan permission service */ - protected FilePlanPermissionService filePlanPermissionService; - - /** record folder service */ - private RecordFolderService recordFolderService; - - /** - * @param vitalRecordService vital record service - */ - public void setVitalRecordService(VitalRecordService vitalRecordService) - { - this.vitalRecordService = vitalRecordService; - } - - /** - * @param filePlanPermissionService file plan permission service - */ - public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) - { - this.filePlanPermissionService = filePlanPermissionService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * On every event - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION - ) - public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) - { - // ensure content is not placed directly into a record category - NodeRef nodeRef = childAssocRef.getChildRef(); - if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT)) - { - throw new AlfrescoRuntimeException("Operation failed, because you can't place content directly into a record category."); - } - - if (bNew) - { - // setup the record folder - recordFolderService.setupRecordFolder(nodeRef); - } - } - - /** - * On transaction commit - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - policy = "alf:onCreateChildAssociation", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) - { - final NodeRef recordCategory = childAssocRef.getChildRef(); - - behaviourFilter.disableBehaviour(); - try - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // setup vital record definition - vitalRecordService.setupVitalRecordDefinition(recordCategory); - - return null; - } - }); - } - finally - { - behaviourFilter.enableBehaviour(); - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateNode(final ChildAssociationRef childAssocRef) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("rma:recordCategory|alf:onCreateNode|this.onCreateNode()|TRANSATION_COMMIT"); - } - - // execute behaviour code as system user - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // setup record category permissions - filePlanPermissionService.setupRecordCategoryPermissions(childAssocRef.getChildRef()); - - return null; - } - }); - - } - - /** - * Copy callback for record category - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback onCopyRecordCategory(final QName classRef, final CopyDetails copyDetails) - { - return new DefaultCopyBehaviourCallback() - { - /** - * If the targets parent is a Record Folder -- Do Not Allow Copy - * - * @param classQName - * @param copyDetails - * @return boolean - */ - @Override - public boolean getMustCopy(QName classQName, CopyDetails copyDetails) - { - return nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER) ? false : true; - } - }; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * rma:recordCategory behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordCategory" +) +public class RecordCategoryType extends BaseBehaviourBean + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnCreateNodePolicy +{ + /** vital record service */ + protected VitalRecordService vitalRecordService; + + /** file plan permission service */ + protected FilePlanPermissionService filePlanPermissionService; + + /** record folder service */ + private RecordFolderService recordFolderService; + + /** + * @param vitalRecordService vital record service + */ + public void setVitalRecordService(VitalRecordService vitalRecordService) + { + this.vitalRecordService = vitalRecordService; + } + + /** + * @param filePlanPermissionService file plan permission service + */ + public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) + { + this.filePlanPermissionService = filePlanPermissionService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * On every event + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION + ) + public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) + { + // ensure content is not placed directly into a record category + NodeRef nodeRef = childAssocRef.getChildRef(); + if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT)) + { + throw new AlfrescoRuntimeException("Operation failed, because you can't place content directly into a record category."); + } + + if (bNew) + { + // setup the record folder + recordFolderService.setupRecordFolder(nodeRef); + } + } + + /** + * On transaction commit + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + policy = "alf:onCreateChildAssociation", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) + { + final NodeRef recordCategory = childAssocRef.getChildRef(); + + behaviourFilter.disableBehaviour(); + try + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // setup vital record definition + vitalRecordService.setupVitalRecordDefinition(recordCategory); + + return null; + } + }); + } + finally + { + behaviourFilter.enableBehaviour(); + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateNode(final ChildAssociationRef childAssocRef) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("rma:recordCategory|alf:onCreateNode|this.onCreateNode()|TRANSATION_COMMIT"); + } + + // execute behaviour code as system user + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // setup record category permissions + filePlanPermissionService.setupRecordCategoryPermissions(childAssocRef.getChildRef()); + + return null; + } + }); + + } + + /** + * Copy callback for record category + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback onCopyRecordCategory(final QName classRef, final CopyDetails copyDetails) + { + return new DefaultCopyBehaviourCallback() + { + /** + * If the targets parent is a Record Folder -- Do Not Allow Copy + * + * @param classQName + * @param copyDetails + * @return boolean + */ + @Override + public boolean getMustCopy(QName classQName, CopyDetails copyDetails) + { + return nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER) ? false : true; + } + }; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java index 89802c2b62..3f3f7e85d4 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java @@ -1,252 +1,252 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.ArrayUtils; - -/** - * rma:recordFolder behaviour bean - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordFolder" -) -public class RecordFolderType extends AbstractDisposableItem - implements NodeServicePolicies.OnMoveNodePolicy, - NodeServicePolicies.OnCreateChildAssociationPolicy -{ - /** record service */ - private RecordService recordService; - - /** record folder service */ - private RecordFolderService recordFolderService; - - /** vital record service */ - protected VitalRecordService vitalRecordService; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param vitalRecordService vital record service - */ - public void setVitalRecordService(VitalRecordService vitalRecordService) - { - this.vitalRecordService = vitalRecordService; - } - - /** - * Record folder move behaviour - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - if (!nodeService.getType(newChildAssocRef.getParentRef()).equals(TYPE_RECORD_FOLDER)) - { - if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef())) - { - final NodeRef newNodeRef = newChildAssocRef.getChildRef(); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - // clean record folder - cleanDisposableItem(nodeService, newNodeRef); - - // re-initialise the record folder - recordFolderService.setupRecordFolder(newNodeRef); - - // sort out the child records - for (NodeRef record : recordService.getRecords(newNodeRef)) - { - // clean record - cleanDisposableItem(nodeService, record); - - // Re-initiate the records in the new folder. - recordService.file(record); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - } - else - { - throw new UnsupportedOperationException("Cannot move record folder into another record folder."); - } - } - - /** - * Record folder copy callback - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(final QName classRef, final CopyDetails copyDetails) - { - return new DefaultCopyBehaviourCallback() - { - @Override - public Map getCopyProperties(QName classRef, CopyDetails copyDetails, Map properties) - { - Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); - - // ensure that the 'closed' status of the record folder is not copied - if (sourceProperties.containsKey(PROP_IS_CLOSED)) - { - sourceProperties.remove(PROP_IS_CLOSED); - } - - return sourceProperties; - } - - /** - * If the targets parent is a Record Folder -- Do Not Allow Copy - * - * @param classQName - * @param copyDetails - * @return boolean - */ - @Override - public boolean getMustCopy(QName classQName, CopyDetails copyDetails) - { - boolean result = true; - - if (nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER)) - { - result = false; - } - else if (ArrayUtils.contains(unwantedAspects, classQName)) - { - result = false; - } - - return result; - } - }; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) - { - NodeRef nodeRef = childAssocRef.getChildRef(); - if (nodeService.exists(nodeRef) && instanceOf(nodeRef, TYPE_RECORD_FOLDER)) - { - // ensure nothing is being added to a closed record folder - NodeRef recordFolder = childAssocRef.getParentRef(); - Boolean isClosed = (Boolean) nodeService.getProperty(recordFolder, PROP_IS_CLOSED); - if (isClosed != null && Boolean.TRUE.equals(isClosed)) - { - throw new AlfrescoRuntimeException("You can't add new items to a closed record folder."); - } - } - } - - /** - * On transaction commit - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - policy = "alf:onCreateChildAssociation", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) - { - final NodeRef recordFolder = childAssocRef.getChildRef(); - - behaviourFilter.disableBehaviour(); - try - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // setup vital record definition - vitalRecordService.setupVitalRecordDefinition(recordFolder); - - return null; - } - }); - } - finally - { - behaviourFilter.enableBehaviour(); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.ArrayUtils; + +/** + * rma:recordFolder behaviour bean + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordFolder" +) +public class RecordFolderType extends AbstractDisposableItem + implements NodeServicePolicies.OnMoveNodePolicy, + NodeServicePolicies.OnCreateChildAssociationPolicy +{ + /** record service */ + private RecordService recordService; + + /** record folder service */ + private RecordFolderService recordFolderService; + + /** vital record service */ + protected VitalRecordService vitalRecordService; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param vitalRecordService vital record service + */ + public void setVitalRecordService(VitalRecordService vitalRecordService) + { + this.vitalRecordService = vitalRecordService; + } + + /** + * Record folder move behaviour + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + if (!nodeService.getType(newChildAssocRef.getParentRef()).equals(TYPE_RECORD_FOLDER)) + { + if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef())) + { + final NodeRef newNodeRef = newChildAssocRef.getChildRef(); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + // clean record folder + cleanDisposableItem(nodeService, newNodeRef); + + // re-initialise the record folder + recordFolderService.setupRecordFolder(newNodeRef); + + // sort out the child records + for (NodeRef record : recordService.getRecords(newNodeRef)) + { + // clean record + cleanDisposableItem(nodeService, record); + + // Re-initiate the records in the new folder. + recordService.file(record); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + } + else + { + throw new UnsupportedOperationException("Cannot move record folder into another record folder."); + } + } + + /** + * Record folder copy callback + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(final QName classRef, final CopyDetails copyDetails) + { + return new DefaultCopyBehaviourCallback() + { + @Override + public Map getCopyProperties(QName classRef, CopyDetails copyDetails, Map properties) + { + Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); + + // ensure that the 'closed' status of the record folder is not copied + if (sourceProperties.containsKey(PROP_IS_CLOSED)) + { + sourceProperties.remove(PROP_IS_CLOSED); + } + + return sourceProperties; + } + + /** + * If the targets parent is a Record Folder -- Do Not Allow Copy + * + * @param classQName + * @param copyDetails + * @return boolean + */ + @Override + public boolean getMustCopy(QName classQName, CopyDetails copyDetails) + { + boolean result = true; + + if (nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER)) + { + result = false; + } + else if (ArrayUtils.contains(unwantedAspects, classQName)) + { + result = false; + } + + return result; + } + }; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) + { + NodeRef nodeRef = childAssocRef.getChildRef(); + if (nodeService.exists(nodeRef) && instanceOf(nodeRef, TYPE_RECORD_FOLDER)) + { + // ensure nothing is being added to a closed record folder + NodeRef recordFolder = childAssocRef.getParentRef(); + Boolean isClosed = (Boolean) nodeService.getProperty(recordFolder, PROP_IS_CLOSED); + if (isClosed != null && Boolean.TRUE.equals(isClosed)) + { + throw new AlfrescoRuntimeException("You can't add new items to a closed record folder."); + } + } + } + + /** + * On transaction commit + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + policy = "alf:onCreateChildAssociation", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) + { + final NodeRef recordFolder = childAssocRef.getChildRef(); + + behaviourFilter.disableBehaviour(); + try + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // setup vital record definition + vitalRecordService.setupVitalRecordDefinition(recordFolder); + + return null; + } + }); + } + finally + { + behaviourFilter.enableBehaviour(); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java index 38214b000d..0d1002ef41 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java @@ -1,212 +1,212 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * rma:recordsManagementContainer behaviour bean. - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:recordsManagementContainer" -) -public class RecordsManagementContainerType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy -{ - /** behaviour name */ - private static final String BEHAVIOUR_NAME = "onCreateContainerType"; - - /** identifier service */ - protected IdentifierService identifierService; - - /** record service */ - protected RecordService recordService; - - /** record folder service */ - protected RecordFolderService recordFolderService; - - /** - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * Disable the behaviours for this transaction - * - * @since 2.3 - */ - public void disable() - { - getBehaviour(BEHAVIOUR_NAME).disable(); - } - - /** - * Enable behaviours for this transaction - * - * @since 2.3 - */ - public void enable() - { - getBehaviour(BEHAVIOUR_NAME).enable(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.BaseTypeBehaviour#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT, - name = BEHAVIOUR_NAME - ) - public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // Get the elements of the created association - final NodeRef child = childAssocRef.getChildRef(); - if (nodeService.exists(child)) - { - QName childType = nodeService.getType(child); - - // We only care about "folder" or sub-types - if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER)) - { - if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER)) - { - // this is a rule container, make sure it is an file plan component - nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); - } - else - { - // We need to automatically cast the created folder to RM type if it is a plain folder - // This occurs if the RM folder has been created via IMap, WebDav, etc - if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT)) - { - // check the type of the parent to determine what 'kind' of artifact to create - NodeRef parent = childAssocRef.getParentRef(); - QName parentType = nodeService.getType(parent); - - if (dictionaryService.isSubClass(parentType, TYPE_FILE_PLAN)) - { - // create a rma:recordCategoty since we are in the root of the file plan - nodeService.setType(child, TYPE_RECORD_CATEGORY); - } - else - { - // create a rma:recordFolder and initialise record folder - nodeService.setType(child, TYPE_RECORD_FOLDER); - recordFolderService.setupRecordFolder(child); - } - } - - // Catch all to generate the rm id (assuming it doesn't already have one!) - setIdenifierProperty(child); - } - } - else - { - NodeRef parentRef = childAssocRef.getParentRef(); - QName parentType = nodeService.getType(parentRef); - boolean isContentSubType = dictionaryService.isSubClass(childType, ContentModel.TYPE_CONTENT); - boolean isUnfiledRecordContainer = parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER); - boolean isUnfiledRecordFolder = parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER); - if (isContentSubType && (isUnfiledRecordContainer || isUnfiledRecordFolder)) - { - if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT)) - { - nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); - } - if (!nodeService.hasAspect(child, ASPECT_RECORD)) - { - recordService.makeRecord(child); - } - } - } - } - - return null; - } - }); - - } - - /** - * Set the identifier property - * - * @param nodeRef node reference - */ - protected void setIdenifierProperty(final NodeRef nodeRef) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Object doWork() - { - if (nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) && - nodeService.getProperty(nodeRef, PROP_IDENTIFIER) == null) - { - String id = identifierService.generateIdentifier(nodeRef); - nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER, id); - } - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * rma:recordsManagementContainer behaviour bean. + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:recordsManagementContainer" +) +public class RecordsManagementContainerType extends BaseBehaviourBean + implements NodeServicePolicies.OnCreateChildAssociationPolicy +{ + /** behaviour name */ + private static final String BEHAVIOUR_NAME = "onCreateContainerType"; + + /** identifier service */ + protected IdentifierService identifierService; + + /** record service */ + protected RecordService recordService; + + /** record folder service */ + protected RecordFolderService recordFolderService; + + /** + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * Disable the behaviours for this transaction + * + * @since 2.3 + */ + public void disable() + { + getBehaviour(BEHAVIOUR_NAME).disable(); + } + + /** + * Enable behaviours for this transaction + * + * @since 2.3 + */ + public void enable() + { + getBehaviour(BEHAVIOUR_NAME).enable(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.BaseTypeBehaviour#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT, + name = BEHAVIOUR_NAME + ) + public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Get the elements of the created association + final NodeRef child = childAssocRef.getChildRef(); + if (nodeService.exists(child)) + { + QName childType = nodeService.getType(child); + + // We only care about "folder" or sub-types + if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER)) + { + if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER)) + { + // this is a rule container, make sure it is an file plan component + nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); + } + else + { + // We need to automatically cast the created folder to RM type if it is a plain folder + // This occurs if the RM folder has been created via IMap, WebDav, etc + if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT)) + { + // check the type of the parent to determine what 'kind' of artifact to create + NodeRef parent = childAssocRef.getParentRef(); + QName parentType = nodeService.getType(parent); + + if (dictionaryService.isSubClass(parentType, TYPE_FILE_PLAN)) + { + // create a rma:recordCategoty since we are in the root of the file plan + nodeService.setType(child, TYPE_RECORD_CATEGORY); + } + else + { + // create a rma:recordFolder and initialise record folder + nodeService.setType(child, TYPE_RECORD_FOLDER); + recordFolderService.setupRecordFolder(child); + } + } + + // Catch all to generate the rm id (assuming it doesn't already have one!) + setIdenifierProperty(child); + } + } + else + { + NodeRef parentRef = childAssocRef.getParentRef(); + QName parentType = nodeService.getType(parentRef); + boolean isContentSubType = dictionaryService.isSubClass(childType, ContentModel.TYPE_CONTENT); + boolean isUnfiledRecordContainer = parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER); + boolean isUnfiledRecordFolder = parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER); + if (isContentSubType && (isUnfiledRecordContainer || isUnfiledRecordFolder)) + { + if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT)) + { + nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); + } + if (!nodeService.hasAspect(child, ASPECT_RECORD)) + { + recordService.makeRecord(child); + } + } + } + } + + return null; + } + }); + + } + + /** + * Set the identifier property + * + * @param nodeRef node reference + */ + protected void setIdenifierProperty(final NodeRef nodeRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Object doWork() + { + if (nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) && + nodeService.getProperty(nodeRef, PROP_IDENTIFIER) == null) + { + String id = identifierService.generateIdentifier(nodeRef); + nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER, id); + } + return null; + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 161ad68d06..f577805464 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -1,289 +1,289 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.rma.type; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.PropertyMap; - -/** - * Behaviour associated with the RM Site type - * - * @author Roy Wetherall - * @since 2.2 - */ -@BehaviourBean -( - defaultType = "rma:rmsite" -) -public class RmSiteType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateNodePolicy, - NodeServicePolicies.OnUpdatePropertiesPolicy, - NodeServicePolicies.BeforeDeleteNodePolicy -{ - /** Constant values */ - public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary"; - public static final String DEFAULT_SITE_NAME = "rm"; - public static final QName DEFAULT_FILE_PLAN_TYPE = TYPE_FILE_PLAN; - - /** Site service */ - protected SiteService siteService; - - /** Record Management Search Service */ - protected RecordsManagementSearchService recordsManagementSearchService; - - /** Capability service */ - protected CapabilityService capabilityService; - - /** Authority service */ - private AuthorityService authorityService; - - /** Map of file plan type's key'ed by corresponding site types */ - protected Map mapFilePlanType = new HashMap(3); - - /** - * Set the site service - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * Registers a file plan type for a specific site type. - * - * @param siteType siteType sub-type of rma:rmsite - * @param filePlanType filePlanType sub-type of rma:filePlan - * @since 2.2 - */ - public void registerFilePlanType(QName siteType, QName filePlanType) - { - ParameterCheck.mandatory("siteType", siteType); - ParameterCheck.mandatory("filePlanType", filePlanType); - - // check that the registered site type is a subtype of rma:rmsite - if (!dictionaryService.isSubClass(siteType, TYPE_RM_SITE)) - { - throw new AlfrescoRuntimeException( - "Can't register site type, because site type is not a sub type of rma:rmsite (siteType=" + siteType.toString() + ")"); - } - - // check that the registered file plan type is a sub type of rma:filePlan - if (!dictionaryService.isSubClass(filePlanType, TYPE_FILE_PLAN)) - { - throw new AlfrescoRuntimeException( - "Can't register file plan type, because site type is not a sub type of rma:filePlan (filePlanType=" + filePlanType.toString() + ")"); - } - - // add site and file plan types to map - mapFilePlanType.put(siteType, filePlanType); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onCreateNode(ChildAssociationRef childAssocRef) - { - final NodeRef rmSite = childAssocRef.getChildRef(); - - // Do not execute behaviour if this has been created in the archive store - if(rmSite.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) - { - // This is not the spaces store - probably the archive store - return; - } - - if (nodeService.exists(rmSite)) - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - SiteInfo siteInfo = siteService.getSite(rmSite); - if (siteInfo != null) - { - // Create the file plan component - siteService.createContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY, getFilePlanType(siteInfo), null); - - // Add the reports - recordsManagementSearchService.addReports(siteInfo.getShortName()); - } - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - } - - /** - * Get the file plan type for the given site. - * - * @param siteInfo site info - * @return QName file plan type to create as a container - * @since 2.2 - */ - private QName getFilePlanType(SiteInfo siteInfo) - { - ParameterCheck.mandatory("siteInfo", siteInfo); - - // set default file plan - QName result = DEFAULT_FILE_PLAN_TYPE; - - // check to see if there is an 'override' for the file plan type given the site type - QName siteType = nodeService.getType(siteInfo.getNodeRef()); - if (mapFilePlanType.containsKey(siteType)) - { - result = mapFilePlanType.get(siteType); - } - - return result; - } - - /** - * Ensure that the visibility of a RM site can not be changed to anything but public. - * - * TODO support other site visibilities - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - if (nodeService.exists(nodeRef)) - { - Map changed = PropertyMap.getChangedProperties(before, after); - if (changed.containsKey(SiteModel.PROP_SITE_VISIBILITY) && - changed.get(SiteModel.PROP_SITE_VISIBILITY) != null && - !SiteVisibility.PUBLIC.equals(changed.get(SiteModel.PROP_SITE_VISIBILITY))) - { - // we do not current support non-public RM sites - throw new AlfrescoRuntimeException("The records management site must have public visibility. It can't be changed to " + changed.get(SiteModel.PROP_SITE_VISIBILITY)); - } - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void beforeDeleteNode(NodeRef nodeRef) - { - final SiteInfo siteInfo = siteService.getSite(nodeRef); - if (siteInfo != null) - { - // grab the file plan for the RM site - NodeRef filePlan = AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return siteService.getContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY); - } - - }); - - if (filePlan != null) - { - // determine whether the current user has delete capability on the file plan node - AccessStatus accessStatus = capabilityService.getCapabilityAccessState(filePlan, "Delete"); - if (AccessStatus.DENIED.equals(accessStatus)) - { - throw new AlfrescoRuntimeException("The records management site can not be deleted, because the user doesn't have sufficient privillages to delete the file plan."); - } - - // work around for MNT-11038 .. we want to ensure that the RM site can be created once it's been deleted since we only - // allow one short name for the RM site - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // delete the authority - String siteGroup = siteService.getSiteGroup(siteInfo.getShortName()); - authorityService.deleteAuthority(siteGroup, true); - - return null; - } - }); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.rma.type; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.site.SiteModel; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.alfresco.util.PropertyMap; + +/** + * Behaviour associated with the RM Site type + * + * @author Roy Wetherall + * @since 2.2 + */ +@BehaviourBean +( + defaultType = "rma:rmsite" +) +public class RmSiteType extends BaseBehaviourBean + implements NodeServicePolicies.OnCreateNodePolicy, + NodeServicePolicies.OnUpdatePropertiesPolicy, + NodeServicePolicies.BeforeDeleteNodePolicy +{ + /** Constant values */ + public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary"; + public static final String DEFAULT_SITE_NAME = "rm"; + public static final QName DEFAULT_FILE_PLAN_TYPE = TYPE_FILE_PLAN; + + /** Site service */ + protected SiteService siteService; + + /** Record Management Search Service */ + protected RecordsManagementSearchService recordsManagementSearchService; + + /** Capability service */ + protected CapabilityService capabilityService; + + /** Authority service */ + private AuthorityService authorityService; + + /** Map of file plan type's key'ed by corresponding site types */ + protected Map mapFilePlanType = new HashMap(3); + + /** + * Set the site service + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * Registers a file plan type for a specific site type. + * + * @param siteType siteType sub-type of rma:rmsite + * @param filePlanType filePlanType sub-type of rma:filePlan + * @since 2.2 + */ + public void registerFilePlanType(QName siteType, QName filePlanType) + { + ParameterCheck.mandatory("siteType", siteType); + ParameterCheck.mandatory("filePlanType", filePlanType); + + // check that the registered site type is a subtype of rma:rmsite + if (!dictionaryService.isSubClass(siteType, TYPE_RM_SITE)) + { + throw new AlfrescoRuntimeException( + "Can't register site type, because site type is not a sub type of rma:rmsite (siteType=" + siteType.toString() + ")"); + } + + // check that the registered file plan type is a sub type of rma:filePlan + if (!dictionaryService.isSubClass(filePlanType, TYPE_FILE_PLAN)) + { + throw new AlfrescoRuntimeException( + "Can't register file plan type, because site type is not a sub type of rma:filePlan (filePlanType=" + filePlanType.toString() + ")"); + } + + // add site and file plan types to map + mapFilePlanType.put(siteType, filePlanType); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onCreateNode(ChildAssociationRef childAssocRef) + { + final NodeRef rmSite = childAssocRef.getChildRef(); + + // Do not execute behaviour if this has been created in the archive store + if(rmSite.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) + { + // This is not the spaces store - probably the archive store + return; + } + + if (nodeService.exists(rmSite)) + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + SiteInfo siteInfo = siteService.getSite(rmSite); + if (siteInfo != null) + { + // Create the file plan component + siteService.createContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY, getFilePlanType(siteInfo), null); + + // Add the reports + recordsManagementSearchService.addReports(siteInfo.getShortName()); + } + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + } + + /** + * Get the file plan type for the given site. + * + * @param siteInfo site info + * @return QName file plan type to create as a container + * @since 2.2 + */ + private QName getFilePlanType(SiteInfo siteInfo) + { + ParameterCheck.mandatory("siteInfo", siteInfo); + + // set default file plan + QName result = DEFAULT_FILE_PLAN_TYPE; + + // check to see if there is an 'override' for the file plan type given the site type + QName siteType = nodeService.getType(siteInfo.getNodeRef()); + if (mapFilePlanType.containsKey(siteType)) + { + result = mapFilePlanType.get(siteType); + } + + return result; + } + + /** + * Ensure that the visibility of a RM site can not be changed to anything but public. + * + * TODO support other site visibilities + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if (nodeService.exists(nodeRef)) + { + Map changed = PropertyMap.getChangedProperties(before, after); + if (changed.containsKey(SiteModel.PROP_SITE_VISIBILITY) && + changed.get(SiteModel.PROP_SITE_VISIBILITY) != null && + !SiteVisibility.PUBLIC.equals(changed.get(SiteModel.PROP_SITE_VISIBILITY))) + { + // we do not current support non-public RM sites + throw new AlfrescoRuntimeException("The records management site must have public visibility. It can't be changed to " + changed.get(SiteModel.PROP_SITE_VISIBILITY)); + } + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void beforeDeleteNode(NodeRef nodeRef) + { + final SiteInfo siteInfo = siteService.getSite(nodeRef); + if (siteInfo != null) + { + // grab the file plan for the RM site + NodeRef filePlan = AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return siteService.getContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY); + } + + }); + + if (filePlan != null) + { + // determine whether the current user has delete capability on the file plan node + AccessStatus accessStatus = capabilityService.getCapabilityAccessState(filePlan, "Delete"); + if (AccessStatus.DENIED.equals(accessStatus)) + { + throw new AlfrescoRuntimeException("The records management site can not be deleted, because the user doesn't have sufficient privillages to delete the file plan."); + } + + // work around for MNT-11038 .. we want to ensure that the RM site can be created once it's been deleted since we only + // allow one short name for the RM site + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // delete the authority + String siteGroup = siteService.getSiteGroup(siteInfo.getShortName()); + authorityService.deleteAuthority(siteGroup, true); + + return null; + } + }); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelAccessDeniedException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelAccessDeniedException.java index b7b99f9504..13236c3cd1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelAccessDeniedException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelAccessDeniedException.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -import org.alfresco.repo.security.permissions.AccessDeniedException; - -/** - * Model access denied exception implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ModelAccessDeniedException extends AccessDeniedException -{ - private static final long serialVersionUID = 6796435040345714366L; - - public ModelAccessDeniedException(String msg) - { - super(msg); - } - - public ModelAccessDeniedException(String msg, Throwable cause) - { - super(msg, cause); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +import org.alfresco.repo.security.permissions.AccessDeniedException; + +/** + * Model access denied exception implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ModelAccessDeniedException extends AccessDeniedException +{ + private static final long serialVersionUID = 6796435040345714366L; + + public ModelAccessDeniedException(String msg) + { + super(msg); + } + + public ModelAccessDeniedException(String msg, Throwable cause) + { + super(msg, cause); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityService.java index 5e341d46d5..40c1127f63 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityService.java @@ -1,138 +1,138 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Model security service interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface ModelSecurityService -{ - /** - * Sets whether model security is enabled globally or not. - * - * @param enabled - */ - void setEnabled(boolean enabled); - - /** - * Indicates whether model security is enabled or not. - * - * @return - */ - boolean isEnabled(); - - /** - * Disable model security checks for the current thread. - */ - void disable(); - - /** - * Enable model security checks for the current thread. - */ - void enable(); - - /** - * Registers a protected model artifact with the service. - * - * @param atrifact protected model artifact - */ - void register(ProtectedModelArtifact atrifact); - - /** - * Indicates whether a property is protected or not. - * - * @param name name of property - * @return boolean true if property is protected, false otherwise - */ - boolean isProtectedProperty(QName property); - - /** - * Get the protected properties - * - * @return {@link Set}<{@link QName}> all the protected properties - */ - Set getProtectedProperties(); - - /** - * Get the details of the protected property, returns null if property - * is not protected. - * - * @param name name of the protected property - * @return {@link ProtectedProperty} protected property details, null otherwise - */ - ProtectedProperty getProtectedProperty(QName name); - - /** - * Indicates whether the current user can edit a protected property in the context of - * a given node. - *

- * If the property is not protected then returns true. - * - * @param nodeRef node reference - * @param property name of the property - * @return boolean true if the current user can edit the protected property or the property - * is not protected, false otherwise - */ - boolean canEditProtectedProperty(NodeRef nodeRef, QName property); - - /** - * Indicates whether an aspect is protected or not. - * - * @param aspect aspect name - * @return boolean true if aspect is protected, false otherwise - */ - boolean isProtectedAspect(QName aspect); - - /** - * Get the protected aspects. - * - * @return {@link Set}<{@link QName}> all the protected aspects - */ - Set getProtectedAspects(); - - /** - * Get the details of the protected aspect, returns null if aspect is - * not protected. - * - * @param name name of the aspect - * @return {@link ProtectedAspect} protected aspect details, null otherwise - */ - ProtectedAspect getProtectedAspect(QName name); - - /** - * Indicates whether the current user can edit (ie add or remove) a protected - * aspect in the context of a given node. - *

- * If the aspect is not protected then returns true. - * - * @param nodeRef node reference - * @param aspect name of the of aspect - * @return boolean true if the current user can edit the protected aspect or the the - * aspect is not protected, false otherwise - */ - boolean canEditProtectedAspect(NodeRef nodeRef, QName aspect); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Model security service interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface ModelSecurityService +{ + /** + * Sets whether model security is enabled globally or not. + * + * @param enabled + */ + void setEnabled(boolean enabled); + + /** + * Indicates whether model security is enabled or not. + * + * @return + */ + boolean isEnabled(); + + /** + * Disable model security checks for the current thread. + */ + void disable(); + + /** + * Enable model security checks for the current thread. + */ + void enable(); + + /** + * Registers a protected model artifact with the service. + * + * @param atrifact protected model artifact + */ + void register(ProtectedModelArtifact atrifact); + + /** + * Indicates whether a property is protected or not. + * + * @param name name of property + * @return boolean true if property is protected, false otherwise + */ + boolean isProtectedProperty(QName property); + + /** + * Get the protected properties + * + * @return {@link Set}<{@link QName}> all the protected properties + */ + Set getProtectedProperties(); + + /** + * Get the details of the protected property, returns null if property + * is not protected. + * + * @param name name of the protected property + * @return {@link ProtectedProperty} protected property details, null otherwise + */ + ProtectedProperty getProtectedProperty(QName name); + + /** + * Indicates whether the current user can edit a protected property in the context of + * a given node. + *

+ * If the property is not protected then returns true. + * + * @param nodeRef node reference + * @param property name of the property + * @return boolean true if the current user can edit the protected property or the property + * is not protected, false otherwise + */ + boolean canEditProtectedProperty(NodeRef nodeRef, QName property); + + /** + * Indicates whether an aspect is protected or not. + * + * @param aspect aspect name + * @return boolean true if aspect is protected, false otherwise + */ + boolean isProtectedAspect(QName aspect); + + /** + * Get the protected aspects. + * + * @return {@link Set}<{@link QName}> all the protected aspects + */ + Set getProtectedAspects(); + + /** + * Get the details of the protected aspect, returns null if aspect is + * not protected. + * + * @param name name of the aspect + * @return {@link ProtectedAspect} protected aspect details, null otherwise + */ + ProtectedAspect getProtectedAspect(QName name); + + /** + * Indicates whether the current user can edit (ie add or remove) a protected + * aspect in the context of a given node. + *

+ * If the aspect is not protected then returns true. + * + * @param nodeRef node reference + * @param aspect name of the of aspect + * @return boolean true if the current user can edit the protected aspect or the the + * aspect is not protected, false otherwise + */ + boolean canEditProtectedAspect(NodeRef nodeRef, QName aspect); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityServiceImpl.java index 3e960609fa..a3c05d45b6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ModelSecurityServiceImpl.java @@ -1,363 +1,363 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.EqualsHelper; - - -/** - * Model security service implementation. - *

- * This service records the protected properties and aspects, ensuring that only those with the appropriate capabilities can edit them. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class ModelSecurityServiceImpl extends BaseBehaviourBean - implements ModelSecurityService, - NodeServicePolicies.BeforeAddAspectPolicy, - NodeServicePolicies.BeforeRemoveAspectPolicy, - NodeServicePolicies.OnUpdatePropertiesPolicy -{ - /** Indicates whether model security is enabled or not */ - private boolean enabled = true; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Map of protected properties keyed by name */ - private Map protectedProperties = new HashMap(21); - - /** Map of protected aspects keyed by name */ - private Map protectedAspects= new HashMap(21); - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isEnabled() - */ - public boolean isEnabled() - { - return enabled; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#disable() - */ - @Override - public void disable() - { - getBehaviour("beforeAddAspect").disable(); - getBehaviour("beforeRemoveAspect").disable(); - getBehaviour("onUpdateProperties").disable(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#enable() - */ - @Override - public void enable() - { - getBehaviour("beforeAddAspect").enable(); - getBehaviour("beforeRemoveAspect").enable(); - getBehaviour("onUpdateProperties").enable(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#register(org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedModelArtifact) - */ - @Override - public void register(ProtectedModelArtifact artifact) - { - // TODO validate that the artifact has a valid property and has a capability set ... - - if (artifact instanceof ProtectedProperty) - { - protectedProperties.put(artifact.getQName(), (ProtectedProperty)artifact); - } - else if (artifact instanceof ProtectedAspect) - { - protectedAspects.put(artifact.getQName(), (ProtectedAspect)artifact); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isProtectedProperty(org.alfresco.service.namespace.QName) - */ - @Override - public boolean isProtectedProperty(QName property) - { - return protectedProperties.containsKey(property); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedProperties() - */ - @Override - public Set getProtectedProperties() - { - return Collections.unmodifiableSet(protectedProperties.keySet()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedProperty(org.alfresco.service.namespace.QName) - */ - @Override - public ProtectedProperty getProtectedProperty(QName name) - { - return protectedProperties.get(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#canEditProtectedProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - public boolean canEditProtectedProperty(NodeRef nodeRef, QName property) - { - boolean result = false; - - ProtectedModelArtifact artifact = getProtectedProperty(property); - if (artifact == null) - { - result = true; - } - else - { - result = canEdit(nodeRef, artifact); - } - - return result; - } - - /** - * Indicates whether the current user can edit protected model artifact in the context - * of a given node or not. - * - * @param nodeRef node reference - * @param artifact protected model artifact - * @return boolean true if the current user can edit the protected model artifact, false otherwise - */ - private boolean canEdit(NodeRef nodeRef, ProtectedModelArtifact artifact) - { - boolean result = false; - - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - if (filePlan != null) - { - for (Capability capability : artifact.getCapabilities()) - { - if (capability.hasPermission(nodeRef).equals(AccessStatus.ALLOWED)) - { - result = true; - break; - } - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isProtectedAspect(org.alfresco.service.namespace.QName) - */ - @Override - public boolean isProtectedAspect(QName aspect) - { - return protectedAspects.containsKey(aspect); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedAspects() - */ - @Override - public Set getProtectedAspects() - { - return Collections.unmodifiableSet(protectedAspects.keySet()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedAspect(org.alfresco.service.namespace.QName) - */ - @Override - public ProtectedAspect getProtectedAspect(QName name) - { - return protectedAspects.get(name); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#canEditProtectedAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - public boolean canEditProtectedAspect(NodeRef nodeRef, QName aspect) - { - boolean result = false; - - ProtectedModelArtifact artifact = getProtectedAspect(aspect); - if (artifact == null) - { - result = true; - } - else - { - result = canEdit(nodeRef, artifact); - } - - return result; - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy#beforeAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - name = "beforeAddAspect" - ) - public void beforeAddAspect(NodeRef nodeRef, QName aspect) - { - if (enabled && - AuthenticationUtil.getFullyAuthenticatedUser() != null && - !AuthenticationUtil.isRunAsUserTheSystemUser() && - isProtectedAspect(aspect) && - nodeService.exists(nodeRef) && - !canEditProtectedAspect(nodeRef, aspect)) - { - // the user can't edit the protected aspect - throw new ModelAccessDeniedException( - "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + - " does not have the permission to add the protected aspect " + aspect.toPrefixString(namespaceService) + - " to the node " + nodeRef.toString()); - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeRemoveAspectPolicy#beforeRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - name = "beforeRemoveAspect" - ) - public void beforeRemoveAspect(NodeRef nodeRef, QName aspect) - { - if (enabled && - AuthenticationUtil.getFullyAuthenticatedUser() != null && - !AuthenticationUtil.isRunAsUserTheSystemUser() && - isProtectedAspect(aspect) && - nodeService.exists(nodeRef) && - !canEditProtectedAspect(nodeRef, aspect)) - { - // the user can't edit the protected aspect - throw new ModelAccessDeniedException( - "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + - " does not have the permission to remove the protected aspect " + aspect.toPrefixString(namespaceService) + - " from the node " + nodeRef.toString()); - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - isService = true, - name = "onUpdateProperties" - ) - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - if (enabled && - AuthenticationUtil.getFullyAuthenticatedUser() != null && - !AuthenticationUtil.isRunAsUserTheSystemUser() && - nodeService.exists(nodeRef)) - { - for (Map.Entry entry : after.entrySet()) - { - QName property = entry.getKey(); - if (isProtectedProperty(property)) - { - // always allow if this is the first time we are setting the protected property - if (before == null || before.isEmpty() || before.get(property) == null) - { - return; - } - - if (!EqualsHelper.nullSafeEquals(before.get(property), entry.getValue()) && - !canEditProtectedProperty(nodeRef, property)) - { - // the user can't edit the protected property - throw new ModelAccessDeniedException( - "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + - " does not have the permission to edit the protected property " + property.toPrefixString(namespaceService) + - " on the node " + nodeRef.toString()); - } - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.EqualsHelper; + + +/** + * Model security service implementation. + *

+ * This service records the protected properties and aspects, ensuring that only those with the appropriate capabilities can edit them. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class ModelSecurityServiceImpl extends BaseBehaviourBean + implements ModelSecurityService, + NodeServicePolicies.BeforeAddAspectPolicy, + NodeServicePolicies.BeforeRemoveAspectPolicy, + NodeServicePolicies.OnUpdatePropertiesPolicy +{ + /** Indicates whether model security is enabled or not */ + private boolean enabled = true; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Map of protected properties keyed by name */ + private Map protectedProperties = new HashMap(21); + + /** Map of protected aspects keyed by name */ + private Map protectedAspects= new HashMap(21); + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isEnabled() + */ + public boolean isEnabled() + { + return enabled; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#disable() + */ + @Override + public void disable() + { + getBehaviour("beforeAddAspect").disable(); + getBehaviour("beforeRemoveAspect").disable(); + getBehaviour("onUpdateProperties").disable(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#enable() + */ + @Override + public void enable() + { + getBehaviour("beforeAddAspect").enable(); + getBehaviour("beforeRemoveAspect").enable(); + getBehaviour("onUpdateProperties").enable(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#register(org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedModelArtifact) + */ + @Override + public void register(ProtectedModelArtifact artifact) + { + // TODO validate that the artifact has a valid property and has a capability set ... + + if (artifact instanceof ProtectedProperty) + { + protectedProperties.put(artifact.getQName(), (ProtectedProperty)artifact); + } + else if (artifact instanceof ProtectedAspect) + { + protectedAspects.put(artifact.getQName(), (ProtectedAspect)artifact); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isProtectedProperty(org.alfresco.service.namespace.QName) + */ + @Override + public boolean isProtectedProperty(QName property) + { + return protectedProperties.containsKey(property); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedProperties() + */ + @Override + public Set getProtectedProperties() + { + return Collections.unmodifiableSet(protectedProperties.keySet()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedProperty(org.alfresco.service.namespace.QName) + */ + @Override + public ProtectedProperty getProtectedProperty(QName name) + { + return protectedProperties.get(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#canEditProtectedProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + public boolean canEditProtectedProperty(NodeRef nodeRef, QName property) + { + boolean result = false; + + ProtectedModelArtifact artifact = getProtectedProperty(property); + if (artifact == null) + { + result = true; + } + else + { + result = canEdit(nodeRef, artifact); + } + + return result; + } + + /** + * Indicates whether the current user can edit protected model artifact in the context + * of a given node or not. + * + * @param nodeRef node reference + * @param artifact protected model artifact + * @return boolean true if the current user can edit the protected model artifact, false otherwise + */ + private boolean canEdit(NodeRef nodeRef, ProtectedModelArtifact artifact) + { + boolean result = false; + + NodeRef filePlan = filePlanService.getFilePlan(nodeRef); + if (filePlan != null) + { + for (Capability capability : artifact.getCapabilities()) + { + if (capability.hasPermission(nodeRef).equals(AccessStatus.ALLOWED)) + { + result = true; + break; + } + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#isProtectedAspect(org.alfresco.service.namespace.QName) + */ + @Override + public boolean isProtectedAspect(QName aspect) + { + return protectedAspects.containsKey(aspect); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedAspects() + */ + @Override + public Set getProtectedAspects() + { + return Collections.unmodifiableSet(protectedAspects.keySet()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#getProtectedAspect(org.alfresco.service.namespace.QName) + */ + @Override + public ProtectedAspect getProtectedAspect(QName name) + { + return protectedAspects.get(name); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#canEditProtectedAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + public boolean canEditProtectedAspect(NodeRef nodeRef, QName aspect) + { + boolean result = false; + + ProtectedModelArtifact artifact = getProtectedAspect(aspect); + if (artifact == null) + { + result = true; + } + else + { + result = canEdit(nodeRef, artifact); + } + + return result; + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy#beforeAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + name = "beforeAddAspect" + ) + public void beforeAddAspect(NodeRef nodeRef, QName aspect) + { + if (enabled && + AuthenticationUtil.getFullyAuthenticatedUser() != null && + !AuthenticationUtil.isRunAsUserTheSystemUser() && + isProtectedAspect(aspect) && + nodeService.exists(nodeRef) && + !canEditProtectedAspect(nodeRef, aspect)) + { + // the user can't edit the protected aspect + throw new ModelAccessDeniedException( + "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + + " does not have the permission to add the protected aspect " + aspect.toPrefixString(namespaceService) + + " to the node " + nodeRef.toString()); + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeRemoveAspectPolicy#beforeRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + name = "beforeRemoveAspect" + ) + public void beforeRemoveAspect(NodeRef nodeRef, QName aspect) + { + if (enabled && + AuthenticationUtil.getFullyAuthenticatedUser() != null && + !AuthenticationUtil.isRunAsUserTheSystemUser() && + isProtectedAspect(aspect) && + nodeService.exists(nodeRef) && + !canEditProtectedAspect(nodeRef, aspect)) + { + // the user can't edit the protected aspect + throw new ModelAccessDeniedException( + "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + + " does not have the permission to remove the protected aspect " + aspect.toPrefixString(namespaceService) + + " from the node " + nodeRef.toString()); + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + isService = true, + name = "onUpdateProperties" + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if (enabled && + AuthenticationUtil.getFullyAuthenticatedUser() != null && + !AuthenticationUtil.isRunAsUserTheSystemUser() && + nodeService.exists(nodeRef)) + { + for (Map.Entry entry : after.entrySet()) + { + QName property = entry.getKey(); + if (isProtectedProperty(property)) + { + // always allow if this is the first time we are setting the protected property + if (before == null || before.isEmpty() || before.get(property) == null) + { + return; + } + + if (!EqualsHelper.nullSafeEquals(before.get(property), entry.getValue()) && + !canEditProtectedProperty(nodeRef, property)) + { + // the user can't edit the protected property + throw new ModelAccessDeniedException( + "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + + " does not have the permission to edit the protected property " + property.toPrefixString(namespaceService) + + " on the node " + nodeRef.toString()); + } + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedAspect.java index 71a2f96d70..31f923ca69 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedAspect.java @@ -1,28 +1,28 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -/** - * @author Roy Wetherall - * @since 2.1 - */ -public class ProtectedAspect extends ProtectedModelArtifact -{ - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +/** + * @author Roy Wetherall + * @since 2.1 + */ +public class ProtectedAspect extends ProtectedModelArtifact +{ + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedModelArtifact.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedModelArtifact.java index 110e8ada51..fe3361ff38 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedModelArtifact.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedModelArtifact.java @@ -1,124 +1,124 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Protected model artifact class. - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class ProtectedModelArtifact -{ - /** Model security service */ - private ModelSecurityService modelSecurityService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Qualified name of the model artifact */ - private QName name; - - /** Set of capabilities */ - private Set capabilities; - - /** Capability names */ - private Set capabilityNames; - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param modelSecurityService model security service - */ - public void setModelSecurityService(ModelSecurityService modelSecurityService) - { - this.modelSecurityService = modelSecurityService; - } - - /** - * Init method - */ - public void init() - { - modelSecurityService.register(this); - } - - /** - * @param name artifact name (in cm:content form) - */ - public void setName(String name) - { - QName qname = QName.createQName(name, namespaceService); - this.name = qname; - } - - /** - * @return artifact QName - */ - public QName getQName() - { - return name; - } - - /** - * @param capabilities capabilities - */ - public void setCapabilities(Set capabilities) - { - this.capabilities = capabilities; - } - - /** - * @return capabilities - */ - public Set getCapabilities() - { - return capabilities; - } - - /** - * @return capability names - */ - public Set getCapilityNames() - { - if (capabilityNames == null && capabilities != null) - { - capabilityNames = new HashSet(capabilities.size()); - for (Capability capability : capabilities) - { - capabilityNames.add(capability.getName()); - } - } - - return capabilityNames; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Protected model artifact class. + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class ProtectedModelArtifact +{ + /** Model security service */ + private ModelSecurityService modelSecurityService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Qualified name of the model artifact */ + private QName name; + + /** Set of capabilities */ + private Set capabilities; + + /** Capability names */ + private Set capabilityNames; + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param modelSecurityService model security service + */ + public void setModelSecurityService(ModelSecurityService modelSecurityService) + { + this.modelSecurityService = modelSecurityService; + } + + /** + * Init method + */ + public void init() + { + modelSecurityService.register(this); + } + + /** + * @param name artifact name (in cm:content form) + */ + public void setName(String name) + { + QName qname = QName.createQName(name, namespaceService); + this.name = qname; + } + + /** + * @return artifact QName + */ + public QName getQName() + { + return name; + } + + /** + * @param capabilities capabilities + */ + public void setCapabilities(Set capabilities) + { + this.capabilities = capabilities; + } + + /** + * @return capabilities + */ + public Set getCapabilities() + { + return capabilities; + } + + /** + * @return capability names + */ + public Set getCapilityNames() + { + if (capabilityNames == null && capabilities != null) + { + capabilityNames = new HashSet(capabilities.size()); + for (Capability capability : capabilities) + { + capabilityNames.add(capability.getName()); + } + } + + return capabilityNames; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedProperty.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedProperty.java index 84b12262e5..3b8cda61e2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedProperty.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/security/ProtectedProperty.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.security; - -/** - * Protected property implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ProtectedProperty extends ProtectedModelArtifact -{ - /** always allow new indicator */ - private boolean allwaysAllowNew = false; - - /** - * @param allwaysAllowNew true if always allow new, false otherwise - */ - public void setAllwaysAllowNew(boolean allwaysAllowNew) - { - this.allwaysAllowNew = allwaysAllowNew; - } - - /** - * @return true if always allow new, false otherwise - */ - public boolean isAllwaysAllowNew() - { - return allwaysAllowNew; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.security; + +/** + * Protected property implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ProtectedProperty extends ProtectedModelArtifact +{ + /** always allow new indicator */ + private boolean allwaysAllowNew = false; + + /** + * @param allwaysAllowNew true if always allow new, false otherwise + */ + public void setAllwaysAllowNew(boolean allwaysAllowNew) + { + this.allwaysAllowNew = allwaysAllowNew; + } + + /** + * @return true if always allow new, false otherwise + */ + public boolean isAllwaysAllowNew() + { + return allwaysAllowNew; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java index 6d4e042108..fbbbb14536 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java @@ -1,467 +1,467 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.notification; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.notification.EMailNotificationProvider; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.tenant.TenantAdminService; -import org.alfresco.repo.tenant.TenantUtil; -import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; -import org.alfresco.service.cmr.notification.NotificationContext; -import org.alfresco.service.cmr.notification.NotificationService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Helper bean containing methods useful when sending records - * management notifications via the {@link NotificationService} - * - * @author Roy Wetherall - */ -public class RecordsManagementNotificationHelper implements RecordsManagementModel -{ - private static Log logger = LogFactory.getLog(RecordsManagementNotificationHelper.class); - - /** I18n */ - private static final String MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW = "notification.dueforreview.subject"; - private static final String MSG_SUBJECT_RECORD_SUPERCEDED = "notification.superseded.subject"; - private static final String MSG_SUBJECT_RECORD_REJECTED = "notification.rejected.subject"; - - /** Defaults */ - private static final String DEFAULT_SITE = "rm"; - - /** Services */ - private NotificationService notificationService; - private FilePlanRoleService filePlanRoleService; - private SearchService searchService; - private NamespaceService namespaceService; - private SiteService siteService; - private AuthorityService authorityService; - private TenantAdminService tenantAdminService; - private NodeService nodeService; - private FilePlanService filePlanService; - - /** Notification role */ - private String notificationRole; - - /** EMail notification templates */ - private NodeRef supersededTemplate = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "record_superseded_template"); - private NodeRef dueForReviewTemplate; - private NodeRef rejectedTemplate = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "record_rejected_template"); - - /** - * @param notificationService notification service - */ - public void setNotificationService(NotificationService notificationService) - { - this.notificationService = notificationService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param notificationRole rm notification role - */ - public void setNotificationRole(String notificationRole) - { - this.notificationRole = notificationRole; - } - - /** - * @param searchService search service - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param tenantAdminService tenant admin service - */ - public void setTenantAdminService(TenantAdminService tenantAdminService) - { - this.tenantAdminService = tenantAdminService; - } - - /** - * @return superseded email template - */ - public NodeRef getSupersededTemplate() - { - return supersededTemplate; - } - - /** - * @return rejected email template - */ - public NodeRef getRejectedTemplate() - { - return rejectedTemplate; - } - - /** - * @return due for review email template - */ - public NodeRef getDueForReviewTemplate() - { - if (dueForReviewTemplate == null) - { - List nodeRefs = - searchService.selectNodes( - getRootNode(), - "app:company_home/app:dictionary/cm:records_management/cm:records_management_email_templates/cm:notify-records-due-for-review-email.ftl", null, - namespaceService, - false); - if (nodeRefs.size() == 1) - { - dueForReviewTemplate = nodeRefs.get(0); - } - } - return dueForReviewTemplate; - } - - /** - * Helper method to get root node in a tenant safe way. - * - * @return NodeRef root node of spaces store - */ - private NodeRef getRootNode() - { - String tenantDomain = tenantAdminService.getCurrentUserDomain(); - return TenantUtil.runAsSystemTenant(new TenantRunAsWork() - { - public NodeRef doWork() - { - return nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - } - }, tenantDomain); - } - - /** - * Sends records due for review email notification. - * - * @param records records due for review - */ - public void recordsDueForReviewEmailNotification(final List records) - { - ParameterCheck.mandatory("records", records); - if (!records.isEmpty()) - { - NodeRef root = getRMRoot(records.get(0)); - String groupName = getGroupName(root); - - if (doesGroupContainUsers(groupName)) - { - NotificationContext notificationContext = new NotificationContext(); - notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW)); - notificationContext.setAsyncNotification(false); - notificationContext.setIgnoreNotificationFailure(true); - - notificationContext.setBodyTemplate(getDueForReviewTemplate().toString()); - Map args = new HashMap(1, 1.0f); - args.put("records", (Serializable)records); - args.put("site", getSiteName(root)); - notificationContext.setTemplateArgs(args); - - notificationContext.addTo(groupName); - - notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn("Unable to send record due for review email notification, because notification group was empty."); - } - - throw new AlfrescoRuntimeException("Unable to send record due for review email notification, because notification group was empty."); - } - } - } - - /** - * Sends record superseded email notification. - * - * @param record superseded record - */ - public void recordSupersededEmailNotification(final NodeRef record) - { - ParameterCheck.mandatory("record", record); - - NodeRef root = getRMRoot(record); - String groupName = getGroupName(root); - - if (doesGroupContainUsers(groupName)) - { - NotificationContext notificationContext = new NotificationContext(); - notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_SUPERCEDED)); - notificationContext.setAsyncNotification(false); - notificationContext.setIgnoreNotificationFailure(true); - - notificationContext.setBodyTemplate(supersededTemplate.toString()); - Map args = new HashMap(1, 1.0f); - args.put("record", record); - args.put("site", getSiteName(root)); - notificationContext.setTemplateArgs(args); - - notificationContext.addTo(groupName); - - notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn("Unable to send record superseded email notification, because notification group was empty."); - } - } - } - - /** - * Sends record rejected email notification. - * - * @param record rejected record - */ - public void recordRejectedEmailNotification(NodeRef record, String recordId, String recordCreator) - { - ParameterCheck.mandatory("record", record); - - if (canSendRejectEmail(record, recordCreator)) - { - String site = siteService.getSite(record).getShortName(); - String rejectReason = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON); - String rejectedPerson = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID); - Date rejectDate = (Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE); - String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME); - - Map args = new HashMap(8); - args.put("record", record); - args.put("site", site); - args.put("recordCreator", recordCreator); - args.put("rejectReason", rejectReason); - args.put("rejectedPerson", rejectedPerson); - args.put("rejectDate", rejectDate); - args.put("recordId", recordId); - args.put("recordName", recordName); - - NotificationContext notificationContext = new NotificationContext(); - notificationContext.setAsyncNotification(true); - notificationContext.setIgnoreNotificationFailure(true); - notificationContext.addTo(recordCreator); - notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_REJECTED)); - notificationContext.setBodyTemplate(getRejectedTemplate().toString()); - notificationContext.setTemplateArgs(args); - - notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); - } - } - - /** - * Helper method to check if the mandatory properties are set - * - * @param record rejected record - */ - private boolean canSendRejectEmail(NodeRef record, String recordCreator) - { - boolean result = true; - - String msg1 = "Unable to send record rejected email notification, because "; - String msg2 = " could not be found!"; - - if (siteService.getSite(record) == null) - { - result = false; - logger.warn(msg1 + "the site which should contain the node '" + record.toString() + "'" + msg2); - } - if (StringUtils.isBlank(recordCreator)) - { - result = false; - logger.warn(msg1 + "the user, who created the record" + msg2); - } - if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON))) - { - result = false; - logger.warn(msg1 + "the reason for rejection" + msg2); - } - if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID))) - { - result = false; - logger.warn(msg1 + "the user, who rejected the record" + msg2); - } - if (((Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE)) == null) - { - result = false; - logger.warn(msg1 + "the date, when the record was rejected" + msg2); - } - - return result; - } - - /** - * Gets the rm root given a context node. - * - * @param context context node reference - * @return {@link NodeRef} rm root node reference - */ - private NodeRef getRMRoot(final NodeRef context) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return filePlanService.getFilePlan(context); - - } - }, AuthenticationUtil.getSystemUserName()); - - } - - /** - * Gets the group name for the notification role. - * - * @param root rm root node - * @return String notification role's group name - */ - private String getGroupName(final NodeRef root) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public String doWork() - { - // Find the authority for the given role - Role role = filePlanRoleService.getRole(root, notificationRole); - return role.getRoleGroupName(); - } - }, AuthenticationUtil.getSystemUserName()); - } - - private boolean doesGroupContainUsers(final String groupName) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Boolean doWork() throws Exception - { - Set users = authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); - return !users.isEmpty(); - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Get the site name, default if none/undetermined. - * - * @param root rm root - * @return String site name - */ - private String getSiteName(final NodeRef root) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public String doWork() - { - String result = DEFAULT_SITE; - - SiteInfo siteInfo = siteService.getSite(root); - if (siteInfo != null) - { - result = siteInfo.getShortName(); - } - - return result; - } - }, AuthenticationUtil.getSystemUserName()); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.notification; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.notification.EMailNotificationProvider; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.tenant.TenantAdminService; +import org.alfresco.repo.tenant.TenantUtil; +import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; +import org.alfresco.service.cmr.notification.NotificationContext; +import org.alfresco.service.cmr.notification.NotificationService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Helper bean containing methods useful when sending records + * management notifications via the {@link NotificationService} + * + * @author Roy Wetherall + */ +public class RecordsManagementNotificationHelper implements RecordsManagementModel +{ + private static Log logger = LogFactory.getLog(RecordsManagementNotificationHelper.class); + + /** I18n */ + private static final String MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW = "notification.dueforreview.subject"; + private static final String MSG_SUBJECT_RECORD_SUPERCEDED = "notification.superseded.subject"; + private static final String MSG_SUBJECT_RECORD_REJECTED = "notification.rejected.subject"; + + /** Defaults */ + private static final String DEFAULT_SITE = "rm"; + + /** Services */ + private NotificationService notificationService; + private FilePlanRoleService filePlanRoleService; + private SearchService searchService; + private NamespaceService namespaceService; + private SiteService siteService; + private AuthorityService authorityService; + private TenantAdminService tenantAdminService; + private NodeService nodeService; + private FilePlanService filePlanService; + + /** Notification role */ + private String notificationRole; + + /** EMail notification templates */ + private NodeRef supersededTemplate = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "record_superseded_template"); + private NodeRef dueForReviewTemplate; + private NodeRef rejectedTemplate = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "record_rejected_template"); + + /** + * @param notificationService notification service + */ + public void setNotificationService(NotificationService notificationService) + { + this.notificationService = notificationService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param notificationRole rm notification role + */ + public void setNotificationRole(String notificationRole) + { + this.notificationRole = notificationRole; + } + + /** + * @param searchService search service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param tenantAdminService tenant admin service + */ + public void setTenantAdminService(TenantAdminService tenantAdminService) + { + this.tenantAdminService = tenantAdminService; + } + + /** + * @return superseded email template + */ + public NodeRef getSupersededTemplate() + { + return supersededTemplate; + } + + /** + * @return rejected email template + */ + public NodeRef getRejectedTemplate() + { + return rejectedTemplate; + } + + /** + * @return due for review email template + */ + public NodeRef getDueForReviewTemplate() + { + if (dueForReviewTemplate == null) + { + List nodeRefs = + searchService.selectNodes( + getRootNode(), + "app:company_home/app:dictionary/cm:records_management/cm:records_management_email_templates/cm:notify-records-due-for-review-email.ftl", null, + namespaceService, + false); + if (nodeRefs.size() == 1) + { + dueForReviewTemplate = nodeRefs.get(0); + } + } + return dueForReviewTemplate; + } + + /** + * Helper method to get root node in a tenant safe way. + * + * @return NodeRef root node of spaces store + */ + private NodeRef getRootNode() + { + String tenantDomain = tenantAdminService.getCurrentUserDomain(); + return TenantUtil.runAsSystemTenant(new TenantRunAsWork() + { + public NodeRef doWork() + { + return nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + } + }, tenantDomain); + } + + /** + * Sends records due for review email notification. + * + * @param records records due for review + */ + public void recordsDueForReviewEmailNotification(final List records) + { + ParameterCheck.mandatory("records", records); + if (!records.isEmpty()) + { + NodeRef root = getRMRoot(records.get(0)); + String groupName = getGroupName(root); + + if (doesGroupContainUsers(groupName)) + { + NotificationContext notificationContext = new NotificationContext(); + notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW)); + notificationContext.setAsyncNotification(false); + notificationContext.setIgnoreNotificationFailure(true); + + notificationContext.setBodyTemplate(getDueForReviewTemplate().toString()); + Map args = new HashMap(1, 1.0f); + args.put("records", (Serializable)records); + args.put("site", getSiteName(root)); + notificationContext.setTemplateArgs(args); + + notificationContext.addTo(groupName); + + notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn("Unable to send record due for review email notification, because notification group was empty."); + } + + throw new AlfrescoRuntimeException("Unable to send record due for review email notification, because notification group was empty."); + } + } + } + + /** + * Sends record superseded email notification. + * + * @param record superseded record + */ + public void recordSupersededEmailNotification(final NodeRef record) + { + ParameterCheck.mandatory("record", record); + + NodeRef root = getRMRoot(record); + String groupName = getGroupName(root); + + if (doesGroupContainUsers(groupName)) + { + NotificationContext notificationContext = new NotificationContext(); + notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_SUPERCEDED)); + notificationContext.setAsyncNotification(false); + notificationContext.setIgnoreNotificationFailure(true); + + notificationContext.setBodyTemplate(supersededTemplate.toString()); + Map args = new HashMap(1, 1.0f); + args.put("record", record); + args.put("site", getSiteName(root)); + notificationContext.setTemplateArgs(args); + + notificationContext.addTo(groupName); + + notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn("Unable to send record superseded email notification, because notification group was empty."); + } + } + } + + /** + * Sends record rejected email notification. + * + * @param record rejected record + */ + public void recordRejectedEmailNotification(NodeRef record, String recordId, String recordCreator) + { + ParameterCheck.mandatory("record", record); + + if (canSendRejectEmail(record, recordCreator)) + { + String site = siteService.getSite(record).getShortName(); + String rejectReason = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON); + String rejectedPerson = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID); + Date rejectDate = (Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE); + String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME); + + Map args = new HashMap(8); + args.put("record", record); + args.put("site", site); + args.put("recordCreator", recordCreator); + args.put("rejectReason", rejectReason); + args.put("rejectedPerson", rejectedPerson); + args.put("rejectDate", rejectDate); + args.put("recordId", recordId); + args.put("recordName", recordName); + + NotificationContext notificationContext = new NotificationContext(); + notificationContext.setAsyncNotification(true); + notificationContext.setIgnoreNotificationFailure(true); + notificationContext.addTo(recordCreator); + notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_REJECTED)); + notificationContext.setBodyTemplate(getRejectedTemplate().toString()); + notificationContext.setTemplateArgs(args); + + notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); + } + } + + /** + * Helper method to check if the mandatory properties are set + * + * @param record rejected record + */ + private boolean canSendRejectEmail(NodeRef record, String recordCreator) + { + boolean result = true; + + String msg1 = "Unable to send record rejected email notification, because "; + String msg2 = " could not be found!"; + + if (siteService.getSite(record) == null) + { + result = false; + logger.warn(msg1 + "the site which should contain the node '" + record.toString() + "'" + msg2); + } + if (StringUtils.isBlank(recordCreator)) + { + result = false; + logger.warn(msg1 + "the user, who created the record" + msg2); + } + if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON))) + { + result = false; + logger.warn(msg1 + "the reason for rejection" + msg2); + } + if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID))) + { + result = false; + logger.warn(msg1 + "the user, who rejected the record" + msg2); + } + if (((Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE)) == null) + { + result = false; + logger.warn(msg1 + "the date, when the record was rejected" + msg2); + } + + return result; + } + + /** + * Gets the rm root given a context node. + * + * @param context context node reference + * @return {@link NodeRef} rm root node reference + */ + private NodeRef getRMRoot(final NodeRef context) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return filePlanService.getFilePlan(context); + + } + }, AuthenticationUtil.getSystemUserName()); + + } + + /** + * Gets the group name for the notification role. + * + * @param root rm root node + * @return String notification role's group name + */ + private String getGroupName(final NodeRef root) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public String doWork() + { + // Find the authority for the given role + Role role = filePlanRoleService.getRole(root, notificationRole); + return role.getRoleGroupName(); + } + }, AuthenticationUtil.getSystemUserName()); + } + + private boolean doesGroupContainUsers(final String groupName) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Boolean doWork() throws Exception + { + Set users = authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); + return !users.isEmpty(); + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Get the site name, default if none/undetermined. + * + * @param root rm root + * @return String site name + */ + private String getSiteName(final NodeRef root) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public String doWork() + { + String result = DEFAULT_SITE; + + SiteInfo siteInfo = siteService.getSite(root); + if (siteInfo != null) + { + result = siteInfo.getShortName(); + } + + return result; + } + }, AuthenticationUtil.getSystemUserName()); + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/AbstractModulePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/AbstractModulePatch.java index c3bed75b30..3299e4432b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/AbstractModulePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/AbstractModulePatch.java @@ -1,289 +1,289 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch; - -import java.util.concurrent.TimeUnit; - -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.transaction.TransactionService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Abstract module patch implementation. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware -{ - /** logger */ - protected static final Log LOGGER = LogFactory.getLog(ModulePatch.class); - - /** module patch service */ - private ModulePatchExecuter modulePatchExecuter; - - /** transaction service */ - protected TransactionService transactionService; - - /** module patch id */ - private String id; - - /** module patch description */ - private String description; - - /** module id */ - private String moduleId; - - /** module patch fixes from module schema number */ - private int fixesFromSchema; - - /** module patch fixes to module schema number */ - private int fixesToSchema; - - /** module patch target module schema number */ - private int targetSchema; - - /** if it should use a read only transaction */ - private boolean txnReadOnly = true; - - /** if it should use a new transaction */ - private boolean txnRequiresNew = false; - - /** - * Initiialisation method - */ - public void init() - { - modulePatchExecuter.register(this); - } - - public void setTxnReadOnly(boolean txnReadOnly) - { - this.txnReadOnly = txnReadOnly; - } - - public void setTxnRequiresNew(boolean txnRequiresNew) - { - this.txnRequiresNew = txnRequiresNew; - } - - /** - * @param modulePatchExecuter module patch executer - */ - public void setModulePatchExecuter(ModulePatchExecuter modulePatchExecuter) - { - this.modulePatchExecuter = modulePatchExecuter; - } - - /** - * @param transactionService transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * @param id module patch id - */ - public void setId(String id) - { - this.id = id; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getId() - */ - @Override - public String getId() - { - return id; - } - - /** - * Convenience method to set the module patch id to the bean name (if not already specified) - */ - @Override - public void setBeanName(String beanName) - { - if (id == null) - { - id = beanName; - } - } - - /** - * @param description module patch description - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getDescription() - */ - @Override - public String getDescription() - { - return description; - } - - /** - * @param moduleId module id - */ - public void setModuleId(String moduleId) - { - this.moduleId = moduleId; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getModuleId() - */ - @Override - public String getModuleId() - { - return moduleId; - } - - /** - * @param fixesFromSchema fixes from schema value - */ - public void setFixesFromSchema(int fixesFromSchema) - { - this.fixesFromSchema = fixesFromSchema; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesFromSchema() - */ - @Override - public int getFixesFromSchema() - { - return fixesFromSchema; - } - - /** - * @param fixesToSchema fixes to schema value - */ - public void setFixesToSchema(int fixesToSchema) - { - this.fixesToSchema = fixesToSchema; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesToSchema() - */ - @Override - public int getFixesToSchema() - { - return fixesToSchema; - } - - public void setTargetSchema(int targetSchema) - { - this.targetSchema = targetSchema; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getTargetSchema() - */ - @Override - public int getTargetSchema() - { - return targetSchema; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#apply() - */ - @Override - public void apply() - { - if (LOGGER.isInfoEnabled()) - { - LOGGER.info("Executing module patch \"" + description + "\""); - } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... id=" + id + - ",moduleId=" + moduleId + - ",from=" + fixesFromSchema + - ",to=" + fixesToSchema + - ",target=" + targetSchema); - } - - long startTime = System.nanoTime(); - - // do patch in transaction - transactionService.getRetryingTransactionHelper().doInTransaction( - new ApplyCallback(), - txnReadOnly, - txnRequiresNew); - - long elapsedTime = System.nanoTime() - startTime; - - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... module patch applied in " + TimeUnit.NANOSECONDS.toMillis(elapsedTime) + "ms"); - } - } - - /** - * Apply patch internal method. Implementations can assume a transaction has - * been started. - */ - public abstract void applyInternal(); - - /** - * Apply callback worker class implementation - */ - private class ApplyCallback implements RetryingTransactionCallback - { - /** - * @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute() - */ - @Override - public Void execute() - { - applyInternal(); - return null; - } - } - - /** - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(ModulePatch o) - { - int result = 0; - if (getTargetSchema() < o.getTargetSchema()) - { - result = -1; - } - else if (getTargetSchema() > o.getTargetSchema()) - { - result = 1; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch; + +import java.util.concurrent.TimeUnit; + +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.transaction.TransactionService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Abstract module patch implementation. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware +{ + /** logger */ + protected static final Log LOGGER = LogFactory.getLog(ModulePatch.class); + + /** module patch service */ + private ModulePatchExecuter modulePatchExecuter; + + /** transaction service */ + protected TransactionService transactionService; + + /** module patch id */ + private String id; + + /** module patch description */ + private String description; + + /** module id */ + private String moduleId; + + /** module patch fixes from module schema number */ + private int fixesFromSchema; + + /** module patch fixes to module schema number */ + private int fixesToSchema; + + /** module patch target module schema number */ + private int targetSchema; + + /** if it should use a read only transaction */ + private boolean txnReadOnly = true; + + /** if it should use a new transaction */ + private boolean txnRequiresNew = false; + + /** + * Initiialisation method + */ + public void init() + { + modulePatchExecuter.register(this); + } + + public void setTxnReadOnly(boolean txnReadOnly) + { + this.txnReadOnly = txnReadOnly; + } + + public void setTxnRequiresNew(boolean txnRequiresNew) + { + this.txnRequiresNew = txnRequiresNew; + } + + /** + * @param modulePatchExecuter module patch executer + */ + public void setModulePatchExecuter(ModulePatchExecuter modulePatchExecuter) + { + this.modulePatchExecuter = modulePatchExecuter; + } + + /** + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * @param id module patch id + */ + public void setId(String id) + { + this.id = id; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getId() + */ + @Override + public String getId() + { + return id; + } + + /** + * Convenience method to set the module patch id to the bean name (if not already specified) + */ + @Override + public void setBeanName(String beanName) + { + if (id == null) + { + id = beanName; + } + } + + /** + * @param description module patch description + */ + public void setDescription(String description) + { + this.description = description; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getDescription() + */ + @Override + public String getDescription() + { + return description; + } + + /** + * @param moduleId module id + */ + public void setModuleId(String moduleId) + { + this.moduleId = moduleId; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getModuleId() + */ + @Override + public String getModuleId() + { + return moduleId; + } + + /** + * @param fixesFromSchema fixes from schema value + */ + public void setFixesFromSchema(int fixesFromSchema) + { + this.fixesFromSchema = fixesFromSchema; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesFromSchema() + */ + @Override + public int getFixesFromSchema() + { + return fixesFromSchema; + } + + /** + * @param fixesToSchema fixes to schema value + */ + public void setFixesToSchema(int fixesToSchema) + { + this.fixesToSchema = fixesToSchema; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesToSchema() + */ + @Override + public int getFixesToSchema() + { + return fixesToSchema; + } + + public void setTargetSchema(int targetSchema) + { + this.targetSchema = targetSchema; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getTargetSchema() + */ + @Override + public int getTargetSchema() + { + return targetSchema; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#apply() + */ + @Override + public void apply() + { + if (LOGGER.isInfoEnabled()) + { + LOGGER.info("Executing module patch \"" + description + "\""); + } + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... id=" + id + + ",moduleId=" + moduleId + + ",from=" + fixesFromSchema + + ",to=" + fixesToSchema + + ",target=" + targetSchema); + } + + long startTime = System.nanoTime(); + + // do patch in transaction + transactionService.getRetryingTransactionHelper().doInTransaction( + new ApplyCallback(), + txnReadOnly, + txnRequiresNew); + + long elapsedTime = System.nanoTime() - startTime; + + if (LOGGER.isInfoEnabled()) + { + LOGGER.info(" ... module patch applied in " + TimeUnit.NANOSECONDS.toMillis(elapsedTime) + "ms"); + } + } + + /** + * Apply patch internal method. Implementations can assume a transaction has + * been started. + */ + public abstract void applyInternal(); + + /** + * Apply callback worker class implementation + */ + private class ApplyCallback implements RetryingTransactionCallback + { + /** + * @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute() + */ + @Override + public Void execute() + { + applyInternal(); + return null; + } + } + + /** + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(ModulePatch o) + { + int result = 0; + if (getTargetSchema() < o.getTargetSchema()) + { + result = -1; + } + else if (getTargetSchema() > o.getTargetSchema()) + { + result = 1; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatch.java index 4c0bc086d6..19e372da8d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatch.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch; - -/** - * Module Patch Interface - * - * @author Roy Wetherall - * @since 2.2 - */ -public interface ModulePatch extends Comparable -{ - /** - * @return module patch id - */ - String getId(); - - /** - * @return module patch description - */ - String getDescription(); - - /** - * @return module id this patch applies to - */ - String getModuleId(); - - /** - * @return smallest module schema number that this patch may be applied to - */ - int getFixesFromSchema(); - - /** - * @return largest module schema number that this patch may be applied to - */ - int getFixesToSchema(); - - /** - * @return module schema number that this patch attempts to bring the repo up to - */ - int getTargetSchema(); - - /** - * Apply the module patch - */ - void apply(); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch; + +/** + * Module Patch Interface + * + * @author Roy Wetherall + * @since 2.2 + */ +public interface ModulePatch extends Comparable +{ + /** + * @return module patch id + */ + String getId(); + + /** + * @return module patch description + */ + String getDescription(); + + /** + * @return module id this patch applies to + */ + String getModuleId(); + + /** + * @return smallest module schema number that this patch may be applied to + */ + int getFixesFromSchema(); + + /** + * @return largest module schema number that this patch may be applied to + */ + int getFixesToSchema(); + + /** + * @return module schema number that this patch attempts to bring the repo up to + */ + int getTargetSchema(); + + /** + * Apply the module patch + */ + void apply(); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuter.java index 670c4df3fc..34906f53e7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuter.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2015 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; - -/** - * Module patch service interface - * - * @author Roy Wetherall - * @since 2.2 - */ -public interface ModulePatchExecuter -{ - /** - * Register module patch with the module patch executer - * - * @param modulePatch module patch - */ - void register(ModulePatch modulePatch); - - /** - * Init the schema version number - */ - void initSchemaVersion(); -} +/* + * Copyright (C) 2005-2015 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; + +/** + * Module patch service interface + * + * @author Roy Wetherall + * @since 2.2 + */ +public interface ModulePatchExecuter +{ + /** + * Register module patch with the module patch executer + * + * @param modulePatch module patch + */ + void register(ModulePatch modulePatch); + + /** + * Init the schema version number + */ + void initSchemaVersion(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuterImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuterImpl.java index f1c6925886..68b7358d97 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuterImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/ModulePatchExecuterImpl.java @@ -1,168 +1,168 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.module.AbstractModuleComponent; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Module patch executer base implementation - * - * @author Roy Wetherall - * @since 2.2 - */ -public class ModulePatchExecuterImpl extends AbstractModuleComponent - implements ModulePatchExecuter -{ - /** logger */ - protected static final Log LOGGER = LogFactory.getLog(ModulePatchExecuterImpl.class); - - /** default start schema */ - private static final int START_SCHEMA = 0; - - /** attribute key */ - private static final String KEY_MODULE_SCHEMA = "module-schema"; - - /** configured module schema version */ - protected int moduleSchema = START_SCHEMA; - - /** attribute service */ - protected AttributeService attributeService; - - /** module patches */ - protected Map modulePatches = new HashMap(21); - - /** - * @param attributeService attribute service - */ - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - /** - * @param moduleSchema configured module schema version - */ - public void setModuleSchema(int moduleSchema) - { - this.moduleSchema = moduleSchema; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#register(org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch) - */ - @Override - public void register(ModulePatch modulePatch) - { - // ensure that the module patch being registered relates to the module id - if (!getModuleId().equals(modulePatch.getModuleId())) - { - throw new AlfrescoRuntimeException("Unable to register module patch, becuase module id is invalid."); - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Registering module patch " + modulePatch.getId() + " for module " + getModuleId()); - } - - modulePatches.put(modulePatch.getId(), modulePatch); - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executeInternal() - { - // get current schema version - int currentSchema = getCurrentSchema(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Running module patch executer (currentSchema=" + currentSchema + ", configuredSchema=" + moduleSchema + ")"); - } - - if (moduleSchema > currentSchema) - { - // determine what patches should be applied - List patchesToApply = new ArrayList(13); - for (ModulePatch modulePatch : modulePatches.values()) - { - if (modulePatch.getFixesFromSchema() <= currentSchema && - modulePatch.getFixesToSchema() >= currentSchema) - { - patchesToApply.add(modulePatch); - } - } - - // apply the patches in the correct order - Collections.sort(patchesToApply); - for (ModulePatch patchToApply : patchesToApply) - { - patchToApply.apply(); - } - - // update the schema - updateSchema(moduleSchema); - } - } - - /** - * Get the currently recorded schema version for the module - * - * @return int currently recorded schema version - */ - protected int getCurrentSchema() - { - Integer result = START_SCHEMA; - if (attributeService.exists(KEY_MODULE_SCHEMA, getModuleId())) - { - result = (Integer)attributeService.getAttribute(KEY_MODULE_SCHEMA, getModuleId()); - } - return result; - } - - /** - * Update the recorded schema version for the module. - * - * @param newSchema new schema version - */ - protected void updateSchema(int newSchema) - { - attributeService.setAttribute(Integer.valueOf(newSchema), KEY_MODULE_SCHEMA, getModuleId()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#initSchemaVersion() - */ - @Override - public void initSchemaVersion() - { - updateSchema(moduleSchema); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.module.AbstractModuleComponent; +import org.alfresco.service.cmr.attributes.AttributeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Module patch executer base implementation + * + * @author Roy Wetherall + * @since 2.2 + */ +public class ModulePatchExecuterImpl extends AbstractModuleComponent + implements ModulePatchExecuter +{ + /** logger */ + protected static final Log LOGGER = LogFactory.getLog(ModulePatchExecuterImpl.class); + + /** default start schema */ + private static final int START_SCHEMA = 0; + + /** attribute key */ + private static final String KEY_MODULE_SCHEMA = "module-schema"; + + /** configured module schema version */ + protected int moduleSchema = START_SCHEMA; + + /** attribute service */ + protected AttributeService attributeService; + + /** module patches */ + protected Map modulePatches = new HashMap(21); + + /** + * @param attributeService attribute service + */ + public void setAttributeService(AttributeService attributeService) + { + this.attributeService = attributeService; + } + + /** + * @param moduleSchema configured module schema version + */ + public void setModuleSchema(int moduleSchema) + { + this.moduleSchema = moduleSchema; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#register(org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch) + */ + @Override + public void register(ModulePatch modulePatch) + { + // ensure that the module patch being registered relates to the module id + if (!getModuleId().equals(modulePatch.getModuleId())) + { + throw new AlfrescoRuntimeException("Unable to register module patch, becuase module id is invalid."); + } + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Registering module patch " + modulePatch.getId() + " for module " + getModuleId()); + } + + modulePatches.put(modulePatch.getId(), modulePatch); + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executeInternal() + { + // get current schema version + int currentSchema = getCurrentSchema(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Running module patch executer (currentSchema=" + currentSchema + ", configuredSchema=" + moduleSchema + ")"); + } + + if (moduleSchema > currentSchema) + { + // determine what patches should be applied + List patchesToApply = new ArrayList(13); + for (ModulePatch modulePatch : modulePatches.values()) + { + if (modulePatch.getFixesFromSchema() <= currentSchema && + modulePatch.getFixesToSchema() >= currentSchema) + { + patchesToApply.add(modulePatch); + } + } + + // apply the patches in the correct order + Collections.sort(patchesToApply); + for (ModulePatch patchToApply : patchesToApply) + { + patchToApply.apply(); + } + + // update the schema + updateSchema(moduleSchema); + } + } + + /** + * Get the currently recorded schema version for the module + * + * @return int currently recorded schema version + */ + protected int getCurrentSchema() + { + Integer result = START_SCHEMA; + if (attributeService.exists(KEY_MODULE_SCHEMA, getModuleId())) + { + result = (Integer)attributeService.getAttribute(KEY_MODULE_SCHEMA, getModuleId()); + } + return result; + } + + /** + * Update the recorded schema version for the module. + * + * @param newSchema new schema version + */ + protected void updateSchema(int newSchema) + { + attributeService.setAttribute(Integer.valueOf(newSchema), KEY_MODULE_SCHEMA, getModuleId()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#initSchemaVersion() + */ + @Override + public void initSchemaVersion() + { + updateSchema(moduleSchema); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/common/CapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/common/CapabilityPatch.java index be8caa2d38..2209b2e10b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/common/CapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/common/CapabilityPatch.java @@ -1,140 +1,140 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.common; - -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; - -/** - * Abstract implementation of capability patch. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class CapabilityPatch extends AbstractModulePatch -{ - /** File plan service */ - private FilePlanService filePlanService; - - /** authority service */ - private AuthorityService authorityService; - - /** permission service */ - private PermissionService permissionService; - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Helper method to get the file plans - * - * @return Set of file plan node references - */ - protected Set getFilePlans() - { - return filePlanService.getFilePlans(); - } - - /** - * Adds a new capability to the specified roles. - * - * @param filePlan file plan - * @param capabilityName capability name - * @param roles roles - */ - protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles) - { - for (String role : roles) - { - String fullRoleName = role + filePlan.getId(); - String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName); - if (roleAuthority == null) - { - throw new AlfrescoRuntimeException("Role " + role + " does not exist."); - } - else - { - permissionService.setPermission(filePlan, roleAuthority, capabilityName, true); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - Set filePlans = getFilePlans(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); - } - - for (NodeRef filePlan : filePlans) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating file plan " + filePlan.toString()); - } - - // apply the capability patch to each file plan - applyCapabilityPatch(filePlan); - } - } - - @Override - public void apply() - { - setTxnReadOnly(false); - setTxnRequiresNew(true); - super.apply(); - } - - protected abstract void applyCapabilityPatch(NodeRef filePlan); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.common; + +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; + +/** + * Abstract implementation of capability patch. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class CapabilityPatch extends AbstractModulePatch +{ + /** File plan service */ + private FilePlanService filePlanService; + + /** authority service */ + private AuthorityService authorityService; + + /** permission service */ + private PermissionService permissionService; + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Helper method to get the file plans + * + * @return Set of file plan node references + */ + protected Set getFilePlans() + { + return filePlanService.getFilePlans(); + } + + /** + * Adds a new capability to the specified roles. + * + * @param filePlan file plan + * @param capabilityName capability name + * @param roles roles + */ + protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles) + { + for (String role : roles) + { + String fullRoleName = role + filePlan.getId(); + String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName); + if (roleAuthority == null) + { + throw new AlfrescoRuntimeException("Role " + role + " does not exist."); + } + else + { + permissionService.setPermission(filePlan, roleAuthority, capabilityName, true); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + Set filePlans = getFilePlans(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); + } + + for (NodeRef filePlan : filePlans) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating file plan " + filePlan.toString()); + } + + // apply the capability patch to each file plan + applyCapabilityPatch(filePlan); + } + } + + @Override + public void apply() + { + setTxnReadOnly(false); + setTxnRequiresNew(true); + super.apply(); + } + + protected abstract void applyCapabilityPatch(NodeRef filePlan); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java index e2232b6d1b..4c0d4f2666 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java @@ -1,137 +1,137 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.compatibility; - -import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl; -import org.alfresco.repo.module.AbstractModuleComponent; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * Module patch component base class. - * - * @author Roy Wetherall - * @since 2.1 - */ -@Deprecated -public abstract class ModulePatchComponent extends AbstractModuleComponent -{ - /** logger */ - protected static final Log LOGGER = LogFactory.getLog(ModulePatchComponent.class); - - /** Retrying transaction helper */ - protected RetryingTransactionHelper retryingTransactionHelper; - - /** Behaviour filter */ - protected BehaviourFilter behaviourFilter; - - /** module patch executer */ - protected ModulePatchExecuterImpl modulePatchExecuter; - - /** - * @param retryingTransactionHelper retrying transaction helper - */ - public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @param behaviourFilter behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * @param modulePatchExecuter module patch executer - */ - public void setModulePatchExecuter(ModulePatchExecuterImpl modulePatchExecuter) - { - this.modulePatchExecuter = modulePatchExecuter; - } - - /** - * Init method - */ - @Override - public void init() - { - super.init(); - modulePatchExecuter.getDependsOn().add(this); - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executeInternal() - { - try - { - if (LOGGER.isInfoEnabled()) - { - LOGGER.info("Module patch component '" + getName() + "' is executing ..."); - } - - // execute path within an isolated transaction - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - @Override - public Void execute() - { - behaviourFilter.disableBehaviour(); - try - { - executePatch(); - } - finally - { - behaviourFilter.enableBehaviour(); - } - return null; - } - - }, false, true); - - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... completed module patch '" + getName() + "'"); - } - } - catch (Throwable exception) - { - // record the exception otherwise it gets swallowed - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... error encountered. " + exception.getMessage(), exception); - } - throw exception; - } - } - - /** - * Execute patch work. - */ - protected abstract void executePatch(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.compatibility; + +import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl; +import org.alfresco.repo.module.AbstractModuleComponent; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + +/** + * Module patch component base class. + * + * @author Roy Wetherall + * @since 2.1 + */ +@Deprecated +public abstract class ModulePatchComponent extends AbstractModuleComponent +{ + /** logger */ + protected static final Log LOGGER = LogFactory.getLog(ModulePatchComponent.class); + + /** Retrying transaction helper */ + protected RetryingTransactionHelper retryingTransactionHelper; + + /** Behaviour filter */ + protected BehaviourFilter behaviourFilter; + + /** module patch executer */ + protected ModulePatchExecuterImpl modulePatchExecuter; + + /** + * @param retryingTransactionHelper retrying transaction helper + */ + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + /** + * @param behaviourFilter behaviour filter + */ + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * @param modulePatchExecuter module patch executer + */ + public void setModulePatchExecuter(ModulePatchExecuterImpl modulePatchExecuter) + { + this.modulePatchExecuter = modulePatchExecuter; + } + + /** + * Init method + */ + @Override + public void init() + { + super.init(); + modulePatchExecuter.getDependsOn().add(this); + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executeInternal() + { + try + { + if (LOGGER.isInfoEnabled()) + { + LOGGER.info("Module patch component '" + getName() + "' is executing ..."); + } + + // execute path within an isolated transaction + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + @Override + public Void execute() + { + behaviourFilter.disableBehaviour(); + try + { + executePatch(); + } + finally + { + behaviourFilter.enableBehaviour(); + } + return null; + } + + }, false, true); + + if (LOGGER.isInfoEnabled()) + { + LOGGER.info(" ... completed module patch '" + getName() + "'"); + } + } + catch (Throwable exception) + { + // record the exception otherwise it gets swallowed + if (LOGGER.isInfoEnabled()) + { + LOGGER.info(" ... error encountered. " + exception.getMessage(), exception); + } + throw exception; + } + } + + /** + * Execute patch work. + */ + protected abstract void executePatch(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/NotificationTemplatePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/NotificationTemplatePatch.java index 1c1218ad35..7c711448c6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/NotificationTemplatePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/NotificationTemplatePatch.java @@ -1,202 +1,202 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v20; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; -import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.audit.AuditService; -import org.alfresco.service.cmr.repository.ContentService; -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.version.Version; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Notification template patch implementation - * - * @author Roy Wetherall - * @since 2.0 - */ -@SuppressWarnings("deprecation") -public class NotificationTemplatePatch extends ModulePatchComponent - implements BeanNameAware -{ - /** Last patch update property */ - private static final QName PROP_LAST_PATCH_UPDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastPatchUpdate"); - - private static final String PATH_DUE_FOR_REVIEW = "alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl"; - private static final String PATH_SUPERSEDED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl"; - - /** Records management notification helper */ - private RecordsManagementNotificationHelper notificationHelper; - - /** Node service */ - private NodeService nodeService; - - /** Content service */ - private ContentService contentService; - - /** Version service */ - private VersionService versionService; - - /** Audit service */ - private AuditService auditService; - - /** Bean name */ - private String name; - - /** - * @param notificationHelper notification helper - */ - public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) - { - this.notificationHelper = notificationHelper; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param versionService version service - */ - public void setVersionService(VersionService versionService) - { - this.versionService = versionService; - } - - /** - * @param auditService audit service - */ - public void setAuditService(AuditService auditService) - { - this.auditService = auditService; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#setBeanName(java.lang.String) - */ - @Override - public void setBeanName(String name) - { - this.name = name; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - NodeRef supersededTemplate = notificationHelper.getSupersededTemplate(); - updateTemplate(supersededTemplate, PATH_SUPERSEDED); - - NodeRef dueForReviewTemplate = notificationHelper.getDueForReviewTemplate(); - updateTemplate(dueForReviewTemplate, PATH_DUE_FOR_REVIEW); - } - - /** - * Attempt to update the template with the updated version - * - * @param template - * @param updatedTemplate - */ - private void updateTemplate(NodeRef template, String templateUpdate) - { - if (template == null || !nodeService.exists(template)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Skipping template update, because template has not been bootstraped."); - } - } - else - { - // Check to see if this template has already been updated - String lastPatchUpdate = (String)nodeService.getProperty(template, PROP_LAST_PATCH_UPDATE); - if (lastPatchUpdate == null || !name.equals(lastPatchUpdate)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Applying update to template. (template=" + template.toString() + ", templateUpdate=" + templateUpdate + ")"); - } - - // Make sure the template is versionable - if (!nodeService.hasAspect(template, ContentModel.ASPECT_VERSIONABLE)) - { - nodeService.addAspect(template, ContentModel.ASPECT_VERSIONABLE, null); - - // Create version (before template is updated) - Map versionProperties = new HashMap(2); - versionProperties.put(Version.PROP_DESCRIPTION, "Initial version"); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionService.createVersion(template, versionProperties); - } - - // Update the content of the template - InputStream is = getClass().getClassLoader().getResourceAsStream(templateUpdate); - ContentWriter writer = contentService.getWriter(template, ContentModel.PROP_CONTENT, true); - writer.putContent(is); - - boolean enabled = auditService.isAuditEnabled(); - auditService.setAuditEnabled(false); - try - { - // Set the last patch update property - nodeService.setProperty(template, PROP_LAST_PATCH_UPDATE, name); - } - finally - { - auditService.setAuditEnabled(enabled); - } - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Skipping template update, because template has already been patched. (template=" + template.toString() + ")"); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v20; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.audit.AuditService; +import org.alfresco.service.cmr.repository.ContentService; +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.version.Version; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.cmr.version.VersionType; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Notification template patch implementation + * + * @author Roy Wetherall + * @since 2.0 + */ +@SuppressWarnings("deprecation") +public class NotificationTemplatePatch extends ModulePatchComponent + implements BeanNameAware +{ + /** Last patch update property */ + private static final QName PROP_LAST_PATCH_UPDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastPatchUpdate"); + + private static final String PATH_DUE_FOR_REVIEW = "alfresco/module/org_alfresco_module_rm/bootstrap/content/notify-records-due-for-review-email.ftl"; + private static final String PATH_SUPERSEDED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-superseded-email.ftl"; + + /** Records management notification helper */ + private RecordsManagementNotificationHelper notificationHelper; + + /** Node service */ + private NodeService nodeService; + + /** Content service */ + private ContentService contentService; + + /** Version service */ + private VersionService versionService; + + /** Audit service */ + private AuditService auditService; + + /** Bean name */ + private String name; + + /** + * @param notificationHelper notification helper + */ + public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) + { + this.notificationHelper = notificationHelper; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @param versionService version service + */ + public void setVersionService(VersionService versionService) + { + this.versionService = versionService; + } + + /** + * @param auditService audit service + */ + public void setAuditService(AuditService auditService) + { + this.auditService = auditService; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#setBeanName(java.lang.String) + */ + @Override + public void setBeanName(String name) + { + this.name = name; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + NodeRef supersededTemplate = notificationHelper.getSupersededTemplate(); + updateTemplate(supersededTemplate, PATH_SUPERSEDED); + + NodeRef dueForReviewTemplate = notificationHelper.getDueForReviewTemplate(); + updateTemplate(dueForReviewTemplate, PATH_DUE_FOR_REVIEW); + } + + /** + * Attempt to update the template with the updated version + * + * @param template + * @param updatedTemplate + */ + private void updateTemplate(NodeRef template, String templateUpdate) + { + if (template == null || !nodeService.exists(template)) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Skipping template update, because template has not been bootstraped."); + } + } + else + { + // Check to see if this template has already been updated + String lastPatchUpdate = (String)nodeService.getProperty(template, PROP_LAST_PATCH_UPDATE); + if (lastPatchUpdate == null || !name.equals(lastPatchUpdate)) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Applying update to template. (template=" + template.toString() + ", templateUpdate=" + templateUpdate + ")"); + } + + // Make sure the template is versionable + if (!nodeService.hasAspect(template, ContentModel.ASPECT_VERSIONABLE)) + { + nodeService.addAspect(template, ContentModel.ASPECT_VERSIONABLE, null); + + // Create version (before template is updated) + Map versionProperties = new HashMap(2); + versionProperties.put(Version.PROP_DESCRIPTION, "Initial version"); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionService.createVersion(template, versionProperties); + } + + // Update the content of the template + InputStream is = getClass().getClassLoader().getResourceAsStream(templateUpdate); + ContentWriter writer = contentService.getWriter(template, ContentModel.PROP_CONTENT, true); + writer.putContent(is); + + boolean enabled = auditService.isAuditEnabled(); + auditService.setAuditEnabled(false); + try + { + // Set the last patch update property + nodeService.setProperty(template, PROP_LAST_PATCH_UPDATE, name); + } + finally + { + auditService.setAuditEnabled(enabled); + } + } + else + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Skipping template update, because template has already been patched. (template=" + template.toString() + ")"); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2FilePlanNodeRefPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2FilePlanNodeRefPatch.java index 30e0dc935e..8d37003933 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2FilePlanNodeRefPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2FilePlanNodeRefPatch.java @@ -1,173 +1,173 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v20; - -import java.io.Serializable; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.domain.node.NodeDAO; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.domain.qname.QNameDAO; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.springframework.beans.factory.BeanNameAware; - -/** - * RM v2.0 File Plan Node Ref Patch - * - * @author Roy Wetherall - * @since 2.0 - */ -@SuppressWarnings("deprecation") -public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent - implements BeanNameAware, RecordsManagementModel, DOD5015Model -{ - private NodeService nodeService; - private PatchDAO patchDAO; - private NodeDAO nodeDAO; - private QNameDAO qnameDAO; - private PermissionService permissionService; - private FilePlanService filePlanService; - private FilePlanRoleService filePlanRoleService; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - public void setNodeDAO(NodeDAO nodeDAO) - { - this.nodeDAO = nodeDAO; - } - - public void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - Pair aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); - if (aspectPair != null) - { - List filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + filePlanComponents.size() + " items"); - } - - - for (Long filePlanComponent : filePlanComponents) - { - Pair recordPair = nodeDAO.getNodePair(filePlanComponent); - NodeRef filePlanComponentNodeRef = recordPair.getSecond(); - - NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef); - - if(filePlan != null) - { - // set the file plan node reference - if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null) - { - nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan); - } - - // only set the admin permissions on record categories, record folders and records - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef); - if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) || - FilePlanComponentKind.RECORD_FOLDER.equals(kind) || - FilePlanComponentKind.RECORD.equals(kind)) - { - // ensure the that the records management role has read and file on the node - Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator"); - if (adminRole != null) - { - permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true); - } - - // ensure that the default vital record default values have been set (RM-753) - Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR); - if (vitalRecordIndicator == null) - { - nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false); - } - Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD); - if (reviewPeriod == null) - { - nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0")); - } - } - } - else - { - if (LOGGER.isWarnEnabled()) - { - LOGGER.warn(" ... node " + filePlanComponent.toString() + " was skiped, beacuse there was no associated file plan."); - } - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v20; + +import java.io.Serializable; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.patch.PatchDAO; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.0 File Plan Node Ref Patch + * + * @author Roy Wetherall + * @since 2.0 + */ +@SuppressWarnings("deprecation") +public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + private NodeService nodeService; + private PatchDAO patchDAO; + private NodeDAO nodeDAO; + private QNameDAO qnameDAO; + private PermissionService permissionService; + private FilePlanService filePlanService; + private FilePlanRoleService filePlanRoleService; + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setPatchDAO(PatchDAO patchDAO) + { + this.patchDAO = patchDAO; + } + + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + Pair aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + if (aspectPair != null) + { + List filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + filePlanComponents.size() + " items"); + } + + + for (Long filePlanComponent : filePlanComponents) + { + Pair recordPair = nodeDAO.getNodePair(filePlanComponent); + NodeRef filePlanComponentNodeRef = recordPair.getSecond(); + + NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef); + + if(filePlan != null) + { + // set the file plan node reference + if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null) + { + nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan); + } + + // only set the admin permissions on record categories, record folders and records + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef); + if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) || + FilePlanComponentKind.RECORD_FOLDER.equals(kind) || + FilePlanComponentKind.RECORD.equals(kind)) + { + // ensure the that the records management role has read and file on the node + Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator"); + if (adminRole != null) + { + permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true); + } + + // ensure that the default vital record default values have been set (RM-753) + Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR); + if (vitalRecordIndicator == null) + { + nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false); + } + Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD); + if (reviewPeriod == null) + { + nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0")); + } + } + } + else + { + if (LOGGER.isWarnEnabled()) + { + LOGGER.warn(" ... node " + filePlanComponent.toString() + " was skiped, beacuse there was no associated file plan."); + } + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2ModelPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2ModelPatch.java index 01be7f7155..2b02f0016a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2ModelPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2ModelPatch.java @@ -1,147 +1,147 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v20; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; -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.transaction.RetryingTransactionHelper; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.springframework.beans.factory.BeanNameAware; - -/** - * RM v2.0 Model Updates Patch - * - * @author Roy Wetherall - * @since 2.0 - */ -@SuppressWarnings("deprecation") -public class RMv2ModelPatch extends ModulePatchComponent - implements BeanNameAware, RecordsManagementModel, DOD5015Model -{ - private static final long BATCH_SIZE = 100000L; - - private PatchDAO patchDAO; - private NodeDAO nodeDAO; - private QNameDAO qnameDAO; - - 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 executePatch() - { - updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE"); - updateQName(QName.createQName(DOD_URI, "recordCategory"), TYPE_RECORD_CATEGORY, "TYPE"); - updateQName(QName.createQName(DOD_URI, "ghosted"), ASPECT_GHOSTED, "ASPECT"); - } - - private void updateQName(QName qnameBefore, QName qnameAfter, String reindexClass) - { - Work work = new Work(qnameBefore, qnameAfter, reindexClass); - retryingTransactionHelper.doInTransaction(work, false, true); - } - - private class Work implements RetryingTransactionHelper.RetryingTransactionCallback - { - private QName qnameBefore; - private QName qnameAfter; - private String reindexClass; - - /** - * Constructor - * - * @param qnameBefore qname before - * @param qnameAfter qname after - * @param reindexClass reindex class - */ - Work(QName qnameBefore, QName qnameAfter, String reindexClass) - { - this.qnameBefore = qnameBefore; - this.qnameAfter = qnameAfter; - this.reindexClass = reindexClass; - } - - /** - * @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute() - */ - @Override - public Integer execute() throws Throwable - { - Long maxNodeId = patchDAO.getMaxAdmNodeID(); - - Pair before = qnameDAO.getQName(qnameBefore); - - if (before != null) - { - for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE) - { - if ("TYPE".equals(reindexClass)) - { - List nodeIds = patchDAO.getNodesByTypeQNameId(before.getFirst(), i, i + BATCH_SIZE); - nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds); - } - else if ("ASPECT".equals(reindexClass)) - { - List nodeIds = patchDAO.getNodesByAspectQNameId(before.getFirst(), i, i + BATCH_SIZE); - nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds); - } - } - - qnameDAO.updateQName(qnameBefore, qnameAfter); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updated qname " + qnameBefore.toString()); - } - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... no need to update qname " + qnameBefore.toString()); - } - } - - //nothing to do - return 0; - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v20; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; +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.transaction.RetryingTransactionHelper; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.0 Model Updates Patch + * + * @author Roy Wetherall + * @since 2.0 + */ +@SuppressWarnings("deprecation") +public class RMv2ModelPatch extends ModulePatchComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + private static final long BATCH_SIZE = 100000L; + + private PatchDAO patchDAO; + private NodeDAO nodeDAO; + private QNameDAO qnameDAO; + + 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 executePatch() + { + updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE"); + updateQName(QName.createQName(DOD_URI, "recordCategory"), TYPE_RECORD_CATEGORY, "TYPE"); + updateQName(QName.createQName(DOD_URI, "ghosted"), ASPECT_GHOSTED, "ASPECT"); + } + + private void updateQName(QName qnameBefore, QName qnameAfter, String reindexClass) + { + Work work = new Work(qnameBefore, qnameAfter, reindexClass); + retryingTransactionHelper.doInTransaction(work, false, true); + } + + private class Work implements RetryingTransactionHelper.RetryingTransactionCallback + { + private QName qnameBefore; + private QName qnameAfter; + private String reindexClass; + + /** + * Constructor + * + * @param qnameBefore qname before + * @param qnameAfter qname after + * @param reindexClass reindex class + */ + Work(QName qnameBefore, QName qnameAfter, String reindexClass) + { + this.qnameBefore = qnameBefore; + this.qnameAfter = qnameAfter; + this.reindexClass = reindexClass; + } + + /** + * @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute() + */ + @Override + public Integer execute() throws Throwable + { + Long maxNodeId = patchDAO.getMaxAdmNodeID(); + + Pair before = qnameDAO.getQName(qnameBefore); + + if (before != null) + { + for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE) + { + if ("TYPE".equals(reindexClass)) + { + List nodeIds = patchDAO.getNodesByTypeQNameId(before.getFirst(), i, i + BATCH_SIZE); + nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds); + } + else if ("ASPECT".equals(reindexClass)) + { + List nodeIds = patchDAO.getNodesByAspectQNameId(before.getFirst(), i, i + BATCH_SIZE); + nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds); + } + } + + qnameDAO.updateQName(qnameBefore, qnameAfter); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updated qname " + qnameBefore.toString()); + } + } + else + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... no need to update qname " + qnameBefore.toString()); + } + } + + //nothing to do + return 0; + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2SavedSearchPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2SavedSearchPatch.java index 6dd1881118..636e6f1c56 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2SavedSearchPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v20/RMv2SavedSearchPatch.java @@ -1,117 +1,117 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v20; - -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteService; -import org.springframework.beans.factory.BeanNameAware; - -/** - * RM v2.0 Saved Search Patch - * - * @author Roy Wetherall - * @since 2.0 - */ -@SuppressWarnings("deprecation") -public class RMv2SavedSearchPatch extends ModulePatchComponent - implements BeanNameAware, RecordsManagementModel, DOD5015Model -{ - /** RM site id */ - private static final String RM_SITE_ID = "rm"; - - /** Records management search service */ - private RecordsManagementSearchService recordsManagementSearchService; - - /** Site service */ - private SiteService siteService; - - /** Content service */ - private ContentService contentService; - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - if (siteService.getSite(RM_SITE_ID) != null) - { - // get the saved searches - List savedSearches = recordsManagementSearchService.getSavedSearches(RM_SITE_ID); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + savedSearches.size() + " saved searches"); - } - - for (SavedSearchDetails savedSearchDetails : savedSearches) - { - // refresh the query - String refreshedJSON = savedSearchDetails.toJSONString(); - NodeRef nodeRef = savedSearchDetails.getNodeRef(); - - if (nodeRef != null) - { - ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); - writer.putContent(refreshedJSON); - - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updated saved search " + savedSearchDetails.getName() + " (nodeRef=" + nodeRef.toString() + ")"); - } - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v20; + +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteService; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.0 Saved Search Patch + * + * @author Roy Wetherall + * @since 2.0 + */ +@SuppressWarnings("deprecation") +public class RMv2SavedSearchPatch extends ModulePatchComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + /** RM site id */ + private static final String RM_SITE_ID = "rm"; + + /** Records management search service */ + private RecordsManagementSearchService recordsManagementSearchService; + + /** Site service */ + private SiteService siteService; + + /** Content service */ + private ContentService contentService; + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + if (siteService.getSite(RM_SITE_ID) != null) + { + // get the saved searches + List savedSearches = recordsManagementSearchService.getSavedSearches(RM_SITE_ID); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + savedSearches.size() + " saved searches"); + } + + for (SavedSearchDetails savedSearchDetails : savedSearches) + { + // refresh the query + String refreshedJSON = savedSearchDetails.toJSONString(); + NodeRef nodeRef = savedSearchDetails.getNodeRef(); + + if (nodeRef != null) + { + ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); + writer.putContent(refreshedJSON); + + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updated saved search " + savedSearchDetails.getName() + " (nodeRef=" + nodeRef.toString() + ")"); + } + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/NotificationTemplatePatch_v21.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/NotificationTemplatePatch_v21.java index c14a2da0b3..a03cfeb59f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/NotificationTemplatePatch_v21.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/NotificationTemplatePatch_v21.java @@ -1,117 +1,117 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Adds a new email template for rejected records to the existing templates - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class NotificationTemplatePatch_v21 extends RMv21PatchComponent -{ - /** Email template path */ - private static final String PATH_REJECTED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl"; - - /** Reject template config node id*/ - private static final String CONFIG_NODEID = "record_rejected_template"; - - /** Records management notification helper */ - private RecordsManagementNotificationHelper notificationHelper; - - /** Node service */ - private NodeService nodeService; - - /** Content service */ - private ContentService contentService; - - /** - * @param notificationHelper notification helper - */ - public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) - { - this.notificationHelper = notificationHelper; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - @Override - protected void executePatch() - { - NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); - // get the parent node - NodeRef supersededTemplate = notificationHelper.getSupersededTemplate(); - if (!nodeService.exists(nodeRef) && nodeService.exists(supersededTemplate)) - { - NodeRef parent = nodeService.getPrimaryParent(supersededTemplate).getParentRef(); - - // build the node properties - Map props = new HashMap(4); - props.put(ContentModel.PROP_DESCRIPTION, "Record superseded email template."); - props.put(ContentModel.PROP_TITLE, "record-rejected-email.ftl"); - props.put(ContentModel.PROP_NAME, "record-rejected-email.ftl"); - props.put(ContentModel.PROP_NODE_UUID, "record_rejected_template"); - - // get the assoc qname - QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("record-rejected-email.ftl")); - - // create the node - ChildAssociationRef node = nodeService.createNode(parent, - ContentModel.ASSOC_CONTAINS, - assocQName, - ContentModel.TYPE_CONTENT, - props); - - // put the content - ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); - InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_REJECTED); - writer.putContent(is); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Adds a new email template for rejected records to the existing templates + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class NotificationTemplatePatch_v21 extends RMv21PatchComponent +{ + /** Email template path */ + private static final String PATH_REJECTED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl"; + + /** Reject template config node id*/ + private static final String CONFIG_NODEID = "record_rejected_template"; + + /** Records management notification helper */ + private RecordsManagementNotificationHelper notificationHelper; + + /** Node service */ + private NodeService nodeService; + + /** Content service */ + private ContentService contentService; + + /** + * @param notificationHelper notification helper + */ + public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) + { + this.notificationHelper = notificationHelper; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + @Override + protected void executePatch() + { + NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); + // get the parent node + NodeRef supersededTemplate = notificationHelper.getSupersededTemplate(); + if (!nodeService.exists(nodeRef) && nodeService.exists(supersededTemplate)) + { + NodeRef parent = nodeService.getPrimaryParent(supersededTemplate).getParentRef(); + + // build the node properties + Map props = new HashMap(4); + props.put(ContentModel.PROP_DESCRIPTION, "Record superseded email template."); + props.put(ContentModel.PROP_TITLE, "record-rejected-email.ftl"); + props.put(ContentModel.PROP_NAME, "record-rejected-email.ftl"); + props.put(ContentModel.PROP_NODE_UUID, "record_rejected_template"); + + // get the assoc qname + QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("record-rejected-email.ftl")); + + // create the node + ChildAssociationRef node = nodeService.createNode(parent, + ContentModel.ASSOC_CONTAINS, + assocQName, + ContentModel.TYPE_CONTENT, + props); + + // put the content + ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); + InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_REJECTED); + writer.putContent(is); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21BehaviorScriptsPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21BehaviorScriptsPatch.java index a66a16aa5f..81a8c4c1e3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21BehaviorScriptsPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21BehaviorScriptsPatch.java @@ -1,175 +1,175 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import static org.apache.commons.logging.LogFactory.getLog; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.springframework.beans.factory.BeanNameAware; - -/** - * This patch creates a new "Records Management Behavior Scripts" folder and moves existing behavior scripts from the old "Records Management Scripts" folder to the new folder. - * This is to compensate for any non-behavior RM scripts so that they can live in the old "Records Management Scripts" folder for its intended purpose and be picked up by the - * execute script rule action. - * - * @author Craig Tan - * @since 2.1 - */ -public class RMv21BehaviorScriptsPatch extends RMv21PatchComponent implements BeanNameAware -{ - /** Logger */ - private static final Log LOGGER = getLog(RMv21BehaviorScriptsPatch.class); - - /** rm config folder root lookup */ - protected static final NodeRef RM_CONFIG = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); - - /** old behavior scripts folder root lookup */ - protected static final NodeRef OLD_BEHAVIOR_SCRIPTS_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_scripts"); - - /** new behavior scripts folder root lookup */ - private static NodeRef newBehaviorScriptsFolder = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_behavior_scripts"); - - /** name of example script */ - protected static final String IS_CLOSED_JS = "rma_isClosed.js"; - - /** Node Service */ - private NodeService nodeService; - - /** File Folder Service */ - private FileFolderService fileFolderService; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch() - */ - @Override - protected void executePatch() - { - // check that the rm config root has been correctly bootstrapped - if (!nodeService.exists(RM_CONFIG)) - { - // we don't need to do anything - return; - } - - // check that the behavior scripts folder exists - if (!nodeService.exists(newBehaviorScriptsFolder)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... creating RM Behavior Scripts folder"); - } - - String newBehaviorScriptsFolderName = "Records Management Behavior Scripts"; - String newBehaviorScriptsNodeUUID = "rm_behavior_scripts"; - String newBehaviorScriptsAssocQName = "records_management_behavior_scripts"; - - Map newBehaviorScriptsFolderProps = new HashMap(); - newBehaviorScriptsFolderProps.put(ContentModel.PROP_NODE_UUID, newBehaviorScriptsNodeUUID); - newBehaviorScriptsFolderProps.put(ContentModel.PROP_NAME, newBehaviorScriptsFolderName); - newBehaviorScriptsFolderProps.put(ContentModel.PROP_TITLE, newBehaviorScriptsFolderName); - newBehaviorScriptsFolderProps.put(ContentModel.PROP_DESCRIPTION, "Scripts intended for execution in response to RM events."); - - newBehaviorScriptsFolder = nodeService.createNode(RM_CONFIG, ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, newBehaviorScriptsAssocQName), - ContentModel.TYPE_FOLDER, newBehaviorScriptsFolderProps).getChildRef(); - } - - // move to the new behavior scripts folder if the old behavior scripts folder exists and contains files - if (nodeService.exists(OLD_BEHAVIOR_SCRIPTS_FOLDER)) - { - // run the following code as System - AuthenticationUtil.runAs(new RunAsWork() - { - @SuppressWarnings("deprecation") - public Object doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Update the description of the old Scripts folder. - nodeService.setProperty(OLD_BEHAVIOR_SCRIPTS_FOLDER, ContentModel.PROP_DESCRIPTION, "Scripts specific to RM that can also be executed by RM rules."); - - // Move files from RM Scripts folder to RM Behavior Scripts folder. - List oldBehaviorScripts = fileFolderService.listFiles(OLD_BEHAVIOR_SCRIPTS_FOLDER); - - if (oldBehaviorScripts != null && !oldBehaviorScripts.isEmpty()) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... moving files from RM Scripts folder to RM Behavior Scripts folder"); - } - - for (FileInfo script : oldBehaviorScripts) - { - // move the old script to the new location - fileFolderService.moveFrom(script.getNodeRef(), OLD_BEHAVIOR_SCRIPTS_FOLDER, RMv21BehaviorScriptsPatch.newBehaviorScriptsFolder, script.getName()); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ...... moved " + script.getName()); - } - } - - } - return null; - } - }; - - retryingTransactionHelper.doInTransaction(callback); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - } - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import static org.apache.commons.logging.LogFactory.getLog; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.springframework.beans.factory.BeanNameAware; + +/** + * This patch creates a new "Records Management Behavior Scripts" folder and moves existing behavior scripts from the old "Records Management Scripts" folder to the new folder. + * This is to compensate for any non-behavior RM scripts so that they can live in the old "Records Management Scripts" folder for its intended purpose and be picked up by the + * execute script rule action. + * + * @author Craig Tan + * @since 2.1 + */ +public class RMv21BehaviorScriptsPatch extends RMv21PatchComponent implements BeanNameAware +{ + /** Logger */ + private static final Log LOGGER = getLog(RMv21BehaviorScriptsPatch.class); + + /** rm config folder root lookup */ + protected static final NodeRef RM_CONFIG = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); + + /** old behavior scripts folder root lookup */ + protected static final NodeRef OLD_BEHAVIOR_SCRIPTS_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_scripts"); + + /** new behavior scripts folder root lookup */ + private static NodeRef newBehaviorScriptsFolder = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_behavior_scripts"); + + /** name of example script */ + protected static final String IS_CLOSED_JS = "rma_isClosed.js"; + + /** Node Service */ + private NodeService nodeService; + + /** File Folder Service */ + private FileFolderService fileFolderService; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch() + */ + @Override + protected void executePatch() + { + // check that the rm config root has been correctly bootstrapped + if (!nodeService.exists(RM_CONFIG)) + { + // we don't need to do anything + return; + } + + // check that the behavior scripts folder exists + if (!nodeService.exists(newBehaviorScriptsFolder)) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... creating RM Behavior Scripts folder"); + } + + String newBehaviorScriptsFolderName = "Records Management Behavior Scripts"; + String newBehaviorScriptsNodeUUID = "rm_behavior_scripts"; + String newBehaviorScriptsAssocQName = "records_management_behavior_scripts"; + + Map newBehaviorScriptsFolderProps = new HashMap(); + newBehaviorScriptsFolderProps.put(ContentModel.PROP_NODE_UUID, newBehaviorScriptsNodeUUID); + newBehaviorScriptsFolderProps.put(ContentModel.PROP_NAME, newBehaviorScriptsFolderName); + newBehaviorScriptsFolderProps.put(ContentModel.PROP_TITLE, newBehaviorScriptsFolderName); + newBehaviorScriptsFolderProps.put(ContentModel.PROP_DESCRIPTION, "Scripts intended for execution in response to RM events."); + + newBehaviorScriptsFolder = nodeService.createNode(RM_CONFIG, ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, newBehaviorScriptsAssocQName), + ContentModel.TYPE_FOLDER, newBehaviorScriptsFolderProps).getChildRef(); + } + + // move to the new behavior scripts folder if the old behavior scripts folder exists and contains files + if (nodeService.exists(OLD_BEHAVIOR_SCRIPTS_FOLDER)) + { + // run the following code as System + AuthenticationUtil.runAs(new RunAsWork() + { + @SuppressWarnings("deprecation") + public Object doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Update the description of the old Scripts folder. + nodeService.setProperty(OLD_BEHAVIOR_SCRIPTS_FOLDER, ContentModel.PROP_DESCRIPTION, "Scripts specific to RM that can also be executed by RM rules."); + + // Move files from RM Scripts folder to RM Behavior Scripts folder. + List oldBehaviorScripts = fileFolderService.listFiles(OLD_BEHAVIOR_SCRIPTS_FOLDER); + + if (oldBehaviorScripts != null && !oldBehaviorScripts.isEmpty()) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... moving files from RM Scripts folder to RM Behavior Scripts folder"); + } + + for (FileInfo script : oldBehaviorScripts) + { + // move the old script to the new location + fileFolderService.moveFrom(script.getNodeRef(), OLD_BEHAVIOR_SCRIPTS_FOLDER, RMv21BehaviorScriptsPatch.newBehaviorScriptsFolder, script.getName()); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ...... moved " + script.getName()); + } + } + + } + return null; + } + }; + + retryingTransactionHelper.doInTransaction(callback); + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + } + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21CapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21CapabilityPatch.java index 8844cba92b..2b7d97d3a6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21CapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21CapabilityPatch.java @@ -1,167 +1,167 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; - -/** - * RM v2.1 patch to updated modified capabilities. - * - * @author Roy Wetherall - * @since 2.1 - */ -@SuppressWarnings("deprecation") -public class RMv21CapabilityPatch extends RMv21PatchComponent -{ - /** File plan service */ - private FilePlanService filePlanService; - - /** authority service */ - private AuthorityService authorityService; - - /** permission service */ - private PermissionService permissionService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Helper method to get the file plans - * - * @return Set of file plan node references - */ - protected Set getFilePlans() - { - return filePlanService.getFilePlans(); - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * Adds a new capability to the specified roles. - * - * @param filePlan file plan - * @param capabilityName capability name - * @param roles roles - */ - private void addCapability(NodeRef filePlan, String capabilityName, String ... roles) - { - for (String role : roles) - { - String fullRoleName = role + filePlan.getId(); - String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName); - if (roleAuthority == null) - { - throw new AlfrescoRuntimeException("Role " + role + " does not exist."); - } - else - { - permissionService.setPermission(filePlan, roleAuthority, capabilityName, true); - } - } - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - Set filePlans = getFilePlans(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); - } - - for (NodeRef filePlan : filePlans) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating file plan " + filePlan.toString()); - } - - // add new capabilities - addCapability(filePlan, - "CreateRecords", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_POWER_USER, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER); - addCapability(filePlan, - "ManageRules", - FilePlanRoleService.ROLE_ADMIN); - addCapability(filePlan, - "RequestRecordInformation", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_POWER_USER, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER); - addCapability(filePlan, - "FileDestructionReport", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - addCapability(filePlan, - "RejectRecords", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_POWER_USER, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER); - addCapability(filePlan, - "FileUnfiledRecords", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_POWER_USER, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER); - addCapability(filePlan, - "LinkToRecords", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_POWER_USER, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; + +/** + * RM v2.1 patch to updated modified capabilities. + * + * @author Roy Wetherall + * @since 2.1 + */ +@SuppressWarnings("deprecation") +public class RMv21CapabilityPatch extends RMv21PatchComponent +{ + /** File plan service */ + private FilePlanService filePlanService; + + /** authority service */ + private AuthorityService authorityService; + + /** permission service */ + private PermissionService permissionService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Helper method to get the file plans + * + * @return Set of file plan node references + */ + protected Set getFilePlans() + { + return filePlanService.getFilePlans(); + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * Adds a new capability to the specified roles. + * + * @param filePlan file plan + * @param capabilityName capability name + * @param roles roles + */ + private void addCapability(NodeRef filePlan, String capabilityName, String ... roles) + { + for (String role : roles) + { + String fullRoleName = role + filePlan.getId(); + String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName); + if (roleAuthority == null) + { + throw new AlfrescoRuntimeException("Role " + role + " does not exist."); + } + else + { + permissionService.setPermission(filePlan, roleAuthority, capabilityName, true); + } + } + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + Set filePlans = getFilePlans(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); + } + + for (NodeRef filePlan : filePlans) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating file plan " + filePlan.toString()); + } + + // add new capabilities + addCapability(filePlan, + "CreateRecords", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_POWER_USER, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER); + addCapability(filePlan, + "ManageRules", + FilePlanRoleService.ROLE_ADMIN); + addCapability(filePlan, + "RequestRecordInformation", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_POWER_USER, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER); + addCapability(filePlan, + "FileDestructionReport", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + addCapability(filePlan, + "RejectRecords", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_POWER_USER, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER); + addCapability(filePlan, + "FileUnfiledRecords", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_POWER_USER, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER); + addCapability(filePlan, + "LinkToRecords", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_POWER_USER, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java index d3a02070cb..3adddd965b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java @@ -1,224 +1,224 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.springframework.beans.factory.BeanNameAware; - -/** - * RM v2.1 patch to support InPlace functional updates - * - * @author Roy Wetherall - * @since 2.1 - */ -@SuppressWarnings("deprecation") -public class RMv21InPlacePatch extends RMv21PatchComponent - implements BeanNameAware, RecordsManagementModel, DOD5015Model -{ - /** Extended reader and writer role details */ - private static final String ROLE_READERS_LABEL = "In-Place Readers"; - private static final String[] ROLE_READERS_CAPABILITIES = new String[] - { - "ViewRecords" - }; - private static final String ROLE_WRITERS_LABEL = "In-Place Writers"; - private static final String[] ROLE_WRITERS_CAPABILITIES = new String[] - { - "ViewRecords", - "EditNonRecordMetadata" - }; - - /** file plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** file plan service */ - private FilePlanService filePlanService; - - /** File plan permission service */ - private FilePlanPermissionService filePlanPermissionService; - - /** capability service */ - private CapabilityService capabilityService; - - /** rule service */ - private RuleService ruleService; - - /** node service */ - private NodeService nodeService; - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param filePlanPermissionService file plan permission service - */ - public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) - { - this.filePlanPermissionService = filePlanPermissionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param ruleService rule service - */ - public void setRuleService(RuleService ruleService) - { - this.ruleService = ruleService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - Set filePlans = filePlanService.getFilePlans(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); - } - - for (NodeRef filePlan : filePlans) - { - if (filePlanService.getUnfiledContainer(filePlan) == null) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating file plan " + filePlan.toString()); - } - - ruleService.disableRules(); - try - { - // create fileplan containers - filePlanService.createHoldContainer(filePlan); - filePlanService.createTransferContainer(filePlan); - filePlanService.createUnfiledContainer(filePlan); - - // move any existing holds to new container - moveExistingHolds(filePlan); - - // move any existing transfers to new container - moveExistingTransfers(filePlan); - - // add the inplace roles - filePlanRoleService.createRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS, ROLE_READERS_LABEL, getCapabilities(ROLE_READERS_CAPABILITIES)); - filePlanRoleService.createRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS, ROLE_WRITERS_LABEL, getCapabilities(ROLE_WRITERS_CAPABILITIES)); - } - finally - { - ruleService.enableRules(); - } - } - } - } - - private Set getCapabilities(String[] capabilityNames) - { - Set capabilities = new HashSet(3); - for (String capabilityName : capabilityNames) - { - capabilities.add(capabilityService.getCapability(capabilityName)); - } - return capabilities; - } - - private void moveExistingHolds(NodeRef filePlan) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... moving existing holds for file plan " + filePlan.toString()); - } - - NodeRef container = filePlanService.getHoldContainer(filePlan); - - List assocs = nodeService.getChildAssocs(filePlan, ASSOC_HOLDS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef hold = assoc.getChildRef(); - String name = (String)nodeService.getProperty(hold, ContentModel.PROP_NAME); - nodeService.moveNode(hold, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name)); - } - } - - private void moveExistingTransfers(NodeRef filePlan) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... moving existing transfers for file plan " + filePlan.toString()); - } - - NodeRef container = filePlanService.getTransferContainer(filePlan); - - List assocs = nodeService.getChildAssocs(filePlan, ASSOC_TRANSFERS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef transfer = assoc.getChildRef(); - String name = (String)nodeService.getProperty(transfer, ContentModel.PROP_NAME); - nodeService.moveNode(transfer, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name)); - } - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.rule.RuleService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.1 patch to support InPlace functional updates + * + * @author Roy Wetherall + * @since 2.1 + */ +@SuppressWarnings("deprecation") +public class RMv21InPlacePatch extends RMv21PatchComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + /** Extended reader and writer role details */ + private static final String ROLE_READERS_LABEL = "In-Place Readers"; + private static final String[] ROLE_READERS_CAPABILITIES = new String[] + { + "ViewRecords" + }; + private static final String ROLE_WRITERS_LABEL = "In-Place Writers"; + private static final String[] ROLE_WRITERS_CAPABILITIES = new String[] + { + "ViewRecords", + "EditNonRecordMetadata" + }; + + /** file plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** file plan service */ + private FilePlanService filePlanService; + + /** File plan permission service */ + private FilePlanPermissionService filePlanPermissionService; + + /** capability service */ + private CapabilityService capabilityService; + + /** rule service */ + private RuleService ruleService; + + /** node service */ + private NodeService nodeService; + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param filePlanPermissionService file plan permission service + */ + public void setFilePlanPermissionService(FilePlanPermissionService filePlanPermissionService) + { + this.filePlanPermissionService = filePlanPermissionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param ruleService rule service + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + Set filePlans = filePlanService.getFilePlans(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); + } + + for (NodeRef filePlan : filePlans) + { + if (filePlanService.getUnfiledContainer(filePlan) == null) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating file plan " + filePlan.toString()); + } + + ruleService.disableRules(); + try + { + // create fileplan containers + filePlanService.createHoldContainer(filePlan); + filePlanService.createTransferContainer(filePlan); + filePlanService.createUnfiledContainer(filePlan); + + // move any existing holds to new container + moveExistingHolds(filePlan); + + // move any existing transfers to new container + moveExistingTransfers(filePlan); + + // add the inplace roles + filePlanRoleService.createRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS, ROLE_READERS_LABEL, getCapabilities(ROLE_READERS_CAPABILITIES)); + filePlanRoleService.createRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS, ROLE_WRITERS_LABEL, getCapabilities(ROLE_WRITERS_CAPABILITIES)); + } + finally + { + ruleService.enableRules(); + } + } + } + } + + private Set getCapabilities(String[] capabilityNames) + { + Set capabilities = new HashSet(3); + for (String capabilityName : capabilityNames) + { + capabilities.add(capabilityService.getCapability(capabilityName)); + } + return capabilities; + } + + private void moveExistingHolds(NodeRef filePlan) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... moving existing holds for file plan " + filePlan.toString()); + } + + NodeRef container = filePlanService.getHoldContainer(filePlan); + + List assocs = nodeService.getChildAssocs(filePlan, ASSOC_HOLDS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef hold = assoc.getChildRef(); + String name = (String)nodeService.getProperty(hold, ContentModel.PROP_NAME); + nodeService.moveNode(hold, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name)); + } + } + + private void moveExistingTransfers(NodeRef filePlan) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... moving existing transfers for file plan " + filePlan.toString()); + } + + NodeRef container = filePlanService.getTransferContainer(filePlan); + + List assocs = nodeService.getChildAssocs(filePlan, ASSOC_TRANSFERS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef transfer = assoc.getChildRef(); + String name = (String)nodeService.getProperty(transfer, ContentModel.PROP_NAME); + nodeService.moveNode(transfer, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name)); + } + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21PatchComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21PatchComponent.java index 81ac31a8fe..ea04ddc954 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21PatchComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21PatchComponent.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; -import org.alfresco.repo.module.ModuleComponent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * Convenience class to ensure all V2.0 patches are executed before v2.1 - * - * @author Roy Wetherall - * @since 2.2 - */ -@SuppressWarnings("deprecation") -public abstract class RMv21PatchComponent extends ModulePatchComponent - implements ApplicationContextAware -{ - /** application context */ - private ApplicationContext applicationContext; - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - { - this.applicationContext = applicationContext; - } - - /** - * init method - */ - @Override - public void init() - { - super.init(); - - // manual addition of V20 patch dependencies - List depends = getDependsOn(); - addDependency(depends, "org_alfresco_module_rm_notificationTemplatePatch"); - addDependency(depends, "org_alfresco_module_rm_RMv2ModelPatch"); - addDependency(depends, "org_alfresco_module_rm_RMv2FilePlanNodeRefPatch"); - addDependency(depends, "org_alfresco_module_rm_RMv2SavedSearchPatch"); - } - - /** - * @param depends list of module dependencies - * @param beanName bean name - */ - private void addDependency(List depends, String beanName) - { - ModuleComponent moduleComponent = (ModuleComponent)applicationContext.getBean(beanName); - depends.add(moduleComponent); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent; +import org.alfresco.repo.module.ModuleComponent; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * Convenience class to ensure all V2.0 patches are executed before v2.1 + * + * @author Roy Wetherall + * @since 2.2 + */ +@SuppressWarnings("deprecation") +public abstract class RMv21PatchComponent extends ModulePatchComponent + implements ApplicationContextAware +{ + /** application context */ + private ApplicationContext applicationContext; + + /** + * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) + { + this.applicationContext = applicationContext; + } + + /** + * init method + */ + @Override + public void init() + { + super.init(); + + // manual addition of V20 patch dependencies + List depends = getDependsOn(); + addDependency(depends, "org_alfresco_module_rm_notificationTemplatePatch"); + addDependency(depends, "org_alfresco_module_rm_RMv2ModelPatch"); + addDependency(depends, "org_alfresco_module_rm_RMv2FilePlanNodeRefPatch"); + addDependency(depends, "org_alfresco_module_rm_RMv2SavedSearchPatch"); + } + + /** + * @param depends list of module dependencies + * @param beanName bean name + */ + private void addDependency(List depends, String beanName) + { + ModuleComponent moduleComponent = (ModuleComponent)applicationContext.getBean(beanName); + depends.add(moduleComponent); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RecordInheritancePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RecordInheritancePatch.java index a3d4d2f707..5ba69e6f98 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RecordInheritancePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RecordInheritancePatch.java @@ -1,137 +1,137 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionServiceImpl; -import org.alfresco.repo.domain.node.NodeDAO; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.domain.qname.QNameDAO; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.springframework.beans.factory.BeanNameAware; - -/** - * RM v2.1 patch to change the record inheritance of permissions. - * - * @author Roy Wetherall - * @since 2.1 - */ -@SuppressWarnings("deprecation") -public class RMv21RecordInheritancePatch extends RMv21PatchComponent - implements BeanNameAware, RecordsManagementModel, DOD5015Model -{ - /** file plan permission service */ - private FilePlanPermissionServiceImpl filePlanPermissionServiceImpl; - - /** node service */ - private NodeService nodeService; - - /** patch DAO */ - private PatchDAO patchDAO; - - /** qname DAO */ - private QNameDAO qnameDAO; - - /** node DAO */ - private NodeDAO nodeDAO; - - /** - * @param patchDAO patch DAO - */ - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - /** - * @param qnameDAO qname DAO - */ - public void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - /** - * @param nodeDAO node DAO - */ - public void setNodeDAO(NodeDAO nodeDAO) - { - this.nodeDAO = nodeDAO; - } - - /** - * @param filePlanPermissionServiceImpl file plan permission service implementation - */ - public void setFilePlanPermissionServiceImpl(FilePlanPermissionServiceImpl filePlanPermissionServiceImpl) - { - this.filePlanPermissionServiceImpl = filePlanPermissionServiceImpl; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() - */ - @Override - protected void executePatch() - { - Pair aspectPair = qnameDAO.getQName(ASPECT_RECORD); - if (aspectPair != null) - { - List records = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + records.size() + " records"); - } - - for (Long record : records) - { - Pair recordPair = nodeDAO.getNodePair(record); - NodeRef recordNodeRef = recordPair.getSecond(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating record " + recordNodeRef.toString()); - - // get the primary parent - ChildAssociationRef assoc = nodeService.getPrimaryParent(recordNodeRef); - NodeRef parent = assoc.getParentRef(); - if (parent != null) - { - filePlanPermissionServiceImpl.setupPermissions(parent, recordNodeRef); - } - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionServiceImpl; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.patch.PatchDAO; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.1 patch to change the record inheritance of permissions. + * + * @author Roy Wetherall + * @since 2.1 + */ +@SuppressWarnings("deprecation") +public class RMv21RecordInheritancePatch extends RMv21PatchComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + /** file plan permission service */ + private FilePlanPermissionServiceImpl filePlanPermissionServiceImpl; + + /** node service */ + private NodeService nodeService; + + /** patch DAO */ + private PatchDAO patchDAO; + + /** qname DAO */ + private QNameDAO qnameDAO; + + /** node DAO */ + private NodeDAO nodeDAO; + + /** + * @param patchDAO patch DAO + */ + public void setPatchDAO(PatchDAO patchDAO) + { + this.patchDAO = patchDAO; + } + + /** + * @param qnameDAO qname DAO + */ + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * @param nodeDAO node DAO + */ + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + /** + * @param filePlanPermissionServiceImpl file plan permission service implementation + */ + public void setFilePlanPermissionServiceImpl(FilePlanPermissionServiceImpl filePlanPermissionServiceImpl) + { + this.filePlanPermissionServiceImpl = filePlanPermissionServiceImpl; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executePatch() + { + Pair aspectPair = qnameDAO.getQName(ASPECT_RECORD); + if (aspectPair != null) + { + List records = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + records.size() + " records"); + } + + for (Long record : records) + { + Pair recordPair = nodeDAO.getNodePair(record); + NodeRef recordNodeRef = recordPair.getSecond(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating record " + recordNodeRef.toString()); + + // get the primary parent + ChildAssociationRef assoc = nodeService.getPrimaryParent(recordNodeRef); + NodeRef parent = assoc.getParentRef(); + if (parent != null) + { + filePlanPermissionServiceImpl.setupPermissions(parent, recordNodeRef); + } + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21ReportServicePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21ReportServicePatch.java index 73b704cb97..b2cb46de63 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21ReportServicePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21ReportServicePatch.java @@ -1,140 +1,140 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentService; -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.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Report service patch, adding report structure in data dictionary and report templates. - * - * @author Roy Wetherall - * @since 2.1 - */ -@SuppressWarnings("deprecation") -public class RMv21ReportServicePatch extends RMv21PatchComponent - implements BeanNameAware -{ - private static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); - private static final NodeRef RM_CONFIG_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); - - private static final String PATH_DESTRUCTION_TEMPLATE = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl"; - - /** node service */ - private NodeService nodeService; - - /** content service */ - private ContentService contentService; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - @Override - protected void executePatch() - { - // check whether report dir exists or not - if (nodeService.exists(RM_CONFIG_FOLDER) && !nodeService.exists(TEMPLATE_ROOT)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... adding template root folder"); - } - - NodeRef reportTemplates = createNode( - RM_CONFIG_FOLDER, - ContentModel.TYPE_FOLDER, - "rm_report_templates", - "Records Management Report Templates", - "rm_report_templates", - "Records Management Report Templates", - "Records Management Report Templates"); - nodeService.addAspect(reportTemplates, ContentModel.ASPECT_TITLED, null); - nodeService.addAspect(reportTemplates, ContentModel.ASPECT_AUTHOR, null); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... adding destruction report template"); - } - - // create report templates - NodeRef destructionTemplate = createNode( - TEMPLATE_ROOT, - ContentModel.TYPE_CONTENT, - "rmr_destructionReport", - "report_rmr_destructionReport.html.ftl", - "report_rmr_destructionReport.html.ftl", - "Destruction Report Template", - "Desruction report template."); - nodeService.addAspect(destructionTemplate, ContentModel.ASPECT_TITLED, null); - nodeService.addAspect(destructionTemplate, ContentModel.ASPECT_AUTHOR, null); - - // put the content - ContentWriter writer = contentService.getWriter(destructionTemplate, ContentModel.PROP_CONTENT, true); - InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_DESTRUCTION_TEMPLATE); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(is); - } - } - - private NodeRef createNode(NodeRef parent, QName type, String id, String name, String assocName, String title, String description) - { - Map props = new HashMap(4); - props.put(ContentModel.PROP_DESCRIPTION, description); - props.put(ContentModel.PROP_TITLE, title); - props.put(ContentModel.PROP_NAME, name); - props.put(ContentModel.PROP_NODE_UUID, id); - - // get the assoc qname - QName assocQName = QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, - QName.createValidLocalName(assocName)); - - // create the node - return nodeService.createNode( - parent, - ContentModel.ASSOC_CONTAINS, - assocQName, - type, - props).getChildRef(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ContentService; +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.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Report service patch, adding report structure in data dictionary and report templates. + * + * @author Roy Wetherall + * @since 2.1 + */ +@SuppressWarnings("deprecation") +public class RMv21ReportServicePatch extends RMv21PatchComponent + implements BeanNameAware +{ + private static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); + private static final NodeRef RM_CONFIG_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); + + private static final String PATH_DESTRUCTION_TEMPLATE = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_destructionReport.html.ftl"; + + /** node service */ + private NodeService nodeService; + + /** content service */ + private ContentService contentService; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + @Override + protected void executePatch() + { + // check whether report dir exists or not + if (nodeService.exists(RM_CONFIG_FOLDER) && !nodeService.exists(TEMPLATE_ROOT)) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... adding template root folder"); + } + + NodeRef reportTemplates = createNode( + RM_CONFIG_FOLDER, + ContentModel.TYPE_FOLDER, + "rm_report_templates", + "Records Management Report Templates", + "rm_report_templates", + "Records Management Report Templates", + "Records Management Report Templates"); + nodeService.addAspect(reportTemplates, ContentModel.ASPECT_TITLED, null); + nodeService.addAspect(reportTemplates, ContentModel.ASPECT_AUTHOR, null); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... adding destruction report template"); + } + + // create report templates + NodeRef destructionTemplate = createNode( + TEMPLATE_ROOT, + ContentModel.TYPE_CONTENT, + "rmr_destructionReport", + "report_rmr_destructionReport.html.ftl", + "report_rmr_destructionReport.html.ftl", + "Destruction Report Template", + "Desruction report template."); + nodeService.addAspect(destructionTemplate, ContentModel.ASPECT_TITLED, null); + nodeService.addAspect(destructionTemplate, ContentModel.ASPECT_AUTHOR, null); + + // put the content + ContentWriter writer = contentService.getWriter(destructionTemplate, ContentModel.PROP_CONTENT, true); + InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_DESTRUCTION_TEMPLATE); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent(is); + } + } + + private NodeRef createNode(NodeRef parent, QName type, String id, String name, String assocName, String title, String description) + { + Map props = new HashMap(4); + props.put(ContentModel.PROP_DESCRIPTION, description); + props.put(ContentModel.PROP_TITLE, title); + props.put(ContentModel.PROP_NAME, name); + props.put(ContentModel.PROP_NODE_UUID, id); + + // get the assoc qname + QName assocQName = QName.createQName( + NamespaceService.CONTENT_MODEL_1_0_URI, + QName.createValidLocalName(assocName)); + + // create the node + return nodeService.createNode( + parent, + ContentModel.ASSOC_CONTAINS, + assocQName, + type, + props).getChildRef(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RolesPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RolesPatch.java index 3ce9e325db..2f72dc53c4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RolesPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21RolesPatch.java @@ -1,109 +1,109 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v21; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.security.authority.RMAuthority; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Adds the existing rm roles to a new zone "APP.RM" - * - * @author Tuna Aksoy - * @since 2.1 - */ -@SuppressWarnings("deprecation") -public class RMv21RolesPatch extends RMv21PatchComponent implements BeanNameAware -{ - /** file plan service */ - private FilePlanService filePlanService; - - /** file plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** authority service */ - private AuthorityService authorityService; - - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch() - */ - @Override - protected void executePatch() - { - Set filePlans = filePlanService.getFilePlans(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); - } - - for (NodeRef filePlan : filePlans) - { - boolean parentAddedToZone = false; - Set roles = filePlanRoleService.getRoles(filePlan); - for (Role role : roles) - { - String roleGroupName = role.getRoleGroupName(); - if (!authorityService.getAuthorityZones(roleGroupName).contains(RMAuthority.ZONE_APP_RM)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + roleGroupName + " in file plan " + filePlan.toString()); - } - - addAuthorityToZone(roleGroupName); - if (!parentAddedToZone) - { - String allRolesGroupName = filePlanRoleService.getAllRolesContainerGroup(filePlan); - addAuthorityToZone(allRolesGroupName); - parentAddedToZone = true; - } - } - } - } - } - - private void addAuthorityToZone(String roleGroupName) - { - authorityService.addAuthorityToZones(roleGroupName, new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v21; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.springframework.beans.factory.BeanNameAware; + +/** + * Adds the existing rm roles to a new zone "APP.RM" + * + * @author Tuna Aksoy + * @since 2.1 + */ +@SuppressWarnings("deprecation") +public class RMv21RolesPatch extends RMv21PatchComponent implements BeanNameAware +{ + /** file plan service */ + private FilePlanService filePlanService; + + /** file plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** authority service */ + private AuthorityService authorityService; + + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch() + */ + @Override + protected void executePatch() + { + Set filePlans = filePlanService.getFilePlans(); + + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + filePlans.size() + " file plans"); + } + + for (NodeRef filePlan : filePlans) + { + boolean parentAddedToZone = false; + Set roles = filePlanRoleService.getRoles(filePlan); + for (Role role : roles) + { + String roleGroupName = role.getRoleGroupName(); + if (!authorityService.getAuthorityZones(roleGroupName).contains(RMAuthority.ZONE_APP_RM)) + { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + roleGroupName + " in file plan " + filePlan.toString()); + } + + addAuthorityToZone(roleGroupName); + if (!parentAddedToZone) + { + String allRolesGroupName = filePlanRoleService.getAllRolesContainerGroup(filePlan); + addAuthorityToZone(allRolesGroupName); + parentAddedToZone = true; + } + } + } + } + } + + private void addAuthorityToZone(String roleGroupName) + { + authorityService.addAuthorityToZones(roleGroupName, new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java index 1226edf1ee..f1f4f5b44e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * RM v2.2 patch to updated modified capabilities. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class RMv22CapabilityPatch extends CapabilityPatch -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) - */ - protected void applyCapabilityPatch(NodeRef filePlan) - { - // add new capbilities - addCapability(filePlan, - "FileDestructionReport", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - addCapability(filePlan, - "CreateHold", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - addCapability(filePlan, - "AddToHold", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - addCapability(filePlan, - "RemoveFromHold", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - - // @see https://issues.alfresco.com/jira/browse/RM-2058 - addCapability(filePlan, - "ManageAccessControls", - FilePlanRoleService.ROLE_SECURITY_OFFICER, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * RM v2.2 patch to updated modified capabilities. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class RMv22CapabilityPatch extends CapabilityPatch +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) + */ + protected void applyCapabilityPatch(NodeRef filePlan) + { + // add new capbilities + addCapability(filePlan, + "FileDestructionReport", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + addCapability(filePlan, + "CreateHold", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + addCapability(filePlan, + "AddToHold", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + addCapability(filePlan, + "RemoveFromHold", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + + // @see https://issues.alfresco.com/jira/browse/RM-2058 + addCapability(filePlan, + "ManageAccessControls", + FilePlanRoleService.ROLE_SECURITY_OFFICER, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODCompliantSitePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODCompliantSitePatch.java index 6d5cd5d907..fa303c3a15 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODCompliantSitePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODCompliantSitePatch.java @@ -1,82 +1,82 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.repo.domain.qname.QNameDAO; - -/** - * DOD compliant site patch. - * - * Makes all existing sites of type dod:site to preserve their DOD compliance status. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22DODCompliantSitePatch extends AbstractModulePatch - implements RecordsManagementModel -{ - /** QName DAO */ - private QNameDAO qnameDAO; - - /** indicates whether we convert to a standard file plan or not */ - private boolean convertToStandardFilePlan = false; - - /** - * @param qnameDAO QName DAO - */ - public void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - /** - * @param convertToStandardFilePlan convert to standard file if true, false otherwise - */ - public void setConvertToStandardFilePlan(boolean convertToStandardFilePlan) - { - this.convertToStandardFilePlan = convertToStandardFilePlan; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - if (!convertToStandardFilePlan) - { - // ensure all existing sites are of the correct type - if (qnameDAO.getQName(RecordsManagementModel.TYPE_RM_SITE) != null && - qnameDAO.getQName(DOD5015Model.TYPE_DOD_5015_SITE) == null) - { - qnameDAO.updateQName(RecordsManagementModel.TYPE_RM_SITE, DOD5015Model.TYPE_DOD_5015_SITE); - } - - // ensure all the existing file plans are of the correct type - if (qnameDAO.getQName(RecordsManagementModel.TYPE_FILE_PLAN) != null && - qnameDAO.getQName(DOD5015Model.TYPE_DOD_5015_FILE_PLAN) == null) - { - qnameDAO.updateQName(RecordsManagementModel.TYPE_FILE_PLAN, DOD5015Model.TYPE_DOD_5015_FILE_PLAN); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.repo.domain.qname.QNameDAO; + +/** + * DOD compliant site patch. + * + * Makes all existing sites of type dod:site to preserve their DOD compliance status. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22DODCompliantSitePatch extends AbstractModulePatch + implements RecordsManagementModel +{ + /** QName DAO */ + private QNameDAO qnameDAO; + + /** indicates whether we convert to a standard file plan or not */ + private boolean convertToStandardFilePlan = false; + + /** + * @param qnameDAO QName DAO + */ + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * @param convertToStandardFilePlan convert to standard file if true, false otherwise + */ + public void setConvertToStandardFilePlan(boolean convertToStandardFilePlan) + { + this.convertToStandardFilePlan = convertToStandardFilePlan; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + if (!convertToStandardFilePlan) + { + // ensure all existing sites are of the correct type + if (qnameDAO.getQName(RecordsManagementModel.TYPE_RM_SITE) != null && + qnameDAO.getQName(DOD5015Model.TYPE_DOD_5015_SITE) == null) + { + qnameDAO.updateQName(RecordsManagementModel.TYPE_RM_SITE, DOD5015Model.TYPE_DOD_5015_SITE); + } + + // ensure all the existing file plans are of the correct type + if (qnameDAO.getQName(RecordsManagementModel.TYPE_FILE_PLAN) != null && + qnameDAO.getQName(DOD5015Model.TYPE_DOD_5015_FILE_PLAN) == null) + { + qnameDAO.updateQName(RecordsManagementModel.TYPE_FILE_PLAN, DOD5015Model.TYPE_DOD_5015_FILE_PLAN); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODModelSeparationModulePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODModelSeparationModulePatch.java index b2b0296f37..b10e6e105d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODModelSeparationModulePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22DODModelSeparationModulePatch.java @@ -1,168 +1,168 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.repo.domain.node.NodeDAO; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * DOD model separation module patch implementation - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22DODModelSeparationModulePatch extends AbstractModulePatch - implements RecordsManagementModel -{ - /** query batch size */ - private static final long BATCH_SIZE = 100000L; - - /** indicates whether we convert to a standard file plan or not */ - private boolean convertToStandardFilePlan = false; - - /** Patch DAO */ - private PatchDAO patchDAO; - - /** Node DAO */ - private NodeDAO nodeDAO; - - /** qnames to update (switch to dod namespace) */ - private QName[] qnames = - { - DOD5015Model.PROP_ORIGINATOR, - DOD5015Model.PROP_ORIGINATING_ORGANIZATION, - DOD5015Model.PROP_PUBLICATION_DATE, - DOD5015Model.PROP_MEDIA_TYPE, - DOD5015Model.PROP_FORMAT, - DOD5015Model.PROP_DATE_RECEIVED, - DOD5015Model.PROP_ADDRESS, - DOD5015Model.PROP_OTHER_ADDRESS - }; - - /** - * @param convertToStandardFilePlan convert to standard file if true, false otherwise - */ - public void setConvertToStandardFilePlan(boolean convertToStandardFilePlan) - { - this.convertToStandardFilePlan = convertToStandardFilePlan; - } - - /** - * @param patchDAO patch DAO - */ - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - /** - * @param nodeDAO node DAO - */ - public void setNodeDAO(NodeDAO nodeDAO) - { - this.nodeDAO = nodeDAO; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - if (!convertToStandardFilePlan) - { - Long maxNodeId = patchDAO.getMaxAdmNodeID(); - long recordCount = patchDAO.getCountNodesWithAspects(Collections.singleton(ASPECT_RECORD)); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... updating " + recordCount + " records in batches of " + BATCH_SIZE); - } - - // apply the DOD record aspect to all exiting records - int completed = 0; - for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE) - { - final Long finali = i; - Integer batchCount = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - int batchCount = 0; - - public Integer execute() throws Throwable - { - nodeDAO.getNodesWithAspects(Collections.singleton(ASPECT_RECORD), finali, finali + BATCH_SIZE, new NodeDAO.NodeRefQueryCallback() - { - public boolean handle(Pair nodePair) - { - // get the records properties - Map properties = nodeDAO.getNodeProperties(nodePair.getFirst()); - boolean changed = false; - - for (QName qname : qnames) - { - // if the record has any of the moved properties - QName origional = QName.createQName(RecordsManagementModel.RM_URI, qname.getLocalName()); - if (properties.containsKey(origional)) - { - // move the property value - Serializable value = properties.get(origional); - properties.put(qname, value); - properties.remove(origional); - changed = true; - } - } - - // set properties and add aspect - if (changed) - { - nodeDAO.setNodeProperties(nodePair.getFirst(), properties); - } - nodeDAO.addNodeAspects(nodePair.getFirst(), Collections.singleton(DOD5015Model.ASPECT_DOD_5015_RECORD)); - batchCount ++; - - return true; - } - }); - - return batchCount; - } - } , false, true); - - if (batchCount != 0) - { - completed = completed + batchCount; - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(" ... completed " + completed + " of " + recordCount); - } - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.patch.PatchDAO; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; + +/** + * DOD model separation module patch implementation + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22DODModelSeparationModulePatch extends AbstractModulePatch + implements RecordsManagementModel +{ + /** query batch size */ + private static final long BATCH_SIZE = 100000L; + + /** indicates whether we convert to a standard file plan or not */ + private boolean convertToStandardFilePlan = false; + + /** Patch DAO */ + private PatchDAO patchDAO; + + /** Node DAO */ + private NodeDAO nodeDAO; + + /** qnames to update (switch to dod namespace) */ + private QName[] qnames = + { + DOD5015Model.PROP_ORIGINATOR, + DOD5015Model.PROP_ORIGINATING_ORGANIZATION, + DOD5015Model.PROP_PUBLICATION_DATE, + DOD5015Model.PROP_MEDIA_TYPE, + DOD5015Model.PROP_FORMAT, + DOD5015Model.PROP_DATE_RECEIVED, + DOD5015Model.PROP_ADDRESS, + DOD5015Model.PROP_OTHER_ADDRESS + }; + + /** + * @param convertToStandardFilePlan convert to standard file if true, false otherwise + */ + public void setConvertToStandardFilePlan(boolean convertToStandardFilePlan) + { + this.convertToStandardFilePlan = convertToStandardFilePlan; + } + + /** + * @param patchDAO patch DAO + */ + public void setPatchDAO(PatchDAO patchDAO) + { + this.patchDAO = patchDAO; + } + + /** + * @param nodeDAO node DAO + */ + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + if (!convertToStandardFilePlan) + { + Long maxNodeId = patchDAO.getMaxAdmNodeID(); + long recordCount = patchDAO.getCountNodesWithAspects(Collections.singleton(ASPECT_RECORD)); + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... updating " + recordCount + " records in batches of " + BATCH_SIZE); + } + + // apply the DOD record aspect to all exiting records + int completed = 0; + for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE) + { + final Long finali = i; + Integer batchCount = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() + { + int batchCount = 0; + + public Integer execute() throws Throwable + { + nodeDAO.getNodesWithAspects(Collections.singleton(ASPECT_RECORD), finali, finali + BATCH_SIZE, new NodeDAO.NodeRefQueryCallback() + { + public boolean handle(Pair nodePair) + { + // get the records properties + Map properties = nodeDAO.getNodeProperties(nodePair.getFirst()); + boolean changed = false; + + for (QName qname : qnames) + { + // if the record has any of the moved properties + QName origional = QName.createQName(RecordsManagementModel.RM_URI, qname.getLocalName()); + if (properties.containsKey(origional)) + { + // move the property value + Serializable value = properties.get(origional); + properties.put(qname, value); + properties.remove(origional); + changed = true; + } + } + + // set properties and add aspect + if (changed) + { + nodeDAO.setNodeProperties(nodePair.getFirst(), properties); + } + nodeDAO.addNodeAspects(nodePair.getFirst(), Collections.singleton(DOD5015Model.ASPECT_DOD_5015_RECORD)); + batchCount ++; + + return true; + } + }); + + return batchCount; + } + } , false, true); + + if (batchCount != 0) + { + completed = completed + batchCount; + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug(" ... completed " + completed + " of " + recordCount); + } + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22FileHoldReportCapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22FileHoldReportCapabilityPatch.java index c77fb4a6b1..99513c7ef0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22FileHoldReportCapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22FileHoldReportCapabilityPatch.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * RM v2.2 patch to add FileHoldReport capability. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22FileHoldReportCapabilityPatch extends CapabilityPatch -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) - */ - protected void applyCapabilityPatch(NodeRef filePlan) - { - // add new capability - addCapability(filePlan, - "FileHoldReport", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * RM v2.2 patch to add FileHoldReport capability. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22FileHoldReportCapabilityPatch extends CapabilityPatch +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) + */ + protected void applyCapabilityPatch(NodeRef filePlan) + { + // add new capability + addCapability(filePlan, + "FileHoldReport", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22GhostOnDestroyDispositionActionPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22GhostOnDestroyDispositionActionPatch.java index f7712c97e3..dd560f84cd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22GhostOnDestroyDispositionActionPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22GhostOnDestroyDispositionActionPatch.java @@ -1,180 +1,180 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Sets the ghost on destroy property for existing destroy disposition actions - * to the value specified in the global properties file - * - * @author Mark Hibbins - * @since 2.2 - */ -public class RMv22GhostOnDestroyDispositionActionPatch extends AbstractModulePatch -{ - /** Disposition service */ - private DispositionService dispositionService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Node service */ - private NodeService nodeService; - - /** Ghost on destroy setting */ - private boolean ghostingEnabled; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param nodeService file plan service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param ghostingEnabled Ghost on destroy setting from - * alfresco-global.properties - */ - public void setGhostingEnabled(boolean ghostingEnabled) - { - this.ghostingEnabled = ghostingEnabled; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - Set filePlans = filePlanService.getFilePlans(); - for (NodeRef filePlan : filePlans) - { - processFilePlan(filePlan); - } - } - - /** - * Apply the patch to each file plan - * - * @param filePlan - */ - private void processFilePlan(NodeRef filePlan) - { - Set dispositionSchedules = new HashSet(); - getDispositionSchedules(filePlan, dispositionSchedules); - for (DispositionSchedule dispositionSchedule : dispositionSchedules) - { - processDispositionSchedule(dispositionSchedule); - } - } - - /** - * Add the disposition schedule associated with the node ref to the passed - * set of disposition schedule then call this method recursively for this - * node's children - * - * @param nodeRef - * @param dispositionSchedules - */ - private void getDispositionSchedules(NodeRef nodeRef, Set dispositionSchedules) - { - if (filePlanService.isRecordCategory(nodeRef)) - { - DispositionSchedule dispositionSchedule = this.dispositionService.getDispositionSchedule(nodeRef); - if (dispositionSchedule != null) - { - dispositionSchedules.add(dispositionSchedule); - } - - List children = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef childAssoc : children) - { - getDispositionSchedules(childAssoc.getChildRef(), dispositionSchedules); - } - } - } - - /** - * Patch the specified disposition schedule. To do this add the host on - * destroy to any action definition that doesn't already have it defined and - * set the value to the value set in the global properties file. Leave any - * action definitions that have this property already defined untouched. - * - * @param dispositionSchedule - */ - private void processDispositionSchedule(DispositionSchedule dispositionSchedule) - { - List actionDefinitions = dispositionSchedule.getDispositionActionDefinitions(); - for(DispositionActionDefinition actionDefinition : actionDefinitions) - { - String actionName = (String) nodeService.getProperty(actionDefinition.getNodeRef(), - RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME); - if ("destroy".equals(actionName)) - { - // we only want to add the ghost on destroy property to action - // definitions that do not already have it defined - String ghostOnDestroyValue = (String) nodeService.getProperty(actionDefinition.getNodeRef(), - RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY); - if (ghostOnDestroyValue == null) - { - Map props = new HashMap(1); - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, - this.ghostingEnabled ? "ghost" : "destroy"); - this.dispositionService.updateDispositionActionDefinition(actionDefinition, props); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Sets the ghost on destroy property for existing destroy disposition actions + * to the value specified in the global properties file + * + * @author Mark Hibbins + * @since 2.2 + */ +public class RMv22GhostOnDestroyDispositionActionPatch extends AbstractModulePatch +{ + /** Disposition service */ + private DispositionService dispositionService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Node service */ + private NodeService nodeService; + + /** Ghost on destroy setting */ + private boolean ghostingEnabled; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param nodeService file plan service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param ghostingEnabled Ghost on destroy setting from + * alfresco-global.properties + */ + public void setGhostingEnabled(boolean ghostingEnabled) + { + this.ghostingEnabled = ghostingEnabled; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + Set filePlans = filePlanService.getFilePlans(); + for (NodeRef filePlan : filePlans) + { + processFilePlan(filePlan); + } + } + + /** + * Apply the patch to each file plan + * + * @param filePlan + */ + private void processFilePlan(NodeRef filePlan) + { + Set dispositionSchedules = new HashSet(); + getDispositionSchedules(filePlan, dispositionSchedules); + for (DispositionSchedule dispositionSchedule : dispositionSchedules) + { + processDispositionSchedule(dispositionSchedule); + } + } + + /** + * Add the disposition schedule associated with the node ref to the passed + * set of disposition schedule then call this method recursively for this + * node's children + * + * @param nodeRef + * @param dispositionSchedules + */ + private void getDispositionSchedules(NodeRef nodeRef, Set dispositionSchedules) + { + if (filePlanService.isRecordCategory(nodeRef)) + { + DispositionSchedule dispositionSchedule = this.dispositionService.getDispositionSchedule(nodeRef); + if (dispositionSchedule != null) + { + dispositionSchedules.add(dispositionSchedule); + } + + List children = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef childAssoc : children) + { + getDispositionSchedules(childAssoc.getChildRef(), dispositionSchedules); + } + } + } + + /** + * Patch the specified disposition schedule. To do this add the host on + * destroy to any action definition that doesn't already have it defined and + * set the value to the value set in the global properties file. Leave any + * action definitions that have this property already defined untouched. + * + * @param dispositionSchedule + */ + private void processDispositionSchedule(DispositionSchedule dispositionSchedule) + { + List actionDefinitions = dispositionSchedule.getDispositionActionDefinitions(); + for(DispositionActionDefinition actionDefinition : actionDefinitions) + { + String actionName = (String) nodeService.getProperty(actionDefinition.getNodeRef(), + RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME); + if ("destroy".equals(actionName)) + { + // we only want to add the ghost on destroy property to action + // definitions that do not already have it defined + String ghostOnDestroyValue = (String) nodeService.getProperty(actionDefinition.getNodeRef(), + RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY); + if (ghostOnDestroyValue == null) + { + Map props = new HashMap(1); + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, + this.ghostingEnabled ? "ghost" : "destroy"); + this.dispositionService.updateDispositionActionDefinition(actionDefinition, props); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java index a3967cc1c5..79b9af1cb0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * RM v2.2 patch to update capabilities. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22HoldCapabilityPatch extends CapabilityPatch -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) - */ - protected void applyCapabilityPatch(NodeRef filePlan) - { - // add new capability - addCapability(filePlan, - "DeleteHold", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - addCapability(filePlan, - "EditHold", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * RM v2.2 patch to update capabilities. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22HoldCapabilityPatch extends CapabilityPatch +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) + */ + protected void applyCapabilityPatch(NodeRef filePlan) + { + // add new capability + addCapability(filePlan, + "DeleteHold", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + addCapability(filePlan, + "EditHold", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldReportPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldReportPatch.java index c3087ce1d9..96114d0539 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldReportPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldReportPatch.java @@ -1,109 +1,109 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Adds the hold report. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22HoldReportPatch extends AbstractModulePatch -{ - /** Report template path */ - private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl"; - - /** Report template config node IDs */ - private static final NodeRef REPORT_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); - private static final NodeRef REPORT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rmr_holdReport"); - - /** Node service */ - private NodeService nodeService; - - /** Content service */ - private ContentService contentService; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - if (!nodeService.exists(REPORT)) - { - // get the assoc qname - QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_holdReport.html.ftl")); - - // build the node properties - Map props = new HashMap(4); - props.put(ContentModel.PROP_DESCRIPTION, "Hold report template."); - props.put(ContentModel.PROP_TITLE, "Hold Report Template"); - props.put(ContentModel.PROP_NAME, "report_rmr_holdReport.html.ftl"); - props.put(ContentModel.PROP_NODE_UUID, "rmr_holdReport"); - - // create the node - ChildAssociationRef node = nodeService.createNode( - REPORT_FOLDER, - ContentModel.ASSOC_CONTAINS, - assocQName, - ContentModel.TYPE_CONTENT, - props); - - // put the content - ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH); - writer.putContent(is); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Adds the hold report. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22HoldReportPatch extends AbstractModulePatch +{ + /** Report template path */ + private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl"; + + /** Report template config node IDs */ + private static final NodeRef REPORT_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); + private static final NodeRef REPORT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rmr_holdReport"); + + /** Node service */ + private NodeService nodeService; + + /** Content service */ + private ContentService contentService; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + if (!nodeService.exists(REPORT)) + { + // get the assoc qname + QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_holdReport.html.ftl")); + + // build the node properties + Map props = new HashMap(4); + props.put(ContentModel.PROP_DESCRIPTION, "Hold report template."); + props.put(ContentModel.PROP_TITLE, "Hold Report Template"); + props.put(ContentModel.PROP_NAME, "report_rmr_holdReport.html.ftl"); + props.put(ContentModel.PROP_NODE_UUID, "rmr_holdReport"); + + // create the node + ChildAssociationRef node = nodeService.createNode( + REPORT_FOLDER, + ContentModel.ASSOC_CONTAINS, + assocQName, + ContentModel.TYPE_CONTENT, + props); + + // put the content + ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH); + writer.putContent(is); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatch.java index 61be509bd5..65a4e1b423 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatch.java @@ -1,97 +1,97 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AuthorityService; - -/** - * Removes the in-place groups from the all roles group. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22RemoveInPlaceRolesFromAllPatch extends AbstractModulePatch -{ - /** file plan service */ - private FilePlanService filePlanService; - - /** file plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** authority service */ - private AuthorityService authorityService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - // get all file plans - Set filePlans = filePlanService.getFilePlans(); - for (NodeRef filePlan : filePlans) - { - Role extendedReaders = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); - Role extendedWriters = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - - // remove extended readers and writers roles from the all roles group - String allRolesGroup = filePlanRoleService.getAllRolesContainerGroup(filePlan); - Set members = authorityService.getContainedAuthorities(null, allRolesGroup, true); - if (members.contains(extendedReaders.getRoleGroupName())) - { - authorityService.removeAuthority(allRolesGroup, extendedReaders.getRoleGroupName()); - } - if (members.contains(extendedWriters.getRoleGroupName())) - { - authorityService.removeAuthority(allRolesGroup, extendedWriters.getRoleGroupName()); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityService; + +/** + * Removes the in-place groups from the all roles group. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22RemoveInPlaceRolesFromAllPatch extends AbstractModulePatch +{ + /** file plan service */ + private FilePlanService filePlanService; + + /** file plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** authority service */ + private AuthorityService authorityService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + // get all file plans + Set filePlans = filePlanService.getFilePlans(); + for (NodeRef filePlan : filePlans) + { + Role extendedReaders = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); + Role extendedWriters = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); + + // remove extended readers and writers roles from the all roles group + String allRolesGroup = filePlanRoleService.getAllRolesContainerGroup(filePlan); + Set members = authorityService.getContainedAuthorities(null, allRolesGroup, true); + if (members.contains(extendedReaders.getRoleGroupName())) + { + authorityService.removeAuthority(allRolesGroup, extendedReaders.getRoleGroupName()); + } + if (members.contains(extendedWriters.getRoleGroupName())) + { + authorityService.removeAuthority(allRolesGroup, extendedWriters.getRoleGroupName()); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22ReportTemplatePatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22ReportTemplatePatch.java index 679d8aa35c..2a9235c28b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22ReportTemplatePatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22ReportTemplatePatch.java @@ -1,112 +1,112 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Adds a new transfer/accession report template to the existing report templates - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class RMv22ReportTemplatePatch extends AbstractModulePatch -{ - /** Report template path */ - private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl"; - - /** Report template config node IDs */ - private static final String TRANSFER_REPORT = "rmr_transferReport"; - private static final String DESTRUCTION_REPORT = "rmr_destructionReport"; - - /** Node service */ - private NodeService nodeService; - - /** Content service */ - private ContentService contentService; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - NodeRef transferReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, TRANSFER_REPORT); - NodeRef destructionReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DESTRUCTION_REPORT); - if (!nodeService.exists(transferReport) && nodeService.exists(destructionReport)) - { - NodeRef parent = nodeService.getPrimaryParent(destructionReport).getParentRef(); - - // get the assoc qname - QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_transferReport.html.ftl")); - - // build the node properties - Map props = new HashMap(4); - props.put(ContentModel.PROP_DESCRIPTION, "Transfer report template."); - props.put(ContentModel.PROP_TITLE, "Transfer Report Template"); - props.put(ContentModel.PROP_NAME, "report_rmr_transferReport.html.ftl"); - props.put(ContentModel.PROP_NODE_UUID, "rmr_transferReport"); - - // create the node - ChildAssociationRef node = nodeService.createNode(parent, - ContentModel.ASSOC_CONTAINS, - assocQName, - ContentModel.TYPE_CONTENT, - props); - - // put the content - ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); - InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(is); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Adds a new transfer/accession report template to the existing report templates + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class RMv22ReportTemplatePatch extends AbstractModulePatch +{ + /** Report template path */ + private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl"; + + /** Report template config node IDs */ + private static final String TRANSFER_REPORT = "rmr_transferReport"; + private static final String DESTRUCTION_REPORT = "rmr_destructionReport"; + + /** Node service */ + private NodeService nodeService; + + /** Content service */ + private ContentService contentService; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + NodeRef transferReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, TRANSFER_REPORT); + NodeRef destructionReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DESTRUCTION_REPORT); + if (!nodeService.exists(transferReport) && nodeService.exists(destructionReport)) + { + NodeRef parent = nodeService.getPrimaryParent(destructionReport).getParentRef(); + + // get the assoc qname + QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_transferReport.html.ftl")); + + // build the node properties + Map props = new HashMap(4); + props.put(ContentModel.PROP_DESCRIPTION, "Transfer report template."); + props.put(ContentModel.PROP_TITLE, "Transfer Report Template"); + props.put(ContentModel.PROP_NAME, "report_rmr_transferReport.html.ftl"); + props.put(ContentModel.PROP_NODE_UUID, "rmr_transferReport"); + + // create the node + ChildAssociationRef node = nodeService.createNode(parent, + ContentModel.ASSOC_CONTAINS, + assocQName, + ContentModel.TYPE_CONTENT, + props); + + // put the content + ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true); + InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent(is); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23EndRetentionCapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23EndRetentionCapabilityPatch.java index 9fe8ee707b..f34c48922e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23EndRetentionCapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23EndRetentionCapabilityPatch.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v23; - -import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * RM v2.3 patch to add new end retention capability. - * - * @author Alex Balan - * @since 2.3 - */ -public class RMv23EndRetentionCapabilityPatch extends CapabilityPatch -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) - */ - protected void applyCapabilityPatch(NodeRef filePlan) - { - // add new capability - addCapability(filePlan, - "EndRetention", - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v23; + +import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * RM v2.3 patch to add new end retention capability. + * + * @author Alex Balan + * @since 2.3 + */ +public class RMv23EndRetentionCapabilityPatch extends CapabilityPatch +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef) + */ + protected void applyCapabilityPatch(NodeRef filePlan) + { + // add new capability + addCapability(filePlan, + "EndRetention", + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23RecordContributorsGroupPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23RecordContributorsGroupPatch.java index ab9d387b53..61d8be5ad6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23RecordContributorsGroupPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23RecordContributorsGroupPatch.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v23; - -import org.alfresco.module.org_alfresco_module_rm.bootstrap.RecordContributorsGroupBootstrapComponent; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; - -/** - * RM v2.3 patch that creates the record contributors group. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RMv23RecordContributorsGroupPatch extends AbstractModulePatch -{ - /** record contributors group bootstrap component */ - private RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent; - - /** - * @param recordContributorsGroupBootstrapComponent record contributors group bootstrap component - */ - public void setRecordContributorsGroupBootstrapComponent(RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent) - { - this.recordContributorsGroupBootstrapComponent = recordContributorsGroupBootstrapComponent; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - // create record contributors group - recordContributorsGroupBootstrapComponent.createRecordContributorsGroup(); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v23; + +import org.alfresco.module.org_alfresco_module_rm.bootstrap.RecordContributorsGroupBootstrapComponent; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; + +/** + * RM v2.3 patch that creates the record contributors group. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RMv23RecordContributorsGroupPatch extends AbstractModulePatch +{ + /** record contributors group bootstrap component */ + private RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent; + + /** + * @param recordContributorsGroupBootstrapComponent record contributors group bootstrap component + */ + public void setRecordContributorsGroupBootstrapComponent(RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent) + { + this.recordContributorsGroupBootstrapComponent = recordContributorsGroupBootstrapComponent; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + // create record contributors group + recordContributorsGroupBootstrapComponent.createRecordContributorsGroup(); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23VersionsEventPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23VersionsEventPatch.java index 696183e5ac..89ce2c43bc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23VersionsEventPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v23/RMv23VersionsEventPatch.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v23; - -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * RM v2.3 patch that creates the versions event. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RMv23VersionsEventPatch extends AbstractModulePatch -{ - /** event details */ - private static final String EVENT_TYPE = "rmEventType.versioned"; - private static final String EVENT_NAME = "versioned"; - private static final String EVENT_I18N = "rmevent.versioned"; - - /** records management event service */ - private RecordsManagementEventService recordsManagementEventService; - - /** - * @param recordsManagementEventService records management event service - */ - public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) - { - this.recordsManagementEventService = recordsManagementEventService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - // add versions event - recordsManagementEventService.addEvent(EVENT_TYPE, EVENT_NAME, I18NUtil.getMessage(EVENT_I18N)); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v23; + +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * RM v2.3 patch that creates the versions event. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RMv23VersionsEventPatch extends AbstractModulePatch +{ + /** event details */ + private static final String EVENT_TYPE = "rmEventType.versioned"; + private static final String EVENT_NAME = "versioned"; + private static final String EVENT_I18N = "rmevent.versioned"; + + /** records management event service */ + private RecordsManagementEventService recordsManagementEventService; + + /** + * @param recordsManagementEventService records management event service + */ + public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) + { + this.recordsManagementEventService = recordsManagementEventService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() + */ + @Override + public void applyInternal() + { + // add versions event + recordsManagementEventService.addEvent(EVENT_TYPE, EVENT_NAME, I18NUtil.getMessage(EVENT_I18N)); + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index 0b080c8d0f..357fbec661 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.query; - -/** - * Records management query DAO - * - * NOTE: a place holder that can be extended later when we want to enhance performance with canned queries. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordsManagementQueryDAO -{ - /** - * Get the number of objects with the given identifier value. - * - * Note: this is provided as an example and is not currently used - * - * @param identifierValue id value - * @return int count - */ - int getCountRmaIdentifier(String identifierValue); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.query; + +/** + * Records management query DAO + * + * NOTE: a place holder that can be extended later when we want to enhance performance with canned queries. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordsManagementQueryDAO +{ + /** + * Get the number of objects with the given identifier value. + * + * Note: this is provided as an example and is not currently used + * + * @param identifierValue id value + * @return int count + */ + int getCountRmaIdentifier(String identifierValue); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index fa635d8036..82c6af4134 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -1,91 +1,91 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.query; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.domain.qname.QNameDAO; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * Records management query DAO implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel -{ - private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; - - /** SQL session template */ - protected SqlSessionTemplate template; - - /** QName DAO */ - protected QNameDAO qnameDAO; - - /** - * @param sqlSessionTemplate SQL session template - */ - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - /** - * @param qnameDAO qname DAO - */ - public final void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getCountRmaIdentifier(java.lang.String) - */ - @Override - public int getCountRmaIdentifier(String identifierValue) - { - int result = 0; - - // lookup the id of the identifier property qname - Pair pair = qnameDAO.getQName(PROP_IDENTIFIER); - if (pair != null) - { - // create query params - Map params = new HashMap(2); - params.put("qnameId", pair.getFirst()); - params.put("idValue", identifierValue); - - // return the number of rma identifiers found that match the passed value - Integer count = (Integer)template.selectOne(COUNT_IDENTIFIER, params); - - if (count != null) - { - result = count; - } - } - - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.query; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.mybatis.spring.SqlSessionTemplate; + +/** + * Records management query DAO implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel +{ + private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; + + /** SQL session template */ + protected SqlSessionTemplate template; + + /** QName DAO */ + protected QNameDAO qnameDAO; + + /** + * @param sqlSessionTemplate SQL session template + */ + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) + { + this.template = sqlSessionTemplate; + } + + /** + * @param qnameDAO qname DAO + */ + public final void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getCountRmaIdentifier(java.lang.String) + */ + @Override + public int getCountRmaIdentifier(String identifierValue) + { + int result = 0; + + // lookup the id of the identifier property qname + Pair pair = qnameDAO.getQName(PROP_IDENTIFIER); + if (pair != null) + { + // create query params + Map params = new HashMap(2); + params.put("qnameId", pair.getFirst()); + params.put("idValue", identifierValue); + + // return the number of rma identifiers found that match the passed value + Integer count = (Integer)template.selectOne(COUNT_IDENTIFIER, params); + + if (count != null) + { + result = count; + } + } + + return result; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordService.java index a3c27c465e..40af6a4aa7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordService.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Inplace Record Service Interface. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public interface InplaceRecordService -{ - /** - * Hides a record within a collaboration site - * - * @param nodeRef The record which should be hidden - */ - void hideRecord(NodeRef nodeRef); - - /** - * Moves a record within a collaboration site - * - * @param nodeRef The record which should be moved - * @param targetNodeRef The target node reference where it should be moved to - */ - void moveRecord(NodeRef nodeRef, NodeRef targetNodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Inplace Record Service Interface. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public interface InplaceRecordService +{ + /** + * Hides a record within a collaboration site + * + * @param nodeRef The record which should be hidden + */ + void hideRecord(NodeRef nodeRef); + + /** + * Moves a record within a collaboration site + * + * @param nodeRef The record which should be moved + * @param targetNodeRef The target node reference where it should be moved to + */ + void moveRecord(NodeRef nodeRef, NodeRef targetNodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java index 8132f465f7..49443babd3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java @@ -1,185 +1,185 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import static org.alfresco.model.ContentModel.ASPECT_PENDING_DELETE; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.util.ParameterCheck; - -/** - * Inplace record service implementation. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class InplaceRecordServiceImpl extends ServiceBaseImpl implements InplaceRecordService, RecordsManagementModel -{ - /** Site service */ - private SiteService siteService; - - /** Extended security service */ - private ExtendedSecurityService extendedSecurityService; - - /** File folder service */ - private FileFolderService fileFolderService; - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param extendedSecurityService extended security service - */ - public void setExtendedSecurityService( - ExtendedSecurityService extendedSecurityService) - { - this.extendedSecurityService = extendedSecurityService; - } - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#hideRecord(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void hideRecord(final NodeRef nodeRef) - { - ParameterCheck.mandatory("NodeRef", nodeRef); - - // do the work of hiding the record as the system user - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - // remove the child association - NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION); - - if (originatingLocation != null) - { - List parentAssocs = nodeService.getParentAssocs(nodeRef); - for (ChildAssociationRef childAssociationRef : parentAssocs) - { - if (!childAssociationRef.isPrimary() && - childAssociationRef.getParentRef().equals(originatingLocation) && - !nodeService.hasAspect(childAssociationRef.getChildRef(), ASPECT_PENDING_DELETE)) - { - nodeService.removeChildAssociation(childAssociationRef); - break; - } - } - - // remove the extended security from the node - // this prevents the users from continuing to see the record in searchs and other linked locations - extendedSecurityService.remove(nodeRef); - } - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("targetNodeRef", targetNodeRef); - - NodeRef sourceParentNodeRef = null; - - NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION); - for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef)) - { - if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation)) - { - sourceParentNodeRef = parentAssoc.getParentRef(); - break; - } - } - - if (sourceParentNodeRef == null) - { - throw new AlfrescoRuntimeException("Could not find source parent node reference."); - } - - SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef); - SiteInfo targetSite = siteService.getSite(targetNodeRef); - - if (!sourceSite.equals(targetSite)) - { - throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site."); - } - - if (!sourceSite.getSitePreset().equals("site-dashboard")) - { - throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved."); - } - - final NodeRef source = sourceParentNodeRef; - - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - try - { - // Move the record - fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null); - - // Update the originating location property - nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef); - } - catch (FileExistsException | FileNotFoundException ex) - { - throw new AlfrescoRuntimeException("Can't move node: " + ex); - } - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import static org.alfresco.model.ContentModel.ASPECT_PENDING_DELETE; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.model.FileExistsException; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.model.FileNotFoundException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.util.ParameterCheck; + +/** + * Inplace record service implementation. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class InplaceRecordServiceImpl extends ServiceBaseImpl implements InplaceRecordService, RecordsManagementModel +{ + /** Site service */ + private SiteService siteService; + + /** Extended security service */ + private ExtendedSecurityService extendedSecurityService; + + /** File folder service */ + private FileFolderService fileFolderService; + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param extendedSecurityService extended security service + */ + public void setExtendedSecurityService( + ExtendedSecurityService extendedSecurityService) + { + this.extendedSecurityService = extendedSecurityService; + } + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#hideRecord(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void hideRecord(final NodeRef nodeRef) + { + ParameterCheck.mandatory("NodeRef", nodeRef); + + // do the work of hiding the record as the system user + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // remove the child association + NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION); + + if (originatingLocation != null) + { + List parentAssocs = nodeService.getParentAssocs(nodeRef); + for (ChildAssociationRef childAssociationRef : parentAssocs) + { + if (!childAssociationRef.isPrimary() && + childAssociationRef.getParentRef().equals(originatingLocation) && + !nodeService.hasAspect(childAssociationRef.getChildRef(), ASPECT_PENDING_DELETE)) + { + nodeService.removeChildAssociation(childAssociationRef); + break; + } + } + + // remove the extended security from the node + // this prevents the users from continuing to see the record in searchs and other linked locations + extendedSecurityService.remove(nodeRef); + } + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("targetNodeRef", targetNodeRef); + + NodeRef sourceParentNodeRef = null; + + NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION); + for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef)) + { + if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation)) + { + sourceParentNodeRef = parentAssoc.getParentRef(); + break; + } + } + + if (sourceParentNodeRef == null) + { + throw new AlfrescoRuntimeException("Could not find source parent node reference."); + } + + SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef); + SiteInfo targetSite = siteService.getSite(targetNodeRef); + + if (!sourceSite.equals(targetSite)) + { + throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site."); + } + + if (!sourceSite.getSitePreset().equals("site-dashboard")) + { + throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved."); + } + + final NodeRef source = sourceParentNodeRef; + + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + try + { + // Move the record + fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null); + + // Update the originating location property + nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef); + } + catch (FileExistsException | FileNotFoundException ex) + { + throw new AlfrescoRuntimeException("Can't move node: " + ex); + } + + return null; + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordLinkRuntimeException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordLinkRuntimeException.java index b114543715..04cb1552f2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordLinkRuntimeException.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordLinkRuntimeException.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import org.alfresco.error.AlfrescoRuntimeException; - - -/** - * Record link exception class - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordLinkRuntimeException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = 5202539484220535897L; - - public RecordLinkRuntimeException(String msgId, Throwable cause) - { - super(msgId, cause); - } - - public RecordLinkRuntimeException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - } - - public RecordLinkRuntimeException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - } - - public RecordLinkRuntimeException(String msgId) - { - super(msgId); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import org.alfresco.error.AlfrescoRuntimeException; + + +/** + * Record link exception class + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordLinkRuntimeException extends AlfrescoRuntimeException +{ + private static final long serialVersionUID = 5202539484220535897L; + + public RecordLinkRuntimeException(String msgId, Throwable cause) + { + super(msgId, cause); + } + + public RecordLinkRuntimeException(String msgId, Object[] msgParams, Throwable cause) + { + super(msgId, msgParams, cause); + } + + public RecordLinkRuntimeException(String msgId, Object[] msgParams) + { + super(msgId, msgParams); + } + + public RecordLinkRuntimeException(String msgId) + { + super(msgId); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrap.java index 14e01ca84e..799079bffe 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrap.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import java.util.Map; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; - -/** - * Record metadata bootstrap bean. - *

- * This method of bootstrapping record metadata aspects into the RecordService deprecates the - * previous practice of extending rma:recordMetaData. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RecordMetadataBootstrap -{ - /** record service */ - private RecordService recordService; - - /** namespace service */ - private NamespaceService namespaceService; - - /** map of record metadata aspects against file plan type */ - private Map recordMetadataAspects; - - /** - * @param recordMetadataAspects map of record metadata aspects against file plan types - */ - public void setRecordMetadataAspects(Map recordMetadataAspects) - { - this.recordMetadataAspects = recordMetadataAspects; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * Init method - */ - public void init() - { - ParameterCheck.mandatory("recordService", recordService); - ParameterCheck.mandatory("namespaceService", namespaceService); - - if (recordMetadataAspects != null) - { - for (Map.Entry entry : recordMetadataAspects.entrySet()) - { - // convert to qname's - QName recordMetadataAspect = QName.createQName(entry.getKey(), namespaceService); - QName filePlanType = QName.createQName(entry.getValue(), namespaceService); - - // register with record service - recordService.registerRecordMetadataAspect(recordMetadataAspect, filePlanType); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import java.util.Map; + +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; + +/** + * Record metadata bootstrap bean. + *

+ * This method of bootstrapping record metadata aspects into the RecordService deprecates the + * previous practice of extending rma:recordMetaData. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RecordMetadataBootstrap +{ + /** record service */ + private RecordService recordService; + + /** namespace service */ + private NamespaceService namespaceService; + + /** map of record metadata aspects against file plan type */ + private Map recordMetadataAspects; + + /** + * @param recordMetadataAspects map of record metadata aspects against file plan types + */ + public void setRecordMetadataAspects(Map recordMetadataAspects) + { + this.recordMetadataAspects = recordMetadataAspects; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * Init method + */ + public void init() + { + ParameterCheck.mandatory("recordService", recordService); + ParameterCheck.mandatory("namespaceService", namespaceService); + + if (recordMetadataAspects != null) + { + for (Map.Entry entry : recordMetadataAspects.entrySet()) + { + // convert to qname's + QName recordMetadataAspect = QName.createQName(entry.getKey(), namespaceService); + QName filePlanType = QName.createQName(entry.getValue(), namespaceService); + + // register with record service + recordService.registerRecordMetadataAspect(recordMetadataAspect, filePlanType); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java index 9b33b71687..9b20f07050 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java @@ -1,271 +1,271 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.record; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Record Service Interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordService -{ - /** - * Register a record metadata aspect. - *

- * The file plan type indicates which file plan type the aspect applied to. Null indicates that - * the aspect applies to rma:filePlan. - *

- * A record metadata aspect can be registered more than once if it applies to more than one - * file plan type. - * - * @param recordMetadataAspect record metadata aspect qualified name - * @param filePlanType file plan type - * - * @since 2.2 - */ - void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType); - - /** - * Disables the property editable check. - * - * @since 2.2 - */ - void disablePropertyEditableCheck(); - - /** - * Disables the property editable check for a given node in this transaction only. - * - * @param nodeRef node reference - * - * @since 2.2 - */ - void disablePropertyEditableCheck(NodeRef nodeRef); - - /** - * Enables the property editable check. By default this is always enabled. - */ - void enablePropertyEditableCheck(); - - /** - * Gets a list of all the record meta-data aspects - * - * @return {@link Set}<{@link QName}> list of record meta-data aspects - * - * @deprecated since 2.2, file plan component required to provide context - */ - @Deprecated - Set getRecordMetaDataAspects(); - - /** - * Indicates whether the provided aspect is a registered record meta-data - * aspect. - * - * @param aspect aspect {@link QName} - * @return boolean true if the aspect is a registered record meta-data aspect, false otherwise - * - * @since 2.3 - */ - boolean isRecordMetadataAspect(QName aspect); - - /** - * Indicates whther the provided property is declared on a registered record - * meta-data aspect. - * - * @param property property {@link QName} - * @return boolean true if the property is declared on a registered record meta-data aspect, - * false otherwise - * - * @since 2.3 - */ - boolean isRecordMetadataProperty(QName property); - - /** - * Gets a list of all the record metadata aspects relevant to the file plan type of the - * file plan component provided. - *

- * If a null context is provided all record meta-data aspects are returned, but this is not - * recommended. - * - * @param nodeRef node reference to file plan component providing context - * @return {@link Set}<{@link QName}> list of record meta-data aspects - * - * @since 2.2 - */ - Set getRecordMetadataAspects(NodeRef nodeRef); - - /** - * Gets a list of all the record metadata aspect that relate to the provided file plan type. - *

- * If null is provided for the file plan type then record metadata aspects for the default - * file plan type (rma:filePlan) are returned. - * - * @param filePlanType file plan type - * @return{@link Set}<{@link QName}> list of record meta-data aspects - * - * @since 2.2 - */ - Set getRecordMetadataAspects(QName filePlanType); - - /** - * Checks whether if the given node reference is a record or not - * - * @param nodeRef node reference to be checked - * @return boolean true if the node reference is a record, false otherwise - */ - boolean isRecord(NodeRef nodeRef); - - /** - * Indicates whether the record is declared - * - * @param nodeRef node reference of the record for which the check would be performed - * @return boolean true if record is declared, false otherwise - */ - boolean isDeclared(NodeRef nodeRef); - - /** - * Creates a new unfiled record from an existing node. - *

- * Note that the node reference of the record will be the same as the original - * document. - * - * @param filePlan The filePlan in which the record should be placed - * @param nodeRef The node from which the record will be created - * @param isLinked indicates if the newly created record is linked to it's original location or not. - */ - void createRecord(NodeRef filePlan, NodeRef nodeRef, boolean isLinked); - - /** - * Links the newly created record to it's original location. - * - * @see #createRecord(NodeRef, NodeRef, boolean) - */ - void createRecord(NodeRef filePlan, NodeRef nodeRef); - - /** - * Creates a record from a copy of the node reference provided. - * - * @param filePlan file plan - * @param nodeRef node reference - */ - NodeRef createRecordFromCopy(NodeRef filePlan, NodeRef nodeRef); - - /** - * Creates a new document in the unfiled records container if the given node reference is a file plan - * node reference otherwise the node reference will be used as the destination for the new record. - * - * @param parent parent node reference - * @param name name of the new record - * @param type content type, cm:content if null - * @param properties properties - * @param reader content reader - */ - NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map properties, ContentReader reader); - - /** - * Indicates whether the record is filed or not - * - * @param nodeRef record - * @return boolean true if filed, false otherwise - */ - boolean isFiled(NodeRef record); - - /** - * 'File' a new document that arrived in the file plan structure. - * - * @param nodeRef record - */ - void file(NodeRef record); - - /** - * Rejects a record with the provided reason - * - * @param nodeRef The record which will be rejected - * @param reason The reason for rejection - */ - void rejectRecord(NodeRef nodeRef, String reason); - - /** - * Indicates whether a property of a record is editable for the current user or not. - * - * @param record record - * @param property property - * @return boolean true if editable, false otherwise. - */ - boolean isPropertyEditable(NodeRef record, QName property); - - /** - * Indicates whether the given node (record or record folder) is a metadata stub or not. - * - * @param nodeRef node reference - * @return boolean true if a metadata stub, false otherwise - */ - boolean isMetadataStub(NodeRef nodeRef); - - /** - * Gets a list of all the records within a record folder - * - * @param recordFolder record folder - * @return List list of records in the record folder - */ - List getRecords(NodeRef recordFolder); - - /** - * Adds the specified type to the record - * - * @param nodeRef Record node reference - * @param typeQName Type to add - */ - void addRecordType(NodeRef nodeRef, QName typeQName); - - /** - * Creates a record from the given document - * - * @param nodeRef The document node reference from which a record will be created - */ - void makeRecord(NodeRef nodeRef); - - /** - * Links a record to a record folder - * - * @param record the record to link - * @param recordFolder the record folder to link it to - */ - void link(NodeRef record, NodeRef recordFolder); - - /** - * Unlinks a record from a specified record folder. - * - * @param record the record to unlink - * @param recordFolder the record folder to unlink it from - * - * @since 2.3 - */ - void unlink(NodeRef record, NodeRef recordFolder); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.record; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Record Service Interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordService +{ + /** + * Register a record metadata aspect. + *

+ * The file plan type indicates which file plan type the aspect applied to. Null indicates that + * the aspect applies to rma:filePlan. + *

+ * A record metadata aspect can be registered more than once if it applies to more than one + * file plan type. + * + * @param recordMetadataAspect record metadata aspect qualified name + * @param filePlanType file plan type + * + * @since 2.2 + */ + void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType); + + /** + * Disables the property editable check. + * + * @since 2.2 + */ + void disablePropertyEditableCheck(); + + /** + * Disables the property editable check for a given node in this transaction only. + * + * @param nodeRef node reference + * + * @since 2.2 + */ + void disablePropertyEditableCheck(NodeRef nodeRef); + + /** + * Enables the property editable check. By default this is always enabled. + */ + void enablePropertyEditableCheck(); + + /** + * Gets a list of all the record meta-data aspects + * + * @return {@link Set}<{@link QName}> list of record meta-data aspects + * + * @deprecated since 2.2, file plan component required to provide context + */ + @Deprecated + Set getRecordMetaDataAspects(); + + /** + * Indicates whether the provided aspect is a registered record meta-data + * aspect. + * + * @param aspect aspect {@link QName} + * @return boolean true if the aspect is a registered record meta-data aspect, false otherwise + * + * @since 2.3 + */ + boolean isRecordMetadataAspect(QName aspect); + + /** + * Indicates whther the provided property is declared on a registered record + * meta-data aspect. + * + * @param property property {@link QName} + * @return boolean true if the property is declared on a registered record meta-data aspect, + * false otherwise + * + * @since 2.3 + */ + boolean isRecordMetadataProperty(QName property); + + /** + * Gets a list of all the record metadata aspects relevant to the file plan type of the + * file plan component provided. + *

+ * If a null context is provided all record meta-data aspects are returned, but this is not + * recommended. + * + * @param nodeRef node reference to file plan component providing context + * @return {@link Set}<{@link QName}> list of record meta-data aspects + * + * @since 2.2 + */ + Set getRecordMetadataAspects(NodeRef nodeRef); + + /** + * Gets a list of all the record metadata aspect that relate to the provided file plan type. + *

+ * If null is provided for the file plan type then record metadata aspects for the default + * file plan type (rma:filePlan) are returned. + * + * @param filePlanType file plan type + * @return{@link Set}<{@link QName}> list of record meta-data aspects + * + * @since 2.2 + */ + Set getRecordMetadataAspects(QName filePlanType); + + /** + * Checks whether if the given node reference is a record or not + * + * @param nodeRef node reference to be checked + * @return boolean true if the node reference is a record, false otherwise + */ + boolean isRecord(NodeRef nodeRef); + + /** + * Indicates whether the record is declared + * + * @param nodeRef node reference of the record for which the check would be performed + * @return boolean true if record is declared, false otherwise + */ + boolean isDeclared(NodeRef nodeRef); + + /** + * Creates a new unfiled record from an existing node. + *

+ * Note that the node reference of the record will be the same as the original + * document. + * + * @param filePlan The filePlan in which the record should be placed + * @param nodeRef The node from which the record will be created + * @param isLinked indicates if the newly created record is linked to it's original location or not. + */ + void createRecord(NodeRef filePlan, NodeRef nodeRef, boolean isLinked); + + /** + * Links the newly created record to it's original location. + * + * @see #createRecord(NodeRef, NodeRef, boolean) + */ + void createRecord(NodeRef filePlan, NodeRef nodeRef); + + /** + * Creates a record from a copy of the node reference provided. + * + * @param filePlan file plan + * @param nodeRef node reference + */ + NodeRef createRecordFromCopy(NodeRef filePlan, NodeRef nodeRef); + + /** + * Creates a new document in the unfiled records container if the given node reference is a file plan + * node reference otherwise the node reference will be used as the destination for the new record. + * + * @param parent parent node reference + * @param name name of the new record + * @param type content type, cm:content if null + * @param properties properties + * @param reader content reader + */ + NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map properties, ContentReader reader); + + /** + * Indicates whether the record is filed or not + * + * @param nodeRef record + * @return boolean true if filed, false otherwise + */ + boolean isFiled(NodeRef record); + + /** + * 'File' a new document that arrived in the file plan structure. + * + * @param nodeRef record + */ + void file(NodeRef record); + + /** + * Rejects a record with the provided reason + * + * @param nodeRef The record which will be rejected + * @param reason The reason for rejection + */ + void rejectRecord(NodeRef nodeRef, String reason); + + /** + * Indicates whether a property of a record is editable for the current user or not. + * + * @param record record + * @param property property + * @return boolean true if editable, false otherwise. + */ + boolean isPropertyEditable(NodeRef record, QName property); + + /** + * Indicates whether the given node (record or record folder) is a metadata stub or not. + * + * @param nodeRef node reference + * @return boolean true if a metadata stub, false otherwise + */ + boolean isMetadataStub(NodeRef nodeRef); + + /** + * Gets a list of all the records within a record folder + * + * @param recordFolder record folder + * @return List list of records in the record folder + */ + List getRecords(NodeRef recordFolder); + + /** + * Adds the specified type to the record + * + * @param nodeRef Record node reference + * @param typeQName Type to add + */ + void addRecordType(NodeRef nodeRef, QName typeQName); + + /** + * Creates a record from the given document + * + * @param nodeRef The document node reference from which a record will be created + */ + void makeRecord(NodeRef nodeRef); + + /** + * Links a record to a record folder + * + * @param record the record to link + * @param recordFolder the record folder to link it to + */ + void link(NodeRef record, NodeRef recordFolder); + + /** + * Unlinks a record from a specified record folder. + * + * @param record the record to unlink + * @param recordFolder the record folder to unlink it from + * + * @since 2.3 + */ + void unlink(NodeRef record, NodeRef recordFolder); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index dd2238ee61..a229811adf 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -1,1777 +1,1777 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeFileRecord; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RecordsManagementContainerType; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException; -import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.ClassPolicyDelegate; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.PropertyMap; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Record service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class RecordServiceImpl extends BaseBehaviourBean - implements RecordService, - RecordsManagementModel, - RecordsManagementCustomModel, - NodeServicePolicies.OnCreateChildAssociationPolicy, - NodeServicePolicies.OnAddAspectPolicy, - NodeServicePolicies.OnRemoveAspectPolicy, - NodeServicePolicies.OnUpdatePropertiesPolicy -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RecordServiceImpl.class); - - /** transation data key */ - private static final String KEY_IGNORE_ON_UPDATE = "ignoreOnUpdate"; - private static final String KEY_PENDING_FILLING = "pendingFilling"; - public static final String KEY_NEW_RECORDS = "newRecords"; - - /** I18N */ - private static final String MSG_NODE_HAS_ASPECT = "rm.service.node-has-aspect"; - private static final String FINAL_VERSION = "rm.service.final-version"; - private static final String FINAL_DESCRIPTION = "rm.service.final-version-description"; - - /** Always edit property array */ - private static final QName[] ALWAYS_EDIT_PROPERTIES = new QName[] - { - ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA - }; - - /** always edit model URI's */ - private static final String[] ALWAYS_EDIT_URIS = new String[] - { - NamespaceService.SECURITY_MODEL_1_0_URI, - NamespaceService.SYSTEM_MODEL_1_0_URI, - NamespaceService.WORKFLOW_MODEL_1_0_URI, - NamespaceService.APP_MODEL_1_0_URI, - NamespaceService.DATALIST_MODEL_1_0_URI, - NamespaceService.DICTIONARY_MODEL_1_0_URI, - NamespaceService.BPM_MODEL_1_0_URI, - NamespaceService.RENDITION_MODEL_1_0_URI - }; - - /** record model URI's */ - public static final List RECORD_MODEL_URIS = Collections.unmodifiableList( - Arrays.asList( - RM_URI, - RM_CUSTOM_URI, - ReportModel.RMR_URI, - RecordableVersionModel.RMV_URI, - DOD5015Model.DOD_URI - )); - - /** non-record model URI's */ - private static final String[] NON_RECORD_MODEL_URIS = new String[] - { - NamespaceService.AUDIO_MODEL_1_0_URI, - NamespaceService.CONTENT_MODEL_1_0_URI, - NamespaceService.EMAILSERVER_MODEL_URI, - NamespaceService.EXIF_MODEL_1_0_URI, - NamespaceService.FORUMS_MODEL_1_0_URI, - NamespaceService.LINKS_MODEL_1_0_URI, - NamespaceService.REPOSITORY_VIEW_1_0_URI - }; - - /** Indentity service */ - private IdentifierService identifierService; - - /** Extended permission service */ - private ExtendedPermissionService extendedPermissionService; - - /** Extended security service */ - private ExtendedSecurityService extendedSecurityService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Records management notification helper */ - private RecordsManagementNotificationHelper notificationHelper; - - /** Policy component */ - private PolicyComponent policyComponent; - - /** Ownable service */ - private OwnableService ownableService; - - /** Capability service */ - private CapabilityService capabilityService; - - /** Rule service */ - private RuleService ruleService; - - /** File folder service */ - private FileFolderService fileFolderService; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** Permission service */ - private PermissionService permissionService; - - /** Version service */ - private VersionService versionService; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** records management container type */ - private RecordsManagementContainerType recordsManagementContainerType; - - /** recordable version service */ - private RecordableVersionService recordableVersionService; - - /** list of available record meta-data aspects and the file plan types the are applicable to */ - private Map> recordMetaDataAspects; - - /** policies */ - private ClassPolicyDelegate beforeFileRecord; - private ClassPolicyDelegate onFileRecord; - - /** Behaviours */ - private JavaBehaviour onCreateChildAssociation = new JavaBehaviour( - this, - "onCreateChildAssociation", - NotificationFrequency.FIRST_EVENT); - - /** - * @param identifierService identifier service - */ - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - /** - * @param extendedPermissionService extended permission service - */ - public void setExtendedPermissionService(ExtendedPermissionService extendedPermissionService) - { - this.extendedPermissionService = extendedPermissionService; - } - - /** - * @param extendedSecurityService extended security service - */ - public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) - { - this.extendedSecurityService = extendedSecurityService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param notificationHelper notification helper - */ - public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) - { - this.notificationHelper = notificationHelper; - } - - /** - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * @param ownableService ownable service - */ - public void setOwnableService(OwnableService ownableService) - { - this.ownableService = ownableService; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param ruleService rule service - */ - public void setRuleService(RuleService ruleService) - { - this.ruleService = ruleService; - } - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param versionService version service - */ - public void setVersionService(VersionService versionService) - { - this.versionService = versionService; - } - - /** - * @param relationshipService relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordsManagementContainerType records management container type - */ - public void setRecordsManagementContainerType(RecordsManagementContainerType recordsManagementContainerType) - { - this.recordsManagementContainerType = recordsManagementContainerType; - } - - /** - * @param recordableVersionService recordable version service - */ - public void setRecordableVersionService(RecordableVersionService recordableVersionService) - { - this.recordableVersionService = recordableVersionService; - } - - /** - * Init method - */ - public void init() - { - // bind policies - beforeFileRecord = policyComponent.registerClassPolicy(BeforeFileRecord.class); - onFileRecord = policyComponent.registerClassPolicy(OnFileRecord.class); - - // bind behaviours - policyComponent.bindAssociationBehaviour( - NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, - TYPE_RECORD_FOLDER, - ContentModel.ASSOC_CONTAINS, - onCreateChildAssociation); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "sys:noContent" - ) - public void onRemoveAspect(NodeRef nodeRef, QName aspect) - { - - if (nodeService.hasAspect(nodeRef, ASPECT_RECORD)) - { - ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); - - // Only switch name back to the format of "name (identifierId)" if content size is non-zero, else leave it as the original name to avoid CIFS shuffling issues. - if (contentData != null && contentData.getSize() > 0) - { - switchNames(nodeRef); - } - } - else - { - // check whether filling is pending aspect removal - Set pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING); - if (pendingFilling.contains(nodeRef)) - { - file(nodeRef); - } - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - type = "sys:noContent" - ) - public void onAddAspect(NodeRef nodeRef, QName aspect) - { - switchNames(nodeRef); - } - - /** - * Helper method to switch the name of the record around. Used to support record creation via - * file protocols. - * - * @param nodeRef node reference (record) - */ - private void switchNames(NodeRef nodeRef) - { - try - { - if (nodeService.hasAspect(nodeRef, ASPECT_RECORD)) - { - String origionalName = (String)nodeService.getProperty(nodeRef, PROP_ORIGIONAL_NAME); - if (origionalName != null) - { - String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - fileFolderService.rename(nodeRef, origionalName); - nodeService.setProperty(nodeRef, PROP_ORIGIONAL_NAME, name); - } - } - } - catch (FileExistsException e) - { - if (logger.isDebugEnabled()) - { - logger.debug(e.getMessage()); - } - } - catch (InvalidNodeRefException e) - { - if (logger.isDebugEnabled()) - { - logger.debug(e.getMessage()); - } - } - catch (FileNotFoundException e) - { - if (logger.isDebugEnabled()) - { - logger.debug(e.getMessage()); - } - } - } - - /** - * Behaviour executed when a new item is added to a record folder. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Override - public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, final boolean bNew) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - onCreateChildAssociation.disable(); - try - { - NodeRef nodeRef = childAssocRef.getChildRef(); - if (nodeService.exists(nodeRef) && - !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) && - !nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) && - !nodeService.getType(nodeRef).equals(TYPE_RECORD_CATEGORY)) - { - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) - { - // we need to postpone filling until the NO_CONTENT aspect is removed - Set pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING); - pendingFilling.add(nodeRef); - } - else - { - // store information about the 'new' record in the transaction - // @since 2.3 - // @see https://issues.alfresco.com/jira/browse/RM-1956 - if (bNew) - { - Set newRecords = transactionalResourceHelper.getSet(KEY_NEW_RECORDS); - newRecords.add(nodeRef); - } - else - { - // if we are linking a record - NodeRef parentNodeRef = childAssocRef.getParentRef(); - if (isRecord(nodeRef) && isRecordFolder(parentNodeRef)) - { - // validate the link conditions - validateLinkConditions(nodeRef, parentNodeRef); - } - } - - // create and file the content as a record - file(nodeRef); - } - } - } - catch (RecordLinkRuntimeException e) - { - // rethrow exception - throw e; - } - catch (AlfrescoRuntimeException e) - { - // do nothing but log error - if (logger.isWarnEnabled()) - { - logger.warn("Unable to file pending record.", e); - } - } - finally - { - onCreateChildAssociation.enable(); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck() - */ - @Override - public void disablePropertyEditableCheck() - { - getBehaviour("onUpdateProperties").disable(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck(org.alfresco.service.cmr.repository.NodeRef) - */ - public void disablePropertyEditableCheck(NodeRef nodeRef) - { - Set ignoreOnUpdate = transactionalResourceHelper.getSet(KEY_IGNORE_ON_UPDATE); - ignoreOnUpdate.add(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#enablePropertyEditableCheck() - */ - @Override - public void enablePropertyEditableCheck() - { - getBehaviour("onUpdateProperties").enable(); - } - - /** - * Ensure that the user only updates record properties that they have permission to. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) - */ - @Override - @Behaviour - ( - name = "onUpdateProperties", - kind = BehaviourKind.CLASS, - type= "rma:record" - ) - public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) - { - if (AuthenticationUtil.getFullyAuthenticatedUser() != null && - !AuthenticationUtil.isRunAsUserTheSystemUser() && - nodeService.exists(nodeRef) && - isRecord(nodeRef) && - !transactionalResourceHelper.getSet(KEY_IGNORE_ON_UPDATE).contains(nodeRef)) - { - for (Map.Entry entry : after.entrySet()) - { - Serializable beforeValue = null; - QName property = entry.getKey(); - if (before != null) - { - beforeValue = before.get(property); - } - - Serializable afterValue = entry.getValue(); - boolean propertyUnchanged = false; - if (beforeValue instanceof Date && afterValue instanceof Date) - { - // deal with date values, remove the seconds and milliseconds for the - // comparison as they are removed from the submitted for data - Calendar beforeCal = Calendar.getInstance(); - beforeCal.setTime((Date)beforeValue); - Calendar afterCal = Calendar.getInstance(); - afterCal.setTime((Date)afterValue); - beforeCal.set(Calendar.SECOND, 0); - beforeCal.set(Calendar.MILLISECOND, 0); - afterCal.set(Calendar.SECOND, 0); - afterCal.set(Calendar.MILLISECOND, 0); - propertyUnchanged = (beforeCal.compareTo(afterCal) == 0); - } - else if ((afterValue instanceof Boolean) && (beforeValue == null) && (afterValue.equals(Boolean.FALSE))) - { - propertyUnchanged = true; - } - else - { - // otherwise - propertyUnchanged = EqualsHelper.nullSafeEquals(beforeValue, afterValue); - } - - if (!propertyUnchanged && - !(ContentModel.PROP_CONTENT.equals(property) && beforeValue == null) && - !isPropertyEditable(nodeRef, property)) - { - // the user can't edit the record property - throw new ModelAccessDeniedException( - "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + - " does not have the permission to edit the record property " + property.toString() + - " on the node " + nodeRef.toString()); - } - } - } - } - - /** - * Get map containing record metadata aspects. - * - * @return {@link Map}<{@link QName}, {@link Set}<{@link QName}>> map containing record metadata aspects - * - * @since 2.2 - */ - protected Map> getRecordMetadataAspectsMap() - { - if (recordMetaDataAspects == null) - { - // create map - recordMetaDataAspects = new HashMap>(); - - // init with legacy aspects - initRecordMetaDataMap(); - } - - return recordMetaDataAspects; - } - - /** - * Initialises the record meta-data map. - *

- * This is here to support backwards compatibility in case an existing - * customization (pre 2.2) is still using the record meta-data aspect. - * - * @since 2.2 - */ - private void initRecordMetaDataMap() - { - // populate the inital set of record meta-data aspects .. this is here for legacy reasons - Collection aspects = dictionaryService.getAllAspects(); - for (QName aspect : aspects) - { - AspectDefinition def = dictionaryService.getAspect(aspect); - if (def != null) - { - QName parent = def.getParentName(); - if (parent != null && ASPECT_RECORD_META_DATA.equals(parent)) - { - recordMetaDataAspects.put(aspect, Collections.singleton(TYPE_FILE_PLAN)); - } - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#registerRecordMetadataAspect(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) - */ - @Override - public void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType) - { - ParameterCheck.mandatory("recordMetadataAspect", recordMetadataAspect); - ParameterCheck.mandatory("filePlanType", filePlanType); - - Set filePlanTypes = null; - - if (getRecordMetadataAspectsMap().containsKey(recordMetadataAspect)) - { - // get the current set of file plan types for this aspect - filePlanTypes = getRecordMetadataAspectsMap().get(recordMetadataAspect); - } - else - { - // create a new set for the file plan type - filePlanTypes = new HashSet(1); - getRecordMetadataAspectsMap().put(recordMetadataAspect, filePlanTypes); - } - - // add the file plan type - filePlanTypes.add(filePlanType); - } - - /** - * @deprecated since 2.2, file plan is required to provide context - */ - @Override - @Deprecated - public Set getRecordMetaDataAspects() - { - return getRecordMetadataAspects(TYPE_FILE_PLAN); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isRecordMetadataAspect(org.alfresco.service.namespace.QName) - */ - @Override - public boolean isRecordMetadataAspect(QName aspect) - { - return getRecordMetadataAspectsMap().containsKey(aspect); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isRecordMetadataProperty(org.alfresco.service.namespace.QName) - */ - @Override - public boolean isRecordMetadataProperty(QName property) - { - boolean result = false; - PropertyDefinition propertyDefinition = dictionaryService.getProperty(property); - if (propertyDefinition != null) - { - ClassDefinition classDefinition = propertyDefinition.getContainerClass(); - if (classDefinition != null && - getRecordMetadataAspectsMap().containsKey(classDefinition.getName())) - { - result = true; - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Set getRecordMetadataAspects(NodeRef nodeRef) - { - QName filePlanType = TYPE_FILE_PLAN; - - if (nodeRef != null) - { - NodeRef filePlan = getFilePlan(nodeRef); - filePlanType = nodeService.getType(filePlan); - } - - return getRecordMetadataAspects(filePlanType); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetadataAspects(org.alfresco.service.namespace.QName) - */ - @Override - public Set getRecordMetadataAspects(QName filePlanType) - { - Set result = new HashSet(getRecordMetadataAspectsMap().size()); - - for (Entry> entry : getRecordMetadataAspectsMap().entrySet()) - { - if (entry.getValue().contains(filePlanType)) - { - result.add(entry.getKey()); - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void createRecord(NodeRef filePlan, NodeRef nodeRef) - { - createRecord(filePlan, nodeRef, true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public void createRecord(final NodeRef filePlan, final NodeRef nodeRef, final boolean isLinked) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("isLinked", isLinked); - - // first we do a sanity check to ensure that the user has at least write permissions on the document - if (extendedPermissionService.hasPermission(nodeRef, PermissionService.WRITE) != AccessStatus.ALLOWED) - { - throw new AccessDeniedException("Can not create record from document, because the user " + - AuthenticationUtil.getRunAsUser() + - " does not have Write permissions on the doucment " + - nodeRef.toString()); - } - - - // do the work of creating the record as the system user - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - if (!nodeService.hasAspect(nodeRef, ASPECT_RECORD)) - { - // disable delete rules - ruleService.disableRuleType("outbound"); - try - { - // get the new record container for the file plan - NodeRef newRecordContainer = filePlanService.getUnfiledContainer(filePlan); - if (newRecordContainer == null) - { - throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found."); - } - - // get the documents readers and writers - Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); - - // get the current owner - String owner = ownableService.getOwner(nodeRef); - - // get the documents primary parent assoc - ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); - - // get the latest version record, if there is one - NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef); - - behaviourFilter.disableBehaviour(); - try - { - // move the document into the file plan - nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); - } - finally - { - behaviourFilter.enableBehaviour(); - } - - // save the information about the originating details - Map aspectProperties = new HashMap(3); - aspectProperties.put(PROP_RECORD_ORIGINATING_LOCATION, parentAssoc.getParentRef()); - aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, owner); - aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date()); - nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties); - - // make the document a record - makeRecord(nodeRef); - - if (latestVersionRecord != null) - { - // indicate that this is the 'final' record version - PropertyMap versionRecordProps = new PropertyMap(2); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, I18NUtil.getMessage(FINAL_VERSION)); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, I18NUtil.getMessage(FINAL_DESCRIPTION)); - nodeService.addAspect(nodeRef, RecordableVersionModel.ASPECT_VERSION_RECORD, versionRecordProps); - - // link to previous version - relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord); - } - - if (isLinked) - { - // turn off rules - ruleService.disableRules(); - try - { - // maintain the original primary location - nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName()); - - // set the extended security - extendedSecurityService.set(nodeRef, readersAndWriters); - } - finally - { - ruleService.enableRules(); - } - } - } - finally - { - ruleService.enableRuleType("outbound"); - } - } - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecordFromCopy(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef createRecordFromCopy(final NodeRef filePlan, final NodeRef nodeRef) - { - return authenticationUtil.runAsSystem(new RunAsWork() - { - public NodeRef doWork() throws Exception - { - // get the unfiled record folder - final NodeRef unfiledRecordFolder = filePlanService.getUnfiledContainer(filePlan); - - // get the documents readers and writers - Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); - - // copy version state and create record - NodeRef record = null; - try - { - List originalAssocs = null; - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_COPIEDFROM)) - { - // take a note of any copyFrom information already on the node - originalAssocs = nodeService.getTargetAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL); - } - - recordsManagementContainerType.disable(); - try - { - // create a copy of the original state and add it to the unfiled record container - FileInfo recordInfo = fileFolderService.copy(nodeRef, unfiledRecordFolder, null); - record = recordInfo.getNodeRef(); - } - finally - { - recordsManagementContainerType.enable(); - } - - // if versionable, then remove without destroying version history, - // because it is being shared with the originating document - behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE); - try - { - nodeService.removeAspect(record, ContentModel.ASPECT_VERSIONABLE); - } - finally - { - behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE); - } - - // make record - makeRecord(record); - - // remove added copy assocs - List recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL); - for (AssociationRef recordAssoc : recordAssocs) - { - nodeService.removeAssociation( - recordAssoc.getSourceRef(), - recordAssoc.getTargetRef(), - ContentModel.ASSOC_ORIGINAL); - } - - // re-add origional assocs or remove aspect - if (originalAssocs == null) - { - nodeService.removeAspect(record, ContentModel.ASPECT_COPIEDFROM); - } - else - { - for (AssociationRef originalAssoc : originalAssocs) - { - nodeService.createAssociation(record, originalAssoc.getTargetRef(), ContentModel.ASSOC_ORIGINAL); - } - } - } - catch (FileNotFoundException e) - { - throw new AlfrescoRuntimeException("Can't create recorded version, because copy fails.", e); - } - - // set extended security on record - extendedSecurityService.set(record, readersAndWriters); - - return record; - } - }); - } - - /** - * Helper to get the latest version record for a given document (ie non-record) - * - * @param nodeRef node reference - * @return NodeRef latest version record, null otherwise - */ - private NodeRef getLatestVersionRecord(NodeRef nodeRef) - { - NodeRef versionRecord = null; - - // wire record up to previous record - VersionHistory versionHistory = versionService.getVersionHistory(nodeRef); - if (versionHistory != null) - { - Collection previousVersions = versionHistory.getAllVersions(); - for (Version previousVersion : previousVersions) - { - // look for the associated record - final NodeRef previousRecord = recordableVersionService.getVersionRecord(previousVersion); - if (previousRecord != null) - { - versionRecord = previousRecord; - break; - } - } - } - - return versionRecord; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createNewRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map, org.alfresco.service.cmr.repository.ContentReader) - */ - @Override - public NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map properties, ContentReader reader) - { - ParameterCheck.mandatory("nodeRef", parent); - ParameterCheck.mandatory("name", name); - - NodeRef result = null; - NodeRef destination = parent; - - if (isFilePlan(parent)) - { - // get the unfiled record container for the file plan - destination = filePlanService.getUnfiledContainer(parent); - if (destination == null) - { - throw new AlfrescoRuntimeException("Unable to create record, because unfiled container could not be found."); - } - } - - // if none set the default record type is cm:content - if (type == null) - { - type = ContentModel.TYPE_CONTENT; - } - else if (!dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)) - { - throw new AlfrescoRuntimeException("Record can only be created from a sub-type of cm:content."); - } - - disablePropertyEditableCheck(); - try - { - // create the new record - final NodeRef record = fileFolderService.create(destination, name, type).getNodeRef(); - - // set the properties - if (properties != null) - { - nodeService.addProperties(record, properties); - } - - // set the content - if (reader != null) - { - ContentWriter writer = fileFolderService.getWriter(record); - writer.setEncoding(reader.getEncoding()); - writer.setMimetype(reader.getMimetype()); - writer.putContent(reader); - } - - result = authenticationUtil.runAsSystem(new RunAsWork() - { - public NodeRef doWork() throws Exception - { - // Check if the "record" aspect has been applied already. - // In case of filing a report the created node will be made - // a record within the "onCreateChildAssociation" method if - // a destination for the report has been selected. - if (!nodeService.hasAspect(record, ASPECT_RECORD)) - { - // make record - makeRecord(record); - } - - return record; - } - - }); - } - finally - { - enablePropertyEditableCheck(); - } - - return result; - } - - /** - * Creates a record from the given document - * - * @param document the document from which a record will be created - */ - @Override - public void makeRecord(NodeRef document) - { - ParameterCheck.mandatory("document", document); - - ruleService.disableRules(); - disablePropertyEditableCheck(); - try - { - // get the record id - String recordId = identifierService.generateIdentifier(ASPECT_RECORD, - nodeService.getPrimaryParent(document).getParentRef()); - - // get the record name - String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME); - - // rename the record - int dotIndex = name.lastIndexOf('.'); - String prefix = name; - String postfix = ""; - if (dotIndex != -1) - { - prefix = name.substring(0, dotIndex); - postfix = name.substring(dotIndex); - } - String recordName = prefix + " (" + recordId + ")" + postfix; - behaviourFilter.disableBehaviour(); - try - { - fileFolderService.rename(document, recordName); - } - finally - { - behaviourFilter.enableBehaviour(); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Rename " + name + " to " + recordName); - } - - // add the record aspect - Map props = new HashMap(2); - props.put(PROP_IDENTIFIER, recordId); - props.put(PROP_ORIGIONAL_NAME, name); - nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props); - - // remove versionable aspect(s) - nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE); - - // remove the owner - ownableService.setOwner(document, OwnableService.NO_OWNER); - } - catch (FileNotFoundException e) - { - throw new AlfrescoRuntimeException("Unable to make record, because rename failed.", e); - } - finally - { - ruleService.enableRules(); - enablePropertyEditableCheck(); - } - - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isFiled(final NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - boolean result = false; - - if (isRecord(nodeRef)) - { - result = AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Boolean doWork() throws Exception - { - return (null != nodeService.getProperty(nodeRef, PROP_DATE_FILED)); - } - }); - } - - return result; - } - - /** - * Helper method to 'file' a new document that arrived in the file plan structure. - * - * TODO atm we only 'file' content as a record .. may need to consider other types if we - * are to support the notion of composite records. - * - * @param record node reference to record (or soon to be record!) - */ - @Override - public void file(NodeRef record) - { - ParameterCheck.mandatory("item", record); - - // we only support filling of content items - // TODO composite record support needs to file containers too - QName type = nodeService.getType(record); - if (ContentModel.TYPE_CONTENT.equals(type) || - dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)) - { - // fire before file record policy - beforeFileRecord.get(getTypeAndApsects(record)).beforeFileRecord(record); - - // check whether this item is already an item or not - if (!isRecord(record)) - { - // make the item a record - makeRecord(record); - } - - // set filed date - if (nodeService.getProperty(record, PROP_DATE_FILED) == null) - { - Calendar fileCalendar = Calendar.getInstance(); - nodeService.setProperty(record, PROP_DATE_FILED, fileCalendar.getTime()); - } - - // file on file record policy - onFileRecord.get(getTypeAndApsects(record)).onFileRecord(record); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#rejectRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public void rejectRecord(final NodeRef nodeRef, final String reason) - { - ParameterCheck.mandatory("NodeRef", nodeRef); - ParameterCheck.mandatoryString("Reason", reason); - - // Save the id of the currently logged in user - final String userId = AuthenticationUtil.getFullyAuthenticatedUser(); - - // do the work of rejecting the record as the system user - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - ruleService.disableRules(); - try - { - // get the latest version record, if there is one - NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef); - - if (latestVersionRecord != null) - { - relationshipService.removeRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord); - } - - // get record property values - final Map properties = nodeService.getProperties(nodeRef); - final String recordId = (String)properties.get(PROP_IDENTIFIER); - final String documentOwner = (String)properties.get(PROP_RECORD_ORIGINATING_USER_ID); - final String originalName = (String)properties.get(PROP_ORIGIONAL_NAME); - final NodeRef originatingLocation = (NodeRef)properties.get(PROP_RECORD_ORIGINATING_LOCATION); - - // we can only reject if the originating location is present - if (originatingLocation != null) - { - // first remove the secondary link association - final List parentAssocs = nodeService.getParentAssocs(nodeRef); - for (ChildAssociationRef childAssociationRef : parentAssocs) - { - if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation)) - { - nodeService.removeChildAssociation(childAssociationRef); - break; - } - } - - removeRmAspectsFrom(nodeRef); - - // get the records primary parent association - final ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); - - // move the record into the collaboration site - nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); - - // rename to the original name - if (originalName != null) - { - fileFolderService.rename(nodeRef, originalName); - - if (logger.isDebugEnabled()) - { - String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - logger.debug("Rename " + name + " to " + originalName); - } - } - - // save the information about the rejection details - final Map aspectProperties = new HashMap<>(3); - aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId); - aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date()); - aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason); - nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties); - - // Restore the owner of the document - if (StringUtils.isBlank(documentOwner)) - { - throw new AlfrescoRuntimeException("Unable to find the creator of document."); - } - ownableService.setOwner(nodeRef, documentOwner); - - // clear the existing permissions - permissionService.clearPermission(nodeRef, null); - - // restore permission inheritance - permissionService.setInheritParentPermissions(nodeRef, true); - - // send an email to the record creator - notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner); - } - } - finally - { - ruleService.enableRules(); - } - - return null; - } - - /** Removes all RM related aspects from the specified node and any rendition children. */ - private void removeRmAspectsFrom(NodeRef nodeRef) - { - // Note that when folder records are supported, we will need to recursively - // remove aspects from their descendants. - final Set aspects = nodeService.getAspects(nodeRef); - for (QName aspect : aspects) - { - if (RM_URI.equals(aspect.getNamespaceURI()) || - RecordableVersionModel.RMV_URI.equals(aspect.getNamespaceURI())) - { - nodeService.removeAspect(nodeRef, aspect); - } - } - for (ChildAssociationRef renditionAssoc : renditionService.getRenditions(nodeRef)) - { - final NodeRef renditionNode = renditionAssoc.getChildRef(); - - // Do not attempt to clean up rendition nodes which are not children of their source node. - final boolean renditionRequiresCleaning = nodeService.exists(renditionNode) && - renditionAssoc.isPrimary(); - - if (renditionRequiresCleaning) - { - removeRmAspectsFrom(renditionNode); - } - } - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isPropertyEditable(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - @Override - public boolean isPropertyEditable(NodeRef record, QName property) - { - ParameterCheck.mandatory("record", record); - ParameterCheck.mandatory("property", property); - - if (!isRecord(record)) - { - throw new AlfrescoRuntimeException("Can not check if the property " + property.toString() + " is editable, because node reference is not a record."); - } - - NodeRef filePlan = getFilePlan(record); - - // DEBUG ... - boolean debugEnabled = logger.isDebugEnabled(); - if (debugEnabled) - { - logger.debug("Checking whether property " + property.toString() + " is editable for user " + AuthenticationUtil.getRunAsUser()); - - Set roles = filePlanRoleService.getRolesByUser(filePlan, AuthenticationUtil.getRunAsUser()); - - logger.debug(" ... users roles"); - - for (Role role : roles) - { - logger.debug(" ... user has role " + role.getName() + " with capabilities "); - - for (Capability cap : role.getCapabilities()) - { - logger.debug(" ... " + cap.getName()); - } - } - - logger.debug(" ... user has the following set permissions on the file plan"); - - Set perms = permissionService.getAllSetPermissions(filePlan); - for (AccessPermission perm : perms) - { - if ((perm.getPermission().contains(RMPermissionModel.EDIT_NON_RECORD_METADATA) || - perm.getPermission().contains(RMPermissionModel.EDIT_RECORD_METADATA))) - { - logger.debug(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString()); - } - } - - if (permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA).equals(AccessStatus.ALLOWED)) - { - logger.debug(" ... user has the edit non record metadata permission on the file plan"); - } - } - // END DEBUG ... - - boolean result = alwaysEditProperty(property); - if (result) - { - if (debugEnabled) - { - logger.debug(" ... property marked as always editable."); - } - } - else - { - boolean allowRecordEdit = false; - boolean allowNonRecordEdit = false; - - AccessStatus accessNonRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_NON_RECORD_METADATA); - AccessStatus accessDeclaredRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); - AccessStatus accessRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_RECORD_METADATA); - - if (AccessStatus.ALLOWED.equals(accessNonRecord)) - { - if (debugEnabled) - { - logger.debug(" ... user has edit nonrecord metadata capability"); - } - - allowNonRecordEdit = true; - } - - if (AccessStatus.ALLOWED.equals(accessRecord) || - AccessStatus.ALLOWED.equals(accessDeclaredRecord)) - { - if (debugEnabled) - { - logger.debug(" ... user has edit record or declared metadata capability"); - } - - allowRecordEdit = true; - } - - if (allowNonRecordEdit && allowRecordEdit) - { - if (debugEnabled) - { - logger.debug(" ... so all properties can be edited."); - } - - result = true; - } - else if (allowNonRecordEdit && !allowRecordEdit) - { - // can only edit non record properties - if (!isRecordMetadata(filePlan, property)) - { - if (debugEnabled) - { - logger.debug(" ... property is not considered record metadata so editable."); - } - - result = true; - } - else - { - if (debugEnabled) - { - logger.debug(" ... property is considered record metadata so not editable."); - } - } - } - else if (!allowNonRecordEdit && allowRecordEdit) - { - // can only edit record properties - if (isRecordMetadata(filePlan, property)) - { - if (debugEnabled) - { - logger.debug(" ... property is considered record metadata so editable."); - } - - result = true; - } - else - { - if (debugEnabled) - { - logger.debug(" ... property is not considered record metadata so not editable."); - } - } - } - // otherwise we can't edit any properties so just return the empty set - } - return result; - } - - /** - * Helper method that indicates whether a property is considered record metadata or not. - * - * @param property property - * @return boolea true if record metadata, false otherwise - */ - private boolean isRecordMetadata(NodeRef filePlan, QName property) - { - boolean result = false; - - // grab the information about the properties parent type - ClassDefinition parent = null; - PropertyDefinition def = dictionaryService.getProperty(property); - if (def != null) - { - parent = def.getContainerClass(); - } - - // non-electronic record is considered a special case - // TODO move non-electronic record support to a separate model namespace - if (parent != null && TYPE_NON_ELECTRONIC_DOCUMENT.equals(parent.getName())) - { - result = false; - } - else - { - // check the URI's - result = RECORD_MODEL_URIS.contains(property.getNamespaceURI()); - - // check the custom model - if (!result && !ArrayUtils.contains(NON_RECORD_MODEL_URIS, property.getNamespaceURI())) - { - if (parent != null && parent.isAspect()) - { - result = getRecordMetadataAspects(filePlan).contains(parent.getName()); - } - } - } - - return result; - } - - /** - * Determines whether the property should always be allowed to be edited or not. - * - * @param property - * @return - */ - private boolean alwaysEditProperty(QName property) - { - return (ArrayUtils.contains(ALWAYS_EDIT_URIS, property.getNamespaceURI()) || - ArrayUtils.contains(ALWAYS_EDIT_PROPERTIES, property) || - isProtectedProperty(property)); - } - - /** - * Helper method to determine whether a property is protected at a dictionary definition - * level. - * - * @param property property qualified name - * @return booelan true if protected, false otherwise - */ - private boolean isProtectedProperty(QName property) - { - boolean result = false; - PropertyDefinition def = dictionaryService.getProperty(property); - if (def != null) - { - result = def.isProtected(); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isMetadataStub(NodeRef) - */ - @Override - public boolean isMetadataStub(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecords(NodeRef) - */ - @Override - public List getRecords(NodeRef recordFolder) - { - ParameterCheck.mandatory("recordFolder", recordFolder); - - List result = new ArrayList(1); - if (recordFolderService.isRecordFolder(recordFolder)) - { - List assocs = nodeService.getChildAssocs(recordFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef child = assoc.getChildRef(); - if (isRecord(child)) - { - result.add(child); - } - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#addRecordType(NodeRef, QName) - */ - @Override - public void addRecordType(NodeRef nodeRef, QName typeQName) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("typeQName", typeQName); - - if (!nodeService.hasAspect(nodeRef, typeQName)) - { - nodeService.addAspect(nodeRef, typeQName, null); - } - else - { - logger.info(I18NUtil.getMessage(MSG_NODE_HAS_ASPECT, nodeRef.toString(), typeQName.toString())); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#link(NodeRef, NodeRef) - */ - @Override - public void link(NodeRef record, NodeRef recordFolder) - { - ParameterCheck.mandatory("record", record); - ParameterCheck.mandatory("recordFolder", recordFolder); - - // ensure we are linking a record to a record folder - if(isRecord(record) && isRecordFolder(recordFolder)) - { - // ensure that we are not linking a record to an exisiting location - List parents = nodeService.getParentAssocs(record); - for (ChildAssociationRef parent : parents) - { - if (parent.getParentRef().equals(recordFolder)) - { - // we can not link a record to the same location more than once - throw new RecordLinkRuntimeException("Can not link a record to the same record folder more than once"); - } - } - - // validate link conditions - validateLinkConditions(record, recordFolder); - - // get the current name of the record - String name = nodeService.getProperty(record, ContentModel.PROP_NAME).toString(); - - // create a secondary link to the record folder - nodeService.addChild( - recordFolder, - record, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); - } - else - { - // can only link a record to a record folder - throw new RecordLinkRuntimeException("Can only link a record to a record folder."); - } - } - - /** - * - * @param record - * @param recordFolder - */ - private void validateLinkConditions(NodeRef record, NodeRef recordFolder) - { - // ensure that the linking record folders have compatible disposition schedules - DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record); - if (recordDispositionSchedule != null) - { - DispositionSchedule recordFolderDispositionSchedule = dispositionService.getDispositionSchedule(recordFolder); - if (recordFolderDispositionSchedule != null) - { - if (recordDispositionSchedule.isRecordLevelDisposition() != recordFolderDispositionSchedule.isRecordLevelDisposition()) - { - // we can't link a record to an incompatible disposition schedule - throw new RecordLinkRuntimeException("Can not link a record to a record folder with an incompatible disposition schedule. " - + "They must either both be record level or record folder level dispositions."); - } - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#unlink(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void unlink(NodeRef record, NodeRef recordFolder) - { - ParameterCheck.mandatory("record", record); - ParameterCheck.mandatory("recordFolder", recordFolder); - - // ensure we are unlinking a record from a record folder - if(isRecord(record) && isRecordFolder(recordFolder)) - { - // check that we are not trying to unlink the primary parent - NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef(); - if (primaryParent.equals(recordFolder)) - { - throw new RecordLinkRuntimeException("Can't unlink a record from it's owning record folder."); - } - - // remove the link - nodeService.removeChild(recordFolder, record); - } - else - { - // can only unlink a record from a record folder - throw new RecordLinkRuntimeException("Can only unlink a record from a record folder."); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeFileRecord; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RecordsManagementContainerType; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException; +import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.ClassPolicyDelegate; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.ClassDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.model.FileExistsException; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.model.FileNotFoundException; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.InvalidNodeRefException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.rule.RuleService; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.EqualsHelper; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; +import org.alfresco.util.PropertyMap; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Record service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class RecordServiceImpl extends BaseBehaviourBean + implements RecordService, + RecordsManagementModel, + RecordsManagementCustomModel, + NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnAddAspectPolicy, + NodeServicePolicies.OnRemoveAspectPolicy, + NodeServicePolicies.OnUpdatePropertiesPolicy +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RecordServiceImpl.class); + + /** transation data key */ + private static final String KEY_IGNORE_ON_UPDATE = "ignoreOnUpdate"; + private static final String KEY_PENDING_FILLING = "pendingFilling"; + public static final String KEY_NEW_RECORDS = "newRecords"; + + /** I18N */ + private static final String MSG_NODE_HAS_ASPECT = "rm.service.node-has-aspect"; + private static final String FINAL_VERSION = "rm.service.final-version"; + private static final String FINAL_DESCRIPTION = "rm.service.final-version-description"; + + /** Always edit property array */ + private static final QName[] ALWAYS_EDIT_PROPERTIES = new QName[] + { + ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA + }; + + /** always edit model URI's */ + private static final String[] ALWAYS_EDIT_URIS = new String[] + { + NamespaceService.SECURITY_MODEL_1_0_URI, + NamespaceService.SYSTEM_MODEL_1_0_URI, + NamespaceService.WORKFLOW_MODEL_1_0_URI, + NamespaceService.APP_MODEL_1_0_URI, + NamespaceService.DATALIST_MODEL_1_0_URI, + NamespaceService.DICTIONARY_MODEL_1_0_URI, + NamespaceService.BPM_MODEL_1_0_URI, + NamespaceService.RENDITION_MODEL_1_0_URI + }; + + /** record model URI's */ + public static final List RECORD_MODEL_URIS = Collections.unmodifiableList( + Arrays.asList( + RM_URI, + RM_CUSTOM_URI, + ReportModel.RMR_URI, + RecordableVersionModel.RMV_URI, + DOD5015Model.DOD_URI + )); + + /** non-record model URI's */ + private static final String[] NON_RECORD_MODEL_URIS = new String[] + { + NamespaceService.AUDIO_MODEL_1_0_URI, + NamespaceService.CONTENT_MODEL_1_0_URI, + NamespaceService.EMAILSERVER_MODEL_URI, + NamespaceService.EXIF_MODEL_1_0_URI, + NamespaceService.FORUMS_MODEL_1_0_URI, + NamespaceService.LINKS_MODEL_1_0_URI, + NamespaceService.REPOSITORY_VIEW_1_0_URI + }; + + /** Indentity service */ + private IdentifierService identifierService; + + /** Extended permission service */ + private ExtendedPermissionService extendedPermissionService; + + /** Extended security service */ + private ExtendedSecurityService extendedSecurityService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Records management notification helper */ + private RecordsManagementNotificationHelper notificationHelper; + + /** Policy component */ + private PolicyComponent policyComponent; + + /** Ownable service */ + private OwnableService ownableService; + + /** Capability service */ + private CapabilityService capabilityService; + + /** Rule service */ + private RuleService ruleService; + + /** File folder service */ + private FileFolderService fileFolderService; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** Permission service */ + private PermissionService permissionService; + + /** Version service */ + private VersionService versionService; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** records management container type */ + private RecordsManagementContainerType recordsManagementContainerType; + + /** recordable version service */ + private RecordableVersionService recordableVersionService; + + /** list of available record meta-data aspects and the file plan types the are applicable to */ + private Map> recordMetaDataAspects; + + /** policies */ + private ClassPolicyDelegate beforeFileRecord; + private ClassPolicyDelegate onFileRecord; + + /** Behaviours */ + private JavaBehaviour onCreateChildAssociation = new JavaBehaviour( + this, + "onCreateChildAssociation", + NotificationFrequency.FIRST_EVENT); + + /** + * @param identifierService identifier service + */ + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + /** + * @param extendedPermissionService extended permission service + */ + public void setExtendedPermissionService(ExtendedPermissionService extendedPermissionService) + { + this.extendedPermissionService = extendedPermissionService; + } + + /** + * @param extendedSecurityService extended security service + */ + public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) + { + this.extendedSecurityService = extendedSecurityService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param notificationHelper notification helper + */ + public void setNotificationHelper(RecordsManagementNotificationHelper notificationHelper) + { + this.notificationHelper = notificationHelper; + } + + /** + * @param policyComponent policy component + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * @param ownableService ownable service + */ + public void setOwnableService(OwnableService ownableService) + { + this.ownableService = ownableService; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param ruleService rule service + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param versionService version service + */ + public void setVersionService(VersionService versionService) + { + this.versionService = versionService; + } + + /** + * @param relationshipService relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordsManagementContainerType records management container type + */ + public void setRecordsManagementContainerType(RecordsManagementContainerType recordsManagementContainerType) + { + this.recordsManagementContainerType = recordsManagementContainerType; + } + + /** + * @param recordableVersionService recordable version service + */ + public void setRecordableVersionService(RecordableVersionService recordableVersionService) + { + this.recordableVersionService = recordableVersionService; + } + + /** + * Init method + */ + public void init() + { + // bind policies + beforeFileRecord = policyComponent.registerClassPolicy(BeforeFileRecord.class); + onFileRecord = policyComponent.registerClassPolicy(OnFileRecord.class); + + // bind behaviours + policyComponent.bindAssociationBehaviour( + NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, + TYPE_RECORD_FOLDER, + ContentModel.ASSOC_CONTAINS, + onCreateChildAssociation); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "sys:noContent" + ) + public void onRemoveAspect(NodeRef nodeRef, QName aspect) + { + + if (nodeService.hasAspect(nodeRef, ASPECT_RECORD)) + { + ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); + + // Only switch name back to the format of "name (identifierId)" if content size is non-zero, else leave it as the original name to avoid CIFS shuffling issues. + if (contentData != null && contentData.getSize() > 0) + { + switchNames(nodeRef); + } + } + else + { + // check whether filling is pending aspect removal + Set pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING); + if (pendingFilling.contains(nodeRef)) + { + file(nodeRef); + } + } + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "sys:noContent" + ) + public void onAddAspect(NodeRef nodeRef, QName aspect) + { + switchNames(nodeRef); + } + + /** + * Helper method to switch the name of the record around. Used to support record creation via + * file protocols. + * + * @param nodeRef node reference (record) + */ + private void switchNames(NodeRef nodeRef) + { + try + { + if (nodeService.hasAspect(nodeRef, ASPECT_RECORD)) + { + String origionalName = (String)nodeService.getProperty(nodeRef, PROP_ORIGIONAL_NAME); + if (origionalName != null) + { + String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + fileFolderService.rename(nodeRef, origionalName); + nodeService.setProperty(nodeRef, PROP_ORIGIONAL_NAME, name); + } + } + } + catch (FileExistsException e) + { + if (logger.isDebugEnabled()) + { + logger.debug(e.getMessage()); + } + } + catch (InvalidNodeRefException e) + { + if (logger.isDebugEnabled()) + { + logger.debug(e.getMessage()); + } + } + catch (FileNotFoundException e) + { + if (logger.isDebugEnabled()) + { + logger.debug(e.getMessage()); + } + } + } + + /** + * Behaviour executed when a new item is added to a record folder. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) + */ + @Override + public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, final boolean bNew) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + onCreateChildAssociation.disable(); + try + { + NodeRef nodeRef = childAssocRef.getChildRef(); + if (nodeService.exists(nodeRef) && + !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) && + !nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) && + !nodeService.getType(nodeRef).equals(TYPE_RECORD_CATEGORY)) + { + if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) + { + // we need to postpone filling until the NO_CONTENT aspect is removed + Set pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING); + pendingFilling.add(nodeRef); + } + else + { + // store information about the 'new' record in the transaction + // @since 2.3 + // @see https://issues.alfresco.com/jira/browse/RM-1956 + if (bNew) + { + Set newRecords = transactionalResourceHelper.getSet(KEY_NEW_RECORDS); + newRecords.add(nodeRef); + } + else + { + // if we are linking a record + NodeRef parentNodeRef = childAssocRef.getParentRef(); + if (isRecord(nodeRef) && isRecordFolder(parentNodeRef)) + { + // validate the link conditions + validateLinkConditions(nodeRef, parentNodeRef); + } + } + + // create and file the content as a record + file(nodeRef); + } + } + } + catch (RecordLinkRuntimeException e) + { + // rethrow exception + throw e; + } + catch (AlfrescoRuntimeException e) + { + // do nothing but log error + if (logger.isWarnEnabled()) + { + logger.warn("Unable to file pending record.", e); + } + } + finally + { + onCreateChildAssociation.enable(); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck() + */ + @Override + public void disablePropertyEditableCheck() + { + getBehaviour("onUpdateProperties").disable(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck(org.alfresco.service.cmr.repository.NodeRef) + */ + public void disablePropertyEditableCheck(NodeRef nodeRef) + { + Set ignoreOnUpdate = transactionalResourceHelper.getSet(KEY_IGNORE_ON_UPDATE); + ignoreOnUpdate.add(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#enablePropertyEditableCheck() + */ + @Override + public void enablePropertyEditableCheck() + { + getBehaviour("onUpdateProperties").enable(); + } + + /** + * Ensure that the user only updates record properties that they have permission to. + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) + */ + @Override + @Behaviour + ( + name = "onUpdateProperties", + kind = BehaviourKind.CLASS, + type= "rma:record" + ) + public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) + { + if (AuthenticationUtil.getFullyAuthenticatedUser() != null && + !AuthenticationUtil.isRunAsUserTheSystemUser() && + nodeService.exists(nodeRef) && + isRecord(nodeRef) && + !transactionalResourceHelper.getSet(KEY_IGNORE_ON_UPDATE).contains(nodeRef)) + { + for (Map.Entry entry : after.entrySet()) + { + Serializable beforeValue = null; + QName property = entry.getKey(); + if (before != null) + { + beforeValue = before.get(property); + } + + Serializable afterValue = entry.getValue(); + boolean propertyUnchanged = false; + if (beforeValue instanceof Date && afterValue instanceof Date) + { + // deal with date values, remove the seconds and milliseconds for the + // comparison as they are removed from the submitted for data + Calendar beforeCal = Calendar.getInstance(); + beforeCal.setTime((Date)beforeValue); + Calendar afterCal = Calendar.getInstance(); + afterCal.setTime((Date)afterValue); + beforeCal.set(Calendar.SECOND, 0); + beforeCal.set(Calendar.MILLISECOND, 0); + afterCal.set(Calendar.SECOND, 0); + afterCal.set(Calendar.MILLISECOND, 0); + propertyUnchanged = (beforeCal.compareTo(afterCal) == 0); + } + else if ((afterValue instanceof Boolean) && (beforeValue == null) && (afterValue.equals(Boolean.FALSE))) + { + propertyUnchanged = true; + } + else + { + // otherwise + propertyUnchanged = EqualsHelper.nullSafeEquals(beforeValue, afterValue); + } + + if (!propertyUnchanged && + !(ContentModel.PROP_CONTENT.equals(property) && beforeValue == null) && + !isPropertyEditable(nodeRef, property)) + { + // the user can't edit the record property + throw new ModelAccessDeniedException( + "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + + " does not have the permission to edit the record property " + property.toString() + + " on the node " + nodeRef.toString()); + } + } + } + } + + /** + * Get map containing record metadata aspects. + * + * @return {@link Map}<{@link QName}, {@link Set}<{@link QName}>> map containing record metadata aspects + * + * @since 2.2 + */ + protected Map> getRecordMetadataAspectsMap() + { + if (recordMetaDataAspects == null) + { + // create map + recordMetaDataAspects = new HashMap>(); + + // init with legacy aspects + initRecordMetaDataMap(); + } + + return recordMetaDataAspects; + } + + /** + * Initialises the record meta-data map. + *

+ * This is here to support backwards compatibility in case an existing + * customization (pre 2.2) is still using the record meta-data aspect. + * + * @since 2.2 + */ + private void initRecordMetaDataMap() + { + // populate the inital set of record meta-data aspects .. this is here for legacy reasons + Collection aspects = dictionaryService.getAllAspects(); + for (QName aspect : aspects) + { + AspectDefinition def = dictionaryService.getAspect(aspect); + if (def != null) + { + QName parent = def.getParentName(); + if (parent != null && ASPECT_RECORD_META_DATA.equals(parent)) + { + recordMetaDataAspects.put(aspect, Collections.singleton(TYPE_FILE_PLAN)); + } + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#registerRecordMetadataAspect(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) + */ + @Override + public void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType) + { + ParameterCheck.mandatory("recordMetadataAspect", recordMetadataAspect); + ParameterCheck.mandatory("filePlanType", filePlanType); + + Set filePlanTypes = null; + + if (getRecordMetadataAspectsMap().containsKey(recordMetadataAspect)) + { + // get the current set of file plan types for this aspect + filePlanTypes = getRecordMetadataAspectsMap().get(recordMetadataAspect); + } + else + { + // create a new set for the file plan type + filePlanTypes = new HashSet(1); + getRecordMetadataAspectsMap().put(recordMetadataAspect, filePlanTypes); + } + + // add the file plan type + filePlanTypes.add(filePlanType); + } + + /** + * @deprecated since 2.2, file plan is required to provide context + */ + @Override + @Deprecated + public Set getRecordMetaDataAspects() + { + return getRecordMetadataAspects(TYPE_FILE_PLAN); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isRecordMetadataAspect(org.alfresco.service.namespace.QName) + */ + @Override + public boolean isRecordMetadataAspect(QName aspect) + { + return getRecordMetadataAspectsMap().containsKey(aspect); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isRecordMetadataProperty(org.alfresco.service.namespace.QName) + */ + @Override + public boolean isRecordMetadataProperty(QName property) + { + boolean result = false; + PropertyDefinition propertyDefinition = dictionaryService.getProperty(property); + if (propertyDefinition != null) + { + ClassDefinition classDefinition = propertyDefinition.getContainerClass(); + if (classDefinition != null && + getRecordMetadataAspectsMap().containsKey(classDefinition.getName())) + { + result = true; + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Set getRecordMetadataAspects(NodeRef nodeRef) + { + QName filePlanType = TYPE_FILE_PLAN; + + if (nodeRef != null) + { + NodeRef filePlan = getFilePlan(nodeRef); + filePlanType = nodeService.getType(filePlan); + } + + return getRecordMetadataAspects(filePlanType); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetadataAspects(org.alfresco.service.namespace.QName) + */ + @Override + public Set getRecordMetadataAspects(QName filePlanType) + { + Set result = new HashSet(getRecordMetadataAspectsMap().size()); + + for (Entry> entry : getRecordMetadataAspectsMap().entrySet()) + { + if (entry.getValue().contains(filePlanType)) + { + result.add(entry.getKey()); + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void createRecord(NodeRef filePlan, NodeRef nodeRef) + { + createRecord(filePlan, nodeRef, true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public void createRecord(final NodeRef filePlan, final NodeRef nodeRef, final boolean isLinked) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("isLinked", isLinked); + + // first we do a sanity check to ensure that the user has at least write permissions on the document + if (extendedPermissionService.hasPermission(nodeRef, PermissionService.WRITE) != AccessStatus.ALLOWED) + { + throw new AccessDeniedException("Can not create record from document, because the user " + + AuthenticationUtil.getRunAsUser() + + " does not have Write permissions on the doucment " + + nodeRef.toString()); + } + + + // do the work of creating the record as the system user + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + if (!nodeService.hasAspect(nodeRef, ASPECT_RECORD)) + { + // disable delete rules + ruleService.disableRuleType("outbound"); + try + { + // get the new record container for the file plan + NodeRef newRecordContainer = filePlanService.getUnfiledContainer(filePlan); + if (newRecordContainer == null) + { + throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found."); + } + + // get the documents readers and writers + Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); + + // get the current owner + String owner = ownableService.getOwner(nodeRef); + + // get the documents primary parent assoc + ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); + + // get the latest version record, if there is one + NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef); + + behaviourFilter.disableBehaviour(); + try + { + // move the document into the file plan + nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); + } + finally + { + behaviourFilter.enableBehaviour(); + } + + // save the information about the originating details + Map aspectProperties = new HashMap(3); + aspectProperties.put(PROP_RECORD_ORIGINATING_LOCATION, parentAssoc.getParentRef()); + aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, owner); + aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date()); + nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties); + + // make the document a record + makeRecord(nodeRef); + + if (latestVersionRecord != null) + { + // indicate that this is the 'final' record version + PropertyMap versionRecordProps = new PropertyMap(2); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, I18NUtil.getMessage(FINAL_VERSION)); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, I18NUtil.getMessage(FINAL_DESCRIPTION)); + nodeService.addAspect(nodeRef, RecordableVersionModel.ASPECT_VERSION_RECORD, versionRecordProps); + + // link to previous version + relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord); + } + + if (isLinked) + { + // turn off rules + ruleService.disableRules(); + try + { + // maintain the original primary location + nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName()); + + // set the extended security + extendedSecurityService.set(nodeRef, readersAndWriters); + } + finally + { + ruleService.enableRules(); + } + } + } + finally + { + ruleService.enableRuleType("outbound"); + } + } + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecordFromCopy(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef createRecordFromCopy(final NodeRef filePlan, final NodeRef nodeRef) + { + return authenticationUtil.runAsSystem(new RunAsWork() + { + public NodeRef doWork() throws Exception + { + // get the unfiled record folder + final NodeRef unfiledRecordFolder = filePlanService.getUnfiledContainer(filePlan); + + // get the documents readers and writers + Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); + + // copy version state and create record + NodeRef record = null; + try + { + List originalAssocs = null; + if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_COPIEDFROM)) + { + // take a note of any copyFrom information already on the node + originalAssocs = nodeService.getTargetAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL); + } + + recordsManagementContainerType.disable(); + try + { + // create a copy of the original state and add it to the unfiled record container + FileInfo recordInfo = fileFolderService.copy(nodeRef, unfiledRecordFolder, null); + record = recordInfo.getNodeRef(); + } + finally + { + recordsManagementContainerType.enable(); + } + + // if versionable, then remove without destroying version history, + // because it is being shared with the originating document + behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE); + try + { + nodeService.removeAspect(record, ContentModel.ASPECT_VERSIONABLE); + } + finally + { + behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE); + } + + // make record + makeRecord(record); + + // remove added copy assocs + List recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL); + for (AssociationRef recordAssoc : recordAssocs) + { + nodeService.removeAssociation( + recordAssoc.getSourceRef(), + recordAssoc.getTargetRef(), + ContentModel.ASSOC_ORIGINAL); + } + + // re-add origional assocs or remove aspect + if (originalAssocs == null) + { + nodeService.removeAspect(record, ContentModel.ASPECT_COPIEDFROM); + } + else + { + for (AssociationRef originalAssoc : originalAssocs) + { + nodeService.createAssociation(record, originalAssoc.getTargetRef(), ContentModel.ASSOC_ORIGINAL); + } + } + } + catch (FileNotFoundException e) + { + throw new AlfrescoRuntimeException("Can't create recorded version, because copy fails.", e); + } + + // set extended security on record + extendedSecurityService.set(record, readersAndWriters); + + return record; + } + }); + } + + /** + * Helper to get the latest version record for a given document (ie non-record) + * + * @param nodeRef node reference + * @return NodeRef latest version record, null otherwise + */ + private NodeRef getLatestVersionRecord(NodeRef nodeRef) + { + NodeRef versionRecord = null; + + // wire record up to previous record + VersionHistory versionHistory = versionService.getVersionHistory(nodeRef); + if (versionHistory != null) + { + Collection previousVersions = versionHistory.getAllVersions(); + for (Version previousVersion : previousVersions) + { + // look for the associated record + final NodeRef previousRecord = recordableVersionService.getVersionRecord(previousVersion); + if (previousRecord != null) + { + versionRecord = previousRecord; + break; + } + } + } + + return versionRecord; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createNewRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map, org.alfresco.service.cmr.repository.ContentReader) + */ + @Override + public NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map properties, ContentReader reader) + { + ParameterCheck.mandatory("nodeRef", parent); + ParameterCheck.mandatory("name", name); + + NodeRef result = null; + NodeRef destination = parent; + + if (isFilePlan(parent)) + { + // get the unfiled record container for the file plan + destination = filePlanService.getUnfiledContainer(parent); + if (destination == null) + { + throw new AlfrescoRuntimeException("Unable to create record, because unfiled container could not be found."); + } + } + + // if none set the default record type is cm:content + if (type == null) + { + type = ContentModel.TYPE_CONTENT; + } + else if (!dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)) + { + throw new AlfrescoRuntimeException("Record can only be created from a sub-type of cm:content."); + } + + disablePropertyEditableCheck(); + try + { + // create the new record + final NodeRef record = fileFolderService.create(destination, name, type).getNodeRef(); + + // set the properties + if (properties != null) + { + nodeService.addProperties(record, properties); + } + + // set the content + if (reader != null) + { + ContentWriter writer = fileFolderService.getWriter(record); + writer.setEncoding(reader.getEncoding()); + writer.setMimetype(reader.getMimetype()); + writer.putContent(reader); + } + + result = authenticationUtil.runAsSystem(new RunAsWork() + { + public NodeRef doWork() throws Exception + { + // Check if the "record" aspect has been applied already. + // In case of filing a report the created node will be made + // a record within the "onCreateChildAssociation" method if + // a destination for the report has been selected. + if (!nodeService.hasAspect(record, ASPECT_RECORD)) + { + // make record + makeRecord(record); + } + + return record; + } + + }); + } + finally + { + enablePropertyEditableCheck(); + } + + return result; + } + + /** + * Creates a record from the given document + * + * @param document the document from which a record will be created + */ + @Override + public void makeRecord(NodeRef document) + { + ParameterCheck.mandatory("document", document); + + ruleService.disableRules(); + disablePropertyEditableCheck(); + try + { + // get the record id + String recordId = identifierService.generateIdentifier(ASPECT_RECORD, + nodeService.getPrimaryParent(document).getParentRef()); + + // get the record name + String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME); + + // rename the record + int dotIndex = name.lastIndexOf('.'); + String prefix = name; + String postfix = ""; + if (dotIndex != -1) + { + prefix = name.substring(0, dotIndex); + postfix = name.substring(dotIndex); + } + String recordName = prefix + " (" + recordId + ")" + postfix; + behaviourFilter.disableBehaviour(); + try + { + fileFolderService.rename(document, recordName); + } + finally + { + behaviourFilter.enableBehaviour(); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Rename " + name + " to " + recordName); + } + + // add the record aspect + Map props = new HashMap(2); + props.put(PROP_IDENTIFIER, recordId); + props.put(PROP_ORIGIONAL_NAME, name); + nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props); + + // remove versionable aspect(s) + nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE); + + // remove the owner + ownableService.setOwner(document, OwnableService.NO_OWNER); + } + catch (FileNotFoundException e) + { + throw new AlfrescoRuntimeException("Unable to make record, because rename failed.", e); + } + finally + { + ruleService.enableRules(); + enablePropertyEditableCheck(); + } + + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isFiled(final NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + boolean result = false; + + if (isRecord(nodeRef)) + { + result = AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Boolean doWork() throws Exception + { + return (null != nodeService.getProperty(nodeRef, PROP_DATE_FILED)); + } + }); + } + + return result; + } + + /** + * Helper method to 'file' a new document that arrived in the file plan structure. + * + * TODO atm we only 'file' content as a record .. may need to consider other types if we + * are to support the notion of composite records. + * + * @param record node reference to record (or soon to be record!) + */ + @Override + public void file(NodeRef record) + { + ParameterCheck.mandatory("item", record); + + // we only support filling of content items + // TODO composite record support needs to file containers too + QName type = nodeService.getType(record); + if (ContentModel.TYPE_CONTENT.equals(type) || + dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)) + { + // fire before file record policy + beforeFileRecord.get(getTypeAndApsects(record)).beforeFileRecord(record); + + // check whether this item is already an item or not + if (!isRecord(record)) + { + // make the item a record + makeRecord(record); + } + + // set filed date + if (nodeService.getProperty(record, PROP_DATE_FILED) == null) + { + Calendar fileCalendar = Calendar.getInstance(); + nodeService.setProperty(record, PROP_DATE_FILED, fileCalendar.getTime()); + } + + // file on file record policy + onFileRecord.get(getTypeAndApsects(record)).onFileRecord(record); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#rejectRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public void rejectRecord(final NodeRef nodeRef, final String reason) + { + ParameterCheck.mandatory("NodeRef", nodeRef); + ParameterCheck.mandatoryString("Reason", reason); + + // Save the id of the currently logged in user + final String userId = AuthenticationUtil.getFullyAuthenticatedUser(); + + // do the work of rejecting the record as the system user + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + ruleService.disableRules(); + try + { + // get the latest version record, if there is one + NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef); + + if (latestVersionRecord != null) + { + relationshipService.removeRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord); + } + + // get record property values + final Map properties = nodeService.getProperties(nodeRef); + final String recordId = (String)properties.get(PROP_IDENTIFIER); + final String documentOwner = (String)properties.get(PROP_RECORD_ORIGINATING_USER_ID); + final String originalName = (String)properties.get(PROP_ORIGIONAL_NAME); + final NodeRef originatingLocation = (NodeRef)properties.get(PROP_RECORD_ORIGINATING_LOCATION); + + // we can only reject if the originating location is present + if (originatingLocation != null) + { + // first remove the secondary link association + final List parentAssocs = nodeService.getParentAssocs(nodeRef); + for (ChildAssociationRef childAssociationRef : parentAssocs) + { + if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation)) + { + nodeService.removeChildAssociation(childAssociationRef); + break; + } + } + + removeRmAspectsFrom(nodeRef); + + // get the records primary parent association + final ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); + + // move the record into the collaboration site + nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); + + // rename to the original name + if (originalName != null) + { + fileFolderService.rename(nodeRef, originalName); + + if (logger.isDebugEnabled()) + { + String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + logger.debug("Rename " + name + " to " + originalName); + } + } + + // save the information about the rejection details + final Map aspectProperties = new HashMap<>(3); + aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId); + aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date()); + aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason); + nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties); + + // Restore the owner of the document + if (StringUtils.isBlank(documentOwner)) + { + throw new AlfrescoRuntimeException("Unable to find the creator of document."); + } + ownableService.setOwner(nodeRef, documentOwner); + + // clear the existing permissions + permissionService.clearPermission(nodeRef, null); + + // restore permission inheritance + permissionService.setInheritParentPermissions(nodeRef, true); + + // send an email to the record creator + notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner); + } + } + finally + { + ruleService.enableRules(); + } + + return null; + } + + /** Removes all RM related aspects from the specified node and any rendition children. */ + private void removeRmAspectsFrom(NodeRef nodeRef) + { + // Note that when folder records are supported, we will need to recursively + // remove aspects from their descendants. + final Set aspects = nodeService.getAspects(nodeRef); + for (QName aspect : aspects) + { + if (RM_URI.equals(aspect.getNamespaceURI()) || + RecordableVersionModel.RMV_URI.equals(aspect.getNamespaceURI())) + { + nodeService.removeAspect(nodeRef, aspect); + } + } + for (ChildAssociationRef renditionAssoc : renditionService.getRenditions(nodeRef)) + { + final NodeRef renditionNode = renditionAssoc.getChildRef(); + + // Do not attempt to clean up rendition nodes which are not children of their source node. + final boolean renditionRequiresCleaning = nodeService.exists(renditionNode) && + renditionAssoc.isPrimary(); + + if (renditionRequiresCleaning) + { + removeRmAspectsFrom(renditionNode); + } + } + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isPropertyEditable(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) + */ + @Override + public boolean isPropertyEditable(NodeRef record, QName property) + { + ParameterCheck.mandatory("record", record); + ParameterCheck.mandatory("property", property); + + if (!isRecord(record)) + { + throw new AlfrescoRuntimeException("Can not check if the property " + property.toString() + " is editable, because node reference is not a record."); + } + + NodeRef filePlan = getFilePlan(record); + + // DEBUG ... + boolean debugEnabled = logger.isDebugEnabled(); + if (debugEnabled) + { + logger.debug("Checking whether property " + property.toString() + " is editable for user " + AuthenticationUtil.getRunAsUser()); + + Set roles = filePlanRoleService.getRolesByUser(filePlan, AuthenticationUtil.getRunAsUser()); + + logger.debug(" ... users roles"); + + for (Role role : roles) + { + logger.debug(" ... user has role " + role.getName() + " with capabilities "); + + for (Capability cap : role.getCapabilities()) + { + logger.debug(" ... " + cap.getName()); + } + } + + logger.debug(" ... user has the following set permissions on the file plan"); + + Set perms = permissionService.getAllSetPermissions(filePlan); + for (AccessPermission perm : perms) + { + if ((perm.getPermission().contains(RMPermissionModel.EDIT_NON_RECORD_METADATA) || + perm.getPermission().contains(RMPermissionModel.EDIT_RECORD_METADATA))) + { + logger.debug(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString()); + } + } + + if (permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA).equals(AccessStatus.ALLOWED)) + { + logger.debug(" ... user has the edit non record metadata permission on the file plan"); + } + } + // END DEBUG ... + + boolean result = alwaysEditProperty(property); + if (result) + { + if (debugEnabled) + { + logger.debug(" ... property marked as always editable."); + } + } + else + { + boolean allowRecordEdit = false; + boolean allowNonRecordEdit = false; + + AccessStatus accessNonRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_NON_RECORD_METADATA); + AccessStatus accessDeclaredRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); + AccessStatus accessRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_RECORD_METADATA); + + if (AccessStatus.ALLOWED.equals(accessNonRecord)) + { + if (debugEnabled) + { + logger.debug(" ... user has edit nonrecord metadata capability"); + } + + allowNonRecordEdit = true; + } + + if (AccessStatus.ALLOWED.equals(accessRecord) || + AccessStatus.ALLOWED.equals(accessDeclaredRecord)) + { + if (debugEnabled) + { + logger.debug(" ... user has edit record or declared metadata capability"); + } + + allowRecordEdit = true; + } + + if (allowNonRecordEdit && allowRecordEdit) + { + if (debugEnabled) + { + logger.debug(" ... so all properties can be edited."); + } + + result = true; + } + else if (allowNonRecordEdit && !allowRecordEdit) + { + // can only edit non record properties + if (!isRecordMetadata(filePlan, property)) + { + if (debugEnabled) + { + logger.debug(" ... property is not considered record metadata so editable."); + } + + result = true; + } + else + { + if (debugEnabled) + { + logger.debug(" ... property is considered record metadata so not editable."); + } + } + } + else if (!allowNonRecordEdit && allowRecordEdit) + { + // can only edit record properties + if (isRecordMetadata(filePlan, property)) + { + if (debugEnabled) + { + logger.debug(" ... property is considered record metadata so editable."); + } + + result = true; + } + else + { + if (debugEnabled) + { + logger.debug(" ... property is not considered record metadata so not editable."); + } + } + } + // otherwise we can't edit any properties so just return the empty set + } + return result; + } + + /** + * Helper method that indicates whether a property is considered record metadata or not. + * + * @param property property + * @return boolea true if record metadata, false otherwise + */ + private boolean isRecordMetadata(NodeRef filePlan, QName property) + { + boolean result = false; + + // grab the information about the properties parent type + ClassDefinition parent = null; + PropertyDefinition def = dictionaryService.getProperty(property); + if (def != null) + { + parent = def.getContainerClass(); + } + + // non-electronic record is considered a special case + // TODO move non-electronic record support to a separate model namespace + if (parent != null && TYPE_NON_ELECTRONIC_DOCUMENT.equals(parent.getName())) + { + result = false; + } + else + { + // check the URI's + result = RECORD_MODEL_URIS.contains(property.getNamespaceURI()); + + // check the custom model + if (!result && !ArrayUtils.contains(NON_RECORD_MODEL_URIS, property.getNamespaceURI())) + { + if (parent != null && parent.isAspect()) + { + result = getRecordMetadataAspects(filePlan).contains(parent.getName()); + } + } + } + + return result; + } + + /** + * Determines whether the property should always be allowed to be edited or not. + * + * @param property + * @return + */ + private boolean alwaysEditProperty(QName property) + { + return (ArrayUtils.contains(ALWAYS_EDIT_URIS, property.getNamespaceURI()) || + ArrayUtils.contains(ALWAYS_EDIT_PROPERTIES, property) || + isProtectedProperty(property)); + } + + /** + * Helper method to determine whether a property is protected at a dictionary definition + * level. + * + * @param property property qualified name + * @return booelan true if protected, false otherwise + */ + private boolean isProtectedProperty(QName property) + { + boolean result = false; + PropertyDefinition def = dictionaryService.getProperty(property); + if (def != null) + { + result = def.isProtected(); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isMetadataStub(NodeRef) + */ + @Override + public boolean isMetadataStub(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecords(NodeRef) + */ + @Override + public List getRecords(NodeRef recordFolder) + { + ParameterCheck.mandatory("recordFolder", recordFolder); + + List result = new ArrayList(1); + if (recordFolderService.isRecordFolder(recordFolder)) + { + List assocs = nodeService.getChildAssocs(recordFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef child = assoc.getChildRef(); + if (isRecord(child)) + { + result.add(child); + } + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#addRecordType(NodeRef, QName) + */ + @Override + public void addRecordType(NodeRef nodeRef, QName typeQName) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("typeQName", typeQName); + + if (!nodeService.hasAspect(nodeRef, typeQName)) + { + nodeService.addAspect(nodeRef, typeQName, null); + } + else + { + logger.info(I18NUtil.getMessage(MSG_NODE_HAS_ASPECT, nodeRef.toString(), typeQName.toString())); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#link(NodeRef, NodeRef) + */ + @Override + public void link(NodeRef record, NodeRef recordFolder) + { + ParameterCheck.mandatory("record", record); + ParameterCheck.mandatory("recordFolder", recordFolder); + + // ensure we are linking a record to a record folder + if(isRecord(record) && isRecordFolder(recordFolder)) + { + // ensure that we are not linking a record to an exisiting location + List parents = nodeService.getParentAssocs(record); + for (ChildAssociationRef parent : parents) + { + if (parent.getParentRef().equals(recordFolder)) + { + // we can not link a record to the same location more than once + throw new RecordLinkRuntimeException("Can not link a record to the same record folder more than once"); + } + } + + // validate link conditions + validateLinkConditions(record, recordFolder); + + // get the current name of the record + String name = nodeService.getProperty(record, ContentModel.PROP_NAME).toString(); + + // create a secondary link to the record folder + nodeService.addChild( + recordFolder, + record, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); + } + else + { + // can only link a record to a record folder + throw new RecordLinkRuntimeException("Can only link a record to a record folder."); + } + } + + /** + * + * @param record + * @param recordFolder + */ + private void validateLinkConditions(NodeRef record, NodeRef recordFolder) + { + // ensure that the linking record folders have compatible disposition schedules + DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record); + if (recordDispositionSchedule != null) + { + DispositionSchedule recordFolderDispositionSchedule = dispositionService.getDispositionSchedule(recordFolder); + if (recordFolderDispositionSchedule != null) + { + if (recordDispositionSchedule.isRecordLevelDisposition() != recordFolderDispositionSchedule.isRecordLevelDisposition()) + { + // we can't link a record to an incompatible disposition schedule + throw new RecordLinkRuntimeException("Can not link a record to a record folder with an incompatible disposition schedule. " + + "They must either both be record level or record folder level dispositions."); + } + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#unlink(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void unlink(NodeRef record, NodeRef recordFolder) + { + ParameterCheck.mandatory("record", record); + ParameterCheck.mandatory("recordFolder", recordFolder); + + // ensure we are unlinking a record from a record folder + if(isRecord(record) && isRecordFolder(recordFolder)) + { + // check that we are not trying to unlink the primary parent + NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef(); + if (primaryParent.equals(recordFolder)) + { + throw new RecordLinkRuntimeException("Can't unlink a record from it's owning record folder."); + } + + // remove the link + nodeService.removeChild(recordFolder, record); + } + else + { + // can only unlink a record from a record folder + throw new RecordLinkRuntimeException("Can only unlink a record from a record folder."); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigService.java index 1d5b759e45..1b17ce9d52 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigService.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recordableversion; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Recordable version config service interface - * - * @author Tuna Aksoy - * @since 2.3 - */ -public interface RecordableVersionConfigService -{ - /** - * Gets the recordable versions - * - * @param nodeRef The node reference for which the recordable versions should be retrieved - * @return The list of recordable versions - */ - List getVersions(NodeRef nodeRef); - - /** - * Sets the recordable version for the given node - * - * @param nodeRef The node reference for which the recorable version should be set - * @param version The version to be set - */ - void setVersion(NodeRef nodeRef, String version); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recordableversion; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Recordable version config service interface + * + * @author Tuna Aksoy + * @since 2.3 + */ +public interface RecordableVersionConfigService +{ + /** + * Gets the recordable versions + * + * @param nodeRef The node reference for which the recordable versions should be retrieved + * @return The list of recordable versions + */ + List getVersions(NodeRef nodeRef); + + /** + * Sets the recordable version for the given node + * + * @param nodeRef The node reference for which the recorable version should be set + * @param version The version to be set + */ + void setVersion(NodeRef nodeRef, String version); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java index a73e03a06c..64a16a57bd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recordableversion; - -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; - -/** - * Recordable version config service - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordableVersionConfigServiceImpl implements RecordableVersionConfigService, RecordableVersionModel -{ - /** Node service */ - private NodeService nodeService; - - /** - * Gets the node service - * - * @return The node service - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Sets the node service - * - * @param nodeService The node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#getVersions(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getVersions(NodeRef nodeRef) - { - mandatory("nodeRef", nodeRef); - - RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values(); - List versions = new ArrayList(recordableVersionPolicies.length); - - for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies) - { - String policy = recordableVersionPolicy.toString(); - boolean selected = isVersionPolicySelected(recordableVersionPolicy, nodeRef); - versions.add(new Version(policy, selected)); - } - - return versions; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#setVersion(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public void setVersion(NodeRef nodeRef, String version) - { - mandatory("nodeRef", nodeRef); - mandatoryString("recordedVersion", version); - - RecordableVersionPolicy recordableVersionPolicy = RecordableVersionPolicy.valueOf(version); - getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy); - } - - /** - * Checks if the specified recordable version policy has been selected for the document - * - * @param recordableVersionPolicy The recordable version policy - * @param nodeRef Node reference of the document - * @return true if the specified recordable version policy has been selected for the document, false otherwise - */ - private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef) - { - boolean isVersionPolicySelected = false; - String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); - if (isNotBlank(policy)) - { - if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy)) - { - isVersionPolicySelected = true; - } - } - else - { - if (recordableVersionPolicy.equals(NONE)) - { - isVersionPolicySelected = true; - } - } - return isVersionPolicySelected; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recordableversion; + +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; +import static org.apache.commons.lang.StringUtils.isNotBlank; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; + +/** + * Recordable version config service + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordableVersionConfigServiceImpl implements RecordableVersionConfigService, RecordableVersionModel +{ + /** Node service */ + private NodeService nodeService; + + /** + * Gets the node service + * + * @return The node service + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Sets the node service + * + * @param nodeService The node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#getVersions(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getVersions(NodeRef nodeRef) + { + mandatory("nodeRef", nodeRef); + + RecordableVersionPolicy[] recordableVersionPolicies = RecordableVersionPolicy.values(); + List versions = new ArrayList(recordableVersionPolicies.length); + + for (RecordableVersionPolicy recordableVersionPolicy : recordableVersionPolicies) + { + String policy = recordableVersionPolicy.toString(); + boolean selected = isVersionPolicySelected(recordableVersionPolicy, nodeRef); + versions.add(new Version(policy, selected)); + } + + return versions; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService#setVersion(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public void setVersion(NodeRef nodeRef, String version) + { + mandatory("nodeRef", nodeRef); + mandatoryString("recordedVersion", version); + + RecordableVersionPolicy recordableVersionPolicy = RecordableVersionPolicy.valueOf(version); + getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy); + } + + /** + * Checks if the specified recordable version policy has been selected for the document + * + * @param recordableVersionPolicy The recordable version policy + * @param nodeRef Node reference of the document + * @return true if the specified recordable version policy has been selected for the document, false otherwise + */ + private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef) + { + boolean isVersionPolicySelected = false; + String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); + if (isNotBlank(policy)) + { + if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy)) + { + isVersionPolicySelected = true; + } + } + else + { + if (recordableVersionPolicy.equals(NONE)) + { + isVersionPolicySelected = true; + } + } + return isVersionPolicySelected; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java index f0db508fa6..a2f64b327f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java @@ -1,158 +1,158 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recordfolder; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Record folder service interface - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface RecordFolderService -{ - /** - * Sets up the a record folder from a standard folder. - * - * @param nodeRef node reference of the folder to setup - * - * @since 2.2 - */ - void setupRecordFolder(NodeRef nodeRef); - - /** - * Indicates whether the given node is a record folder or not. - * - * @param nodeRef node reference - * @return boolean true if record folder, false otherwise - * - * @since 2.2 - */ - boolean isRecordFolder(NodeRef nodeRef); - - /** - * Indicates whether the contents of a record folder are all declared. - * - * @param nodeRef node reference (record folder) - * @return boolean true if record folder contents are declared, false otherwise - * - * @since 2.2 - */ - boolean isRecordFolderDeclared(NodeRef nodeRef); - - /** - * Indicates whether a record folder is closed or not. - * - * @param nodeRef node reference (record folder) - * @return boolean true if record folder is closed, false otherwise - * - * @since 2.2 - */ - boolean isRecordFolderClosed(NodeRef nodeRef); - - /** - * Create a record folder in the rm container. The record folder will take the name and type - * provided. - * - * @param rmContainer records management container - * @param name name - * @param type type - * @return NodeRef node reference of record folder - * - * @since 2.2 - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); - - /** - * Create a record folder in the rm container. The record folder will take the name, type and - * properties provided. - * - * @param rmContainer records management container - * @param name name - * @param type type - * @param properties properties - * @return NodeRef node reference of record folder - * - * @since 2.2 - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); - - /** - * Create a record folder in the rm container. The record folder will take the name provided. - * Type defaults to rm:recordFolder. - * - * @param rmContainer records management container - * @param name name - * @return NodeRef node reference of record folder - * - * @since 2.2 - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name); - - /** - * Create a record folder in the rm container. The record folder will take the name and - * properties provided. Type defaults to rm:recordFolder. - * - * @param rmContainer records management container - * @param name name - * @param properties properties - * @return NodeRef node reference of record folder - * - * @since 2.2 - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name, Map properties); - - /** - * Get all the record folders that a record is filed into. - * - * @param record the record node reference - * @return List list of folder record node references - * - * @since 2.2 - */ - // TODO rename to List getParentRecordFolders(NodeRef record); - List getRecordFolders(NodeRef record); - - // TODO NodeRef getRecordFolderByPath(String path); - - // TODO NodeRef getRecordFolderById(String id); - - // TODO NodeRef getRecordFolderByName(NodeRef parent, String name); - - // TODO void deleteRecordFolder(NodeRef recordFolder); - - // TODO List getParentRecordsManagementContainers(NodeRef container); // also applicable to record folders - - // TODO rename to getContainedRecords(NodeRef recordFolder); - - /** - * Closes the record folder. If the given node reference is a record the parent will be retrieved and processed. - * - * @param nodeRef the record folder node reference - * - * @since 2.2 - */ - void closeRecordFolder(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recordfolder; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Record folder service interface + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface RecordFolderService +{ + /** + * Sets up the a record folder from a standard folder. + * + * @param nodeRef node reference of the folder to setup + * + * @since 2.2 + */ + void setupRecordFolder(NodeRef nodeRef); + + /** + * Indicates whether the given node is a record folder or not. + * + * @param nodeRef node reference + * @return boolean true if record folder, false otherwise + * + * @since 2.2 + */ + boolean isRecordFolder(NodeRef nodeRef); + + /** + * Indicates whether the contents of a record folder are all declared. + * + * @param nodeRef node reference (record folder) + * @return boolean true if record folder contents are declared, false otherwise + * + * @since 2.2 + */ + boolean isRecordFolderDeclared(NodeRef nodeRef); + + /** + * Indicates whether a record folder is closed or not. + * + * @param nodeRef node reference (record folder) + * @return boolean true if record folder is closed, false otherwise + * + * @since 2.2 + */ + boolean isRecordFolderClosed(NodeRef nodeRef); + + /** + * Create a record folder in the rm container. The record folder will take the name and type + * provided. + * + * @param rmContainer records management container + * @param name name + * @param type type + * @return NodeRef node reference of record folder + * + * @since 2.2 + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); + + /** + * Create a record folder in the rm container. The record folder will take the name, type and + * properties provided. + * + * @param rmContainer records management container + * @param name name + * @param type type + * @param properties properties + * @return NodeRef node reference of record folder + * + * @since 2.2 + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); + + /** + * Create a record folder in the rm container. The record folder will take the name provided. + * Type defaults to rm:recordFolder. + * + * @param rmContainer records management container + * @param name name + * @return NodeRef node reference of record folder + * + * @since 2.2 + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name); + + /** + * Create a record folder in the rm container. The record folder will take the name and + * properties provided. Type defaults to rm:recordFolder. + * + * @param rmContainer records management container + * @param name name + * @param properties properties + * @return NodeRef node reference of record folder + * + * @since 2.2 + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, Map properties); + + /** + * Get all the record folders that a record is filed into. + * + * @param record the record node reference + * @return List list of folder record node references + * + * @since 2.2 + */ + // TODO rename to List getParentRecordFolders(NodeRef record); + List getRecordFolders(NodeRef record); + + // TODO NodeRef getRecordFolderByPath(String path); + + // TODO NodeRef getRecordFolderById(String id); + + // TODO NodeRef getRecordFolderByName(NodeRef parent, String name); + + // TODO void deleteRecordFolder(NodeRef recordFolder); + + // TODO List getParentRecordsManagementContainers(NodeRef container); // also applicable to record folders + + // TODO rename to getContainedRecords(NodeRef recordFolder); + + /** + * Closes the record folder. If the given node reference is a record the parent will be retrieved and processed. + * + * @param nodeRef the record folder node reference + * + * @since 2.2 + */ + void closeRecordFolder(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java index e432769e1b..76b0496b7d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java @@ -1,312 +1,312 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recordfolder; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Record Folder Service Implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordFolderServiceImpl extends ServiceBaseImpl - implements RecordFolderService, - RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(RecordFolderServiceImpl.class); - - /** I18N */ - private static final String MSG_RECORD_FOLDER_EXPECTED = "rm.service.record-folder-expected"; - private static final String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root"; - private static final String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type"; - private static final String MSG_RECORD_FOLDER_TYPE = "rm.service.record-folder-type"; - private static final String MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER = "rm.service.close-record-folder-not-folder"; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Record Service */ - private RecordService recordService; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#setupRecordFolder(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void setupRecordFolder(NodeRef nodeRef) - { - // initialise disposition details - if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) - { - DispositionSchedule di = dispositionService.getDispositionSchedule(nodeRef); - if (di != null && !di.isRecordLevelDisposition()) - { - nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderDeclared(NodeRef) - */ - @Override - public boolean isRecordFolderDeclared(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Check we have a record folder - if (!isRecordFolder(nodeRef)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); - } - - boolean result = true; - - // Check that each record in the record folder in declared - List records = recordService.getRecords(nodeRef); - for (NodeRef record : records) - { - if (!recordService.isDeclared(record)) - { - result = false; - break; - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderClosed(NodeRef) - */ - @Override - public boolean isRecordFolderClosed(final NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Check we have a record folder - if (!isRecordFolder(nodeRef)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); - } - - return AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Boolean doWork() throws Exception - { - return ((Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED)); - } - }); - } - - @Override - public NodeRef createRecordFolder(NodeRef rmContainer, String name, - QName type) - { - ParameterCheck.mandatory("rmContainer", rmContainer); - ParameterCheck.mandatoryString("name", name); - ParameterCheck.mandatory("type", type); - - return createRecordFolder(rmContainer, name, type, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, QName, Map) - */ - @Override - public NodeRef createRecordFolder(NodeRef rmContainer, String name, - QName type, Map properties) - { - ParameterCheck.mandatory("rmContainer", rmContainer); - ParameterCheck.mandatoryString("name", name); - ParameterCheck.mandatory("type", type); - // "properties" is not mandatory - - // Check that we are not trying to create a record folder in a root container - if (filePlanService.isFilePlan(rmContainer)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_ROOT)); - } - - // Check that the parent is a container - QName parentType = nodeService.getType(rmContainer); - if (!TYPE_RECORD_CATEGORY.equals(parentType) && - !dictionaryService.isSubClass(parentType, TYPE_RECORD_CATEGORY)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_TYPE, parentType.toString())); - } - - // Check that the the provided type is a sub-type of rm:recordFolder - if (!TYPE_RECORD_FOLDER.equals(type) && - !dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_TYPE, type.toString())); - } - - Map props = new HashMap(1); - if (properties != null && properties.size() != 0) - { - props.putAll(properties); - } - props.put(ContentModel.PROP_NAME, name); - - return nodeService.createNode( - rmContainer, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, (name.length() > QName.MAX_LENGTH ? name.substring(0, QName.MAX_LENGTH) : name)), - type, - props).getChildRef(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String) - */ - @Override - public NodeRef createRecordFolder(NodeRef rmContainer, String name) - { - ParameterCheck.mandatory("rmContainer", rmContainer); - ParameterCheck.mandatoryString("name", name); - - // TODO defaults to rm:recordFolder, but in future could auto-detect sub-type of folder based on context - return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, Map) - */ - @Override - public NodeRef createRecordFolder(NodeRef rmContainer, String name, - Map properties) - { - ParameterCheck.mandatory("rmContainer", rmContainer); - ParameterCheck.mandatoryString("name", name); - ParameterCheck.mandatory("properties", properties); - - return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER, properties); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#getRecordFolders(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getRecordFolders(NodeRef record) - { - ParameterCheck.mandatory("record", record); - - List result = new ArrayList(1); - if (recordService.isRecord(record)) - { - List assocs = nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef parent = assoc.getParentRef(); - if (isRecordFolder(parent)) - { - result.add(parent); - } - } - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#closeRecordFolder(NodeRef) - */ - @Override - public void closeRecordFolder(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (isRecord(nodeRef)) - { - ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); - if (assocRef != null) - { - nodeRef = assocRef.getParentRef(); - } - } - - if (isRecordFolder(nodeRef)) - { - if (!isRecordFolderClosed(nodeRef)) - { - nodeService.setProperty(nodeRef, PROP_IS_CLOSED, true); - } - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, nodeRef.toString())); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recordfolder; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Record Folder Service Implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordFolderServiceImpl extends ServiceBaseImpl + implements RecordFolderService, + RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RecordFolderServiceImpl.class); + + /** I18N */ + private static final String MSG_RECORD_FOLDER_EXPECTED = "rm.service.record-folder-expected"; + private static final String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root"; + private static final String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type"; + private static final String MSG_RECORD_FOLDER_TYPE = "rm.service.record-folder-type"; + private static final String MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER = "rm.service.close-record-folder-not-folder"; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Record Service */ + private RecordService recordService; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#setupRecordFolder(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void setupRecordFolder(NodeRef nodeRef) + { + // initialise disposition details + if (!nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) + { + DispositionSchedule di = dispositionService.getDispositionSchedule(nodeRef); + if (di != null && !di.isRecordLevelDisposition()) + { + nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderDeclared(NodeRef) + */ + @Override + public boolean isRecordFolderDeclared(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Check we have a record folder + if (!isRecordFolder(nodeRef)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); + } + + boolean result = true; + + // Check that each record in the record folder in declared + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + if (!recordService.isDeclared(record)) + { + result = false; + break; + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderClosed(NodeRef) + */ + @Override + public boolean isRecordFolderClosed(final NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Check we have a record folder + if (!isRecordFolder(nodeRef)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); + } + + return AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Boolean doWork() throws Exception + { + return ((Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED)); + } + }); + } + + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + QName type) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("type", type); + + return createRecordFolder(rmContainer, name, type, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, QName, Map) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + QName type, Map properties) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("type", type); + // "properties" is not mandatory + + // Check that we are not trying to create a record folder in a root container + if (filePlanService.isFilePlan(rmContainer)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_ROOT)); + } + + // Check that the parent is a container + QName parentType = nodeService.getType(rmContainer); + if (!TYPE_RECORD_CATEGORY.equals(parentType) && + !dictionaryService.isSubClass(parentType, TYPE_RECORD_CATEGORY)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_TYPE, parentType.toString())); + } + + // Check that the the provided type is a sub-type of rm:recordFolder + if (!TYPE_RECORD_FOLDER.equals(type) && + !dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_TYPE, type.toString())); + } + + Map props = new HashMap(1); + if (properties != null && properties.size() != 0) + { + props.putAll(properties); + } + props.put(ContentModel.PROP_NAME, name); + + return nodeService.createNode( + rmContainer, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, (name.length() > QName.MAX_LENGTH ? name.substring(0, QName.MAX_LENGTH) : name)), + type, + props).getChildRef(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + + // TODO defaults to rm:recordFolder, but in future could auto-detect sub-type of folder based on context + return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, Map) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + Map properties) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("properties", properties); + + return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER, properties); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#getRecordFolders(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getRecordFolders(NodeRef record) + { + ParameterCheck.mandatory("record", record); + + List result = new ArrayList(1); + if (recordService.isRecord(record)) + { + List assocs = nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef parent = assoc.getParentRef(); + if (isRecordFolder(parent)) + { + result.add(parent); + } + } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#closeRecordFolder(NodeRef) + */ + @Override + public void closeRecordFolder(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + if (isRecord(nodeRef)) + { + ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); + if (assocRef != null) + { + nodeRef = assocRef.getParentRef(); + } + } + + if (isRecordFolder(nodeRef)) + { + if (!isRecordFolderClosed(nodeRef)) + { + nodeService.setProperty(nodeRef, PROP_IS_CLOSED, true); + } + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, nodeRef.toString())); + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/Relationship.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/Relationship.java index 7265491122..e25032cefb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/Relationship.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/Relationship.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Interface representing the relationship - * - * @author Tuna Aksoy - * @since 2.3 - */ -public interface Relationship -{ - /** - * Gets the unique name of the relationship - * - * @return The unique name of the relationship - */ - String getUniqueName(); - - /** - * Gets the source of the relationship - * - * @return The source of the relationship - */ - NodeRef getSource(); - - /** - * Gets the target of the relationship - * - * @return The target of the relationship - */ - NodeRef getTarget(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Interface representing the relationship + * + * @author Tuna Aksoy + * @since 2.3 + */ +public interface Relationship +{ + /** + * Gets the unique name of the relationship + * + * @return The unique name of the relationship + */ + String getUniqueName(); + + /** + * Gets the source of the relationship + * + * @return The source of the relationship + */ + NodeRef getSource(); + + /** + * Gets the target of the relationship + * + * @return The target of the relationship + */ + NodeRef getTarget(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinition.java index 0a2ad1e943..9a596cef75 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinition.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -/** - * Interface representing the relationship definition - * - * @author Tuna Aksoy - * @since 2.3 - */ -public interface RelationshipDefinition -{ - /** - * Gets the unique name of the relationship definition - * - * @return The unique name of the relationship definition - */ - String getUniqueName(); - - /** - * Gets the type of the relationship definition - * - * @return The type of the relationship definition - */ - RelationshipType getType(); - - /** - * Gets the display name of the relationship definition - * - * @return The display name of the relationship definition - */ - RelationshipDisplayName getDisplayName(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +/** + * Interface representing the relationship definition + * + * @author Tuna Aksoy + * @since 2.3 + */ +public interface RelationshipDefinition +{ + /** + * Gets the unique name of the relationship definition + * + * @return The unique name of the relationship definition + */ + String getUniqueName(); + + /** + * Gets the type of the relationship definition + * + * @return The type of the relationship definition + */ + RelationshipType getType(); + + /** + * Gets the display name of the relationship definition + * + * @return The display name of the relationship definition + */ + RelationshipDisplayName getDisplayName(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinitionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinitionImpl.java index 3b90dec107..ef48718130 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinitionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDefinitionImpl.java @@ -1,115 +1,115 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; - -/** - * Relationship definition implementation - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipDefinitionImpl implements RelationshipDefinition -{ - /** The unique name of the relationship definition */ - private String uniqueName; - - /** The type of the relationship definition */ - private RelationshipType type; - - /** The display name of the relationship definition */ - private RelationshipDisplayName displayName; - - /** - * Constructor for creating a relationship definition - * - * @param uniqueName The unique name of the relationship definition - * @param type The type of the relationship definition - * @param displayName The display name of the relationship definition - */ - public RelationshipDefinitionImpl(String uniqueName, RelationshipType type, RelationshipDisplayName displayName) - { - mandatoryString("uniqueName", uniqueName); - mandatory("type", type); - mandatory("displayName", displayName); - - setUniqueName(uniqueName); - setType(type); - setDisplayName(displayName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getUniqueName() - */ - @Override - public String getUniqueName() - { - return this.uniqueName; - } - - /** - * Sets the name of the relationship definition - * - * @param uniqueName The name of the relationship definition - */ - private void setUniqueName(String uniqueName) - { - this.uniqueName = uniqueName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getType() - */ - @Override - public RelationshipType getType() - { - return this.type; - } - - /** - * Sets the type of the relationship definition - * - * @param type The type of the relationship definition - */ - private void setType(RelationshipType type) - { - this.type = type; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getDisplayName() - */ - @Override - public RelationshipDisplayName getDisplayName() - { - return this.displayName; - } - - /** - * Sets the display name of the relationship definition - * - * @param displayName The display name of the relationship definition - */ - private void setDisplayName(RelationshipDisplayName displayName) - { - this.displayName = displayName; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; + +/** + * Relationship definition implementation + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipDefinitionImpl implements RelationshipDefinition +{ + /** The unique name of the relationship definition */ + private String uniqueName; + + /** The type of the relationship definition */ + private RelationshipType type; + + /** The display name of the relationship definition */ + private RelationshipDisplayName displayName; + + /** + * Constructor for creating a relationship definition + * + * @param uniqueName The unique name of the relationship definition + * @param type The type of the relationship definition + * @param displayName The display name of the relationship definition + */ + public RelationshipDefinitionImpl(String uniqueName, RelationshipType type, RelationshipDisplayName displayName) + { + mandatoryString("uniqueName", uniqueName); + mandatory("type", type); + mandatory("displayName", displayName); + + setUniqueName(uniqueName); + setType(type); + setDisplayName(displayName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getUniqueName() + */ + @Override + public String getUniqueName() + { + return this.uniqueName; + } + + /** + * Sets the name of the relationship definition + * + * @param uniqueName The name of the relationship definition + */ + private void setUniqueName(String uniqueName) + { + this.uniqueName = uniqueName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getType() + */ + @Override + public RelationshipType getType() + { + return this.type; + } + + /** + * Sets the type of the relationship definition + * + * @param type The type of the relationship definition + */ + private void setType(RelationshipType type) + { + this.type = type; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getDisplayName() + */ + @Override + public RelationshipDisplayName getDisplayName() + { + return this.displayName; + } + + /** + * Sets the display name of the relationship definition + * + * @param displayName The display name of the relationship definition + */ + private void setDisplayName(RelationshipDisplayName displayName) + { + this.displayName = displayName; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDisplayName.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDisplayName.java index 2ed160e07a..46495d7385 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDisplayName.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipDisplayName.java @@ -1,107 +1,107 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import static org.alfresco.util.ParameterCheck.mandatoryString; - -/** - * POJO representing the relationship display name - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipDisplayName -{ - /** The source text of the relationship */ - private String sourceText; - - /** The target text of the relationship */ - private String targetText; - - /** - * Constructor for creating the relationship display name. - * In case of a bidirectional relationship the source - * text and target text will be the same. - * - * @param sourceText The source text of the relationship - * @param targetText The target text of the relationship - */ - public RelationshipDisplayName(String sourceText, String targetText) - { - mandatoryString("sourceText", sourceText); - mandatoryString("targetText", targetText); - - setSourceText(sourceText); - setTargetText(targetText); - } - - /** - * Gets the source text of the relationship - * - * @return The source text of the relationship - */ - public String getSourceText() - { - return this.sourceText; - } - - /** - * Sets the source text of the relationship - * - * @param sourceText The source text of the relationship - */ - private void setSourceText(String sourceText) - { - this.sourceText = sourceText; - } - - /** - * Gets the target text of the relationship - * - * @return The target text of the relationship - */ - public String getTargetText() - { - return this.targetText; - } - - /** - * Sets the target text of the relationship - * - * @param targetText The target text of the relationship - */ - private void setTargetText(String targetText) - { - this.targetText = targetText; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append("(") - .append("source=").append(sourceText) - .append(", target=").append(targetText) - .append(")"); - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import static org.alfresco.util.ParameterCheck.mandatoryString; + +/** + * POJO representing the relationship display name + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipDisplayName +{ + /** The source text of the relationship */ + private String sourceText; + + /** The target text of the relationship */ + private String targetText; + + /** + * Constructor for creating the relationship display name. + * In case of a bidirectional relationship the source + * text and target text will be the same. + * + * @param sourceText The source text of the relationship + * @param targetText The target text of the relationship + */ + public RelationshipDisplayName(String sourceText, String targetText) + { + mandatoryString("sourceText", sourceText); + mandatoryString("targetText", targetText); + + setSourceText(sourceText); + setTargetText(targetText); + } + + /** + * Gets the source text of the relationship + * + * @return The source text of the relationship + */ + public String getSourceText() + { + return this.sourceText; + } + + /** + * Sets the source text of the relationship + * + * @param sourceText The source text of the relationship + */ + private void setSourceText(String sourceText) + { + this.sourceText = sourceText; + } + + /** + * Gets the target text of the relationship + * + * @return The target text of the relationship + */ + public String getTargetText() + { + return this.targetText; + } + + /** + * Sets the target text of the relationship + * + * @param targetText The target text of the relationship + */ + private void setTargetText(String targetText) + { + this.targetText = targetText; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("(") + .append("source=").append(sourceText) + .append(", target=").append(targetText) + .append(")"); + return sb.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipImpl.java index 574a804cf5..6c7abe5811 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipImpl.java @@ -1,157 +1,157 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; - -import java.io.Serializable; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Relationship implementation - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipImpl implements Relationship, Serializable -{ - /** serial UID */ - private static final long serialVersionUID = 9120649510198344978L; - - /** The unique name of the relationship */ - private String uniqueName; - - /** The source of the relationship */ - private NodeRef source; - - /** The target of the relationship */ - private NodeRef target; - - /** - * Constructor for creating a relationship - * - * @param uniqueName The unique name of the relationship - * @param source The source of the relationship - * @param target The target of the relationship - */ - public RelationshipImpl(String uniqueName, NodeRef source, NodeRef target) - { - mandatoryString("uniqueName", uniqueName); - mandatory("source", source); - mandatory("target", target); - - setUniqueName(uniqueName); - setSource(source); - setTarget(target); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getUniqueName() - */ - @Override - public String getUniqueName() - { - return uniqueName; - } - - /** - * Sets the unique name of the relationship - * - * @param uniqueName The unique name of the relationship - */ - private void setUniqueName(String uniqueName) - { - this.uniqueName = uniqueName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getSource() - */ - @Override - public NodeRef getSource() - { - return source; - } - - /** - * Sets the source of the relationship - * - * @param source The source of the relationship - */ - private void setSource(NodeRef source) - { - this.source = source; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getTarget() - */ - @Override - public NodeRef getTarget() - { - return target; - } - - /** - * Sets the target of the relationship - * - * @param target The target of the relationship - */ - private void setTarget(NodeRef target) - { - this.target = target; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj instanceof Relationship) - { - RelationshipImpl that = (RelationshipImpl) obj; - return (this.uniqueName.equals(that.uniqueName) - && this.source.equals(that.source) - && this.target.equals(that.target)); - } - else - { - return false; - } - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - int prime = 31; - int result = prime + uniqueName.hashCode(); - result = (prime*result) + source.hashCode(); - return (prime*result) + target.hashCode(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; + +import java.io.Serializable; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Relationship implementation + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipImpl implements Relationship, Serializable +{ + /** serial UID */ + private static final long serialVersionUID = 9120649510198344978L; + + /** The unique name of the relationship */ + private String uniqueName; + + /** The source of the relationship */ + private NodeRef source; + + /** The target of the relationship */ + private NodeRef target; + + /** + * Constructor for creating a relationship + * + * @param uniqueName The unique name of the relationship + * @param source The source of the relationship + * @param target The target of the relationship + */ + public RelationshipImpl(String uniqueName, NodeRef source, NodeRef target) + { + mandatoryString("uniqueName", uniqueName); + mandatory("source", source); + mandatory("target", target); + + setUniqueName(uniqueName); + setSource(source); + setTarget(target); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getUniqueName() + */ + @Override + public String getUniqueName() + { + return uniqueName; + } + + /** + * Sets the unique name of the relationship + * + * @param uniqueName The unique name of the relationship + */ + private void setUniqueName(String uniqueName) + { + this.uniqueName = uniqueName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getSource() + */ + @Override + public NodeRef getSource() + { + return source; + } + + /** + * Sets the source of the relationship + * + * @param source The source of the relationship + */ + private void setSource(NodeRef source) + { + this.source = source; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getTarget() + */ + @Override + public NodeRef getTarget() + { + return target; + } + + /** + * Sets the target of the relationship + * + * @param target The target of the relationship + */ + private void setTarget(NodeRef target) + { + this.target = target; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj instanceof Relationship) + { + RelationshipImpl that = (RelationshipImpl) obj; + return (this.uniqueName.equals(that.uniqueName) + && this.source.equals(that.source) + && this.target.equals(that.target)); + } + else + { + return false; + } + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() + { + int prime = 31; + int result = prime + uniqueName.hashCode(); + result = (prime*result) + source.hashCode(); + return (prime*result) + target.hashCode(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipService.java index dcdab7b285..b5622a49b2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipService.java @@ -1,147 +1,147 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * The relationship service interface - * - * @author Tuna Aksoy - * @since 2.3 - */ -public interface RelationshipService -{ - /** System relationship names */ - static final String RELATIONSHIP_VERSIONS = "versions"; - - /** - * Gets all the existing relationship definitions - * - * @return All existing relationship definitions - */ - Set getRelationshipDefinitions(); - - /** - * Gets the relationship definition for the given unique name - * - * @param uniqueName The unique name of the relationship definition - * @return The relationship definition for the given unique name if it exist, null otherwise - */ - RelationshipDefinition getRelationshipDefinition(String uniqueName); - - /** - * Creates a relationship definition using the display name - * - * @param displayName The display name of the relationship definition - * @return The new relationship definition - */ - RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName); - - /** - * Updates an existing relationship definition - * - * @param uniqueName The unique name of the relationship definition - * @param displayName The display name of the relationship definition - * @return The updated relationship definition - */ - RelationshipDefinition updateRelationshipDefinition(String uniqueName, RelationshipDisplayName displayName); - - /** - * Removes a relationship definition - * - * @param uniqueName The unique name of the relationship definition - * @return true if the relationship definition was removed successfully, false otherwise - */ - boolean removeRelationshipDefinition(String uniqueName); - - /** - * Checks if a relationship exists or not - * - * @param uniqueName The unique name of the relationship definition - * @return true if the relationship definition exists, false otherwise - */ - boolean existsRelationshipDefinition(String uniqueName); - - /** - * Gets all the relationships that come out from the given node reference - * - * @param nodeRef The node reference - * @return All relationships that come out from the given node reference - */ - Set getRelationshipsFrom(NodeRef nodeRef); - - /** - * Gets all the relationships that come out from the given node reference - * that match the a given name filter. - *

- * Exact match only. - * - * @param nodeRef The node reference - * @param nameFilter Name filter for results - * @return All relationships that come out from the given node reference - * - * @since 2.3.1 - */ - Set getRelationshipsFrom(NodeRef nodeRef, String nameFilter); - - /** - * Gets all the relationships that go into the given node reference - * - * @param nodeRef The node reference - * @return All relationships that go into the given node reference - */ - Set getRelationshipsTo(NodeRef nodeRef); - - /** - * Gets all the relationships that go into the given node reference - * that match the a given name filter. - *

- * Exact match only. - * - * @param nodeRef The node reference - * @param nameFilter Name filter for results - * @return All relationships that go into the given node reference - * - * @since 2.3.1 - */ - Set getRelationshipsTo(NodeRef nodeRef, String nameFilter); - - /** - * Adds a relationship from the given node source - * to the give node target with the given unique name - * - * @param uniqueName The unique name of the relationship - * @param source The node reference which the relationship come from - * @param target The node reference which the relationship go to - */ - void addRelationship(String uniqueName, NodeRef source, NodeRef target); - - /** - * Removes the relationship from the given node source - * to the given node target with the given unique name - * - * @param uniqueName The unique name of the relationship - * @param source The node reference which the relationship come from - * @param target The node reference which the relationship go to - */ - void removeRelationship(String uniqueName, NodeRef source, NodeRef target); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * The relationship service interface + * + * @author Tuna Aksoy + * @since 2.3 + */ +public interface RelationshipService +{ + /** System relationship names */ + static final String RELATIONSHIP_VERSIONS = "versions"; + + /** + * Gets all the existing relationship definitions + * + * @return All existing relationship definitions + */ + Set getRelationshipDefinitions(); + + /** + * Gets the relationship definition for the given unique name + * + * @param uniqueName The unique name of the relationship definition + * @return The relationship definition for the given unique name if it exist, null otherwise + */ + RelationshipDefinition getRelationshipDefinition(String uniqueName); + + /** + * Creates a relationship definition using the display name + * + * @param displayName The display name of the relationship definition + * @return The new relationship definition + */ + RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName); + + /** + * Updates an existing relationship definition + * + * @param uniqueName The unique name of the relationship definition + * @param displayName The display name of the relationship definition + * @return The updated relationship definition + */ + RelationshipDefinition updateRelationshipDefinition(String uniqueName, RelationshipDisplayName displayName); + + /** + * Removes a relationship definition + * + * @param uniqueName The unique name of the relationship definition + * @return true if the relationship definition was removed successfully, false otherwise + */ + boolean removeRelationshipDefinition(String uniqueName); + + /** + * Checks if a relationship exists or not + * + * @param uniqueName The unique name of the relationship definition + * @return true if the relationship definition exists, false otherwise + */ + boolean existsRelationshipDefinition(String uniqueName); + + /** + * Gets all the relationships that come out from the given node reference + * + * @param nodeRef The node reference + * @return All relationships that come out from the given node reference + */ + Set getRelationshipsFrom(NodeRef nodeRef); + + /** + * Gets all the relationships that come out from the given node reference + * that match the a given name filter. + *

+ * Exact match only. + * + * @param nodeRef The node reference + * @param nameFilter Name filter for results + * @return All relationships that come out from the given node reference + * + * @since 2.3.1 + */ + Set getRelationshipsFrom(NodeRef nodeRef, String nameFilter); + + /** + * Gets all the relationships that go into the given node reference + * + * @param nodeRef The node reference + * @return All relationships that go into the given node reference + */ + Set getRelationshipsTo(NodeRef nodeRef); + + /** + * Gets all the relationships that go into the given node reference + * that match the a given name filter. + *

+ * Exact match only. + * + * @param nodeRef The node reference + * @param nameFilter Name filter for results + * @return All relationships that go into the given node reference + * + * @since 2.3.1 + */ + Set getRelationshipsTo(NodeRef nodeRef, String nameFilter); + + /** + * Adds a relationship from the given node source + * to the give node target with the given unique name + * + * @param uniqueName The unique name of the relationship + * @param source The node reference which the relationship come from + * @param target The node reference which the relationship go to + */ + void addRelationship(String uniqueName, NodeRef source, NodeRef target); + + /** + * Removes the relationship from the given node source + * to the given node target with the given unique name + * + * @param uniqueName The unique name of the relationship + * @param source The node reference which the relationship come from + * @param target The node reference which the relationship go to + */ + void removeRelationship(String uniqueName, NodeRef source, NodeRef target); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java index df7487e6ad..e33cddc617 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java @@ -1,960 +1,960 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_FROZEN; -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang.StringUtils.isBlank; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRemoveReference; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRemoveReference; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminBase; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil; -import org.alfresco.repo.dictionary.M2Aspect; -import org.alfresco.repo.dictionary.M2ClassAssociation; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.policy.ClassPolicyDelegate; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; - -/** - * The relationship service implementation - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipServiceImpl extends RecordsManagementAdminBase implements RelationshipService -{ - /** Policy component */ - private PolicyComponent policyComponent; - - /** - * Gets the policy component instance - * - * @return The policy component instance - */ - private PolicyComponent getPolicyComponent() - { - return this.policyComponent; - } - - /** - * Sets the policy component instance - * - * @param policyComponent The policy component instance - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** Policy delegates */ - private ClassPolicyDelegate beforeCreateReferenceDelegate; - private ClassPolicyDelegate onCreateReferenceDelegate; - private ClassPolicyDelegate beforeRemoveReferenceDelegate; - private ClassPolicyDelegate onRemoveReferenceDelegate; - - /** - * Initialisation method - */ - public void init() - { - // Register the various policies - beforeCreateReferenceDelegate = getPolicyComponent().registerClassPolicy(BeforeCreateReference.class); - onCreateReferenceDelegate = getPolicyComponent().registerClassPolicy(OnCreateReference.class); - beforeRemoveReferenceDelegate = getPolicyComponent().registerClassPolicy(BeforeRemoveReference.class); - onRemoveReferenceDelegate = getPolicyComponent().registerClassPolicy(OnRemoveReference.class); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinitions() - */ - @Override - public Set getRelationshipDefinitions() - { - Set relationshipDefinitions = new HashSet(); - - Set> associationsEntrySet = getCustomAssociations().entrySet(); - for (Map.Entry associationEntry : associationsEntrySet) - { - AssociationDefinition associationDefinition = associationEntry.getValue(); - RelationshipDefinition relationshipDefinition = createRelationshipDefinition(associationDefinition); - if (relationshipDefinition != null) - { - relationshipDefinitions.add(relationshipDefinition); - } - } - - return relationshipDefinitions; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinition(java.lang.String) - */ - @Override - public RelationshipDefinition getRelationshipDefinition(String uniqueName) - { - mandatoryString("uniqueName", uniqueName); - - RelationshipDefinition relationshipDefinition = null; - - AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); - if (associationDefinition != null) - { - relationshipDefinition = createRelationshipDefinition(associationDefinition); - } - - return relationshipDefinition; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName) - */ - @Override - public RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName) - { - mandatory("displayName", displayName); - - String title; - RelationshipType type = determineRelationshipTypeFromDisplayName(displayName); - - switch (type) - { - case BIDIRECTIONAL: - - title = displayName.getSourceText(); - break; - - case PARENTCHILD: - - String sourceText = displayName.getSourceText(); - String targetText = displayName.getTargetText(); - title = composeAssociationDefinitionTitle(sourceText, targetText); - break; - - default: - - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type: '") - .append(type.toString()) - .append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - // If this title is already taken... - if (existsTitle(title)) - { - StringBuilder sb = new StringBuilder(); - sb.append("Cannot create a relationship definition for the display name: '") - .append(displayName.toString()) - .append("' as there is already a relationship definition with this display name."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - // Defaults to RM_CUSTOM_URI - NodeRef modelRef = getCustomModelRef(""); - M2Model deserializedModel = readCustomContentModel(modelRef); - String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(getNamespaceService()); - M2Aspect customAssocsAspect = deserializedModel.getAspect(customAspectName); - - if (customAssocsAspect == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("The aspect: '") - .append(customAspectName) - .append("' is undefined."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - QName relationshipDefinitionQName = generateRelationshipDefinitionQNameFor(title); - String generatedShortQName = relationshipDefinitionQName.toPrefixString(getNamespaceService()); - - M2ClassAssociation customAssoc = customAssocsAspect.getAssociation(generatedShortQName); - if (customAssoc != null) - { - StringBuilder sb = new StringBuilder(); - sb.append("The association: '") - .append(customAssoc.getName()) - .append("' already exists."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - M2ClassAssociation newAssoc; - - switch (type) - { - case BIDIRECTIONAL: - - newAssoc = customAssocsAspect.createAssociation(generatedShortQName); - break; - - case PARENTCHILD: - - newAssoc = customAssocsAspect.createChildAssociation(generatedShortQName); - break; - - default: - - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type: '") - .append(type.toString()) - .append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - newAssoc.setSourceMandatory(false); - newAssoc.setTargetMandatory(false); - - // MOB-1573 - newAssoc.setSourceMany(true); - newAssoc.setTargetMany(true); - - newAssoc.setTitle(title); - newAssoc.setTargetClassName(RecordsManagementModel.ASPECT_RECORD.toPrefixString(getNamespaceService())); - writeCustomContentModel(modelRef, deserializedModel); - - return new RelationshipDefinitionImpl(relationshipDefinitionQName.getLocalName(), type, displayName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#updateReleationshipDefinition(java.lang.String) - */ - @Override - public RelationshipDefinition updateRelationshipDefinition(String uniqueName, RelationshipDisplayName displayName) - { - mandatoryString("uniqueName", uniqueName); - - RelationshipDefinition relationshipDefinition = getRelationshipDefinition(uniqueName); - if (relationshipDefinition == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("The relationship definition for the unique name '") - .append(uniqueName) - .append("' was not found."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - String title; - RelationshipType type = relationshipDefinition.getType(); - - switch (type) - { - case BIDIRECTIONAL: - - title = displayName.getSourceText(); - - if (isBlank(title)) - { - StringBuilder sb = new StringBuilder(); - sb.append("Label text '") - .append(title) - .append(" cannot be blank."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - break; - - case PARENTCHILD: - - String sourceText = displayName.getSourceText(); - String targetText = displayName.getTargetText(); - - if (isBlank(sourceText) || isBlank(targetText)) - { - StringBuilder sb = new StringBuilder(); - sb.append("Neither source text '") - .append(sourceText) - .append("' nor target text '") - .append(targetText) - .append(" can be blank."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - title = composeAssociationDefinitionTitle(sourceText, targetText); - - break; - - default: - - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type: '") - .append(type.toString()) - .append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - if (existsTitle(title)) - { - StringBuilder sb = new StringBuilder(); - sb.append("Cannot update the relationship definition as '") - .append(title) - .append("' already exists."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - QName associationDefinitionQName = getAssociationDefinitionName(uniqueName); - QName updatedAssociationDefinitionQName = persistUpdatedAssocTitle(associationDefinitionQName, title); - RelationshipDefinition updatedRelationshipDefinition = getRelationshipDefinition(updatedAssociationDefinitionQName.getLocalName()); - - if (updatedRelationshipDefinition == null) - { - throw new AlfrescoRuntimeException("The relationship definition could not be updated successfully."); - } - - return updatedRelationshipDefinition; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationshipDefinition(java.lang.String) - */ - @Override - public boolean removeRelationshipDefinition(String uniqueName) - { - mandatoryString("uniqueName", uniqueName); - - throw new UnsupportedOperationException("It is not possible to remove a relationship."); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#existsRelationshipDefinition(java.lang.String) - */ - @Override - public boolean existsRelationshipDefinition(String uniqueName) - { - mandatoryString("uniqueName", uniqueName); - - boolean exists = false; - - RelationshipDefinition relationshipDefinition = getRelationshipDefinition(uniqueName); - if (relationshipDefinition != null) - { - exists = true; - } - - return exists; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Set getRelationshipsFrom(NodeRef nodeRef) - { - return getRelationshipsFrom(nodeRef, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef, String) - */ - @Override - public Set getRelationshipsFrom(NodeRef nodeRef, String nameFilter) - { - mandatory("nodeRef", nodeRef); - - Set relationships = new HashSet(); - - List customReferencesFrom = getNodeService().getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); - relationships.addAll(generateRelationshipFromAssociationRef(customReferencesFrom, nameFilter)); - - List customChildReferences = getNodeService().getChildAssocs(nodeRef); - relationships.addAll(generateRelationshipFromParentChildAssociationRef(customChildReferences, nameFilter)); - - return relationships; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Set getRelationshipsTo(NodeRef nodeRef) - { - return getRelationshipsTo(nodeRef, null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef, String) - */ - @Override - public Set getRelationshipsTo(NodeRef nodeRef, String nameFilter) - { - mandatory("nodeRef", nodeRef); - - Set relationships = new HashSet(); - - List customReferencesTo = getNodeService().getSourceAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); - relationships.addAll(generateRelationshipFromAssociationRef(customReferencesTo, nameFilter)); - - List customParentReferences = getNodeService().getParentAssocs(nodeRef); - relationships.addAll(generateRelationshipFromParentChildAssociationRef(customParentReferences, nameFilter)); - - return relationships; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#addRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void addRelationship(String uniqueName, NodeRef source, NodeRef target) - { - mandatoryString("uniqueName", uniqueName); - mandatory("source", source); - mandatory("target", target); - - // check the source node exists - if (!getNodeService().exists(source)) - { - throw new AlfrescoRuntimeException("Can't create relationship '" + uniqueName + "', because source node doesn't exist."); - } - - // check the target node exists - if (!getNodeService().exists(target)) - { - throw new AlfrescoRuntimeException("Can't create relationship " + uniqueName + ", because target node doesn't exist."); - } - - if (getNodeService().hasAspect(target, ASPECT_FROZEN)) - { - StringBuilder sb = new StringBuilder(); - sb.append("Relationship cannot be created as the target '"). - append(getNodeService().getProperty(target, ContentModel.PROP_NAME)). - append("' is in a hold."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - // Check that the association definition for the given unique name exists. - AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); - if (associationDefinition == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("No association definition found for '"). - append(uniqueName). - append("'."); - throw new IllegalArgumentException(sb.toString()); - } - - // Get the association definition name - QName associationDefinitionName = associationDefinition.getName(); - - // Check if an instance of this association already exists in the same direction - boolean associationAlreadyExists = associationExists(associationDefinition, source, target); - - if (associationAlreadyExists) - { - StringBuilder sb = new StringBuilder(); - sb.append("Association '"). - append(associationDefinitionName.getLocalName()). - append("' already exists from '"). - append(source). - append("' to '"). - append(target). - append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - // Invoke before create reference policy - invokeBeforeCreateReference(source, target, associationDefinitionName); - - if (associationDefinition.isChild()) - { - getNodeService().addChild(source, target, associationDefinitionName, associationDefinitionName); - } - else - { - getNodeService().createAssociation(source, target, associationDefinitionName); - } - - // Invoke on create reference policy - invokeOnCreateReference(source, target, associationDefinitionName); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void removeRelationship(String uniqueName, NodeRef source, NodeRef target) - { - mandatoryString("uniqueName", uniqueName); - mandatory("source", source); - mandatory("target", target); - - // Check that the association definition for the given unique name exists. - AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); - if (associationDefinition == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("No association definition found for '"). - append(uniqueName). - append("'."); - throw new IllegalArgumentException(sb.toString()); - } - - // Get the association definition name - final QName associationDefinitionName = associationDefinition.getName(); - final NodeRef targetNode = target; - final NodeRef sourceNode = source; - - invokeBeforeRemoveReference(sourceNode, targetNode, associationDefinitionName); - - if (associationDefinition.isChild()) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - List children = getNodeService().getChildAssocs(sourceNode); - for (ChildAssociationRef chRef : children) - { - if (associationDefinitionName.equals(chRef.getTypeQName()) && chRef.getChildRef().equals(targetNode)) - { - getNodeService().removeChildAssociation(chRef); - } - } - - return null; - } - }); - } - else - { - getNodeService().removeAssociation(source, targetNode, associationDefinitionName); - } - - invokeOnRemoveReference(source, targetNode, associationDefinitionName); - } - - /** - * Creates the relationship definition from the association definition - * - * @param associationDefinition The association definition - * @return The relationship definition if associationDefinition exists, null otherwise - */ - private RelationshipDefinition createRelationshipDefinition(AssociationDefinition associationDefinition) - { - RelationshipDefinition relationshipDefinition = null; - - if (associationDefinition != null) - { - String uniqueName = associationDefinition.getName().getLocalName(); - - RelationshipType type = getRelationshipType(associationDefinition); - - String title = associationDefinition.getTitle(getDictionaryService()); - RelationshipDisplayName displayName = getRelationshipDisplayName(type, title); - - relationshipDefinition = new RelationshipDefinitionImpl(uniqueName, type, displayName); - } - - return relationshipDefinition; - } - - /** - * Gets the relationship type from the association definition - * - * @param associationDefinition The association definition - * @return The type of the relationship definition - */ - private RelationshipType getRelationshipType(AssociationDefinition associationDefinition) - { - RelationshipType type; - - if (associationDefinition instanceof ChildAssociationDefinition) - { - type = RelationshipType.PARENTCHILD; - } - else - { - type = RelationshipType.BIDIRECTIONAL; - } - - return type; - } - - /** - * Gets the relationship display name of the relationship definition - * - * @param type The type of the relationship definition - * @param title The title of the association definition - * @return The relationship display name of the relationship definition - */ - private RelationshipDisplayName getRelationshipDisplayName(RelationshipType type, String title) - { - String sourceText = null; - String targetText = null; - - switch (type) - { - case BIDIRECTIONAL: - - sourceText = title; - targetText = title; - break; - - case PARENTCHILD: - - String[] sourceAndTarget = splitAssociationDefinitionTitle(title); - sourceText = sourceAndTarget[0]; - targetText = sourceAndTarget[1]; - break; - - default: - - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type: '") - .append(type.toString()) - .append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - return new RelationshipDisplayName(sourceText, targetText); - } - - /** - * Generates relationships from the given association references - * - * @param associationRefs Association references - * @return Relationships generated from the given association references - */ - private Set generateRelationshipFromAssociationRef(List associationRefs, String nameFilter) - { - Set relationships = new HashSet(); - - for (AssociationRef associationRef : associationRefs) - { - String uniqueName = associationRef.getTypeQName().getLocalName(); - if (existsRelationshipDefinition(uniqueName) && - (nameFilter == null || uniqueName.equals(nameFilter))) - { - NodeRef from = associationRef.getSourceRef(); - NodeRef to = associationRef.getTargetRef(); - relationships.add(new RelationshipImpl(uniqueName, from, to)); - } - } - - return relationships; - } - - /** - * Generates relationships from the given child association references - * - * @param childAssociationRefs Child association references - * @return Relationships generated from the given child association references - */ - private Set generateRelationshipFromParentChildAssociationRef(List childAssociationRefs, String nameFilter) - { - Set relationships = new HashSet(); - - for (ChildAssociationRef childAssociationRef : childAssociationRefs) - { - String uniqueName = childAssociationRef.getQName().getLocalName(); - if (existsRelationshipDefinition(uniqueName)&& - (nameFilter == null || uniqueName.equals(nameFilter))) - { - NodeRef from = childAssociationRef.getParentRef(); - NodeRef to = childAssociationRef.getChildRef(); - relationships.add(new RelationshipImpl(uniqueName, from, to)); - } - } - - return relationships; - } - - /** - * Determines the relationship type from the display name - * - * @param displayName The display name of the relationship - * @return The relationship type from the display name - */ - private RelationshipType determineRelationshipTypeFromDisplayName(RelationshipDisplayName displayName) - { - RelationshipType relationshipType; - - String sourceText = displayName.getSourceText(); - String targetText = displayName.getTargetText(); - - String errorMsg = "Relationship type could not be determined from the display name. It is neither biderectional nor parent/child relationship"; - - if (isBlank(sourceText) || isBlank(targetText)) - { - throw new AlfrescoRuntimeException(errorMsg); - } - - if (sourceText.equals(targetText)) - { - relationshipType = RelationshipType.BIDIRECTIONAL; - } - else - { - relationshipType = RelationshipType.PARENTCHILD; - } - - return relationshipType; - } - - /** - * Invoke before create reference policy - * - * @param source The source node reference - * @param target The target node reference - * @param associationDefinitionName The association definition name - */ - private void invokeBeforeCreateReference(NodeRef source, NodeRef target, QName associationDefinitionName) - { - // Get QNames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); - // Execute policy for node type and aspects - BeforeCreateReference policy = beforeCreateReferenceDelegate.get(qnames); - policy.beforeCreateReference(source, target, associationDefinitionName); - } - - /** - * Invoke on create reference policy - * - * @param source The source node reference - * @param target The target node reference - * @param associationDefinitionName The association definition name - */ - private void invokeOnCreateReference(NodeRef source, NodeRef target, QName associationDefinitionName) - { - // Get QNames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); - // Execute policy for node type and aspects - OnCreateReference policy = onCreateReferenceDelegate.get(qnames); - policy.onCreateReference(source, target, associationDefinitionName); - } - - /** - * Invoke before remove reference policy - * - * @param source The source node reference - * @param target The target node reference - * @param associationDefinitionName The association definition name - */ - private void invokeBeforeRemoveReference(NodeRef source, NodeRef target, QName associationDefinitionName) - { - // Get QNames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); - // Execute policy for node type and aspects - BeforeRemoveReference policy = beforeRemoveReferenceDelegate.get(qnames); - policy.beforeRemoveReference(source, target, associationDefinitionName); - } - - /** - * Invoke on remove reference policy - * - * @param source The source node reference - * @param target The target node reference - * @param associationDefinitionName The association definition name - */ - private void invokeOnRemoveReference(NodeRef source, NodeRef target, QName associationDefinitionName) - { - // Get QNames to invoke against - Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); - // Execute policy for node type and aspects - OnRemoveReference policy = onRemoveReferenceDelegate.get(qnames); - policy.onRemoveReference(source, target, associationDefinitionName); - } - - /** - * Check if an instance of the association already exists from the given - * source node reference to the given target node reference - * - * @param associationDefinition The association definition - * @param source The source node reference - * @param target The target node reference - * @return true if an association already exists, false otherwise - */ - private boolean associationExists(AssociationDefinition associationDefinition, NodeRef source, NodeRef target) - { - boolean associationAlreadyExists = false; - - QName associationDefinitionName = associationDefinition.getName(); - if (associationDefinition.isChild()) - { - List childAssocs = getNodeService().getChildAssocs(source, associationDefinitionName, associationDefinitionName); - for (ChildAssociationRef chAssRef : childAssocs) - { - if (chAssRef.getChildRef().equals(target)) - { - associationAlreadyExists = true; - } - } - } - else - { - List assocs = getNodeService().getTargetAssocs(source, associationDefinitionName); - for (AssociationRef assRef : assocs) - { - if (assRef.getTargetRef().equals(target)) - { - associationAlreadyExists = true; - } - } - } - - return associationAlreadyExists; - } - - /** - * Gets the association definition for the given unique name - * - * @param uniqueName The unique name - * @return The association definition for the given unique name if exists, null otherwise - */ - private AssociationDefinition getAssociationDefinition(String uniqueName) - { - AssociationDefinition associationDefinition = null; - - Set> associationsEntrySet = getCustomAssociations().entrySet(); - for (Map.Entry associationEntry : associationsEntrySet) - { - String localName = associationEntry.getKey().getLocalName(); - if (uniqueName.equals(localName)) - { - associationDefinition = associationEntry.getValue(); - break; - } - } - - return associationDefinition; - } - - /** - * Gets the qualified name of the association definition for the given unique name - * - * @param uniqueName The unique name - * @return The qualified name of the association definition for the given unique name - */ - private QName getAssociationDefinitionName(String uniqueName) - { - AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); - - if (associationDefinition == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("The qualified name for '") - .append(uniqueName) - .append("' was not found."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - return associationDefinition.getName(); - } - - /** - * This method writes the specified String into the association's title property. - * For RM custom properties and references, Title is used to store the identifier. - * - * NOTE: Currently RMC custom associations only - * @param associationDefinitionQName Qualified name for the association definition - * @param newTitle The new title - * @return Qualified name for the association definition - */ - private QName persistUpdatedAssocTitle(QName associationDefinitionQName, String newTitle) - { - mandatory("associationDefinitionQName", associationDefinitionQName); - - AssociationDefinition assocDefn = getDictionaryService().getAssociation(associationDefinitionQName); - if (assocDefn == null) - { - StringBuilder sb = new StringBuilder(); - sb.append("Cannot find the association definiton for '"). - append(associationDefinitionQName.getLocalName()). - append("'."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - // defaults to RM_CUSTOM_URI - NodeRef modelRef = getCustomModelRef(""); - M2Model deserializedModel = readCustomContentModel(modelRef); - - String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(getNamespaceService()); - M2Aspect customAssocsAspect = deserializedModel.getAspect(customAspectName); - - for (M2ClassAssociation assoc : customAssocsAspect.getAssociations()) - { - if (associationDefinitionQName.toPrefixString(getNamespaceService()).equals(assoc.getName()) && newTitle != null) - { - assoc.setTitle(newTitle); - } - } - writeCustomContentModel(modelRef, deserializedModel); - - if (logger.isInfoEnabled()) - { - logger.info("persistUpdatedAssocTitle: " + associationDefinitionQName + "=" + newTitle + " to aspect: " + customAspectName); - } - - return associationDefinitionQName; - } - - /** - * Generates a qualified name for the given relationship definition unique name - * - * @param uniqueName The unique name of the relationship definition - * @return The qualified name of relationship definition - */ - private QName generateRelationshipDefinitionQNameFor(String uniqueName) - { - mandatoryString("uniqueName", uniqueName); - - QName existingQName = null; - - Set customAssociationsQNames = getCustomAssociations().keySet(); - for (QName customAssociationsQName : customAssociationsQNames) - { - if (uniqueName.equals(customAssociationsQName.getLocalName())) - { - existingQName = customAssociationsQName; - } - } - - if (existingQName != null) - { - StringBuilder sb = new StringBuilder(); - sb.append("Cannot create qualified name for given unique name '"). - append(uniqueName). - append("' as it already exists."); - throw new AlfrescoRuntimeException(sb.toString()); - } - - return QName.createQName(RM_CUSTOM_PREFIX, GUID.generate(), getNamespaceService()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_FROZEN; +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; +import static org.apache.commons.lang.StringUtils.isBlank; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRemoveReference; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRemoveReference; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminBase; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil; +import org.alfresco.repo.dictionary.M2Aspect; +import org.alfresco.repo.dictionary.M2ClassAssociation; +import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.repo.policy.ClassPolicyDelegate; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.GUID; + +/** + * The relationship service implementation + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipServiceImpl extends RecordsManagementAdminBase implements RelationshipService +{ + /** Policy component */ + private PolicyComponent policyComponent; + + /** + * Gets the policy component instance + * + * @return The policy component instance + */ + private PolicyComponent getPolicyComponent() + { + return this.policyComponent; + } + + /** + * Sets the policy component instance + * + * @param policyComponent The policy component instance + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** Policy delegates */ + private ClassPolicyDelegate beforeCreateReferenceDelegate; + private ClassPolicyDelegate onCreateReferenceDelegate; + private ClassPolicyDelegate beforeRemoveReferenceDelegate; + private ClassPolicyDelegate onRemoveReferenceDelegate; + + /** + * Initialisation method + */ + public void init() + { + // Register the various policies + beforeCreateReferenceDelegate = getPolicyComponent().registerClassPolicy(BeforeCreateReference.class); + onCreateReferenceDelegate = getPolicyComponent().registerClassPolicy(OnCreateReference.class); + beforeRemoveReferenceDelegate = getPolicyComponent().registerClassPolicy(BeforeRemoveReference.class); + onRemoveReferenceDelegate = getPolicyComponent().registerClassPolicy(OnRemoveReference.class); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinitions() + */ + @Override + public Set getRelationshipDefinitions() + { + Set relationshipDefinitions = new HashSet(); + + Set> associationsEntrySet = getCustomAssociations().entrySet(); + for (Map.Entry associationEntry : associationsEntrySet) + { + AssociationDefinition associationDefinition = associationEntry.getValue(); + RelationshipDefinition relationshipDefinition = createRelationshipDefinition(associationDefinition); + if (relationshipDefinition != null) + { + relationshipDefinitions.add(relationshipDefinition); + } + } + + return relationshipDefinitions; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinition(java.lang.String) + */ + @Override + public RelationshipDefinition getRelationshipDefinition(String uniqueName) + { + mandatoryString("uniqueName", uniqueName); + + RelationshipDefinition relationshipDefinition = null; + + AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); + if (associationDefinition != null) + { + relationshipDefinition = createRelationshipDefinition(associationDefinition); + } + + return relationshipDefinition; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName) + */ + @Override + public RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName) + { + mandatory("displayName", displayName); + + String title; + RelationshipType type = determineRelationshipTypeFromDisplayName(displayName); + + switch (type) + { + case BIDIRECTIONAL: + + title = displayName.getSourceText(); + break; + + case PARENTCHILD: + + String sourceText = displayName.getSourceText(); + String targetText = displayName.getTargetText(); + title = composeAssociationDefinitionTitle(sourceText, targetText); + break; + + default: + + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type: '") + .append(type.toString()) + .append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + // If this title is already taken... + if (existsTitle(title)) + { + StringBuilder sb = new StringBuilder(); + sb.append("Cannot create a relationship definition for the display name: '") + .append(displayName.toString()) + .append("' as there is already a relationship definition with this display name."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + // Defaults to RM_CUSTOM_URI + NodeRef modelRef = getCustomModelRef(""); + M2Model deserializedModel = readCustomContentModel(modelRef); + String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(getNamespaceService()); + M2Aspect customAssocsAspect = deserializedModel.getAspect(customAspectName); + + if (customAssocsAspect == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("The aspect: '") + .append(customAspectName) + .append("' is undefined."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + QName relationshipDefinitionQName = generateRelationshipDefinitionQNameFor(title); + String generatedShortQName = relationshipDefinitionQName.toPrefixString(getNamespaceService()); + + M2ClassAssociation customAssoc = customAssocsAspect.getAssociation(generatedShortQName); + if (customAssoc != null) + { + StringBuilder sb = new StringBuilder(); + sb.append("The association: '") + .append(customAssoc.getName()) + .append("' already exists."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + M2ClassAssociation newAssoc; + + switch (type) + { + case BIDIRECTIONAL: + + newAssoc = customAssocsAspect.createAssociation(generatedShortQName); + break; + + case PARENTCHILD: + + newAssoc = customAssocsAspect.createChildAssociation(generatedShortQName); + break; + + default: + + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type: '") + .append(type.toString()) + .append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + newAssoc.setSourceMandatory(false); + newAssoc.setTargetMandatory(false); + + // MOB-1573 + newAssoc.setSourceMany(true); + newAssoc.setTargetMany(true); + + newAssoc.setTitle(title); + newAssoc.setTargetClassName(RecordsManagementModel.ASPECT_RECORD.toPrefixString(getNamespaceService())); + writeCustomContentModel(modelRef, deserializedModel); + + return new RelationshipDefinitionImpl(relationshipDefinitionQName.getLocalName(), type, displayName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#updateReleationshipDefinition(java.lang.String) + */ + @Override + public RelationshipDefinition updateRelationshipDefinition(String uniqueName, RelationshipDisplayName displayName) + { + mandatoryString("uniqueName", uniqueName); + + RelationshipDefinition relationshipDefinition = getRelationshipDefinition(uniqueName); + if (relationshipDefinition == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("The relationship definition for the unique name '") + .append(uniqueName) + .append("' was not found."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + String title; + RelationshipType type = relationshipDefinition.getType(); + + switch (type) + { + case BIDIRECTIONAL: + + title = displayName.getSourceText(); + + if (isBlank(title)) + { + StringBuilder sb = new StringBuilder(); + sb.append("Label text '") + .append(title) + .append(" cannot be blank."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + break; + + case PARENTCHILD: + + String sourceText = displayName.getSourceText(); + String targetText = displayName.getTargetText(); + + if (isBlank(sourceText) || isBlank(targetText)) + { + StringBuilder sb = new StringBuilder(); + sb.append("Neither source text '") + .append(sourceText) + .append("' nor target text '") + .append(targetText) + .append(" can be blank."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + title = composeAssociationDefinitionTitle(sourceText, targetText); + + break; + + default: + + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type: '") + .append(type.toString()) + .append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + if (existsTitle(title)) + { + StringBuilder sb = new StringBuilder(); + sb.append("Cannot update the relationship definition as '") + .append(title) + .append("' already exists."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + QName associationDefinitionQName = getAssociationDefinitionName(uniqueName); + QName updatedAssociationDefinitionQName = persistUpdatedAssocTitle(associationDefinitionQName, title); + RelationshipDefinition updatedRelationshipDefinition = getRelationshipDefinition(updatedAssociationDefinitionQName.getLocalName()); + + if (updatedRelationshipDefinition == null) + { + throw new AlfrescoRuntimeException("The relationship definition could not be updated successfully."); + } + + return updatedRelationshipDefinition; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationshipDefinition(java.lang.String) + */ + @Override + public boolean removeRelationshipDefinition(String uniqueName) + { + mandatoryString("uniqueName", uniqueName); + + throw new UnsupportedOperationException("It is not possible to remove a relationship."); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#existsRelationshipDefinition(java.lang.String) + */ + @Override + public boolean existsRelationshipDefinition(String uniqueName) + { + mandatoryString("uniqueName", uniqueName); + + boolean exists = false; + + RelationshipDefinition relationshipDefinition = getRelationshipDefinition(uniqueName); + if (relationshipDefinition != null) + { + exists = true; + } + + return exists; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Set getRelationshipsFrom(NodeRef nodeRef) + { + return getRelationshipsFrom(nodeRef, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef, String) + */ + @Override + public Set getRelationshipsFrom(NodeRef nodeRef, String nameFilter) + { + mandatory("nodeRef", nodeRef); + + Set relationships = new HashSet(); + + List customReferencesFrom = getNodeService().getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); + relationships.addAll(generateRelationshipFromAssociationRef(customReferencesFrom, nameFilter)); + + List customChildReferences = getNodeService().getChildAssocs(nodeRef); + relationships.addAll(generateRelationshipFromParentChildAssociationRef(customChildReferences, nameFilter)); + + return relationships; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Set getRelationshipsTo(NodeRef nodeRef) + { + return getRelationshipsTo(nodeRef, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef, String) + */ + @Override + public Set getRelationshipsTo(NodeRef nodeRef, String nameFilter) + { + mandatory("nodeRef", nodeRef); + + Set relationships = new HashSet(); + + List customReferencesTo = getNodeService().getSourceAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); + relationships.addAll(generateRelationshipFromAssociationRef(customReferencesTo, nameFilter)); + + List customParentReferences = getNodeService().getParentAssocs(nodeRef); + relationships.addAll(generateRelationshipFromParentChildAssociationRef(customParentReferences, nameFilter)); + + return relationships; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#addRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void addRelationship(String uniqueName, NodeRef source, NodeRef target) + { + mandatoryString("uniqueName", uniqueName); + mandatory("source", source); + mandatory("target", target); + + // check the source node exists + if (!getNodeService().exists(source)) + { + throw new AlfrescoRuntimeException("Can't create relationship '" + uniqueName + "', because source node doesn't exist."); + } + + // check the target node exists + if (!getNodeService().exists(target)) + { + throw new AlfrescoRuntimeException("Can't create relationship " + uniqueName + ", because target node doesn't exist."); + } + + if (getNodeService().hasAspect(target, ASPECT_FROZEN)) + { + StringBuilder sb = new StringBuilder(); + sb.append("Relationship cannot be created as the target '"). + append(getNodeService().getProperty(target, ContentModel.PROP_NAME)). + append("' is in a hold."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + // Check that the association definition for the given unique name exists. + AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); + if (associationDefinition == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("No association definition found for '"). + append(uniqueName). + append("'."); + throw new IllegalArgumentException(sb.toString()); + } + + // Get the association definition name + QName associationDefinitionName = associationDefinition.getName(); + + // Check if an instance of this association already exists in the same direction + boolean associationAlreadyExists = associationExists(associationDefinition, source, target); + + if (associationAlreadyExists) + { + StringBuilder sb = new StringBuilder(); + sb.append("Association '"). + append(associationDefinitionName.getLocalName()). + append("' already exists from '"). + append(source). + append("' to '"). + append(target). + append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + // Invoke before create reference policy + invokeBeforeCreateReference(source, target, associationDefinitionName); + + if (associationDefinition.isChild()) + { + getNodeService().addChild(source, target, associationDefinitionName, associationDefinitionName); + } + else + { + getNodeService().createAssociation(source, target, associationDefinitionName); + } + + // Invoke on create reference policy + invokeOnCreateReference(source, target, associationDefinitionName); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void removeRelationship(String uniqueName, NodeRef source, NodeRef target) + { + mandatoryString("uniqueName", uniqueName); + mandatory("source", source); + mandatory("target", target); + + // Check that the association definition for the given unique name exists. + AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); + if (associationDefinition == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("No association definition found for '"). + append(uniqueName). + append("'."); + throw new IllegalArgumentException(sb.toString()); + } + + // Get the association definition name + final QName associationDefinitionName = associationDefinition.getName(); + final NodeRef targetNode = target; + final NodeRef sourceNode = source; + + invokeBeforeRemoveReference(sourceNode, targetNode, associationDefinitionName); + + if (associationDefinition.isChild()) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + List children = getNodeService().getChildAssocs(sourceNode); + for (ChildAssociationRef chRef : children) + { + if (associationDefinitionName.equals(chRef.getTypeQName()) && chRef.getChildRef().equals(targetNode)) + { + getNodeService().removeChildAssociation(chRef); + } + } + + return null; + } + }); + } + else + { + getNodeService().removeAssociation(source, targetNode, associationDefinitionName); + } + + invokeOnRemoveReference(source, targetNode, associationDefinitionName); + } + + /** + * Creates the relationship definition from the association definition + * + * @param associationDefinition The association definition + * @return The relationship definition if associationDefinition exists, null otherwise + */ + private RelationshipDefinition createRelationshipDefinition(AssociationDefinition associationDefinition) + { + RelationshipDefinition relationshipDefinition = null; + + if (associationDefinition != null) + { + String uniqueName = associationDefinition.getName().getLocalName(); + + RelationshipType type = getRelationshipType(associationDefinition); + + String title = associationDefinition.getTitle(getDictionaryService()); + RelationshipDisplayName displayName = getRelationshipDisplayName(type, title); + + relationshipDefinition = new RelationshipDefinitionImpl(uniqueName, type, displayName); + } + + return relationshipDefinition; + } + + /** + * Gets the relationship type from the association definition + * + * @param associationDefinition The association definition + * @return The type of the relationship definition + */ + private RelationshipType getRelationshipType(AssociationDefinition associationDefinition) + { + RelationshipType type; + + if (associationDefinition instanceof ChildAssociationDefinition) + { + type = RelationshipType.PARENTCHILD; + } + else + { + type = RelationshipType.BIDIRECTIONAL; + } + + return type; + } + + /** + * Gets the relationship display name of the relationship definition + * + * @param type The type of the relationship definition + * @param title The title of the association definition + * @return The relationship display name of the relationship definition + */ + private RelationshipDisplayName getRelationshipDisplayName(RelationshipType type, String title) + { + String sourceText = null; + String targetText = null; + + switch (type) + { + case BIDIRECTIONAL: + + sourceText = title; + targetText = title; + break; + + case PARENTCHILD: + + String[] sourceAndTarget = splitAssociationDefinitionTitle(title); + sourceText = sourceAndTarget[0]; + targetText = sourceAndTarget[1]; + break; + + default: + + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type: '") + .append(type.toString()) + .append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + return new RelationshipDisplayName(sourceText, targetText); + } + + /** + * Generates relationships from the given association references + * + * @param associationRefs Association references + * @return Relationships generated from the given association references + */ + private Set generateRelationshipFromAssociationRef(List associationRefs, String nameFilter) + { + Set relationships = new HashSet(); + + for (AssociationRef associationRef : associationRefs) + { + String uniqueName = associationRef.getTypeQName().getLocalName(); + if (existsRelationshipDefinition(uniqueName) && + (nameFilter == null || uniqueName.equals(nameFilter))) + { + NodeRef from = associationRef.getSourceRef(); + NodeRef to = associationRef.getTargetRef(); + relationships.add(new RelationshipImpl(uniqueName, from, to)); + } + } + + return relationships; + } + + /** + * Generates relationships from the given child association references + * + * @param childAssociationRefs Child association references + * @return Relationships generated from the given child association references + */ + private Set generateRelationshipFromParentChildAssociationRef(List childAssociationRefs, String nameFilter) + { + Set relationships = new HashSet(); + + for (ChildAssociationRef childAssociationRef : childAssociationRefs) + { + String uniqueName = childAssociationRef.getQName().getLocalName(); + if (existsRelationshipDefinition(uniqueName)&& + (nameFilter == null || uniqueName.equals(nameFilter))) + { + NodeRef from = childAssociationRef.getParentRef(); + NodeRef to = childAssociationRef.getChildRef(); + relationships.add(new RelationshipImpl(uniqueName, from, to)); + } + } + + return relationships; + } + + /** + * Determines the relationship type from the display name + * + * @param displayName The display name of the relationship + * @return The relationship type from the display name + */ + private RelationshipType determineRelationshipTypeFromDisplayName(RelationshipDisplayName displayName) + { + RelationshipType relationshipType; + + String sourceText = displayName.getSourceText(); + String targetText = displayName.getTargetText(); + + String errorMsg = "Relationship type could not be determined from the display name. It is neither biderectional nor parent/child relationship"; + + if (isBlank(sourceText) || isBlank(targetText)) + { + throw new AlfrescoRuntimeException(errorMsg); + } + + if (sourceText.equals(targetText)) + { + relationshipType = RelationshipType.BIDIRECTIONAL; + } + else + { + relationshipType = RelationshipType.PARENTCHILD; + } + + return relationshipType; + } + + /** + * Invoke before create reference policy + * + * @param source The source node reference + * @param target The target node reference + * @param associationDefinitionName The association definition name + */ + private void invokeBeforeCreateReference(NodeRef source, NodeRef target, QName associationDefinitionName) + { + // Get QNames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); + // Execute policy for node type and aspects + BeforeCreateReference policy = beforeCreateReferenceDelegate.get(qnames); + policy.beforeCreateReference(source, target, associationDefinitionName); + } + + /** + * Invoke on create reference policy + * + * @param source The source node reference + * @param target The target node reference + * @param associationDefinitionName The association definition name + */ + private void invokeOnCreateReference(NodeRef source, NodeRef target, QName associationDefinitionName) + { + // Get QNames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); + // Execute policy for node type and aspects + OnCreateReference policy = onCreateReferenceDelegate.get(qnames); + policy.onCreateReference(source, target, associationDefinitionName); + } + + /** + * Invoke before remove reference policy + * + * @param source The source node reference + * @param target The target node reference + * @param associationDefinitionName The association definition name + */ + private void invokeBeforeRemoveReference(NodeRef source, NodeRef target, QName associationDefinitionName) + { + // Get QNames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); + // Execute policy for node type and aspects + BeforeRemoveReference policy = beforeRemoveReferenceDelegate.get(qnames); + policy.beforeRemoveReference(source, target, associationDefinitionName); + } + + /** + * Invoke on remove reference policy + * + * @param source The source node reference + * @param target The target node reference + * @param associationDefinitionName The association definition name + */ + private void invokeOnRemoveReference(NodeRef source, NodeRef target, QName associationDefinitionName) + { + // Get QNames to invoke against + Set qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), source); + // Execute policy for node type and aspects + OnRemoveReference policy = onRemoveReferenceDelegate.get(qnames); + policy.onRemoveReference(source, target, associationDefinitionName); + } + + /** + * Check if an instance of the association already exists from the given + * source node reference to the given target node reference + * + * @param associationDefinition The association definition + * @param source The source node reference + * @param target The target node reference + * @return true if an association already exists, false otherwise + */ + private boolean associationExists(AssociationDefinition associationDefinition, NodeRef source, NodeRef target) + { + boolean associationAlreadyExists = false; + + QName associationDefinitionName = associationDefinition.getName(); + if (associationDefinition.isChild()) + { + List childAssocs = getNodeService().getChildAssocs(source, associationDefinitionName, associationDefinitionName); + for (ChildAssociationRef chAssRef : childAssocs) + { + if (chAssRef.getChildRef().equals(target)) + { + associationAlreadyExists = true; + } + } + } + else + { + List assocs = getNodeService().getTargetAssocs(source, associationDefinitionName); + for (AssociationRef assRef : assocs) + { + if (assRef.getTargetRef().equals(target)) + { + associationAlreadyExists = true; + } + } + } + + return associationAlreadyExists; + } + + /** + * Gets the association definition for the given unique name + * + * @param uniqueName The unique name + * @return The association definition for the given unique name if exists, null otherwise + */ + private AssociationDefinition getAssociationDefinition(String uniqueName) + { + AssociationDefinition associationDefinition = null; + + Set> associationsEntrySet = getCustomAssociations().entrySet(); + for (Map.Entry associationEntry : associationsEntrySet) + { + String localName = associationEntry.getKey().getLocalName(); + if (uniqueName.equals(localName)) + { + associationDefinition = associationEntry.getValue(); + break; + } + } + + return associationDefinition; + } + + /** + * Gets the qualified name of the association definition for the given unique name + * + * @param uniqueName The unique name + * @return The qualified name of the association definition for the given unique name + */ + private QName getAssociationDefinitionName(String uniqueName) + { + AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName); + + if (associationDefinition == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("The qualified name for '") + .append(uniqueName) + .append("' was not found."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + return associationDefinition.getName(); + } + + /** + * This method writes the specified String into the association's title property. + * For RM custom properties and references, Title is used to store the identifier. + * + * NOTE: Currently RMC custom associations only + * @param associationDefinitionQName Qualified name for the association definition + * @param newTitle The new title + * @return Qualified name for the association definition + */ + private QName persistUpdatedAssocTitle(QName associationDefinitionQName, String newTitle) + { + mandatory("associationDefinitionQName", associationDefinitionQName); + + AssociationDefinition assocDefn = getDictionaryService().getAssociation(associationDefinitionQName); + if (assocDefn == null) + { + StringBuilder sb = new StringBuilder(); + sb.append("Cannot find the association definiton for '"). + append(associationDefinitionQName.getLocalName()). + append("'."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + // defaults to RM_CUSTOM_URI + NodeRef modelRef = getCustomModelRef(""); + M2Model deserializedModel = readCustomContentModel(modelRef); + + String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(getNamespaceService()); + M2Aspect customAssocsAspect = deserializedModel.getAspect(customAspectName); + + for (M2ClassAssociation assoc : customAssocsAspect.getAssociations()) + { + if (associationDefinitionQName.toPrefixString(getNamespaceService()).equals(assoc.getName()) && newTitle != null) + { + assoc.setTitle(newTitle); + } + } + writeCustomContentModel(modelRef, deserializedModel); + + if (logger.isInfoEnabled()) + { + logger.info("persistUpdatedAssocTitle: " + associationDefinitionQName + "=" + newTitle + " to aspect: " + customAspectName); + } + + return associationDefinitionQName; + } + + /** + * Generates a qualified name for the given relationship definition unique name + * + * @param uniqueName The unique name of the relationship definition + * @return The qualified name of relationship definition + */ + private QName generateRelationshipDefinitionQNameFor(String uniqueName) + { + mandatoryString("uniqueName", uniqueName); + + QName existingQName = null; + + Set customAssociationsQNames = getCustomAssociations().keySet(); + for (QName customAssociationsQName : customAssociationsQNames) + { + if (uniqueName.equals(customAssociationsQName.getLocalName())) + { + existingQName = customAssociationsQName; + } + } + + if (existingQName != null) + { + StringBuilder sb = new StringBuilder(); + sb.append("Cannot create qualified name for given unique name '"). + append(uniqueName). + append("' as it already exists."); + throw new AlfrescoRuntimeException(sb.toString()); + } + + return QName.createQName(RM_CUSTOM_PREFIX, GUID.generate(), getNamespaceService()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipType.java index acc78cc977..76ae17bb53 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipType.java @@ -1,31 +1,31 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.relationship; - -/** - * Enum representing the relationship types - * - * @author Tuna Aksoy - * @since 2.3 - */ -public enum RelationshipType -{ - BIDIRECTIONAL, - PARENTCHILD; -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.relationship; + +/** + * Enum representing the relationship types + * + * @author Tuna Aksoy + * @since 2.3 + */ +public enum RelationshipType +{ + BIDIRECTIONAL, + PARENTCHILD; +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/Report.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/Report.java index 9278896805..40a1578e62 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/Report.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/Report.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.namespace.QName; - -/** - * Report interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface Report -{ - /** - * @return {@link QName} report type - */ - QName getReportType(); - - /** - * @return {@link String} report name - */ - String getReportName(); - - /** - * @return {@link Map}<{@link QName},{@link Serializable}> report properties - */ - Map getReportProperties(); - - /** - * @return {@link ContentReader} content reader to report content - */ - ContentReader getReportContent(); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.namespace.QName; + +/** + * Report interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface Report +{ + /** + * @return {@link QName} report type + */ + QName getReportType(); + + /** + * @return {@link String} report name + */ + String getReportName(); + + /** + * @return {@link Map}<{@link QName},{@link Serializable}> report properties + */ + Map getReportProperties(); + + /** + * @return {@link ContentReader} content reader to report content + */ + ContentReader getReportContent(); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportGenerator.java index 8d5c4aa861..81ec6a140d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportGenerator.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Report generator interface. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface ReportGenerator -{ - /** - * @return {@link QName} report type - */ - QName getReportType(); - - /** - * Generate report. - * - * @param reportedUponNodeRef - * @param mimetype - * @return - */ - Report generateReport(NodeRef reportedUponNodeRef, String mimetype); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Report generator interface. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface ReportGenerator +{ + /** + * @return {@link QName} report type + */ + QName getReportType(); + + /** + * Generate report. + * + * @param reportedUponNodeRef + * @param mimetype + * @return + */ + Report generateReport(NodeRef reportedUponNodeRef, String mimetype); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportModel.java index c087fde6da..513bcc6053 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportModel.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report; - -import org.alfresco.service.namespace.QName; - -/** - * Helper class containing records management report qualified names - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface ReportModel -{ - /** Namespace details */ - String RMR_URI = "http://www.alfresco.org/model/recordsmanagementreport/1.0"; - String RMR_PREFIX = "rmr"; - - /** base report type */ - QName TYPE_REPORT = QName.createQName(RMR_URI, "report"); - - /** destruction report type */ - QName TYPE_DESTRUCTION_REPORT = QName.createQName(RMR_URI, "destructionReport"); - - /** transfer report type */ - QName TYPE_TRANSFER_REPORT = QName.createQName(RMR_URI, "transferReport"); - - /** - * hold report type - * @since 2.2 - */ - QName TYPE_HOLD_REPORT = QName.createQName(RMR_URI, "holdReport"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report; + +import org.alfresco.service.namespace.QName; + +/** + * Helper class containing records management report qualified names + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface ReportModel +{ + /** Namespace details */ + String RMR_URI = "http://www.alfresco.org/model/recordsmanagementreport/1.0"; + String RMR_PREFIX = "rmr"; + + /** base report type */ + QName TYPE_REPORT = QName.createQName(RMR_URI, "report"); + + /** destruction report type */ + QName TYPE_DESTRUCTION_REPORT = QName.createQName(RMR_URI, "destructionReport"); + + /** transfer report type */ + QName TYPE_TRANSFER_REPORT = QName.createQName(RMR_URI, "transferReport"); + + /** + * hold report type + * @since 2.2 + */ + QName TYPE_HOLD_REPORT = QName.createQName(RMR_URI, "holdReport"); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportService.java index bee7a8f586..f3ec0129f5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportService.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report; - -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Report service. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface ReportService -{ - /** - * Register a report generator with the report service. - * - * @param reportGenerator report generator - */ - void registerReportGenerator(ReportGenerator reportGenerator); - - /** - * Get a list of the available report types. - * - * @return {@link Set}<{@link QName}> list of the available report types - */ - Set getReportTypes(); - - /** - * Generate a report of the given type and reported upon node reference. - * - * @param reportType report type - * @param reportedUponNodeRef reported upon node reference - * @return {@link Report} generated report - */ - Report generateReport(QName reportType, NodeRef reportedUponNodeRef); - - /** - * Generate a report for a specified mimetype. - * - * @see #generateReport(QName, NodeRef) - * - * @param reportType report type - * @param reportedUponNodeRef report upon node reference - * @param mimetype report mimetype - * @return {@link Report} generated report - */ - Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype); - - /** - * File report in the given destination. If the given node reference is a file plan node - * reference the report will be filed in the unfiled records container. - * - * @param nodeRef node reference - * @param report report - * @return NodeRef node reference of the filed report - */ - NodeRef fileReport(NodeRef nodeRef, Report report); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report; + +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Report service. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface ReportService +{ + /** + * Register a report generator with the report service. + * + * @param reportGenerator report generator + */ + void registerReportGenerator(ReportGenerator reportGenerator); + + /** + * Get a list of the available report types. + * + * @return {@link Set}<{@link QName}> list of the available report types + */ + Set getReportTypes(); + + /** + * Generate a report of the given type and reported upon node reference. + * + * @param reportType report type + * @param reportedUponNodeRef reported upon node reference + * @return {@link Report} generated report + */ + Report generateReport(QName reportType, NodeRef reportedUponNodeRef); + + /** + * Generate a report for a specified mimetype. + * + * @see #generateReport(QName, NodeRef) + * + * @param reportType report type + * @param reportedUponNodeRef report upon node reference + * @param mimetype report mimetype + * @return {@link Report} generated report + */ + Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype); + + /** + * File report in the given destination. If the given node reference is a file plan node + * reference the report will be filed in the unfiled records container. + * + * @param nodeRef node reference + * @param report report + * @return NodeRef node reference of the filed report + */ + NodeRef fileReport(NodeRef nodeRef, Report report); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportServiceImpl.java index 2b051c0133..3394396345 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/ReportServiceImpl.java @@ -1,125 +1,125 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Report service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ReportServiceImpl extends ServiceBaseImpl - implements ReportService -{ - /** record service */ - protected RecordService recordService; - - /** report generator registry */ - private Map registry = new HashMap(); - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#registerReportGenerator(org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator) - */ - @Override - public void registerReportGenerator(ReportGenerator reportGenerator) - { - ParameterCheck.mandatory("reportGenerator", reportGenerator); - registry.put(reportGenerator.getReportType(), reportGenerator); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#getReportTypes() - */ - @Override - public Set getReportTypes() - { - return registry.keySet(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(QName, NodeRef) - */ - @Override - public Report generateReport(QName reportType, NodeRef reportedUponNodeRef) - { - ParameterCheck.mandatory("reportType", reportType); - ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); - - return generateReport(reportType, reportedUponNodeRef, MimetypeMap.MIMETYPE_HTML); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(QName, NodeRef, String) - */ - @Override - public Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype) - { - ParameterCheck.mandatory("reportType", reportType); - ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); - ParameterCheck.mandatoryString("mimetype", mimetype); - - // get the generator - ReportGenerator generator = registry.get(reportType); - - // error is generator not found in registry - if (generator == null) - { - throw new AlfrescoRuntimeException("Unable to generate report, because report type " + reportType.toString() + " does not correspond to a registered report type."); - } - - // generate the report - return generator.generateReport(reportedUponNodeRef, mimetype); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#fileReport(org.alfresco.module.org_alfresco_module_rm.report.Report) - */ - @Override - public NodeRef fileReport(NodeRef nodeRef, Report report) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("report", report); - - return recordService.createRecordFromContent(nodeRef, - report.getReportName(), - report.getReportType(), - report.getReportProperties(), - report.getReportContent()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.ParameterCheck; + +/** + * Report service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ReportServiceImpl extends ServiceBaseImpl + implements ReportService +{ + /** record service */ + protected RecordService recordService; + + /** report generator registry */ + private Map registry = new HashMap(); + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#registerReportGenerator(org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator) + */ + @Override + public void registerReportGenerator(ReportGenerator reportGenerator) + { + ParameterCheck.mandatory("reportGenerator", reportGenerator); + registry.put(reportGenerator.getReportType(), reportGenerator); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#getReportTypes() + */ + @Override + public Set getReportTypes() + { + return registry.keySet(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(QName, NodeRef) + */ + @Override + public Report generateReport(QName reportType, NodeRef reportedUponNodeRef) + { + ParameterCheck.mandatory("reportType", reportType); + ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); + + return generateReport(reportType, reportedUponNodeRef, MimetypeMap.MIMETYPE_HTML); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(QName, NodeRef, String) + */ + @Override + public Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype) + { + ParameterCheck.mandatory("reportType", reportType); + ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); + ParameterCheck.mandatoryString("mimetype", mimetype); + + // get the generator + ReportGenerator generator = registry.get(reportType); + + // error is generator not found in registry + if (generator == null) + { + throw new AlfrescoRuntimeException("Unable to generate report, because report type " + reportType.toString() + " does not correspond to a registered report type."); + } + + // generate the report + return generator.generateReport(reportedUponNodeRef, mimetype); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#fileReport(org.alfresco.module.org_alfresco_module_rm.report.Report) + */ + @Override + public NodeRef fileReport(NodeRef nodeRef, Report report) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("report", report); + + return recordService.createRecordFromContent(nodeRef, + report.getReportName(), + report.getReportType(), + report.getReportProperties(), + report.getReportContent()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/BaseReportGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/BaseReportGenerator.java index ca844725aa..45a3e52e2d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/BaseReportGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/BaseReportGenerator.java @@ -1,148 +1,148 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report.generator; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.report.Report; -import org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator; -import org.alfresco.module.org_alfresco_module_rm.report.ReportService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; - -/** - * Base report generator. - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class BaseReportGenerator implements ReportGenerator -{ - /** report service */ - protected ReportService reportService; - - /** namespace service */ - protected NamespaceService namespaceService; - - /** report type qualified name */ - protected QName reportType; - - /** - * @param reportService report service - */ - public void setReportService(ReportService reportService) - { - this.reportService = reportService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param reportType report type - */ - public void setReportType(QName reportType) - { - this.reportType = reportType; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#getReportType() - */ - @Override - public QName getReportType() - { - return reportType; - } - - /** - * Init method - */ - public void init() - { - // ensure required values have been set - ParameterCheck.mandatory("reportType", reportType); - - // register report generator - reportService.registerReportGenerator(this); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#generateReport(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) - */ - @Override - public Report generateReport(NodeRef reportedUponNodeRef, String mimetype) - { - ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); - ParameterCheck.mandatoryString("mimetype", mimetype); - - // check the applicability of the report generator for the given reported upon node - checkReportApplicability(reportedUponNodeRef); - - // generate the report name - String reportName = generateReportName(reportedUponNodeRef, mimetype); - - // generate the report meta-data - Map reportProperties = generateReportMetadata(reportedUponNodeRef); - - // generate the report content - ContentReader contentReader = generateReportContent(reportedUponNodeRef, mimetype, generateReportTemplateContext(reportedUponNodeRef)); - - // return the report information object - return new ReportInfo(reportType, reportName, reportProperties, contentReader); - } - - /** - * Checks whether the report generator is applicable given the reported upon node reference. - *

- * Throws AlfrescoRuntimeException if applicability fails, with reason. - * - * @param reportedUponNodeRef reported upon node reference - */ - protected abstract void checkReportApplicability(NodeRef reportedUponNodeRef); - - /** - * Generate the report name - */ - protected abstract String generateReportName(NodeRef reportedUponNodeRef, String mimetype); - - /** - * Generate the report template context. - */ - protected abstract Map generateReportTemplateContext(NodeRef reportedUponNodeRef); - - /** - * Generate report meta-data - */ - protected abstract Map generateReportMetadata(NodeRef reportedUponNodeRef); - - /** - * Generate report content - */ - protected abstract ContentReader generateReportContent(NodeRef reportedUponNodeRef, String mimetype, Map properties); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.generator; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.report.Report; +import org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator; +import org.alfresco.module.org_alfresco_module_rm.report.ReportService; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; + +/** + * Base report generator. + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class BaseReportGenerator implements ReportGenerator +{ + /** report service */ + protected ReportService reportService; + + /** namespace service */ + protected NamespaceService namespaceService; + + /** report type qualified name */ + protected QName reportType; + + /** + * @param reportService report service + */ + public void setReportService(ReportService reportService) + { + this.reportService = reportService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param reportType report type + */ + public void setReportType(QName reportType) + { + this.reportType = reportType; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#getReportType() + */ + @Override + public QName getReportType() + { + return reportType; + } + + /** + * Init method + */ + public void init() + { + // ensure required values have been set + ParameterCheck.mandatory("reportType", reportType); + + // register report generator + reportService.registerReportGenerator(this); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#generateReport(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) + */ + @Override + public Report generateReport(NodeRef reportedUponNodeRef, String mimetype) + { + ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef); + ParameterCheck.mandatoryString("mimetype", mimetype); + + // check the applicability of the report generator for the given reported upon node + checkReportApplicability(reportedUponNodeRef); + + // generate the report name + String reportName = generateReportName(reportedUponNodeRef, mimetype); + + // generate the report meta-data + Map reportProperties = generateReportMetadata(reportedUponNodeRef); + + // generate the report content + ContentReader contentReader = generateReportContent(reportedUponNodeRef, mimetype, generateReportTemplateContext(reportedUponNodeRef)); + + // return the report information object + return new ReportInfo(reportType, reportName, reportProperties, contentReader); + } + + /** + * Checks whether the report generator is applicable given the reported upon node reference. + *

+ * Throws AlfrescoRuntimeException if applicability fails, with reason. + * + * @param reportedUponNodeRef reported upon node reference + */ + protected abstract void checkReportApplicability(NodeRef reportedUponNodeRef); + + /** + * Generate the report name + */ + protected abstract String generateReportName(NodeRef reportedUponNodeRef, String mimetype); + + /** + * Generate the report template context. + */ + protected abstract Map generateReportTemplateContext(NodeRef reportedUponNodeRef); + + /** + * Generate report meta-data + */ + protected abstract Map generateReportMetadata(NodeRef reportedUponNodeRef); + + /** + * Generate report content + */ + protected abstract ContentReader generateReportContent(NodeRef reportedUponNodeRef, String mimetype, Map properties); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java index 952ae9bbea..f71f30d7be 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java @@ -1,368 +1,368 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report.generator; - -import java.io.Serializable; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.admin.SysAdminParams; -import org.alfresco.repo.i18n.StaticMessageLookup; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.TemplateService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.UrlUtil; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Declarative report generator. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class DeclarativeReportGenerator extends BaseReportGenerator -{ - /** message lookups */ - protected static final String MSG_REPORT = "report.default"; - - /** template lookup root */ - protected static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); - - /** model keys */ - protected static final String KEY_NODE = "node"; - protected static final String KEY_CHILDREN = "children"; - - /** applicable reported upon types */ - protected Set applicableTypes; - - /** content service */ - protected ContentService contentService; - - /** mimetype service */ - protected MimetypeService mimetypeService; - - /** file folder service */ - protected FileFolderService fileFolderService; - - /** template service */ - protected TemplateService templateService; - - /** repository helper */ - protected Repository repository; - - /** node service */ - protected NodeService nodeService; - - /** dictionary service */ - protected DictionaryService dictionaryService; - - /** sys admin params */ - protected SysAdminParams sysAdminParams; - - /** - * @param applicableTypes applicable types - */ - public void setApplicableTypes(Set applicableTypes) - { - this.applicableTypes = applicableTypes; - } - - /** - * @param mimetypeService mimetype service - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param templateService template service - */ - public void setTemplateService(TemplateService templateService) - { - this.templateService = templateService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param repository repository helper - */ - public void setRepository(Repository repository) - { - this.repository = repository; - } - - /** - * @param sysAdminParams sys admin params - */ - public void setSysAdminParams(SysAdminParams sysAdminParams) - { - this.sysAdminParams = sysAdminParams; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportName(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected String generateReportName(NodeRef reportedUponNodeRef, String mimetype) - { - // get the file extension based on the mimetype - String extension = mimetypeService.getExtension(mimetype); - - // get the name of the reported updon node ref - String name = (String)nodeService.getProperty(reportedUponNodeRef, ContentModel.PROP_NAME); - - // build default report name - StringBuilder builder = new StringBuilder(); - builder.append(getReportDisplayLabel()); - if (StringUtils.isNotBlank(name)) - { - builder.append(" - ").append(name); - } - builder.append(".").append(extension); - - return builder.toString(); - } - - /** - * Helper method to get the report types display label - * - * @return {@link String} report type display label - */ - private String getReportDisplayLabel() - { - String result = I18NUtil.getMessage(MSG_REPORT); - - TypeDefinition typeDef = dictionaryService.getType(reportType); - if (typeDef != null) - { - result = typeDef.getTitle(new StaticMessageLookup()); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportContent(NodeRef, String, Map) - */ - @Override - protected ContentReader generateReportContent(NodeRef reportedUponNodeRef, String mimetype, Map properties) - { - // get the template - NodeRef reportTemplateNodeRef = getReportTemplate(mimetype); - - // get the model - Map model = createTemplateModel(reportTemplateNodeRef, reportedUponNodeRef, properties); - - // run the template - String result = templateService.processTemplate("freemarker", reportTemplateNodeRef.toString(), model); - - // create the temp content - ContentWriter contentWriter = contentService.getTempWriter(); - contentWriter.setEncoding("UTF-8"); - contentWriter.setMimetype(mimetype); - contentWriter.putContent(result); - - // return the reader to the temp content - return contentWriter.getReader(); - } - - /** - * Create template model. - * - * @param templateNodeRef - * @param reportedUponNodeRef - * @param properties - * @return - */ - protected Map createTemplateModel(NodeRef templateNodeRef, NodeRef reportedUponNodeRef, Map properties) - { - Map model = new HashMap(); - - // build the default model - NodeRef person = repository.getPerson(); - templateService.buildDefaultModel(person, - repository.getCompanyHome(), - repository.getUserHome(person), - templateNodeRef, - null); - - // put the reported upon node reference in the model - model.put(KEY_NODE, reportedUponNodeRef); - - // context url's (handy for images and links) - model.put("url", UrlUtil.getAlfrescoUrl(sysAdminParams)); - model.put(TemplateService.KEY_SHARE_URL, UrlUtil.getShareUrl(sysAdminParams)); - - // who and when the report was generated - model.put("reportUser", AuthenticationUtil.getRunAsUser()); - Calendar now = Calendar.getInstance(I18NUtil.getContentLocale()); - model.put("reportDate", SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(now.getTime())); - - // add additional properties - model.put("properties", (Serializable) properties); - - return model; - } - - /** - * Get's the report template based on the type and mimetype. - * - * @param mimetype - * @return - */ - private NodeRef getReportTemplate(String mimetype) - { - // check that the template root has been correctly bootstraped - if (!fileFolderService.exists(TEMPLATE_ROOT)) - { - throw new AlfrescoRuntimeException("Unable to get report template, because the template root folder does not exist in the data dictionary."); - } - - String reportTemplateName = getReportTemplateName(mimetype); - - NodeRef reportTemplateNodeRef = fileFolderService.searchSimple(TEMPLATE_ROOT, reportTemplateName); - if (reportTemplateNodeRef == null) - { - throw new AlfrescoRuntimeException("Unable to get report template, because report template " + reportTemplateName + " does not exist."); - } - - // get localise template - return fileFolderService.getLocalizedSibling(reportTemplateNodeRef); - } - - /** - * Gets the template name based on the type and mimetype. - * - * @param mimetype - * @return - */ - private String getReportTemplateName(String mimetype) - { - String typePrefixName = reportType.getPrefixedQName(namespaceService).getPrefixString().replace(":", "_"); - String extension = mimetypeService.getExtension(mimetype); - - StringBuffer sb = new StringBuffer(128) - .append("report_") - .append(typePrefixName) - .append(".") - .append(extension) - .append(".ftl"); - - return sb.toString(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#checkReportApplicability(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void checkReportApplicability(NodeRef reportedUponNodeRef) - { - if (applicableTypes != null && applicableTypes.size() != 0) - { - boolean isTypeApplicable = false; - QName type = nodeService.getType(reportedUponNodeRef); - - for (QName applicableType : applicableTypes) - { - if (dictionaryService.isSubClass(type, applicableType)) - { - isTypeApplicable = true; - break; - } - } - - if (!isTypeApplicable) - { - // throw an exception - throw new AlfrescoRuntimeException("Can't generate report, because the provided reported upon node reference is type " + type.toString() + - " which is not an applicable type for a " + reportType.toString() + " report."); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected Map generateReportTemplateContext(NodeRef reportedUponNodeRef) - { - return Collections.EMPTY_MAP; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportMetadata(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected Map generateReportMetadata(NodeRef reportedUponNodeRef) - { - return Collections.EMPTY_MAP; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.generator; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.admin.SysAdminParams; +import org.alfresco.repo.i18n.StaticMessageLookup; +import org.alfresco.repo.model.Repository; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.MimetypeService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.repository.TemplateService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.UrlUtil; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Declarative report generator. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class DeclarativeReportGenerator extends BaseReportGenerator +{ + /** message lookups */ + protected static final String MSG_REPORT = "report.default"; + + /** template lookup root */ + protected static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates"); + + /** model keys */ + protected static final String KEY_NODE = "node"; + protected static final String KEY_CHILDREN = "children"; + + /** applicable reported upon types */ + protected Set applicableTypes; + + /** content service */ + protected ContentService contentService; + + /** mimetype service */ + protected MimetypeService mimetypeService; + + /** file folder service */ + protected FileFolderService fileFolderService; + + /** template service */ + protected TemplateService templateService; + + /** repository helper */ + protected Repository repository; + + /** node service */ + protected NodeService nodeService; + + /** dictionary service */ + protected DictionaryService dictionaryService; + + /** sys admin params */ + protected SysAdminParams sysAdminParams; + + /** + * @param applicableTypes applicable types + */ + public void setApplicableTypes(Set applicableTypes) + { + this.applicableTypes = applicableTypes; + } + + /** + * @param mimetypeService mimetype service + */ + public void setMimetypeService(MimetypeService mimetypeService) + { + this.mimetypeService = mimetypeService; + } + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @param templateService template service + */ + public void setTemplateService(TemplateService templateService) + { + this.templateService = templateService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param repository repository helper + */ + public void setRepository(Repository repository) + { + this.repository = repository; + } + + /** + * @param sysAdminParams sys admin params + */ + public void setSysAdminParams(SysAdminParams sysAdminParams) + { + this.sysAdminParams = sysAdminParams; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportName(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected String generateReportName(NodeRef reportedUponNodeRef, String mimetype) + { + // get the file extension based on the mimetype + String extension = mimetypeService.getExtension(mimetype); + + // get the name of the reported updon node ref + String name = (String)nodeService.getProperty(reportedUponNodeRef, ContentModel.PROP_NAME); + + // build default report name + StringBuilder builder = new StringBuilder(); + builder.append(getReportDisplayLabel()); + if (StringUtils.isNotBlank(name)) + { + builder.append(" - ").append(name); + } + builder.append(".").append(extension); + + return builder.toString(); + } + + /** + * Helper method to get the report types display label + * + * @return {@link String} report type display label + */ + private String getReportDisplayLabel() + { + String result = I18NUtil.getMessage(MSG_REPORT); + + TypeDefinition typeDef = dictionaryService.getType(reportType); + if (typeDef != null) + { + result = typeDef.getTitle(new StaticMessageLookup()); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportContent(NodeRef, String, Map) + */ + @Override + protected ContentReader generateReportContent(NodeRef reportedUponNodeRef, String mimetype, Map properties) + { + // get the template + NodeRef reportTemplateNodeRef = getReportTemplate(mimetype); + + // get the model + Map model = createTemplateModel(reportTemplateNodeRef, reportedUponNodeRef, properties); + + // run the template + String result = templateService.processTemplate("freemarker", reportTemplateNodeRef.toString(), model); + + // create the temp content + ContentWriter contentWriter = contentService.getTempWriter(); + contentWriter.setEncoding("UTF-8"); + contentWriter.setMimetype(mimetype); + contentWriter.putContent(result); + + // return the reader to the temp content + return contentWriter.getReader(); + } + + /** + * Create template model. + * + * @param templateNodeRef + * @param reportedUponNodeRef + * @param properties + * @return + */ + protected Map createTemplateModel(NodeRef templateNodeRef, NodeRef reportedUponNodeRef, Map properties) + { + Map model = new HashMap(); + + // build the default model + NodeRef person = repository.getPerson(); + templateService.buildDefaultModel(person, + repository.getCompanyHome(), + repository.getUserHome(person), + templateNodeRef, + null); + + // put the reported upon node reference in the model + model.put(KEY_NODE, reportedUponNodeRef); + + // context url's (handy for images and links) + model.put("url", UrlUtil.getAlfrescoUrl(sysAdminParams)); + model.put(TemplateService.KEY_SHARE_URL, UrlUtil.getShareUrl(sysAdminParams)); + + // who and when the report was generated + model.put("reportUser", AuthenticationUtil.getRunAsUser()); + Calendar now = Calendar.getInstance(I18NUtil.getContentLocale()); + model.put("reportDate", SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(now.getTime())); + + // add additional properties + model.put("properties", (Serializable) properties); + + return model; + } + + /** + * Get's the report template based on the type and mimetype. + * + * @param mimetype + * @return + */ + private NodeRef getReportTemplate(String mimetype) + { + // check that the template root has been correctly bootstraped + if (!fileFolderService.exists(TEMPLATE_ROOT)) + { + throw new AlfrescoRuntimeException("Unable to get report template, because the template root folder does not exist in the data dictionary."); + } + + String reportTemplateName = getReportTemplateName(mimetype); + + NodeRef reportTemplateNodeRef = fileFolderService.searchSimple(TEMPLATE_ROOT, reportTemplateName); + if (reportTemplateNodeRef == null) + { + throw new AlfrescoRuntimeException("Unable to get report template, because report template " + reportTemplateName + " does not exist."); + } + + // get localise template + return fileFolderService.getLocalizedSibling(reportTemplateNodeRef); + } + + /** + * Gets the template name based on the type and mimetype. + * + * @param mimetype + * @return + */ + private String getReportTemplateName(String mimetype) + { + String typePrefixName = reportType.getPrefixedQName(namespaceService).getPrefixString().replace(":", "_"); + String extension = mimetypeService.getExtension(mimetype); + + StringBuffer sb = new StringBuffer(128) + .append("report_") + .append(typePrefixName) + .append(".") + .append(extension) + .append(".ftl"); + + return sb.toString(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#checkReportApplicability(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void checkReportApplicability(NodeRef reportedUponNodeRef) + { + if (applicableTypes != null && applicableTypes.size() != 0) + { + boolean isTypeApplicable = false; + QName type = nodeService.getType(reportedUponNodeRef); + + for (QName applicableType : applicableTypes) + { + if (dictionaryService.isSubClass(type, applicableType)) + { + isTypeApplicable = true; + break; + } + } + + if (!isTypeApplicable) + { + // throw an exception + throw new AlfrescoRuntimeException("Can't generate report, because the provided reported upon node reference is type " + type.toString() + + " which is not an applicable type for a " + reportType.toString() + " report."); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + protected Map generateReportTemplateContext(NodeRef reportedUponNodeRef) + { + return Collections.EMPTY_MAP; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportMetadata(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + protected Map generateReportMetadata(NodeRef reportedUponNodeRef) + { + return Collections.EMPTY_MAP; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/ReportInfo.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/ReportInfo.java index c7e112743c..12c957f67e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/ReportInfo.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/ReportInfo.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report.generator; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.report.Report; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Report implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -/*package*/ class ReportInfo implements Report -{ - /** report type */ - private QName reportType; - - private String reportName; - - private Map reportProperties = new HashMap(21); - - /** content reader */ - private ContentReader reportContent; - - /** - * Default constructor. - * - * @param reportType report type - * @param reportName report name - * @param reportProperties report properties - * @param reportContent report content reader - */ - public ReportInfo(QName reportType, String reportName, Map reportProperties, ContentReader reportContent) - { - ParameterCheck.mandatory("reportType", reportType); - ParameterCheck.mandatory("reportName", reportName); - ParameterCheck.mandatory("reportContent", reportContent); - - this.reportType = reportType; - this.reportName = reportName; - this.reportProperties = reportProperties; - this.reportContent = reportContent; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportType() - */ - public QName getReportType() - { - return reportType; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportName() - */ - @Override - public String getReportName() - { - return reportName; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportProperties() - */ - @Override - public Map getReportProperties() - { - return reportProperties; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportContent() - */ - @Override - public ContentReader getReportContent() - { - return reportContent; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.generator; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.report.Report; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.ParameterCheck; + +/** + * Report implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +/*package*/ class ReportInfo implements Report +{ + /** report type */ + private QName reportType; + + private String reportName; + + private Map reportProperties = new HashMap(21); + + /** content reader */ + private ContentReader reportContent; + + /** + * Default constructor. + * + * @param reportType report type + * @param reportName report name + * @param reportProperties report properties + * @param reportContent report content reader + */ + public ReportInfo(QName reportType, String reportName, Map reportProperties, ContentReader reportContent) + { + ParameterCheck.mandatory("reportType", reportType); + ParameterCheck.mandatory("reportName", reportName); + ParameterCheck.mandatory("reportContent", reportContent); + + this.reportType = reportType; + this.reportName = reportName; + this.reportProperties = reportProperties; + this.reportContent = reportContent; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportType() + */ + public QName getReportType() + { + return reportType; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportName() + */ + @Override + public String getReportName() + { + return reportName; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportProperties() + */ + @Override + public Map getReportProperties() + { + return reportProperties; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportContent() + */ + @Override + public ContentReader getReportContent() + { + return reportContent; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferNode.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferNode.java index 69b68ddd77..9a2943c8e7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferNode.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferNode.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Transfer node class - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class TransferNode -{ - /** Transfer node reference */ - private NodeRef nodeRef; - - /** Transfer node properties */ - private Map properties; - - /** - * @param nodeRef - * @param properties - */ - public TransferNode(NodeRef nodeRef, Map properties) - { - this.nodeRef = nodeRef; - this.properties = properties; - } - - /** - * @return transfer node reference - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - /** - * @return transfer node properties - */ - public Map getProperties() - { - return this.properties; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Transfer node class + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class TransferNode +{ + /** Transfer node reference */ + private NodeRef nodeRef; + + /** Transfer node properties */ + private Map properties; + + /** + * @param nodeRef + * @param properties + */ + public TransferNode(NodeRef nodeRef, Map properties) + { + this.nodeRef = nodeRef; + this.properties = properties; + } + + /** + * @return transfer node reference + */ + public NodeRef getNodeRef() + { + return this.nodeRef; + } + + /** + * @return transfer node properties + */ + public Map getProperties() + { + return this.properties; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java index 0aa90b952f..c5d149d5b2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java @@ -1,233 +1,233 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGenerator; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.lang.StringUtils; - -/** - * Transfer report generator. - * - * @author Tuna Aksoy - * @author Roy Wetherall - * @since 2.2 - */ -public class TransferReportGenerator extends DeclarativeReportGenerator -{ - /** dispotion service */ - protected DispositionService dispositionService; - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGeneratorUnitTest#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected Map generateReportTemplateContext(NodeRef reportedUponNodeRef) - { - // Get all 'transferred' nodes - List transferNodes = getTransferNodes(reportedUponNodeRef); - - // Get the disposition authority - String dispositionAuthority = getDispositionAuthority(transferNodes); - - // Save to the properties map - Map properties = new HashMap(2); - properties.put("transferNodes", (ArrayList) transferNodes); - properties.put("dispositionAuthority", dispositionAuthority); - - return properties; - } - - /** - * Returns a list of transfer nodes - * - * @param nodeRef The transfer object - * @return Transfer node list - */ - private List getTransferNodes(NodeRef nodeRef) - { - List assocs = nodeService.getChildAssocs(nodeRef, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - List transferNodes = new ArrayList(assocs.size()); - for (ChildAssociationRef assoc : assocs) - { - NodeRef childRef = assoc.getChildRef(); - Map properties = getTransferNodeProperties(childRef); - transferNodes.add(new TransferNode(childRef, properties)); - } - return transferNodes; - } - - /** - * Helper method to get the properties of a transfer node - * - * @param childRef Node reference - * @return Transfer node properties - */ - private Map getTransferNodeProperties(NodeRef childRef) - { - Map transferNodeProperties = new HashMap(6); - - boolean isFolder = dictionaryService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER); - transferNodeProperties.put("isFolder", isFolder); - - if (isFolder) - { - Map folderProperties = getFolderProperties(childRef); - transferNodeProperties.putAll(folderProperties); - } - else - { - Map recordProperties = getRecordProperties(childRef); - transferNodeProperties.putAll(recordProperties); - } - - return transferNodeProperties; - } - - /** - * Helper method to get the list of records (with their properties) within a folder - * - * @param childRef Node reference of the folder - * @return List of records within the specified folder - */ - private List getRecords(NodeRef childRef) - { - List records = new ArrayList(4); - List assocs = nodeService.getChildAssocs(childRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef child : assocs) - { - NodeRef record = child.getChildRef(); - if (nodeService.hasAspect(record, RecordsManagementModel.ASPECT_RECORD)) - { - Map recordProperties = getRecordProperties(record); - TransferNode transferNode = new TransferNode(record, recordProperties); - records.add(transferNode); - } - } - return records; - } - - /** - * Helper method to get the common transfer node properties - * - * @param nodeRef Node reference of the transfer node - * @return Map of the common transfer node properties - */ - private Map getCommonProperties(NodeRef nodeRef) - { - Map transferNodeProperties = new HashMap(3); - - Map properties = nodeService.getProperties(nodeRef); - String name = (String) properties.get(ContentModel.PROP_NAME); - String identifier = (String) properties.get(RecordsManagementModel.PROP_IDENTIFIER); - - transferNodeProperties.put("name", name); - transferNodeProperties.put("identifier", identifier); - - return transferNodeProperties; - } - - /** - * Helper method to get the folder specific properties - * - * @param folder Node reference of the folder - * @return Map of the folder specific properties - */ - private Map getFolderProperties(NodeRef folder) - { - Map transferNodeProperties = new HashMap(3); - - Map commonProperties = getCommonProperties(folder); - ArrayList records = (ArrayList) getRecords(folder); - transferNodeProperties.putAll(commonProperties); - transferNodeProperties.put("records", records); - - return transferNodeProperties; - } - - /** - * Helper method to get the record folder properties - * - * @param record Node reference of the record - * @return Map of the record specific properties - */ - private Map getRecordProperties(NodeRef record) - { - Map transferNodeProperties = new HashMap(5); - - Map properties = nodeService.getProperties(record); - String declaredBy = (String) properties.get(RecordsManagementModel.PROP_DECLARED_BY); - Date declaredOn = (Date) properties.get(RecordsManagementModel.PROP_DECLARED_AT); - boolean isDeclared = nodeService.hasAspect(record, RecordsManagementModel.ASPECT_DECLARED_RECORD); - - Map commonProperties = getCommonProperties(record); - transferNodeProperties.putAll(commonProperties); - transferNodeProperties.put("declaredBy", declaredBy); - transferNodeProperties.put("declaredOn", declaredOn); - transferNodeProperties.put("isDeclared", isDeclared); - - return transferNodeProperties; - } - - /** - * Gets the disposition authority from the list of the transfer nodes - * - * @param transferNodes The transfer nodes - * @return Disposition authority - */ - private String getDispositionAuthority(List transferNodes) - { - // use RMService to get disposition authority - String dispositionAuthority = null; - if (transferNodes.size() > 0) - { - // use the first transfer item to get to disposition schedule - NodeRef nodeRef = transferNodes.iterator().next().getNodeRef(); - DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); - if (ds != null) - { - dispositionAuthority = ds.getDispositionAuthority(); - } - } - return dispositionAuthority == null ? StringUtils.EMPTY : dispositionAuthority; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGenerator; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.lang.StringUtils; + +/** + * Transfer report generator. + * + * @author Tuna Aksoy + * @author Roy Wetherall + * @since 2.2 + */ +public class TransferReportGenerator extends DeclarativeReportGenerator +{ + /** dispotion service */ + protected DispositionService dispositionService; + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGeneratorUnitTest#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected Map generateReportTemplateContext(NodeRef reportedUponNodeRef) + { + // Get all 'transferred' nodes + List transferNodes = getTransferNodes(reportedUponNodeRef); + + // Get the disposition authority + String dispositionAuthority = getDispositionAuthority(transferNodes); + + // Save to the properties map + Map properties = new HashMap(2); + properties.put("transferNodes", (ArrayList) transferNodes); + properties.put("dispositionAuthority", dispositionAuthority); + + return properties; + } + + /** + * Returns a list of transfer nodes + * + * @param nodeRef The transfer object + * @return Transfer node list + */ + private List getTransferNodes(NodeRef nodeRef) + { + List assocs = nodeService.getChildAssocs(nodeRef, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + List transferNodes = new ArrayList(assocs.size()); + for (ChildAssociationRef assoc : assocs) + { + NodeRef childRef = assoc.getChildRef(); + Map properties = getTransferNodeProperties(childRef); + transferNodes.add(new TransferNode(childRef, properties)); + } + return transferNodes; + } + + /** + * Helper method to get the properties of a transfer node + * + * @param childRef Node reference + * @return Transfer node properties + */ + private Map getTransferNodeProperties(NodeRef childRef) + { + Map transferNodeProperties = new HashMap(6); + + boolean isFolder = dictionaryService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER); + transferNodeProperties.put("isFolder", isFolder); + + if (isFolder) + { + Map folderProperties = getFolderProperties(childRef); + transferNodeProperties.putAll(folderProperties); + } + else + { + Map recordProperties = getRecordProperties(childRef); + transferNodeProperties.putAll(recordProperties); + } + + return transferNodeProperties; + } + + /** + * Helper method to get the list of records (with their properties) within a folder + * + * @param childRef Node reference of the folder + * @return List of records within the specified folder + */ + private List getRecords(NodeRef childRef) + { + List records = new ArrayList(4); + List assocs = nodeService.getChildAssocs(childRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef child : assocs) + { + NodeRef record = child.getChildRef(); + if (nodeService.hasAspect(record, RecordsManagementModel.ASPECT_RECORD)) + { + Map recordProperties = getRecordProperties(record); + TransferNode transferNode = new TransferNode(record, recordProperties); + records.add(transferNode); + } + } + return records; + } + + /** + * Helper method to get the common transfer node properties + * + * @param nodeRef Node reference of the transfer node + * @return Map of the common transfer node properties + */ + private Map getCommonProperties(NodeRef nodeRef) + { + Map transferNodeProperties = new HashMap(3); + + Map properties = nodeService.getProperties(nodeRef); + String name = (String) properties.get(ContentModel.PROP_NAME); + String identifier = (String) properties.get(RecordsManagementModel.PROP_IDENTIFIER); + + transferNodeProperties.put("name", name); + transferNodeProperties.put("identifier", identifier); + + return transferNodeProperties; + } + + /** + * Helper method to get the folder specific properties + * + * @param folder Node reference of the folder + * @return Map of the folder specific properties + */ + private Map getFolderProperties(NodeRef folder) + { + Map transferNodeProperties = new HashMap(3); + + Map commonProperties = getCommonProperties(folder); + ArrayList records = (ArrayList) getRecords(folder); + transferNodeProperties.putAll(commonProperties); + transferNodeProperties.put("records", records); + + return transferNodeProperties; + } + + /** + * Helper method to get the record folder properties + * + * @param record Node reference of the record + * @return Map of the record specific properties + */ + private Map getRecordProperties(NodeRef record) + { + Map transferNodeProperties = new HashMap(5); + + Map properties = nodeService.getProperties(record); + String declaredBy = (String) properties.get(RecordsManagementModel.PROP_DECLARED_BY); + Date declaredOn = (Date) properties.get(RecordsManagementModel.PROP_DECLARED_AT); + boolean isDeclared = nodeService.hasAspect(record, RecordsManagementModel.ASPECT_DECLARED_RECORD); + + Map commonProperties = getCommonProperties(record); + transferNodeProperties.putAll(commonProperties); + transferNodeProperties.put("declaredBy", declaredBy); + transferNodeProperties.put("declaredOn", declaredOn); + transferNodeProperties.put("isDeclared", isDeclared); + + return transferNodeProperties; + } + + /** + * Gets the disposition authority from the list of the transfer nodes + * + * @param transferNodes The transfer nodes + * @return Disposition authority + */ + private String getDispositionAuthority(List transferNodes) + { + // use RMService to get disposition authority + String dispositionAuthority = null; + if (transferNodes.size() > 0) + { + // use the first transfer item to get to disposition schedule + NodeRef nodeRef = transferNodes.iterator().next().getNodeRef(); + DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); + if (ds != null) + { + dispositionAuthority = ds.getDispositionAuthority(); + } + } + return dispositionAuthority == null ? StringUtils.EMPTY : dispositionAuthority; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java index 69ee116e29..dbb80fd3f8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java @@ -1,215 +1,215 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.role; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Role service interface - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface FilePlanRoleService -{ - /** Default role names */ - String ROLE_USER = "User"; - String ROLE_POWER_USER = "PowerUser"; - String ROLE_SECURITY_OFFICER = "SecurityOfficer"; - String ROLE_RECORDS_MANAGER = "RecordsManager"; - String ROLE_ADMIN = "Administrator"; - String ROLE_EXTENDED_READERS = "ExtendedReaders"; - String ROLE_EXTENDED_WRITERS = "ExtendedWriters"; - - /** System roles */ - List SYSTEM_ROLES = Arrays.asList( - ROLE_EXTENDED_READERS, - ROLE_EXTENDED_WRITERS - ); - - /** - * Sets up the roles on a new file plan. - * - * @param filePlan file plan - */ - void setupFilePlanRoles(NodeRef filePlan); - - /** - * Tears down the roles on a file plan. - * - * @param filePlan file plan - */ - void tearDownFilePlanRoles(NodeRef filePlan); - - /** - * Returns the name of the container group for all roles of a specified file - * plan. - * - * @param filePlan file plan node reference - * @return String group name - */ - String getAllRolesContainerGroup(NodeRef filePlan); - - /** - * Get all the available roles for the given records management root node - * (includes also the system roles) - * - * @param filePlan file plan - * @return - */ - Set getRoles(NodeRef filePlan); - - /** - * Get all the available roles for the given records management root node. - * System roles can be filtered - * - * @param filePlan file plan - * @param includeSystemRoles system roles - * @return - */ - Set getRoles(NodeRef filePlan, boolean includeSystemRoles); - - /** - * Gets the roles for a given user - * (includes also the system roles) - * - * @param filePlan file plan - * @param user user - * @return - */ - Set getRolesByUser(NodeRef filePlan, String user); - - /** - * Gets the roles for a given user. - * System roles can be filtered - * - * @param filePlan file plan - * @param user user - * @param includeSystemRoles system roles - * @return - */ - Set getRolesByUser(NodeRef filePlan, String user, boolean includeSystemRoles); - - /** - * Get a role by name - * - * @param filePlan file plan - * @param role role - * @return - */ - Role getRole(NodeRef filePlan, String role); - - /** - * Indicate whether a role exists for a given records management root node - * @param filePlan file plan - * @param role role - * @return - */ - boolean existsRole(NodeRef filePlan, String role); - - /** - * Determines whether the given user has the RM Admin role - * - * @param filePlan filePlan - * @param user user name to check - * @return true if the user has the RM Admin role, false otherwise - */ - boolean hasRMAdminRole(NodeRef filePlan, String user); - - /** - * Create a new role - * - * @param filePlan file plan - * @param role - * @param roleDisplayLabel - * @param capabilities - * @return - */ - Role createRole(NodeRef filePlan, String role, String roleDisplayLabel, Set capabilities); - - /** - * Update an existing role - * - * @param filePlan file plan - * @param role - * @param roleDisplayLabel - * @param capabilities - * @return - */ - Role updateRole(NodeRef filePlan, String role, String roleDisplayLabel, Set capabilities); - - /** - * Delete a role - * - * @param filePlan file plan - * @param role role - */ - void deleteRole(NodeRef filePlan, String role); - - /** - * Gets all the users that have been directly assigned to a role. - * - * @param filePlan file plan - * @param role role - * @return {@link Set}<{@link String}> set of users - */ - Set getUsersAssignedToRole(NodeRef filePlan, String role); - - /** - * Gets all the groups that have been directly assigned to a role. - * - * @param filePlan file plan - * @param role role - * @return {@link Set}<{@link String}> set of groups - */ - Set getGroupsAssignedToRole(NodeRef filePlan, String role); - - /** - * Gets all the groups and users that have been directly assigned to a role. - * - * @param filePlan file plan - * @param role role - * @return {@link Set}<{@link String}> set of groups and users - */ - Set getAllAssignedToRole(NodeRef filePlan, String role); - - /** - * Assign a role to an authority - * - * @param filePlan file plan - * @param role role - * @param authorityName authority name - */ - void assignRoleToAuthority(NodeRef filePlan, String role, String authorityName); - - - /** - * Unassign a role from an authority - * - * @param filePlan file plan - * @param role role - * @param authorityName authority name - */ - void unassignRoleFromAuthority(NodeRef filePlan, String role, String authorityName); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.role; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Role service interface + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface FilePlanRoleService +{ + /** Default role names */ + String ROLE_USER = "User"; + String ROLE_POWER_USER = "PowerUser"; + String ROLE_SECURITY_OFFICER = "SecurityOfficer"; + String ROLE_RECORDS_MANAGER = "RecordsManager"; + String ROLE_ADMIN = "Administrator"; + String ROLE_EXTENDED_READERS = "ExtendedReaders"; + String ROLE_EXTENDED_WRITERS = "ExtendedWriters"; + + /** System roles */ + List SYSTEM_ROLES = Arrays.asList( + ROLE_EXTENDED_READERS, + ROLE_EXTENDED_WRITERS + ); + + /** + * Sets up the roles on a new file plan. + * + * @param filePlan file plan + */ + void setupFilePlanRoles(NodeRef filePlan); + + /** + * Tears down the roles on a file plan. + * + * @param filePlan file plan + */ + void tearDownFilePlanRoles(NodeRef filePlan); + + /** + * Returns the name of the container group for all roles of a specified file + * plan. + * + * @param filePlan file plan node reference + * @return String group name + */ + String getAllRolesContainerGroup(NodeRef filePlan); + + /** + * Get all the available roles for the given records management root node + * (includes also the system roles) + * + * @param filePlan file plan + * @return + */ + Set getRoles(NodeRef filePlan); + + /** + * Get all the available roles for the given records management root node. + * System roles can be filtered + * + * @param filePlan file plan + * @param includeSystemRoles system roles + * @return + */ + Set getRoles(NodeRef filePlan, boolean includeSystemRoles); + + /** + * Gets the roles for a given user + * (includes also the system roles) + * + * @param filePlan file plan + * @param user user + * @return + */ + Set getRolesByUser(NodeRef filePlan, String user); + + /** + * Gets the roles for a given user. + * System roles can be filtered + * + * @param filePlan file plan + * @param user user + * @param includeSystemRoles system roles + * @return + */ + Set getRolesByUser(NodeRef filePlan, String user, boolean includeSystemRoles); + + /** + * Get a role by name + * + * @param filePlan file plan + * @param role role + * @return + */ + Role getRole(NodeRef filePlan, String role); + + /** + * Indicate whether a role exists for a given records management root node + * @param filePlan file plan + * @param role role + * @return + */ + boolean existsRole(NodeRef filePlan, String role); + + /** + * Determines whether the given user has the RM Admin role + * + * @param filePlan filePlan + * @param user user name to check + * @return true if the user has the RM Admin role, false otherwise + */ + boolean hasRMAdminRole(NodeRef filePlan, String user); + + /** + * Create a new role + * + * @param filePlan file plan + * @param role + * @param roleDisplayLabel + * @param capabilities + * @return + */ + Role createRole(NodeRef filePlan, String role, String roleDisplayLabel, Set capabilities); + + /** + * Update an existing role + * + * @param filePlan file plan + * @param role + * @param roleDisplayLabel + * @param capabilities + * @return + */ + Role updateRole(NodeRef filePlan, String role, String roleDisplayLabel, Set capabilities); + + /** + * Delete a role + * + * @param filePlan file plan + * @param role role + */ + void deleteRole(NodeRef filePlan, String role); + + /** + * Gets all the users that have been directly assigned to a role. + * + * @param filePlan file plan + * @param role role + * @return {@link Set}<{@link String}> set of users + */ + Set getUsersAssignedToRole(NodeRef filePlan, String role); + + /** + * Gets all the groups that have been directly assigned to a role. + * + * @param filePlan file plan + * @param role role + * @return {@link Set}<{@link String}> set of groups + */ + Set getGroupsAssignedToRole(NodeRef filePlan, String role); + + /** + * Gets all the groups and users that have been directly assigned to a role. + * + * @param filePlan file plan + * @param role role + * @return {@link Set}<{@link String}> set of groups and users + */ + Set getAllAssignedToRole(NodeRef filePlan, String role); + + /** + * Assign a role to an authority + * + * @param filePlan file plan + * @param role role + * @param authorityName authority name + */ + void assignRoleToAuthority(NodeRef filePlan, String role, String authorityName); + + + /** + * Unassign a role from an authority + * + * @param filePlan file plan + * @param role role + * @param authorityName authority name + */ + void unassignRoleFromAuthority(NodeRef filePlan, String role, String authorityName); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java index 3f84eda2c1..c227fa2a80 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java @@ -1,876 +1,876 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.role; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.bootstrap.BootstrapImporterModuleComponent; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authority.RMAuthority; -import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Role service implementation - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FilePlanRoleServiceImpl implements FilePlanRoleService, - RecordsManagementModel -{ - /** I18N */ - private static final String MSG_ALL_ROLES = "rm.role.all"; - - /** Location of bootstrap role JSON */ - private static final String BOOTSTRAP_ROLE_JSON_LOCATION = "alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json"; - - /** JSON names */ - private static final String JSON_NAME = "name"; - private static final String JSON_DISPLAY_LABEL = "displayLabel"; - private static final String JSON_IS_ADMIN = "isAdmin"; - private static final String JSON_CAPABILITIES = "capabilities"; - - /** Capability service */ - private CapabilityService capabilityService; - - /** Authority service */ - private AuthorityService authorityService; - - /** Permission service */ - private PermissionService permissionService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Node service */ - private NodeService nodeService; - - private BootstrapImporterModuleComponent bootstrapImporterModule; - - /** Records management role zone */ - public static final String RM_ROLE_ZONE_PREFIX = "rmRoleZone"; - - /** Records Management Config Node */ - private static final String CONFIG_NODEID = "rm_config_folder"; - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * - * @param bootstrapImporterModuleComponent - */ - public void setBootstrapImporterModuleComponent(BootstrapImporterModuleComponent bootstrapImporterModuleComponent) - { - this.bootstrapImporterModule = bootstrapImporterModuleComponent; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#initialiseFilePlan(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void setupFilePlanRoles(final NodeRef filePlan) - { - // Do not execute behaviour if this has been created in the archive store - if(filePlan.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) - { - // This is not the spaces store - probably the archive store - return; - } - - if (nodeService.exists(filePlan)) - { - List systemContainers = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork>() - { - public List doWork() - { - List systemContainers = new ArrayList(3); - - //In a multi tenant store we need to initialize the rm config if it has been done yet - NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); - if (!nodeService.exists(nodeRef)) - { - bootstrapImporterModule.execute(); - } - - // Create "all" role group for root node - String allRoles = authorityService.createAuthority( - AuthorityType.GROUP, - getAllRolesGroupShortName(filePlan), - I18NUtil.getMessage(MSG_ALL_ROLES), - new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); - - // Set the permissions - permissionService.setInheritParentPermissions(filePlan, false); - permissionService.setPermission(filePlan, allRoles, RMPermissionModel.READ_RECORDS, true); - - // Create the transfer and hold containers - systemContainers.add(filePlanService.createHoldContainer(filePlan)); - systemContainers.add(filePlanService.createTransferContainer(filePlan)); - - // Create the unfiled record container - systemContainers.add(filePlanService.createUnfiledContainer(filePlan)); - - return systemContainers; - } - }); - - // Bootstrap in the default set of roles for the newly created root node - bootstrapDefaultRoles(filePlan, systemContainers); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#tearDownFilePlanRoles(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void tearDownFilePlanRoles(final NodeRef filePlan) - { - AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - // cascade delete the 'all' roles group for the site - String allRolesGroup = authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); - Set groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, allRolesGroup, true); - for (String group : groups) - { - authorityService.deleteAuthority(group); - } - - authorityService.deleteAuthority(allRolesGroup, false); - - return null; - } - }); - } - - /** - * Get all the roles by short name - * - * @param rmRootNode - * @return - */ - private String getAllRolesGroupShortName(NodeRef rmRootNode) - { - return RMAuthority.ALL_ROLES_PREFIX + rmRootNode.getId(); - } - - /** - * Bootstraps the default roles - * - * @param filePlan file plan - * @param systemContainers system containers - */ - private void bootstrapDefaultRoles(final NodeRef filePlan, final List systemContainers) - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - try - { - JSONArray array = null; - try - { - // Load up the default roles from JSON - InputStream is = getClass().getClassLoader().getResourceAsStream(BOOTSTRAP_ROLE_JSON_LOCATION); - if (is == null) - { - throw new AlfrescoRuntimeException("Could not load default bootstrap roles configuration"); - } - array = new JSONArray(convertStreamToString(is)); - } - catch (IOException ioe) - { - throw new AlfrescoRuntimeException("Unable to load rm-default-roles-bootstrap.json configuration file.", ioe); - } - - // Add each role to the rm root node - for (int i = 0; i < array.length(); i++) - { - JSONObject object = array.getJSONObject(i); - - // Get the name of the role - String name = null; - if (object.has(JSON_NAME)) - { - name = object.getString(JSON_NAME); - if (existsRole(filePlan, name)) - { - throw new AlfrescoRuntimeException("The bootstrap role " + name + " already exists on the rm root node " + filePlan.toString()); - } - } - else - { - throw new AlfrescoRuntimeException("No name given to default bootstrap role. Check json configuration file."); - } - - - // Get the role's display label - String displayLabel = name; - if (object.has(JSON_DISPLAY_LABEL)) - { - displayLabel = object.getString(JSON_DISPLAY_LABEL); - } - - // Determine whether the role is an admin role or not - boolean isAdmin = false; - if (object.has(JSON_IS_ADMIN)) - { - isAdmin = object.getBoolean(JSON_IS_ADMIN); - } - - // Get the roles capabilities - Set capabilities = new HashSet(30); - if (object.has(JSON_CAPABILITIES)) - { - JSONArray arrCaps = object.getJSONArray(JSON_CAPABILITIES); - for (int index = 0; index < arrCaps.length(); index++) - { - String capName = arrCaps.getString(index); - Capability capability = capabilityService.getCapability(capName); - if (capability == null) - { - throw new AlfrescoRuntimeException("The capability '" + capName + "' configured for the deafult boostrap role '" + name + "' is invalid."); - } - capabilities.add(capability); - } - } - - // Create the role - Role role = createRole(filePlan, name, displayLabel, capabilities); - - // Add any additional admin permissions - if (isAdmin) - { - // Admin has filing - permissionService.setPermission(filePlan, role.getRoleGroupName(), RMPermissionModel.FILING, true); - if (systemContainers != null) - { - for (NodeRef systemContainer : systemContainers) - { - permissionService.setPermission(systemContainer, role.getRoleGroupName(), RMPermissionModel.FILING, true); - } - } - - // Add the creating user to the administration group - String user = AuthenticationUtil.getFullyAuthenticatedUser(); - authorityService.addAuthority(role.getRoleGroupName(), user); - - if (!AuthenticationUtil.getAdminUserName().equals(user)) - { - // add the dynamic admin authority - authorityService.addAuthority(role.getRoleGroupName(), AuthenticationUtil.getAdminUserName()); - } - } - } - } - catch (JSONException exception) - { - throw new AlfrescoRuntimeException("Error loading json configuration file rm-default-roles-bootstrap.json", exception); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Helper method to convert a stream to a string. - * - * @param is input stream - * @return {@link String} string - * @throws IOException - */ - public String convertStreamToString(InputStream is) throws IOException - { - /* - * To convert the InputStream to String we use the BufferedReader.readLine() - * method. We iterate until the BufferedReader return null which means - * there's no more data to read. Each line will appended to a StringBuilder - * and returned as String. - */ - BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); - StringBuilder sb = new StringBuilder(); - - String line = null; - try - { - while ((line = reader.readLine()) != null) - { - sb.append(line + "\n"); - } - } - finally - { - try {is.close();} catch (IOException e) {} - } - - return sb.toString(); - } - - /** - * Helper method to check whether the current authority is a system role or not - * - * @param roleAuthority The role to check - * @return Returns true if roleAuthority is a system role, false otherwise - */ - private boolean isSystemRole(String roleAuthority) - { - boolean isSystemRole = false; - - for (String systemRole : SYSTEM_ROLES) - { - if (StringUtils.contains(roleAuthority, systemRole)) - { - isSystemRole = true; - break; - } - } - - return isSystemRole; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRoles() - */ - public Set getRoles(final NodeRef rmRootNode) - { - return getRoles(rmRootNode, true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getRoles(NodeRef, boolean) - */ - @Override - public Set getRoles(final NodeRef rmRootNode, final boolean includeSystemRoles) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public Set doWork() - { - Set result = new HashSet(13); - - Set roleAuthorities = authorityService.getAllAuthoritiesInZone(getZoneName(rmRootNode), AuthorityType.GROUP); - for (String roleAuthority : roleAuthorities) - { - if (includeSystemRoles || !isSystemRole(roleAuthority)) - { - String groupShortName = authorityService.getShortName(roleAuthority); - String name = getShortRoleName(groupShortName, rmRootNode); - String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); - String translated = I18NUtil.getMessage(displayLabel); - if (translated != null) - { - displayLabel = translated; - } - Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); - - Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); - result.add(role); - } - } - - return result; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRolesByUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public Set getRolesByUser(final NodeRef rmRootNode, final String user) - { - return getRolesByUser(rmRootNode, user, true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getRolesByUser(NodeRef, String, boolean) - */ - @Override - public Set getRolesByUser(final NodeRef rmRootNode, final String user, final boolean includeSystemRoles) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public Set doWork() - { - Set result = new HashSet(13); - - Set roleAuthorities = authorityService.getAllAuthoritiesInZone(getZoneName(rmRootNode), AuthorityType.GROUP); - for (String roleAuthority : roleAuthorities) - { - Set users = authorityService.getContainedAuthorities(AuthorityType.USER, roleAuthority, false); - if (users.contains(user) && (includeSystemRoles || !isSystemRole(roleAuthority))) - { - String groupShortName = authorityService.getShortName(roleAuthority); - String name = getShortRoleName(groupShortName, rmRootNode); - String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); - String translated = I18NUtil.getMessage(displayLabel); - if (translated != null) - { - displayLabel = translated; - } - Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); - - Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); - result.add(role); - } - } - - return result; - } - }, AuthenticationUtil.getSystemUserName()); - }; - - /** - * - * @param rmRootNode - * @return - */ - private String getZoneName(NodeRef rmRootNode) - { - return RM_ROLE_ZONE_PREFIX + rmRootNode.getId(); - } - - /** - * Get the full role name - * - * @param role - * @param rmRootNode - * @return - */ - private String getFullRoleName(String role, NodeRef rmRootNode) - { - return role + rmRootNode.getId(); - } - - /** - * Get the short role name - * - * @param fullRoleName - * @param rmRootNode - * @return - */ - private String getShortRoleName(String fullRoleName, NodeRef rmRootNode) - { - return fullRoleName.replaceAll(rmRootNode.getId(), ""); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public Role getRole(final NodeRef rmRootNode, final String role) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Role doWork() - { - Role result = null; - - String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); - if (authorityService.authorityExists(roleAuthority)) - { - String name = getShortRoleName(authorityService.getShortName(roleAuthority), rmRootNode); - String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); - Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); - - result = new Role(name, displayLabel, capabilities, roleAuthority); - } - - return result; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * - * @param rmRootNode - * @param roleAuthority - * @return - */ - private Set getCapabilitiesImpl(NodeRef rmRootNode, String roleAuthority) - { - Set permissions = permissionService.getAllSetPermissions(rmRootNode); - Set capabilities = new HashSet(52); - for (AccessPermission permission : permissions) - { - if (permission.getAuthority().equals(roleAuthority)) - { - String capabilityName = permission.getPermission(); - Capability capability = capabilityService.getCapability(capabilityName); - if (capability != null && !capability.isPrivate()) - { - capabilities.add(capability); - } - } - } - - return capabilities; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#existsRole(java.lang.String) - */ - public boolean existsRole(final NodeRef rmRootNode, final String role) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Boolean doWork() - { - String fullRoleName = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); - - String zone = getZoneName(rmRootNode); - Set roles = authorityService.getAllAuthoritiesInZone(zone, AuthorityType.GROUP); - return Boolean.valueOf(roles.contains(fullRoleName)); - } - }, AuthenticationUtil.getSystemUserName()).booleanValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#hasRMAdminRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - * - * TODO .. change this to check a property of the role its self - */ - public boolean hasRMAdminRole(NodeRef rmRootNode, String user) - { - boolean isAdmin = false; - - Set userRoles = this.getRolesByUser(rmRootNode, user); - if (userRoles != null) - { - for (Role role : userRoles) - { - if (role.getName().equals("Administrator")) - { - isAdmin = true; - break; - } - } - } - - return isAdmin; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#createRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) - */ - public Role createRole(final NodeRef filePlan, final String role, final String roleDisplayLabel, final Set capabilities) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Role doWork() - { - String fullRoleName = getFullRoleName(role, filePlan); - - // Check that the role does not already exist for the rm root node - if (authorityService.authorityExists(authorityService.getName(AuthorityType.GROUP, fullRoleName))) - { - throw new AlfrescoRuntimeException("The role " + role + " already exists for root rm node " + filePlan.getId()); - } - - // Create a group that relates to the records management role - Set zones = new HashSet(2); - zones.add(getZoneName(filePlan)); - zones.add(RMAuthority.ZONE_APP_RM); - - // Look up string, default to passed value if none found - String groupDisplayLabel = I18NUtil.getMessage(roleDisplayLabel); - if (groupDisplayLabel == null) - { - groupDisplayLabel = roleDisplayLabel; - } - - String roleGroup = authorityService.createAuthority(AuthorityType.GROUP, fullRoleName, groupDisplayLabel, zones); - - // do not add system roles to "all" - if (!isSystemRole(role)) - { - // Add the roleGroup to the "all" role group - String allRoleGroup = authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); - authorityService.addAuthority(allRoleGroup, roleGroup); - } - - // TODO .. we should be creating a permission set containing all the capabilities and then assigning that - // single permission group to the file plan .. would be tidier - - // Assign the various capabilities to the group on the root records management node - if (capabilities != null) - { - for (Capability capability : capabilities) - { - permissionService.setPermission(filePlan, roleGroup, capability.getName(), true); - } - } - - return new Role(role, roleDisplayLabel, capabilities, roleGroup); - } - }, AuthenticationUtil.getSystemUserName()); - } - - - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) - */ - public Role updateRole(final NodeRef rmRootNode, final String role, final String roleDisplayLabel, final Set capabilities) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Role doWork() - { - if (!existsRole(rmRootNode, role)) - { - throw new AlfrescoRuntimeException("Unable to update role " + role + ", because it does not exist."); - } - - String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); - - // Reset the role display name - authorityService.setAuthorityDisplayName(roleAuthority, roleDisplayLabel); - - // TODO this needs to be improved, removing all and reading is not ideal - - // Clear the current capabilities - permissionService.clearPermission(rmRootNode, roleAuthority); - - // Re-add the provided capabilities - for (Capability capability : capabilities) - { - permissionService.setPermission(rmRootNode, roleAuthority, capability.getName(), true); - } - - return new Role(role, roleDisplayLabel, capabilities, roleAuthority); - - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deleteRole(java.lang.String) - */ - public void deleteRole(final NodeRef rmRootNode, final String role) - { - // ensure that we are not trying to delete the admin role - if (ROLE_ADMIN.equals(role)) - { - throw new AlfrescoRuntimeException("Can not delete the records management administration role."); - } - - // ensure that we are not trying to delete a system role - if (FilePlanRoleService.SYSTEM_ROLES.contains(role)) - { - throw new AlfrescoRuntimeException("'" + role + "' is a system role and cannot be deleted."); - } - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); - authorityService.deleteAuthority(roleAuthority); - return null; - - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getUsersAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public Set getUsersAssignedToRole(final NodeRef filePlan, final String roleName) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("roleName", roleName); - - return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.USER); - } - - /** - * Gets all the authorities of a given type directly assigned to the given role in the file plan. - * - * @param filePlan file plan - * @param roleName role name - * @param authorityType authority type - * @return Set directly assigned authorities - */ - private Set getAuthoritiesAssignedToRole(final NodeRef filePlan, final String roleName, final AuthorityType authorityType) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public Set doWork() - { - Role role = getRole(filePlan, roleName); - if (role == null) - { - throw new AlfrescoRuntimeException("Can not get authorities for role " + roleName + ", because it does not exist. (filePlan=" + filePlan.toString() + ")"); - } - return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), true); - } - }, AuthenticationUtil.getSystemUserName()); - - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getGroupsAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public Set getGroupsAssignedToRole(final NodeRef filePlan, final String roleName) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("roleName", roleName); - - return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.GROUP); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getAllAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public Set getAllAssignedToRole(NodeRef filePlan, String role) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("roleName", role); - - Set result = new HashSet(21); - result.addAll(getUsersAssignedToRole(filePlan, role)); - result.addAll(getGroupsAssignedToRole(filePlan, role)); - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - public void assignRoleToAuthority(final NodeRef filePlan, final String role, final String authorityName) - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - if (!getAllAssignedToRole(filePlan, role).contains(authorityName)) - { - String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan)); - try - { - authorityService.addAuthority(roleAuthority, authorityName); - } - catch (DuplicateChildNodeNameException exception) - { - // ignore, because the work has already been performed - } - } - return null; - - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#unassignRoleFromAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - @Override - public void unassignRoleFromAuthority(final NodeRef filePlan, final String role, final String authorityName) - { - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan)); - authorityService.removeAuthority(roleAuthority, authorityName); - return null; - - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String getAllRolesContainerGroup(NodeRef filePlan) - { - return authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.role; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.bootstrap.BootstrapImporterModuleComponent; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Role service implementation + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FilePlanRoleServiceImpl implements FilePlanRoleService, + RecordsManagementModel +{ + /** I18N */ + private static final String MSG_ALL_ROLES = "rm.role.all"; + + /** Location of bootstrap role JSON */ + private static final String BOOTSTRAP_ROLE_JSON_LOCATION = "alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json"; + + /** JSON names */ + private static final String JSON_NAME = "name"; + private static final String JSON_DISPLAY_LABEL = "displayLabel"; + private static final String JSON_IS_ADMIN = "isAdmin"; + private static final String JSON_CAPABILITIES = "capabilities"; + + /** Capability service */ + private CapabilityService capabilityService; + + /** Authority service */ + private AuthorityService authorityService; + + /** Permission service */ + private PermissionService permissionService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Node service */ + private NodeService nodeService; + + private BootstrapImporterModuleComponent bootstrapImporterModule; + + /** Records management role zone */ + public static final String RM_ROLE_ZONE_PREFIX = "rmRoleZone"; + + /** Records Management Config Node */ + private static final String CONFIG_NODEID = "rm_config_folder"; + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * + * @param bootstrapImporterModuleComponent + */ + public void setBootstrapImporterModuleComponent(BootstrapImporterModuleComponent bootstrapImporterModuleComponent) + { + this.bootstrapImporterModule = bootstrapImporterModuleComponent; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#initialiseFilePlan(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void setupFilePlanRoles(final NodeRef filePlan) + { + // Do not execute behaviour if this has been created in the archive store + if(filePlan.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) + { + // This is not the spaces store - probably the archive store + return; + } + + if (nodeService.exists(filePlan)) + { + List systemContainers = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork>() + { + public List doWork() + { + List systemContainers = new ArrayList(3); + + //In a multi tenant store we need to initialize the rm config if it has been done yet + NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); + if (!nodeService.exists(nodeRef)) + { + bootstrapImporterModule.execute(); + } + + // Create "all" role group for root node + String allRoles = authorityService.createAuthority( + AuthorityType.GROUP, + getAllRolesGroupShortName(filePlan), + I18NUtil.getMessage(MSG_ALL_ROLES), + new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); + + // Set the permissions + permissionService.setInheritParentPermissions(filePlan, false); + permissionService.setPermission(filePlan, allRoles, RMPermissionModel.READ_RECORDS, true); + + // Create the transfer and hold containers + systemContainers.add(filePlanService.createHoldContainer(filePlan)); + systemContainers.add(filePlanService.createTransferContainer(filePlan)); + + // Create the unfiled record container + systemContainers.add(filePlanService.createUnfiledContainer(filePlan)); + + return systemContainers; + } + }); + + // Bootstrap in the default set of roles for the newly created root node + bootstrapDefaultRoles(filePlan, systemContainers); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#tearDownFilePlanRoles(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void tearDownFilePlanRoles(final NodeRef filePlan) + { + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + // cascade delete the 'all' roles group for the site + String allRolesGroup = authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); + Set groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, allRolesGroup, true); + for (String group : groups) + { + authorityService.deleteAuthority(group); + } + + authorityService.deleteAuthority(allRolesGroup, false); + + return null; + } + }); + } + + /** + * Get all the roles by short name + * + * @param rmRootNode + * @return + */ + private String getAllRolesGroupShortName(NodeRef rmRootNode) + { + return RMAuthority.ALL_ROLES_PREFIX + rmRootNode.getId(); + } + + /** + * Bootstraps the default roles + * + * @param filePlan file plan + * @param systemContainers system containers + */ + private void bootstrapDefaultRoles(final NodeRef filePlan, final List systemContainers) + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + try + { + JSONArray array = null; + try + { + // Load up the default roles from JSON + InputStream is = getClass().getClassLoader().getResourceAsStream(BOOTSTRAP_ROLE_JSON_LOCATION); + if (is == null) + { + throw new AlfrescoRuntimeException("Could not load default bootstrap roles configuration"); + } + array = new JSONArray(convertStreamToString(is)); + } + catch (IOException ioe) + { + throw new AlfrescoRuntimeException("Unable to load rm-default-roles-bootstrap.json configuration file.", ioe); + } + + // Add each role to the rm root node + for (int i = 0; i < array.length(); i++) + { + JSONObject object = array.getJSONObject(i); + + // Get the name of the role + String name = null; + if (object.has(JSON_NAME)) + { + name = object.getString(JSON_NAME); + if (existsRole(filePlan, name)) + { + throw new AlfrescoRuntimeException("The bootstrap role " + name + " already exists on the rm root node " + filePlan.toString()); + } + } + else + { + throw new AlfrescoRuntimeException("No name given to default bootstrap role. Check json configuration file."); + } + + + // Get the role's display label + String displayLabel = name; + if (object.has(JSON_DISPLAY_LABEL)) + { + displayLabel = object.getString(JSON_DISPLAY_LABEL); + } + + // Determine whether the role is an admin role or not + boolean isAdmin = false; + if (object.has(JSON_IS_ADMIN)) + { + isAdmin = object.getBoolean(JSON_IS_ADMIN); + } + + // Get the roles capabilities + Set capabilities = new HashSet(30); + if (object.has(JSON_CAPABILITIES)) + { + JSONArray arrCaps = object.getJSONArray(JSON_CAPABILITIES); + for (int index = 0; index < arrCaps.length(); index++) + { + String capName = arrCaps.getString(index); + Capability capability = capabilityService.getCapability(capName); + if (capability == null) + { + throw new AlfrescoRuntimeException("The capability '" + capName + "' configured for the deafult boostrap role '" + name + "' is invalid."); + } + capabilities.add(capability); + } + } + + // Create the role + Role role = createRole(filePlan, name, displayLabel, capabilities); + + // Add any additional admin permissions + if (isAdmin) + { + // Admin has filing + permissionService.setPermission(filePlan, role.getRoleGroupName(), RMPermissionModel.FILING, true); + if (systemContainers != null) + { + for (NodeRef systemContainer : systemContainers) + { + permissionService.setPermission(systemContainer, role.getRoleGroupName(), RMPermissionModel.FILING, true); + } + } + + // Add the creating user to the administration group + String user = AuthenticationUtil.getFullyAuthenticatedUser(); + authorityService.addAuthority(role.getRoleGroupName(), user); + + if (!AuthenticationUtil.getAdminUserName().equals(user)) + { + // add the dynamic admin authority + authorityService.addAuthority(role.getRoleGroupName(), AuthenticationUtil.getAdminUserName()); + } + } + } + } + catch (JSONException exception) + { + throw new AlfrescoRuntimeException("Error loading json configuration file rm-default-roles-bootstrap.json", exception); + } + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Helper method to convert a stream to a string. + * + * @param is input stream + * @return {@link String} string + * @throws IOException + */ + public String convertStreamToString(InputStream is) throws IOException + { + /* + * To convert the InputStream to String we use the BufferedReader.readLine() + * method. We iterate until the BufferedReader return null which means + * there's no more data to read. Each line will appended to a StringBuilder + * and returned as String. + */ + BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + StringBuilder sb = new StringBuilder(); + + String line = null; + try + { + while ((line = reader.readLine()) != null) + { + sb.append(line + "\n"); + } + } + finally + { + try {is.close();} catch (IOException e) {} + } + + return sb.toString(); + } + + /** + * Helper method to check whether the current authority is a system role or not + * + * @param roleAuthority The role to check + * @return Returns true if roleAuthority is a system role, false otherwise + */ + private boolean isSystemRole(String roleAuthority) + { + boolean isSystemRole = false; + + for (String systemRole : SYSTEM_ROLES) + { + if (StringUtils.contains(roleAuthority, systemRole)) + { + isSystemRole = true; + break; + } + } + + return isSystemRole; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRoles() + */ + public Set getRoles(final NodeRef rmRootNode) + { + return getRoles(rmRootNode, true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getRoles(NodeRef, boolean) + */ + @Override + public Set getRoles(final NodeRef rmRootNode, final boolean includeSystemRoles) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() + { + public Set doWork() + { + Set result = new HashSet(13); + + Set roleAuthorities = authorityService.getAllAuthoritiesInZone(getZoneName(rmRootNode), AuthorityType.GROUP); + for (String roleAuthority : roleAuthorities) + { + if (includeSystemRoles || !isSystemRole(roleAuthority)) + { + String groupShortName = authorityService.getShortName(roleAuthority); + String name = getShortRoleName(groupShortName, rmRootNode); + String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); + String translated = I18NUtil.getMessage(displayLabel); + if (translated != null) + { + displayLabel = translated; + } + Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); + + Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); + result.add(role); + } + } + + return result; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRolesByUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + public Set getRolesByUser(final NodeRef rmRootNode, final String user) + { + return getRolesByUser(rmRootNode, user, true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getRolesByUser(NodeRef, String, boolean) + */ + @Override + public Set getRolesByUser(final NodeRef rmRootNode, final String user, final boolean includeSystemRoles) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() + { + public Set doWork() + { + Set result = new HashSet(13); + + Set roleAuthorities = authorityService.getAllAuthoritiesInZone(getZoneName(rmRootNode), AuthorityType.GROUP); + for (String roleAuthority : roleAuthorities) + { + Set users = authorityService.getContainedAuthorities(AuthorityType.USER, roleAuthority, false); + if (users.contains(user) && (includeSystemRoles || !isSystemRole(roleAuthority))) + { + String groupShortName = authorityService.getShortName(roleAuthority); + String name = getShortRoleName(groupShortName, rmRootNode); + String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); + String translated = I18NUtil.getMessage(displayLabel); + if (translated != null) + { + displayLabel = translated; + } + Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); + + Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); + result.add(role); + } + } + + return result; + } + }, AuthenticationUtil.getSystemUserName()); + }; + + /** + * + * @param rmRootNode + * @return + */ + private String getZoneName(NodeRef rmRootNode) + { + return RM_ROLE_ZONE_PREFIX + rmRootNode.getId(); + } + + /** + * Get the full role name + * + * @param role + * @param rmRootNode + * @return + */ + private String getFullRoleName(String role, NodeRef rmRootNode) + { + return role + rmRootNode.getId(); + } + + /** + * Get the short role name + * + * @param fullRoleName + * @param rmRootNode + * @return + */ + private String getShortRoleName(String fullRoleName, NodeRef rmRootNode) + { + return fullRoleName.replaceAll(rmRootNode.getId(), ""); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + public Role getRole(final NodeRef rmRootNode, final String role) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Role doWork() + { + Role result = null; + + String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); + if (authorityService.authorityExists(roleAuthority)) + { + String name = getShortRoleName(authorityService.getShortName(roleAuthority), rmRootNode); + String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); + Set capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); + + result = new Role(name, displayLabel, capabilities, roleAuthority); + } + + return result; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * + * @param rmRootNode + * @param roleAuthority + * @return + */ + private Set getCapabilitiesImpl(NodeRef rmRootNode, String roleAuthority) + { + Set permissions = permissionService.getAllSetPermissions(rmRootNode); + Set capabilities = new HashSet(52); + for (AccessPermission permission : permissions) + { + if (permission.getAuthority().equals(roleAuthority)) + { + String capabilityName = permission.getPermission(); + Capability capability = capabilityService.getCapability(capabilityName); + if (capability != null && !capability.isPrivate()) + { + capabilities.add(capability); + } + } + } + + return capabilities; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#existsRole(java.lang.String) + */ + public boolean existsRole(final NodeRef rmRootNode, final String role) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Boolean doWork() + { + String fullRoleName = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); + + String zone = getZoneName(rmRootNode); + Set roles = authorityService.getAllAuthoritiesInZone(zone, AuthorityType.GROUP); + return Boolean.valueOf(roles.contains(fullRoleName)); + } + }, AuthenticationUtil.getSystemUserName()).booleanValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#hasRMAdminRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + * + * TODO .. change this to check a property of the role its self + */ + public boolean hasRMAdminRole(NodeRef rmRootNode, String user) + { + boolean isAdmin = false; + + Set userRoles = this.getRolesByUser(rmRootNode, user); + if (userRoles != null) + { + for (Role role : userRoles) + { + if (role.getName().equals("Administrator")) + { + isAdmin = true; + break; + } + } + } + + return isAdmin; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#createRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) + */ + public Role createRole(final NodeRef filePlan, final String role, final String roleDisplayLabel, final Set capabilities) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Role doWork() + { + String fullRoleName = getFullRoleName(role, filePlan); + + // Check that the role does not already exist for the rm root node + if (authorityService.authorityExists(authorityService.getName(AuthorityType.GROUP, fullRoleName))) + { + throw new AlfrescoRuntimeException("The role " + role + " already exists for root rm node " + filePlan.getId()); + } + + // Create a group that relates to the records management role + Set zones = new HashSet(2); + zones.add(getZoneName(filePlan)); + zones.add(RMAuthority.ZONE_APP_RM); + + // Look up string, default to passed value if none found + String groupDisplayLabel = I18NUtil.getMessage(roleDisplayLabel); + if (groupDisplayLabel == null) + { + groupDisplayLabel = roleDisplayLabel; + } + + String roleGroup = authorityService.createAuthority(AuthorityType.GROUP, fullRoleName, groupDisplayLabel, zones); + + // do not add system roles to "all" + if (!isSystemRole(role)) + { + // Add the roleGroup to the "all" role group + String allRoleGroup = authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); + authorityService.addAuthority(allRoleGroup, roleGroup); + } + + // TODO .. we should be creating a permission set containing all the capabilities and then assigning that + // single permission group to the file plan .. would be tidier + + // Assign the various capabilities to the group on the root records management node + if (capabilities != null) + { + for (Capability capability : capabilities) + { + permissionService.setPermission(filePlan, roleGroup, capability.getName(), true); + } + } + + return new Role(role, roleDisplayLabel, capabilities, roleGroup); + } + }, AuthenticationUtil.getSystemUserName()); + } + + + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set) + */ + public Role updateRole(final NodeRef rmRootNode, final String role, final String roleDisplayLabel, final Set capabilities) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Role doWork() + { + if (!existsRole(rmRootNode, role)) + { + throw new AlfrescoRuntimeException("Unable to update role " + role + ", because it does not exist."); + } + + String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); + + // Reset the role display name + authorityService.setAuthorityDisplayName(roleAuthority, roleDisplayLabel); + + // TODO this needs to be improved, removing all and reading is not ideal + + // Clear the current capabilities + permissionService.clearPermission(rmRootNode, roleAuthority); + + // Re-add the provided capabilities + for (Capability capability : capabilities) + { + permissionService.setPermission(rmRootNode, roleAuthority, capability.getName(), true); + } + + return new Role(role, roleDisplayLabel, capabilities, roleAuthority); + + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deleteRole(java.lang.String) + */ + public void deleteRole(final NodeRef rmRootNode, final String role) + { + // ensure that we are not trying to delete the admin role + if (ROLE_ADMIN.equals(role)) + { + throw new AlfrescoRuntimeException("Can not delete the records management administration role."); + } + + // ensure that we are not trying to delete a system role + if (FilePlanRoleService.SYSTEM_ROLES.contains(role)) + { + throw new AlfrescoRuntimeException("'" + role + "' is a system role and cannot be deleted."); + } + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode)); + authorityService.deleteAuthority(roleAuthority); + return null; + + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getUsersAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public Set getUsersAssignedToRole(final NodeRef filePlan, final String roleName) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("roleName", roleName); + + return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.USER); + } + + /** + * Gets all the authorities of a given type directly assigned to the given role in the file plan. + * + * @param filePlan file plan + * @param roleName role name + * @param authorityType authority type + * @return Set directly assigned authorities + */ + private Set getAuthoritiesAssignedToRole(final NodeRef filePlan, final String roleName, final AuthorityType authorityType) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() + { + public Set doWork() + { + Role role = getRole(filePlan, roleName); + if (role == null) + { + throw new AlfrescoRuntimeException("Can not get authorities for role " + roleName + ", because it does not exist. (filePlan=" + filePlan.toString() + ")"); + } + return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), true); + } + }, AuthenticationUtil.getSystemUserName()); + + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getGroupsAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public Set getGroupsAssignedToRole(final NodeRef filePlan, final String roleName) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("roleName", roleName); + + return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.GROUP); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getAllAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public Set getAllAssignedToRole(NodeRef filePlan, String role) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("roleName", role); + + Set result = new HashSet(21); + result.addAll(getUsersAssignedToRole(filePlan, role)); + result.addAll(getGroupsAssignedToRole(filePlan, role)); + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + public void assignRoleToAuthority(final NodeRef filePlan, final String role, final String authorityName) + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + if (!getAllAssignedToRole(filePlan, role).contains(authorityName)) + { + String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan)); + try + { + authorityService.addAuthority(roleAuthority, authorityName); + } + catch (DuplicateChildNodeNameException exception) + { + // ignore, because the work has already been performed + } + } + return null; + + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#unassignRoleFromAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + @Override + public void unassignRoleFromAuthority(final NodeRef filePlan, final String role, final String authorityName) + { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan)); + authorityService.removeAuthority(roleAuthority, authorityName); + return null; + + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String getAllRolesContainerGroup(NodeRef filePlan) + { + return authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan)); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/Role.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/Role.java index 948995b873..c6007904b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/Role.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/Role.java @@ -1,114 +1,114 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.role; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; - -/** - * Records management role class - * - * @author Roy Wetherall - */ -public class Role -{ - /** Role name */ - private String name; - - /** Role label */ - private String displayLabel; - - /** Role capabilities */ - private Set capabilities; - - /** Role group name */ - private String roleGroupName; - - /** Role group short name */ - private String groupShortName; - - /** - * @param name - * @param displayLabel - * @param capabilities - * @param roleGroupName - */ - public Role(String name, String displayLabel, Set capabilities, String roleGroupName) - { - this.name = name; - this.displayLabel = displayLabel; - this.capabilities = capabilities; - this.roleGroupName = roleGroupName; - } - - /** - * @param name - * @param displayLabel - * @param capabilities - * @param roleGroupName - * @param groupShortName - */ - public Role(String name, String displayLabel, Set capabilities, String roleGroupName, String groupShortName) - { - this(name, displayLabel, capabilities, roleGroupName); - this.groupShortName = groupShortName; - } - - /** - * @return the name - */ - public String getName() - { - return name; - } - - /** - * @return the displayLabel - */ - public String getDisplayLabel() - { - return displayLabel; - } - - /** - * @return the capabilities - */ - public Set getCapabilities() - { - return capabilities; - } - - /** - * @return the roleGroupName - */ - public String getRoleGroupName() - { - return roleGroupName; - } - - /** - * @return the groupShortName - */ - public String getGroupShortName() - { - return this.groupShortName; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.role; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; + +/** + * Records management role class + * + * @author Roy Wetherall + */ +public class Role +{ + /** Role name */ + private String name; + + /** Role label */ + private String displayLabel; + + /** Role capabilities */ + private Set capabilities; + + /** Role group name */ + private String roleGroupName; + + /** Role group short name */ + private String groupShortName; + + /** + * @param name + * @param displayLabel + * @param capabilities + * @param roleGroupName + */ + public Role(String name, String displayLabel, Set capabilities, String roleGroupName) + { + this.name = name; + this.displayLabel = displayLabel; + this.capabilities = capabilities; + this.roleGroupName = roleGroupName; + } + + /** + * @param name + * @param displayLabel + * @param capabilities + * @param roleGroupName + * @param groupShortName + */ + public Role(String name, String displayLabel, Set capabilities, String roleGroupName, String groupShortName) + { + this(name, displayLabel, capabilities, roleGroupName); + this.groupShortName = groupShortName; + } + + /** + * @return the name + */ + public String getName() + { + return name; + } + + /** + * @return the displayLabel + */ + public String getDisplayLabel() + { + return displayLabel; + } + + /** + * @return the capabilities + */ + public Set getCapabilities() + { + return capabilities; + } + + /** + * @return the roleGroupName + */ + public String getRoleGroupName() + { + return roleGroupName; + } + + /** + * @return the groupShortName + */ + public String getGroupShortName() + { + return this.groupShortName; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java index 9a6704959d..cb6c01070a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java @@ -1,149 +1,149 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import static org.alfresco.util.WebScriptUtils.getTemplateVars; - -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Abstract base class for all RM webscript classes. - * Includes utility methods for processing the webscript request. - * - * @author Neil McErlean - * @author Tuna Aksoy - */ -public abstract class AbstractRmWebScript extends DeclarativeWebScript -{ - /** Constants */ - protected static final String PATH_SEPARATOR = "/"; - protected static final String STORE_TYPE = "store_type"; - protected static final String STORE_ID = "store_id"; - protected static final String ID = "id"; - protected static final String SUCCESS = "success"; - protected static final String INVERT = "__invert"; - - /** Disposition service */ - private DispositionService dispositionService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Node service */ - private NodeService nodeService; - - /** - * Gets the disposition service instance - * - * @return The disposition service instance - */ - protected DispositionService getDispositionService() - { - return this.dispositionService; - } - - /** - * Sets the disposition service instance - * - * @param dispositionService The disposition service instance - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Gets the namespace service instance - * - * @return The namespace service instance - */ - protected NamespaceService getNamespaceService() - { - return this.namespaceService; - } - - /** - * Sets the namespace service instance - * - * @param namespaceService The namespace service instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Gets the node service instance - * - * @return The node service instance - */ - protected NodeService getNodeService() - { - return this.nodeService; - } - - /** - * Sets the node service instance - * - * @param nodeService The node service instance - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Parses the request and providing it's valid returns the NodeRef. - * - * @param req The webscript request - * @return The NodeRef passed in the request - * - * @author Gavin Cornwell - */ - protected NodeRef parseRequestForNodeRef(WebScriptRequest req) - { - // get the parameters that represent the NodeRef, we know they are present - // otherwise this webscript would not have matched - Map templateVars = getTemplateVars(req); - String storeType = templateVars.get(STORE_TYPE); - String storeId = templateVars.get(STORE_ID); - String nodeId = templateVars.get(ID); - - // create the NodeRef and ensure it is valid - NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId); - - if (!getNodeService().exists(nodeRef)) - { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" + - nodeRef.toString() + "'."); - } - - return nodeRef; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import static org.alfresco.util.WebScriptUtils.getTemplateVars; + +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Abstract base class for all RM webscript classes. + * Includes utility methods for processing the webscript request. + * + * @author Neil McErlean + * @author Tuna Aksoy + */ +public abstract class AbstractRmWebScript extends DeclarativeWebScript +{ + /** Constants */ + protected static final String PATH_SEPARATOR = "/"; + protected static final String STORE_TYPE = "store_type"; + protected static final String STORE_ID = "store_id"; + protected static final String ID = "id"; + protected static final String SUCCESS = "success"; + protected static final String INVERT = "__invert"; + + /** Disposition service */ + private DispositionService dispositionService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Node service */ + private NodeService nodeService; + + /** + * Gets the disposition service instance + * + * @return The disposition service instance + */ + protected DispositionService getDispositionService() + { + return this.dispositionService; + } + + /** + * Sets the disposition service instance + * + * @param dispositionService The disposition service instance + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Gets the namespace service instance + * + * @return The namespace service instance + */ + protected NamespaceService getNamespaceService() + { + return this.namespaceService; + } + + /** + * Sets the namespace service instance + * + * @param namespaceService The namespace service instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Gets the node service instance + * + * @return The node service instance + */ + protected NodeService getNodeService() + { + return this.nodeService; + } + + /** + * Sets the node service instance + * + * @param nodeService The node service instance + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Parses the request and providing it's valid returns the NodeRef. + * + * @param req The webscript request + * @return The NodeRef passed in the request + * + * @author Gavin Cornwell + */ + protected NodeRef parseRequestForNodeRef(WebScriptRequest req) + { + // get the parameters that represent the NodeRef, we know they are present + // otherwise this webscript would not have matched + Map templateVars = getTemplateVars(req); + String storeType = templateVars.get(STORE_TYPE); + String storeId = templateVars.get(STORE_ID); + String nodeId = templateVars.get(ID); + + // create the NodeRef and ensure it is valid + NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId); + + if (!getNodeService().exists(nodeRef)) + { + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" + + nodeRef.toString() + "'."); + } + + return nodeRef; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyDodCertModelFixesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyDodCertModelFixesGet.java index 754248276a..4f457bdd8f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyDodCertModelFixesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyDodCertModelFixesGet.java @@ -1,218 +1,218 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.dictionary.IndexTokenisationMode; -import org.alfresco.repo.dictionary.M2Aspect; -import org.alfresco.repo.dictionary.M2ClassAssociation; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.dictionary.M2Property; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This webscript applies necessary changes to the RM custom model in the repository. These changes - * are to 'patch' a deployed RM custom model during the DoD certification process. With that in mind - * they are safe to apply to a live database i.e. without side-effect to existing data and safe - * to call multiple times. - *

- * - * TODO This webscript should be removed after DOD certification as none of these patches are needed - * for a newly-installed DoD amp. - * - * @author neilm - */ -@Deprecated -public class ApplyDodCertModelFixesGet extends DeclarativeWebScript - implements RecordsManagementModel -{ - private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef("workspace://SpacesStore/records_management_custom_model"); - private static final String RMC_CUSTOM_RECORD_SERIES_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordSeriesProperties"; - private static final String RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordCategoryProperties"; - private static final String RMC_CUSTOM_RECORD_FOLDER_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordFolderProperties"; - private static final String RMC_CUSTOM_RECORD_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordProperties"; - - /** Logger */ - private static Log logger = LogFactory.getLog(ApplyDodCertModelFixesGet.class); - - private ContentService contentService; - private NamespaceService namespaceService; - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - if (logger.isInfoEnabled()) - { - logger.info("Applying webscript-based patches to RM custom model in the repo."); - } - - M2Model customModel = readCustomContentModel(); - - String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService); - M2Aspect customAssocsAspect = customModel.getAspect(customAspectName); - - if (customAssocsAspect == null) - { - final String msg = "Unknown aspect: " + customAspectName; - if (logger.isErrorEnabled()) - { - logger.error(msg); - } - throw new AlfrescoRuntimeException(msg); - } - - - // MOB-1573. All custom references should have many-many multiplicity. - if (logger.isInfoEnabled()) - { - logger.info("MOB-1573. All custom references should have many-many multiplicity."); - } - - for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations()) - { - classAssoc.setSourceMany(true); - classAssoc.setTargetMany(true); - - } - - //MOB-1621. Custom fields should be created as untokenized by default. - if (logger.isInfoEnabled()) - { - logger.info("MOB-1621. Custom fields should be created as untokenized by default."); - } - - List allCustomPropertiesAspects = new ArrayList(4); - allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_SERIES_PROPERTIES); - allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES); - allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_FOLDER_PROPERTIES); - allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_PROPERTIES); - for (String aspectName : allCustomPropertiesAspects) - { - M2Aspect aspectObj = customModel.getAspect(aspectName); - List customProperties = aspectObj.getProperties(); - for (M2Property propertyObj : customProperties) - { - propertyObj.setIndexed(true); - propertyObj.setIndexedAtomically(true); - propertyObj.setStoredInIndex(false); - propertyObj.setIndexTokenisationMode(IndexTokenisationMode.FALSE); - } - } - - - writeCustomContentModel(customModel); - - if (logger.isInfoEnabled()) - { - logger.info("Completed application of webscript-based patches to RM custom model in the repo."); - } - - Map model = new HashMap(1, 1.0f); - model.put("success", true); - - return model; - } - - private M2Model readCustomContentModel() - { - ContentReader reader = this.contentService.getReader(RM_CUSTOM_MODEL_NODE_REF, - ContentModel.TYPE_CONTENT); - - if (!reader.exists()) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");} - - InputStream contentIn = null; - M2Model deserializedModel = null; - try - { - contentIn = reader.getContentInputStream(); - deserializedModel = M2Model.createModel(contentIn); - } - finally - { - try - { - if (contentIn != null) - { - contentIn.close(); - } - } - catch (IOException ignored) - { - // Intentionally empty.` - } - } - return deserializedModel; - } - - private void writeCustomContentModel(M2Model deserializedModel) - { - ContentWriter writer = this.contentService.getWriter(RM_CUSTOM_MODEL_NODE_REF, - ContentModel.TYPE_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_XML); - writer.setEncoding("UTF-8"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - deserializedModel.toXML(baos); - - String updatedModelXml; - try - { - updatedModelXml = baos.toString("UTF-8"); - writer.putContent(updatedModelXml); - // putContent closes all resources. - // so we don't have to. - } catch (UnsupportedEncodingException uex) - { - throw new AlfrescoRuntimeException("Exception when writing custom model xml.", uex); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.dictionary.IndexTokenisationMode; +import org.alfresco.repo.dictionary.M2Aspect; +import org.alfresco.repo.dictionary.M2ClassAssociation; +import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.repo.dictionary.M2Property; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * This webscript applies necessary changes to the RM custom model in the repository. These changes + * are to 'patch' a deployed RM custom model during the DoD certification process. With that in mind + * they are safe to apply to a live database i.e. without side-effect to existing data and safe + * to call multiple times. + *

+ * + * TODO This webscript should be removed after DOD certification as none of these patches are needed + * for a newly-installed DoD amp. + * + * @author neilm + */ +@Deprecated +public class ApplyDodCertModelFixesGet extends DeclarativeWebScript + implements RecordsManagementModel +{ + private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef("workspace://SpacesStore/records_management_custom_model"); + private static final String RMC_CUSTOM_RECORD_SERIES_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordSeriesProperties"; + private static final String RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordCategoryProperties"; + private static final String RMC_CUSTOM_RECORD_FOLDER_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordFolderProperties"; + private static final String RMC_CUSTOM_RECORD_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordProperties"; + + /** Logger */ + private static Log logger = LogFactory.getLog(ApplyDodCertModelFixesGet.class); + + private ContentService contentService; + private NamespaceService namespaceService; + + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + if (logger.isInfoEnabled()) + { + logger.info("Applying webscript-based patches to RM custom model in the repo."); + } + + M2Model customModel = readCustomContentModel(); + + String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService); + M2Aspect customAssocsAspect = customModel.getAspect(customAspectName); + + if (customAssocsAspect == null) + { + final String msg = "Unknown aspect: " + customAspectName; + if (logger.isErrorEnabled()) + { + logger.error(msg); + } + throw new AlfrescoRuntimeException(msg); + } + + + // MOB-1573. All custom references should have many-many multiplicity. + if (logger.isInfoEnabled()) + { + logger.info("MOB-1573. All custom references should have many-many multiplicity."); + } + + for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations()) + { + classAssoc.setSourceMany(true); + classAssoc.setTargetMany(true); + + } + + //MOB-1621. Custom fields should be created as untokenized by default. + if (logger.isInfoEnabled()) + { + logger.info("MOB-1621. Custom fields should be created as untokenized by default."); + } + + List allCustomPropertiesAspects = new ArrayList(4); + allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_SERIES_PROPERTIES); + allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES); + allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_FOLDER_PROPERTIES); + allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_PROPERTIES); + for (String aspectName : allCustomPropertiesAspects) + { + M2Aspect aspectObj = customModel.getAspect(aspectName); + List customProperties = aspectObj.getProperties(); + for (M2Property propertyObj : customProperties) + { + propertyObj.setIndexed(true); + propertyObj.setIndexedAtomically(true); + propertyObj.setStoredInIndex(false); + propertyObj.setIndexTokenisationMode(IndexTokenisationMode.FALSE); + } + } + + + writeCustomContentModel(customModel); + + if (logger.isInfoEnabled()) + { + logger.info("Completed application of webscript-based patches to RM custom model in the repo."); + } + + Map model = new HashMap(1, 1.0f); + model.put("success", true); + + return model; + } + + private M2Model readCustomContentModel() + { + ContentReader reader = this.contentService.getReader(RM_CUSTOM_MODEL_NODE_REF, + ContentModel.TYPE_CONTENT); + + if (!reader.exists()) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");} + + InputStream contentIn = null; + M2Model deserializedModel = null; + try + { + contentIn = reader.getContentInputStream(); + deserializedModel = M2Model.createModel(contentIn); + } + finally + { + try + { + if (contentIn != null) + { + contentIn.close(); + } + } + catch (IOException ignored) + { + // Intentionally empty.` + } + } + return deserializedModel; + } + + private void writeCustomContentModel(M2Model deserializedModel) + { + ContentWriter writer = this.contentService.getWriter(RM_CUSTOM_MODEL_NODE_REF, + ContentModel.TYPE_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_XML); + writer.setEncoding("UTF-8"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + deserializedModel.toXML(baos); + + String updatedModelXml; + try + { + updatedModelXml = baos.toString("UTF-8"); + writer.putContent(updatedModelXml); + // putContent closes all resources. + // so we don't have to. + } catch (UnsupportedEncodingException uex) + { + throw new AlfrescoRuntimeException("Exception when writing custom model xml.", uex); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyFixMob1573Get.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyFixMob1573Get.java index df46460489..b3c9895705 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyFixMob1573Get.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ApplyFixMob1573Get.java @@ -1,155 +1,155 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.dictionary.M2Aspect; -import org.alfresco.repo.dictionary.M2ClassAssociation; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This webscript patches the RM custom model as fix for MOB-1573. It is only necessary for databases - * that had their RM amps initialised before the fix went in. - * There is no side-effect if it is called when it is not needed or if it is called multiple times. - * - * TODO This webscript should be removed after DOD certification. - * - * @author neilm - */ -@Deprecated -public class ApplyFixMob1573Get extends DeclarativeWebScript - implements RecordsManagementModel -{ - private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef("workspace://SpacesStore/records_management_custom_model"); - - private ContentService contentService; - private NamespaceService namespaceService; - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - M2Model customModel = readCustomContentModel(); - - // Go through every custom reference defined in the custom model and make sure that it - // has many-to-many multiplicity - String aspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService); - M2Aspect customAssocsAspect = customModel.getAspect(aspectName); - - if (customAssocsAspect == null) - { - throw new AlfrescoRuntimeException("Unknown aspect: "+aspectName); - } - - for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations()) - { - classAssoc.setSourceMany(true); - classAssoc.setTargetMany(true); - } - - writeCustomContentModel(customModel); - - Map model = new HashMap(1, 1.0f); - model.put("success", true); - - return model; - } - - private M2Model readCustomContentModel() - { - ContentReader reader = contentService.getReader(RM_CUSTOM_MODEL_NODE_REF, - ContentModel.TYPE_CONTENT); - - if (!reader.exists()) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");} - - InputStream contentIn = null; - M2Model deserializedModel = null; - try - { - contentIn = reader.getContentInputStream(); - deserializedModel = M2Model.createModel(contentIn); - } - finally - { - try - { - if (contentIn != null) - { - contentIn.close(); - } - } - catch (IOException ignored) - { - // Intentionally empty. - } - } - return deserializedModel; - } - - private void writeCustomContentModel(M2Model deserializedModel) - { - ContentWriter writer = contentService.getWriter(RM_CUSTOM_MODEL_NODE_REF, - ContentModel.TYPE_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_XML); - writer.setEncoding("UTF-8"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - deserializedModel.toXML(baos); - - String updatedModelXml; - try - { - updatedModelXml = baos.toString("UTF-8"); - writer.putContent(updatedModelXml); - // putContent closes all resources. - // so we don't have to. - } catch (UnsupportedEncodingException uex) - { - throw new AlfrescoRuntimeException("Exception when writing custom model xml.", uex); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.dictionary.M2Aspect; +import org.alfresco.repo.dictionary.M2ClassAssociation; +import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * This webscript patches the RM custom model as fix for MOB-1573. It is only necessary for databases + * that had their RM amps initialised before the fix went in. + * There is no side-effect if it is called when it is not needed or if it is called multiple times. + * + * TODO This webscript should be removed after DOD certification. + * + * @author neilm + */ +@Deprecated +public class ApplyFixMob1573Get extends DeclarativeWebScript + implements RecordsManagementModel +{ + private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef("workspace://SpacesStore/records_management_custom_model"); + + private ContentService contentService; + private NamespaceService namespaceService; + + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + M2Model customModel = readCustomContentModel(); + + // Go through every custom reference defined in the custom model and make sure that it + // has many-to-many multiplicity + String aspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService); + M2Aspect customAssocsAspect = customModel.getAspect(aspectName); + + if (customAssocsAspect == null) + { + throw new AlfrescoRuntimeException("Unknown aspect: "+aspectName); + } + + for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations()) + { + classAssoc.setSourceMany(true); + classAssoc.setTargetMany(true); + } + + writeCustomContentModel(customModel); + + Map model = new HashMap(1, 1.0f); + model.put("success", true); + + return model; + } + + private M2Model readCustomContentModel() + { + ContentReader reader = contentService.getReader(RM_CUSTOM_MODEL_NODE_REF, + ContentModel.TYPE_CONTENT); + + if (!reader.exists()) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");} + + InputStream contentIn = null; + M2Model deserializedModel = null; + try + { + contentIn = reader.getContentInputStream(); + deserializedModel = M2Model.createModel(contentIn); + } + finally + { + try + { + if (contentIn != null) + { + contentIn.close(); + } + } + catch (IOException ignored) + { + // Intentionally empty. + } + } + return deserializedModel; + } + + private void writeCustomContentModel(M2Model deserializedModel) + { + ContentWriter writer = contentService.getWriter(RM_CUSTOM_MODEL_NODE_REF, + ContentModel.TYPE_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_XML); + writer.setEncoding("UTF-8"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + deserializedModel.toXML(baos); + + String updatedModelXml; + try + { + updatedModelXml = baos.toString("UTF-8"); + writer.putContent(updatedModelXml); + // putContent closes all resources. + // so we don't have to. + } catch (UnsupportedEncodingException uex) + { + throw new AlfrescoRuntimeException("Exception when writing custom model xml.", uex); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogDelete.java index 9533896be9..d215fabd4c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogDelete.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to clear the - * Records Management audit log. - * - * @author Gavin Cornwell - */ -public class AuditLogDelete extends BaseAuditAdminWebScript -{ - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - this.rmAuditService.clearAuditLog(getDefaultFilePlan()); - - // create model object with the audit status model - Map model = new HashMap(1); - model.put("auditstatus", createAuditStatusModel()); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to clear the + * Records Management audit log. + * + * @author Gavin Cornwell + */ +public class AuditLogDelete extends BaseAuditAdminWebScript +{ + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + this.rmAuditService.clearAuditLog(getDefaultFilePlan()); + + // create model object with the audit status model + Map model = new HashMap(1); + model.put("auditstatus", createAuditStatusModel()); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java index 3acdbd1197..8e9c90b201 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java @@ -1,156 +1,156 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.IOException; - -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.ReportFormat; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.repo.web.scripts.content.ContentStreamer; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Implementation for Java backed webscript to return audit - * log of RM events, optionally scoped to an RM node. - * - * @author Gavin Cornwell - */ -public class AuditLogGet extends BaseAuditRetrievalWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(AuditLogGet.class); - - private static final String PARAM_EXPORT = "export"; - private static final String ACCESS_AUDIT_CAPABILITY = "AccessAudit"; - - /** Content Streamer */ - protected ContentStreamer contentStreamer; - - /** Capability service */ - protected CapabilityService capabilityService; - - /** File plan service */ - protected FilePlanService filePlanService; - - /** - * @param contentStreamer - */ - public void setContentStreamer(ContentStreamer contentStreamer) - { - this.contentStreamer = contentStreamer; - } - - /** - * - * @param capabilityService Capability Service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * - * @param capabilityService Capability Service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - @Override - public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - File auditTrail = null; - - try - { - - RecordsManagementAuditQueryParameters queryParams = parseQueryParameters(req); - ReportFormat reportFormat = parseReportFormat(req); - - if( !userCanAccessAudit(queryParams) ) - { - throw new WebScriptException(Status.STATUS_FORBIDDEN, "Access denied because the user does not have the Access Audit capability"); - } - // parse the parameters and get a file containing the audit trail - auditTrail = this.rmAuditService.getAuditTrailFile(queryParams, reportFormat); - - if (logger.isDebugEnabled()) - { - logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath()); - } - - boolean attach = false; - String attachFileName = null; - String export = req.getParameter(PARAM_EXPORT); - if (export != null && Boolean.parseBoolean(export)) - { - attach = true; - attachFileName = auditTrail.getName(); - - if (logger.isDebugEnabled()) - { - logger.debug("Exporting audit trail using file name: " + attachFileName); - } - } - - // stream the file back to the client - contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null); - } - finally - { - if (auditTrail != null) - { - if (logger.isDebugEnabled()) - { - logger.debug( - "Audit results written to file: \n" + - " File: " + auditTrail + "\n" + - " Parameter: " + parseQueryParameters(req)); - } - else - { - auditTrail.delete(); - } - } - } - } - - private boolean userCanAccessAudit(RecordsManagementAuditQueryParameters queryParams) - { - NodeRef targetNode = queryParams.getNodeRef(); - if( targetNode == null ) - { - targetNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - return AccessStatus.ALLOWED.equals( - capabilityService.getCapabilityAccessState(targetNode, ACCESS_AUDIT_CAPABILITY)); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.IOException; + +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.ReportFormat; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.repo.web.scripts.content.ContentStreamer; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Implementation for Java backed webscript to return audit + * log of RM events, optionally scoped to an RM node. + * + * @author Gavin Cornwell + */ +public class AuditLogGet extends BaseAuditRetrievalWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(AuditLogGet.class); + + private static final String PARAM_EXPORT = "export"; + private static final String ACCESS_AUDIT_CAPABILITY = "AccessAudit"; + + /** Content Streamer */ + protected ContentStreamer contentStreamer; + + /** Capability service */ + protected CapabilityService capabilityService; + + /** File plan service */ + protected FilePlanService filePlanService; + + /** + * @param contentStreamer + */ + public void setContentStreamer(ContentStreamer contentStreamer) + { + this.contentStreamer = contentStreamer; + } + + /** + * + * @param capabilityService Capability Service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * + * @param capabilityService Capability Service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + @Override + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + File auditTrail = null; + + try + { + + RecordsManagementAuditQueryParameters queryParams = parseQueryParameters(req); + ReportFormat reportFormat = parseReportFormat(req); + + if( !userCanAccessAudit(queryParams) ) + { + throw new WebScriptException(Status.STATUS_FORBIDDEN, "Access denied because the user does not have the Access Audit capability"); + } + // parse the parameters and get a file containing the audit trail + auditTrail = this.rmAuditService.getAuditTrailFile(queryParams, reportFormat); + + if (logger.isDebugEnabled()) + { + logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath()); + } + + boolean attach = false; + String attachFileName = null; + String export = req.getParameter(PARAM_EXPORT); + if (export != null && Boolean.parseBoolean(export)) + { + attach = true; + attachFileName = auditTrail.getName(); + + if (logger.isDebugEnabled()) + { + logger.debug("Exporting audit trail using file name: " + attachFileName); + } + } + + // stream the file back to the client + contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null); + } + finally + { + if (auditTrail != null) + { + if (logger.isDebugEnabled()) + { + logger.debug( + "Audit results written to file: \n" + + " File: " + auditTrail + "\n" + + " Parameter: " + parseQueryParameters(req)); + } + else + { + auditTrail.delete(); + } + } + } + } + + private boolean userCanAccessAudit(RecordsManagementAuditQueryParameters queryParams) + { + NodeRef targetNode = queryParams.getNodeRef(); + if( targetNode == null ) + { + targetNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + return AccessStatus.ALLOWED.equals( + capabilityService.getCapabilityAccessState(targetNode, ACCESS_AUDIT_CAPABILITY)); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java index 47e07a83ab..5716c3987a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java @@ -1,289 +1,289 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Implementation for Java backed webscript to file an - * audit log as a record. - * - * @author Gavin Cornwell - */ -public class AuditLogPost extends BaseAuditRetrievalWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(AuditLogPost.class); - - /** Constants */ - protected static final String PARAM_DESTINATION = "destination"; - protected static final String RESPONSE_SUCCESS = "success"; - protected static final String RESPONSE_RECORD = "record"; - protected static final String RESPONSE_RECORD_NAME = "recordName"; - - /** Record folder service */ - private RecordFolderService recordFolderService; - - /** Disposition service */ - private DispositionService dispositionService; - - /** - * Sets the record folder service - * - * @param recordFolderService Record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * Sets the disposition service - * - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @see org.alfresco.repo.web.scripts.content.StreamContent#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse) - */ - @Override - public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - try - { - ParameterCheck.mandatory("req", req); - ParameterCheck.mandatory("res", res); - - // build the json object from the request - JSONObject json = getJSONObjectFromRequest(req); - - // extract the destination parameter, ensure it's present and it is a record folder and not closed or cut off - NodeRef destination = getDestination(json); - - // file audit trail as a record - NodeRef record = fileAuditTrail(destination, req); - - // create response - String response = createResponse(record); - - // write the JSON response - writeResponse(res, response); - } - catch (Exception ex) - { - JSONObject json = new JSONObject(); - putToJSONObject(json, "message", ex.getMessage()); - writeResponse(res, json.toString()); - } - } - - /** - * Helper method to write the response to the web script response - * - * @param res {@link WebScriptResponse} Web script response - * @param reponse {@link String} Response to write - * @throws IOException can throw an exception whilst writing the response - */ - private void writeResponse(WebScriptResponse res, String response) throws IOException - { - // setup response - res.setContentType(MimetypeMap.MIMETYPE_JSON); - res.setContentEncoding("UTF-8"); - res.setHeader("Content-Length", Long.toString(response.length())); - - // write the JSON response - res.getWriter().write(response); - } - - /** - * Helper method to create the response text from the record - * - * @param record {@link NodeRef} The audit trail as record - * @return Response text as {@link String} - */ - @SuppressWarnings("null") - private String createResponse(NodeRef record) - { - JSONObject responseJSON = new JSONObject(); - boolean recordExists = record != null; - - putToJSONObject(responseJSON, RESPONSE_SUCCESS, recordExists); - - if (recordExists) - { - putToJSONObject(responseJSON, RESPONSE_RECORD, record.toString()); - putToJSONObject(responseJSON, RESPONSE_RECORD_NAME, (String) nodeService.getProperty(record, ContentModel.PROP_NAME)); - } - - return responseJSON.toString(); - } - - /** - * Helper method to put a key and a value to a json object. - * It handles the {@link JSONException} so that a try/catch - * block is not need through out the code - * - * @param json The json object the key/value write to - * @param key The key which will be written to the json object - * @param value The value which will be written to the json object - */ - private void putToJSONObject(JSONObject json, String key, Object value) - { - try - { - json.put(key, value); - } - catch (JSONException error) - { - throw new AlfrescoRuntimeException("Error writing the value '" + value + "' of the key '" + key + "' to the json object.", error); - } - } - - /** - * Helper method which will file the audit trail - * - * @param destination The destination where the audit trail will be filed - * @param req {@link WebScriptRequest} from which additional parameters will be retrieved - * @return The {@link NodeRef} of the record - */ - private NodeRef fileAuditTrail(NodeRef destination, WebScriptRequest req) - { - - NodeRef record = rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req), destination, parseReportFormat(req)); - - if (logger.isDebugEnabled()) - { - logger.debug("Filed audit trail as new record: '" + record + "'."); - } - - return record; - } - - /** - * Helper method to create a json object from the request - * - * @param req {@link WebScriptRequest} from which the json object will be created - * @return Returns a json object containing the request content - * @throws IOException can throw an exception whilst getting the content from the request - */ - private JSONObject getJSONObjectFromRequest(WebScriptRequest req) throws IOException - { - JSONObject json; - - try - { - json = new JSONObject(new JSONTokener(req.getContent().getContent())); - } - catch (JSONException error) - { - throw new AlfrescoRuntimeException("Error creating json object from request content.", error); - } - - return json; - } - - /** - * Helper method to get the destination from the json object - * - * @param json The json object which was created from the request content - * @return {@link NodeRef} The destination of the audit log - */ - private NodeRef getDestination(JSONObject json) - { - if (!json.has(PARAM_DESTINATION)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory parameter '" + PARAM_DESTINATION + "' has not been supplied."); - } - - String destinationParam; - try - { - destinationParam = json.getString(PARAM_DESTINATION); - } - catch (JSONException error) - { - throw new AlfrescoRuntimeException("Error extracting 'destination' from parameter.", error); - } - - if (StringUtils.isBlank(destinationParam)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Please select a record folder."); - } - - NodeRef destination = new NodeRef(destinationParam); - if (!nodeService.exists(destination)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, - "Selected node does not exist"); - } - - // ensure the node is a record folder - if (!RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(destination))) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Selected node is not a record folder"); - } - - // ensure the record folder is not closed - if (recordFolderService.isRecordFolderClosed(destination)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Cannot file into a closed folder."); - } - - // ensure the record folder is not cut off - if (dispositionService.isDisposableItemCutoff(destination)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Cannot file into a cut off folder."); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Filing audit trail as record in record folder: '" + destination + "'."); - } - - return destination; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Implementation for Java backed webscript to file an + * audit log as a record. + * + * @author Gavin Cornwell + */ +public class AuditLogPost extends BaseAuditRetrievalWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(AuditLogPost.class); + + /** Constants */ + protected static final String PARAM_DESTINATION = "destination"; + protected static final String RESPONSE_SUCCESS = "success"; + protected static final String RESPONSE_RECORD = "record"; + protected static final String RESPONSE_RECORD_NAME = "recordName"; + + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Disposition service */ + private DispositionService dispositionService; + + /** + * Sets the record folder service + * + * @param recordFolderService Record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * Sets the disposition service + * + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @see org.alfresco.repo.web.scripts.content.StreamContent#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse) + */ + @Override + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + try + { + ParameterCheck.mandatory("req", req); + ParameterCheck.mandatory("res", res); + + // build the json object from the request + JSONObject json = getJSONObjectFromRequest(req); + + // extract the destination parameter, ensure it's present and it is a record folder and not closed or cut off + NodeRef destination = getDestination(json); + + // file audit trail as a record + NodeRef record = fileAuditTrail(destination, req); + + // create response + String response = createResponse(record); + + // write the JSON response + writeResponse(res, response); + } + catch (Exception ex) + { + JSONObject json = new JSONObject(); + putToJSONObject(json, "message", ex.getMessage()); + writeResponse(res, json.toString()); + } + } + + /** + * Helper method to write the response to the web script response + * + * @param res {@link WebScriptResponse} Web script response + * @param reponse {@link String} Response to write + * @throws IOException can throw an exception whilst writing the response + */ + private void writeResponse(WebScriptResponse res, String response) throws IOException + { + // setup response + res.setContentType(MimetypeMap.MIMETYPE_JSON); + res.setContentEncoding("UTF-8"); + res.setHeader("Content-Length", Long.toString(response.length())); + + // write the JSON response + res.getWriter().write(response); + } + + /** + * Helper method to create the response text from the record + * + * @param record {@link NodeRef} The audit trail as record + * @return Response text as {@link String} + */ + @SuppressWarnings("null") + private String createResponse(NodeRef record) + { + JSONObject responseJSON = new JSONObject(); + boolean recordExists = record != null; + + putToJSONObject(responseJSON, RESPONSE_SUCCESS, recordExists); + + if (recordExists) + { + putToJSONObject(responseJSON, RESPONSE_RECORD, record.toString()); + putToJSONObject(responseJSON, RESPONSE_RECORD_NAME, (String) nodeService.getProperty(record, ContentModel.PROP_NAME)); + } + + return responseJSON.toString(); + } + + /** + * Helper method to put a key and a value to a json object. + * It handles the {@link JSONException} so that a try/catch + * block is not need through out the code + * + * @param json The json object the key/value write to + * @param key The key which will be written to the json object + * @param value The value which will be written to the json object + */ + private void putToJSONObject(JSONObject json, String key, Object value) + { + try + { + json.put(key, value); + } + catch (JSONException error) + { + throw new AlfrescoRuntimeException("Error writing the value '" + value + "' of the key '" + key + "' to the json object.", error); + } + } + + /** + * Helper method which will file the audit trail + * + * @param destination The destination where the audit trail will be filed + * @param req {@link WebScriptRequest} from which additional parameters will be retrieved + * @return The {@link NodeRef} of the record + */ + private NodeRef fileAuditTrail(NodeRef destination, WebScriptRequest req) + { + + NodeRef record = rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req), destination, parseReportFormat(req)); + + if (logger.isDebugEnabled()) + { + logger.debug("Filed audit trail as new record: '" + record + "'."); + } + + return record; + } + + /** + * Helper method to create a json object from the request + * + * @param req {@link WebScriptRequest} from which the json object will be created + * @return Returns a json object containing the request content + * @throws IOException can throw an exception whilst getting the content from the request + */ + private JSONObject getJSONObjectFromRequest(WebScriptRequest req) throws IOException + { + JSONObject json; + + try + { + json = new JSONObject(new JSONTokener(req.getContent().getContent())); + } + catch (JSONException error) + { + throw new AlfrescoRuntimeException("Error creating json object from request content.", error); + } + + return json; + } + + /** + * Helper method to get the destination from the json object + * + * @param json The json object which was created from the request content + * @return {@link NodeRef} The destination of the audit log + */ + private NodeRef getDestination(JSONObject json) + { + if (!json.has(PARAM_DESTINATION)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory parameter '" + PARAM_DESTINATION + "' has not been supplied."); + } + + String destinationParam; + try + { + destinationParam = json.getString(PARAM_DESTINATION); + } + catch (JSONException error) + { + throw new AlfrescoRuntimeException("Error extracting 'destination' from parameter.", error); + } + + if (StringUtils.isBlank(destinationParam)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Please select a record folder."); + } + + NodeRef destination = new NodeRef(destinationParam); + if (!nodeService.exists(destination)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, + "Selected node does not exist"); + } + + // ensure the node is a record folder + if (!RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(destination))) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Selected node is not a record folder"); + } + + // ensure the record folder is not closed + if (recordFolderService.isRecordFolderClosed(destination)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Cannot file into a closed folder."); + } + + // ensure the record folder is not cut off + if (dispositionService.isDisposableItemCutoff(destination)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Cannot file into a cut off folder."); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Filing audit trail as record in record folder: '" + destination + "'."); + } + + return destination; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPut.java index b21b200636..12f7af5bad 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPut.java @@ -1,87 +1,87 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -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 start - * and stop Records Management auditing. - * - * @author Gavin Cornwell - */ -public class AuditLogPut extends BaseAuditAdminWebScript -{ - protected static final String PARAM_ENABLED = "enabled"; - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - try - { - // determine whether to start or stop auditing - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - - // check the enabled property present - if (!json.has(PARAM_ENABLED)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'enabled' parameter was not provided in request body"); - } - - boolean enabled = json.getBoolean(PARAM_ENABLED); - if (enabled) - { - this.rmAuditService.startAuditLog(getDefaultFilePlan()); - } - else - { - this.rmAuditService.stopAuditLog(getDefaultFilePlan()); - } - - // create model object with the audit status model - Map model = new HashMap(1); - model.put("auditstatus", createAuditStatusModel()); - return model; - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +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 start + * and stop Records Management auditing. + * + * @author Gavin Cornwell + */ +public class AuditLogPut extends BaseAuditAdminWebScript +{ + protected static final String PARAM_ENABLED = "enabled"; + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + try + { + // determine whether to start or stop auditing + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + + // check the enabled property present + if (!json.has(PARAM_ENABLED)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'enabled' parameter was not provided in request body"); + } + + boolean enabled = json.getBoolean(PARAM_ENABLED); + if (enabled) + { + this.rmAuditService.startAuditLog(getDefaultFilePlan()); + } + else + { + this.rmAuditService.stopAuditLog(getDefaultFilePlan()); + } + + // create model object with the audit status model + Map model = new HashMap(1); + model.put("auditstatus", createAuditStatusModel()); + return model; + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogStatusGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogStatusGet.java index 55cd41e657..4a2913f1dc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogStatusGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogStatusGet.java @@ -1,89 +1,89 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * GET audit log status - * - * @author Roy Wetherall - */ -public class AuditLogStatusGet extends DeclarativeWebScript -{ - /** Records management audit service */ - protected RecordsManagementAuditService rmAuditService; - - /** File plan service */ - protected FilePlanService filePlanService; - - /** - * Sets the RecordsManagementAuditService instance - * - * @param auditService The RecordsManagementAuditService instance - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) - { - this.rmAuditService = rmAuditService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - model.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan()))); - return model; - } - - /** - * Helper method to get default file plan. - * - * @return NodeRef default file plan - */ - protected NodeRef getDefaultFilePlan() - { - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - throw new AlfrescoRuntimeException("Default file plan not found."); - } - return filePlan; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * GET audit log status + * + * @author Roy Wetherall + */ +public class AuditLogStatusGet extends DeclarativeWebScript +{ + /** Records management audit service */ + protected RecordsManagementAuditService rmAuditService; + + /** File plan service */ + protected FilePlanService filePlanService; + + /** + * Sets the RecordsManagementAuditService instance + * + * @param auditService The RecordsManagementAuditService instance + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) + { + this.rmAuditService = rmAuditService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + model.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan()))); + return model; + } + + /** + * Helper method to get default file plan. + * + * @return NodeRef default file plan + */ + protected NodeRef getDefaultFilePlan() + { + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + throw new AlfrescoRuntimeException("Default file plan not found."); + } + return filePlan; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditAdminWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditAdminWebScript.java index d96c397f8f..08ad7614f8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditAdminWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditAdminWebScript.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Base class for all audit administration webscripts. - * - * @author Gavin Cornwell - */ -public class BaseAuditAdminWebScript extends DeclarativeWebScript -{ - /** Records management audit service */ - protected RecordsManagementAuditService rmAuditService; - - /** File plan service */ - protected FilePlanService filePlanService; - - /** - * Sets the RecordsManagementAuditService instance - * - * @param auditService The RecordsManagementAuditService instance - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) - { - this.rmAuditService = rmAuditService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Creates a model to represent the current status of the RM audit log. - * - * @return Map of RM audit log status - */ - protected Map createAuditStatusModel() - { - Map auditStatus = new HashMap(3); - - auditStatus.put("started", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStarted(getDefaultFilePlan()))); - auditStatus.put("stopped", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStopped(getDefaultFilePlan()))); - auditStatus.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan()))); - - return auditStatus; - } - - /** - * Helper method to get default file plan. - * - * @return NodeRef default file plan - */ - protected NodeRef getDefaultFilePlan() - { - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - throw new AlfrescoRuntimeException("Default file plan not found."); - } - return filePlan; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.extensions.webscripts.DeclarativeWebScript; + +/** + * Base class for all audit administration webscripts. + * + * @author Gavin Cornwell + */ +public class BaseAuditAdminWebScript extends DeclarativeWebScript +{ + /** Records management audit service */ + protected RecordsManagementAuditService rmAuditService; + + /** File plan service */ + protected FilePlanService filePlanService; + + /** + * Sets the RecordsManagementAuditService instance + * + * @param auditService The RecordsManagementAuditService instance + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) + { + this.rmAuditService = rmAuditService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Creates a model to represent the current status of the RM audit log. + * + * @return Map of RM audit log status + */ + protected Map createAuditStatusModel() + { + Map auditStatus = new HashMap(3); + + auditStatus.put("started", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStarted(getDefaultFilePlan()))); + auditStatus.put("stopped", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStopped(getDefaultFilePlan()))); + auditStatus.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan()))); + + return auditStatus; + } + + /** + * Helper method to get default file plan. + * + * @return NodeRef default file plan + */ + protected NodeRef getDefaultFilePlan() + { + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + throw new AlfrescoRuntimeException("Default file plan not found."); + } + return filePlan; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditRetrievalWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditRetrievalWebScript.java index 84e427fed8..d958fe5715 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditRetrievalWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseAuditRetrievalWebScript.java @@ -1,273 +1,273 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.ReportFormat; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.web.scripts.content.StreamContent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.InvalidQNameException; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; - -/** - * Base class for all audit retrieval webscripts. - * - * @author Gavin Cornwell - */ -public class BaseAuditRetrievalWebScript extends StreamContent -{ - /** Logger */ - private static Log logger = LogFactory.getLog(BaseAuditRetrievalWebScript.class); - - private static final String PARAM_USER = "user"; - private static final String PARAM_SIZE = "size"; - private static final String PARAM_EVENT = "event"; - private static final String PARAM_FROM = "from"; - private static final String PARAM_TO = "to"; - private static final String PARAM_PROPERTY = "property"; - private static final String DATE_PATTERN = "yyyy-MM-dd"; - - protected RecordsManagementAuditService rmAuditService; - protected NamespaceService namespaceService; - - /** - * Sets the RecordsManagementAuditService instance - * - * @param auditService The RecordsManagementAuditService instance - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) - { - this.rmAuditService = rmAuditService; - } - - /** - * Sets the NamespaceService instance - * - * @param namespaceService The NamespaceService instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Parses the given request and builds an instance of - * RecordsManagementAuditQueryParameters to retrieve the relevant audit entries - * - * @param req The request - * @return RecordsManagementAuditQueryParameters instance - */ - protected RecordsManagementAuditQueryParameters parseQueryParameters(WebScriptRequest req) - { - // create parameters for audit trail retrieval - RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); - - // the webscripts can have a couple of different forms of url, work out - // whether a nodeRef has been supplied or whether the whole audit - // log should be displayed - NodeRef nodeRef = null; - Map templateVars = req.getServiceMatch().getTemplateVars(); - String storeType = templateVars.get("store_type"); - if (storeType != null && storeType.length() > 0) - { - // there is a store_type so all other params are likely to be present - String storeId = templateVars.get("store_id"); - String nodeId = templateVars.get("id"); - - // create the nodeRef - nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId); - } - - // gather all the common filtering parameters, these could be on the - // query string, in a multipart/form-data request or in a JSON body - String size = null; - String user = null; - String event = null; - String from = null; - String to = null; - String property = null; - - if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType())) - { - try - { - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - if (json.has(PARAM_SIZE)) - { - size = json.getString(PARAM_SIZE); - } - if (json.has(PARAM_USER)) - { - user = json.getString(PARAM_USER); - } - if (json.has(PARAM_EVENT)) - { - event = json.getString(PARAM_EVENT); - } - if (json.has(PARAM_FROM)) - { - from = json.getString(PARAM_FROM); - } - if (json.has(PARAM_TO)) - { - to = json.getString(PARAM_TO); - } - if (json.has(PARAM_PROPERTY)) - { - property = json.getString(PARAM_PROPERTY); - } - } - catch (IOException ioe) - { - // log a warning - if (logger.isWarnEnabled()) - { - logger.warn("Failed to parse JSON parameters for audit query: " + ioe.getMessage()); - } - } - catch (JSONException je) - { - // log a warning - if (logger.isWarnEnabled()) - { - logger.warn("Failed to parse JSON parameters for audit query: " + je.getMessage()); - } - } - } - else - { - size = req.getParameter(PARAM_SIZE); - user = req.getParameter(PARAM_USER); - event = req.getParameter(PARAM_EVENT); - from = req.getParameter(PARAM_FROM); - to = req.getParameter(PARAM_TO); - property = req.getParameter(PARAM_PROPERTY); - } - - // setup the audit query parameters object - params.setNodeRef(nodeRef); - params.setUser(user); - params.setEvent(event); - - if (size != null && size.length() > 0) - { - try - { - params.setMaxEntries(Integer.parseInt(size)); - } - catch (NumberFormatException nfe) - { - if (logger.isWarnEnabled()) - { - logger.warn("Ignoring size parameter as '" + size + "' is not a number!"); - } - } - } - - if (from != null && from.length() > 0) - { - try - { - SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN); - params.setDateFrom(dateFormat.parse(from)); - } - catch (ParseException pe) - { - if (logger.isWarnEnabled()) - { - logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN); - } - } - } - - if (to != null && to.length() > 0) - { - try - { - SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN); - params.setDateTo(dateFormat.parse(to)); - } - catch (ParseException pe) - { - if (logger.isWarnEnabled()) - { - logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN); - } - } - } - - if (property != null && property.length() > 0) - { - try - { - params.setProperty(QName.createQName(property, namespaceService)); - } - catch (InvalidQNameException iqe) - { - if (logger.isWarnEnabled()) - { - logger.warn("Ignoring property parameter as '" + property + "' is an invalid QName"); - } - } - } - - return params; - } - - /** - * Parses the given request for the format the audit report - * should be returned in - * - * @param req The request - * @return The format for the report - */ - protected ReportFormat parseReportFormat(WebScriptRequest req) - { - String format = req.getFormat(); - - if (format != null) - { - if (format.equalsIgnoreCase("json")) - { - return ReportFormat.JSON; - } - else if (format.equalsIgnoreCase("html")) - { - return ReportFormat.HTML; - } - } - - return ReportFormat.JSON; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.ReportFormat; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.web.scripts.content.StreamContent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.InvalidQNameException; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; + +/** + * Base class for all audit retrieval webscripts. + * + * @author Gavin Cornwell + */ +public class BaseAuditRetrievalWebScript extends StreamContent +{ + /** Logger */ + private static Log logger = LogFactory.getLog(BaseAuditRetrievalWebScript.class); + + private static final String PARAM_USER = "user"; + private static final String PARAM_SIZE = "size"; + private static final String PARAM_EVENT = "event"; + private static final String PARAM_FROM = "from"; + private static final String PARAM_TO = "to"; + private static final String PARAM_PROPERTY = "property"; + private static final String DATE_PATTERN = "yyyy-MM-dd"; + + protected RecordsManagementAuditService rmAuditService; + protected NamespaceService namespaceService; + + /** + * Sets the RecordsManagementAuditService instance + * + * @param auditService The RecordsManagementAuditService instance + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) + { + this.rmAuditService = rmAuditService; + } + + /** + * Sets the NamespaceService instance + * + * @param namespaceService The NamespaceService instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Parses the given request and builds an instance of + * RecordsManagementAuditQueryParameters to retrieve the relevant audit entries + * + * @param req The request + * @return RecordsManagementAuditQueryParameters instance + */ + protected RecordsManagementAuditQueryParameters parseQueryParameters(WebScriptRequest req) + { + // create parameters for audit trail retrieval + RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); + + // the webscripts can have a couple of different forms of url, work out + // whether a nodeRef has been supplied or whether the whole audit + // log should be displayed + NodeRef nodeRef = null; + Map templateVars = req.getServiceMatch().getTemplateVars(); + String storeType = templateVars.get("store_type"); + if (storeType != null && storeType.length() > 0) + { + // there is a store_type so all other params are likely to be present + String storeId = templateVars.get("store_id"); + String nodeId = templateVars.get("id"); + + // create the nodeRef + nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId); + } + + // gather all the common filtering parameters, these could be on the + // query string, in a multipart/form-data request or in a JSON body + String size = null; + String user = null; + String event = null; + String from = null; + String to = null; + String property = null; + + if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType())) + { + try + { + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + if (json.has(PARAM_SIZE)) + { + size = json.getString(PARAM_SIZE); + } + if (json.has(PARAM_USER)) + { + user = json.getString(PARAM_USER); + } + if (json.has(PARAM_EVENT)) + { + event = json.getString(PARAM_EVENT); + } + if (json.has(PARAM_FROM)) + { + from = json.getString(PARAM_FROM); + } + if (json.has(PARAM_TO)) + { + to = json.getString(PARAM_TO); + } + if (json.has(PARAM_PROPERTY)) + { + property = json.getString(PARAM_PROPERTY); + } + } + catch (IOException ioe) + { + // log a warning + if (logger.isWarnEnabled()) + { + logger.warn("Failed to parse JSON parameters for audit query: " + ioe.getMessage()); + } + } + catch (JSONException je) + { + // log a warning + if (logger.isWarnEnabled()) + { + logger.warn("Failed to parse JSON parameters for audit query: " + je.getMessage()); + } + } + } + else + { + size = req.getParameter(PARAM_SIZE); + user = req.getParameter(PARAM_USER); + event = req.getParameter(PARAM_EVENT); + from = req.getParameter(PARAM_FROM); + to = req.getParameter(PARAM_TO); + property = req.getParameter(PARAM_PROPERTY); + } + + // setup the audit query parameters object + params.setNodeRef(nodeRef); + params.setUser(user); + params.setEvent(event); + + if (size != null && size.length() > 0) + { + try + { + params.setMaxEntries(Integer.parseInt(size)); + } + catch (NumberFormatException nfe) + { + if (logger.isWarnEnabled()) + { + logger.warn("Ignoring size parameter as '" + size + "' is not a number!"); + } + } + } + + if (from != null && from.length() > 0) + { + try + { + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN); + params.setDateFrom(dateFormat.parse(from)); + } + catch (ParseException pe) + { + if (logger.isWarnEnabled()) + { + logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN); + } + } + } + + if (to != null && to.length() > 0) + { + try + { + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN); + params.setDateTo(dateFormat.parse(to)); + } + catch (ParseException pe) + { + if (logger.isWarnEnabled()) + { + logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN); + } + } + } + + if (property != null && property.length() > 0) + { + try + { + params.setProperty(QName.createQName(property, namespaceService)); + } + catch (InvalidQNameException iqe) + { + if (logger.isWarnEnabled()) + { + logger.warn("Ignoring property parameter as '" + property + "' is an invalid QName"); + } + } + } + + return params; + } + + /** + * Parses the given request for the format the audit report + * should be returned in + * + * @param req The request + * @return The format for the report + */ + protected ReportFormat parseReportFormat(WebScriptRequest req) + { + String format = req.getFormat(); + + if (format != null) + { + if (format.equalsIgnoreCase("json")) + { + return ReportFormat.JSON; + } + else if (format.equalsIgnoreCase("html")) + { + return ReportFormat.HTML; + } + } + + return ReportFormat.JSON; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseCustomPropertyWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseCustomPropertyWebScript.java index 0463060cb8..aaeca8da12 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseCustomPropertyWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseCustomPropertyWebScript.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.namespace.QName; - -/** - * Base class for all custom property webscripts. - * - * @author Roy Wetherall - */ -public class BaseCustomPropertyWebScript extends AbstractRmWebScript -{ - /** - * Takes the element name and maps it to the QName of the customisable type. The passed element name should be a prefixed - * qname string, but to support previous versions of this API a couple of hard coded checks are made first. - * - * @param elementName - * @return - */ - protected QName mapToTypeQName(String elementName) - { - // Direct matching provided for backward compatibility with RM 1.0 - if ("recordFolder".equalsIgnoreCase(elementName)) - { - return RecordsManagementModel.TYPE_RECORD_FOLDER; - } - else if ("record".equalsIgnoreCase(elementName)) - { - return RecordsManagementModel.ASPECT_RECORD; - } - else if ("recordCategory".equalsIgnoreCase(elementName)) - { - return RecordsManagementModel.TYPE_RECORD_CATEGORY; - } - else if ("recordSeries".equalsIgnoreCase(elementName)) - { - return CompatibilityModel.TYPE_RECORD_SERIES; - } - else - { - // Try and convert the string to a qname - return QName.createQName(elementName, getNamespaceService()); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.namespace.QName; + +/** + * Base class for all custom property webscripts. + * + * @author Roy Wetherall + */ +public class BaseCustomPropertyWebScript extends AbstractRmWebScript +{ + /** + * Takes the element name and maps it to the QName of the customisable type. The passed element name should be a prefixed + * qname string, but to support previous versions of this API a couple of hard coded checks are made first. + * + * @param elementName + * @return + */ + protected QName mapToTypeQName(String elementName) + { + // Direct matching provided for backward compatibility with RM 1.0 + if ("recordFolder".equalsIgnoreCase(elementName)) + { + return RecordsManagementModel.TYPE_RECORD_FOLDER; + } + else if ("record".equalsIgnoreCase(elementName)) + { + return RecordsManagementModel.ASPECT_RECORD; + } + else if ("recordCategory".equalsIgnoreCase(elementName)) + { + return RecordsManagementModel.TYPE_RECORD_CATEGORY; + } + else if ("recordSeries".equalsIgnoreCase(elementName)) + { + return CompatibilityModel.TYPE_RECORD_SERIES; + } + else + { + // Try and convert the string to a qname + return QName.createQName(elementName, getNamespaceService()); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseTransferWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseTransferWebScript.java index 3304648aa3..8a7d26f144 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseTransferWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BaseTransferWebScript.java @@ -1,215 +1,215 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.web.scripts.content.StreamACP; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Abstract base class for transfer related web scripts. - * - * @author Gavin Cornwell - */ -public abstract class BaseTransferWebScript extends StreamACP - implements RecordsManagementModel -{ - /** Logger */ - private static Log logger = LogFactory.getLog(BaseTransferWebScript.class); - - protected FilePlanService filePlanService; - - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) - */ - public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - File tempFile = null; - try - { - // retrieve requested format - String format = req.getFormat(); - - // construct model for template - Status status = new Status(); - Cache cache = new Cache(getDescription().getRequiredCache()); - Map model = new HashMap(); - model.put("status", status); - model.put("cache", cache); - - // get the parameters that represent the NodeRef, we know they are present - // otherwise this webscript would not have matched - Map templateVars = req.getServiceMatch().getTemplateVars(); - String storeType = templateVars.get("store_type"); - String storeId = templateVars.get("store_id"); - String nodeId = templateVars.get("id"); - String transferId = templateVars.get("transfer_id"); - - // create and return the file plan NodeRef - NodeRef filePlan = new NodeRef(new StoreRef(storeType, storeId), nodeId); - - if (logger.isDebugEnabled()) - { - logger.debug("Retrieving transfer '" + transferId + "' from file plan: " + filePlan); - } - - // ensure the file plan exists - if (!this.nodeService.exists(filePlan)) - { - status.setCode(HttpServletResponse.SC_NOT_FOUND, - "Node " + filePlan.toString() + " does not exist"); - Map templateModel = createTemplateParameters(req, res, model); - sendStatus(req, res, status, cache, format, templateModel); - return; - } - - // ensure the node is a filePlan object - if (!filePlanService.isFilePlan(filePlan)) - { - status.setCode(HttpServletResponse.SC_BAD_REQUEST, - "Node " + filePlan.toString() + " is not a file plan"); - Map templateModel = createTemplateParameters(req, res, model); - sendStatus(req, res, status, cache, format, templateModel); - return; - } - - // attempt to find the transfer node - NodeRef transferNode = findTransferNode(filePlan, transferId); - - // send 404 if the transfer is not found - if (transferNode == null) - { - status.setCode(HttpServletResponse.SC_NOT_FOUND, - "Could not locate transfer with id: " + transferId); - Map templateModel = createTemplateParameters(req, res, model); - sendStatus(req, res, status, cache, format, templateModel); - return; - } - - // execute the transfer operation - tempFile = executeTransfer(transferNode, req, res, status, cache); - } - catch (Throwable e) - { - throw createStatusException(e, req, res); - } - finally - { - // try and delete the temporary file (if not in debug mode) - if (tempFile != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Transfer report saved to temporary file: " + tempFile.getAbsolutePath()); - } - else - { - tempFile.delete(); - } - } - } - } - - /** - * Abstract method subclasses implement to perform the actual logic required. - * - * @param transferNode The transfer node - * @param req The request - * @param res The response - * @param status Status object - * @param cache Cache object - * @return File object representing the file containing the JSON of the report - * @throws IOException - */ - protected abstract File executeTransfer(NodeRef transferNode, - WebScriptRequest req, WebScriptResponse res, - Status status, Cache cache) throws IOException; - - /** - * Finds a transfer object with the given id in the given file plan. - * This method returns null if a transfer with the given id is not found. - * - * @param filePlan The file plan to search - * @param transferId The id of the transfer being requested - * @return The transfer node or null if not found - */ - protected NodeRef findTransferNode(NodeRef filePlan, String transferId) - { - NodeRef transferNode = null; - - // get all the transfer nodes and find the one we need - NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); - List assocs = this.nodeService.getChildAssocs(transferContainer, - ContentModel.ASSOC_CONTAINS, - RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef child : assocs) - { - if (child.getChildRef().getId().equals(transferId)) - { - transferNode = child.getChildRef(); - break; - } - } - - return transferNode; - } - - /** - * Returns an array of NodeRefs representing the items to be transferred. - * - * @param transferNode The transfer object - * @return Array of NodeRefs - */ - protected NodeRef[] getTransferNodes(NodeRef transferNode) - { - List assocs = this.nodeService.getChildAssocs(transferNode, - RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - NodeRef[] itemsToTransfer = new NodeRef[assocs.size()]; - for (int idx = 0; idx < assocs.size(); idx++) - { - itemsToTransfer[idx] = assocs.get(idx).getChildRef(); - } - - return itemsToTransfer; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.web.scripts.content.StreamACP; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Abstract base class for transfer related web scripts. + * + * @author Gavin Cornwell + */ +public abstract class BaseTransferWebScript extends StreamACP + implements RecordsManagementModel +{ + /** Logger */ + private static Log logger = LogFactory.getLog(BaseTransferWebScript.class); + + protected FilePlanService filePlanService; + + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) + */ + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + File tempFile = null; + try + { + // retrieve requested format + String format = req.getFormat(); + + // construct model for template + Status status = new Status(); + Cache cache = new Cache(getDescription().getRequiredCache()); + Map model = new HashMap(); + model.put("status", status); + model.put("cache", cache); + + // get the parameters that represent the NodeRef, we know they are present + // otherwise this webscript would not have matched + Map templateVars = req.getServiceMatch().getTemplateVars(); + String storeType = templateVars.get("store_type"); + String storeId = templateVars.get("store_id"); + String nodeId = templateVars.get("id"); + String transferId = templateVars.get("transfer_id"); + + // create and return the file plan NodeRef + NodeRef filePlan = new NodeRef(new StoreRef(storeType, storeId), nodeId); + + if (logger.isDebugEnabled()) + { + logger.debug("Retrieving transfer '" + transferId + "' from file plan: " + filePlan); + } + + // ensure the file plan exists + if (!this.nodeService.exists(filePlan)) + { + status.setCode(HttpServletResponse.SC_NOT_FOUND, + "Node " + filePlan.toString() + " does not exist"); + Map templateModel = createTemplateParameters(req, res, model); + sendStatus(req, res, status, cache, format, templateModel); + return; + } + + // ensure the node is a filePlan object + if (!filePlanService.isFilePlan(filePlan)) + { + status.setCode(HttpServletResponse.SC_BAD_REQUEST, + "Node " + filePlan.toString() + " is not a file plan"); + Map templateModel = createTemplateParameters(req, res, model); + sendStatus(req, res, status, cache, format, templateModel); + return; + } + + // attempt to find the transfer node + NodeRef transferNode = findTransferNode(filePlan, transferId); + + // send 404 if the transfer is not found + if (transferNode == null) + { + status.setCode(HttpServletResponse.SC_NOT_FOUND, + "Could not locate transfer with id: " + transferId); + Map templateModel = createTemplateParameters(req, res, model); + sendStatus(req, res, status, cache, format, templateModel); + return; + } + + // execute the transfer operation + tempFile = executeTransfer(transferNode, req, res, status, cache); + } + catch (Throwable e) + { + throw createStatusException(e, req, res); + } + finally + { + // try and delete the temporary file (if not in debug mode) + if (tempFile != null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Transfer report saved to temporary file: " + tempFile.getAbsolutePath()); + } + else + { + tempFile.delete(); + } + } + } + } + + /** + * Abstract method subclasses implement to perform the actual logic required. + * + * @param transferNode The transfer node + * @param req The request + * @param res The response + * @param status Status object + * @param cache Cache object + * @return File object representing the file containing the JSON of the report + * @throws IOException + */ + protected abstract File executeTransfer(NodeRef transferNode, + WebScriptRequest req, WebScriptResponse res, + Status status, Cache cache) throws IOException; + + /** + * Finds a transfer object with the given id in the given file plan. + * This method returns null if a transfer with the given id is not found. + * + * @param filePlan The file plan to search + * @param transferId The id of the transfer being requested + * @return The transfer node or null if not found + */ + protected NodeRef findTransferNode(NodeRef filePlan, String transferId) + { + NodeRef transferNode = null; + + // get all the transfer nodes and find the one we need + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + List assocs = this.nodeService.getChildAssocs(transferContainer, + ContentModel.ASSOC_CONTAINS, + RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef child : assocs) + { + if (child.getChildRef().getId().equals(transferId)) + { + transferNode = child.getChildRef(); + break; + } + } + + return transferNode; + } + + /** + * Returns an array of NodeRefs representing the items to be transferred. + * + * @param transferNode The transfer object + * @return Array of NodeRefs + */ + protected NodeRef[] getTransferNodes(NodeRef transferNode) + { + List assocs = this.nodeService.getChildAssocs(transferNode, + RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + NodeRef[] itemsToTransfer = new NodeRef[assocs.size()]; + for (int idx = 0; idx < assocs.size(); idx++) + { + itemsToTransfer[idx] = assocs.get(idx).getChildRef(); + } + + return itemsToTransfer; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java index 9524c4bbdc..8143ed8835 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java @@ -1,347 +1,347 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; -import org.alfresco.module.org_alfresco_module_rm.security.Role; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authority.RMAuthority; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.view.ImporterService; -import org.alfresco.service.cmr.view.Location; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * BootstrapTestData GET WebScript implementation. - */ -@Deprecated -public class BootstrapTestDataGet extends DeclarativeWebScript - implements RecordsManagementModel -{ - private static Log logger = LogFactory.getLog(BootstrapTestDataGet.class); - - private static final String ARG_SITE_NAME = "site"; - private static final String ARG_IMPORT = "import"; - - private static final String XML_IMPORT = "alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml"; - private static final String CHARSET_NAME = "UTF-8"; - - private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - - private NodeService nodeService; - private SearchService searchService; - private RecordsManagementService recordsManagementService; - private RecordsManagementActionService recordsManagementActionService; - private ImporterService importerService; - private SiteService siteService; - private PermissionService permissionService; - private RecordsManagementSecurityService recordsManagementSecurityService; - private AuthorityService authorityService; - private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour; - private DispositionService dispositionService; - private RecordFolderService recordFolderService; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - public void setImporterService(ImporterService importerService) - { - this.importerService = importerService; - } - - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService) - { - this.recordsManagementSecurityService = recordsManagementSecurityService; - } - - public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour searchBehaviour) - { - this.recordsManagementSearchBehaviour = searchBehaviour; - } - - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // resolve import argument - boolean importData = false; - if (req.getParameter(ARG_IMPORT) != null) - { - importData = Boolean.parseBoolean(req.getParameter(ARG_IMPORT)); - } - - // resolve rm site - String siteName = RmSiteType.DEFAULT_SITE_NAME; - if (req.getParameter(ARG_SITE_NAME) != null) - { - siteName = req.getParameter(ARG_SITE_NAME); - } - - if (importData) - { - SiteInfo site = siteService.getSite(siteName); - if (site == null) - { - throw new AlfrescoRuntimeException("Records Management site does not exist: " + siteName); - } - - // resolve documentLibrary (filePlan) container - NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - if (filePlan == null) - { - filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY, TYPE_FILE_PLAN, null); - } - - // import the RM test data ACP into the the provided filePlan node reference - InputStream is = BootstrapTestDataGet.class.getClassLoader().getResourceAsStream(XML_IMPORT); - if (is == null) - { - throw new AlfrescoRuntimeException("The DODExampleFilePlan.xml import file could not be found"); - } - Reader viewReader = null; - try - { - viewReader = new InputStreamReader(is, CHARSET_NAME); - } - catch (UnsupportedEncodingException error) - { - throw new AlfrescoRuntimeException("The Character Encoding '" + CHARSET_NAME + "' is not supported.", error); - } - Location location = new Location(filePlan); - importerService.importView(viewReader, location, null, null); - } - - // Patch data - BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService, - recordsManagementActionService, permissionService, - authorityService, recordsManagementSecurityService, - recordsManagementSearchBehaviour, - dispositionService, recordFolderService); - - Map model = new HashMap(1, 1.0f); - model.put("success", true); - - return model; - } - - /** - * Temp method to patch AMP'ed data - * - * @param searchService - * @param nodeService - * @param recordsManagementService - * @param recordsManagementActionService - */ - public static void patchLoadedData( final SearchService searchService, - final NodeService nodeService, - final RecordsManagementService recordsManagementService, - final RecordsManagementActionService recordsManagementActionService, - final PermissionService permissionService, - final AuthorityService authorityService, - final RecordsManagementSecurityService recordsManagementSecurityService, - final RecordsManagementSearchBehaviour recordManagementSearchBehaviour, - final DispositionService dispositionService, - final RecordFolderService recordFolderService) - { - AuthenticationUtil.RunAsWork runAsWork = new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - java.util.List rmRoots = recordsManagementService.getFilePlans(); - logger.info("Bootstraping " + rmRoots.size() + " rm roots ..."); - for (NodeRef rmRoot : rmRoots) - { - if (permissionService.getInheritParentPermissions(rmRoot)) - { - logger.info("Updating permissions for rm root: " + rmRoot); - permissionService.setInheritParentPermissions(rmRoot, false); - } - - String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId(); - String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName); - - if (!authorityService.authorityExists(allRoleGroupName)) - { - logger.info("Creating all roles group for root node: " + rmRoot.toString()); - - // Create "all" role group for root node - String allRoles = authorityService.createAuthority(AuthorityType.GROUP, - allRoleShortName, - RMAuthority.ALL_ROLES_DISPLAY_NAME, - new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); - - // Put all the role groups in it - Set roles = recordsManagementSecurityService.getRoles(rmRoot); - for (Role role : roles) - { - logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group"); - authorityService.addAuthority(allRoles, role.getRoleGroupName()); - } - - // Set the permissions - permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true); - } - } - - // Make sure all the containers do not inherit permissions - ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordsManagementContainer\""); - try - { - logger.info("Bootstraping " + rs.length() + " record containers ..."); - - for (NodeRef container : rs.getNodeRefs()) - { - String containerName = (String)nodeService.getProperty(container, ContentModel.PROP_NAME); - - // Set permissions - if (permissionService.getInheritParentPermissions(container)) - { - logger.info("Updating permissions for record container: " + containerName); - permissionService.setInheritParentPermissions(container, false); - } - } - } - finally - { - rs.close(); - } - - // fix up the test dataset to fire initial events for disposition schedules - rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\""); - try - { - logger.info("Bootstraping " + rs.length() + " record folders ..."); - - for (NodeRef recordFolder : rs.getNodeRefs()) - { - String folderName = (String)nodeService.getProperty(recordFolder, ContentModel.PROP_NAME); - - // Set permissions - if (permissionService.getInheritParentPermissions(recordFolder)) - { - logger.info("Updating permissions for record folder: " + folderName); - permissionService.setInheritParentPermissions(recordFolder, false); - } - - if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) - { - // See if the folder has a disposition schedule that needs to be applied - DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder); - if (ds != null) - { - // Fire action to "set-up" the folder correctly - logger.info("Setting up bootstraped record folder: " + folderName); - recordFolderService.setupRecordFolder(recordFolder); - } - } - - // fixup the search behaviour aspect for the record folder - logger.info("Setting up search aspect for record folder: " + folderName); - recordManagementSearchBehaviour.fixupSearchAspect(recordFolder); - } - } - finally - { - rs.close(); - } - - return null; - } - }; - - AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName()); - - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; +import org.alfresco.module.org_alfresco_module_rm.security.Role; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.view.ImporterService; +import org.alfresco.service.cmr.view.Location; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * BootstrapTestData GET WebScript implementation. + */ +@Deprecated +public class BootstrapTestDataGet extends DeclarativeWebScript + implements RecordsManagementModel +{ + private static Log logger = LogFactory.getLog(BootstrapTestDataGet.class); + + private static final String ARG_SITE_NAME = "site"; + private static final String ARG_IMPORT = "import"; + + private static final String XML_IMPORT = "alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml"; + private static final String CHARSET_NAME = "UTF-8"; + + private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); + + private NodeService nodeService; + private SearchService searchService; + private RecordsManagementService recordsManagementService; + private RecordsManagementActionService recordsManagementActionService; + private ImporterService importerService; + private SiteService siteService; + private PermissionService permissionService; + private RecordsManagementSecurityService recordsManagementSecurityService; + private AuthorityService authorityService; + private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour; + private DispositionService dispositionService; + private RecordFolderService recordFolderService; + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + public void setRecordsManagementService(RecordsManagementService recordsManagementService) + { + this.recordsManagementService = recordsManagementService; + } + + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + public void setImporterService(ImporterService importerService) + { + this.importerService = importerService; + } + + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService) + { + this.recordsManagementSecurityService = recordsManagementSecurityService; + } + + public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour searchBehaviour) + { + this.recordsManagementSearchBehaviour = searchBehaviour; + } + + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // resolve import argument + boolean importData = false; + if (req.getParameter(ARG_IMPORT) != null) + { + importData = Boolean.parseBoolean(req.getParameter(ARG_IMPORT)); + } + + // resolve rm site + String siteName = RmSiteType.DEFAULT_SITE_NAME; + if (req.getParameter(ARG_SITE_NAME) != null) + { + siteName = req.getParameter(ARG_SITE_NAME); + } + + if (importData) + { + SiteInfo site = siteService.getSite(siteName); + if (site == null) + { + throw new AlfrescoRuntimeException("Records Management site does not exist: " + siteName); + } + + // resolve documentLibrary (filePlan) container + NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); + if (filePlan == null) + { + filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY, TYPE_FILE_PLAN, null); + } + + // import the RM test data ACP into the the provided filePlan node reference + InputStream is = BootstrapTestDataGet.class.getClassLoader().getResourceAsStream(XML_IMPORT); + if (is == null) + { + throw new AlfrescoRuntimeException("The DODExampleFilePlan.xml import file could not be found"); + } + Reader viewReader = null; + try + { + viewReader = new InputStreamReader(is, CHARSET_NAME); + } + catch (UnsupportedEncodingException error) + { + throw new AlfrescoRuntimeException("The Character Encoding '" + CHARSET_NAME + "' is not supported.", error); + } + Location location = new Location(filePlan); + importerService.importView(viewReader, location, null, null); + } + + // Patch data + BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService, + recordsManagementActionService, permissionService, + authorityService, recordsManagementSecurityService, + recordsManagementSearchBehaviour, + dispositionService, recordFolderService); + + Map model = new HashMap(1, 1.0f); + model.put("success", true); + + return model; + } + + /** + * Temp method to patch AMP'ed data + * + * @param searchService + * @param nodeService + * @param recordsManagementService + * @param recordsManagementActionService + */ + public static void patchLoadedData( final SearchService searchService, + final NodeService nodeService, + final RecordsManagementService recordsManagementService, + final RecordsManagementActionService recordsManagementActionService, + final PermissionService permissionService, + final AuthorityService authorityService, + final RecordsManagementSecurityService recordsManagementSecurityService, + final RecordsManagementSearchBehaviour recordManagementSearchBehaviour, + final DispositionService dispositionService, + final RecordFolderService recordFolderService) + { + AuthenticationUtil.RunAsWork runAsWork = new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + java.util.List rmRoots = recordsManagementService.getFilePlans(); + logger.info("Bootstraping " + rmRoots.size() + " rm roots ..."); + for (NodeRef rmRoot : rmRoots) + { + if (permissionService.getInheritParentPermissions(rmRoot)) + { + logger.info("Updating permissions for rm root: " + rmRoot); + permissionService.setInheritParentPermissions(rmRoot, false); + } + + String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId(); + String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName); + + if (!authorityService.authorityExists(allRoleGroupName)) + { + logger.info("Creating all roles group for root node: " + rmRoot.toString()); + + // Create "all" role group for root node + String allRoles = authorityService.createAuthority(AuthorityType.GROUP, + allRoleShortName, + RMAuthority.ALL_ROLES_DISPLAY_NAME, + new HashSet(Arrays.asList(RMAuthority.ZONE_APP_RM))); + + // Put all the role groups in it + Set roles = recordsManagementSecurityService.getRoles(rmRoot); + for (Role role : roles) + { + logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group"); + authorityService.addAuthority(allRoles, role.getRoleGroupName()); + } + + // Set the permissions + permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true); + } + } + + // Make sure all the containers do not inherit permissions + ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordsManagementContainer\""); + try + { + logger.info("Bootstraping " + rs.length() + " record containers ..."); + + for (NodeRef container : rs.getNodeRefs()) + { + String containerName = (String)nodeService.getProperty(container, ContentModel.PROP_NAME); + + // Set permissions + if (permissionService.getInheritParentPermissions(container)) + { + logger.info("Updating permissions for record container: " + containerName); + permissionService.setInheritParentPermissions(container, false); + } + } + } + finally + { + rs.close(); + } + + // fix up the test dataset to fire initial events for disposition schedules + rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\""); + try + { + logger.info("Bootstraping " + rs.length() + " record folders ..."); + + for (NodeRef recordFolder : rs.getNodeRefs()) + { + String folderName = (String)nodeService.getProperty(recordFolder, ContentModel.PROP_NAME); + + // Set permissions + if (permissionService.getInheritParentPermissions(recordFolder)) + { + logger.info("Updating permissions for record folder: " + folderName); + permissionService.setInheritParentPermissions(recordFolder, false); + } + + if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) + { + // See if the folder has a disposition schedule that needs to be applied + DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder); + if (ds != null) + { + // Fire action to "set-up" the folder correctly + logger.info("Setting up bootstraped record folder: " + folderName); + recordFolderService.setupRecordFolder(recordFolder); + } + } + + // fixup the search behaviour aspect for the record folder + logger.info("Setting up search aspect for record folder: " + folderName); + recordManagementSearchBehaviour.fixupSearchAspect(recordFolder); + } + } + finally + { + rs.close(); + } + + return null; + } + }; + + AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName()); + + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionDelete.java index df9754b380..09a005bdd2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionDelete.java @@ -1,113 +1,113 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.namespace.QName; -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.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; - -/** - * Implementation for Java backed webscript to remove RM custom property definitions - * from the custom model. - * - * @author Neil McErlean - */ -public class CustomPropertyDefinitionDelete extends AbstractRmWebScript -{ - private static final String PROP_ID = "propId"; - - private static Log logger = LogFactory.getLog(CustomPropertyDefinitionDelete.class); - - private RecordsManagementAdminService rmAdminService; - - public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) - { - this.rmAdminService = rmAdminService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map ftlModel = null; - try - { - QName propQName = getPropertyFromReq(req); - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Deleting property definition ").append(propQName); - logger.debug(msg.toString()); - } - ftlModel = removePropertyDefinition(propQName); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - return ftlModel; - } - - private QName getPropertyFromReq(WebScriptRequest req) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - String propIdString = templateVars.get(PROP_ID); - - QName propQName = this.rmAdminService.getQNameForClientId(propIdString); - Map existingPropDefs = rmAdminService.getCustomPropertyDefinitions(); - - if (!existingPropDefs.containsKey(propQName)) - { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, - "Requested property definition (id:" + propIdString + ") does not exist"); - } - - return propQName; - } - - /** - * Applies custom properties to the specified record node. - */ - protected Map removePropertyDefinition(QName propQName) throws JSONException - { - Map result = new HashMap(); - - rmAdminService.removeCustomPropertyDefinition(propQName); - - result.put("propertyqname", propQName.toPrefixString(getNamespaceService())); - - return result; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.namespace.QName; +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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; + +/** + * Implementation for Java backed webscript to remove RM custom property definitions + * from the custom model. + * + * @author Neil McErlean + */ +public class CustomPropertyDefinitionDelete extends AbstractRmWebScript +{ + private static final String PROP_ID = "propId"; + + private static Log logger = LogFactory.getLog(CustomPropertyDefinitionDelete.class); + + private RecordsManagementAdminService rmAdminService; + + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) + { + this.rmAdminService = rmAdminService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map ftlModel = null; + try + { + QName propQName = getPropertyFromReq(req); + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Deleting property definition ").append(propQName); + logger.debug(msg.toString()); + } + ftlModel = removePropertyDefinition(propQName); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + return ftlModel; + } + + private QName getPropertyFromReq(WebScriptRequest req) + { + Map templateVars = req.getServiceMatch().getTemplateVars(); + String propIdString = templateVars.get(PROP_ID); + + QName propQName = this.rmAdminService.getQNameForClientId(propIdString); + Map existingPropDefs = rmAdminService.getCustomPropertyDefinitions(); + + if (!existingPropDefs.containsKey(propQName)) + { + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, + "Requested property definition (id:" + propIdString + ") does not exist"); + } + + return propQName; + } + + /** + * Applies custom properties to the specified record node. + */ + protected Map removePropertyDefinition(QName propQName) throws JSONException + { + Map result = new HashMap(); + + rmAdminService.removeCustomPropertyDefinition(propQName); + + result.put("propertyqname", propQName.toPrefixString(getNamespaceService())); + + return result; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPost.java index 97ef604047..ac70e53872 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPost.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; 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 3b4e07854f..dcaeca2e85 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 @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionsGet.java index 6ae689d651..d757a54fd2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionsGet.java @@ -1,121 +1,121 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This class provides the implementation for the custompropdefinitions.get webscript. - * - * @author Neil McErlean - */ -public class CustomPropertyDefinitionsGet extends BaseCustomPropertyWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(CustomPropertyDefinitionsGet.class); - - private static final String ELEMENT = "element"; - private static final String PROP_ID = "propId"; - - /** Records management admin service */ - private RecordsManagementAdminService rmAdminService; - - /** - * @param rmAdminService records management admin service - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) - { - this.rmAdminService = rmAdminService; - } - - /** - * @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(); - - Map templateVars = req.getServiceMatch().getTemplateVars(); - String propId = templateVars.get(PROP_ID); - String elementName = req.getParameter(ELEMENT); - - if (logger.isDebugEnabled() && elementName != null) - { - logger.debug("Getting custom property definitions for elementName " + elementName); - } - else if (logger.isDebugEnabled() && propId != null) - { - logger.debug("Getting custom property definition for propId " + propId); - } - - // If propId has been provided then this is a request for a single custom-property-defn. - // else it is a request for all defined on the specified element. - List propData = new ArrayList(); - if (propId != null) - { - QName propQName = rmAdminService.getQNameForClientId(propId); - PropertyDefinition propDefn = rmAdminService.getCustomPropertyDefinitions().get(propQName); - if (propQName == null || propDefn == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Property definition for " + propId + " not found."); - } - propData.add(propDefn); - } - else if (elementName != null) - { - QName customisableType = mapToTypeQName(elementName); - Map currentCustomProps = rmAdminService.getCustomPropertyDefinitions(customisableType); - if (currentCustomProps != null) - { - for (Entry entry : currentCustomProps.entrySet()) - { - propData.add(entry.getValue()); - } - } - } - else - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Either elementName or propId must be specified."); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Retrieved custom property definitions: " + propData); - } - - model.put("customProps", propData); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * This class provides the implementation for the custompropdefinitions.get webscript. + * + * @author Neil McErlean + */ +public class CustomPropertyDefinitionsGet extends BaseCustomPropertyWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(CustomPropertyDefinitionsGet.class); + + private static final String ELEMENT = "element"; + private static final String PROP_ID = "propId"; + + /** Records management admin service */ + private RecordsManagementAdminService rmAdminService; + + /** + * @param rmAdminService records management admin service + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) + { + this.rmAdminService = rmAdminService; + } + + /** + * @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(); + + Map templateVars = req.getServiceMatch().getTemplateVars(); + String propId = templateVars.get(PROP_ID); + String elementName = req.getParameter(ELEMENT); + + if (logger.isDebugEnabled() && elementName != null) + { + logger.debug("Getting custom property definitions for elementName " + elementName); + } + else if (logger.isDebugEnabled() && propId != null) + { + logger.debug("Getting custom property definition for propId " + propId); + } + + // If propId has been provided then this is a request for a single custom-property-defn. + // else it is a request for all defined on the specified element. + List propData = new ArrayList(); + if (propId != null) + { + QName propQName = rmAdminService.getQNameForClientId(propId); + PropertyDefinition propDefn = rmAdminService.getCustomPropertyDefinitions().get(propQName); + if (propQName == null || propDefn == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Property definition for " + propId + " not found."); + } + propData.add(propDefn); + } + else if (elementName != null) + { + QName customisableType = mapToTypeQName(elementName); + Map currentCustomProps = rmAdminService.getCustomPropertyDefinitions(customisableType); + if (currentCustomProps != null) + { + for (Entry entry : currentCustomProps.entrySet()) + { + propData.add(entry.getValue()); + } + } + } + else + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Either elementName or propId must be specified."); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Retrieved custom property definitions: " + propData); + } + + model.put("customProps", propData); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefDelete.java index f4fc9d8a69..952c97792d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefDelete.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefPost.java index 105a142929..f3464c76eb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefPost.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java index e7e6d8c004..5c4daafe84 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; -import static org.apache.commons.lang.StringUtils.isBlank; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.json.JSONObject; - -/** - * Base class for custom reference definition classes - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class CustomReferenceDefinitionBase extends AbstractRmWebScript -{ - /** Constants for the custom reference definition classes */ - protected static final String REFERENCE_TYPE = "referenceType"; - protected static final String REF_ID = "refId"; - protected static final String LABEL = "label"; - protected static final String SOURCE = "source"; - protected static final String TARGET = "target"; - protected static final String CUSTOM_REFS = "customRefs"; - protected static final String URL = "url"; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** - * Gets the relationship service instance - * - * @return The relationship service instance - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Sets the relationship service instance - * - * @param relationshipService The relationship service instance - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * Creates the relationship display name from request content - * - * @param requestContent The request content as json object - * @return The relationship display name - */ - protected RelationshipDisplayName createDisplayName(JSONObject requestContent) - { - String sourceText; - String targetText; - - String labelText = getStringValueFromJSONObject(requestContent, LABEL, false, false); - - if (isBlank(labelText)) - { - sourceText = getStringValueFromJSONObject(requestContent, SOURCE); - targetText = getStringValueFromJSONObject(requestContent, TARGET); - } - else - { - sourceText = labelText; - targetText = labelText; - } - - return new RelationshipDisplayName(sourceText, targetText); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; +import static org.apache.commons.lang.StringUtils.isBlank; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.json.JSONObject; + +/** + * Base class for custom reference definition classes + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class CustomReferenceDefinitionBase extends AbstractRmWebScript +{ + /** Constants for the custom reference definition classes */ + protected static final String REFERENCE_TYPE = "referenceType"; + protected static final String REF_ID = "refId"; + protected static final String LABEL = "label"; + protected static final String SOURCE = "source"; + protected static final String TARGET = "target"; + protected static final String CUSTOM_REFS = "customRefs"; + protected static final String URL = "url"; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** + * Gets the relationship service instance + * + * @return The relationship service instance + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Sets the relationship service instance + * + * @param relationshipService The relationship service instance + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * Creates the relationship display name from request content + * + * @param requestContent The request content as json object + * @return The relationship display name + */ + protected RelationshipDisplayName createDisplayName(JSONObject requestContent) + { + String sourceText; + String targetText; + + String labelText = getStringValueFromJSONObject(requestContent, LABEL, false, false); + + if (isBlank(labelText)) + { + sourceText = getStringValueFromJSONObject(requestContent, SOURCE); + targetText = getStringValueFromJSONObject(requestContent, TARGET); + } + else + { + sourceText = labelText; + targetText = labelText; + } + + return new RelationshipDisplayName(sourceText, targetText); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPost.java index 0d86218f48..a6cd82047c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPost.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java index 8483ef3b4f..adbee12bbd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; 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 e389dadb25..46ffd94558 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 @@ -1,136 +1,136 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import static org.alfresco.util.WebScriptUtils.getRequestParameterValue; -import static org.apache.commons.lang3.StringUtils.isBlank; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get RM custom reference definitions. - * - * @author Neil McErlean - * @author Tuna Aksoy - */ -public class CustomReferenceDefinitionsGet extends CustomReferenceDefinitionBase -{ - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String uniqueName = getRequestParameterValue(req, REF_ID, false); - Set relationshipDefinitions = getRelationshipDefinitons(uniqueName); - List> relationshipDefinitionData = createRelationshipDefinitionData(relationshipDefinitions); - - Map model = new HashMap(); - model.put(CUSTOM_REFS, relationshipDefinitionData); - return model; - } - - /** - * Gets the relationship definition for the unique name. If the unique - * name is blank all relationship definitions will be retrieved - * - * @param uniqueName The unique name of the relationship definition - * @return Relationship definition for the given unique name or all - * relationship definitions if unique name is blank - */ - private Set getRelationshipDefinitons(String uniqueName) - { - Set relationshipDefinitions = new HashSet(); - - if (isBlank(uniqueName)) - { - relationshipDefinitions.addAll(getRelationshipService().getRelationshipDefinitions()); - } - else - { - RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); - if (relationshipDefinition != null) - { - relationshipDefinitions.add(relationshipDefinition); - } - } - - return relationshipDefinitions; - } - - /** - * Creates relationship definition data for the ftl template - * - * @param relationshipDefinitions The relationship definitions - * @return The relationship definition data - */ - private List> createRelationshipDefinitionData(Set relationshipDefinitions) - { - List> relationshipDefinitionData = new ArrayList>(); - - for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) - { - Map data = new HashMap(); - - RelationshipType type = relationshipDefinition.getType(); - RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); - - if (RelationshipType.BIDIRECTIONAL.equals(type)) - { - data.put(LABEL, displayName.getSourceText()); - } - else if (RelationshipType.PARENTCHILD.equals(type)) - { - data.put(SOURCE, displayName.getSourceText()); - data.put(TARGET, displayName.getTargetText()); - } - else - { - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type '") - .append(type) - .append("'."); - - throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString()); - } - - data.put(REF_ID, relationshipDefinition.getUniqueName()); - data.put(REFERENCE_TYPE, type.toString().toLowerCase()); - - relationshipDefinitionData.add(data); - } - - return relationshipDefinitionData; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import static org.alfresco.util.WebScriptUtils.getRequestParameterValue; +import static org.apache.commons.lang3.StringUtils.isBlank; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get RM custom reference definitions. + * + * @author Neil McErlean + * @author Tuna Aksoy + */ +public class CustomReferenceDefinitionsGet extends CustomReferenceDefinitionBase +{ + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + String uniqueName = getRequestParameterValue(req, REF_ID, false); + Set relationshipDefinitions = getRelationshipDefinitons(uniqueName); + List> relationshipDefinitionData = createRelationshipDefinitionData(relationshipDefinitions); + + Map model = new HashMap(); + model.put(CUSTOM_REFS, relationshipDefinitionData); + return model; + } + + /** + * Gets the relationship definition for the unique name. If the unique + * name is blank all relationship definitions will be retrieved + * + * @param uniqueName The unique name of the relationship definition + * @return Relationship definition for the given unique name or all + * relationship definitions if unique name is blank + */ + private Set getRelationshipDefinitons(String uniqueName) + { + Set relationshipDefinitions = new HashSet(); + + if (isBlank(uniqueName)) + { + relationshipDefinitions.addAll(getRelationshipService().getRelationshipDefinitions()); + } + else + { + RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); + if (relationshipDefinition != null) + { + relationshipDefinitions.add(relationshipDefinition); + } + } + + return relationshipDefinitions; + } + + /** + * Creates relationship definition data for the ftl template + * + * @param relationshipDefinitions The relationship definitions + * @return The relationship definition data + */ + private List> createRelationshipDefinitionData(Set relationshipDefinitions) + { + List> relationshipDefinitionData = new ArrayList>(); + + for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) + { + Map data = new HashMap(); + + RelationshipType type = relationshipDefinition.getType(); + RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); + + if (RelationshipType.BIDIRECTIONAL.equals(type)) + { + data.put(LABEL, displayName.getSourceText()); + } + else if (RelationshipType.PARENTCHILD.equals(type)) + { + data.put(SOURCE, displayName.getSourceText()); + data.put(TARGET, displayName.getTargetText()); + } + else + { + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type '") + .append(type) + .append("'."); + + throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString()); + } + + data.put(REF_ID, relationshipDefinition.getUniqueName()); + data.put(REFERENCE_TYPE, type.toString().toLowerCase()); + + relationshipDefinitionData.add(data); + } + + return relationshipDefinitionData; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceType.java index 7618457f0f..f1991c2724 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceType.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; - -/** - * This enum represents the allowed types of custom references. - * - * @author Neil McErlean - * @deprecated as of RM 2.3, please use {@link RelationshipType} instead. - */ -public enum CustomReferenceType -{ - PARENT_CHILD("parentchild"), - BIDIRECTIONAL("bidirectional"); - - private final String printableString; - - private CustomReferenceType(String printableString) - { - this.printableString = printableString; - } - - @Override - public String toString() - { - return this.printableString; - } - - public static CustomReferenceType getEnumFromString(String stg) - { - for (CustomReferenceType type : CustomReferenceType.values()) - { - if (type.printableString.equals(stg)) - { - return type; - } - } - throw new IllegalArgumentException("Unrecognised CustomReferenceType: " + stg); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; + +/** + * This enum represents the allowed types of custom references. + * + * @author Neil McErlean + * @deprecated as of RM 2.3, please use {@link RelationshipType} instead. + */ +public enum CustomReferenceType +{ + PARENT_CHILD("parentchild"), + BIDIRECTIONAL("bidirectional"); + + private final String printableString; + + private CustomReferenceType(String printableString) + { + this.printableString = printableString; + } + + @Override + public String toString() + { + return this.printableString; + } + + public static CustomReferenceType getEnumFromString(String stg) + { + for (CustomReferenceType type : CustomReferenceType.values()) + { + if (type.printableString.equals(stg)) + { + return type; + } + } + throw new IllegalArgumentException("Unrecognised CustomReferenceType: " + stg); + } } \ No newline at end of file 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 cd240f689a..f58816d55a 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 @@ -1,234 +1,234 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get RM custom references for a node. - * - * @author Neil McErlean - * @author Tuna Aksoy - */ -public class CustomRefsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String REFERENCE_TYPE = "referenceType"; - private static final String REF_ID = "refId"; - private static final String LABEL = "label"; - private static final String SOURCE = "source"; - private static final String TARGET = "target"; - private static final String PARENT_REF = "parentRef"; - private static final String CHILD_REF = "childRef"; - private static final String SOURCE_REF = "sourceRef"; - private static final String TARGET_REF = "targetRef"; - private static final String CUSTOM_REFS_FROM = "customRefsFrom"; - private static final String CUSTOM_REFS_TO = "customRefsTo"; - private static final String NODE_NAME = "nodeName"; - private static final String NODE_TITLE = "nodeTitle"; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** Capability service */ - private CapabilityService capabilityService; - - /** - * Gets the relationship service instance - * - * @return The relationship service instance - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Sets the relationship service instance - * - * @param relationshipService The relationship service instance - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * Gets the capability service instance - * - * @return The capability service instance - */ - protected CapabilityService getCapabilityService() - { - return this.capabilityService; - } - - /** - * Sets the capability service instance - * - * @param capabilityService Capability service instance - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(4); - NodeRef nodeRef = parseRequestForNodeRef(req); - model.put(NODE_NAME, getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME)); - model.put(NODE_TITLE, getNodeService().getProperty(nodeRef, ContentModel.PROP_TITLE)); - model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef)); - model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef)); - return model; - } - - /** - * Gets all the references that come 'out' from this node - * - * @param nodeRef Node reference - * @return All the references that come 'out' from this node - */ - private List> getOutwardReferences(NodeRef nodeRef) - { - List> outwardReferenceData = new ArrayList>(); - Set relationships = getRelationshipService().getRelationshipsFrom(nodeRef); - outwardReferenceData.addAll(getRelationshipData(relationships)); - return outwardReferenceData; - } - - /** - * Gets all the references that come 'in' to this node - * - * @param nodeRef Node reference - * @return All the references that come 'in' to this node - */ - private List> getInwardReferenceData(NodeRef nodeRef) - { - List> inwardReferenceData = new ArrayList>(); - Set relationships = getRelationshipService().getRelationshipsTo(nodeRef); - inwardReferenceData.addAll(getRelationshipData(relationships)); - return inwardReferenceData; - } - - /** - * Creates relationship data for the ftl template - * - * @param relationships The relationships - * @return The relationship data - */ - private List> getRelationshipData(Set relationships) - { - List> relationshipData = new ArrayList>(); - - for (Relationship relationship : relationships) - { - String uniqueName = relationship.getUniqueName(); - RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); - - NodeRef source = relationship.getSource(); - NodeRef target = relationship.getTarget(); - - if (relationshipDefinition != null && hasView(source) && hasView(target)) - { - Map data = new HashMap(); - - RelationshipType type = relationshipDefinition.getType(); - RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); - - if (RelationshipType.BIDIRECTIONAL.equals(type)) - { - data.put(LABEL, displayName.getSourceText()); - data.put(SOURCE_REF, source.toString()); - data.put(TARGET_REF, target.toString()); - } - else if (RelationshipType.PARENTCHILD.equals(type)) - { - data.put(SOURCE, displayName.getSourceText()); - data.put(TARGET, displayName.getTargetText()); - data.put(PARENT_REF, source.toString()); - data.put(CHILD_REF, target.toString()); - } - else - { - StringBuilder sb = new StringBuilder(); - sb.append("Unsupported relationship type '") - .append(type) - .append("'."); - - throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString()); - } - - data.put(REFERENCE_TYPE, type.toString().toLowerCase()); - data.put(REF_ID, uniqueName); - - relationshipData.add(data); - } - - } - - return relationshipData; - } - - /** - * Determines whether the current user has view capabilities on the given node. - * - * @param nodeRef Node reference - * @return boolean true if current user has view capability, false otherwise - */ - private boolean hasView(NodeRef nodeRef) - { - boolean result = false; - - Capability viewRecordCapability = getCapabilityService().getCapability(ViewRecordsCapability.NAME); - if (AccessStatus.ALLOWED.equals(viewRecordCapability.hasPermission(nodeRef))) - { - result = true; - } - - return result; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get RM custom references for a node. + * + * @author Neil McErlean + * @author Tuna Aksoy + */ +public class CustomRefsGet extends AbstractRmWebScript +{ + /** Constants */ + private static final String REFERENCE_TYPE = "referenceType"; + private static final String REF_ID = "refId"; + private static final String LABEL = "label"; + private static final String SOURCE = "source"; + private static final String TARGET = "target"; + private static final String PARENT_REF = "parentRef"; + private static final String CHILD_REF = "childRef"; + private static final String SOURCE_REF = "sourceRef"; + private static final String TARGET_REF = "targetRef"; + private static final String CUSTOM_REFS_FROM = "customRefsFrom"; + private static final String CUSTOM_REFS_TO = "customRefsTo"; + private static final String NODE_NAME = "nodeName"; + private static final String NODE_TITLE = "nodeTitle"; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** Capability service */ + private CapabilityService capabilityService; + + /** + * Gets the relationship service instance + * + * @return The relationship service instance + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Sets the relationship service instance + * + * @param relationshipService The relationship service instance + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * Gets the capability service instance + * + * @return The capability service instance + */ + protected CapabilityService getCapabilityService() + { + return this.capabilityService; + } + + /** + * Sets the capability service instance + * + * @param capabilityService Capability service instance + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(4); + NodeRef nodeRef = parseRequestForNodeRef(req); + model.put(NODE_NAME, getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME)); + model.put(NODE_TITLE, getNodeService().getProperty(nodeRef, ContentModel.PROP_TITLE)); + model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef)); + model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef)); + return model; + } + + /** + * Gets all the references that come 'out' from this node + * + * @param nodeRef Node reference + * @return All the references that come 'out' from this node + */ + private List> getOutwardReferences(NodeRef nodeRef) + { + List> outwardReferenceData = new ArrayList>(); + Set relationships = getRelationshipService().getRelationshipsFrom(nodeRef); + outwardReferenceData.addAll(getRelationshipData(relationships)); + return outwardReferenceData; + } + + /** + * Gets all the references that come 'in' to this node + * + * @param nodeRef Node reference + * @return All the references that come 'in' to this node + */ + private List> getInwardReferenceData(NodeRef nodeRef) + { + List> inwardReferenceData = new ArrayList>(); + Set relationships = getRelationshipService().getRelationshipsTo(nodeRef); + inwardReferenceData.addAll(getRelationshipData(relationships)); + return inwardReferenceData; + } + + /** + * Creates relationship data for the ftl template + * + * @param relationships The relationships + * @return The relationship data + */ + private List> getRelationshipData(Set relationships) + { + List> relationshipData = new ArrayList>(); + + for (Relationship relationship : relationships) + { + String uniqueName = relationship.getUniqueName(); + RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); + + NodeRef source = relationship.getSource(); + NodeRef target = relationship.getTarget(); + + if (relationshipDefinition != null && hasView(source) && hasView(target)) + { + Map data = new HashMap(); + + RelationshipType type = relationshipDefinition.getType(); + RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); + + if (RelationshipType.BIDIRECTIONAL.equals(type)) + { + data.put(LABEL, displayName.getSourceText()); + data.put(SOURCE_REF, source.toString()); + data.put(TARGET_REF, target.toString()); + } + else if (RelationshipType.PARENTCHILD.equals(type)) + { + data.put(SOURCE, displayName.getSourceText()); + data.put(TARGET, displayName.getTargetText()); + data.put(PARENT_REF, source.toString()); + data.put(CHILD_REF, target.toString()); + } + else + { + StringBuilder sb = new StringBuilder(); + sb.append("Unsupported relationship type '") + .append(type) + .append("'."); + + throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString()); + } + + data.put(REFERENCE_TYPE, type.toString().toLowerCase()); + data.put(REF_ID, uniqueName); + + relationshipData.add(data); + } + + } + + return relationshipData; + } + + /** + * Determines whether the current user has view capabilities on the given node. + * + * @param nodeRef Node reference + * @return boolean true if current user has view capability, false otherwise + */ + private boolean hasView(NodeRef nodeRef) + { + boolean result = false; + + Capability viewRecordCapability = getCapabilityService().getCapability(ViewRecordsCapability.NAME); + if (AccessStatus.ALLOWED.equals(viewRecordCapability.hasPermission(nodeRef))) + { + result = true; + } + + return result; + } } \ No newline at end of file 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 7f11d4a5de..bb718be343 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 @@ -1,168 +1,168 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -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; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This class provides the implementation for the customisable.get webscript. - * - * @author Roy Wetherall - */ -public class CustomisableGet extends DeclarativeWebScript -{ - /** Records management admin service */ - private RecordsManagementAdminService rmAdminService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** - * @param rmAdminService records management admin service - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) - { - this.rmAdminService = rmAdminService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - /** - * @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(); - - Set qnames = rmAdminService.getCustomisable(); - ArrayList items = new ArrayList(qnames.size()); - for (QName qname : qnames) - { - ClassDefinition definition = dictionaryService.getClass(qname); - if (definition != null) - { - String name = qname.toPrefixString(namespaceService); - String title = definition.getTitle(dictionaryService); - if (title == null || title.length() == 0) - { - title = qname.getLocalName(); - } - boolean isAspect = definition.isAspect(); - - items.add(new Item(name, isAspect, title)); - } - } - - // Sort the customisable types and aspects by title - Collections.sort(items, new Comparator() - { - @Override - public int compare(Item o1, Item o2) - { - return o1.title.compareToIgnoreCase(o2.title); - }}); - - model.put("items", items); - return model; - } - - /** - * Model items - */ - public class Item - { - private String name; - private boolean isAspect; - private String title; - - public Item(String name, boolean isAspect, String title) - { - this.name = name; - this.isAspect = isAspect; - this.title = title; - } - - public String getName() - { - return name; - } - - public boolean getIsAspect() - { - return isAspect; - } - - public String getTitle() - { - return title; - } - - @Override - public int hashCode() - { - int varCode = (null == name ? 0 : name.hashCode()); - return 31 + varCode; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null || (obj.getClass() != this.getClass())) - { - return false; - } - else - { - return this.name.equals(((Item)obj).name); - } - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.service.cmr.dictionary.ClassDefinition; +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; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * This class provides the implementation for the customisable.get webscript. + * + * @author Roy Wetherall + */ +public class CustomisableGet extends DeclarativeWebScript +{ + /** Records management admin service */ + private RecordsManagementAdminService rmAdminService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** + * @param rmAdminService records management admin service + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) + { + this.rmAdminService = rmAdminService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + /** + * @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(); + + Set qnames = rmAdminService.getCustomisable(); + ArrayList items = new ArrayList(qnames.size()); + for (QName qname : qnames) + { + ClassDefinition definition = dictionaryService.getClass(qname); + if (definition != null) + { + String name = qname.toPrefixString(namespaceService); + String title = definition.getTitle(dictionaryService); + if (title == null || title.length() == 0) + { + title = qname.getLocalName(); + } + boolean isAspect = definition.isAspect(); + + items.add(new Item(name, isAspect, title)); + } + } + + // Sort the customisable types and aspects by title + Collections.sort(items, new Comparator() + { + @Override + public int compare(Item o1, Item o2) + { + return o1.title.compareToIgnoreCase(o2.title); + }}); + + model.put("items", items); + return model; + } + + /** + * Model items + */ + public class Item + { + private String name; + private boolean isAspect; + private String title; + + public Item(String name, boolean isAspect, String title) + { + this.name = name; + this.isAspect = isAspect; + this.title = title; + } + + public String getName() + { + return name; + } + + public boolean getIsAspect() + { + return isAspect; + } + + public String getTitle() + { + return title; + } + + @Override + public int hashCode() + { + int varCode = (null == name ? 0 : name.hashCode()); + return 31 + varCode; + } + + @Override + public boolean equals(Object obj) + { + if (obj == null || (obj.getClass() != this.getClass())) + { + return false; + } + else + { + return this.name.equals(((Item)obj).name); + } + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java index 26ac093d52..3359aebe2c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java @@ -1,117 +1,117 @@ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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; - -public class DataSetPost extends DeclarativeWebScript implements RecordsManagementModel -{ - /** Constant for the site name parameter */ - private static final String ARG_SITE_NAME = "site"; - - /** Constant for the data set id parameter */ - private static final String ARG_DATA_SET_ID = "dataSetId"; - - /** Logger */ - private static Log logger = LogFactory.getLog(DataSetPost.class); - - /** Site service */ - private SiteService siteService; - - /** Data set service */ - private DataSetService dataSetService; - - /** - * Set site service - * - * @param siteService the site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * Data set service - * - * @param dataSetService the data set service - */ - public void setDataSetService(DataSetService dataSetService) - { - this.dataSetService = dataSetService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1, 1.0f); - try - { - // Resolve data set id - String dataSetId = req.getServiceMatch().getTemplateVars().get(ARG_DATA_SET_ID); - if (StringUtils.isBlank(dataSetId)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A data set id was not provided."); - } - if (!dataSetService.existsDataSet(dataSetId)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "A data set with the id '" + dataSetId + "'" - + " does not exist."); - } - - // Resolve RM site - String siteName = req.getParameter(ARG_SITE_NAME); - if (StringUtils.isBlank(siteName)) - { - siteName = RmSiteType.DEFAULT_SITE_NAME; - } - - // Check the site if it exists - if (siteService.getSite(siteName) == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A Records Management site with the name '" - + siteName + "' does not exist."); - } - - // Resolve documentLibrary (filePlan) container - NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - if (filePlan == null) - { - filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY, - TYPE_FILE_PLAN, null); - } - - // Load data set in to the file plan - dataSetService.loadDataSet(filePlan, dataSetId); - - model.put("success", true); - model.put("message", "Successfully imported data set."); - } - catch (Exception ex) - { - model.put("success", false); - model.put("message", ex.getMessage()); - logger.error("Error while importing data set: " + ex); - } - - return model; - } -} +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteService; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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; + +public class DataSetPost extends DeclarativeWebScript implements RecordsManagementModel +{ + /** Constant for the site name parameter */ + private static final String ARG_SITE_NAME = "site"; + + /** Constant for the data set id parameter */ + private static final String ARG_DATA_SET_ID = "dataSetId"; + + /** Logger */ + private static Log logger = LogFactory.getLog(DataSetPost.class); + + /** Site service */ + private SiteService siteService; + + /** Data set service */ + private DataSetService dataSetService; + + /** + * Set site service + * + * @param siteService the site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * Data set service + * + * @param dataSetService the data set service + */ + public void setDataSetService(DataSetService dataSetService) + { + this.dataSetService = dataSetService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1, 1.0f); + try + { + // Resolve data set id + String dataSetId = req.getServiceMatch().getTemplateVars().get(ARG_DATA_SET_ID); + if (StringUtils.isBlank(dataSetId)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A data set id was not provided."); + } + if (!dataSetService.existsDataSet(dataSetId)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "A data set with the id '" + dataSetId + "'" + + " does not exist."); + } + + // Resolve RM site + String siteName = req.getParameter(ARG_SITE_NAME); + if (StringUtils.isBlank(siteName)) + { + siteName = RmSiteType.DEFAULT_SITE_NAME; + } + + // Check the site if it exists + if (siteService.getSite(siteName) == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A Records Management site with the name '" + + siteName + "' does not exist."); + } + + // Resolve documentLibrary (filePlan) container + NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); + if (filePlan == null) + { + filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY, + TYPE_FILE_PLAN, null); + } + + // Load data set in to the file plan + dataSetService.loadDataSet(filePlan, dataSetId); + + model.put("success", true); + model.put("message", "Successfully imported data set."); + } + catch (Exception ex) + { + model.put("success", false); + model.put("message", ex.getMessage()); + logger.error("Error while importing data set: " + ex); + } + + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java index 2c76cbd863..78bd475588 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java @@ -1,104 +1,104 @@ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet; -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -public class DataSetsGet extends DeclarativeWebScript -{ - - /** Constant for the site name parameter */ - private static final String ARG_SITE_NAME = "site"; - - /** Constant for the unloadedonly parameter */ - private static final String ARG_UNLOADED_ONLY = "unloadedonly"; - - /** Data set service */ - private DataSetService dataSetService; - - /** Site service */ - private SiteService siteService; - - /** - * Set data set service - * - * @param dataSetService the data set service - */ - public void setDataSetService(DataSetService dataSetService) - { - this.dataSetService = dataSetService; - } - - /** - * Set site service - * - * @param siteService the site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Get the site name from the URL and find out the file plan - String siteName = req.getParameter(ARG_SITE_NAME); - if (StringUtils.isBlank(siteName)) - { - siteName = RmSiteType.DEFAULT_SITE_NAME; - } - NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - - // Check if only unloaded data sets should be returned - default value is false - String unloadedOnlyParam = req.getParameter(ARG_UNLOADED_ONLY); - boolean unloadedOnly = false; - if (StringUtils.isNotBlank(unloadedOnlyParam)) - { - unloadedOnly = Boolean.valueOf(unloadedOnlyParam).booleanValue(); - } - - // Get the loaded/unloaded data sets depending on the "unloadedOnly" parameter - Map dataSets = dataSetService.getDataSets(filePlan, unloadedOnly); - List> dataSetList = new ArrayList>(dataSets.size()); - - for (Map.Entry entry : dataSets.entrySet()) - { - Map dataSet = new HashMap(3); - DataSet value = entry.getValue(); - - // Data set details - String dataSetId = value.getId(); - String isLoaded = String.valueOf(dataSetService.isLoadedDataSet(filePlan, dataSetId)); - - dataSet.put("label", value.getLabel()); - dataSet.put("id", dataSetId); - dataSet.put("isLoaded", isLoaded); - - // Add data set to the list - dataSetList.add(dataSet); - } - - Map model = new HashMap(1); - model.put("datasets", dataSetList); - - return model; - } -} +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet; +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteService; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +public class DataSetsGet extends DeclarativeWebScript +{ + + /** Constant for the site name parameter */ + private static final String ARG_SITE_NAME = "site"; + + /** Constant for the unloadedonly parameter */ + private static final String ARG_UNLOADED_ONLY = "unloadedonly"; + + /** Data set service */ + private DataSetService dataSetService; + + /** Site service */ + private SiteService siteService; + + /** + * Set data set service + * + * @param dataSetService the data set service + */ + public void setDataSetService(DataSetService dataSetService) + { + this.dataSetService = dataSetService; + } + + /** + * Set site service + * + * @param siteService the site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Get the site name from the URL and find out the file plan + String siteName = req.getParameter(ARG_SITE_NAME); + if (StringUtils.isBlank(siteName)) + { + siteName = RmSiteType.DEFAULT_SITE_NAME; + } + NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); + + // Check if only unloaded data sets should be returned - default value is false + String unloadedOnlyParam = req.getParameter(ARG_UNLOADED_ONLY); + boolean unloadedOnly = false; + if (StringUtils.isNotBlank(unloadedOnlyParam)) + { + unloadedOnly = Boolean.valueOf(unloadedOnlyParam).booleanValue(); + } + + // Get the loaded/unloaded data sets depending on the "unloadedOnly" parameter + Map dataSets = dataSetService.getDataSets(filePlan, unloadedOnly); + List> dataSetList = new ArrayList>(dataSets.size()); + + for (Map.Entry entry : dataSets.entrySet()) + { + Map dataSet = new HashMap(3); + DataSet value = entry.getValue(); + + // Data set details + String dataSetId = value.getId(); + String isLoaded = String.valueOf(dataSetService.isLoadedDataSet(filePlan, dataSetId)); + + dataSet.put("label", value.getLabel()); + dataSet.put("id", dataSetId); + dataSet.put("isLoaded", isLoaded); + + // Add data set to the list + dataSetList.add(dataSet); + } + + Map model = new HashMap(1); + model.put("datasets", dataSetList); + + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionAbstractBase.java index f3e2e8f771..80e39c02ce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionAbstractBase.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.script; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionDelete.java index 3fc0dbb8a6..c7261eb6a0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionDelete.java @@ -1,74 +1,74 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to delete a dispostion action definition. - * - * @author Gavin Cornwell - */ -public class DispositionActionDefinitionDelete extends DispositionAbstractBase -{ - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // parse the request to retrieve the schedule object - DispositionSchedule schedule = parseRequestForSchedule(req); - - // parse the request to retrieve the action definition object - DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule); - - // remove the action definition from the schedule - removeDispositionActionDefinitions(schedule, actionDef); - - // return the disposition schedule model - return getDispositionScheduleModel(req); - } - - /** - * Helper method to remove a disposition action definition and the following definition(s) - * - * @param schedule The disposition schedule - * @param actionDef The disposition action definition - */ - private void removeDispositionActionDefinitions(DispositionSchedule schedule, DispositionActionDefinition actionDef) - { - int index = actionDef.getIndex(); - List dispositionActionDefinitions = schedule.getDispositionActionDefinitions(); - for (DispositionActionDefinition dispositionActionDefinition : dispositionActionDefinitions) - { - if (dispositionActionDefinition.getIndex() >= index) - { - getDispositionService().removeDispositionActionDefinition(schedule, dispositionActionDefinition); - } - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to delete a dispostion action definition. + * + * @author Gavin Cornwell + */ +public class DispositionActionDefinitionDelete extends DispositionAbstractBase +{ + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // parse the request to retrieve the schedule object + DispositionSchedule schedule = parseRequestForSchedule(req); + + // parse the request to retrieve the action definition object + DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule); + + // remove the action definition from the schedule + removeDispositionActionDefinitions(schedule, actionDef); + + // return the disposition schedule model + return getDispositionScheduleModel(req); + } + + /** + * Helper method to remove a disposition action definition and the following definition(s) + * + * @param schedule The disposition schedule + * @param actionDef The disposition action definition + */ + private void removeDispositionActionDefinitions(DispositionSchedule schedule, DispositionActionDefinition actionDef) + { + int index = actionDef.getIndex(); + List dispositionActionDefinitions = schedule.getDispositionActionDefinitions(); + for (DispositionActionDefinition dispositionActionDefinition : dispositionActionDefinitions) + { + if (dispositionActionDefinition.getIndex() >= index) + { + getDispositionService().removeDispositionActionDefinition(schedule, dispositionActionDefinition); + } + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPost.java index dbcaf2569c..09a5a4a5e2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPost.java @@ -1,159 +1,159 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.namespace.QName; -import org.json.JSONArray; -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; - -/** - * Implementation for Java backed webscript to create a new dispositon action definition. - * - * @author Gavin Cornwell - */ -public class DispositionActionDefinitionPost extends DispositionAbstractBase -{ - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // parse the request to retrieve the schedule object - DispositionSchedule schedule = parseRequestForSchedule(req); - - // retrieve the rest of the post body and create the action - // definition - JSONObject json = null; - DispositionActionDefinition actionDef = null; - try - { - json = new JSONObject(new JSONTokener(req.getContent().getContent())); - actionDef = createActionDefinition(json, schedule); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - // create model object with just the action data - Map model = new HashMap(1); - model.put("action", createActionDefModel(actionDef, req.getURL() + "/" + actionDef.getId())); - return model; - } - - /** - * Creates a dispositionActionDefinition node in the repo. - * - * @param json The JSON to use to create the action definition - * @param schedule The DispositionSchedule the action is for - * @return The DispositionActionDefinition representing the new action definition - */ - protected DispositionActionDefinition createActionDefinition(JSONObject json, - DispositionSchedule schedule) throws JSONException - { - // extract the data from the JSON request - if (!json.has("name")) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'name' parameter was not provided in request body"); - } - - // create the properties for the action definition - Map props = new HashMap(8); - String name = json.getString("name"); - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME, name); - - if (json.has("description")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_DESCRIPTION, json.getString("description")); - } - - if (json.has("period")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD, json.getString("period")); - } - - if (json.has("periodProperty")) - { - QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService()); - props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty); - } - - if (json.has("eligibleOnFirstCompleteEvent")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT_COMBINATION, - json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and"); - } - - if (json.has("location")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_LOCATION, - json.getString("location")); - } - - if (json.has("events")) - { - JSONArray events = json.getJSONArray("events"); - List eventsList = new ArrayList(events.length()); - for (int x = 0; x < events.length(); x++) - { - eventsList.add(events.getString(x)); - } - props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT, (Serializable)eventsList); - } - - if (json.has("name") && "destroy".equals(json.getString("name"))) - { - if (json.has("ghostOnDestroy")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "ghost"); - } - else - { - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "delete"); - } - } - - // add the action definition to the schedule - return getDispositionService().addDispositionActionDefinition(schedule, props); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.namespace.QName; +import org.json.JSONArray; +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; + +/** + * Implementation for Java backed webscript to create a new dispositon action definition. + * + * @author Gavin Cornwell + */ +public class DispositionActionDefinitionPost extends DispositionAbstractBase +{ + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // parse the request to retrieve the schedule object + DispositionSchedule schedule = parseRequestForSchedule(req); + + // retrieve the rest of the post body and create the action + // definition + JSONObject json = null; + DispositionActionDefinition actionDef = null; + try + { + json = new JSONObject(new JSONTokener(req.getContent().getContent())); + actionDef = createActionDefinition(json, schedule); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + // create model object with just the action data + Map model = new HashMap(1); + model.put("action", createActionDefModel(actionDef, req.getURL() + "/" + actionDef.getId())); + return model; + } + + /** + * Creates a dispositionActionDefinition node in the repo. + * + * @param json The JSON to use to create the action definition + * @param schedule The DispositionSchedule the action is for + * @return The DispositionActionDefinition representing the new action definition + */ + protected DispositionActionDefinition createActionDefinition(JSONObject json, + DispositionSchedule schedule) throws JSONException + { + // extract the data from the JSON request + if (!json.has("name")) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'name' parameter was not provided in request body"); + } + + // create the properties for the action definition + Map props = new HashMap(8); + String name = json.getString("name"); + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME, name); + + if (json.has("description")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_DESCRIPTION, json.getString("description")); + } + + if (json.has("period")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD, json.getString("period")); + } + + if (json.has("periodProperty")) + { + QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService()); + props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty); + } + + if (json.has("eligibleOnFirstCompleteEvent")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT_COMBINATION, + json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and"); + } + + if (json.has("location")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_LOCATION, + json.getString("location")); + } + + if (json.has("events")) + { + JSONArray events = json.getJSONArray("events"); + List eventsList = new ArrayList(events.length()); + for (int x = 0; x < events.length(); x++) + { + eventsList.add(events.getString(x)); + } + props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT, (Serializable)eventsList); + } + + if (json.has("name") && "destroy".equals(json.getString("name"))) + { + if (json.has("ghostOnDestroy")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "ghost"); + } + else + { + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "delete"); + } + } + + // add the action definition to the schedule + return getDispositionService().addDispositionActionDefinition(schedule, props); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPut.java index 68ba13854b..ba5dba9e37 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionActionDefinitionPut.java @@ -1,158 +1,158 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.namespace.QName; -import org.json.JSONArray; -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; - -/** - * Implementation for Java backed webscript to update an existing dispositon - * action definition. - * - * @author Gavin Cornwell - */ -public class DispositionActionDefinitionPut extends DispositionAbstractBase -{ - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // parse the request to retrieve the schedule object - DispositionSchedule schedule = parseRequestForSchedule(req); - - // parse the request to retrieve the action definition object - DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule); - - // retrieve the rest of the post body and update the action definition - JSONObject json = null; - try - { - json = new JSONObject(new JSONTokener(req.getContent().getContent())); - actionDef = updateActionDefinition(actionDef, json); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - // create model object with just the action data - Map model = new HashMap(1); - model.put("action", createActionDefModel(actionDef, req.getURL())); - return model; - } - - /** - * Updates a dispositionActionDefinition node in the repo. - * - * @param actionDef The action definition to update - * @param json The JSON to use to create the action definition - * @param schedule The DispositionSchedule the action definition belongs to - * @return The updated DispositionActionDefinition - */ - protected DispositionActionDefinition updateActionDefinition(DispositionActionDefinition actionDef, - JSONObject json) throws JSONException - { - // create the properties for the action definition - Map props = new HashMap(8); - - if (json.has("name")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME, json.getString("name")); - } - - if (json.has("description")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_DESCRIPTION, json.getString("description")); - } - - if (json.has("period")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD, json.getString("period")); - } - - if (json.has("periodProperty")) - { - QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService()); - props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty); - } - - if (json.has("eligibleOnFirstCompleteEvent")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT_COMBINATION, - json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and"); - } - - if (json.has("location")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_LOCATION, - json.getString("location")); - } - - if (json.has("events")) - { - JSONArray events = json.getJSONArray("events"); - List eventsList = new ArrayList(events.length()); - for (int x = 0; x < events.length(); x++) - { - eventsList.add(events.getString(x)); - } - props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT, (Serializable)eventsList); - } - - if (json.has("name") && "destroy".equals(json.getString("name"))) - { - if (json.has("ghostOnDestroy")) - { - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "ghost"); - } - else - { - props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "delete"); - } - } - - // update the action definition - return getDispositionService().updateDispositionActionDefinition(actionDef, props); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.namespace.QName; +import org.json.JSONArray; +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; + +/** + * Implementation for Java backed webscript to update an existing dispositon + * action definition. + * + * @author Gavin Cornwell + */ +public class DispositionActionDefinitionPut extends DispositionAbstractBase +{ + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // parse the request to retrieve the schedule object + DispositionSchedule schedule = parseRequestForSchedule(req); + + // parse the request to retrieve the action definition object + DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule); + + // retrieve the rest of the post body and update the action definition + JSONObject json = null; + try + { + json = new JSONObject(new JSONTokener(req.getContent().getContent())); + actionDef = updateActionDefinition(actionDef, json); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + // create model object with just the action data + Map model = new HashMap(1); + model.put("action", createActionDefModel(actionDef, req.getURL())); + return model; + } + + /** + * Updates a dispositionActionDefinition node in the repo. + * + * @param actionDef The action definition to update + * @param json The JSON to use to create the action definition + * @param schedule The DispositionSchedule the action definition belongs to + * @return The updated DispositionActionDefinition + */ + protected DispositionActionDefinition updateActionDefinition(DispositionActionDefinition actionDef, + JSONObject json) throws JSONException + { + // create the properties for the action definition + Map props = new HashMap(8); + + if (json.has("name")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME, json.getString("name")); + } + + if (json.has("description")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_DESCRIPTION, json.getString("description")); + } + + if (json.has("period")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD, json.getString("period")); + } + + if (json.has("periodProperty")) + { + QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService()); + props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty); + } + + if (json.has("eligibleOnFirstCompleteEvent")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT_COMBINATION, + json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and"); + } + + if (json.has("location")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_LOCATION, + json.getString("location")); + } + + if (json.has("events")) + { + JSONArray events = json.getJSONArray("events"); + List eventsList = new ArrayList(events.length()); + for (int x = 0; x < events.length(); x++) + { + eventsList.add(events.getString(x)); + } + props.put(RecordsManagementModel.PROP_DISPOSITION_EVENT, (Serializable)eventsList); + } + + if (json.has("name") && "destroy".equals(json.getString("name"))) + { + if (json.has("ghostOnDestroy")) + { + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "ghost"); + } + else + { + props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, "delete"); + } + } + + // update the action definition + return getDispositionService().updateDispositionActionDefinition(actionDef, props); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionLifecycleGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionLifecycleGet.java index 70dbb265d5..b0a2aa39c2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionLifecycleGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionLifecycleGet.java @@ -1,184 +1,184 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PersonService; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return full details - * about a disposition lifecycle (next disposition action). - * - * @author Gavin Cornwell - */ -public class DispositionLifecycleGet extends DispositionAbstractBase -{ - PersonService personService; - - /** - * Sets the PersonService instance - * - * @param personService The PersonService instance - */ - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // parse the request to retrieve the next action - NodeRef nodeRef = parseRequestForNodeRef(req); - - // make sure the node passed in has a next action attached - DispositionAction nextAction = getDispositionService().getNextDispositionAction(nodeRef); - if (nextAction == null) - { - Map nextActionModel = new HashMap(2); - nextActionModel.put("notFound", true); - nextActionModel.put("message", "Node " + nodeRef.toString() + " does not have a disposition lifecycle"); - Map model = new HashMap(1); - model.put("nextaction", nextActionModel); - return model; - } - else - { - // add all the next action data to Map - Map nextActionModel = new HashMap(8); - String serviceUrl = req.getServiceContextPath() + req.getPathInfo(); - nextActionModel.put("url", serviceUrl); - nextActionModel.put("name", nextAction.getName()); - nextActionModel.put("label", nextAction.getLabel()); - nextActionModel.put("eventsEligible", getDispositionService().isNextDispositionActionEligible(nodeRef)); - - if (nextAction.getAsOfDate() != null) - { - nextActionModel.put("asOf", ISO8601DateFormat.format(nextAction.getAsOfDate())); - } - - if (nextAction.getStartedAt() != null) - { - nextActionModel.put("startedAt", ISO8601DateFormat.format(nextAction.getStartedAt())); - } - - String startedBy = nextAction.getStartedBy(); - if (startedBy != null) - { - nextActionModel.put("startedBy", startedBy); - addUsersRealName(nextActionModel, startedBy, "startedBy"); - } - - if (nextAction.getCompletedAt() != null) - { - nextActionModel.put("completedAt", ISO8601DateFormat.format(nextAction.getCompletedAt())); - } - - String completedBy = nextAction.getCompletedBy(); - if (completedBy != null) - { - nextActionModel.put("completedBy", completedBy); - addUsersRealName(nextActionModel, completedBy, "completedBy"); - } - - List> events = new ArrayList>(); - for (EventCompletionDetails event : nextAction.getEventCompletionDetails()) - { - events.add(createEventModel(event)); - } - nextActionModel.put("events", events); - - // create model object with just the schedule data - Map model = new HashMap(1); - model.put("nextaction", nextActionModel); - return model; - } - } - - /** - * Helper to create a model to represent the given event execution. - * - * @param event The event to create a model for - * @return Map representing the model - */ - protected Map createEventModel(EventCompletionDetails event) - { - Map model = new HashMap(8); - - model.put("name", event.getEventName()); - model.put("label", event.getEventLabel()); - model.put("automatic", event.isEventExecutionAutomatic()); - model.put("complete", event.isEventComplete()); - - String completedBy = event.getEventCompletedBy(); - if (completedBy != null) - { - model.put("completedBy", completedBy); - addUsersRealName(model, completedBy, "completedBy"); - } - - if (event.getEventCompletedAt() != null) - { - model.put("completedAt", ISO8601DateFormat.format(event.getEventCompletedAt())); - } - - return model; - } - - /** - * Adds the given username's first and last name to the given model. - * - * @param model The model to add the first and last name to - * @param userName The username of the user to lookup - * @param propertyPrefix The prefix of the property name to use when adding to the model - */ - protected void addUsersRealName(Map model, String userName, String propertyPrefix) - { - NodeRef user = this.personService.getPerson(userName); - if (user != null) - { - String firstName = (String) getNodeService().getProperty(user, ContentModel.PROP_FIRSTNAME); - if (firstName != null) - { - model.put(propertyPrefix + "FirstName", firstName); - } - - String lastName = (String) getNodeService().getProperty(user, ContentModel.PROP_LASTNAME); - if (lastName != null) - { - model.put(propertyPrefix + "LastName", lastName); - } - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.PersonService; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return full details + * about a disposition lifecycle (next disposition action). + * + * @author Gavin Cornwell + */ +public class DispositionLifecycleGet extends DispositionAbstractBase +{ + PersonService personService; + + /** + * Sets the PersonService instance + * + * @param personService The PersonService instance + */ + public void setPersonService(PersonService personService) + { + this.personService = personService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // parse the request to retrieve the next action + NodeRef nodeRef = parseRequestForNodeRef(req); + + // make sure the node passed in has a next action attached + DispositionAction nextAction = getDispositionService().getNextDispositionAction(nodeRef); + if (nextAction == null) + { + Map nextActionModel = new HashMap(2); + nextActionModel.put("notFound", true); + nextActionModel.put("message", "Node " + nodeRef.toString() + " does not have a disposition lifecycle"); + Map model = new HashMap(1); + model.put("nextaction", nextActionModel); + return model; + } + else + { + // add all the next action data to Map + Map nextActionModel = new HashMap(8); + String serviceUrl = req.getServiceContextPath() + req.getPathInfo(); + nextActionModel.put("url", serviceUrl); + nextActionModel.put("name", nextAction.getName()); + nextActionModel.put("label", nextAction.getLabel()); + nextActionModel.put("eventsEligible", getDispositionService().isNextDispositionActionEligible(nodeRef)); + + if (nextAction.getAsOfDate() != null) + { + nextActionModel.put("asOf", ISO8601DateFormat.format(nextAction.getAsOfDate())); + } + + if (nextAction.getStartedAt() != null) + { + nextActionModel.put("startedAt", ISO8601DateFormat.format(nextAction.getStartedAt())); + } + + String startedBy = nextAction.getStartedBy(); + if (startedBy != null) + { + nextActionModel.put("startedBy", startedBy); + addUsersRealName(nextActionModel, startedBy, "startedBy"); + } + + if (nextAction.getCompletedAt() != null) + { + nextActionModel.put("completedAt", ISO8601DateFormat.format(nextAction.getCompletedAt())); + } + + String completedBy = nextAction.getCompletedBy(); + if (completedBy != null) + { + nextActionModel.put("completedBy", completedBy); + addUsersRealName(nextActionModel, completedBy, "completedBy"); + } + + List> events = new ArrayList>(); + for (EventCompletionDetails event : nextAction.getEventCompletionDetails()) + { + events.add(createEventModel(event)); + } + nextActionModel.put("events", events); + + // create model object with just the schedule data + Map model = new HashMap(1); + model.put("nextaction", nextActionModel); + return model; + } + } + + /** + * Helper to create a model to represent the given event execution. + * + * @param event The event to create a model for + * @return Map representing the model + */ + protected Map createEventModel(EventCompletionDetails event) + { + Map model = new HashMap(8); + + model.put("name", event.getEventName()); + model.put("label", event.getEventLabel()); + model.put("automatic", event.isEventExecutionAutomatic()); + model.put("complete", event.isEventComplete()); + + String completedBy = event.getEventCompletedBy(); + if (completedBy != null) + { + model.put("completedBy", completedBy); + addUsersRealName(model, completedBy, "completedBy"); + } + + if (event.getEventCompletedAt() != null) + { + model.put("completedAt", ISO8601DateFormat.format(event.getEventCompletedAt())); + } + + return model; + } + + /** + * Adds the given username's first and last name to the given model. + * + * @param model The model to add the first and last name to + * @param userName The username of the user to lookup + * @param propertyPrefix The prefix of the property name to use when adding to the model + */ + protected void addUsersRealName(Map model, String userName, String propertyPrefix) + { + NodeRef user = this.personService.getPerson(userName); + if (user != null) + { + String firstName = (String) getNodeService().getProperty(user, ContentModel.PROP_FIRSTNAME); + if (firstName != null) + { + model.put(propertyPrefix + "FirstName", firstName); + } + + String lastName = (String) getNodeService().getProperty(user, ContentModel.PROP_LASTNAME); + if (lastName != null) + { + model.put(propertyPrefix + "LastName", lastName); + } + } + } } \ No newline at end of file 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 21a4a9d1ac..1b72568c6f 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 @@ -1,118 +1,118 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -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; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.util.StringUtils; - -/** - * @author Roy Wetherall - */ -public class DispositionPropertiesGet extends DeclarativeWebScript -{ - protected DispositionService dispositionService; - protected NamespaceService namespaceService; - protected DictionaryService dictionaryService; - - /** - * Sets the disposition service - * - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Sets the NamespaceService instance - * - * @param namespaceService The NamespaceService instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Sets the DictionaryService instance - * - * @param dictionaryService The DictionaryService instance - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - boolean recordLevel = false; - String recordLevelValue = req.getParameter("recordlevel"); - if (recordLevelValue != null) - { - recordLevel = Boolean.valueOf(recordLevelValue); - } - String dispositionAction = req.getParameter("dispositionaction"); - - Collection dispositionProperties = dispositionService.getDispositionProperties(recordLevel, dispositionAction); - List> items = new ArrayList>(dispositionProperties.size()); - for (DispositionProperty dispositionProperty : dispositionProperties) - { - PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); - QName propName = dispositionProperty.getQName(); - - if (propDef != null) - { - Map item = new HashMap(2); - String propTitle = propDef.getTitle(dictionaryService); - if (propTitle == null || propTitle.length() == 0) - { - propTitle = StringUtils.capitalize(propName.getLocalName()); - } - item.put("label", propTitle); - item.put("value", propName.toPrefixString(this.namespaceService)); - items.add(item); - } - } - - // create model object with the lists model - Map model = new HashMap(1); - model.put("properties", items); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +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; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.util.StringUtils; + +/** + * @author Roy Wetherall + */ +public class DispositionPropertiesGet extends DeclarativeWebScript +{ + protected DispositionService dispositionService; + protected NamespaceService namespaceService; + protected DictionaryService dictionaryService; + + /** + * Sets the disposition service + * + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Sets the NamespaceService instance + * + * @param namespaceService The NamespaceService instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Sets the DictionaryService instance + * + * @param dictionaryService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + boolean recordLevel = false; + String recordLevelValue = req.getParameter("recordlevel"); + if (recordLevelValue != null) + { + recordLevel = Boolean.valueOf(recordLevelValue); + } + String dispositionAction = req.getParameter("dispositionaction"); + + Collection dispositionProperties = dispositionService.getDispositionProperties(recordLevel, dispositionAction); + List> items = new ArrayList>(dispositionProperties.size()); + for (DispositionProperty dispositionProperty : dispositionProperties) + { + PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); + QName propName = dispositionProperty.getQName(); + + if (propDef != null) + { + Map item = new HashMap(2); + String propTitle = propDef.getTitle(dictionaryService); + if (propTitle == null || propTitle.length() == 0) + { + propTitle = StringUtils.capitalize(propName.getLocalName()); + } + item.put("label", propTitle); + item.put("value", propName.toPrefixString(this.namespaceService)); + items.add(item); + } + } + + // create model object with the lists model + Map model = new HashMap(1); + model.put("properties", items); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionScheduleGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionScheduleGet.java index 0a8ad9075e..bf45e993e3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionScheduleGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionScheduleGet.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.Map; - -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return full details - * about a disposition schedule. - * - * @author Gavin Cornwell - */ -public class DispositionScheduleGet extends DispositionAbstractBase -{ - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // return the disposition schedule model - return getDispositionScheduleModel(req); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.Map; + +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return full details + * about a disposition schedule. + * + * @author Gavin Cornwell + */ +public class DispositionScheduleGet extends DispositionAbstractBase +{ + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // return the disposition schedule model + return getDispositionScheduleModel(req); + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DodCustomTypesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DodCustomTypesGet.java index da9c66ea21..0bcb193da6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DodCustomTypesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DodCustomTypesGet.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This class provides the implementation for the dodcustomtypes.get webscript. - * - * @author Neil McErlean - */ -public class DodCustomTypesGet extends DeclarativeWebScript -{ - // TODO Investigate a way of not hard-coding the 4 custom types here. - private static final List CUSTOM_TYPE_ASPECTS = Arrays.asList(new QName[]{DOD5015Model.ASPECT_SCANNED_RECORD, - DOD5015Model.ASPECT_PDF_RECORD, DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD, DOD5015Model.ASPECT_WEB_RECORD}); - - private DictionaryService dictionaryService; - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - List customTypeAspectDefinitions = new ArrayList(4); - for (QName aspectQName : CUSTOM_TYPE_ASPECTS) - { - AspectDefinition nextAspectDef = dictionaryService.getAspect(aspectQName); - customTypeAspectDefinitions.add(nextAspectDef); - } - model.put("dodCustomTypes", customTypeAspectDefinitions); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * This class provides the implementation for the dodcustomtypes.get webscript. + * + * @author Neil McErlean + */ +public class DodCustomTypesGet extends DeclarativeWebScript +{ + // TODO Investigate a way of not hard-coding the 4 custom types here. + private static final List CUSTOM_TYPE_ASPECTS = Arrays.asList(new QName[]{DOD5015Model.ASPECT_SCANNED_RECORD, + DOD5015Model.ASPECT_PDF_RECORD, DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD, DOD5015Model.ASPECT_WEB_RECORD}); + + private DictionaryService dictionaryService; + + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + List customTypeAspectDefinitions = new ArrayList(4); + for (QName aspectQName : CUSTOM_TYPE_ASPECTS) + { + AspectDefinition nextAspectDef = dictionaryService.getAspect(aspectQName); + customTypeAspectDefinitions.add(nextAspectDef); + } + model.put("dodCustomTypes", customTypeAspectDefinitions); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapDelete.java index ed92b30ef1..d9ccf067b7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapDelete.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; -import org.json.JSONException; -import org.json.JSONObject; -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; - -/** - * Implementation for Java backed webscript to return - * custom email field mappings - */ -public class EmailMapDelete extends DeclarativeWebScript -{ - /** Custom email mapping service */ - private CustomEmailMappingService customEmailMappingService; - - /** - * Custom email mapping service - * - * @param customEmailMappingService the custom email mapping service - */ - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - try - { - // Get the data from the request - JSONObject json = new JSONObject(req.getServiceMatch().getTemplateVars()); - - // Delete custom mapping - customEmailMappingService.deleteCustomMapping(json.getString("from"), json.getString("to")); - - // Create model object with the lists of custom mappings - Map model = new HashMap(1); - model.put("emailmap", customEmailMappingService.getCustomMappings()); - - return model; - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.json.JSONException; +import org.json.JSONObject; +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; + +/** + * Implementation for Java backed webscript to return + * custom email field mappings + */ +public class EmailMapDelete extends DeclarativeWebScript +{ + /** Custom email mapping service */ + private CustomEmailMappingService customEmailMappingService; + + /** + * Custom email mapping service + * + * @param customEmailMappingService the custom email mapping service + */ + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + try + { + // Get the data from the request + JSONObject json = new JSONObject(req.getServiceMatch().getTemplateVars()); + + // Delete custom mapping + customEmailMappingService.deleteCustomMapping(json.getString("from"), json.getString("to")); + + // Create model object with the lists of custom mappings + Map model = new HashMap(1); + model.put("emailmap", customEmailMappingService.getCustomMappings()); + + return model; + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapGet.java index b99a810855..c24f40fe86 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapGet.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return - * custom email field mappings - */ -public class EmailMapGet extends DeclarativeWebScript -{ - /** Custom email mapping service */ - private CustomEmailMappingService customEmailMappingService; - - /** - * Custom email mapping service - * - * @param customEmailMappingService the custom email mapping service - */ - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Create model object with the lists of custom mappings - Map model = new HashMap(1); - model.put("emailmap", customEmailMappingService.getCustomMappings()); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return + * custom email field mappings + */ +public class EmailMapGet extends DeclarativeWebScript +{ + /** Custom email mapping service */ + private CustomEmailMappingService customEmailMappingService; + + /** + * Custom email mapping service + * + * @param customEmailMappingService the custom email mapping service + */ + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Create model object with the lists of custom mappings + Map model = new HashMap(1); + model.put("emailmap", customEmailMappingService.getCustomMappings()); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapKeysGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapKeysGet.java index 64a8ede546..779e199e5a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapKeysGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapKeysGet.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return email mapping keys - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class EmailMapKeysGet extends DeclarativeWebScript -{ - /** Custom email mapping service */ - private CustomEmailMappingService customEmailMappingService; - - /** - * Custom email mapping service - * - * @param customEmailMappingService the custom email mapping service - */ - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Create model object with the lists of email mapping keys - Map model = new HashMap(1); - model.put("emailmapkeys", customEmailMappingService.getEmailMappingKeys()); - return model; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return email mapping keys + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class EmailMapKeysGet extends DeclarativeWebScript +{ + /** Custom email mapping service */ + private CustomEmailMappingService customEmailMappingService; + + /** + * Custom email mapping service + * + * @param customEmailMappingService the custom email mapping service + */ + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Create model object with the lists of email mapping keys + Map model = new HashMap(1); + model.put("emailmapkeys", customEmailMappingService.getEmailMappingKeys()); + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapPost.java index 4692ccb4bc..56c66fbf67 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/EmailMapPost.java @@ -1,91 +1,91 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -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.email.CustomEmailMappingService; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -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; - -/** - * Implementation for Java backed webscript to return - * custom email field mappings - */ -public class EmailMapPost extends DeclarativeWebScript -{ - /** Custom email mapping service */ - private CustomEmailMappingService customEmailMappingService; - - /** - * Custom email mapping service - * - * @param customEmailMappingService the custom email mapping service - */ - public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) - { - this.customEmailMappingService = customEmailMappingService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - try - { - // Get the data from the content - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - - // Add custom mapping - customEmailMappingService.addCustomMapping(json.getString("from"), json.getString("to")); - - // Add the lists of custom mappings to the model - model.put("emailmap", customEmailMappingService.getCustomMappings()); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - catch (AlfrescoRuntimeException are) - { - throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, - are.getMessage(), are); - } - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +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.email.CustomEmailMappingService; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +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; + +/** + * Implementation for Java backed webscript to return + * custom email field mappings + */ +public class EmailMapPost extends DeclarativeWebScript +{ + /** Custom email mapping service */ + private CustomEmailMappingService customEmailMappingService; + + /** + * Custom email mapping service + * + * @param customEmailMappingService the custom email mapping service + */ + public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) + { + this.customEmailMappingService = customEmailMappingService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + try + { + // Get the data from the content + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + + // Add custom mapping + customEmailMappingService.addCustomMapping(json.getString("from"), json.getString("to")); + + // Add the lists of custom mappings to the model + model.put("emailmap", customEmailMappingService.getCustomMappings()); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + catch (AlfrescoRuntimeException are) + { + throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, + are.getMessage(), are); + } + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ExportPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ExportPost.java index c27980b4f9..504088590a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ExportPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ExportPost.java @@ -1,176 +1,176 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.repo.exporter.ACPExportPackageHandler; -import org.alfresco.repo.web.scripts.content.ContentStreamer; -import org.alfresco.repo.web.scripts.content.StreamACP; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.view.ExporterCrawlerParameters; -import org.alfresco.service.cmr.view.Location; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Creates an RM specific ACP file of nodes to export then streams it back - * to the client. - * - * @author Gavin Cornwell - */ -public class ExportPost extends StreamACP -{ - /** Logger */ - private static Log logger = LogFactory.getLog(ExportPost.class); - - protected static final String PARAM_TRANSFER_FORMAT = "transferFormat"; - - /** Content Streamer */ - private ContentStreamer contentStreamer; - - /** - * @param contentStreamer - */ - public void setContentStreamer(ContentStreamer contentStreamer) - { - this.contentStreamer = contentStreamer; - } - - /** - * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) - */ - @SuppressWarnings("deprecation") - @Override - public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - File tempACPFile = null; - try - { - NodeRef[] nodeRefs = null; - boolean transferFormat = false; - String contentType = req.getContentType(); - if (MULTIPART_FORMDATA.equals(contentType)) - { - // get nodeRefs parameter from form - nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS)); - - // look for the transfer format - String transferFormatParam = req.getParameter(PARAM_TRANSFER_FORMAT); - if (transferFormatParam != null && transferFormatParam.length() > 0) - { - transferFormat = Boolean.parseBoolean(transferFormatParam); - } - } - else - { - // presume the request is a JSON request so get nodeRefs from JSON body - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - nodeRefs = getNodeRefs(json); - - if (json.has(PARAM_TRANSFER_FORMAT)) - { - transferFormat = json.getBoolean(PARAM_TRANSFER_FORMAT); - } - } - - // setup the ACP parameters - ExporterCrawlerParameters params = new ExporterCrawlerParameters(); - params.setCrawlSelf(true); - params.setCrawlChildNodes(true); - params.setExportFrom(new Location(nodeRefs)); - - // if transfer format has been requested we need to exclude certain aspects - if (transferFormat) - { - // restrict specific aspects from being returned - QName[] excludedAspects = new QName[] { - RenditionModel.ASPECT_RENDITIONED, - ContentModel.ASPECT_THUMBNAILED, - RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, - RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH, - RecordsManagementModel.ASPECT_EXTENDED_SECURITY}; - params.setExcludeAspects(excludedAspects); - } - else - { - // restrict specific aspects from being returned - QName[] excludedAspects = new QName[] {RecordsManagementModel.ASPECT_EXTENDED_SECURITY}; - params.setExcludeAspects(excludedAspects); - } - - // create an ACP of the nodes - tempACPFile = createACP(params, - transferFormat ? ZIP_EXTENSION : ACPExportPackageHandler.ACP_EXTENSION, - transferFormat); - - // stream the ACP back to the client as an attachment (forcing save as) - contentStreamer.streamContent(req, res, tempACPFile, null, true, tempACPFile.getName(), null); - } - catch (IOException ioe) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", ioe); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - catch(Throwable e) - { - if (logger.isDebugEnabled()) - { - StringWriter stack = new StringWriter(); - e.printStackTrace(new PrintWriter(stack)); - logger.debug("Caught exception; decorating with appropriate status template : " + stack.toString()); - } - - throw createStatusException(e, req, res); - } - finally - { - // try and delete the temporary file - if (tempACPFile != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath()); - } - - tempACPFile.delete(); - } - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.alfresco.model.ContentModel; +import org.alfresco.model.RenditionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.repo.exporter.ACPExportPackageHandler; +import org.alfresco.repo.web.scripts.content.ContentStreamer; +import org.alfresco.repo.web.scripts.content.StreamACP; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.view.ExporterCrawlerParameters; +import org.alfresco.service.cmr.view.Location; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Creates an RM specific ACP file of nodes to export then streams it back + * to the client. + * + * @author Gavin Cornwell + */ +public class ExportPost extends StreamACP +{ + /** Logger */ + private static Log logger = LogFactory.getLog(ExportPost.class); + + protected static final String PARAM_TRANSFER_FORMAT = "transferFormat"; + + /** Content Streamer */ + private ContentStreamer contentStreamer; + + /** + * @param contentStreamer + */ + public void setContentStreamer(ContentStreamer contentStreamer) + { + this.contentStreamer = contentStreamer; + } + + /** + * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) + */ + @SuppressWarnings("deprecation") + @Override + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + File tempACPFile = null; + try + { + NodeRef[] nodeRefs = null; + boolean transferFormat = false; + String contentType = req.getContentType(); + if (MULTIPART_FORMDATA.equals(contentType)) + { + // get nodeRefs parameter from form + nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS)); + + // look for the transfer format + String transferFormatParam = req.getParameter(PARAM_TRANSFER_FORMAT); + if (transferFormatParam != null && transferFormatParam.length() > 0) + { + transferFormat = Boolean.parseBoolean(transferFormatParam); + } + } + else + { + // presume the request is a JSON request so get nodeRefs from JSON body + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + nodeRefs = getNodeRefs(json); + + if (json.has(PARAM_TRANSFER_FORMAT)) + { + transferFormat = json.getBoolean(PARAM_TRANSFER_FORMAT); + } + } + + // setup the ACP parameters + ExporterCrawlerParameters params = new ExporterCrawlerParameters(); + params.setCrawlSelf(true); + params.setCrawlChildNodes(true); + params.setExportFrom(new Location(nodeRefs)); + + // if transfer format has been requested we need to exclude certain aspects + if (transferFormat) + { + // restrict specific aspects from being returned + QName[] excludedAspects = new QName[] { + RenditionModel.ASPECT_RENDITIONED, + ContentModel.ASPECT_THUMBNAILED, + RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, + RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH, + RecordsManagementModel.ASPECT_EXTENDED_SECURITY}; + params.setExcludeAspects(excludedAspects); + } + else + { + // restrict specific aspects from being returned + QName[] excludedAspects = new QName[] {RecordsManagementModel.ASPECT_EXTENDED_SECURITY}; + params.setExcludeAspects(excludedAspects); + } + + // create an ACP of the nodes + tempACPFile = createACP(params, + transferFormat ? ZIP_EXTENSION : ACPExportPackageHandler.ACP_EXTENSION, + transferFormat); + + // stream the ACP back to the client as an attachment (forcing save as) + contentStreamer.streamContent(req, res, tempACPFile, null, true, tempACPFile.getName(), null); + } + catch (IOException ioe) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", ioe); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + catch(Throwable e) + { + if (logger.isDebugEnabled()) + { + StringWriter stack = new StringWriter(); + e.printStackTrace(new PrintWriter(stack)); + logger.debug("Caught exception; decorating with appropriate status template : " + stack.toString()); + } + + throw createStatusException(e, req, res); + } + finally + { + // try and delete the temporary file + if (tempACPFile != null) + { + if (logger.isDebugEnabled()) + { + logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath()); + } + + tempACPFile.delete(); + } + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java index 3a431814fd..f2da2e74bc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java @@ -1,256 +1,256 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.repo.exporter.ACPExportPackageHandler; -import org.alfresco.repo.importer.ACPImportPackageHandler; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.view.ImporterService; -import org.alfresco.service.cmr.view.Location; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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.springframework.extensions.webscripts.WrappingWebScriptRequest; -import org.springframework.extensions.webscripts.servlet.FormData.FormField; -import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; -import org.springframework.util.FileCopyUtils; - -/** - * Imports an ACP file into a records management container. - * - * @author Gavin Cornwell - */ -public class ImportPost extends DeclarativeWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(ImportPost.class); - - protected static final String MULTIPART_FORMDATA = "multipart/form-data"; - protected static final String PARAM_DESTINATION = "destination"; - protected static final String PARAM_ARCHIVE = "archive"; - protected static final String PARAM_FILEDATA = "filedata"; - protected static final String TEMP_FILE_PREFIX = "import_"; - - protected NodeService nodeService; - protected DictionaryService dictionaryService; - protected ImporterService importerService; - protected FilePlanRoleService filePlanRoleService; - protected FilePlanService filePlanService; - - /** - * @param nodeService - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Sets the data dictionary service - * - * @param dictionaryService The DictionaryService instance - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Sets the ImporterService to use - * - * @param importerService The ImporterService - */ - public void setImporterService(ImporterService importerService) - { - this.importerService = importerService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Unwrap to a WebScriptServletRequest if we have one - WebScriptServletRequest webScriptServletRequest = null; - WebScriptRequest current = req; - do - { - if (current instanceof WebScriptServletRequest) - { - webScriptServletRequest = (WebScriptServletRequest) current; - current = null; - } - else if (current instanceof WrappingWebScriptRequest) - { - current = ((WrappingWebScriptRequest) req).getNext(); - } - else - { - current = null; - } - } - while (current != null); - - // get the content type of request and ensure it's multipart/form-data - String contentType = req.getContentType(); - if (MULTIPART_FORMDATA.equals(contentType) && webScriptServletRequest != null) - { - String nodeRef = req.getParameter(PARAM_DESTINATION); - - if (nodeRef == null || nodeRef.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'destination' parameter was not provided in form data"); - } - - // create and check noderef - final NodeRef destination = new NodeRef(nodeRef); - if (nodeService.exists(destination)) - { - // check the destination is an RM container - if (!nodeService.hasAspect(destination, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) || - !dictionaryService.isSubClass(nodeService.getType(destination), ContentModel.TYPE_FOLDER)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "NodeRef '" + destination + "' does not represent an Records Management container node."); - } - } - else - { - status.setCode(HttpServletResponse.SC_NOT_FOUND, - "NodeRef '" + destination + "' does not exist."); - } - - // as there is no 'import capability' and the RM admin user is different from - // the DM admin user (meaning the webscript 'admin' authentication can't be used) - // perform a manual check here to ensure the current user has the RM admin role. - boolean isAdmin = filePlanRoleService.hasRMAdminRole( - filePlanService.getFilePlan(destination), - AuthenticationUtil.getRunAsUser()); - if (!isAdmin) - { - throw new WebScriptException(Status.STATUS_FORBIDDEN, "Access Denied"); - } - - File acpFile = null; - try - { - // create a temporary file representing uploaded ACP file - FormField acpContent = webScriptServletRequest.getFileField(PARAM_ARCHIVE); - if (acpContent == null) - { - acpContent = webScriptServletRequest.getFileField(PARAM_FILEDATA); - if (acpContent == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'archive' file content was not provided in form data"); - } - } - - acpFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, "." + ACPExportPackageHandler.ACP_EXTENSION); - - // copy contents of uploaded file to temp ACP file - FileOutputStream fos = new FileOutputStream(acpFile); - // NOTE: this method closes both streams - FileCopyUtils.copy(acpContent.getInputStream(), fos); - - if (logger.isDebugEnabled()) - { - logger.debug("Importing uploaded ACP (" + acpFile.getAbsolutePath() + ") into " + nodeRef); - } - - // setup the import handler - final ACPImportPackageHandler importHandler = new ACPImportPackageHandler(acpFile, "UTF-8"); - - // import the ACP file as the system user - AuthenticationUtil.runAs(new RunAsWork() - { - public NodeRef doWork() - { - importerService.importView(importHandler, new Location(destination), null, null); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - // create and return model - Map model = new HashMap(1); - model.put("success", true); - return model; - } - catch (FileNotFoundException fnfe) - { - throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, - "Failed to import ACP file", fnfe); - } - catch (IOException ioe) - { - throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, - "Failed to import ACP file", ioe); - } - finally - { - if (acpFile != null) - { - acpFile.delete(); - } - } - } - else - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Request is not " + MULTIPART_FORMDATA + " encoded"); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.repo.exporter.ACPExportPackageHandler; +import org.alfresco.repo.importer.ACPImportPackageHandler; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.view.ImporterService; +import org.alfresco.service.cmr.view.Location; +import org.alfresco.util.TempFileProvider; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.springframework.extensions.webscripts.WrappingWebScriptRequest; +import org.springframework.extensions.webscripts.servlet.FormData.FormField; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; +import org.springframework.util.FileCopyUtils; + +/** + * Imports an ACP file into a records management container. + * + * @author Gavin Cornwell + */ +public class ImportPost extends DeclarativeWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(ImportPost.class); + + protected static final String MULTIPART_FORMDATA = "multipart/form-data"; + protected static final String PARAM_DESTINATION = "destination"; + protected static final String PARAM_ARCHIVE = "archive"; + protected static final String PARAM_FILEDATA = "filedata"; + protected static final String TEMP_FILE_PREFIX = "import_"; + + protected NodeService nodeService; + protected DictionaryService dictionaryService; + protected ImporterService importerService; + protected FilePlanRoleService filePlanRoleService; + protected FilePlanService filePlanService; + + /** + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Sets the data dictionary service + * + * @param dictionaryService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Sets the ImporterService to use + * + * @param importerService The ImporterService + */ + public void setImporterService(ImporterService importerService) + { + this.importerService = importerService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Unwrap to a WebScriptServletRequest if we have one + WebScriptServletRequest webScriptServletRequest = null; + WebScriptRequest current = req; + do + { + if (current instanceof WebScriptServletRequest) + { + webScriptServletRequest = (WebScriptServletRequest) current; + current = null; + } + else if (current instanceof WrappingWebScriptRequest) + { + current = ((WrappingWebScriptRequest) req).getNext(); + } + else + { + current = null; + } + } + while (current != null); + + // get the content type of request and ensure it's multipart/form-data + String contentType = req.getContentType(); + if (MULTIPART_FORMDATA.equals(contentType) && webScriptServletRequest != null) + { + String nodeRef = req.getParameter(PARAM_DESTINATION); + + if (nodeRef == null || nodeRef.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'destination' parameter was not provided in form data"); + } + + // create and check noderef + final NodeRef destination = new NodeRef(nodeRef); + if (nodeService.exists(destination)) + { + // check the destination is an RM container + if (!nodeService.hasAspect(destination, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) || + !dictionaryService.isSubClass(nodeService.getType(destination), ContentModel.TYPE_FOLDER)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "NodeRef '" + destination + "' does not represent an Records Management container node."); + } + } + else + { + status.setCode(HttpServletResponse.SC_NOT_FOUND, + "NodeRef '" + destination + "' does not exist."); + } + + // as there is no 'import capability' and the RM admin user is different from + // the DM admin user (meaning the webscript 'admin' authentication can't be used) + // perform a manual check here to ensure the current user has the RM admin role. + boolean isAdmin = filePlanRoleService.hasRMAdminRole( + filePlanService.getFilePlan(destination), + AuthenticationUtil.getRunAsUser()); + if (!isAdmin) + { + throw new WebScriptException(Status.STATUS_FORBIDDEN, "Access Denied"); + } + + File acpFile = null; + try + { + // create a temporary file representing uploaded ACP file + FormField acpContent = webScriptServletRequest.getFileField(PARAM_ARCHIVE); + if (acpContent == null) + { + acpContent = webScriptServletRequest.getFileField(PARAM_FILEDATA); + if (acpContent == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'archive' file content was not provided in form data"); + } + } + + acpFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, "." + ACPExportPackageHandler.ACP_EXTENSION); + + // copy contents of uploaded file to temp ACP file + FileOutputStream fos = new FileOutputStream(acpFile); + // NOTE: this method closes both streams + FileCopyUtils.copy(acpContent.getInputStream(), fos); + + if (logger.isDebugEnabled()) + { + logger.debug("Importing uploaded ACP (" + acpFile.getAbsolutePath() + ") into " + nodeRef); + } + + // setup the import handler + final ACPImportPackageHandler importHandler = new ACPImportPackageHandler(acpFile, "UTF-8"); + + // import the ACP file as the system user + AuthenticationUtil.runAs(new RunAsWork() + { + public NodeRef doWork() + { + importerService.importView(importHandler, new Location(destination), null, null); + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + // create and return model + Map model = new HashMap(1); + model.put("success", true); + return model; + } + catch (FileNotFoundException fnfe) + { + throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, + "Failed to import ACP file", fnfe); + } + catch (IOException ioe) + { + throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, + "Failed to import ACP file", ioe); + } + finally + { + if (acpFile != null) + { + acpFile.delete(); + } + } + } + else + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Request is not " + MULTIPART_FORMDATA + " encoded"); + } + } } \ No newline at end of file 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 47ec7cba37..9ebaaaa849 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 @@ -1,295 +1,295 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.cmr.repository.PeriodProvider; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.util.StringUtils; - -/** - * Implementation for Java backed webscript to return lists - * of values for various records management services. - * - * @author Gavin Cornwell - */ -public class ListOfValuesGet extends DeclarativeWebScript -{ - protected RecordsManagementActionService rmActionService; - protected RecordsManagementAuditService rmAuditService; - protected RecordsManagementEventService rmEventService; - protected DispositionService dispositionService; - protected DictionaryService ddService; - protected NamespaceService namespaceService; - - /** - * Sets the RecordsManagementActionService instance - * - * @param rmActionService The RecordsManagementActionService instance - */ - public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) - { - this.rmActionService = rmActionService; - } - - /** - * Sets the RecordsManagementAuditService instance - * - * @param rmAuditService The RecordsManagementAuditService instance - */ - public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) - { - this.rmAuditService = rmAuditService; - } - - /** - * Sets the RecordsManagementEventService instance - * - * @param rmEventService The RecordsManagementEventService instance - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - this.rmEventService = rmEventService; - } - - /** - * Sets the disposition service - * - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * Sets the DictionaryService instance - * - * @param ddService The DictionaryService instance - */ - public void setDictionaryService(DictionaryService ddService) - { - this.ddService = ddService; - } - - /** - * Sets the NamespaceService instance - * - * @param namespaceService The NamespaceService instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // add all the lists data to a Map - Map listsModel = new HashMap(4); - String requestUrl = req.getURL(); - listsModel.put("dispositionActions", createDispositionActionsModel(requestUrl)); - listsModel.put("events", createEventsModel(requestUrl)); - listsModel.put("periodTypes", createPeriodTypesModel(requestUrl)); - listsModel.put("periodProperties", createPeriodPropertiesModel(requestUrl)); - listsModel.put("auditEvents", createAuditEventsModel(requestUrl)); - - // create model object with the lists model - Map model = new HashMap(1); - model.put("lists", listsModel); - return model; - } - - /** - * Creates the model for the list of disposition actions. - * - * @param baseUrl The base URL of the service - * @return model of disposition actions list - */ - protected Map createDispositionActionsModel(String baseUrl) - { - // iterate over the disposition actions - List dispositionActions = this.rmActionService.getDispositionActions(); - List> items = new ArrayList>(dispositionActions.size()); - for (RecordsManagementAction dispositionAction : dispositionActions) - { - Map item = new HashMap(2); - item.put("label", dispositionAction.getLabel()); - item.put("value", dispositionAction.getName()); - items.add(item); - } - - // create the model - Map model = new HashMap(2); - model.put("url", baseUrl + "/dispositionactions"); - model.put("items", items); - - return model; - } - - /** - * Creates the model for the list of events. - * - * @param baseUrl The base URL of the service - * @return model of events list - */ - protected Map createEventsModel(String baseUrl) - { - // get all the events including their display labels from the event service - List events = this.rmEventService.getEvents(); - List> items = new ArrayList>(events.size()); - for (RecordsManagementEvent event : events) - { - Map item = new HashMap(3); - item.put("label", event.getDisplayLabel()); - item.put("value", event.getName()); - item.put("automatic", - this.rmEventService.getEventType(event.getType()).isAutomaticEvent()); - items.add(item); - } - - // create the model - Map model = new HashMap(2); - model.put("url", baseUrl + "/events"); - model.put("items", items); - - return model; - } - - /** - * Creates the model for the list of period types. - * - * @param baseUrl The base URL of the service - * @return model of period types list - */ - protected Map createPeriodTypesModel(String baseUrl) - { - // iterate over all period provides, but ignore 'cron' - Set providers = Period.getProviderNames(); - List> items = new ArrayList>(providers.size()); - for (String provider : providers) - { - PeriodProvider pp = Period.getProvider(provider); - if (!pp.getPeriodType().equals("cron")) - { - Map item = new HashMap(2); - item.put("label", pp.getDisplayLabel()); - item.put("value", pp.getPeriodType()); - items.add(item); - } - } - - // create the model - Map model = new HashMap(2); - model.put("url", baseUrl + "/periodtypes"); - model.put("items", items); - - return model; - } - - /** - * Creates the model for the list of period properties. - * - * @param baseUrl The base URL of the service - * @return model of period properties list - */ - protected Map createPeriodPropertiesModel(String baseUrl) - { - // iterate over all period properties and get the label from their type definition - Collection dispositionProperties = dispositionService.getDispositionProperties(); - List> items = new ArrayList>(dispositionProperties.size()); - for (DispositionProperty dispositionProperty : dispositionProperties) - { - PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); - QName propName = dispositionProperty.getQName(); - - if (propDef != null) - { - Map item = new HashMap(2); - String propTitle = propDef.getTitle(ddService); - if (propTitle == null || propTitle.length() == 0) - { - propTitle = StringUtils.capitalize(propName.getLocalName()); - } - item.put("label", propTitle); - item.put("value", propName.toPrefixString(this.namespaceService)); - items.add(item); - } - } - - // create the model - Map model = new HashMap(2); - model.put("url", baseUrl + "/periodproperties"); - model.put("items", items); - - return model; - } - - /** - * Creates the model for the list of audit events. - * - * @param baseUrl The base URL of the service - * @return model of audit events list - */ - protected Map createAuditEventsModel(String baseUrl) - { - // iterate over all audit events - List auditEvents = this.rmAuditService.getAuditEvents(); - List> items = new ArrayList>(auditEvents.size()); - for (AuditEvent event : auditEvents) - { - Map item = new HashMap(2); - item.put("label", event.getLabel()); - item.put("value", event.getName()); - items.add(item); - } - - // create the model - Map model = new HashMap(2); - model.put("url", baseUrl + "/auditevents"); - model.put("items", items); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.cmr.repository.PeriodProvider; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.util.StringUtils; + +/** + * Implementation for Java backed webscript to return lists + * of values for various records management services. + * + * @author Gavin Cornwell + */ +public class ListOfValuesGet extends DeclarativeWebScript +{ + protected RecordsManagementActionService rmActionService; + protected RecordsManagementAuditService rmAuditService; + protected RecordsManagementEventService rmEventService; + protected DispositionService dispositionService; + protected DictionaryService ddService; + protected NamespaceService namespaceService; + + /** + * Sets the RecordsManagementActionService instance + * + * @param rmActionService The RecordsManagementActionService instance + */ + public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) + { + this.rmActionService = rmActionService; + } + + /** + * Sets the RecordsManagementAuditService instance + * + * @param rmAuditService The RecordsManagementAuditService instance + */ + public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) + { + this.rmAuditService = rmAuditService; + } + + /** + * Sets the RecordsManagementEventService instance + * + * @param rmEventService The RecordsManagementEventService instance + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + this.rmEventService = rmEventService; + } + + /** + * Sets the disposition service + * + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * Sets the DictionaryService instance + * + * @param ddService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService ddService) + { + this.ddService = ddService; + } + + /** + * Sets the NamespaceService instance + * + * @param namespaceService The NamespaceService instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // add all the lists data to a Map + Map listsModel = new HashMap(4); + String requestUrl = req.getURL(); + listsModel.put("dispositionActions", createDispositionActionsModel(requestUrl)); + listsModel.put("events", createEventsModel(requestUrl)); + listsModel.put("periodTypes", createPeriodTypesModel(requestUrl)); + listsModel.put("periodProperties", createPeriodPropertiesModel(requestUrl)); + listsModel.put("auditEvents", createAuditEventsModel(requestUrl)); + + // create model object with the lists model + Map model = new HashMap(1); + model.put("lists", listsModel); + return model; + } + + /** + * Creates the model for the list of disposition actions. + * + * @param baseUrl The base URL of the service + * @return model of disposition actions list + */ + protected Map createDispositionActionsModel(String baseUrl) + { + // iterate over the disposition actions + List dispositionActions = this.rmActionService.getDispositionActions(); + List> items = new ArrayList>(dispositionActions.size()); + for (RecordsManagementAction dispositionAction : dispositionActions) + { + Map item = new HashMap(2); + item.put("label", dispositionAction.getLabel()); + item.put("value", dispositionAction.getName()); + items.add(item); + } + + // create the model + Map model = new HashMap(2); + model.put("url", baseUrl + "/dispositionactions"); + model.put("items", items); + + return model; + } + + /** + * Creates the model for the list of events. + * + * @param baseUrl The base URL of the service + * @return model of events list + */ + protected Map createEventsModel(String baseUrl) + { + // get all the events including their display labels from the event service + List events = this.rmEventService.getEvents(); + List> items = new ArrayList>(events.size()); + for (RecordsManagementEvent event : events) + { + Map item = new HashMap(3); + item.put("label", event.getDisplayLabel()); + item.put("value", event.getName()); + item.put("automatic", + this.rmEventService.getEventType(event.getType()).isAutomaticEvent()); + items.add(item); + } + + // create the model + Map model = new HashMap(2); + model.put("url", baseUrl + "/events"); + model.put("items", items); + + return model; + } + + /** + * Creates the model for the list of period types. + * + * @param baseUrl The base URL of the service + * @return model of period types list + */ + protected Map createPeriodTypesModel(String baseUrl) + { + // iterate over all period provides, but ignore 'cron' + Set providers = Period.getProviderNames(); + List> items = new ArrayList>(providers.size()); + for (String provider : providers) + { + PeriodProvider pp = Period.getProvider(provider); + if (!pp.getPeriodType().equals("cron")) + { + Map item = new HashMap(2); + item.put("label", pp.getDisplayLabel()); + item.put("value", pp.getPeriodType()); + items.add(item); + } + } + + // create the model + Map model = new HashMap(2); + model.put("url", baseUrl + "/periodtypes"); + model.put("items", items); + + return model; + } + + /** + * Creates the model for the list of period properties. + * + * @param baseUrl The base URL of the service + * @return model of period properties list + */ + protected Map createPeriodPropertiesModel(String baseUrl) + { + // iterate over all period properties and get the label from their type definition + Collection dispositionProperties = dispositionService.getDispositionProperties(); + List> items = new ArrayList>(dispositionProperties.size()); + for (DispositionProperty dispositionProperty : dispositionProperties) + { + PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); + QName propName = dispositionProperty.getQName(); + + if (propDef != null) + { + Map item = new HashMap(2); + String propTitle = propDef.getTitle(ddService); + if (propTitle == null || propTitle.length() == 0) + { + propTitle = StringUtils.capitalize(propName.getLocalName()); + } + item.put("label", propTitle); + item.put("value", propName.toPrefixString(this.namespaceService)); + items.add(item); + } + } + + // create the model + Map model = new HashMap(2); + model.put("url", baseUrl + "/periodproperties"); + model.put("items", items); + + return model; + } + + /** + * Creates the model for the list of audit events. + * + * @param baseUrl The base URL of the service + * @return model of audit events list + */ + protected Map createAuditEventsModel(String baseUrl) + { + // iterate over all audit events + List auditEvents = this.rmAuditService.getAuditEvents(); + List> items = new ArrayList>(auditEvents.size()); + for (AuditEvent event : auditEvents) + { + Map item = new HashMap(2); + item.put("label", event.getLabel()); + item.put("value", event.getName()); + items.add(item); + } + + // create the model + Map model = new HashMap(2); + model.put("url", baseUrl + "/auditevents"); + model.put("items", items); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RMConstraintGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RMConstraintGet.java index cd8592261b..88c5ea75c5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RMConstraintGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RMConstraintGet.java @@ -1,70 +1,70 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return - * the values for an RM constraint. - */ -public class RMConstraintGet extends DeclarativeWebScript -{ - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String extensionPath = req.getExtensionPath(); - - String constraintName = extensionPath.replace('_', ':'); - - List values = caveatConfigService.getRMAllowedValues(constraintName); - - // create model object with the lists model - Map model = new HashMap(1); - model.put("allowedValuesForCurrentUser", values); - model.put("constraintName", extensionPath); - - return model; - } - - public void setCaveatConfigService(RMCaveatConfigService caveatConfigService) - { - this.caveatConfigService = caveatConfigService; - } - - public RMCaveatConfigService getCaveatConfigService() - { - return caveatConfigService; - } - - private RMCaveatConfigService caveatConfigService; - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return + * the values for an RM constraint. + */ +public class RMConstraintGet extends DeclarativeWebScript +{ + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + String extensionPath = req.getExtensionPath(); + + String constraintName = extensionPath.replace('_', ':'); + + List values = caveatConfigService.getRMAllowedValues(constraintName); + + // create model object with the lists model + Map model = new HashMap(1); + model.put("allowedValuesForCurrentUser", values); + model.put("constraintName", extensionPath); + + return model; + } + + public void setCaveatConfigService(RMCaveatConfigService caveatConfigService) + { + this.caveatConfigService = caveatConfigService; + } + + public RMCaveatConfigService getCaveatConfigService() + { + return caveatConfigService; + } + + private RMCaveatConfigService caveatConfigService; + } \ No newline at end of file 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 596e125b0e..fa03c4751a 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 @@ -1,141 +1,141 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Record metadata aspects GET - * - * @author Roy Wetherall - */ -public class RecordMetaDataAspectsGet extends DeclarativeWebScript -{ - /** parameters */ - private static final String PARAM_NODEREF = "noderef"; - - protected DictionaryService dictionaryService; - protected NamespaceService namespaceService; - protected RecordService recordService; - protected FilePlanService filePlanService; - - /** - * Set the dictionary service instance - * - * @param dictionaryService the {@link DictionaryService} instance - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * Sets the {@link NamespaceService} instance - * - * @param namespaceService The {@link NamespaceService} instance - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Get the nodeRef and confirm it is valid - NodeRef nodeRef = null; - String nodeRefValue = req.getParameter(PARAM_NODEREF); - if (nodeRefValue == null || nodeRefValue.trim().length() == 0) - { - // get the file plan if a node ref hasn't been specified - // TODO will need to remove when multi file plans supported - nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - } - else - { - nodeRef = new NodeRef(nodeRefValue); - } - - // Get the details of all the aspects - Set aspectQNames = recordService.getRecordMetadataAspects(nodeRef); - List> aspects = new ArrayList>(aspectQNames.size()+1); - for (QName aspectQName : aspectQNames) - { - // Get the prefix aspect and default the label to the localname - String prefixString = aspectQName.toPrefixString(namespaceService); - String label = aspectQName.getLocalName(); - - Map aspect = new HashMap(2); - aspect.put("id", prefixString); - - // Try and get the aspect definition - AspectDefinition aspectDefinition = dictionaryService.getAspect(aspectQName); - if (aspectDefinition != null) - { - // Fet the label from the aspect definition - label = aspectDefinition.getTitle(dictionaryService); - } - aspect.put("value", label); - - // Add the aspect details to the aspects list - aspects.add(aspect); - } - - // create model object with the lists model - Map model = new HashMap(1); - model.put("aspects", aspects); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Record metadata aspects GET + * + * @author Roy Wetherall + */ +public class RecordMetaDataAspectsGet extends DeclarativeWebScript +{ + /** parameters */ + private static final String PARAM_NODEREF = "noderef"; + + protected DictionaryService dictionaryService; + protected NamespaceService namespaceService; + protected RecordService recordService; + protected FilePlanService filePlanService; + + /** + * Set the dictionary service instance + * + * @param dictionaryService the {@link DictionaryService} instance + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * Sets the {@link NamespaceService} instance + * + * @param namespaceService The {@link NamespaceService} instance + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Get the nodeRef and confirm it is valid + NodeRef nodeRef = null; + String nodeRefValue = req.getParameter(PARAM_NODEREF); + if (nodeRefValue == null || nodeRefValue.trim().length() == 0) + { + // get the file plan if a node ref hasn't been specified + // TODO will need to remove when multi file plans supported + nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + } + else + { + nodeRef = new NodeRef(nodeRefValue); + } + + // Get the details of all the aspects + Set aspectQNames = recordService.getRecordMetadataAspects(nodeRef); + List> aspects = new ArrayList>(aspectQNames.size()+1); + for (QName aspectQName : aspectQNames) + { + // Get the prefix aspect and default the label to the localname + String prefixString = aspectQName.toPrefixString(namespaceService); + String label = aspectQName.getLocalName(); + + Map aspect = new HashMap(2); + aspect.put("id", prefixString); + + // Try and get the aspect definition + AspectDefinition aspectDefinition = dictionaryService.getAspect(aspectQName); + if (aspectDefinition != null) + { + // Fet the label from the aspect definition + label = aspectDefinition.getTitle(dictionaryService); + } + aspect.put("value", label); + + // Add the aspect details to the aspects list + aspects.add(aspect); + } + + // create model object with the lists model + Map model = new HashMap(1); + model.put("aspects", aspects); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipDelete.java index 93237056f6..cb885ca617 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipDelete.java @@ -1,116 +1,116 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import static org.alfresco.util.WebScriptUtils.getRequestParameterValue; -import static org.alfresco.util.WebScriptUtils.getTemplateVars; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to delete a relationship from a node. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipDelete extends AbstractRmWebScript -{ - /** Constants */ - private static final String STORE_TYPE = "target_store_type"; - private static final String STORE_ID = "target_store_id"; - private static final String ID = "target_id"; - private static final String UNIQUE_NAME = "uniqueName"; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** - * Gets the relationship service - * - * @return The relationship service - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Sets the relationship service - * - * @param relationshipService The relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String uniqueName = getRequestParameterValue(req, UNIQUE_NAME); - NodeRef source = parseRequestForNodeRef(req); - NodeRef target = parseRequestForTargetNodeRef(req); - - getRelationshipService().removeRelationship(uniqueName, source, target); - getRelationshipService().removeRelationship(uniqueName, target, source); - - Map model = new HashMap(1); - model.put(SUCCESS, true); - return model; - } - - /** - * Gets the node reference of target - * - * @param req The webscript request - * @return The node reference of the target - */ - private NodeRef parseRequestForTargetNodeRef(WebScriptRequest req) - { - Map templateVars = getTemplateVars(req); - String storeType = templateVars.get(STORE_TYPE); - String storeId = templateVars.get(STORE_ID); - String nodeId = templateVars.get(ID); - - NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId); - - if (!getNodeService().exists(nodeRef)) - { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" + - nodeRef.toString() + "'."); - } - - return nodeRef; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import static org.alfresco.util.WebScriptUtils.getRequestParameterValue; +import static org.alfresco.util.WebScriptUtils.getTemplateVars; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to delete a relationship from a node. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipDelete extends AbstractRmWebScript +{ + /** Constants */ + private static final String STORE_TYPE = "target_store_type"; + private static final String STORE_ID = "target_store_id"; + private static final String ID = "target_id"; + private static final String UNIQUE_NAME = "uniqueName"; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** + * Gets the relationship service + * + * @return The relationship service + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Sets the relationship service + * + * @param relationshipService The relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + String uniqueName = getRequestParameterValue(req, UNIQUE_NAME); + NodeRef source = parseRequestForNodeRef(req); + NodeRef target = parseRequestForTargetNodeRef(req); + + getRelationshipService().removeRelationship(uniqueName, source, target); + getRelationshipService().removeRelationship(uniqueName, target, source); + + Map model = new HashMap(1); + model.put(SUCCESS, true); + return model; + } + + /** + * Gets the node reference of target + * + * @param req The webscript request + * @return The node reference of the target + */ + private NodeRef parseRequestForTargetNodeRef(WebScriptRequest req) + { + Map templateVars = getTemplateVars(req); + String storeType = templateVars.get(STORE_TYPE); + String storeId = templateVars.get(STORE_ID); + String nodeId = templateVars.get(ID); + + NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId); + + if (!getNodeService().exists(nodeRef)) + { + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" + + nodeRef.toString() + "'."); + } + + return nodeRef; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipLabelsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipLabelsGet.java index c3850a7033..ce5471e11e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipLabelsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipLabelsGet.java @@ -1,218 +1,218 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import static org.alfresco.util.ParameterCheck.mandatoryString; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the relationship labels. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipLabelsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String RELATIONSHIP_LABELS = "relationshipLabels"; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** - * Gets the relationship service - * - * @return The relationship service - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Sets the relationship service - * - * @param relationshipService The relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - model.put(RELATIONSHIP_LABELS, getRelationshipsLabels()); - return model; - } - - /** - * Gets the list of available relationship labels - * - * @return The list of available relationship labels - */ - private List getRelationshipsLabels() - { - List relationshipLabels = new ArrayList(); - - Set relationshipDefinitions = getRelationshipService().getRelationshipDefinitions(); - for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) - { - RelationshipType type = relationshipDefinition.getType(); - String uniqueName = relationshipDefinition.getUniqueName(); - RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); - String sourceText = displayName.getSourceText(); - String targetText = displayName.getTargetText(); - - if (RelationshipType.PARENTCHILD.equals(type)) - { - relationshipLabels.add(new RelationshipLabel(sourceText, uniqueName + INVERT)); - relationshipLabels.add(new RelationshipLabel(targetText, uniqueName)); - } - else if (RelationshipType.BIDIRECTIONAL.equals(type)) - { - if (!sourceText.equals(targetText)) - { - throw new WebScriptException( - Status.STATUS_BAD_REQUEST, - "The source '" - + sourceText - + "' and target text '" - + targetText - + "' must be the same for a bidirectional relationship."); - } - relationshipLabels.add(new RelationshipLabel(sourceText, uniqueName)); - } - else - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unknown relationship type '" + type + "'."); - } - } - - return sortRelationshipLabelsByName(relationshipLabels); - } - - /** - * Helper method to sort the relationship labels by their names - * - * @param relationshipLabels Relationship labels to sort - * @return Sorted list of relationship labels - */ - private List sortRelationshipLabelsByName(List relationshipLabels) - { - Collections.sort(relationshipLabels, new Comparator() - { - @Override - public int compare(RelationshipLabel r1, RelationshipLabel r2) - { - return r1.getLabel().toLowerCase().compareTo(r2.getLabel().toLowerCase()); - } - }); - return relationshipLabels; - } - - /** - * Relationship label helper class - */ - public class RelationshipLabel - { - /** Label of the relationship */ - private String label; - - /** Unique name of the relationship */ - private String uniqueName; - - /** - * Constructor - * - * @param label Label of the relationship - * @param uniqueName Unique name of the relationship - */ - public RelationshipLabel(String label, String uniqueName) - { - mandatoryString("label", label); - mandatoryString("uniqueName", uniqueName); - - setLabel(label); - setUniqueName(uniqueName); - } - - /** - * Gets the label of the relationship - * - * @return The label of the relationship - */ - public String getLabel() - { - return this.label; - } - - /** - * Sets the label of the relationship - * - * @param label The label of the relationship - */ - private void setLabel(String label) - { - this.label = label; - } - - /** - * Gets the unique name of the relationship - * - * @return The unique name of the relationship - */ - public String getUniqueName() - { - return this.uniqueName; - } - - /** - * Sets the unique name of the relationship - * - * @param uniqueName The unique name of the relationship - */ - private void setUniqueName(String uniqueName) - { - this.uniqueName = uniqueName; - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import static org.alfresco.util.ParameterCheck.mandatoryString; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get the relationship labels. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipLabelsGet extends AbstractRmWebScript +{ + /** Constants */ + private static final String RELATIONSHIP_LABELS = "relationshipLabels"; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** + * Gets the relationship service + * + * @return The relationship service + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Sets the relationship service + * + * @param relationshipService The relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + model.put(RELATIONSHIP_LABELS, getRelationshipsLabels()); + return model; + } + + /** + * Gets the list of available relationship labels + * + * @return The list of available relationship labels + */ + private List getRelationshipsLabels() + { + List relationshipLabels = new ArrayList(); + + Set relationshipDefinitions = getRelationshipService().getRelationshipDefinitions(); + for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) + { + RelationshipType type = relationshipDefinition.getType(); + String uniqueName = relationshipDefinition.getUniqueName(); + RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); + String sourceText = displayName.getSourceText(); + String targetText = displayName.getTargetText(); + + if (RelationshipType.PARENTCHILD.equals(type)) + { + relationshipLabels.add(new RelationshipLabel(sourceText, uniqueName + INVERT)); + relationshipLabels.add(new RelationshipLabel(targetText, uniqueName)); + } + else if (RelationshipType.BIDIRECTIONAL.equals(type)) + { + if (!sourceText.equals(targetText)) + { + throw new WebScriptException( + Status.STATUS_BAD_REQUEST, + "The source '" + + sourceText + + "' and target text '" + + targetText + + "' must be the same for a bidirectional relationship."); + } + relationshipLabels.add(new RelationshipLabel(sourceText, uniqueName)); + } + else + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unknown relationship type '" + type + "'."); + } + } + + return sortRelationshipLabelsByName(relationshipLabels); + } + + /** + * Helper method to sort the relationship labels by their names + * + * @param relationshipLabels Relationship labels to sort + * @return Sorted list of relationship labels + */ + private List sortRelationshipLabelsByName(List relationshipLabels) + { + Collections.sort(relationshipLabels, new Comparator() + { + @Override + public int compare(RelationshipLabel r1, RelationshipLabel r2) + { + return r1.getLabel().toLowerCase().compareTo(r2.getLabel().toLowerCase()); + } + }); + return relationshipLabels; + } + + /** + * Relationship label helper class + */ + public class RelationshipLabel + { + /** Label of the relationship */ + private String label; + + /** Unique name of the relationship */ + private String uniqueName; + + /** + * Constructor + * + * @param label Label of the relationship + * @param uniqueName Unique name of the relationship + */ + public RelationshipLabel(String label, String uniqueName) + { + mandatoryString("label", label); + mandatoryString("uniqueName", uniqueName); + + setLabel(label); + setUniqueName(uniqueName); + } + + /** + * Gets the label of the relationship + * + * @return The label of the relationship + */ + public String getLabel() + { + return this.label; + } + + /** + * Sets the label of the relationship + * + * @param label The label of the relationship + */ + private void setLabel(String label) + { + this.label = label; + } + + /** + * Gets the unique name of the relationship + * + * @return The unique name of the relationship + */ + public String getUniqueName() + { + return this.uniqueName; + } + + /** + * Sets the unique name of the relationship + * + * @param uniqueName The unique name of the relationship + */ + private void setUniqueName(String uniqueName) + { + this.uniqueName = uniqueName; + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipsGet.java index 630c9f0ddf..bbf334a014 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RelationshipsGet.java @@ -1,184 +1,184 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.jscript.app.JSONConversionComponent; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.WebScriptUtils; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the relationships for a node. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RelationshipsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String RELATIONSHIPS = "relationships"; - private static final String RELATIONSHIP_LABEL = "relationshipLabel"; - private static final String RELATIONSHIP_UNIQUE_NAME = "relationshipUniqueName"; - - /** The relationship end point */ - private enum RelationshipEndPoint - { - SOURCE, TARGET - }; - - /** Relationship service */ - private RelationshipService relationshipService; - - /** JSON conversion component */ - private JSONConversionComponent jsonConversionComponent; - - /** - * Gets the relationship service - * - * @return The relationship service - */ - protected RelationshipService getRelationshipService() - { - return this.relationshipService; - } - - /** - * Gets the JSON conversion component - * - * @return The JSON conversion component - */ - protected JSONConversionComponent getJsonConversionComponent() - { - return this.jsonConversionComponent; - } - - /** - * Sets the relationship service - * - * @param relationshipService The relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * Sets the JSON conversion component - * - * @param jsonConversionComponent The JSON conversion component - */ - public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) - { - this.jsonConversionComponent = jsonConversionComponent; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - NodeRef nodeRef = parseRequestForNodeRef(req); - model.put(RELATIONSHIPS, getRelationships(nodeRef)); - return model; - } - - /** - * Gets the relationships of a node - * - * @param nodeRef The node reference - * - * @return The list of relationships of a node - */ - private List getRelationships(NodeRef nodeRef) - { - List relationships = new ArrayList(); - - Set relationshipsFrom = getRelationshipService().getRelationshipsFrom(nodeRef); - relationships.addAll(buildRelationshipData(relationshipsFrom, RelationshipEndPoint.TARGET)); - - Set relationshipsTo = getRelationshipService().getRelationshipsTo(nodeRef); - relationships.addAll(buildRelationshipData(relationshipsTo, RelationshipEndPoint.SOURCE)); - - return relationships; - } - - /** - * Creates the relationship data - * - * @param relationships The {@link Set} of relationships - * @param relationshipEndPoint The end point of the relationship, which is either {@link RelationshipEndpoint#SOURCE} or {@link RelationshipEndpoint#TARGET} - * @return The relationship data as {@link List} - */ - private List buildRelationshipData(Set relationships, RelationshipEndPoint relationshipEndPoint) - { - List result = new ArrayList(); - - for (Relationship relationship : relationships) - { - String uniqueName = relationship.getUniqueName(); - RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); - if (relationshipDefinition != null) - { - NodeRef node; - String label; - - if (RelationshipEndPoint.SOURCE.equals(relationshipEndPoint)) - { - node = relationship.getSource(); - label = relationshipDefinition.getDisplayName().getSourceText(); - } - else if (RelationshipEndPoint.TARGET.equals(relationshipEndPoint)) - { - node = relationship.getTarget(); - label = relationshipDefinition.getDisplayName().getTargetText(); - } - else - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unknown relationship end point type '" + relationshipEndPoint + "'."); - } - - String nodeDetails = getJsonConversionComponent().toJSON(node, true); - JSONObject jsonObject = WebScriptUtils.createJSONObject(nodeDetails); - WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_LABEL, label); - WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_UNIQUE_NAME, relationshipDefinition.getUniqueName()); - - result.add(jsonObject.toString()); - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.jscript.app.JSONConversionComponent; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.WebScriptUtils; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get the relationships for a node. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RelationshipsGet extends AbstractRmWebScript +{ + /** Constants */ + private static final String RELATIONSHIPS = "relationships"; + private static final String RELATIONSHIP_LABEL = "relationshipLabel"; + private static final String RELATIONSHIP_UNIQUE_NAME = "relationshipUniqueName"; + + /** The relationship end point */ + private enum RelationshipEndPoint + { + SOURCE, TARGET + }; + + /** Relationship service */ + private RelationshipService relationshipService; + + /** JSON conversion component */ + private JSONConversionComponent jsonConversionComponent; + + /** + * Gets the relationship service + * + * @return The relationship service + */ + protected RelationshipService getRelationshipService() + { + return this.relationshipService; + } + + /** + * Gets the JSON conversion component + * + * @return The JSON conversion component + */ + protected JSONConversionComponent getJsonConversionComponent() + { + return this.jsonConversionComponent; + } + + /** + * Sets the relationship service + * + * @param relationshipService The relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * Sets the JSON conversion component + * + * @param jsonConversionComponent The JSON conversion component + */ + public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) + { + this.jsonConversionComponent = jsonConversionComponent; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + NodeRef nodeRef = parseRequestForNodeRef(req); + model.put(RELATIONSHIPS, getRelationships(nodeRef)); + return model; + } + + /** + * Gets the relationships of a node + * + * @param nodeRef The node reference + * + * @return The list of relationships of a node + */ + private List getRelationships(NodeRef nodeRef) + { + List relationships = new ArrayList(); + + Set relationshipsFrom = getRelationshipService().getRelationshipsFrom(nodeRef); + relationships.addAll(buildRelationshipData(relationshipsFrom, RelationshipEndPoint.TARGET)); + + Set relationshipsTo = getRelationshipService().getRelationshipsTo(nodeRef); + relationships.addAll(buildRelationshipData(relationshipsTo, RelationshipEndPoint.SOURCE)); + + return relationships; + } + + /** + * Creates the relationship data + * + * @param relationships The {@link Set} of relationships + * @param relationshipEndPoint The end point of the relationship, which is either {@link RelationshipEndpoint#SOURCE} or {@link RelationshipEndpoint#TARGET} + * @return The relationship data as {@link List} + */ + private List buildRelationshipData(Set relationships, RelationshipEndPoint relationshipEndPoint) + { + List result = new ArrayList(); + + for (Relationship relationship : relationships) + { + String uniqueName = relationship.getUniqueName(); + RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName); + if (relationshipDefinition != null) + { + NodeRef node; + String label; + + if (RelationshipEndPoint.SOURCE.equals(relationshipEndPoint)) + { + node = relationship.getSource(); + label = relationshipDefinition.getDisplayName().getSourceText(); + } + else if (RelationshipEndPoint.TARGET.equals(relationshipEndPoint)) + { + node = relationship.getTarget(); + label = relationshipDefinition.getDisplayName().getTargetText(); + } + else + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unknown relationship end point type '" + relationshipEndPoint + "'."); + } + + String nodeDetails = getJsonConversionComponent().toJSON(node, true); + JSONObject jsonObject = WebScriptUtils.createJSONObject(nodeDetails); + WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_LABEL, label); + WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_UNIQUE_NAME, relationshipDefinition.getUniqueName()); + + result.add(jsonObject.toString()); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RmActionPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RmActionPost.java index d140c485aa..33dc4f85fd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RmActionPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RmActionPost.java @@ -1,219 +1,219 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -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.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; - -/** - * This class provides the implementation for the rmaction webscript. - * - * @author Neil McErlean - */ -public class RmActionPost extends DeclarativeWebScript -{ - private static Log logger = LogFactory.getLog(RmActionPost.class); - - private static final String PARAM_NAME = "name"; - private static final String PARAM_NODE_REF = "nodeRef"; - private static final String PARAM_NODE_REFS = "nodeRefs"; - private static final String PARAM_PARAMS = "params"; - - private NodeService nodeService; - private RecordsManagementActionService rmActionService; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) - { - this.rmActionService = rmActionService; - } - - @SuppressWarnings("unchecked") - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String reqContentAsString; - try - { - reqContentAsString = req.getContent().getContent(); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - - String actionName = null; - List targetNodeRefs = new ArrayList(1); - Map actionParams = new HashMap(3); - - try - { - JSONObject jsonObj = new JSONObject(new JSONTokener(reqContentAsString)); - - // Get the action name - if (jsonObj.has(PARAM_NAME)) - { - actionName = jsonObj.getString(PARAM_NAME); - } - - // Get the target references - if (jsonObj.has(PARAM_NODE_REF)) - { - NodeRef nodeRef = new NodeRef(jsonObj.getString(PARAM_NODE_REF)); - targetNodeRefs.add(nodeRef); - } - if (jsonObj.has(PARAM_NODE_REFS)) - { - JSONArray jsonArray = jsonObj.getJSONArray(PARAM_NODE_REFS); - if (jsonArray.length() != 0) - { - targetNodeRefs = new ArrayList(jsonArray.length()); - for (int i = 0; i < jsonArray.length(); i++) - { - NodeRef nodeRef = new NodeRef(jsonArray.getString(i)); - targetNodeRefs.add(nodeRef); - } - } - } - - // params are optional. - if (jsonObj.has(PARAM_PARAMS)) - { - JSONObject paramsObj = jsonObj.getJSONObject(PARAM_PARAMS); - for (Iterator iter = paramsObj.keys(); iter.hasNext(); ) - { - String nextKeyString = iter.next(); - Object nextValue = paramsObj.get(nextKeyString); - - // Check for date values - if ((nextValue instanceof JSONObject) && ((JSONObject)nextValue).has("iso8601")) - { - String dateStringValue = ((JSONObject)nextValue).getString("iso8601"); - nextValue = ISO8601DateFormat.parse(dateStringValue); - } - - actionParams.put(nextKeyString, (Serializable)nextValue); - } - } - } - catch (JSONException exception) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request JSON.", exception); - } - - // validate input: check for mandatory params. - // Some RM actions can be posted without a nodeRef. - if (actionName == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "A mandatory parameter has not been provided in URL"); - } - - // Check that all the nodes provided exist and build report string - StringBuffer targetNodeRefsString = new StringBuffer(30); - boolean firstTime = true; - for (NodeRef targetNodeRef : targetNodeRefs) - { - if (!nodeService.exists(targetNodeRef)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, - "The targetNode does not exist (" + targetNodeRef.toString() + ")"); - } - - // Build the string - if (firstTime) - { - firstTime = false; - } - else - { - targetNodeRefsString.append(", "); - } - targetNodeRefsString.append(targetNodeRef.toString()); - } - - // Proceed to execute the specified action on the specified node. - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Executing Record Action ") - .append(actionName) - .append(", (") - .append(targetNodeRefsString.toString()) - .append("), ") - .append(actionParams); - logger.debug(msg.toString()); - } - - Map model = new HashMap(); - if (targetNodeRefs.isEmpty()) - { - RecordsManagementActionResult result = this.rmActionService.executeRecordsManagementAction(actionName, actionParams); - if (result.getValue() != null) - { - model.put("result", result.getValue().toString()); - } - } - else - { - Map resultMap = this.rmActionService.executeRecordsManagementAction(targetNodeRefs, actionName, actionParams); - Map results = new HashMap(resultMap.size()); - for (Map.Entry entry : resultMap.entrySet()) - { - Object value = entry.getValue().getValue(); - if (value != null) - { - results.put(entry.getKey().toString(), value.toString()); - } - } - model.put("results", results); - } - - model.put("message", "Successfully queued action [" + actionName + "] on " + targetNodeRefsString.toString()); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +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.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; + +/** + * This class provides the implementation for the rmaction webscript. + * + * @author Neil McErlean + */ +public class RmActionPost extends DeclarativeWebScript +{ + private static Log logger = LogFactory.getLog(RmActionPost.class); + + private static final String PARAM_NAME = "name"; + private static final String PARAM_NODE_REF = "nodeRef"; + private static final String PARAM_NODE_REFS = "nodeRefs"; + private static final String PARAM_PARAMS = "params"; + + private NodeService nodeService; + private RecordsManagementActionService rmActionService; + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) + { + this.rmActionService = rmActionService; + } + + @SuppressWarnings("unchecked") + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + String reqContentAsString; + try + { + reqContentAsString = req.getContent().getContent(); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + + String actionName = null; + List targetNodeRefs = new ArrayList(1); + Map actionParams = new HashMap(3); + + try + { + JSONObject jsonObj = new JSONObject(new JSONTokener(reqContentAsString)); + + // Get the action name + if (jsonObj.has(PARAM_NAME)) + { + actionName = jsonObj.getString(PARAM_NAME); + } + + // Get the target references + if (jsonObj.has(PARAM_NODE_REF)) + { + NodeRef nodeRef = new NodeRef(jsonObj.getString(PARAM_NODE_REF)); + targetNodeRefs.add(nodeRef); + } + if (jsonObj.has(PARAM_NODE_REFS)) + { + JSONArray jsonArray = jsonObj.getJSONArray(PARAM_NODE_REFS); + if (jsonArray.length() != 0) + { + targetNodeRefs = new ArrayList(jsonArray.length()); + for (int i = 0; i < jsonArray.length(); i++) + { + NodeRef nodeRef = new NodeRef(jsonArray.getString(i)); + targetNodeRefs.add(nodeRef); + } + } + } + + // params are optional. + if (jsonObj.has(PARAM_PARAMS)) + { + JSONObject paramsObj = jsonObj.getJSONObject(PARAM_PARAMS); + for (Iterator iter = paramsObj.keys(); iter.hasNext(); ) + { + String nextKeyString = iter.next(); + Object nextValue = paramsObj.get(nextKeyString); + + // Check for date values + if ((nextValue instanceof JSONObject) && ((JSONObject)nextValue).has("iso8601")) + { + String dateStringValue = ((JSONObject)nextValue).getString("iso8601"); + nextValue = ISO8601DateFormat.parse(dateStringValue); + } + + actionParams.put(nextKeyString, (Serializable)nextValue); + } + } + } + catch (JSONException exception) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request JSON.", exception); + } + + // validate input: check for mandatory params. + // Some RM actions can be posted without a nodeRef. + if (actionName == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "A mandatory parameter has not been provided in URL"); + } + + // Check that all the nodes provided exist and build report string + StringBuffer targetNodeRefsString = new StringBuffer(30); + boolean firstTime = true; + for (NodeRef targetNodeRef : targetNodeRefs) + { + if (!nodeService.exists(targetNodeRef)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, + "The targetNode does not exist (" + targetNodeRef.toString() + ")"); + } + + // Build the string + if (firstTime) + { + firstTime = false; + } + else + { + targetNodeRefsString.append(", "); + } + targetNodeRefsString.append(targetNodeRef.toString()); + } + + // Proceed to execute the specified action on the specified node. + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Executing Record Action ") + .append(actionName) + .append(", (") + .append(targetNodeRefsString.toString()) + .append("), ") + .append(actionParams); + logger.debug(msg.toString()); + } + + Map model = new HashMap(); + if (targetNodeRefs.isEmpty()) + { + RecordsManagementActionResult result = this.rmActionService.executeRecordsManagementAction(actionName, actionParams); + if (result.getValue() != null) + { + model.put("result", result.getValue().toString()); + } + } + else + { + Map resultMap = this.rmActionService.executeRecordsManagementAction(targetNodeRefs, actionName, actionParams); + Map results = new HashMap(resultMap.size()); + for (Map.Entry entry : resultMap.entrySet()) + { + Object value = entry.getValue().getValue(); + if (value != null) + { + results.put(entry.getKey().toString(), value.toString()); + } + } + model.put("results", results); + } + + model.put("message", "Successfully queued action [" + actionName + "] on " + targetNodeRefsString.toString()); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferGet.java index ae9d8303c0..1e346cc106 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferGet.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.IOException; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.repo.web.scripts.content.ContentStreamer; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.view.ExporterCrawlerParameters; -import org.alfresco.service.cmr.view.Location; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Streams the nodes of a transfer object to the client in the form of an - * ACP file. - * - * @author Gavin Cornwell - */ -@Deprecated -public class TransferGet extends BaseTransferWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(TransferGet.class); - - /** Content Streamer */ - private ContentStreamer contentStreamer; - - /** - * @param contentStreamer - */ - public void setContentStreamer(ContentStreamer contentStreamer) - { - this.contentStreamer = contentStreamer; - } - - @Override - protected File executeTransfer(NodeRef transferNode, - WebScriptRequest req, WebScriptResponse res, - Status status, Cache cache) throws IOException - { - // get all 'transferred' nodes - NodeRef[] itemsToTransfer = getTransferNodes(transferNode); - - // setup the ACP parameters - ExporterCrawlerParameters params = new ExporterCrawlerParameters(); - params.setCrawlSelf(true); - params.setCrawlChildNodes(true); - params.setExportFrom(new Location(itemsToTransfer)); - QName[] excludedAspects = new QName[] { - RenditionModel.ASPECT_RENDITIONED, - ContentModel.ASPECT_THUMBNAILED, - RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, - RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH}; - params.setExcludeAspects(excludedAspects); - - // create an archive of all the nodes to transfer - File tempFile = createACP(params, ZIP_EXTENSION, true); - - if (logger.isDebugEnabled()) - { - logger.debug("Creating transfer archive for " + itemsToTransfer.length + - " items into file: " + tempFile.getAbsolutePath()); - } - - // stream the archive back to the client as an attachment (forcing save as) - contentStreamer.streamContent(req, res, tempFile, null, true, tempFile.getName(), null); - - // return the temp file for deletion - return tempFile; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.IOException; + +import org.alfresco.model.ContentModel; +import org.alfresco.model.RenditionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.repo.web.scripts.content.ContentStreamer; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.view.ExporterCrawlerParameters; +import org.alfresco.service.cmr.view.Location; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Streams the nodes of a transfer object to the client in the form of an + * ACP file. + * + * @author Gavin Cornwell + */ +@Deprecated +public class TransferGet extends BaseTransferWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(TransferGet.class); + + /** Content Streamer */ + private ContentStreamer contentStreamer; + + /** + * @param contentStreamer + */ + public void setContentStreamer(ContentStreamer contentStreamer) + { + this.contentStreamer = contentStreamer; + } + + @Override + protected File executeTransfer(NodeRef transferNode, + WebScriptRequest req, WebScriptResponse res, + Status status, Cache cache) throws IOException + { + // get all 'transferred' nodes + NodeRef[] itemsToTransfer = getTransferNodes(transferNode); + + // setup the ACP parameters + ExporterCrawlerParameters params = new ExporterCrawlerParameters(); + params.setCrawlSelf(true); + params.setCrawlChildNodes(true); + params.setExportFrom(new Location(itemsToTransfer)); + QName[] excludedAspects = new QName[] { + RenditionModel.ASPECT_RENDITIONED, + ContentModel.ASPECT_THUMBNAILED, + RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, + RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH}; + params.setExcludeAspects(excludedAspects); + + // create an archive of all the nodes to transfer + File tempFile = createACP(params, ZIP_EXTENSION, true); + + if (logger.isDebugEnabled()) + { + logger.debug("Creating transfer archive for " + itemsToTransfer.length + + " items into file: " + tempFile.getAbsolutePath()); + } + + // stream the archive back to the client as an attachment (forcing save as) + contentStreamer.streamContent(req, res, tempFile, null, true, tempFile.getName(), null); + + // return the temp file for deletion + return tempFile; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java index 742293164e..881be8c02b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java @@ -1,288 +1,288 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.web.scripts.content.ContentStreamer; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Returns a JSON representation of a transfer report. - * - * @author Gavin Cornwell - */ -@Deprecated -public class TransferReportGet extends BaseTransferWebScript -{ - /** Logger */ - private static Log logger = LogFactory.getLog(TransferReportGet.class); - - protected static final String REPORT_FILE_PREFIX = "report_"; - protected static final String REPORT_FILE_SUFFIX = ".json"; - - protected DictionaryService ddService; - protected DispositionService dispositionService; - protected ContentStreamer contentStreamer; - - /** - * Sets the DictionaryService instance - * - * @param ddService The DictionaryService instance - */ - public void setDictionaryService(DictionaryService ddService) - { - this.ddService = ddService; - } - - /** - * Sets the disposition service - * - * @param dispositionService the disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param contentStreamer - */ - public void setContentStreamer(ContentStreamer contentStreamer) - { - this.contentStreamer = contentStreamer; - } - - @Override - protected File executeTransfer(NodeRef transferNode, - WebScriptRequest req, WebScriptResponse res, - Status status, Cache cache) throws IOException - { - // generate the report (will be in JSON format) - File report = generateJSONTransferReport(transferNode); - - // stream the report back to the client - contentStreamer.streamContent(req, res, report, null, false, null, null); - - // 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 - */ - File generateJSONTransferReport(NodeRef transferNode) throws IOException - { - File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); - Writer writer = null; - try - { - // get all 'transferred' nodes - NodeRef[] itemsToTransfer = getTransferNodes(transferNode); - - if (logger.isDebugEnabled()) - { - logger.debug("Generating JSON transfer report for " + itemsToTransfer.length + - " items into file: " + report.getAbsolutePath()); - } - - // create the writer - writer = new OutputStreamWriter(new FileOutputStream(report), Charset.forName("UTF-8")); - - // use RMService to get disposition authority - String dispositionAuthority = null; - if (itemsToTransfer.length > 0) - { - // use the first transfer item to get to disposition schedule - DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); - if (ds != null) - { - dispositionAuthority = ds.getDispositionAuthority(); - } - } - - // write the JSON header - writer.write("{\n\t\"data\":\n\t{"); - writer.write("\n\t\t\"transferDate\": \""); - writer.write(ISO8601DateFormat.format( - (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED))); - writer.write("\",\n\t\t\"transferPerformedBy\": \""); - writer.write(AuthenticationUtil.getRunAsUser()); - writer.write("\",\n\t\t\"dispositionAuthority\": \""); - writer.write(dispositionAuthority != null ? dispositionAuthority : ""); - writer.write("\",\n\t\t\"items\":\n\t\t["); - - // write out JSON representation of items to transfer - generateTransferItemsJSON(writer, itemsToTransfer); - - // write the JSON footer - writer.write("\n\t\t]\n\t}\n}"); - } - finally - { - if (writer != null) - { - 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 - */ - protected void generateTransferItemsJSON(Writer writer, NodeRef[] itemsToTransfer) - throws IOException - { - boolean first = true; - for (NodeRef item : itemsToTransfer) - { - if (first) - { - first = false; - } - else - { - writer.write(","); - } - - if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER)) - { - generateTransferFolderJSON(writer, item); - } - else - { - generateTransferRecordJSON(writer, item); - } - } - } - - /** - * Generates the JSON to represent the given folder. - * - * @param writer Writer to write to - * @param folderNode Folder being transferred - * @throws IOException - */ - protected void generateTransferFolderJSON(Writer writer, NodeRef folderNode) - throws IOException - { - // TODO: Add identation - - writer.write("\n{\n\"type\":\"folder\",\n"); - writer.write("\"name\":\""); - writer.write((String)nodeService.getProperty(folderNode, ContentModel.PROP_NAME)); - writer.write("\",\n\"nodeRef\":\""); - writer.write(folderNode.toString()); - writer.write("\",\n\"id\":\""); - writer.write((String)nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER)); - writer.write("\",\n\"children\":\n["); - - boolean first = true; - List assocs = this.nodeService.getChildAssocs(folderNode, - ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef child : assocs) - { - if (first) - { - first = false; - } - else - { - writer.write(","); - } - - NodeRef childRef = child.getChildRef(); - if (ddService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER)) - { - generateTransferFolderJSON(writer, childRef); - } - else - { - generateTransferRecordJSON(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 - */ - protected void generateTransferRecordJSON(Writer writer, NodeRef recordNode) - throws IOException - { - writer.write("\n{\n\"type\":\"record\",\n"); - writer.write("\"name\":\""); - writer.write((String)nodeService.getProperty(recordNode, ContentModel.PROP_NAME)); - writer.write("\",\n\"nodeRef\":\""); - writer.write(recordNode.toString()); - writer.write("\",\n\"id\":\""); - writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER)); - writer.write("\""); - - if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD)) - { - writer.write(",\n\"declaredBy\":\""); - writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_BY)); - writer.write("\",\n\"declaredAt\":\""); - writer.write(ISO8601DateFormat.format( - (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT))); - writer.write("\""); - } - - writer.write("\n}"); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Date; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.web.scripts.content.ContentStreamer; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.TempFileProvider; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Returns a JSON representation of a transfer report. + * + * @author Gavin Cornwell + */ +@Deprecated +public class TransferReportGet extends BaseTransferWebScript +{ + /** Logger */ + private static Log logger = LogFactory.getLog(TransferReportGet.class); + + protected static final String REPORT_FILE_PREFIX = "report_"; + protected static final String REPORT_FILE_SUFFIX = ".json"; + + protected DictionaryService ddService; + protected DispositionService dispositionService; + protected ContentStreamer contentStreamer; + + /** + * Sets the DictionaryService instance + * + * @param ddService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService ddService) + { + this.ddService = ddService; + } + + /** + * Sets the disposition service + * + * @param dispositionService the disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param contentStreamer + */ + public void setContentStreamer(ContentStreamer contentStreamer) + { + this.contentStreamer = contentStreamer; + } + + @Override + protected File executeTransfer(NodeRef transferNode, + WebScriptRequest req, WebScriptResponse res, + Status status, Cache cache) throws IOException + { + // generate the report (will be in JSON format) + File report = generateJSONTransferReport(transferNode); + + // stream the report back to the client + contentStreamer.streamContent(req, res, report, null, false, null, null); + + // 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 + */ + File generateJSONTransferReport(NodeRef transferNode) throws IOException + { + File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); + Writer writer = null; + try + { + // get all 'transferred' nodes + NodeRef[] itemsToTransfer = getTransferNodes(transferNode); + + if (logger.isDebugEnabled()) + { + logger.debug("Generating JSON transfer report for " + itemsToTransfer.length + + " items into file: " + report.getAbsolutePath()); + } + + // create the writer + writer = new OutputStreamWriter(new FileOutputStream(report), Charset.forName("UTF-8")); + + // use RMService to get disposition authority + String dispositionAuthority = null; + if (itemsToTransfer.length > 0) + { + // use the first transfer item to get to disposition schedule + DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); + if (ds != null) + { + dispositionAuthority = ds.getDispositionAuthority(); + } + } + + // write the JSON header + writer.write("{\n\t\"data\":\n\t{"); + writer.write("\n\t\t\"transferDate\": \""); + writer.write(ISO8601DateFormat.format( + (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED))); + writer.write("\",\n\t\t\"transferPerformedBy\": \""); + writer.write(AuthenticationUtil.getRunAsUser()); + writer.write("\",\n\t\t\"dispositionAuthority\": \""); + writer.write(dispositionAuthority != null ? dispositionAuthority : ""); + writer.write("\",\n\t\t\"items\":\n\t\t["); + + // write out JSON representation of items to transfer + generateTransferItemsJSON(writer, itemsToTransfer); + + // write the JSON footer + writer.write("\n\t\t]\n\t}\n}"); + } + finally + { + if (writer != null) + { + 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 + */ + protected void generateTransferItemsJSON(Writer writer, NodeRef[] itemsToTransfer) + throws IOException + { + boolean first = true; + for (NodeRef item : itemsToTransfer) + { + if (first) + { + first = false; + } + else + { + writer.write(","); + } + + if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER)) + { + generateTransferFolderJSON(writer, item); + } + else + { + generateTransferRecordJSON(writer, item); + } + } + } + + /** + * Generates the JSON to represent the given folder. + * + * @param writer Writer to write to + * @param folderNode Folder being transferred + * @throws IOException + */ + protected void generateTransferFolderJSON(Writer writer, NodeRef folderNode) + throws IOException + { + // TODO: Add identation + + writer.write("\n{\n\"type\":\"folder\",\n"); + writer.write("\"name\":\""); + writer.write((String)nodeService.getProperty(folderNode, ContentModel.PROP_NAME)); + writer.write("\",\n\"nodeRef\":\""); + writer.write(folderNode.toString()); + writer.write("\",\n\"id\":\""); + writer.write((String)nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER)); + writer.write("\",\n\"children\":\n["); + + boolean first = true; + List assocs = this.nodeService.getChildAssocs(folderNode, + ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef child : assocs) + { + if (first) + { + first = false; + } + else + { + writer.write(","); + } + + NodeRef childRef = child.getChildRef(); + if (ddService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER)) + { + generateTransferFolderJSON(writer, childRef); + } + else + { + generateTransferRecordJSON(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 + */ + protected void generateTransferRecordJSON(Writer writer, NodeRef recordNode) + throws IOException + { + writer.write("\n{\n\"type\":\"record\",\n"); + writer.write("\"name\":\""); + writer.write((String)nodeService.getProperty(recordNode, ContentModel.PROP_NAME)); + writer.write("\",\n\"nodeRef\":\""); + writer.write(recordNode.toString()); + writer.write("\",\n\"id\":\""); + writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER)); + writer.write("\""); + + if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD)) + { + writer.write(",\n\"declaredBy\":\""); + writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_BY)); + writer.write("\",\n\"declaredAt\":\""); + writer.write(ISO8601DateFormat.format( + (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT))); + writer.write("\""); + } + + writer.write("\n}"); + } } \ No newline at end of file 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 173104bc79..cc9edab467 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 @@ -1,453 +1,453 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; - -/** - * Files a transfer report as a record. - * - * @author Gavin Cornwell - */ -@Deprecated -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"; - protected static final String RESPONSE_SUCCESS = "success"; - protected static final String RESPONSE_RECORD = "record"; - protected static final String RESPONSE_RECORD_NAME = "recordName"; - - protected DictionaryService ddService; - protected RecordsManagementActionService rmActionService; - protected DispositionService dispositionService; - protected ContentService contentService; - - /** - * Sets the DictionaryService instance - * - * @param ddService The DictionaryService instance - */ - public void setDictionaryService(DictionaryService ddService) - { - this.ddService = ddService; - } - - /** - * 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; - } - - /** - * Sets the ContentSerivce instance - * - * @param contentService ContentService instance - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - @Override - protected File executeTransfer(NodeRef transferNode, - 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 - // a record folder - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - if (!json.has(PARAM_DESTINATION)) - { - 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, - "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, - "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, - (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); - } - catch (JSONException je) - { - 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 - */ - File generateHTMLTransferReport(NodeRef transferNode) throws IOException - { - File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); - Writer writer = null; - try - { - // get all 'transferred' nodes - NodeRef[] itemsToTransfer = getTransferNodes(transferNode); - - if (logger.isDebugEnabled()) - { - logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + - " items into file: " + report.getAbsolutePath()); - } - - // create the writer - writer = new OutputStreamWriter(new FileOutputStream(report), Charset.forName("UTF-8")); - - // use RMService to get disposition authority - String dispositionAuthority = null; - if (itemsToTransfer.length > 0) - { - // use the first transfer item to get to disposition schedule - DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); - if (ds != null) - { - dispositionAuthority = ds.getDispositionAuthority(); - } - } - - // write the HTML header - writer.write("\n"); - writer.write("\n\n"); - Boolean isAccession = (Boolean)this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR); - if (isAccession) - { - writer.write("Accession Report\n"); - } - else - { - writer.write("Transfer Report\n"); - } - writer.write("\n"); - if (isAccession) - { - 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:"); - if (isAccession) - { - 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, - 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(""); - } - finally - { - if (writer != null) - { - 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 - */ - protected void generateTransferItemsHTML(Writer writer, NodeRef[] itemsToTransfer) - throws IOException - { - for (NodeRef item : itemsToTransfer) - { - writer.write("
\n"); - if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER)) - { - generateTransferFolderHTML(writer, item); - } - else - { - generateTransferRecordHTML(writer, item); - } - writer.write("
\n"); - } - } - - /** - * Generates the JSON to represent the given folder. - * - * @param writer Writer to write to - * @param folderNode Folder being transferred - * @throws IOException - */ - protected void generateTransferFolderHTML(Writer writer, NodeRef folderNode) - throws IOException - { - writer.write(""); - 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, - 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, - ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef child : assocs) - { - NodeRef childRef = child.getChildRef(); - if (this.nodeService.hasAspect(childRef, RecordsManagementModel.ASPECT_RECORD)) - { - 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 - */ - protected void generateTransferRecordHTML(Writer writer, NodeRef recordNode) - throws IOException - { - writer.write("
\n"); - writer.write(" "); - 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, - 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, - 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 - */ - protected NodeRef fileTransferReport(File report, NodeRef destination) - { - 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())), - ContentModel.TYPE_CONTENT, properties).getChildRef(); - - // Set the content - ContentWriter writer = contentService.getWriter(record, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_HTML); - writer.setEncoding("UTF-8"); - writer.putContent(report); - - return record; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Serializable; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.TempFileProvider; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Files a transfer report as a record. + * + * @author Gavin Cornwell + */ +@Deprecated +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"; + protected static final String RESPONSE_SUCCESS = "success"; + protected static final String RESPONSE_RECORD = "record"; + protected static final String RESPONSE_RECORD_NAME = "recordName"; + + protected DictionaryService ddService; + protected RecordsManagementActionService rmActionService; + protected DispositionService dispositionService; + protected ContentService contentService; + + /** + * Sets the DictionaryService instance + * + * @param ddService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService ddService) + { + this.ddService = ddService; + } + + /** + * 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; + } + + /** + * Sets the ContentSerivce instance + * + * @param contentService ContentService instance + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + @Override + protected File executeTransfer(NodeRef transferNode, + 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 + // a record folder + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + if (!json.has(PARAM_DESTINATION)) + { + 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, + "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, + "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, + (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); + } + catch (JSONException je) + { + 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 + */ + File generateHTMLTransferReport(NodeRef transferNode) throws IOException + { + File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); + Writer writer = null; + try + { + // get all 'transferred' nodes + NodeRef[] itemsToTransfer = getTransferNodes(transferNode); + + if (logger.isDebugEnabled()) + { + logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + + " items into file: " + report.getAbsolutePath()); + } + + // create the writer + writer = new OutputStreamWriter(new FileOutputStream(report), Charset.forName("UTF-8")); + + // use RMService to get disposition authority + String dispositionAuthority = null; + if (itemsToTransfer.length > 0) + { + // use the first transfer item to get to disposition schedule + DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); + if (ds != null) + { + dispositionAuthority = ds.getDispositionAuthority(); + } + } + + // write the HTML header + writer.write("\n"); + writer.write("\n\n"); + Boolean isAccession = (Boolean)this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR); + if (isAccession) + { + writer.write("Accession Report\n"); + } + else + { + writer.write("Transfer Report\n"); + } + writer.write("\n"); + if (isAccession) + { + 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:"); + if (isAccession) + { + 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, + 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(""); + } + finally + { + if (writer != null) + { + 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 + */ + protected void generateTransferItemsHTML(Writer writer, NodeRef[] itemsToTransfer) + throws IOException + { + for (NodeRef item : itemsToTransfer) + { + writer.write("
\n"); + if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER)) + { + generateTransferFolderHTML(writer, item); + } + else + { + generateTransferRecordHTML(writer, item); + } + writer.write("
\n"); + } + } + + /** + * Generates the JSON to represent the given folder. + * + * @param writer Writer to write to + * @param folderNode Folder being transferred + * @throws IOException + */ + protected void generateTransferFolderHTML(Writer writer, NodeRef folderNode) + throws IOException + { + writer.write(""); + 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, + 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, + ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef child : assocs) + { + NodeRef childRef = child.getChildRef(); + if (this.nodeService.hasAspect(childRef, RecordsManagementModel.ASPECT_RECORD)) + { + 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 + */ + protected void generateTransferRecordHTML(Writer writer, NodeRef recordNode) + throws IOException + { + writer.write("
\n"); + writer.write(" "); + 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, + 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, + 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 + */ + protected NodeRef fileTransferReport(File report, NodeRef destination) + { + 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())), + ContentModel.TYPE_CONTENT, properties).getChildRef(); + + // Set the content + ContentWriter writer = contentService.getWriter(record, ContentModel.PROP_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_HTML); + writer.setEncoding("UTF-8"); + writer.putContent(report); + + return record; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java index 88ca563b53..955fe2f097 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java @@ -1,345 +1,345 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PersonService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to return user rights report. - * - * @author Gavin Cornwell - */ -public class UserRightsReportGet extends DeclarativeWebScript -{ - protected AuthorityService authorityService; - protected PersonService personService; - protected NodeService nodeService; - protected FilePlanRoleService filePlanRoleService; - protected FilePlanService filePlanService; - - /** - * Sets the AuthorityService instance - * - * @param authorityService AuthorityService instance - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * Sets the PersonService instance - * - * @param personService PersonService instance - */ - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - /** - * Sets the NodeService instance - * - * @param nodeService NodeService instance - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - NodeRef filePlanNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - if (filePlanNode == null) - { - status.setCode(HttpServletResponse.SC_BAD_REQUEST, - "The default RM site could not be found."); - return null; - } - - // construct all the maps etc. needed to build the model - Map usersMap = new HashMap(8); - Map rolesMap = new HashMap(8); - Map groupsMap = new HashMap(8); - - // iterate over all the roles for the file plan and construct models - Set roles = filePlanRoleService.getRoles(filePlanNode); - for (Role role : roles) - { - // get or create the RoleModel object for current role - String roleName = role.getName(); - RoleModel roleModel = rolesMap.get(roleName); - if (roleModel == null) - { - roleModel = new RoleModel(role); - rolesMap.put(roleName, roleModel); - } - - // get the users for the current RM role - String group = role.getRoleGroupName(); - Set users = authorityService.getContainedAuthorities(AuthorityType.USER, group, false); - roleModel.setUsers(users); - - // setup a user model object for each user - for (String userName : users) - { - UserModel userModel = usersMap.get(userName); - if (userModel == null) - { - NodeRef userRef = this.personService.getPerson(userName); - userModel = new UserModel(userName, - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); - usersMap.put(userName, userModel); - } - - userModel.addRole(roleName); - } - - // get the groups for the cuurent RM role - Set groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, group, false); - roleModel.setGroups(groups); - - // setup a user model object for each user in each group - for (String groupName : groups) - { - GroupModel groupModel = groupsMap.get(groupName); - if (groupModel == null) - { - groupModel = new GroupModel(groupName, - authorityService.getAuthorityDisplayName(groupName)); - groupsMap.put(groupName, groupModel); - } - - // get users in each group - Set groupUsers = this.authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); - for (String userName : groupUsers) - { - UserModel userModel = usersMap.get(userName); - if (userModel == null) - { - NodeRef userRef = this.personService.getPerson(userName); - userModel = new UserModel(userName, - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); - usersMap.put(userName, userModel); - } - - userModel.addGroup(groupName); - userModel.addRole(roleName); - groupModel.addUser(userName); - } - } - } - - // add all the lists data to a Map - Map reportModel = new HashMap(4); - reportModel.put("users", usersMap); - reportModel.put("roles", rolesMap); - reportModel.put("groups", groupsMap); - - // create model object with the lists model - Map model = new HashMap(1); - model.put("report", reportModel); - return model; - } - - /** - * Class to represent a role for use in a Freemarker template. - * - * @author Gavin Cornwell - */ - public class RoleModel extends Role - { - private Set users = new HashSet(8); - private Set groups = new HashSet(8); - - public RoleModel(Role role) - { - super(role.getName(), role.getDisplayLabel(), role.getCapabilities(), role.getRoleGroupName()); - } - - public void addUser(String username) - { - this.users.add(username); - } - - public void addGroup(String groupName) - { - this.groups.add(groupName); - } - - public void setUsers(Set users) - { - this.users = users; - } - - public void setGroups(Set groups) - { - this.groups = groups; - } - - public Set getUsers() - { - return this.users; - } - - public Set getGroups() - { - return this.groups; - } - } - - /** - * Class to represent a user for use in a Freemarker template. - * - * @author Gavin Cornwell - */ - public class UserModel - { - private String userName; - private String firstName; - private String lastName; - private Set roles; - private Set groups; - - public UserModel(String userName, String firstName, String lastName) - { - this.userName = userName; - this.firstName = firstName; - this.lastName = lastName; - this.roles = new HashSet(2); - this.groups = new HashSet(2); - } - - public String getUserName() - { - return this.userName; - } - - public String getFirstName() - { - return this.firstName; - } - - public String getLastName() - { - return this.lastName; - } - - public Set getRoles() - { - return this.roles; - } - - public Set getGroups() - { - return this.groups; - } - - public void addRole(String roleName) - { - this.roles.add(roleName); - } - - public void addGroup(String groupName) - { - this.groups.add(groupName); - } - } - - /** - * Class to represent a group for use in a Freemarker template. - * - * @author Gavin Cornwell - */ - public class GroupModel - { - private String name; - private String label; - private Set users; - - public GroupModel(String name, String label) - { - this.name = name; - this.label = label; - this.users = new HashSet(4); - } - - public String getName() - { - return this.name; - } - - public String getDisplayLabel() - { - return this.label; - } - - public Set getUsers() - { - return this.users; - } - - public void addUser(String userName) - { - this.users.add(userName); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PersonService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to return user rights report. + * + * @author Gavin Cornwell + */ +public class UserRightsReportGet extends DeclarativeWebScript +{ + protected AuthorityService authorityService; + protected PersonService personService; + protected NodeService nodeService; + protected FilePlanRoleService filePlanRoleService; + protected FilePlanService filePlanService; + + /** + * Sets the AuthorityService instance + * + * @param authorityService AuthorityService instance + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * Sets the PersonService instance + * + * @param personService PersonService instance + */ + public void setPersonService(PersonService personService) + { + this.personService = personService; + } + + /** + * Sets the NodeService instance + * + * @param nodeService NodeService instance + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + NodeRef filePlanNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + if (filePlanNode == null) + { + status.setCode(HttpServletResponse.SC_BAD_REQUEST, + "The default RM site could not be found."); + return null; + } + + // construct all the maps etc. needed to build the model + Map usersMap = new HashMap(8); + Map rolesMap = new HashMap(8); + Map groupsMap = new HashMap(8); + + // iterate over all the roles for the file plan and construct models + Set roles = filePlanRoleService.getRoles(filePlanNode); + for (Role role : roles) + { + // get or create the RoleModel object for current role + String roleName = role.getName(); + RoleModel roleModel = rolesMap.get(roleName); + if (roleModel == null) + { + roleModel = new RoleModel(role); + rolesMap.put(roleName, roleModel); + } + + // get the users for the current RM role + String group = role.getRoleGroupName(); + Set users = authorityService.getContainedAuthorities(AuthorityType.USER, group, false); + roleModel.setUsers(users); + + // setup a user model object for each user + for (String userName : users) + { + UserModel userModel = usersMap.get(userName); + if (userModel == null) + { + NodeRef userRef = this.personService.getPerson(userName); + userModel = new UserModel(userName, + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); + usersMap.put(userName, userModel); + } + + userModel.addRole(roleName); + } + + // get the groups for the cuurent RM role + Set groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, group, false); + roleModel.setGroups(groups); + + // setup a user model object for each user in each group + for (String groupName : groups) + { + GroupModel groupModel = groupsMap.get(groupName); + if (groupModel == null) + { + groupModel = new GroupModel(groupName, + authorityService.getAuthorityDisplayName(groupName)); + groupsMap.put(groupName, groupModel); + } + + // get users in each group + Set groupUsers = this.authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); + for (String userName : groupUsers) + { + UserModel userModel = usersMap.get(userName); + if (userModel == null) + { + NodeRef userRef = this.personService.getPerson(userName); + userModel = new UserModel(userName, + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); + usersMap.put(userName, userModel); + } + + userModel.addGroup(groupName); + userModel.addRole(roleName); + groupModel.addUser(userName); + } + } + } + + // add all the lists data to a Map + Map reportModel = new HashMap(4); + reportModel.put("users", usersMap); + reportModel.put("roles", rolesMap); + reportModel.put("groups", groupsMap); + + // create model object with the lists model + Map model = new HashMap(1); + model.put("report", reportModel); + return model; + } + + /** + * Class to represent a role for use in a Freemarker template. + * + * @author Gavin Cornwell + */ + public class RoleModel extends Role + { + private Set users = new HashSet(8); + private Set groups = new HashSet(8); + + public RoleModel(Role role) + { + super(role.getName(), role.getDisplayLabel(), role.getCapabilities(), role.getRoleGroupName()); + } + + public void addUser(String username) + { + this.users.add(username); + } + + public void addGroup(String groupName) + { + this.groups.add(groupName); + } + + public void setUsers(Set users) + { + this.users = users; + } + + public void setGroups(Set groups) + { + this.groups = groups; + } + + public Set getUsers() + { + return this.users; + } + + public Set getGroups() + { + return this.groups; + } + } + + /** + * Class to represent a user for use in a Freemarker template. + * + * @author Gavin Cornwell + */ + public class UserModel + { + private String userName; + private String firstName; + private String lastName; + private Set roles; + private Set groups; + + public UserModel(String userName, String firstName, String lastName) + { + this.userName = userName; + this.firstName = firstName; + this.lastName = lastName; + this.roles = new HashSet(2); + this.groups = new HashSet(2); + } + + public String getUserName() + { + return this.userName; + } + + public String getFirstName() + { + return this.firstName; + } + + public String getLastName() + { + return this.lastName; + } + + public Set getRoles() + { + return this.roles; + } + + public Set getGroups() + { + return this.groups; + } + + public void addRole(String roleName) + { + this.roles.add(roleName); + } + + public void addGroup(String groupName) + { + this.groups.add(groupName); + } + } + + /** + * Class to represent a group for use in a Freemarker template. + * + * @author Gavin Cornwell + */ + public class GroupModel + { + private String name; + private String label; + private Set users; + + public GroupModel(String name, String label) + { + this.name = name; + this.label = label; + this.users = new HashSet(4); + } + + public String getName() + { + return this.name; + } + + public String getDisplayLabel() + { + return this.label; + } + + public Set getUsers() + { + return this.users; + } + + public void addUser(String userName) + { + this.users.add(userName); + } + } } \ No newline at end of file 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 index 228aaf0763..bfbe352b89 100644 --- 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 @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.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)) - { - 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); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.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)) + { + 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/RmEventDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java index 8d8dad6dfa..4a573e78ed 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.Map; - -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; - -/** - * Records management event delete web script - * - * @author Roy Wetherall - */ -public class RmEventDelete extends DeclarativeWebScript -{ - /** Reccords management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - this.rmEventService = rmEventService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - // 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)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); - } - - // Remove the event - rmEventService.removeEvent(eventName); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.Map; + +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; + +/** + * Records management event delete web script + * + * @author Roy Wetherall + */ +public class RmEventDelete extends DeclarativeWebScript +{ + /** Reccords management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + this.rmEventService = rmEventService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + // 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)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); + } + + // Remove the event + rmEventService.removeEvent(eventName); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java index d55310b4cb..2d7fd7ac26 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -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.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; - -/** - * Records management event GET web script - * - * @author Roy Wetherall - */ -public class RmEventGet extends DeclarativeWebScript -{ - /** Reccords management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - this.rmEventService = rmEventService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - // 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)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); - } - - // Get the event - RecordsManagementEvent event = rmEventService.getEvent(eventName); - model.put("event", event); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +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.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; + +/** + * Records management event GET web script + * + * @author Roy Wetherall + */ +public class RmEventGet extends DeclarativeWebScript +{ + /** Reccords management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + this.rmEventService = rmEventService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + // 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)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); + } + + // Get the event + RecordsManagementEvent event = rmEventService.getEvent(eventName); + model.put("event", event); + + return model; + } } \ No newline at end of file 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 3235b1b607..c6f99bd6c9 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 @@ -1,148 +1,148 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -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.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 RMEventBase -{ - /** Parameter names */ - public static final String PARAM_EVENTNAME = "eventname"; - - /** Records management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - 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) - { - 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())); - - // Check the event name - Map templateVars = req.getServiceMatch().getTemplateVars(); - String eventName = templateVars.get(PARAM_EVENTNAME); - if (eventName == null || - eventName.isEmpty() || - !rmEventService.existsEvent(eventName)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided."); - } - - // Check the event display label - 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, eventType)) - { - // Create event - event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); - } - else - { - // Get event - event = rmEventService.getEvent(eventName); - } - - model.put("event", event); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - 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 - * @param eventType The type of the event - * @return true if the event can be edited, false otherwise - */ - private boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) - { - boolean canEditEvent; - - try - { - canEditEvent = rmEventService.canEditEvent(eventDisplayLabel, eventName, eventType); - } - catch (AlfrescoRuntimeException are) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage(), are); - } - - return canEditEvent; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +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.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 RMEventBase +{ + /** Parameter names */ + public static final String PARAM_EVENTNAME = "eventname"; + + /** Records management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + 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) + { + 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())); + + // Check the event name + Map templateVars = req.getServiceMatch().getTemplateVars(); + String eventName = templateVars.get(PARAM_EVENTNAME); + if (eventName == null || + eventName.isEmpty() || + !rmEventService.existsEvent(eventName)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided."); + } + + // Check the event display label + 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, eventType)) + { + // Create event + event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); + } + else + { + // Get event + event = rmEventService.getEvent(eventName); + } + + model.put("event", event); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + 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 + * @param eventType The type of the event + * @return true if the event can be edited, false otherwise + */ + private boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) + { + boolean canEditEvent; + + try + { + canEditEvent = rmEventService.canEditEvent(eventDisplayLabel, eventName, eventType); + } + catch (AlfrescoRuntimeException are) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage(), are); + } + + return canEditEvent; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java index f4d213904d..f1688f6403 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Records management event types GET web script - * - * @author Roy Wetherall - */ -public class RmEventTypesGet extends DeclarativeWebScript -{ - /** Reccords management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - this.rmEventService = rmEventService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - // Get the events - List events = rmEventService.getEventTypes(); - model.put("eventtypes", events); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Records management event types GET web script + * + * @author Roy Wetherall + */ +public class RmEventTypesGet extends DeclarativeWebScript +{ + /** Reccords management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + this.rmEventService = rmEventService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + // Get the events + List events = rmEventService.getEventTypes(); + model.put("eventtypes", events); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java index 2a7caf2282..770a45c1ce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.List; -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.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Records management events GET web script - * - * @author Roy Wetherall - */ -public class RmEventsGet extends DeclarativeWebScript -{ - /** Reccords management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - this.rmEventService = rmEventService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - // Get the events - List events = rmEventService.getEvents(); - model.put("events", events); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.List; +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.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Records management events GET web script + * + * @author Roy Wetherall + */ +public class RmEventsGet extends DeclarativeWebScript +{ + /** Reccords management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + this.rmEventService = rmEventService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + // Get the events + List events = rmEventService.getEvents(); + model.put("events", events); + + return model; + } } \ 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 cff5349f4f..967160d6d0 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 @@ -1,148 +1,148 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.io.IOException; -import java.util.HashMap; -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.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 RMEventBase -{ - /** Records management event service */ - private RecordsManagementEventService rmEventService; - - /** - * Set the records management event service - * - * @param rmEventService - */ - public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) - { - 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) - { - 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())); - - // 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) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - 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)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Cannot create event. An event with the display label '" - + eventDisplayLabel + "' already exists."); - } - - return canCreateEvent; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.io.IOException; +import java.util.HashMap; +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.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 RMEventBase +{ + /** Records management event service */ + private RecordsManagementEventService rmEventService; + + /** + * Set the records management event service + * + * @param rmEventService + */ + public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) + { + 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) + { + 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())); + + // 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) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + 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)) + { + 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 diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java index d54139b429..fbdf82ccb4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Delete role web script - * - * @author Roy Wetherall - */ -public class RmRoleDelete extends RoleDeclarativeWebScript -{ - /** - * @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(); - - // Role name - Map templateVars = req.getServiceMatch().getTemplateVars(); - String roleParam = templateVars.get("rolename"); - if (StringUtils.isBlank(roleParam)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); - } - - // get the file plan - NodeRef filePlan = getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); - } - - // Check that the role exists - if (!filePlanRoleService.existsRole(filePlan, roleParam)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, - "The role " + roleParam + " does not exist on the records managment root " + filePlan.toString()); - } - - filePlanRoleService.deleteRole(filePlan, roleParam); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Delete role web script + * + * @author Roy Wetherall + */ +public class RmRoleDelete extends RoleDeclarativeWebScript +{ + /** + * @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(); + + // Role name + Map templateVars = req.getServiceMatch().getTemplateVars(); + String roleParam = templateVars.get("rolename"); + if (StringUtils.isBlank(roleParam)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); + } + + // get the file plan + NodeRef filePlan = getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); + } + + // Check that the role exists + if (!filePlanRoleService.existsRole(filePlan, roleParam)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, + "The role " + roleParam + " does not exist on the records managment root " + filePlan.toString()); + } + + filePlanRoleService.deleteRole(filePlan, roleParam); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java index 61d25a0e8e..89c6c46a8a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Role GET web script API - * - * @author Roy Wetherall - */ -public class RmRoleGet extends RoleDeclarativeWebScript -{ - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - - // Role name - Map templateVars = req.getServiceMatch().getTemplateVars(); - String roleParam = templateVars.get("rolename"); - if (roleParam == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); - } - - // get the file plan - NodeRef filePlan = getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); - } - - // Check that the role exists - if (!filePlanRoleService.existsRole(filePlan, roleParam)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, - "The role " + roleParam + " does not exist on the records managment root " + filePlan); - } - - RoleItem item = new RoleItem(filePlanRoleService.getRole(filePlan, roleParam)); - model.put("role", item); - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Role GET web script API + * + * @author Roy Wetherall + */ +public class RmRoleGet extends RoleDeclarativeWebScript +{ + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + // Role name + Map templateVars = req.getServiceMatch().getTemplateVars(); + String roleParam = templateVars.get("rolename"); + if (roleParam == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); + } + + // get the file plan + NodeRef filePlan = getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); + } + + // Check that the role exists + if (!filePlanRoleService.existsRole(filePlan, roleParam)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, + "The role " + roleParam + " does not exist on the records managment root " + filePlan); + } + + RoleItem item = new RoleItem(filePlanRoleService.getRole(filePlan, roleParam)); + model.put("role", item); + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java index 69570b9363..be4ae2b295 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java @@ -1,114 +1,114 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.json.JSONArray; -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; - -/** - * - * - * @author Roy Wetherall - */ -public class RmRolePut extends RoleDeclarativeWebScript -{ - private CapabilityService capabilityService; - - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - JSONObject json = null; - try - { - // Role name - Map templateVars = req.getServiceMatch().getTemplateVars(); - String roleParam = templateVars.get("rolename"); - if (roleParam == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); - } - - json = new JSONObject(new JSONTokener(req.getContent().getContent())); - String name = json.getString("name"); - // TODO check - String displayLabel = json.getString("displayLabel"); - // TODO check - - JSONArray capabilitiesArray = json.getJSONArray("capabilities"); - Set capabilites = new HashSet(capabilitiesArray.length()); - for (int i = 0; i < capabilitiesArray.length(); i++) - { - Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); - capabilites.add(capability); - } - - // get the file plan - NodeRef filePlan = getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); - } - - // Check that the role exists - if (!filePlanRoleService.existsRole(filePlan, roleParam)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, - "The role " + roleParam + " does not exist on the records managment root " + filePlan); - } - - Role role = filePlanRoleService.updateRole(filePlan, name, displayLabel, capabilites); - model.put("role", new RoleItem(role)); - - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.json.JSONArray; +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; + +/** + * + * + * @author Roy Wetherall + */ +public class RmRolePut extends RoleDeclarativeWebScript +{ + private CapabilityService capabilityService; + + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + JSONObject json = null; + try + { + // Role name + Map templateVars = req.getServiceMatch().getTemplateVars(); + String roleParam = templateVars.get("rolename"); + if (roleParam == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); + } + + json = new JSONObject(new JSONTokener(req.getContent().getContent())); + String name = json.getString("name"); + // TODO check + String displayLabel = json.getString("displayLabel"); + // TODO check + + JSONArray capabilitiesArray = json.getJSONArray("capabilities"); + Set capabilites = new HashSet(capabilitiesArray.length()); + for (int i = 0; i < capabilitiesArray.length(); i++) + { + Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); + capabilites.add(capability); + } + + // get the file plan + NodeRef filePlan = getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); + } + + // Check that the role exists + if (!filePlanRoleService.existsRole(filePlan, roleParam)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, + "The role " + roleParam + " does not exist on the records managment root " + filePlan); + } + + Role role = filePlanRoleService.updateRole(filePlan, name, displayLabel, capabilites); + model.put("role", new RoleItem(role)); + + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java index 2e03317e46..f6a145d0f2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java @@ -1,86 +1,86 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Get information about record management roles - * - * @author Roy Wetherall - */ -public class RmRolesGet extends RoleDeclarativeWebScript -{ - /** - * @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(); - Set roles = null; - - // get the file plan - NodeRef filePlan = getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_FOUND, "File plan does not exist."); - } - - // get the includesystem parameter - boolean includeSystem = false; - String includeSystemValue = req.getParameter("is"); - if (includeSystemValue != null && includeSystemValue.length() != 0) - { - includeSystem = Boolean.parseBoolean(includeSystemValue); - } - - // get the user filter - String user = req.getParameter("user"); - if (user != null && user.length() != 0) - { - roles = filePlanRoleService.getRolesByUser(filePlan, user, includeSystem); - } - else - { - roles = filePlanRoleService.getRoles(filePlan, includeSystem); - } - - // get the auths parameter - boolean showAuths = false; - String auths = req.getParameter("auths"); - if (auths != null && auths.length() != 0) - { - showAuths = Boolean.parseBoolean(auths); - } - - Set items = createRoleItems(filePlan, roles, showAuths); - model.put("roles", items); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Get information about record management roles + * + * @author Roy Wetherall + */ +public class RmRolesGet extends RoleDeclarativeWebScript +{ + /** + * @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(); + Set roles = null; + + // get the file plan + NodeRef filePlan = getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_FOUND, "File plan does not exist."); + } + + // get the includesystem parameter + boolean includeSystem = false; + String includeSystemValue = req.getParameter("is"); + if (includeSystemValue != null && includeSystemValue.length() != 0) + { + includeSystem = Boolean.parseBoolean(includeSystemValue); + } + + // get the user filter + String user = req.getParameter("user"); + if (user != null && user.length() != 0) + { + roles = filePlanRoleService.getRolesByUser(filePlan, user, includeSystem); + } + else + { + roles = filePlanRoleService.getRoles(filePlan, includeSystem); + } + + // get the auths parameter + boolean showAuths = false; + String auths = req.getParameter("auths"); + if (auths != null && auths.length() != 0) + { + showAuths = Boolean.parseBoolean(auths); + } + + Set items = createRoleItems(filePlan, roles, showAuths); + model.put("roles", items); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java index a7f446982d..4025c79ff2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java @@ -1,99 +1,99 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.json.JSONArray; -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; - -/** - * RM Roles Post implementation - * - * @author Roy Wetherall - */ -public class RmRolesPost extends RoleDeclarativeWebScript -{ - private CapabilityService capabilityService; - - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - JSONObject json = null; - try - { - json = new JSONObject(new JSONTokener(req.getContent().getContent())); - String name = json.getString("name"); - // TODO check - String displayString = json.getString("displayLabel"); - // TODO check - - JSONArray capabilitiesArray = json.getJSONArray("capabilities"); - Set capabilites = new HashSet(capabilitiesArray.length()); - for (int i = 0; i < capabilitiesArray.length(); i++) - { - Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); - capabilites.add(capability); - } - - // get the file plan - NodeRef filePlan = getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); - } - - Role role = filePlanRoleService.createRole(filePlan, name, displayString, capabilites); - model.put("role", new RoleItem(role)); - - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.json.JSONArray; +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; + +/** + * RM Roles Post implementation + * + * @author Roy Wetherall + */ +public class RmRolesPost extends RoleDeclarativeWebScript +{ + private CapabilityService capabilityService; + + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + JSONObject json = null; + try + { + json = new JSONObject(new JSONTokener(req.getContent().getContent())); + String name = json.getString("name"); + // TODO check + String displayString = json.getString("displayLabel"); + // TODO check + + JSONArray capabilitiesArray = json.getJSONArray("capabilities"); + Set capabilites = new HashSet(capabilitiesArray.length()); + for (int i = 0; i < capabilitiesArray.length(); i++) + { + Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); + capabilites.add(capability); + } + + // get the file plan + NodeRef filePlan = getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); + } + + Role role = filePlanRoleService.createRole(filePlan, name, displayString, capabilites); + model.put("role", new RoleItem(role)); + + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java index b1085475e4..2c592ffd74 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java @@ -1,284 +1,284 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.admin; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Base declarative web script for role API. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RoleDeclarativeWebScript extends DeclarativeWebScript -{ - /** File plan service */ - protected FilePlanService filePlanService; - - /** File plan role service */ - protected FilePlanRoleService filePlanRoleService; - - /** Authority service */ - protected AuthorityService authorityService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * Utility method to get the file plan from the passed parameters. - * - * @param req - * @return - */ - protected NodeRef getFilePlan(WebScriptRequest req) - { - NodeRef filePlan = null; - - Map templateVars = req.getServiceMatch().getTemplateVars(); - String siteId = templateVars.get("siteid"); - if (siteId != null) - { - filePlan = filePlanService.getFilePlanBySiteId(siteId); - } - - if (filePlan == null) - { - String storeType = templateVars.get("store_type"); - String storeId = templateVars.get("store_id"); - String id = templateVars.get("id"); - - if (!StringUtils.isEmpty(storeType) && - !StringUtils.isEmpty(storeId) && - !StringUtils.isEmpty(id)) - { - StoreRef storeRef = new StoreRef(storeType, storeId); - NodeRef nodeRef = new NodeRef(storeRef, id); - if (filePlanService.isFilePlan(nodeRef)) - { - filePlan = nodeRef; - } - } - } - - if (filePlan == null) - { - // Assume we are in a legacy repository and we will grab the default file plan - filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - - return filePlan; - } - - /** - * Create role items - * - * @param filePlan - * @param roles - * @return - */ - protected Set createRoleItems(NodeRef filePlan, Set roles) - { - return createRoleItems(filePlan, roles, false); - } - - /** - * Create role items - * - * @param filePlan - * @param roles - * @param showAuths - * @return - */ - protected Set createRoleItems(NodeRef filePlan, Set roles, boolean showAuths) - { - Set items = new HashSet(roles.size()); - for (Role role : roles) - { - RoleItem item = null; - if (showAuths) - { - item = new RoleItem(role, - createAuthorityItems(filePlanRoleService.getUsersAssignedToRole(filePlan, role.getName())), - createAuthorityItems(filePlanRoleService.getGroupsAssignedToRole(filePlan, role.getName()))); - } - else - { - item = new RoleItem(role); - } - items.add(item); - } - return items; - } - - /** - * Create authority items - * - * @param authorities - * @return - */ - private Set createAuthorityItems(Set authorities) - { - Set result = new HashSet(authorities.size()); - - for (String authority : authorities) - { - String displayLabel = authority; - if (!AuthorityType.getAuthorityType(authority).equals(AuthorityType.USER)) - { - displayLabel = authorityService.getAuthorityDisplayName(authority); - } - result.add(new AuthorityItem(authority, displayLabel)); - } - - return result; - } - - /** - * Role Item Helper Class - * - * @author Roy Wetherall - * @since 2.1 - */ - public class RoleItem - { - private String name; - private String groupShortName; - private String displayLabel; - private Set capabilities; - private boolean showAuths = false; - private Set assignedUsers; - private Set assignedGroups; - - public RoleItem(Role role) - { - this.name = role.getName(); - this.displayLabel = role.getDisplayLabel(); - this.capabilities = role.getCapabilities(); - } - - public RoleItem(Role role, Set assignedUsers, Set assignedGroups) - { - this.name = role.getName(); - this.groupShortName = role.getGroupShortName(); - this.displayLabel = role.getDisplayLabel(); - this.capabilities = role.getCapabilities(); - this.showAuths = true; - this.assignedUsers = assignedUsers; - this.assignedGroups = assignedGroups; - } - - public String getName() - { - return name; - } - - public String getGroupShortName() - { - return groupShortName; - } - - public String getDisplayLabel() - { - return displayLabel; - } - - public Set getCapabilities() - { - return capabilities; - } - - public boolean getShowAuths() - { - return showAuths; - } - - public Set getAssignedGroups() - { - return assignedGroups; - } - - public Set getAssignedUsers() - { - return assignedUsers; - } - } - - /** - * Authority Item Helper Class - * - * @author Roy Wetherall - * @since 2.1 - */ - public class AuthorityItem - { - private String name; - private String displayLabel; - - public AuthorityItem(String name, String displayLabel) - { - this.name = name; - this.displayLabel = displayLabel; - } - - public String getName() - { - return name; - } - - public String getDisplayLabel() - { - return displayLabel; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Base declarative web script for role API. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RoleDeclarativeWebScript extends DeclarativeWebScript +{ + /** File plan service */ + protected FilePlanService filePlanService; + + /** File plan role service */ + protected FilePlanRoleService filePlanRoleService; + + /** Authority service */ + protected AuthorityService authorityService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * Utility method to get the file plan from the passed parameters. + * + * @param req + * @return + */ + protected NodeRef getFilePlan(WebScriptRequest req) + { + NodeRef filePlan = null; + + Map templateVars = req.getServiceMatch().getTemplateVars(); + String siteId = templateVars.get("siteid"); + if (siteId != null) + { + filePlan = filePlanService.getFilePlanBySiteId(siteId); + } + + if (filePlan == null) + { + String storeType = templateVars.get("store_type"); + String storeId = templateVars.get("store_id"); + String id = templateVars.get("id"); + + if (!StringUtils.isEmpty(storeType) && + !StringUtils.isEmpty(storeId) && + !StringUtils.isEmpty(id)) + { + StoreRef storeRef = new StoreRef(storeType, storeId); + NodeRef nodeRef = new NodeRef(storeRef, id); + if (filePlanService.isFilePlan(nodeRef)) + { + filePlan = nodeRef; + } + } + } + + if (filePlan == null) + { + // Assume we are in a legacy repository and we will grab the default file plan + filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + + return filePlan; + } + + /** + * Create role items + * + * @param filePlan + * @param roles + * @return + */ + protected Set createRoleItems(NodeRef filePlan, Set roles) + { + return createRoleItems(filePlan, roles, false); + } + + /** + * Create role items + * + * @param filePlan + * @param roles + * @param showAuths + * @return + */ + protected Set createRoleItems(NodeRef filePlan, Set roles, boolean showAuths) + { + Set items = new HashSet(roles.size()); + for (Role role : roles) + { + RoleItem item = null; + if (showAuths) + { + item = new RoleItem(role, + createAuthorityItems(filePlanRoleService.getUsersAssignedToRole(filePlan, role.getName())), + createAuthorityItems(filePlanRoleService.getGroupsAssignedToRole(filePlan, role.getName()))); + } + else + { + item = new RoleItem(role); + } + items.add(item); + } + return items; + } + + /** + * Create authority items + * + * @param authorities + * @return + */ + private Set createAuthorityItems(Set authorities) + { + Set result = new HashSet(authorities.size()); + + for (String authority : authorities) + { + String displayLabel = authority; + if (!AuthorityType.getAuthorityType(authority).equals(AuthorityType.USER)) + { + displayLabel = authorityService.getAuthorityDisplayName(authority); + } + result.add(new AuthorityItem(authority, displayLabel)); + } + + return result; + } + + /** + * Role Item Helper Class + * + * @author Roy Wetherall + * @since 2.1 + */ + public class RoleItem + { + private String name; + private String groupShortName; + private String displayLabel; + private Set capabilities; + private boolean showAuths = false; + private Set assignedUsers; + private Set assignedGroups; + + public RoleItem(Role role) + { + this.name = role.getName(); + this.displayLabel = role.getDisplayLabel(); + this.capabilities = role.getCapabilities(); + } + + public RoleItem(Role role, Set assignedUsers, Set assignedGroups) + { + this.name = role.getName(); + this.groupShortName = role.getGroupShortName(); + this.displayLabel = role.getDisplayLabel(); + this.capabilities = role.getCapabilities(); + this.showAuths = true; + this.assignedUsers = assignedUsers; + this.assignedGroups = assignedGroups; + } + + public String getName() + { + return name; + } + + public String getGroupShortName() + { + return groupShortName; + } + + public String getDisplayLabel() + { + return displayLabel; + } + + public Set getCapabilities() + { + return capabilities; + } + + public boolean getShowAuths() + { + return showAuths; + } + + public Set getAssignedGroups() + { + return assignedGroups; + } + + public Set getAssignedUsers() + { + return assignedUsers; + } + } + + /** + * Authority Item Helper Class + * + * @author Roy Wetherall + * @since 2.1 + */ + public class AuthorityItem + { + private String name; + private String displayLabel; + + public AuthorityItem(String name, String displayLabel) + { + this.name = name; + this.displayLabel = displayLabel; + } + + public String getName() + { + return name; + } + + public String getDisplayLabel() + { + return displayLabel; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java index 74c7a2a3e9..4ce6640138 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java @@ -1,215 +1,215 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.capability; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import javax.servlet.http.HttpServletResponse; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.Group; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.lang.StringUtils; -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; - -/** - * Capabilities GET web service implementation. - */ -public class CapabilitiesGet extends DeclarativeWebScript -{ - /** File plan service */ - private FilePlanService filePlanService; - - /** Capability service */ - private CapabilityService capabilityService; - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - String storeType = templateVars.get("store_type"); - String storeId = templateVars.get("store_id"); - String nodeId = templateVars.get("id"); - - NodeRef nodeRef = null; - if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(nodeId)) - { - nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId); - } - else - { - // we are talking about the file plan node - // TODO we are making the assumption there is only one file plan here! - nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (nodeRef == null) - { - throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The default file plan node could not be found."); - } - } - - boolean grouped = false; - String groupedString = req.getParameter("grouped"); - if (StringUtils.isNotBlank(groupedString)) - { - grouped = Boolean.parseBoolean(groupedString); - } - - Map model = new TreeMap(); - if (grouped) - { - // Construct the map which is needed to build the model - Map groupedCapabilitiesMap = new TreeMap(); - - List groups = capabilityService.getGroups(); - for (Group group : groups) - { - String capabilityGroupTitle = group.getTitle(); - if (StringUtils.isNotBlank(capabilityGroupTitle)) - { - String capabilityGroupId = group.getId(); - - List capabilities = capabilityService.getCapabilitiesByGroupId(capabilityGroupId); - for (Capability capability : capabilities) - { - String capabilityName = capability.getName(); - String capabilityTitle = capability.getTitle(); - - if (groupedCapabilitiesMap.containsKey(capabilityGroupId)) - { - groupedCapabilitiesMap.get(capabilityGroupId).addCapability(capabilityName, capabilityTitle); - } - else - { - GroupedCapabilities groupedCapabilities = new GroupedCapabilities(capabilityGroupId, capabilityGroupTitle, capabilityName, capabilityTitle); - groupedCapabilities.addCapability(capabilityName, capabilityTitle); - groupedCapabilitiesMap.put(capabilityGroupId, groupedCapabilities); - } - } - } - } - model.put("groupedCapabilities", groupedCapabilitiesMap); - } - else - { - boolean includePrivate = false; - String includePrivateString = req.getParameter("includeAll"); - if (StringUtils.isNotBlank(includePrivateString)) - { - includePrivate = Boolean.parseBoolean(includePrivateString); - } - - Map map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate); - List list = new ArrayList(map.size()); - for (Map.Entry entry : map.entrySet()) - { - AccessStatus accessStatus = entry.getValue(); - if (!AccessStatus.DENIED.equals(accessStatus)) - { - Capability capability = entry.getKey(); - list.add(capability.getName()); - } - } - model.put("capabilities", list); - } - - return model; - } - - /** - * Class to represent grouped capabilities for use in a Freemarker template - * - */ - public class GroupedCapabilities - { - private String capabilityGroupId; - private String capabilityGroupTitle; - private String capabilityName; - private String capabilityTitle; - private Map capabilities; - - public GroupedCapabilities(String capabilityGroupId, String capabilityGroupTitle, String capabilityName, String capabilityTitle) - { - this.capabilityGroupId = capabilityGroupId; - this.capabilityGroupTitle = capabilityGroupTitle; - this.capabilityName = capabilityName; - this.capabilityTitle = capabilityTitle; - this.capabilities = new TreeMap(); - } - - public String getGroupId() - { - return this.capabilityGroupId; - } - - public String getGroupTitle() - { - return this.capabilityGroupTitle; - } - - public String getCapabilityName() - { - return this.capabilityName; - } - - public String getCapabilityTitle() - { - return this.capabilityTitle; - } - - public Map getCapabilities() - { - return this.capabilities; - } - - public void addCapability(String capabilityName, String capabilityTitle) - { - this.capabilities.put(capabilityName, capabilityTitle); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.capability; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.Group; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.apache.commons.lang.StringUtils; +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; + +/** + * Capabilities GET web service implementation. + */ +public class CapabilitiesGet extends DeclarativeWebScript +{ + /** File plan service */ + private FilePlanService filePlanService; + + /** Capability service */ + private CapabilityService capabilityService; + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map templateVars = req.getServiceMatch().getTemplateVars(); + String storeType = templateVars.get("store_type"); + String storeId = templateVars.get("store_id"); + String nodeId = templateVars.get("id"); + + NodeRef nodeRef = null; + if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(nodeId)) + { + nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId); + } + else + { + // we are talking about the file plan node + // TODO we are making the assumption there is only one file plan here! + nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (nodeRef == null) + { + throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The default file plan node could not be found."); + } + } + + boolean grouped = false; + String groupedString = req.getParameter("grouped"); + if (StringUtils.isNotBlank(groupedString)) + { + grouped = Boolean.parseBoolean(groupedString); + } + + Map model = new TreeMap(); + if (grouped) + { + // Construct the map which is needed to build the model + Map groupedCapabilitiesMap = new TreeMap(); + + List groups = capabilityService.getGroups(); + for (Group group : groups) + { + String capabilityGroupTitle = group.getTitle(); + if (StringUtils.isNotBlank(capabilityGroupTitle)) + { + String capabilityGroupId = group.getId(); + + List capabilities = capabilityService.getCapabilitiesByGroupId(capabilityGroupId); + for (Capability capability : capabilities) + { + String capabilityName = capability.getName(); + String capabilityTitle = capability.getTitle(); + + if (groupedCapabilitiesMap.containsKey(capabilityGroupId)) + { + groupedCapabilitiesMap.get(capabilityGroupId).addCapability(capabilityName, capabilityTitle); + } + else + { + GroupedCapabilities groupedCapabilities = new GroupedCapabilities(capabilityGroupId, capabilityGroupTitle, capabilityName, capabilityTitle); + groupedCapabilities.addCapability(capabilityName, capabilityTitle); + groupedCapabilitiesMap.put(capabilityGroupId, groupedCapabilities); + } + } + } + } + model.put("groupedCapabilities", groupedCapabilitiesMap); + } + else + { + boolean includePrivate = false; + String includePrivateString = req.getParameter("includeAll"); + if (StringUtils.isNotBlank(includePrivateString)) + { + includePrivate = Boolean.parseBoolean(includePrivateString); + } + + Map map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate); + List list = new ArrayList(map.size()); + for (Map.Entry entry : map.entrySet()) + { + AccessStatus accessStatus = entry.getValue(); + if (!AccessStatus.DENIED.equals(accessStatus)) + { + Capability capability = entry.getKey(); + list.add(capability.getName()); + } + } + model.put("capabilities", list); + } + + return model; + } + + /** + * Class to represent grouped capabilities for use in a Freemarker template + * + */ + public class GroupedCapabilities + { + private String capabilityGroupId; + private String capabilityGroupTitle; + private String capabilityName; + private String capabilityTitle; + private Map capabilities; + + public GroupedCapabilities(String capabilityGroupId, String capabilityGroupTitle, String capabilityName, String capabilityTitle) + { + this.capabilityGroupId = capabilityGroupId; + this.capabilityGroupTitle = capabilityGroupTitle; + this.capabilityName = capabilityName; + this.capabilityTitle = capabilityTitle; + this.capabilities = new TreeMap(); + } + + public String getGroupId() + { + return this.capabilityGroupId; + } + + public String getGroupTitle() + { + return this.capabilityGroupTitle; + } + + public String getCapabilityName() + { + return this.capabilityName; + } + + public String getCapabilityTitle() + { + return this.capabilityTitle; + } + + public Map getCapabilities() + { + return this.capabilities; + } + + public void addCapability(String capabilityName, String capabilityTitle) + { + this.capabilities.put(capabilityName, capabilityTitle); + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java index a44cdb4e2d..aeebfec864 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java @@ -1,251 +1,251 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -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; - -/** - * Base class for the hold webscripts - * - * @author Tuna Aksoy - * @since 2.2 - */ -public abstract class BaseHold extends DeclarativeWebScript -{ - /** Hold Service */ - private HoldService holdService; - - /** record service */ - private RecordService recordService; - - /** record folder service */ - private RecordFolderService recordFolderService; - - /** node service */ - private NodeService nodeService; - - /** - * Set the hold service - * - * @param holdService the hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Returns the hold service - * - * @return Returns the hold service - */ - protected HoldService getHoldService() - { - return this.holdService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - JSONObject json = getJSONFromContent(req); - List holds = getHolds(json); - List nodeRefs = getItemNodeRefs(json); - doAction(holds, nodeRefs); - return new HashMap(); - } - - /** - * Abstract method which will be implemented in the subclasses. - * It will either add the item(s) to the hold(s) or remove it/them from the hold(s) - * - * @param holds List of hold {@link NodeRef}(s) - * @param nodeRefs List of item {@link NodeRef}(s) (record(s) / record folder(s)) which will be either added to the hold(s) or removed from the hold(s) - */ - abstract void doAction(List holds, List nodeRefs); - - /** - * Helper method the get the json object from the request - * - * @param req The webscript request - * @return The json object which was sent in the request body - */ - protected JSONObject getJSONFromContent(WebScriptRequest req) - { - JSONObject json = null; - try - { - String content = req.getContent().getContent(); - json = new JSONObject(new JSONTokener(content)); - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - return json; - } - - /** - * Helper method to get the {@link NodeRef}s for the items(s) (record(s) / record folder(s)) which will be added to the hold(s) - * - * @param json The request content as JSON object - * @return List of item {@link NodeRef}s which will be added to the hold(s) - */ - protected List getItemNodeRefs(JSONObject json) - { - List nodeRefs = new ArrayList(); - try - { - JSONArray nodeRefsArray = json.getJSONArray("nodeRefs"); - for (int i = 0; i < nodeRefsArray.length(); i++) - { - NodeRef nodeReference = new NodeRef(nodeRefsArray.getString(i)); - checkItemNodeRef(nodeReference); - nodeRefs.add(nodeReference); - } - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not get information from the json array.", je); - } - - return nodeRefs; - } - - /** - * Helper method for checking the node reference for an item - * - * @param nodeRef The {@link NodeRef} of an item (record / record folder) - */ - private void checkItemNodeRef(NodeRef nodeRef) - { - // ensure that the node exists - if (!nodeService.exists(nodeRef)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Item being added to hold does not exist."); - } - - // ensure that the node we are adding to the hold is a record or record folder - if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record or record folder."); - } - } - - /** - * Helper method to get the list of {@link NodeRef}(s) for the hold(s) which will contain the item (record / record folder) - * - * @param json The request content as JSON object - * @return List of {@link NodeRef}(s) of the hold(s) - */ - protected List getHolds(JSONObject json) - { - List holds = new ArrayList(); - try - { - JSONArray holdsArray = json.getJSONArray("holds"); - for (int i = 0; i < holdsArray.length(); i++) - { - NodeRef nodeRef = new NodeRef(holdsArray.getString(i)); - checkHoldNodeRef(nodeRef); - holds.add(nodeRef); - } - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not get information from the json array.", je); - } - - return holds; - } - - /** - * Helper method for checking the node reference for a hold - * - * @param nodeRef The {@link NodeRef} of a hold - */ - private void checkHoldNodeRef(NodeRef nodeRef) - { - // check the hold exists - if (!nodeService.exists(nodeRef)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The hold does not exist."); - } - - // check the noderef is actually a hold - if (!holdService.isHold(nodeRef)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items are being added to a node that isn't a hold."); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +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; + +/** + * Base class for the hold webscripts + * + * @author Tuna Aksoy + * @since 2.2 + */ +public abstract class BaseHold extends DeclarativeWebScript +{ + /** Hold Service */ + private HoldService holdService; + + /** record service */ + private RecordService recordService; + + /** record folder service */ + private RecordFolderService recordFolderService; + + /** node service */ + private NodeService nodeService; + + /** + * Set the hold service + * + * @param holdService the hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Returns the hold service + * + * @return Returns the hold service + */ + protected HoldService getHoldService() + { + return this.holdService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + JSONObject json = getJSONFromContent(req); + List holds = getHolds(json); + List nodeRefs = getItemNodeRefs(json); + doAction(holds, nodeRefs); + return new HashMap(); + } + + /** + * Abstract method which will be implemented in the subclasses. + * It will either add the item(s) to the hold(s) or remove it/them from the hold(s) + * + * @param holds List of hold {@link NodeRef}(s) + * @param nodeRefs List of item {@link NodeRef}(s) (record(s) / record folder(s)) which will be either added to the hold(s) or removed from the hold(s) + */ + abstract void doAction(List holds, List nodeRefs); + + /** + * Helper method the get the json object from the request + * + * @param req The webscript request + * @return The json object which was sent in the request body + */ + protected JSONObject getJSONFromContent(WebScriptRequest req) + { + JSONObject json = null; + try + { + String content = req.getContent().getContent(); + json = new JSONObject(new JSONTokener(content)); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + return json; + } + + /** + * Helper method to get the {@link NodeRef}s for the items(s) (record(s) / record folder(s)) which will be added to the hold(s) + * + * @param json The request content as JSON object + * @return List of item {@link NodeRef}s which will be added to the hold(s) + */ + protected List getItemNodeRefs(JSONObject json) + { + List nodeRefs = new ArrayList(); + try + { + JSONArray nodeRefsArray = json.getJSONArray("nodeRefs"); + for (int i = 0; i < nodeRefsArray.length(); i++) + { + NodeRef nodeReference = new NodeRef(nodeRefsArray.getString(i)); + checkItemNodeRef(nodeReference); + nodeRefs.add(nodeReference); + } + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not get information from the json array.", je); + } + + return nodeRefs; + } + + /** + * Helper method for checking the node reference for an item + * + * @param nodeRef The {@link NodeRef} of an item (record / record folder) + */ + private void checkItemNodeRef(NodeRef nodeRef) + { + // ensure that the node exists + if (!nodeService.exists(nodeRef)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Item being added to hold does not exist."); + } + + // ensure that the node we are adding to the hold is a record or record folder + if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record or record folder."); + } + } + + /** + * Helper method to get the list of {@link NodeRef}(s) for the hold(s) which will contain the item (record / record folder) + * + * @param json The request content as JSON object + * @return List of {@link NodeRef}(s) of the hold(s) + */ + protected List getHolds(JSONObject json) + { + List holds = new ArrayList(); + try + { + JSONArray holdsArray = json.getJSONArray("holds"); + for (int i = 0; i < holdsArray.length(); i++) + { + NodeRef nodeRef = new NodeRef(holdsArray.getString(i)); + checkHoldNodeRef(nodeRef); + holds.add(nodeRef); + } + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not get information from the json array.", je); + } + + return holds; + } + + /** + * Helper method for checking the node reference for a hold + * + * @param nodeRef The {@link NodeRef} of a hold + */ + private void checkHoldNodeRef(NodeRef nodeRef) + { + // check the hold exists + if (!nodeService.exists(nodeRef)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The hold does not exist."); + } + + // check the noderef is actually a hold + if (!holdService.isHold(nodeRef)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items are being added to a node that isn't a hold."); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/Hold.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/Hold.java index 4079d9d8f9..1fd769acd7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/Hold.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/Hold.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Hold POJO - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class Hold -{ - /** Hold name */ - private String name; - - /** Hold node reference */ - private NodeRef nodeRef; - - /** - * Constructor - * - * @param name The name of the hold - * @param nodeRef The {@link NodeRef} of the hold - */ - public Hold(String name, NodeRef nodeRef) - { - this.name = name; - this.nodeRef = nodeRef; - } - - /** - * Gets the hold name - * - * @return The name of the hold - */ - public String getName() - { - return this.name; - } - - /** - * Gets the hold node reference - * - * @return The {@link NodeRef} of the hold - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Hold POJO + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class Hold +{ + /** Hold name */ + private String name; + + /** Hold node reference */ + private NodeRef nodeRef; + + /** + * Constructor + * + * @param name The name of the hold + * @param nodeRef The {@link NodeRef} of the hold + */ + public Hold(String name, NodeRef nodeRef) + { + this.name = name; + this.nodeRef = nodeRef; + } + + /** + * Gets the hold name + * + * @return The name of the hold + */ + public String getName() + { + return this.name; + } + + /** + * Gets the hold node reference + * + * @return The {@link NodeRef} of the hold + */ + public NodeRef getNodeRef() + { + return this.nodeRef; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java index 535831ad9c..c40361470b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Implementation for Java backed webscript to add an item to the given hold(s) in the hold container. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class HoldPost extends BaseHold -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List) - */ - @Override - void doAction(List holds, List nodeRefs) - { - getHoldService().addToHolds(holds, nodeRefs); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Implementation for Java backed webscript to add an item to the given hold(s) in the hold container. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class HoldPost extends BaseHold +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List) + */ + @Override + void doAction(List holds, List nodeRefs) + { + getHoldService().addToHolds(holds, nodeRefs); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPut.java index f63175b6fe..b16beff6e3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPut.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Implementation for Java backed webscript to remove an item from the given hold(s) in the hold container. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class HoldPut extends BaseHold -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List) - */ - @Override - void doAction(List holds, List nodeRefs) - { - getHoldService().removeFromHolds(holds, nodeRefs); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Implementation for Java backed webscript to remove an item from the given hold(s) in the hold container. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class HoldPut extends BaseHold +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List) + */ + @Override + void doAction(List holds, List nodeRefs) + { + getHoldService().removeFromHolds(holds, nodeRefs); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java index ccfb8afad5..145d01c8d7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java @@ -1,241 +1,241 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.apache.commons.lang.StringUtils; -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; - -/** - * Implementation for Java backed webscript to return the list of holds in the hold container. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class HoldsGet extends DeclarativeWebScript -{ - /** File Plan Service */ - private FilePlanService filePlanService; - - /** Node Service */ - private NodeService nodeService; - - /** Hold Service */ - private HoldService holdService; - - /** permission service */ - private PermissionService permissionService; - - /** - * Set the file plan service - * - * @param filePlanService the file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Set the node service - * - * @param nodeService the node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the hold service - * - * @param holdService the hold service - */ - public void setHoldService(HoldService holdService) - { - this.holdService = holdService; - } - - /** - * Set the permission service - * - * @param permissionService the permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - boolean fileOnly = getFileOnly(req); - NodeRef itemNodeRef = getItemNodeRef(req); - List holds = new ArrayList(); - - if (itemNodeRef == null) - { - NodeRef filePlan = getFilePlan(req); - holds.addAll(holdService.getHolds(filePlan)); - } - else - { - boolean includedInHold = getIncludedInHold(req); - holds.addAll(holdService.heldBy(itemNodeRef, includedInHold)); - } - - List holdObjects = new ArrayList(holds.size()); - for (NodeRef nodeRef : holds) - { - // only add if user has filling permisson on the hold - if (!fileOnly || permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED) - { - String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - holdObjects.add(new Hold(name, nodeRef)); - } - } - - Map model = new HashMap(1); - sortHoldByName(holdObjects); - model.put("holds", holdObjects); - - return model; - } - - /** - * Helper method to get the file plan from the request - * - * @param req The webscript request - * @return The {@link NodeRef} of the file plan - */ - private NodeRef getFilePlan(WebScriptRequest req) - { - NodeRef filePlan = null; - - Map templateVars = req.getServiceMatch().getTemplateVars(); - String storeType = templateVars.get("store_type"); - String storeId = templateVars.get("store_id"); - String id = templateVars.get("id"); - - if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(id)) - { - filePlan = new NodeRef(new StoreRef(storeType, storeId), id); - - // check that this node is actually a file plan - if (!nodeService.exists(filePlan) || !filePlanService.isFilePlan(filePlan)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The file plan provided could not be found."); - } - } - else - { - filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The default file plan node could not be found."); - } - } - - return filePlan; - } - - /** - * Helper method to get the item node reference from the request - * - * @param req The webscript request - * @return The {@link NodeRef} of the item (record / record folder) or null if the parameter has not been passed - */ - private NodeRef getItemNodeRef(WebScriptRequest req) - { - String nodeRef = req.getParameter("itemNodeRef"); - NodeRef itemNodeRef = null; - if (StringUtils.isNotBlank(nodeRef)) - { - itemNodeRef = new NodeRef(nodeRef); - } - return itemNodeRef; - } - - /** - * Helper method to get the includeInHold parameter value from the request - * - * @param req The webscript request - * @return The value of the includeInHold parameter - */ - private boolean getIncludedInHold(WebScriptRequest req) - { - boolean result = true; - String includedInHold = req.getParameter("includedInHold"); - if (StringUtils.isNotBlank(includedInHold)) - { - result = Boolean.valueOf(includedInHold).booleanValue(); - } - return result; - } - - private boolean getFileOnly(WebScriptRequest req) - { - boolean result = false; - String fillingOnly = req.getParameter("fileOnly"); - if (StringUtils.isNotBlank(fillingOnly)) - { - result = Boolean.valueOf(fillingOnly).booleanValue(); - } - return result; - } - - /** - * Helper method to sort the holds by their names - * - * @param holds List of holds to sort - */ - private void sortHoldByName(List holds) - { - Collections.sort(holds, new Comparator() - { - @Override - public int compare(Hold h1, Hold h2) - { - return h1.getName().toLowerCase().compareTo(h2.getName().toLowerCase()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.PermissionService; +import org.apache.commons.lang.StringUtils; +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; + +/** + * Implementation for Java backed webscript to return the list of holds in the hold container. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class HoldsGet extends DeclarativeWebScript +{ + /** File Plan Service */ + private FilePlanService filePlanService; + + /** Node Service */ + private NodeService nodeService; + + /** Hold Service */ + private HoldService holdService; + + /** permission service */ + private PermissionService permissionService; + + /** + * Set the file plan service + * + * @param filePlanService the file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Set the node service + * + * @param nodeService the node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set the hold service + * + * @param holdService the hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * Set the permission service + * + * @param permissionService the permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + boolean fileOnly = getFileOnly(req); + NodeRef itemNodeRef = getItemNodeRef(req); + List holds = new ArrayList(); + + if (itemNodeRef == null) + { + NodeRef filePlan = getFilePlan(req); + holds.addAll(holdService.getHolds(filePlan)); + } + else + { + boolean includedInHold = getIncludedInHold(req); + holds.addAll(holdService.heldBy(itemNodeRef, includedInHold)); + } + + List holdObjects = new ArrayList(holds.size()); + for (NodeRef nodeRef : holds) + { + // only add if user has filling permisson on the hold + if (!fileOnly || permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED) + { + String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); + holdObjects.add(new Hold(name, nodeRef)); + } + } + + Map model = new HashMap(1); + sortHoldByName(holdObjects); + model.put("holds", holdObjects); + + return model; + } + + /** + * Helper method to get the file plan from the request + * + * @param req The webscript request + * @return The {@link NodeRef} of the file plan + */ + private NodeRef getFilePlan(WebScriptRequest req) + { + NodeRef filePlan = null; + + Map templateVars = req.getServiceMatch().getTemplateVars(); + String storeType = templateVars.get("store_type"); + String storeId = templateVars.get("store_id"); + String id = templateVars.get("id"); + + if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(id)) + { + filePlan = new NodeRef(new StoreRef(storeType, storeId), id); + + // check that this node is actually a file plan + if (!nodeService.exists(filePlan) || !filePlanService.isFilePlan(filePlan)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The file plan provided could not be found."); + } + } + else + { + filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The default file plan node could not be found."); + } + } + + return filePlan; + } + + /** + * Helper method to get the item node reference from the request + * + * @param req The webscript request + * @return The {@link NodeRef} of the item (record / record folder) or null if the parameter has not been passed + */ + private NodeRef getItemNodeRef(WebScriptRequest req) + { + String nodeRef = req.getParameter("itemNodeRef"); + NodeRef itemNodeRef = null; + if (StringUtils.isNotBlank(nodeRef)) + { + itemNodeRef = new NodeRef(nodeRef); + } + return itemNodeRef; + } + + /** + * Helper method to get the includeInHold parameter value from the request + * + * @param req The webscript request + * @return The value of the includeInHold parameter + */ + private boolean getIncludedInHold(WebScriptRequest req) + { + boolean result = true; + String includedInHold = req.getParameter("includedInHold"); + if (StringUtils.isNotBlank(includedInHold)) + { + result = Boolean.valueOf(includedInHold).booleanValue(); + } + return result; + } + + private boolean getFileOnly(WebScriptRequest req) + { + boolean result = false; + String fillingOnly = req.getParameter("fileOnly"); + if (StringUtils.isNotBlank(fillingOnly)) + { + result = Boolean.valueOf(fillingOnly).booleanValue(); + } + return result; + } + + /** + * Helper method to sort the holds by their names + * + * @param holds List of holds to sort + */ + private void sortHoldByName(List holds) + { + Collections.sort(holds, new Comparator() + { + @Override + public int compare(Hold h1, Hold h2) + { + return h1.getName().toLowerCase().compareTo(h2.getName().toLowerCase()); + } + }); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesDelete.java index 5be6deca5e..7c97abe1af 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesDelete.java @@ -1,95 +1,95 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.service.cmr.site.SiteService; -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; - -/** - * Records Management saved search DELETE web script - * - * @author Roy Wetherall - */ -public class RMSavedSearchesDelete extends DeclarativeWebScript -{ - /** Records management search service */ - protected RecordsManagementSearchService recordsManagementSearchService; - - /** Site service */ - protected SiteService siteService; - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - - // Get the site id and confirm it's valid - String siteId = templateVars.get("site"); - if (siteId == null || siteId.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); - } - if (siteService.getSite(siteId) == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); - } - - // Get the name of the saved search - String name = templateVars.get("name"); - if (name == null || name.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Saved search name not provided."); - } - - // Delete the saved search - recordsManagementSearchService.deleteSavedSearch(siteId, name); - - // Indicate success in the model - Map model = new HashMap(1); - model.put("success", true); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.service.cmr.site.SiteService; +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; + +/** + * Records Management saved search DELETE web script + * + * @author Roy Wetherall + */ +public class RMSavedSearchesDelete extends DeclarativeWebScript +{ + /** Records management search service */ + protected RecordsManagementSearchService recordsManagementSearchService; + + /** Site service */ + protected SiteService siteService; + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map templateVars = req.getServiceMatch().getTemplateVars(); + + // Get the site id and confirm it's valid + String siteId = templateVars.get("site"); + if (siteId == null || siteId.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); + } + if (siteService.getSite(siteId) == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); + } + + // Get the name of the saved search + String name = templateVars.get("name"); + if (name == null || name.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Saved search name not provided."); + } + + // Delete the saved search + recordsManagementSearchService.deleteSavedSearch(siteId, name); + + // Indicate success in the model + Map model = new HashMap(1); + model.put("success", true); + return model; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesGet.java index 5ef072a309..c36671c83f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesGet.java @@ -1,149 +1,149 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; -import org.alfresco.service.cmr.site.SiteService; -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; - -/** - * RM saved searches GET web script - * - * @author Roy Wetherall - */ -public class RMSavedSearchesGet extends DeclarativeWebScript -{ - /** Records management search service */ - protected RecordsManagementSearchService recordsManagementSearchService; - - /** Site service */ - protected SiteService siteService; - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // create model object with the lists model - Map model = new HashMap(13); - - // Get the site id and confirm it is valid - Map templateVars = req.getServiceMatch().getTemplateVars(); - String siteId = templateVars.get("site"); - if (siteId == null || siteId.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); - } - if (siteService.getSite(siteId) == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); - } - - // Get the saved search details - List details = recordsManagementSearchService.getSavedSearches(siteId); - List items = new ArrayList(); - for (SavedSearchDetails savedSearchDetails : details) - { - String name = savedSearchDetails.getName(); - String description = savedSearchDetails.getDescription(); - String query = savedSearchDetails.getCompatibility().getQuery(); - String params = savedSearchDetails.getCompatibility().getParams(); - String sort = savedSearchDetails.getCompatibility().getSort(); - - Item item = new Item(name, description, query, params, sort); - items.add(item); - } - - model.put("savedSearches", items); - return model; - } - - /** - * Item class to contain information about items being placed in model. - */ - public class Item - { - private String name; - private String description; - private String query; - private String params; - private String sort; - - public Item(String name, String description, String query, String params, String sort) - { - this.name = name; - this.description = description; - this.query = query; - this.params = params; - this.sort = sort; - } - - public String getName() - { - return name; - } - - public String getDescription() - { - return description; - } - - public String getQuery() - { - return query; - } - - public String getParams() - { - return params; - } - - public String getSort() - { - return sort; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; +import org.alfresco.service.cmr.site.SiteService; +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; + +/** + * RM saved searches GET web script + * + * @author Roy Wetherall + */ +public class RMSavedSearchesGet extends DeclarativeWebScript +{ + /** Records management search service */ + protected RecordsManagementSearchService recordsManagementSearchService; + + /** Site service */ + protected SiteService siteService; + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // create model object with the lists model + Map model = new HashMap(13); + + // Get the site id and confirm it is valid + Map templateVars = req.getServiceMatch().getTemplateVars(); + String siteId = templateVars.get("site"); + if (siteId == null || siteId.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); + } + if (siteService.getSite(siteId) == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); + } + + // Get the saved search details + List details = recordsManagementSearchService.getSavedSearches(siteId); + List items = new ArrayList(); + for (SavedSearchDetails savedSearchDetails : details) + { + String name = savedSearchDetails.getName(); + String description = savedSearchDetails.getDescription(); + String query = savedSearchDetails.getCompatibility().getQuery(); + String params = savedSearchDetails.getCompatibility().getParams(); + String sort = savedSearchDetails.getCompatibility().getSort(); + + Item item = new Item(name, description, query, params, sort); + items.add(item); + } + + model.put("savedSearches", items); + return model; + } + + /** + * Item class to contain information about items being placed in model. + */ + public class Item + { + private String name; + private String description; + private String query; + private String params; + private String sort; + + public Item(String name, String description, String query, String params, String sort) + { + this.name = name; + this.description = description; + this.query = query; + this.params = params; + this.sort = sort; + } + + public String getName() + { + return name; + } + + public String getDescription() + { + return description; + } + + public String getQuery() + { + return query; + } + + public String getParams() + { + return params; + } + + public String getSort() + { + return sort; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesPost.java index aef0fa4dd3..2a065a1d06 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSavedSearchesPost.java @@ -1,159 +1,159 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetailsCompatibility; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -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; - -/** - * Records management saved search POST web script. - * - * @author Roy Wetherall - */ -public class RMSavedSearchesPost extends DeclarativeWebScript -{ - /** Records management search service */ - protected RecordsManagementSearchService recordsManagementSearchService; - - /** Site service */ - protected SiteService siteService; - - /** Namespace service */ - protected NamespaceService namespaceService; - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Get the site id and confirm it is valid - Map templateVars = req.getServiceMatch().getTemplateVars(); - String siteId = templateVars.get("site"); - if (siteId == null || siteId.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); - } - if (siteService.getSite(siteId) == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); - } - - try - { - // Parse the JSON passed in the request - JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); - - // Get the details of the saved search - if (!json.has("name")) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'name' parameter was not provided in request body"); - } - String name = json.getString("name"); - String description = null; - if (json.has("description")) - { - description = json.getString("description"); - } - boolean isPublic = true; - if (json.has("public")) - { - isPublic = json.getBoolean("public"); - } - // NOTE: we do not need to worry about the query - if (!json.has("params")) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'params' parameter was not provided in request body"); - } - String params = json.getString("params"); - String sort = null; - if (json.has("sort")) - { - sort = json.getString("sort"); - } - - // Use the compatibility class to create a saved search details and save - String search = SavedSearchDetailsCompatibility.getSearchFromParams(params); - if (search == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Mandatory 'terms' was not provided in 'params' parameter found in the request body"); - } - RecordsManagementSearchParameters searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(params, sort, namespaceService); - recordsManagementSearchService.saveSearch(siteId, name, description, search, searchParameters, isPublic); - - } - catch (IOException iox) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not read content from req.", iox); - } - catch (JSONException je) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Could not parse JSON from req.", je); - } - - // Indicate success in the model - Map model = new HashMap(1); - model.put("success", true); - return model; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetailsCompatibility; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +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; + +/** + * Records management saved search POST web script. + * + * @author Roy Wetherall + */ +public class RMSavedSearchesPost extends DeclarativeWebScript +{ + /** Records management search service */ + protected RecordsManagementSearchService recordsManagementSearchService; + + /** Site service */ + protected SiteService siteService; + + /** Namespace service */ + protected NamespaceService namespaceService; + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // Get the site id and confirm it is valid + Map templateVars = req.getServiceMatch().getTemplateVars(); + String siteId = templateVars.get("site"); + if (siteId == null || siteId.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); + } + if (siteService.getSite(siteId) == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); + } + + try + { + // Parse the JSON passed in the request + JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); + + // Get the details of the saved search + if (!json.has("name")) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'name' parameter was not provided in request body"); + } + String name = json.getString("name"); + String description = null; + if (json.has("description")) + { + description = json.getString("description"); + } + boolean isPublic = true; + if (json.has("public")) + { + isPublic = json.getBoolean("public"); + } + // NOTE: we do not need to worry about the query + if (!json.has("params")) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'params' parameter was not provided in request body"); + } + String params = json.getString("params"); + String sort = null; + if (json.has("sort")) + { + sort = json.getString("sort"); + } + + // Use the compatibility class to create a saved search details and save + String search = SavedSearchDetailsCompatibility.getSearchFromParams(params); + if (search == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Mandatory 'terms' was not provided in 'params' parameter found in the request body"); + } + RecordsManagementSearchParameters searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(params, sort, namespaceService); + recordsManagementSearchService.saveSearch(siteId, name, description, search, searchParameters, isPublic); + + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + // Indicate success in the model + Map model = new HashMap(1); + model.put("success", true); + return model; + } } \ No newline at end of file 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 3313032e8a..e504a30ad5 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 @@ -1,433 +1,433 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.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; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetailsCompatibility; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -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; - -/** - * RM search GET web script - * - * @author Roy Wetherall - */ -public class RMSearchGet extends DeclarativeWebScript -{ - /** URL Parameters */ - private static final String PARAM_QUERY = "query"; - 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; - - /** Person data cache */ - private Map personDataCache = null; - - /** - * @param recordsManagementSearchService records management search service - */ - public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) - { - this.recordsManagementSearchService = recordsManagementSearchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param personService person service - */ - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - try - { - // Get the site id and confirm it is valid - Map templateVars = req.getServiceMatch().getTemplateVars(); - String siteId = templateVars.get("site"); - if (siteId == null || siteId.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); - } - if (siteService.getSite(siteId) == null) - { - 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 = - 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 - List> results = recordsManagementSearchService.search(siteId, query, searchParameters); - - // Reset person data cache - personDataCache = new HashMap(57); - - // Process the result items - List items = new ArrayList(results.size()); - for (Pair pair : results) - { - // FIXME: See RM-478 - // TC 3-3 Create User Groups - try - { - Item item = new Item(pair.getFirst(), pair.getSecond()); - items.add(item); - } - catch(Exception e) {} - } - - // Return model - model.put("items", items); - } - catch (Exception ex) - { - model.put("errorMessage", ex.toString()); - } - return model; - - } - - /** - * Item class to contain information about items being placed in model. - */ - public class Item - { - private NodeRef nodeRef; - private String type; - private int size; - private String parentFolder = ""; - private String browseUrl; - private boolean isContainer; - private String modifiedBy; - private String createdBy; - private Map nodeProperties; - private Map properties; - - public Item(NodeRef parent, 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)) - { - isContainer = false; - } - - // Get parent node reference -// NodeRef parent = null; -// ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); -// if (assoc != null) -// { -// parent = assoc.getParentRef(); -// } - - if (isContainer) - { - this.size = -1; - - String displayPath = nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService); - String[] pathElements = displayPath.split("/"); - if (pathElements.length >= 5) - { - if (pathElements.length > 5) - { - 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); - if (relPath.length() > 1) - { - relPath.append("/"); - } - relPath.append(getName()); - try - { - this.browseUrl = "documentlibrary?path=" + URLEncoder.encode(relPath.toString(), "UTF-8").replaceAll("\\+","%20"); - } - catch (UnsupportedEncodingException e) - { - throw new AlfrescoRuntimeException("Could not process search results.", e); - } - } - } - else - { - // Get the document size - ContentData contentData = (ContentData)nodeProperties.get(ContentModel.PROP_CONTENT); - this.size = 0; - if (contentData != null) - { - 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())) - { - String prefixName = qName.getPrefixString().replace(":", "_"); - properties.put(prefixName, entry.getValue()); - } - } - } - - private String getDisplayName(String userName) - { - String result = personDataCache.get(userName); - if (result == null) - { - NodeRef person = personService.getPerson(userName); - if (person != null) - { - StringBuffer displayName = new StringBuffer(128); - displayName.append(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)) - .append(" ") - .append(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)); - result = displayName.toString(); - } - else - { - result = userName; - } - 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; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.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; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetailsCompatibility; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +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; + +/** + * RM search GET web script + * + * @author Roy Wetherall + */ +public class RMSearchGet extends DeclarativeWebScript +{ + /** URL Parameters */ + private static final String PARAM_QUERY = "query"; + 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; + + /** Person data cache */ + private Map personDataCache = null; + + /** + * @param recordsManagementSearchService records management search service + */ + public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService) + { + this.recordsManagementSearchService = recordsManagementSearchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param personService person service + */ + public void setPersonService(PersonService personService) + { + this.personService = personService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + try + { + // Get the site id and confirm it is valid + Map templateVars = req.getServiceMatch().getTemplateVars(); + String siteId = templateVars.get("site"); + if (siteId == null || siteId.length() == 0) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Site id not provided."); + } + if (siteService.getSite(siteId) == null) + { + 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 = + 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 + List> results = recordsManagementSearchService.search(siteId, query, searchParameters); + + // Reset person data cache + personDataCache = new HashMap(57); + + // Process the result items + List items = new ArrayList(results.size()); + for (Pair pair : results) + { + // FIXME: See RM-478 + // TC 3-3 Create User Groups + try + { + Item item = new Item(pair.getFirst(), pair.getSecond()); + items.add(item); + } + catch(Exception e) {} + } + + // Return model + model.put("items", items); + } + catch (Exception ex) + { + model.put("errorMessage", ex.toString()); + } + return model; + + } + + /** + * Item class to contain information about items being placed in model. + */ + public class Item + { + private NodeRef nodeRef; + private String type; + private int size; + private String parentFolder = ""; + private String browseUrl; + private boolean isContainer; + private String modifiedBy; + private String createdBy; + private Map nodeProperties; + private Map properties; + + public Item(NodeRef parent, 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)) + { + isContainer = false; + } + + // Get parent node reference +// NodeRef parent = null; +// ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); +// if (assoc != null) +// { +// parent = assoc.getParentRef(); +// } + + if (isContainer) + { + this.size = -1; + + String displayPath = nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService); + String[] pathElements = displayPath.split("/"); + if (pathElements.length >= 5) + { + if (pathElements.length > 5) + { + 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); + if (relPath.length() > 1) + { + relPath.append("/"); + } + relPath.append(getName()); + try + { + this.browseUrl = "documentlibrary?path=" + URLEncoder.encode(relPath.toString(), "UTF-8").replaceAll("\\+","%20"); + } + catch (UnsupportedEncodingException e) + { + throw new AlfrescoRuntimeException("Could not process search results.", e); + } + } + } + else + { + // Get the document size + ContentData contentData = (ContentData)nodeProperties.get(ContentModel.PROP_CONTENT); + this.size = 0; + if (contentData != null) + { + 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())) + { + String prefixName = qName.getPrefixString().replace(":", "_"); + properties.put(prefixName, entry.getValue()); + } + } + } + + private String getDisplayName(String userName) + { + String result = personDataCache.get(userName); + if (result == null) + { + NodeRef person = personService.getPerson(userName); + if (person != null) + { + StringBuffer displayName = new StringBuffer(128); + displayName.append(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)) + .append(" ") + .append(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)); + result = displayName.toString(); + } + else + { + result = userName; + } + 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; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java index 55761d8d57..b0d34ba25f 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 @@ -1,210 +1,210 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * RM search properties GET web script - * - * @author Roy Wetherall - */ -public class RMSearchPropertiesGet extends DeclarativeWebScript -{ - /** Services */ - private RecordsManagementAdminService adminService; - private RecordService recordService; - private DictionaryService dictionaryService; - private NamespaceService namespaceService; - private FilePlanService filePlanService; - - /** - * @param adminService records management admin service - */ - public void setAdminService(RecordsManagementAdminService adminService) - { - this.adminService = adminService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(13); - - List groups = new ArrayList(5); - - // get the file plan - // TODO the file plan should be passed to this web script - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - // get the record metadata aspects - Set aspects = recordService.getRecordMetadataAspects(filePlan); - for (QName aspect : aspects) - { - Map properties = dictionaryService.getPropertyDefs(aspect); - Property[] propObjs = new Property[properties.size()]; - int index = 0; - for (PropertyDefinition propertyDefinition : properties.values()) - { - Property propObj = new Property(propertyDefinition); - propObjs[index] = propObj; - index ++; - } - - AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); - Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(dictionaryService), propObjs); - groups.add(group); - } - - Map customProps = adminService.getCustomPropertyDefinitions(); - Property[] propObjs = new Property[customProps.size()]; - int index = 0; - for (PropertyDefinition propertyDefinition : customProps.values()) - { - Property propObj = new Property(propertyDefinition); - propObjs[index] = propObj; - index ++; - } - - Group group = new Group("rmcustom", "Custom", propObjs); - groups.add(group); - - model.put("groups", groups); - return model; - } - - public class Group - { - private String id; - private String label; - private Property[] properties; - - public Group(String id, String label, Property[] properties) - { - this.id = id; - this.label = label; - this.properties = properties.clone(); - } - - public String getId() - { - return id; - } - - public String getLabel() - { - return label; - } - - public Property[] getProperties() - { - return properties; - } - } - - public class Property - { - private String prefix; - private String shortName; - private String label; - private String type; - - public Property(PropertyDefinition propertyDefinition) - { - QName qName = propertyDefinition.getName().getPrefixedQName(namespaceService); - this.prefix = QName.splitPrefixedQName(qName.toPrefixString())[0]; - this.shortName = qName.getLocalName(); - this.label = propertyDefinition.getTitle(dictionaryService); - this.type = propertyDefinition.getDataType().getName().getLocalName(); - } - - public String getPrefix() - { - return prefix; - } - - public String getShortName() - { - return shortName; - } - - public String getLabel() - { - return label; - } - - public String getType() - { - return type; - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * RM search properties GET web script + * + * @author Roy Wetherall + */ +public class RMSearchPropertiesGet extends DeclarativeWebScript +{ + /** Services */ + private RecordsManagementAdminService adminService; + private RecordService recordService; + private DictionaryService dictionaryService; + private NamespaceService namespaceService; + private FilePlanService filePlanService; + + /** + * @param adminService records management admin service + */ + public void setAdminService(RecordsManagementAdminService adminService) + { + this.adminService = adminService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(13); + + List groups = new ArrayList(5); + + // get the file plan + // TODO the file plan should be passed to this web script + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + // get the record metadata aspects + Set aspects = recordService.getRecordMetadataAspects(filePlan); + for (QName aspect : aspects) + { + Map properties = dictionaryService.getPropertyDefs(aspect); + Property[] propObjs = new Property[properties.size()]; + int index = 0; + for (PropertyDefinition propertyDefinition : properties.values()) + { + Property propObj = new Property(propertyDefinition); + propObjs[index] = propObj; + index ++; + } + + AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); + Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(dictionaryService), propObjs); + groups.add(group); + } + + Map customProps = adminService.getCustomPropertyDefinitions(); + Property[] propObjs = new Property[customProps.size()]; + int index = 0; + for (PropertyDefinition propertyDefinition : customProps.values()) + { + Property propObj = new Property(propertyDefinition); + propObjs[index] = propObj; + index ++; + } + + Group group = new Group("rmcustom", "Custom", propObjs); + groups.add(group); + + model.put("groups", groups); + return model; + } + + public class Group + { + private String id; + private String label; + private Property[] properties; + + public Group(String id, String label, Property[] properties) + { + this.id = id; + this.label = label; + this.properties = properties.clone(); + } + + public String getId() + { + return id; + } + + public String getLabel() + { + return label; + } + + public Property[] getProperties() + { + return properties; + } + } + + public class Property + { + private String prefix; + private String shortName; + private String label; + private String type; + + public Property(PropertyDefinition propertyDefinition) + { + QName qName = propertyDefinition.getName().getPrefixedQName(namespaceService); + this.prefix = QName.splitPrefixedQName(qName.toPrefixString())[0]; + this.shortName = qName.getLocalName(); + this.label = propertyDefinition.getTitle(dictionaryService); + this.type = propertyDefinition.getDataType().getName().getLocalName(); + } + + public String getPrefix() + { + return prefix; + } + + public String getShortName() + { + return shortName; + } + + public String getLabel() + { + return label; + } + + public String getType() + { + return type; + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigGet.java index d3b8eb3ee0..4e23ac5fb8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigGet.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * REST API to get the recorded version config for a document - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordedVersionConfigGet extends AbstractRmWebScript -{ - /** Recordable version config service */ - private RecordableVersionConfigService recordableVersionConfigService; - - /** - * Gets the recordable version config service - * - * @return The recordable version config service - */ - protected RecordableVersionConfigService getRecordableVersionConfigService() - { - return this.recordableVersionConfigService; - } - - /** - * Sets the recordable version config service - * - * @param recordableVersionConfigService The recordable version config service - */ - public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService) - { - this.recordableVersionConfigService = recordableVersionConfigService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(1); - NodeRef nodeRef = parseRequestForNodeRef(req); - List recordableVersions = getRecordableVersionConfigService().getVersions(nodeRef); - model.put("recordableVersions", recordableVersions); - return model; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; +import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * REST API to get the recorded version config for a document + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordedVersionConfigGet extends AbstractRmWebScript +{ + /** Recordable version config service */ + private RecordableVersionConfigService recordableVersionConfigService; + + /** + * Gets the recordable version config service + * + * @return The recordable version config service + */ + protected RecordableVersionConfigService getRecordableVersionConfigService() + { + return this.recordableVersionConfigService; + } + + /** + * Sets the recordable version config service + * + * @param recordableVersionConfigService The recordable version config service + */ + public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService) + { + this.recordableVersionConfigService = recordableVersionConfigService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(1); + NodeRef nodeRef = parseRequestForNodeRef(req); + List recordableVersions = getRecordableVersionConfigService().getVersions(nodeRef); + model.put("recordableVersions", recordableVersions); + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigPost.java index 2d6a24a6cb..1dc27c0793 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RecordedVersionConfigPost.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject; -import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.alfresco.service.cmr.repository.NodeRef; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * REST API to set the recorded version config for a document - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordedVersionConfigPost extends AbstractRmWebScript -{ - /** Constant for recorded version parameter */ - public static final String RECORDED_VERSION = "recordedVersion"; - - /** Recordable version config service */ - private RecordableVersionConfigService recordableVersionConfigService; - - /** - * Gets the recordable version config service - * - * @return The recordable version config service - */ - protected RecordableVersionConfigService getRecordableVersionConfigService() - { - return this.recordableVersionConfigService; - } - - /** - * Sets the recordable version config service - * - * @param recordableVersionConfigService The recordable version config service - */ - public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService) - { - this.recordableVersionConfigService = recordableVersionConfigService; - } - - /** - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - NodeRef nodeRef = parseRequestForNodeRef(req); - String policy = getRecordableVersionPolicy(req); - getRecordableVersionConfigService().setVersion(nodeRef, policy); - return new HashMap(1); - } - - /** - * Gets the recordable version policy from the request - * - * @param The webscript request - * @return The recordable version policy - */ - private String getRecordableVersionPolicy(WebScriptRequest req) - { - JSONObject requestContent = getRequestContentAsJsonObject(req); - return getStringValueFromJSONObject(requestContent, RECORDED_VERSION); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject; +import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; +import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; +import org.alfresco.service.cmr.repository.NodeRef; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * REST API to set the recorded version config for a document + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordedVersionConfigPost extends AbstractRmWebScript +{ + /** Constant for recorded version parameter */ + public static final String RECORDED_VERSION = "recordedVersion"; + + /** Recordable version config service */ + private RecordableVersionConfigService recordableVersionConfigService; + + /** + * Gets the recordable version config service + * + * @return The recordable version config service + */ + protected RecordableVersionConfigService getRecordableVersionConfigService() + { + return this.recordableVersionConfigService; + } + + /** + * Sets the recordable version config service + * + * @param recordableVersionConfigService The recordable version config service + */ + public void setRecordableVersionConfigService(RecordableVersionConfigService recordableVersionConfigService) + { + this.recordableVersionConfigService = recordableVersionConfigService; + } + + /** + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + NodeRef nodeRef = parseRequestForNodeRef(req); + String policy = getRecordableVersionPolicy(req); + getRecordableVersionConfigService().setVersion(nodeRef, policy); + return new HashMap(1); + } + + /** + * Gets the recordable version policy from the request + * + * @param The webscript request + * @return The recordable version policy + */ + private String getRecordableVersionPolicy(WebScriptRequest req) + { + JSONObject requestContent = getRequestContentAsJsonObject(req); + return getStringValueFromJSONObject(requestContent, RECORDED_VERSION); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/Version.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/Version.java index 0e6f430132..f4abebc381 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/Version.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/Version.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; - -/** - * Recordable version class - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class Version -{ - /** The version policy */ - private String policy; - - /** Is the version selected */ - private boolean selected; - - /** - * Constructor - * - * @param policy The version policy - * @param selected Is the version selected - */ - public Version(String policy, boolean selected) - { - mandatoryString("policy", policy); - mandatory("selected", selected); - - setPolicy(policy); - setSelected(selected); - } - - /** - * Gets the version policy - * - * @return The version policy - */ - public String getPolicy() - { - return this.policy; - } - - /** - * Sets the version policy - * - * @param policy The version policy - */ - private void setPolicy(String policy) - { - this.policy = policy; - } - - /** - * Is the version selected - * - * @return true if the version is selected, false otherwise - */ - public boolean isSelected() - { - return this.selected; - } - - /** - * Sets the version as selected - * - * @param selected true if the version should be selected, false otherwise - */ - private void setSelected(boolean selected) - { - this.selected = selected; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; + +/** + * Recordable version class + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class Version +{ + /** The version policy */ + private String policy; + + /** Is the version selected */ + private boolean selected; + + /** + * Constructor + * + * @param policy The version policy + * @param selected Is the version selected + */ + public Version(String policy, boolean selected) + { + mandatoryString("policy", policy); + mandatory("selected", selected); + + setPolicy(policy); + setSelected(selected); + } + + /** + * Gets the version policy + * + * @return The version policy + */ + public String getPolicy() + { + return this.policy; + } + + /** + * Sets the version policy + * + * @param policy The version policy + */ + private void setPolicy(String policy) + { + this.policy = policy; + } + + /** + * Is the version selected + * + * @return true if the version is selected, false otherwise + */ + public boolean isSelected() + { + return this.selected; + } + + /** + * Sets the version as selected + * + * @param selected true if the version should be selected, false otherwise + */ + private void setSelected(boolean selected) + { + this.selected = selected; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/forms/RMMetaDataGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/forms/RMMetaDataGet.java index 44df8cafde..ddbe8bca9b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/forms/RMMetaDataGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/forms/RMMetaDataGet.java @@ -1,216 +1,216 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * RM metadata used by form extension - * - * @author Roy Wetherall - */ -public class RMMetaDataGet extends DeclarativeWebScript -{ - /** Query parameters */ - private static final String PARAM_NODEREF = "noderef"; - private static final String PARAM_TYPE = "type"; - private static final String PARAM_EXTENDED = "extended"; - - /** NodeRef pattern */ - private static final Pattern NODE_REF_PATTERN = Pattern.compile(".+://.+/.+"); - - /** QName pattern */ - private static final Pattern QNAME_PATTERN = Pattern.compile(".+:[^=,]+"); - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Node service */ - private NodeService nodeService; - - /** File Plan Service */ - private FilePlanService filePlanService; - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /* - * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // create model object with the lists model - Map model = new HashMap(1); - - boolean extended = false; - String result = "NONE"; - - // Get the nodeRef and confirm it is valid - String nodeRef = req.getParameter(PARAM_NODEREF); - if (nodeRef == null || nodeRef.length() == 0) - { - String type = req.getParameter(PARAM_TYPE); - if (type != null && type.length() != 0 && type.indexOf(':') != -1) - { - Matcher m = QNAME_PATTERN.matcher(type); - if (m.matches()) - { - QName qname = QName.createQName(type, namespaceService); - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKindFromType(qname); - if (kind != null) - { - result = kind.toString(); - } - } - } - } - else - { - // quick test before running slow match for full NodeRef pattern - if (nodeRef.indexOf(':') != -1) - { - Matcher m = NODE_REF_PATTERN.matcher(nodeRef); - if (m.matches()) - { - NodeRef nodeRefObj = new NodeRef(nodeRef); - - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRefObj); - if (kind != null) - { - result = kind.toString(); - } - - String extendedValue = req.getParameter(PARAM_EXTENDED); - if (extendedValue != null && extendedValue.length() != 0) - { - extended = Boolean.parseBoolean(extendedValue); - if (extended) - { - // get the aspects of the node - model.put("aspects", getAspects(nodeRefObj)); - } - } - } - } - } - - model.put("kind", result); - model.put("extended", extended); - return model; - } - - /** - * Gets the current node aspects - * - * @return node aspects - */ - public List getAspects(NodeRef nodeRef) - { - Set qnames = nodeService.getAspects(nodeRef); - List aspects = new ArrayList(qnames.size()); - for (QName qname : qnames) - { - aspects.add(new Aspect(qname)); - } - return aspects; - } - - /** - * Qname wrapper class - */ - public class QNameBean implements Serializable - { - private static final long serialVersionUID = 6982292337846270774L; - - protected QName name; - - public QNameBean(QName name) - { - this.name = name; - } - - public String getName() - { - return name.toString(); - } - - public String getPrefixedName() - { - return name.toPrefixString(namespaceService); - } - - public String toString() - { - return getName(); - } - } - - /** - * Aspect wrapper class - */ - public class Aspect extends QNameBean - { - private static final long serialVersionUID = -6448182941386934326L; - - public Aspect(QName name) - { - super(name); - } - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * RM metadata used by form extension + * + * @author Roy Wetherall + */ +public class RMMetaDataGet extends DeclarativeWebScript +{ + /** Query parameters */ + private static final String PARAM_NODEREF = "noderef"; + private static final String PARAM_TYPE = "type"; + private static final String PARAM_EXTENDED = "extended"; + + /** NodeRef pattern */ + private static final Pattern NODE_REF_PATTERN = Pattern.compile(".+://.+/.+"); + + /** QName pattern */ + private static final Pattern QNAME_PATTERN = Pattern.compile(".+:[^=,]+"); + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Node service */ + private NodeService nodeService; + + /** File Plan Service */ + private FilePlanService filePlanService; + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + // create model object with the lists model + Map model = new HashMap(1); + + boolean extended = false; + String result = "NONE"; + + // Get the nodeRef and confirm it is valid + String nodeRef = req.getParameter(PARAM_NODEREF); + if (nodeRef == null || nodeRef.length() == 0) + { + String type = req.getParameter(PARAM_TYPE); + if (type != null && type.length() != 0 && type.indexOf(':') != -1) + { + Matcher m = QNAME_PATTERN.matcher(type); + if (m.matches()) + { + QName qname = QName.createQName(type, namespaceService); + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKindFromType(qname); + if (kind != null) + { + result = kind.toString(); + } + } + } + } + else + { + // quick test before running slow match for full NodeRef pattern + if (nodeRef.indexOf(':') != -1) + { + Matcher m = NODE_REF_PATTERN.matcher(nodeRef); + if (m.matches()) + { + NodeRef nodeRefObj = new NodeRef(nodeRef); + + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRefObj); + if (kind != null) + { + result = kind.toString(); + } + + String extendedValue = req.getParameter(PARAM_EXTENDED); + if (extendedValue != null && extendedValue.length() != 0) + { + extended = Boolean.parseBoolean(extendedValue); + if (extended) + { + // get the aspects of the node + model.put("aspects", getAspects(nodeRefObj)); + } + } + } + } + } + + model.put("kind", result); + model.put("extended", extended); + return model; + } + + /** + * Gets the current node aspects + * + * @return node aspects + */ + public List getAspects(NodeRef nodeRef) + { + Set qnames = nodeService.getAspects(nodeRef); + List aspects = new ArrayList(qnames.size()); + for (QName qname : qnames) + { + aspects.add(new Aspect(qname)); + } + return aspects; + } + + /** + * Qname wrapper class + */ + public class QNameBean implements Serializable + { + private static final long serialVersionUID = 6982292337846270774L; + + protected QName name; + + public QNameBean(QName name) + { + this.name = name; + } + + public String getName() + { + return name.toString(); + } + + public String getPrefixedName() + { + return name.toPrefixString(namespaceService); + } + + public String toString() + { + return getName(); + } + } + + /** + * Aspect wrapper class + */ + public class Aspect extends QNameBean + { + private static final long serialVersionUID = -6448182941386934326L; + + public Aspect(QName name) + { + super(name); + } + } } \ No newline at end of file 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 547210095c..e3e65de4ae 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 @@ -1,369 +1,369 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -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; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * @author Roy Wetherall - */ -@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() - { - { - put("keywords", "%(cm:name cm:title cm:description TEXT)"); - put("name", "%(cm:name)"); - put("title", "%(cm:title)"); - put("description", "%(cm:description)"); - put("creator", "%(cm:creator)"); - put("created", "%(cm:created)"); - put("modifier", "%(cm:modifier)"); - put("modified", "%(cm:modified)"); - put("author", "%(cm:author)"); - put("markings", "%(rmc:supplementalMarkingList)"); - put("dispositionEvents", "%(rma:recordSearchDispositionEvents)"); - put("dispositionActionName", "%(rma:recordSearchDispositionActionName)"); - put("dispositionActionAsOf", "%(rma:recordSearchDispositionActionAsOf)"); - put("dispositionEventsEligible", "%(rma:recordSearchDispositionEventsEligible)"); - put("dispositionPeriod", "%(rma:recordSearchDispositionPeriod)"); - put("hasDispositionSchedule", "%(rma:recordSearchHasDispositionSchedule)"); - put("dispositionInstructions", "%(rma:recordSearchDispositionInstructions)"); - put("dispositionAuthority", "%(rma:recordSearchDispositionAuthority)"); - 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 = 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"; - private static final String JSON_VITALRECORDS = "vitalrecords"; - private static final String JSON_RECORDFOLDERES = "recordfolders"; - private static final String JSON_FROZEN = "frozen"; - private static final String JSON_CUTOFF = "cutoff"; - private static final String JSON_CONTAINERTYPES = "containertypes"; - 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, - * "vitalrecords" : false, - * "recordfolders" : false, - * "frozen" : false, - * "cutoff" : false, - * "containertypes" : - * [ - * "rma:recordSeries", - * "rma:recordCategory" - * ] - * "sort" : - * [ - * { - * "field" : "cm:name", - * "ascending" : true - * } - * ] - * } - */ - public static RecordsManagementSearchParameters createFromJSON(String json, NamespaceService namespaceService) - { - try - { - JSONObject jsonObject = new JSONObject(json); - return RecordsManagementSearchParameters.createFromJSON(jsonObject, namespaceService); - } - catch (JSONException e) - { - throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + json, e); - } - } - - /** - * - * @param jsonObject - * @return - */ - public static RecordsManagementSearchParameters createFromJSON(JSONObject jsonObject, NamespaceService namespaceService) - { - try - { - RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - - // Get the search parameter properties - if (jsonObject.has(JSON_MAXITEMS)) - { - searchParameters.setMaxItems(jsonObject.getInt(JSON_MAXITEMS)); - } - if (jsonObject.has(JSON_RECORDS)) - { - searchParameters.setIncludeRecords(jsonObject.getBoolean(JSON_RECORDS)); - } - if (jsonObject.has(JSON_UNDECLAREDRECORDS)) - { - searchParameters.setIncludeUndeclaredRecords(jsonObject.getBoolean(JSON_UNDECLAREDRECORDS)); - } - if (jsonObject.has(JSON_VITALRECORDS)) - { - searchParameters.setIncludeVitalRecords(jsonObject.getBoolean(JSON_VITALRECORDS)); - } - if (jsonObject.has(JSON_RECORDFOLDERES)) - { - searchParameters.setIncludeRecordFolders(jsonObject.getBoolean(JSON_RECORDFOLDERES)); - } - if (jsonObject.has(JSON_FROZEN)) - { - searchParameters.setIncludeFrozen(jsonObject.getBoolean(JSON_FROZEN)); - } - if (jsonObject.has(JSON_CUTOFF)) - { - searchParameters.setIncludeCutoff(jsonObject.getBoolean(JSON_CUTOFF)); - } - - // Get container types - if (jsonObject.has(JSON_CONTAINERTYPES)) - { - JSONArray jsonArray = jsonObject.getJSONArray(JSON_CONTAINERTYPES); - List containerTypes = new ArrayList(jsonArray.length()); - for (int i = 0; i < jsonArray.length(); i++) - { - String type = jsonArray.getString(i); - containerTypes.add(QName.createQName(type, namespaceService)); - } - searchParameters.setIncludedContainerTypes(containerTypes); - } - - // Get sort details - if (jsonObject.has(JSON_SORT)) - { - JSONArray jsonArray = jsonObject.getJSONArray(JSON_SORT); - List sortOrder = new ArrayList(jsonArray.length()); - for (int i = 0; i < jsonArray.length(); i++) - { - JSONObject sortJSONObject = jsonArray.getJSONObject(i); - if (sortJSONObject.has(JSON_FIELD) && - sortJSONObject.has(JSON_ASCENDING)) - { - sortOrder.add(new SortItem( - 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 - { - JSONObject jsonObject = new JSONObject(); - jsonObject.put(JSON_MAXITEMS, maxItems); - jsonObject.put(JSON_RECORDS, includeRecords); - jsonObject.put(JSON_UNDECLAREDRECORDS, includeUndeclaredRecords); - jsonObject.put(JSON_VITALRECORDS, includeVitalRecords); - 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) - { - jsonArray.put(containerType.toPrefixString(namespaceService)); - } - jsonObject.put(JSON_CONTAINERTYPES, jsonArray); - - // Sort - JSONArray jsonSortArray = new JSONArray(); - for (SortItem entry : sortOrder) - { - JSONObject jsonEntry = new JSONObject(); - jsonEntry.put(JSON_FIELD, entry.property.toPrefixString(namespaceService)); - jsonEntry.put(JSON_ASCENDING, entry.assc); - jsonSortArray.put(jsonEntry); - } - jsonObject.put(JSON_SORT, jsonSortArray); - - return jsonObject; - } - catch (JSONException e) - { - 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; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +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; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * @author Roy Wetherall + */ +@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() + { + { + put("keywords", "%(cm:name cm:title cm:description TEXT)"); + put("name", "%(cm:name)"); + put("title", "%(cm:title)"); + put("description", "%(cm:description)"); + put("creator", "%(cm:creator)"); + put("created", "%(cm:created)"); + put("modifier", "%(cm:modifier)"); + put("modified", "%(cm:modified)"); + put("author", "%(cm:author)"); + put("markings", "%(rmc:supplementalMarkingList)"); + put("dispositionEvents", "%(rma:recordSearchDispositionEvents)"); + put("dispositionActionName", "%(rma:recordSearchDispositionActionName)"); + put("dispositionActionAsOf", "%(rma:recordSearchDispositionActionAsOf)"); + put("dispositionEventsEligible", "%(rma:recordSearchDispositionEventsEligible)"); + put("dispositionPeriod", "%(rma:recordSearchDispositionPeriod)"); + put("hasDispositionSchedule", "%(rma:recordSearchHasDispositionSchedule)"); + put("dispositionInstructions", "%(rma:recordSearchDispositionInstructions)"); + put("dispositionAuthority", "%(rma:recordSearchDispositionAuthority)"); + 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 = 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"; + private static final String JSON_VITALRECORDS = "vitalrecords"; + private static final String JSON_RECORDFOLDERES = "recordfolders"; + private static final String JSON_FROZEN = "frozen"; + private static final String JSON_CUTOFF = "cutoff"; + private static final String JSON_CONTAINERTYPES = "containertypes"; + 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, + * "vitalrecords" : false, + * "recordfolders" : false, + * "frozen" : false, + * "cutoff" : false, + * "containertypes" : + * [ + * "rma:recordSeries", + * "rma:recordCategory" + * ] + * "sort" : + * [ + * { + * "field" : "cm:name", + * "ascending" : true + * } + * ] + * } + */ + public static RecordsManagementSearchParameters createFromJSON(String json, NamespaceService namespaceService) + { + try + { + JSONObject jsonObject = new JSONObject(json); + return RecordsManagementSearchParameters.createFromJSON(jsonObject, namespaceService); + } + catch (JSONException e) + { + throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + json, e); + } + } + + /** + * + * @param jsonObject + * @return + */ + public static RecordsManagementSearchParameters createFromJSON(JSONObject jsonObject, NamespaceService namespaceService) + { + try + { + RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); + + // Get the search parameter properties + if (jsonObject.has(JSON_MAXITEMS)) + { + searchParameters.setMaxItems(jsonObject.getInt(JSON_MAXITEMS)); + } + if (jsonObject.has(JSON_RECORDS)) + { + searchParameters.setIncludeRecords(jsonObject.getBoolean(JSON_RECORDS)); + } + if (jsonObject.has(JSON_UNDECLAREDRECORDS)) + { + searchParameters.setIncludeUndeclaredRecords(jsonObject.getBoolean(JSON_UNDECLAREDRECORDS)); + } + if (jsonObject.has(JSON_VITALRECORDS)) + { + searchParameters.setIncludeVitalRecords(jsonObject.getBoolean(JSON_VITALRECORDS)); + } + if (jsonObject.has(JSON_RECORDFOLDERES)) + { + searchParameters.setIncludeRecordFolders(jsonObject.getBoolean(JSON_RECORDFOLDERES)); + } + if (jsonObject.has(JSON_FROZEN)) + { + searchParameters.setIncludeFrozen(jsonObject.getBoolean(JSON_FROZEN)); + } + if (jsonObject.has(JSON_CUTOFF)) + { + searchParameters.setIncludeCutoff(jsonObject.getBoolean(JSON_CUTOFF)); + } + + // Get container types + if (jsonObject.has(JSON_CONTAINERTYPES)) + { + JSONArray jsonArray = jsonObject.getJSONArray(JSON_CONTAINERTYPES); + List containerTypes = new ArrayList(jsonArray.length()); + for (int i = 0; i < jsonArray.length(); i++) + { + String type = jsonArray.getString(i); + containerTypes.add(QName.createQName(type, namespaceService)); + } + searchParameters.setIncludedContainerTypes(containerTypes); + } + + // Get sort details + if (jsonObject.has(JSON_SORT)) + { + JSONArray jsonArray = jsonObject.getJSONArray(JSON_SORT); + List sortOrder = new ArrayList(jsonArray.length()); + for (int i = 0; i < jsonArray.length(); i++) + { + JSONObject sortJSONObject = jsonArray.getJSONObject(i); + if (sortJSONObject.has(JSON_FIELD) && + sortJSONObject.has(JSON_ASCENDING)) + { + sortOrder.add(new SortItem( + 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 + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put(JSON_MAXITEMS, maxItems); + jsonObject.put(JSON_RECORDS, includeRecords); + jsonObject.put(JSON_UNDECLAREDRECORDS, includeUndeclaredRecords); + jsonObject.put(JSON_VITALRECORDS, includeVitalRecords); + 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) + { + jsonArray.put(containerType.toPrefixString(namespaceService)); + } + jsonObject.put(JSON_CONTAINERTYPES, jsonArray); + + // Sort + JSONArray jsonSortArray = new JSONArray(); + for (SortItem entry : sortOrder) + { + JSONObject jsonEntry = new JSONObject(); + jsonEntry.put(JSON_FIELD, entry.property.toPrefixString(namespaceService)); + jsonEntry.put(JSON_ASCENDING, entry.assc); + jsonSortArray.put(jsonEntry); + } + jsonObject.put(JSON_SORT, jsonSortArray); + + return jsonObject; + } + catch (JSONException e) + { + 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; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchService.java index 22c3c7cc8f..4e5611fca3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchService.java @@ -1,93 +1,93 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Records management search service. - * - * @author Roy Wetherall - */ -public interface RecordsManagementSearchService -{ - /** - * Execute a records management search - * @param siteId the id of the rm site to query - * @param query search query string - * @param searchParameters search parameters - * @return {@link List}<{@link Pair}<{@link NodeRef}, {@link NodeRef}> search results as pairs for parent and child nodes - */ - List> search(String siteId, String query, RecordsManagementSearchParameters searchParameters); - - /** - * Get all the searches saved on the given records management site. - * @param siteId site id - * @return {@link List<{@link SavedSearchDetails}>} list of saved search details - */ - List getSavedSearches(String siteId); - - /** - * Get a named saved search for a given records management site. - * @param siteId site id - * @param name name of search - * @return {@link SavedSearchDetails} saved search details - */ - SavedSearchDetails getSavedSearch(String siteId, String name); - - /** - * Save records management search. - * @param siteId site id - * @param name name - * @param description description - * @param search search string - * @param isPublic indicates whether the saved search is public or not - * @return {@link SavedSearchDetails} details of the saved search - */ - SavedSearchDetails saveSearch(String siteId, String name, String description, String search, RecordsManagementSearchParameters searchParameters, boolean isPublic); - - /** - * Save records management search. - * @param savedSearchDetails details of search to save - * @return {@link SavedSearchDetails} details of the saved search - */ - SavedSearchDetails saveSearch(SavedSearchDetails savedSearchDetails); - - /** - * Delete saved search - * @param siteId site id - * @param name name of saved search - */ - void deleteSavedSearch(String siteId, String name); - - /** - * Delete saved search - * @param savedSearchDetails saved search details - */ - void deleteSavedSearch(SavedSearchDetails savedSearchDetails); - - /** - * Adds the reports as saved searches to a given site. - * @param siteId site id - */ - void addReports(String siteId); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; + +/** + * Records management search service. + * + * @author Roy Wetherall + */ +public interface RecordsManagementSearchService +{ + /** + * Execute a records management search + * @param siteId the id of the rm site to query + * @param query search query string + * @param searchParameters search parameters + * @return {@link List}<{@link Pair}<{@link NodeRef}, {@link NodeRef}> search results as pairs for parent and child nodes + */ + List> search(String siteId, String query, RecordsManagementSearchParameters searchParameters); + + /** + * Get all the searches saved on the given records management site. + * @param siteId site id + * @return {@link List<{@link SavedSearchDetails}>} list of saved search details + */ + List getSavedSearches(String siteId); + + /** + * Get a named saved search for a given records management site. + * @param siteId site id + * @param name name of search + * @return {@link SavedSearchDetails} saved search details + */ + SavedSearchDetails getSavedSearch(String siteId, String name); + + /** + * Save records management search. + * @param siteId site id + * @param name name + * @param description description + * @param search search string + * @param isPublic indicates whether the saved search is public or not + * @return {@link SavedSearchDetails} details of the saved search + */ + SavedSearchDetails saveSearch(String siteId, String name, String description, String search, RecordsManagementSearchParameters searchParameters, boolean isPublic); + + /** + * Save records management search. + * @param savedSearchDetails details of search to save + * @return {@link SavedSearchDetails} details of the saved search + */ + SavedSearchDetails saveSearch(SavedSearchDetails savedSearchDetails); + + /** + * Delete saved search + * @param siteId site id + * @param name name of saved search + */ + void deleteSavedSearch(String siteId, String name); + + /** + * Delete saved search + * @param savedSearchDetails saved search details + */ + void deleteSavedSearch(SavedSearchDetails savedSearchDetails); + + /** + * Adds the reports as saved searches to a given site. + * @param siteId site id + */ + void addReports(String siteId); +} 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 5eed77b551..b3c0dba0f5 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 @@ -1,630 +1,630 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ISO9075; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Records management search service implementation - * - * @author Roy Wetherall - */ -public class RecordsManagementSearchServiceImpl implements RecordsManagementSearchService -{ - private static final String SITES_SPACE_QNAME_PATH = "/app:company_home/st:sites/"; - - /** Name of the main site container used to store the saved searches within */ - private static final String SEARCH_CONTAINER = "Saved Searches"; - - /** File folder service */ - private FileFolderService fileFolderService; - - /** Search service */ - private SearchService searchService; - - /** Site service */ - private SiteService siteService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** List of report details */ - private List reports = new ArrayList(13); - - /** - * @param fileFolderService file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param searchService search service - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param siteService site service - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param reportsJSON - */ - public void setReportsJSON(String reportsJSON) - { - try - { - JSONArray jsonArray = new JSONArray(reportsJSON); - if (jsonArray != null) - { - for (int i=0; i < jsonArray.length(); i++) - { - JSONObject report = jsonArray.getJSONObject(i); - - // Get the name - if (!report.has(SavedSearchDetails.NAME)) - { - throw new AlfrescoRuntimeException("Unable to load report details because name has not been specified. \n" + reportsJSON); - } - String name = report.getString(SavedSearchDetails.NAME); - String translatedName = I18NUtil.getMessage(name); - if (translatedName != null) - { - name = translatedName; - } - - // Get the query - if (!report.has(SavedSearchDetails.SEARCH)) - { - throw new AlfrescoRuntimeException("Unable to load report details because search has not been specified for report " + name + ". \n" + reportsJSON); - } - String query = report.getString(SavedSearchDetails.SEARCH); - - // Get the description - String description = ""; - if (report.has(SavedSearchDetails.DESCRIPTION)) - { - description = report.getString(SavedSearchDetails.DESCRIPTION); - String translatedDescription = I18NUtil.getMessage(description); - if (translatedDescription != null) - { - description = translatedDescription; - } - } - - RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - if (report.has("searchparams")) - { - searchParameters = RecordsManagementSearchParameters.createFromJSON(report.getJSONObject("searchparams"), namespaceService); - } - - // Create the report details and add to list - ReportDetails reportDetails = new ReportDetails(name, description, query, searchParameters); - reports.add(reportDetails); - } - } - } - catch (JSONException exception) - { - throw new AlfrescoRuntimeException("Unable to load report details.\n" + reportsJSON, exception); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#search(java.lang.String, java.lang.String, org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters) - */ - @Override - public List> search(String siteId, String query, RecordsManagementSearchParameters rmSearchParameters) - { - // build the full RM query - StringBuilder fullQuery = new StringBuilder(1024); - fullQuery.append("PATH:\"") - .append(SITES_SPACE_QNAME_PATH) - .append("cm:").append(ISO9075.encode(siteId)).append("/cm:documentLibrary//*\"") - .append(" AND (") - .append(buildQueryString(query, rmSearchParameters)) - .append(")"); - - // create the search parameters - SearchParameters searchParameters = new SearchParameters(); - searchParameters.setQuery(fullQuery.toString()); - searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); - searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - searchParameters.setMaxItems(rmSearchParameters.getMaxItems()); - searchParameters.setNamespace(RecordsManagementModel.RM_URI); - - // set sort - for(SortItem entry : rmSearchParameters.getSortOrder()) - { - searchParameters.addSort(entry.property.toPrefixString(namespaceService), entry.assc); - } - - // set templates - for (Entry entry : rmSearchParameters.getTemplates().entrySet()) - { - searchParameters.addQueryTemplate(entry.getKey(), entry.getValue()); - } - - // execute query - ResultSet resultSet = searchService.query(searchParameters); - - // process results - List> result = new ArrayList>(resultSet.length()); - for (ChildAssociationRef childAssoc : resultSet.getChildAssocRefs()) - { - result.add(new Pair(childAssoc.getParentRef(), childAssoc.getChildRef())); - } - - // return results - return result; - } - - /** - * - * @param queryTerm - * @param aspects - * @param types - * @return - */ - /*package*/ String buildQueryString(String queryTerm, RecordsManagementSearchParameters searchParameters) - { - StringBuilder aspectQuery = new StringBuilder(); - if (searchParameters.isIncludeRecords()) - { - appendAspect(aspectQuery, "rma:record"); - if (!searchParameters.isIncludeUndeclaredRecords()) - { - appendAspect(aspectQuery, "rma:declaredRecord"); - } - if (searchParameters.isIncludeVitalRecords()) - { - appendAspect(aspectQuery, "rma:vitalRecord"); - } - } - - StringBuilder typeQuery = new StringBuilder(); - if (searchParameters.isIncludeRecordFolders()) - { - appendType(typeQuery, "rma:recordFolder"); - } - List includedContainerTypes = searchParameters.getIncludedContainerTypes(); - if (includedContainerTypes != null && includedContainerTypes.size() != 0) - { - for (QName includedContainerType : includedContainerTypes) - { - appendType(typeQuery, includedContainerType.toPrefixString(namespaceService)); - } - } - - StringBuilder query = new StringBuilder(); - if (queryTerm == null || queryTerm.length() == 0) - { - // Default to search for everything - query.append("ISNODE:T"); - } - else - { - if (isComplexQueryTerm(queryTerm)) - { - query.append(queryTerm); - } - else - { - query.append("keywords:\"" + queryTerm + "\""); - } - } - - StringBuilder fullQuery = new StringBuilder(1024); - if (aspectQuery.length() != 0 || typeQuery.length() != 0) - { - if (aspectQuery.length() != 0 && typeQuery.length() != 0) - { - fullQuery.append("("); - } - - if (aspectQuery.length() != 0) - { - fullQuery.append("(").append(aspectQuery).append(") "); - } - - if (typeQuery.length() != 0) - { - fullQuery.append("(").append(typeQuery).append(")"); - } - - if (aspectQuery.length() != 0 && typeQuery.length() != 0) - { - fullQuery.append(")"); - } - } - - if (searchParameters.isIncludeFrozen()) - { - appendAspect(fullQuery, "rma:frozen"); - } - else - { - appendNotAspect(fullQuery, "rma:frozen"); - } - if (searchParameters.isIncludeCutoff()) - { - appendAspect(fullQuery, "rma:cutOff"); - } - - if (fullQuery.length() != 0) - { - fullQuery.append(" AND "); - } - fullQuery.append(query).append(" AND NOT ASPECT:\"rma:versionedRecord\""); - - return fullQuery.toString(); - } - - private boolean isComplexQueryTerm(String query) - { - return query.matches(".*[\":].*"); - } - - /** - * - * @param sb - * @param aspect - */ - private void appendAspect(StringBuilder sb, String aspect) - { - appendWithJoin(sb, " AND ", "ASPECT:\"", aspect, "\""); - } - - private void appendNotAspect(StringBuilder sb, String aspect) - { - appendWithJoin(sb, " AND ", "NOT ASPECT:\"", aspect, "\""); - } - - /** - * - * @param sb - * @param type - */ - private void appendType(StringBuilder sb, String type) - { - appendWithJoin(sb, " ", "TYPE:\"", type, "\""); - } - - /** - * - * @param sb - * @param withJoin - * @param prefix - * @param value - * @param postfix - */ - private void appendWithJoin(StringBuilder sb, String withJoin, String prefix, String value, String postfix) - { - if (sb.length() != 0) - { - sb.append(withJoin); - } - sb.append(prefix).append(value).append(postfix); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearches(java.lang.String) - */ - @Override - public List getSavedSearches(String siteId) - { - List result = new ArrayList(17); - - NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); - if (container != null) - { - // add the details of all the public saved searches - List searches = fileFolderService.listFiles(container); - for (FileInfo search : searches) - { - addSearchDetailsToList(result, search.getNodeRef()); - } - - // add the details of any "private" searches for the current user - String userName = AuthenticationUtil.getFullyAuthenticatedUser(); - NodeRef userContainer = fileFolderService.searchSimple(container, userName); - if (userContainer != null) - { - List userSearches = fileFolderService.listFiles(userContainer); - for (FileInfo userSearch : userSearches) - { - addSearchDetailsToList(result, userSearch.getNodeRef()); - } - } - } - - return result; - } - - /** - * Add the search details to the list. - * @param searches list of search details - * @param searchNode search node - */ - private void addSearchDetailsToList(List searches, NodeRef searchNode) - { - ContentReader reader = fileFolderService.getReader(searchNode); - String jsonString = reader.getContentString(); - SavedSearchDetails savedSearchDetails = SavedSearchDetails.createFromJSON(jsonString, namespaceService, this, searchNode); - searches.add(savedSearchDetails); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearch(java.lang.String, java.lang.String) - */ - @Override - public SavedSearchDetails getSavedSearch(String siteId, String name) - { - // check for mandatory parameters - ParameterCheck.mandatory("siteId", siteId); - ParameterCheck.mandatory("name", name); - - SavedSearchDetails result = null; - - // get the saved search node - NodeRef searchNode = getSearchNodeRef(siteId, name); - - if (searchNode != null) - { - // get the json content - ContentReader reader = fileFolderService.getReader(searchNode); - String jsonString = reader.getContentString(); - - // create the saved search details - result = SavedSearchDetails.createFromJSON(jsonString, namespaceService, this, searchNode); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#saveSearch(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) - */ - @Override - public SavedSearchDetails saveSearch(String siteId, String name, String description, String query, RecordsManagementSearchParameters searchParameters, boolean isPublic) - { - // Check for mandatory parameters - ParameterCheck.mandatory("siteId", siteId); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("query", query); - ParameterCheck.mandatory("searchParameters", searchParameters); - - // Create saved search details - SavedSearchDetails savedSearchDetails = new SavedSearchDetails(siteId, name, description, query, searchParameters, isPublic, false, namespaceService, this); - - // Save search details - return saveSearch(savedSearchDetails); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#saveSearch(org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails) - */ - @Override - public SavedSearchDetails saveSearch(final SavedSearchDetails savedSearchDetails) - { - // Check for mandatory parameters - ParameterCheck.mandatory("savedSearchDetails", savedSearchDetails); - - // Get the root saved search container - final String siteId = savedSearchDetails.getSiteId(); - NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); - if (container == null) - { - container = AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return siteService.createContainer(siteId, SEARCH_CONTAINER, null, null); - } - }, AuthenticationUtil.getSystemUserName()); - } - - // Get the private container for the current user - if (!savedSearchDetails.isPublic()) - { - final String userName = AuthenticationUtil.getFullyAuthenticatedUser(); - NodeRef userContainer = fileFolderService.searchSimple(container, userName); - if (userContainer == null) - { - final NodeRef parentContainer = container; - userContainer = AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return fileFolderService.create(parentContainer, userName, ContentModel.TYPE_FOLDER).getNodeRef(); - } - }, AuthenticationUtil.getSystemUserName()); - } - container = userContainer; - } - - // Get the saved search node - NodeRef searchNode = fileFolderService.searchSimple(container, savedSearchDetails.getName()); - if (searchNode == null) - { - final NodeRef searchContainer = container; - searchNode = AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() - { - return fileFolderService.create(searchContainer, savedSearchDetails.getName(), ContentModel.TYPE_CONTENT).getNodeRef(); - } - }, AuthenticationUtil.getSystemUserName()); - } - - // Write the JSON content to search node - final NodeRef writableSearchNode = searchNode; - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - ContentWriter writer = fileFolderService.getWriter(writableSearchNode); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_JSON); - writer.putContent(savedSearchDetails.toJSONString()); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - return savedSearchDetails; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#deleteSavedSearch(java.lang.String, java.lang.String) - */ - @Override - public void deleteSavedSearch(String siteId, String name) - { - // Check parameters - ParameterCheck.mandatory("siteId", siteId); - ParameterCheck.mandatory("name", name); - - // Get the search node for the saved query - NodeRef searchNode = getSearchNodeRef(siteId, name); - if (searchNode != null && fileFolderService.exists(searchNode)) - { - fileFolderService.delete(searchNode); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#deleteSavedSearch(org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails) - */ - @Override - public void deleteSavedSearch(SavedSearchDetails savedSearchDetails) - { - // Check parameters - ParameterCheck.mandatory("savedSearchDetails", savedSearchDetails); - - // Delete the saved search - deleteSavedSearch(savedSearchDetails.getSiteId(), savedSearchDetails.getName()); - } - - /** - * Get the saved search node reference. - * @param siteId site id - * @param name search name - * @return {@link NodeRef} search node reference - */ - private NodeRef getSearchNodeRef(String siteId, String name) - { - NodeRef searchNode = null; - - // Get the root saved search container - NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); - if (container != null) - { - // try and find the search node - searchNode = fileFolderService.searchSimple(container, name); - - // can't find it so check the users container - if (searchNode == null) - { - String userName = AuthenticationUtil.getFullyAuthenticatedUser(); - NodeRef userContainer = fileFolderService.searchSimple(container, userName); - if (userContainer != null) - { - searchNode = fileFolderService.searchSimple(userContainer, name); - } - } - } - - return searchNode; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#addReports(java.lang.String) - */ - @Override - public void addReports(String siteId) - { - for (ReportDetails report : reports) - { - // Create saved search details - SavedSearchDetails savedSearchDetails = new SavedSearchDetails( - siteId, - report.getName(), - report.getDescription(), - report.getSearch(), - report.getSearchParameters(), - true, - true, - namespaceService, - this); - - // Save search details - saveSearch(savedSearchDetails); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchParameters; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ISO9075; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Records management search service implementation + * + * @author Roy Wetherall + */ +public class RecordsManagementSearchServiceImpl implements RecordsManagementSearchService +{ + private static final String SITES_SPACE_QNAME_PATH = "/app:company_home/st:sites/"; + + /** Name of the main site container used to store the saved searches within */ + private static final String SEARCH_CONTAINER = "Saved Searches"; + + /** File folder service */ + private FileFolderService fileFolderService; + + /** Search service */ + private SearchService searchService; + + /** Site service */ + private SiteService siteService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** List of report details */ + private List reports = new ArrayList(13); + + /** + * @param fileFolderService file folder service + */ + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + /** + * @param searchService search service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * @param siteService site service + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param reportsJSON + */ + public void setReportsJSON(String reportsJSON) + { + try + { + JSONArray jsonArray = new JSONArray(reportsJSON); + if (jsonArray != null) + { + for (int i=0; i < jsonArray.length(); i++) + { + JSONObject report = jsonArray.getJSONObject(i); + + // Get the name + if (!report.has(SavedSearchDetails.NAME)) + { + throw new AlfrescoRuntimeException("Unable to load report details because name has not been specified. \n" + reportsJSON); + } + String name = report.getString(SavedSearchDetails.NAME); + String translatedName = I18NUtil.getMessage(name); + if (translatedName != null) + { + name = translatedName; + } + + // Get the query + if (!report.has(SavedSearchDetails.SEARCH)) + { + throw new AlfrescoRuntimeException("Unable to load report details because search has not been specified for report " + name + ". \n" + reportsJSON); + } + String query = report.getString(SavedSearchDetails.SEARCH); + + // Get the description + String description = ""; + if (report.has(SavedSearchDetails.DESCRIPTION)) + { + description = report.getString(SavedSearchDetails.DESCRIPTION); + String translatedDescription = I18NUtil.getMessage(description); + if (translatedDescription != null) + { + description = translatedDescription; + } + } + + RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); + if (report.has("searchparams")) + { + searchParameters = RecordsManagementSearchParameters.createFromJSON(report.getJSONObject("searchparams"), namespaceService); + } + + // Create the report details and add to list + ReportDetails reportDetails = new ReportDetails(name, description, query, searchParameters); + reports.add(reportDetails); + } + } + } + catch (JSONException exception) + { + throw new AlfrescoRuntimeException("Unable to load report details.\n" + reportsJSON, exception); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#search(java.lang.String, java.lang.String, org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters) + */ + @Override + public List> search(String siteId, String query, RecordsManagementSearchParameters rmSearchParameters) + { + // build the full RM query + StringBuilder fullQuery = new StringBuilder(1024); + fullQuery.append("PATH:\"") + .append(SITES_SPACE_QNAME_PATH) + .append("cm:").append(ISO9075.encode(siteId)).append("/cm:documentLibrary//*\"") + .append(" AND (") + .append(buildQueryString(query, rmSearchParameters)) + .append(")"); + + // create the search parameters + SearchParameters searchParameters = new SearchParameters(); + searchParameters.setQuery(fullQuery.toString()); + searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); + searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + searchParameters.setMaxItems(rmSearchParameters.getMaxItems()); + searchParameters.setNamespace(RecordsManagementModel.RM_URI); + + // set sort + for(SortItem entry : rmSearchParameters.getSortOrder()) + { + searchParameters.addSort(entry.property.toPrefixString(namespaceService), entry.assc); + } + + // set templates + for (Entry entry : rmSearchParameters.getTemplates().entrySet()) + { + searchParameters.addQueryTemplate(entry.getKey(), entry.getValue()); + } + + // execute query + ResultSet resultSet = searchService.query(searchParameters); + + // process results + List> result = new ArrayList>(resultSet.length()); + for (ChildAssociationRef childAssoc : resultSet.getChildAssocRefs()) + { + result.add(new Pair(childAssoc.getParentRef(), childAssoc.getChildRef())); + } + + // return results + return result; + } + + /** + * + * @param queryTerm + * @param aspects + * @param types + * @return + */ + /*package*/ String buildQueryString(String queryTerm, RecordsManagementSearchParameters searchParameters) + { + StringBuilder aspectQuery = new StringBuilder(); + if (searchParameters.isIncludeRecords()) + { + appendAspect(aspectQuery, "rma:record"); + if (!searchParameters.isIncludeUndeclaredRecords()) + { + appendAspect(aspectQuery, "rma:declaredRecord"); + } + if (searchParameters.isIncludeVitalRecords()) + { + appendAspect(aspectQuery, "rma:vitalRecord"); + } + } + + StringBuilder typeQuery = new StringBuilder(); + if (searchParameters.isIncludeRecordFolders()) + { + appendType(typeQuery, "rma:recordFolder"); + } + List includedContainerTypes = searchParameters.getIncludedContainerTypes(); + if (includedContainerTypes != null && includedContainerTypes.size() != 0) + { + for (QName includedContainerType : includedContainerTypes) + { + appendType(typeQuery, includedContainerType.toPrefixString(namespaceService)); + } + } + + StringBuilder query = new StringBuilder(); + if (queryTerm == null || queryTerm.length() == 0) + { + // Default to search for everything + query.append("ISNODE:T"); + } + else + { + if (isComplexQueryTerm(queryTerm)) + { + query.append(queryTerm); + } + else + { + query.append("keywords:\"" + queryTerm + "\""); + } + } + + StringBuilder fullQuery = new StringBuilder(1024); + if (aspectQuery.length() != 0 || typeQuery.length() != 0) + { + if (aspectQuery.length() != 0 && typeQuery.length() != 0) + { + fullQuery.append("("); + } + + if (aspectQuery.length() != 0) + { + fullQuery.append("(").append(aspectQuery).append(") "); + } + + if (typeQuery.length() != 0) + { + fullQuery.append("(").append(typeQuery).append(")"); + } + + if (aspectQuery.length() != 0 && typeQuery.length() != 0) + { + fullQuery.append(")"); + } + } + + if (searchParameters.isIncludeFrozen()) + { + appendAspect(fullQuery, "rma:frozen"); + } + else + { + appendNotAspect(fullQuery, "rma:frozen"); + } + if (searchParameters.isIncludeCutoff()) + { + appendAspect(fullQuery, "rma:cutOff"); + } + + if (fullQuery.length() != 0) + { + fullQuery.append(" AND "); + } + fullQuery.append(query).append(" AND NOT ASPECT:\"rma:versionedRecord\""); + + return fullQuery.toString(); + } + + private boolean isComplexQueryTerm(String query) + { + return query.matches(".*[\":].*"); + } + + /** + * + * @param sb + * @param aspect + */ + private void appendAspect(StringBuilder sb, String aspect) + { + appendWithJoin(sb, " AND ", "ASPECT:\"", aspect, "\""); + } + + private void appendNotAspect(StringBuilder sb, String aspect) + { + appendWithJoin(sb, " AND ", "NOT ASPECT:\"", aspect, "\""); + } + + /** + * + * @param sb + * @param type + */ + private void appendType(StringBuilder sb, String type) + { + appendWithJoin(sb, " ", "TYPE:\"", type, "\""); + } + + /** + * + * @param sb + * @param withJoin + * @param prefix + * @param value + * @param postfix + */ + private void appendWithJoin(StringBuilder sb, String withJoin, String prefix, String value, String postfix) + { + if (sb.length() != 0) + { + sb.append(withJoin); + } + sb.append(prefix).append(value).append(postfix); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearches(java.lang.String) + */ + @Override + public List getSavedSearches(String siteId) + { + List result = new ArrayList(17); + + NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); + if (container != null) + { + // add the details of all the public saved searches + List searches = fileFolderService.listFiles(container); + for (FileInfo search : searches) + { + addSearchDetailsToList(result, search.getNodeRef()); + } + + // add the details of any "private" searches for the current user + String userName = AuthenticationUtil.getFullyAuthenticatedUser(); + NodeRef userContainer = fileFolderService.searchSimple(container, userName); + if (userContainer != null) + { + List userSearches = fileFolderService.listFiles(userContainer); + for (FileInfo userSearch : userSearches) + { + addSearchDetailsToList(result, userSearch.getNodeRef()); + } + } + } + + return result; + } + + /** + * Add the search details to the list. + * @param searches list of search details + * @param searchNode search node + */ + private void addSearchDetailsToList(List searches, NodeRef searchNode) + { + ContentReader reader = fileFolderService.getReader(searchNode); + String jsonString = reader.getContentString(); + SavedSearchDetails savedSearchDetails = SavedSearchDetails.createFromJSON(jsonString, namespaceService, this, searchNode); + searches.add(savedSearchDetails); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearch(java.lang.String, java.lang.String) + */ + @Override + public SavedSearchDetails getSavedSearch(String siteId, String name) + { + // check for mandatory parameters + ParameterCheck.mandatory("siteId", siteId); + ParameterCheck.mandatory("name", name); + + SavedSearchDetails result = null; + + // get the saved search node + NodeRef searchNode = getSearchNodeRef(siteId, name); + + if (searchNode != null) + { + // get the json content + ContentReader reader = fileFolderService.getReader(searchNode); + String jsonString = reader.getContentString(); + + // create the saved search details + result = SavedSearchDetails.createFromJSON(jsonString, namespaceService, this, searchNode); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#saveSearch(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) + */ + @Override + public SavedSearchDetails saveSearch(String siteId, String name, String description, String query, RecordsManagementSearchParameters searchParameters, boolean isPublic) + { + // Check for mandatory parameters + ParameterCheck.mandatory("siteId", siteId); + ParameterCheck.mandatory("name", name); + ParameterCheck.mandatory("query", query); + ParameterCheck.mandatory("searchParameters", searchParameters); + + // Create saved search details + SavedSearchDetails savedSearchDetails = new SavedSearchDetails(siteId, name, description, query, searchParameters, isPublic, false, namespaceService, this); + + // Save search details + return saveSearch(savedSearchDetails); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#saveSearch(org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails) + */ + @Override + public SavedSearchDetails saveSearch(final SavedSearchDetails savedSearchDetails) + { + // Check for mandatory parameters + ParameterCheck.mandatory("savedSearchDetails", savedSearchDetails); + + // Get the root saved search container + final String siteId = savedSearchDetails.getSiteId(); + NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); + if (container == null) + { + container = AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return siteService.createContainer(siteId, SEARCH_CONTAINER, null, null); + } + }, AuthenticationUtil.getSystemUserName()); + } + + // Get the private container for the current user + if (!savedSearchDetails.isPublic()) + { + final String userName = AuthenticationUtil.getFullyAuthenticatedUser(); + NodeRef userContainer = fileFolderService.searchSimple(container, userName); + if (userContainer == null) + { + final NodeRef parentContainer = container; + userContainer = AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return fileFolderService.create(parentContainer, userName, ContentModel.TYPE_FOLDER).getNodeRef(); + } + }, AuthenticationUtil.getSystemUserName()); + } + container = userContainer; + } + + // Get the saved search node + NodeRef searchNode = fileFolderService.searchSimple(container, savedSearchDetails.getName()); + if (searchNode == null) + { + final NodeRef searchContainer = container; + searchNode = AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public NodeRef doWork() + { + return fileFolderService.create(searchContainer, savedSearchDetails.getName(), ContentModel.TYPE_CONTENT).getNodeRef(); + } + }, AuthenticationUtil.getSystemUserName()); + } + + // Write the JSON content to search node + final NodeRef writableSearchNode = searchNode; + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + ContentWriter writer = fileFolderService.getWriter(writableSearchNode); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_JSON); + writer.putContent(savedSearchDetails.toJSONString()); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + return savedSearchDetails; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#deleteSavedSearch(java.lang.String, java.lang.String) + */ + @Override + public void deleteSavedSearch(String siteId, String name) + { + // Check parameters + ParameterCheck.mandatory("siteId", siteId); + ParameterCheck.mandatory("name", name); + + // Get the search node for the saved query + NodeRef searchNode = getSearchNodeRef(siteId, name); + if (searchNode != null && fileFolderService.exists(searchNode)) + { + fileFolderService.delete(searchNode); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#deleteSavedSearch(org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails) + */ + @Override + public void deleteSavedSearch(SavedSearchDetails savedSearchDetails) + { + // Check parameters + ParameterCheck.mandatory("savedSearchDetails", savedSearchDetails); + + // Delete the saved search + deleteSavedSearch(savedSearchDetails.getSiteId(), savedSearchDetails.getName()); + } + + /** + * Get the saved search node reference. + * @param siteId site id + * @param name search name + * @return {@link NodeRef} search node reference + */ + private NodeRef getSearchNodeRef(String siteId, String name) + { + NodeRef searchNode = null; + + // Get the root saved search container + NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER); + if (container != null) + { + // try and find the search node + searchNode = fileFolderService.searchSimple(container, name); + + // can't find it so check the users container + if (searchNode == null) + { + String userName = AuthenticationUtil.getFullyAuthenticatedUser(); + NodeRef userContainer = fileFolderService.searchSimple(container, userName); + if (userContainer != null) + { + searchNode = fileFolderService.searchSimple(userContainer, name); + } + } + } + + return searchNode; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#addReports(java.lang.String) + */ + @Override + public void addReports(String siteId) + { + for (ReportDetails report : reports) + { + // Create saved search details + SavedSearchDetails savedSearchDetails = new SavedSearchDetails( + siteId, + report.getName(), + report.getDescription(), + report.getSearch(), + report.getSearchParameters(), + true, + true, + namespaceService, + this); + + // Save search details + saveSearch(savedSearchDetails); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/ReportDetails.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/ReportDetails.java index 763d1c2595..2cdf4d0e95 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/ReportDetails.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/ReportDetails.java @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - - -/** - * Report details. - * - * @author Roy Wetherall - */ -public class ReportDetails -{ - /** Name */ - protected String name; - - /** Description */ - protected String description; - - /** Search */ - protected String search; - - /** Search parameters */ - protected RecordsManagementSearchParameters searchParameters; - - /** - * - * @param name - * @param description - * @param search - * @param searchParameters - */ - public ReportDetails(String name, String description, String search, RecordsManagementSearchParameters searchParameters) - { - this.name = name; - this.description = description; - this.search = search; - this.searchParameters = searchParameters; - } - - /** - * @return {@link String} name - */ - public String getName() - { - return name; - } - - /** - * @return {@link String} description - */ - public String getDescription() - { - return description; - } - - /** - * @param description description - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @return {@link String} search string - */ - public String getSearch() - { - return search; - } - - /** - * @param query query string - */ - public void setSearch(String search) - { - this.search = search; - } - - /** - * @return - */ - public RecordsManagementSearchParameters getSearchParameters() - { - return searchParameters; - } - - /** - * @param searchParameters - */ - public void setSearchParameters(RecordsManagementSearchParameters searchParameters) - { - this.searchParameters = searchParameters; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + + +/** + * Report details. + * + * @author Roy Wetherall + */ +public class ReportDetails +{ + /** Name */ + protected String name; + + /** Description */ + protected String description; + + /** Search */ + protected String search; + + /** Search parameters */ + protected RecordsManagementSearchParameters searchParameters; + + /** + * + * @param name + * @param description + * @param search + * @param searchParameters + */ + public ReportDetails(String name, String description, String search, RecordsManagementSearchParameters searchParameters) + { + this.name = name; + this.description = description; + this.search = search; + this.searchParameters = searchParameters; + } + + /** + * @return {@link String} name + */ + public String getName() + { + return name; + } + + /** + * @return {@link String} description + */ + public String getDescription() + { + return description; + } + + /** + * @param description description + */ + public void setDescription(String description) + { + this.description = description; + } + + /** + * @return {@link String} search string + */ + public String getSearch() + { + return search; + } + + /** + * @param query query string + */ + public void setSearch(String search) + { + this.search = search; + } + + /** + * @return + */ + public RecordsManagementSearchParameters getSearchParameters() + { + return searchParameters; + } + + /** + * @param searchParameters + */ + public void setSearchParameters(RecordsManagementSearchParameters searchParameters) + { + this.searchParameters = searchParameters; + } +} 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 3f4ab473f5..2ea662512b 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 @@ -1,311 +1,311 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.util.ParameterCheck; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Saved search details. - * - * Example format of posted Saved Search JSON: - * - * { - * "siteid" : "rm", - * "name": "search name", - * "description": "the search description", - * "search": "the search sting as entered by the user", - * "public": boolean, - * "searchparams" : - * { - * "maxItems" : 500, - * "records" : true, - * "undeclaredrecords" : false, - * "vitalrecords" : false, - * "recordfolders" : false, - * "frozen" : false, - * "cutoff" : false, - * "containertypes" : - * [ - * "rma:recordSeries", - * "rma:recordCategory" - * ] - * "sort" : - * [ - * { - * "field" : "cm:name", - * "ascending" : true - * } - * ] - * } - * } - * - * where: name and query values are mandatory, - * searchparams contains the filters, sort, etc information about the query - * query is there for backward compatibility - * note: - * "params": "terms=keywords:xyz&undeclared=true", - * "sort": "cm:name/asc" - * "query": "the complete search query string", - * ... are sometimes found in the place of searchparams and are migrated to the new format when re-saved - * params are in URL encoded name/value pair format - * sort is in comma separated "property/dir" packed format i.e. "cm:name/asc,cm:title/desc" - * - * @author Roy Wetherall - */ -public class SavedSearchDetails extends ReportDetails -{ - // JSON label values - public static final String SITE_ID = "siteid"; - public static final String NAME = "name"; - public static final String DESCRIPTION = "description"; - public static final String SEARCH = "search"; - public static final String PUBLIC = "public"; - public static final String REPORT = "report"; - public static final String SEARCHPARAMS = "searchparams"; - - // JSON values for backwards compatibility - public static final String QUERY = "query"; - 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; - - /** Indicates whether the saved search is public or not */ - private boolean isPublic = true; - - /** Indicates whether the saved search is a report */ - private boolean isReport = false; - - /** Helper method to link to search node ref if provided */ - private NodeRef nodeRef = null; - - /** Namespace service */ - NamespaceService namespaceService; - - /** Records management search service */ - RecordsManagementSearchServiceImpl searchService; - - /** Saves search details compatibility */ - private SavedSearchDetailsCompatibility compatibility; - - /** - * - * @param jsonString - * @return - */ - /*package*/ static SavedSearchDetails createFromJSON(String jsonString, NamespaceService namespaceService, RecordsManagementSearchServiceImpl searchService, NodeRef nodeRef) - { - try - { - JSONObject search = new JSONObject(jsonString); - - // Get the site id - String siteId = DEFAULT_SITE_ID; - if (search.has(SITE_ID)) - { - siteId = search.getString(SITE_ID); - } - - // Get the name - if (!search.has(NAME)) - { - throw new AlfrescoRuntimeException("Can not create saved search details from json, because required name is not present. " + jsonString); - } - String name = search.getString(NAME); - - // Get the description - String description = ""; - if (search.has(DESCRIPTION)) - { - description = search.getString(DESCRIPTION); - String translated = I18NUtil.getMessage(description); - if (translated != null) - { - description = translated; - } - } - - // Get the query - String query = null; - if (!search.has(SEARCH)) - { - // We are probably dealing with a "old" style saved search - if (search.has(PARAMS)) - { - String oldParams = search.getString(PARAMS); - query = SavedSearchDetailsCompatibility.getSearchFromParams(oldParams); - } - else - { - throw new AlfrescoRuntimeException("Can not create saved search details from json, because required search is not present. " + jsonString); - } - - } - else - { - query = search.getString(SEARCH); - } - - // Get the search parameters - RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - if (search.has(SEARCHPARAMS)) - { - searchParameters = RecordsManagementSearchParameters.createFromJSON(search.getJSONObject(SEARCHPARAMS), namespaceService); - } - else - { - // See if we are dealing with the old style of saved search - if (search.has(PARAMS)) - { - String oldParams = search.getString(PARAMS); - String oldSort = search.getString(SORT); - searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(oldParams, oldSort, namespaceService); - } - } - - // Determine whether the saved query is public or not - boolean isPublic = true; - if (search.has(PUBLIC)) - { - isPublic = search.getBoolean(PUBLIC); - } - - // Determine whether the saved query is a report or not - boolean isReport = false; - if (search.has(REPORT)) - { - isReport = search.getBoolean(REPORT); - } - - // Create the saved search details object - SavedSearchDetails savedSearchDetails = new SavedSearchDetails(siteId, name, description, query, searchParameters, isPublic, isReport, namespaceService, searchService); - savedSearchDetails.nodeRef = nodeRef; - return savedSearchDetails; - } - catch (JSONException exception) - { - throw new AlfrescoRuntimeException("Can not create saved search details from json. " + jsonString, exception); - } - } - - /** - * @param siteId - * @param name - * @param description - * @param isPublic - */ - /*package*/ SavedSearchDetails( - String siteId, - String name, - String description, - String serach, - RecordsManagementSearchParameters searchParameters, - boolean isPublic, - boolean isReport, - NamespaceService namespaceService, - RecordsManagementSearchServiceImpl searchService) - { - super(name, description, serach, searchParameters); - - ParameterCheck.mandatory("siteId", siteId); - ParameterCheck.mandatory("namespaceService", namespaceService); - ParameterCheck.mandatory("searchService", searchService); - - this.siteId = siteId; - this.isPublic = isPublic; - this.isReport = isReport; - this.namespaceService = namespaceService; - this.compatibility = new SavedSearchDetailsCompatibility(this, namespaceService, searchService); - this.searchService = searchService; - } - - /** - * @return - */ - public String getSiteId() - { - return siteId; - } - - /** - * @return - */ - public boolean isPublic() - { - return isPublic; - } - - /** - * @return - */ - public boolean isReport() - { - return isReport; - } - - public SavedSearchDetailsCompatibility getCompatibility() - { - return compatibility; - } - - /** - * @return NodeRef search node ref, null if not set - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * @return - */ - public String toJSONString() - { - try - { - JSONObject jsonObject = new JSONObject(); - jsonObject.put(SITE_ID, siteId); - jsonObject.put(NAME, name); - jsonObject.put(DESCRIPTION, description); - jsonObject.put(SEARCH, search); - jsonObject.put(SEARCHPARAMS, searchParameters.toJSONObject(namespaceService)); - jsonObject.put(PUBLIC, isPublic); - - // Add full query for backward compatibility - jsonObject.put(QUERY, searchService.buildQueryString(search, searchParameters)); - jsonObject.put(SORT, compatibility.getSort()); - - return jsonObject.toString(); - } - catch (JSONException exception) - { - throw new AlfrescoRuntimeException("Can not convert saved search details into JSON.", exception); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.util.ParameterCheck; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Saved search details. + * + * Example format of posted Saved Search JSON: + * + * { + * "siteid" : "rm", + * "name": "search name", + * "description": "the search description", + * "search": "the search sting as entered by the user", + * "public": boolean, + * "searchparams" : + * { + * "maxItems" : 500, + * "records" : true, + * "undeclaredrecords" : false, + * "vitalrecords" : false, + * "recordfolders" : false, + * "frozen" : false, + * "cutoff" : false, + * "containertypes" : + * [ + * "rma:recordSeries", + * "rma:recordCategory" + * ] + * "sort" : + * [ + * { + * "field" : "cm:name", + * "ascending" : true + * } + * ] + * } + * } + * + * where: name and query values are mandatory, + * searchparams contains the filters, sort, etc information about the query + * query is there for backward compatibility + * note: + * "params": "terms=keywords:xyz&undeclared=true", + * "sort": "cm:name/asc" + * "query": "the complete search query string", + * ... are sometimes found in the place of searchparams and are migrated to the new format when re-saved + * params are in URL encoded name/value pair format + * sort is in comma separated "property/dir" packed format i.e. "cm:name/asc,cm:title/desc" + * + * @author Roy Wetherall + */ +public class SavedSearchDetails extends ReportDetails +{ + // JSON label values + public static final String SITE_ID = "siteid"; + public static final String NAME = "name"; + public static final String DESCRIPTION = "description"; + public static final String SEARCH = "search"; + public static final String PUBLIC = "public"; + public static final String REPORT = "report"; + public static final String SEARCHPARAMS = "searchparams"; + + // JSON values for backwards compatibility + public static final String QUERY = "query"; + 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; + + /** Indicates whether the saved search is public or not */ + private boolean isPublic = true; + + /** Indicates whether the saved search is a report */ + private boolean isReport = false; + + /** Helper method to link to search node ref if provided */ + private NodeRef nodeRef = null; + + /** Namespace service */ + NamespaceService namespaceService; + + /** Records management search service */ + RecordsManagementSearchServiceImpl searchService; + + /** Saves search details compatibility */ + private SavedSearchDetailsCompatibility compatibility; + + /** + * + * @param jsonString + * @return + */ + /*package*/ static SavedSearchDetails createFromJSON(String jsonString, NamespaceService namespaceService, RecordsManagementSearchServiceImpl searchService, NodeRef nodeRef) + { + try + { + JSONObject search = new JSONObject(jsonString); + + // Get the site id + String siteId = DEFAULT_SITE_ID; + if (search.has(SITE_ID)) + { + siteId = search.getString(SITE_ID); + } + + // Get the name + if (!search.has(NAME)) + { + throw new AlfrescoRuntimeException("Can not create saved search details from json, because required name is not present. " + jsonString); + } + String name = search.getString(NAME); + + // Get the description + String description = ""; + if (search.has(DESCRIPTION)) + { + description = search.getString(DESCRIPTION); + String translated = I18NUtil.getMessage(description); + if (translated != null) + { + description = translated; + } + } + + // Get the query + String query = null; + if (!search.has(SEARCH)) + { + // We are probably dealing with a "old" style saved search + if (search.has(PARAMS)) + { + String oldParams = search.getString(PARAMS); + query = SavedSearchDetailsCompatibility.getSearchFromParams(oldParams); + } + else + { + throw new AlfrescoRuntimeException("Can not create saved search details from json, because required search is not present. " + jsonString); + } + + } + else + { + query = search.getString(SEARCH); + } + + // Get the search parameters + RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); + if (search.has(SEARCHPARAMS)) + { + searchParameters = RecordsManagementSearchParameters.createFromJSON(search.getJSONObject(SEARCHPARAMS), namespaceService); + } + else + { + // See if we are dealing with the old style of saved search + if (search.has(PARAMS)) + { + String oldParams = search.getString(PARAMS); + String oldSort = search.getString(SORT); + searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(oldParams, oldSort, namespaceService); + } + } + + // Determine whether the saved query is public or not + boolean isPublic = true; + if (search.has(PUBLIC)) + { + isPublic = search.getBoolean(PUBLIC); + } + + // Determine whether the saved query is a report or not + boolean isReport = false; + if (search.has(REPORT)) + { + isReport = search.getBoolean(REPORT); + } + + // Create the saved search details object + SavedSearchDetails savedSearchDetails = new SavedSearchDetails(siteId, name, description, query, searchParameters, isPublic, isReport, namespaceService, searchService); + savedSearchDetails.nodeRef = nodeRef; + return savedSearchDetails; + } + catch (JSONException exception) + { + throw new AlfrescoRuntimeException("Can not create saved search details from json. " + jsonString, exception); + } + } + + /** + * @param siteId + * @param name + * @param description + * @param isPublic + */ + /*package*/ SavedSearchDetails( + String siteId, + String name, + String description, + String serach, + RecordsManagementSearchParameters searchParameters, + boolean isPublic, + boolean isReport, + NamespaceService namespaceService, + RecordsManagementSearchServiceImpl searchService) + { + super(name, description, serach, searchParameters); + + ParameterCheck.mandatory("siteId", siteId); + ParameterCheck.mandatory("namespaceService", namespaceService); + ParameterCheck.mandatory("searchService", searchService); + + this.siteId = siteId; + this.isPublic = isPublic; + this.isReport = isReport; + this.namespaceService = namespaceService; + this.compatibility = new SavedSearchDetailsCompatibility(this, namespaceService, searchService); + this.searchService = searchService; + } + + /** + * @return + */ + public String getSiteId() + { + return siteId; + } + + /** + * @return + */ + public boolean isPublic() + { + return isPublic; + } + + /** + * @return + */ + public boolean isReport() + { + return isReport; + } + + public SavedSearchDetailsCompatibility getCompatibility() + { + return compatibility; + } + + /** + * @return NodeRef search node ref, null if not set + */ + public NodeRef getNodeRef() + { + return nodeRef; + } + + /** + * @return + */ + public String toJSONString() + { + try + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put(SITE_ID, siteId); + jsonObject.put(NAME, name); + jsonObject.put(DESCRIPTION, description); + jsonObject.put(SEARCH, search); + jsonObject.put(SEARCHPARAMS, searchParameters.toJSONObject(namespaceService)); + jsonObject.put(PUBLIC, isPublic); + + // Add full query for backward compatibility + jsonObject.put(QUERY, searchService.buildQueryString(search, searchParameters)); + jsonObject.put(SORT, compatibility.getSort()); + + return jsonObject.toString(); + } + catch (JSONException exception) + { + throw new AlfrescoRuntimeException("Can not convert saved search details into JSON.", exception); + } + } +} 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 c6c272c6d6..dac71904b0 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 @@ -1,223 +1,223 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.search; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * Compatibility class. - * - * Used to bridge between the old style of saved search passed and required by the UI and the new actual saved search details. - * Eventually will be factored out as web scripts are brought up to date. - */ -public class SavedSearchDetailsCompatibility implements RecordsManagementModel -{ - /** Saved search details */ - private final SavedSearchDetails savedSearchDetails; - - /** Namespace service */ - private final NamespaceService namespaceService; - - /** Records management search service implementation */ - private final RecordsManagementSearchServiceImpl searchService; - - /** - * Retrieve the search from the parameter string - * @param params parameter string - * @return String search term - */ - public static String getSearchFromParams(String params) - { - String search = null; - String[] values = params.split("&"); - for (String value : values) - { - if (value.startsWith("terms")) - { - String[] terms = value.trim().split("="); - try - { - search = URLDecoder.decode(terms[1], "UTF-8"); - } - catch (UnsupportedEncodingException e) - { - // Do nothing just return null - search = null; - } - break; - } - } - - return search; - } - - public static RecordsManagementSearchParameters createSearchParameters(String params, String sort, NamespaceService namespaceService) - { - return createSearchParameters(params, new String[]{"&", "="}, sort, namespaceService); - } - - /** - * - * @param params - * @param sort - * @param namespaceService - * @return - */ - public static RecordsManagementSearchParameters createSearchParameters(String params, String[] paramsDelim, String sort, NamespaceService namespaceService) - { - RecordsManagementSearchParameters result = new RecordsManagementSearchParameters(); - List includedContainerTypes = new ArrayList(2); - - // Map the param values into the search parameter object - String[] values = params.split(paramsDelim[0]); - for (String value : values) - { - String[] paramValues = value.split(paramsDelim[1]); - String paramName = paramValues[0].trim(); - String paramValue = paramValues[1].trim(); - if ("records".equals(paramName)) - { - result.setIncludeRecords(Boolean.parseBoolean(paramValue)); - } - else if ("undeclared".equals(paramName)) - { - result.setIncludeUndeclaredRecords(Boolean.parseBoolean(paramValue)); - } - else if ("vital".equals(paramName)) - { - result.setIncludeVitalRecords(Boolean.parseBoolean(paramValue)); - } - else if ("folders".equals(paramName)) - { - result.setIncludeRecordFolders(Boolean.parseBoolean(paramValue)); - } - else if ("frozen".equals(paramName)) - { - result.setIncludeFrozen(Boolean.parseBoolean(paramValue)); - } - else if ("cutoff".equals(paramName)) - { - result.setIncludeCutoff(Boolean.parseBoolean(paramValue)); - } - else if ("categories".equals(paramName) && Boolean.parseBoolean(paramValue)) - { - includedContainerTypes.add(TYPE_RECORD_CATEGORY); - } - } - result.setIncludedContainerTypes(includedContainerTypes); - - if (sort != null) - { - // Map the sort string into the search details - String[] sortPairs = sort.split(","); - List sortOrder = new ArrayList(sortPairs.length); - for (String sortPairString : sortPairs) - { - String[] sortPair = sortPairString.split("/"); - QName field = QName.createQName(sortPair[0], namespaceService); - Boolean isAcsending = Boolean.FALSE; - if ("asc".equals(sortPair[1])) - { - isAcsending = Boolean.TRUE; - } - sortOrder.add(new SortItem(field, isAcsending)); - } - result.setSortOrder(sortOrder); - } - - return result; - } - - /** - * Constructor - * @param savedSearchDetails - */ - public SavedSearchDetailsCompatibility(SavedSearchDetails savedSearchDetails, - NamespaceService namespaceService, - RecordsManagementSearchServiceImpl searchService) - { - this.savedSearchDetails = savedSearchDetails; - this.namespaceService = namespaceService; - this.searchService = searchService; - } - - /** - * Get the sort string from the saved search details - * @return - */ - public String getSort() - { - StringBuilder builder = new StringBuilder(64); - - for (SortItem entry : this.savedSearchDetails.getSearchParameters().getSortOrder()) - { - if (builder.length() !=0) - { - builder.append(","); - } - - String order = "desc"; - if (entry.assc) - { - order = "asc"; - } - builder.append(entry.property.toPrefixString(this.namespaceService)) - .append("/") - .append(order); - } - - return builder.toString(); - } - - /** - * Get the parameter string from the saved search details - * @return - */ - public String getParams() - { - List includeContainerTypes = this.savedSearchDetails.getSearchParameters().getIncludedContainerTypes(); - StringBuilder builder = new StringBuilder(128); - builder.append("terms=").append(this.savedSearchDetails.getSearch()).append("&") - .append("records=").append(this.savedSearchDetails.getSearchParameters().isIncludeRecords()).append("&") - .append("undeclared=").append(this.savedSearchDetails.getSearchParameters().isIncludeUndeclaredRecords()).append("&") - .append("vital=").append(this.savedSearchDetails.getSearchParameters().isIncludeVitalRecords()).append("&") - .append("folders=").append(this.savedSearchDetails.getSearchParameters().isIncludeRecordFolders()).append("&") - .append("frozen=").append(this.savedSearchDetails.getSearchParameters().isIncludeFrozen()).append("&") - .append("cutoff=").append(this.savedSearchDetails.getSearchParameters().isIncludeCutoff()).append("&") - .append("categories=").append(includeContainerTypes.contains(TYPE_RECORD_CATEGORY)).append("&") - .append("series=").append(false); - return builder.toString(); - } - - /** - * Build the full query string - * @return - */ - public String getQuery() - { - return searchService.buildQueryString(this.savedSearchDetails.getSearch(), this.savedSearchDetails.getSearchParameters()); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.search; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Compatibility class. + * + * Used to bridge between the old style of saved search passed and required by the UI and the new actual saved search details. + * Eventually will be factored out as web scripts are brought up to date. + */ +public class SavedSearchDetailsCompatibility implements RecordsManagementModel +{ + /** Saved search details */ + private final SavedSearchDetails savedSearchDetails; + + /** Namespace service */ + private final NamespaceService namespaceService; + + /** Records management search service implementation */ + private final RecordsManagementSearchServiceImpl searchService; + + /** + * Retrieve the search from the parameter string + * @param params parameter string + * @return String search term + */ + public static String getSearchFromParams(String params) + { + String search = null; + String[] values = params.split("&"); + for (String value : values) + { + if (value.startsWith("terms")) + { + String[] terms = value.trim().split("="); + try + { + search = URLDecoder.decode(terms[1], "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + // Do nothing just return null + search = null; + } + break; + } + } + + return search; + } + + public static RecordsManagementSearchParameters createSearchParameters(String params, String sort, NamespaceService namespaceService) + { + return createSearchParameters(params, new String[]{"&", "="}, sort, namespaceService); + } + + /** + * + * @param params + * @param sort + * @param namespaceService + * @return + */ + public static RecordsManagementSearchParameters createSearchParameters(String params, String[] paramsDelim, String sort, NamespaceService namespaceService) + { + RecordsManagementSearchParameters result = new RecordsManagementSearchParameters(); + List includedContainerTypes = new ArrayList(2); + + // Map the param values into the search parameter object + String[] values = params.split(paramsDelim[0]); + for (String value : values) + { + String[] paramValues = value.split(paramsDelim[1]); + String paramName = paramValues[0].trim(); + String paramValue = paramValues[1].trim(); + if ("records".equals(paramName)) + { + result.setIncludeRecords(Boolean.parseBoolean(paramValue)); + } + else if ("undeclared".equals(paramName)) + { + result.setIncludeUndeclaredRecords(Boolean.parseBoolean(paramValue)); + } + else if ("vital".equals(paramName)) + { + result.setIncludeVitalRecords(Boolean.parseBoolean(paramValue)); + } + else if ("folders".equals(paramName)) + { + result.setIncludeRecordFolders(Boolean.parseBoolean(paramValue)); + } + else if ("frozen".equals(paramName)) + { + result.setIncludeFrozen(Boolean.parseBoolean(paramValue)); + } + else if ("cutoff".equals(paramName)) + { + result.setIncludeCutoff(Boolean.parseBoolean(paramValue)); + } + else if ("categories".equals(paramName) && Boolean.parseBoolean(paramValue)) + { + includedContainerTypes.add(TYPE_RECORD_CATEGORY); + } + } + result.setIncludedContainerTypes(includedContainerTypes); + + if (sort != null) + { + // Map the sort string into the search details + String[] sortPairs = sort.split(","); + List sortOrder = new ArrayList(sortPairs.length); + for (String sortPairString : sortPairs) + { + String[] sortPair = sortPairString.split("/"); + QName field = QName.createQName(sortPair[0], namespaceService); + Boolean isAcsending = Boolean.FALSE; + if ("asc".equals(sortPair[1])) + { + isAcsending = Boolean.TRUE; + } + sortOrder.add(new SortItem(field, isAcsending)); + } + result.setSortOrder(sortOrder); + } + + return result; + } + + /** + * Constructor + * @param savedSearchDetails + */ + public SavedSearchDetailsCompatibility(SavedSearchDetails savedSearchDetails, + NamespaceService namespaceService, + RecordsManagementSearchServiceImpl searchService) + { + this.savedSearchDetails = savedSearchDetails; + this.namespaceService = namespaceService; + this.searchService = searchService; + } + + /** + * Get the sort string from the saved search details + * @return + */ + public String getSort() + { + StringBuilder builder = new StringBuilder(64); + + for (SortItem entry : this.savedSearchDetails.getSearchParameters().getSortOrder()) + { + if (builder.length() !=0) + { + builder.append(","); + } + + String order = "desc"; + if (entry.assc) + { + order = "asc"; + } + builder.append(entry.property.toPrefixString(this.namespaceService)) + .append("/") + .append(order); + } + + return builder.toString(); + } + + /** + * Get the parameter string from the saved search details + * @return + */ + public String getParams() + { + List includeContainerTypes = this.savedSearchDetails.getSearchParameters().getIncludedContainerTypes(); + StringBuilder builder = new StringBuilder(128); + builder.append("terms=").append(this.savedSearchDetails.getSearch()).append("&") + .append("records=").append(this.savedSearchDetails.getSearchParameters().isIncludeRecords()).append("&") + .append("undeclared=").append(this.savedSearchDetails.getSearchParameters().isIncludeUndeclaredRecords()).append("&") + .append("vital=").append(this.savedSearchDetails.getSearchParameters().isIncludeVitalRecords()).append("&") + .append("folders=").append(this.savedSearchDetails.getSearchParameters().isIncludeRecordFolders()).append("&") + .append("frozen=").append(this.savedSearchDetails.getSearchParameters().isIncludeFrozen()).append("&") + .append("cutoff=").append(this.savedSearchDetails.getSearchParameters().isIncludeCutoff()).append("&") + .append("categories=").append(includeContainerTypes.contains(TYPE_RECORD_CATEGORY)).append("&") + .append("series=").append(false); + return builder.toString(); + } + + /** + * Build the full query string + * @return + */ + public String getQuery() + { + return searchService.buildQueryString(this.savedSearchDetails.getSearch(), this.savedSearchDetails.getSearchParameters()); + } } \ No newline at end of file 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 index 925b1d3193..4213f28649 100644 --- 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 @@ -1,15 +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; - } - -} +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; + } + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityService.java index afa06f4fdb..908f09a2e9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityService.java @@ -1,105 +1,105 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * - - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - - * 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 . - * #L% - */ - -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.util.Set; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Extended security service. - * - * @author Roy Wetherall - * @since 2.1 - */ -@AlfrescoPublicApi -public interface ExtendedSecurityService extends DeprecatedExtendedSecurityService -{ - /** IPR group prefix */ - static final String IPR_GROUP_PREFIX = "IPR"; - - /** - * Indicates whether a node has extended security. - * - * @param nodeRef node reference - * @return boolean true if the node has extended security, false otherwise - */ - boolean hasExtendedSecurity(NodeRef nodeRef); - - /** - * Gets the set of authorities that are extended readers for the given node. - * - * @param nodeRef node reference - * @return {@link Set}<{@link String}> set of extended readers - */ - Set getReaders(NodeRef nodeRef); - - /** - * Get the set of authorities that are extended writers for the given node. - * - * @param nodeRef node reference - * @return {@link Set}<{@link String}> set of extended writers - */ - Set getWriters(NodeRef nodeRef); - - /** - * Helper to allow caller to provide authority sets as a pair where the - * first is the readers and the second is the writers. - * - * @see #set(NodeRef, Set, Set) - * - * @param nodeRef node reference - * @param readersAndWriters pair where first is the set of readers and the - * second is the set of writers - */ - void set(NodeRef nodeRef, Pair, Set> readersAndWriters); - - /** - * Set extended security for a node, where the readers will be granted ReadRecord - * permission and ViewRecord capability to the node and where the writers will be - * granted Filling permission and Filling capability to the node. - *

- * Note it is vaild to provide 'null' values for readers and/or writers. - * - * @param nodeRef node reference - * @param readers set of readers - * @param writers set of writers - * - * @since 2.5 - */ - void set(NodeRef nodeRef, Set readers, Set writers); - - /** - * Removes all extended security from a node. - * - * @param nodeRef node reference - */ - void remove(NodeRef nodeRef); -} +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ + +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.util.Set; + +import org.alfresco.api.AlfrescoPublicApi; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; + +/** + * Extended security service. + * + * @author Roy Wetherall + * @since 2.1 + */ +@AlfrescoPublicApi +public interface ExtendedSecurityService extends DeprecatedExtendedSecurityService +{ + /** IPR group prefix */ + static final String IPR_GROUP_PREFIX = "IPR"; + + /** + * Indicates whether a node has extended security. + * + * @param nodeRef node reference + * @return boolean true if the node has extended security, false otherwise + */ + boolean hasExtendedSecurity(NodeRef nodeRef); + + /** + * Gets the set of authorities that are extended readers for the given node. + * + * @param nodeRef node reference + * @return {@link Set}<{@link String}> set of extended readers + */ + Set getReaders(NodeRef nodeRef); + + /** + * Get the set of authorities that are extended writers for the given node. + * + * @param nodeRef node reference + * @return {@link Set}<{@link String}> set of extended writers + */ + Set getWriters(NodeRef nodeRef); + + /** + * Helper to allow caller to provide authority sets as a pair where the + * first is the readers and the second is the writers. + * + * @see #set(NodeRef, Set, Set) + * + * @param nodeRef node reference + * @param readersAndWriters pair where first is the set of readers and the + * second is the set of writers + */ + void set(NodeRef nodeRef, Pair, Set> readersAndWriters); + + /** + * Set extended security for a node, where the readers will be granted ReadRecord + * permission and ViewRecord capability to the node and where the writers will be + * granted Filling permission and Filling capability to the node. + *

+ * Note it is vaild to provide 'null' values for readers and/or writers. + * + * @param nodeRef node reference + * @param readers set of readers + * @param writers set of writers + * + * @since 2.5 + */ + void set(NodeRef nodeRef, Set readers, Set writers); + + /** + * Removes all extended security from a node. + * + * @param nodeRef node reference + */ + void remove(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java index fda0573794..5f76fac332 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java @@ -1,646 +1,646 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * - - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - - * 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 . - * #L% - */ - -package org.alfresco.module.org_alfresco_module_rm.security; - - -import static org.alfresco.service.cmr.security.PermissionService.GROUP_PREFIX; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.security.authority.RMAuthority; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.extensions.webscripts.ui.common.StringUtils; - -/** - * Extended security service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ExtendedSecurityServiceImpl extends ServiceBaseImpl - implements ExtendedSecurityService, - RecordsManagementModel, - ApplicationListener -{ - /** ipr group names */ - static final String ROOT_IPR_GROUP = "INPLACE_RECORD_MANAGEMENT"; - static final String READER_GROUP_PREFIX = ExtendedSecurityService.IPR_GROUP_PREFIX + "R"; - static final String WRITER_GROUP_PREFIX = ExtendedSecurityService.IPR_GROUP_PREFIX + "W"; - - /** max page size for authority query */ - private static final int MAX_ITEMS = 50; - - /** File plan service */ - private FilePlanService filePlanService; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** authority service */ - private AuthorityService authorityService; - - /** permission service */ - private PermissionService permissionService; - - /** transaction service */ - private TransactionService transactionService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanRoleService file plan role service - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param transactionService transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * Application context refresh event handler - */ - @Override - public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) - { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // if the root group doesn't exist then create it - if (!authorityService.authorityExists(getRootIRPGroup())) - { - authorityService.createAuthority(AuthorityType.GROUP, ROOT_IPR_GROUP, ROOT_IPR_GROUP, Collections.singleton(RMAuthority.ZONE_APP_RM)); - } - - return null; - } - }); - } - - /** - * Get root IPR group name - */ - private String getRootIRPGroup() - { - return GROUP_PREFIX + ROOT_IPR_GROUP; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#hasExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean hasExtendedSecurity(NodeRef nodeRef) - { - return (getIPRGroups(nodeRef) != null); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getReaders(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - public Set getReaders(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - Set result = Collections.EMPTY_SET; - Pair iprGroups = getIPRGroups(nodeRef); - if (iprGroups != null) - { - result = getAuthorities(iprGroups.getFirst()); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#getWriters(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - public Set getWriters(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - Set result = Collections.EMPTY_SET; - Pair iprGroups = getIPRGroups(nodeRef); - if (iprGroups != null) - { - result = getAuthorities(iprGroups.getSecond()); - } - - return result; - } - - /** - * Helper to get authorities for a given group - * - * @param group group name - * @return Set immediate authorities - */ - private Set getAuthorities(String group) - { - Set result = new HashSet(); - result.addAll(authorityService.getContainedAuthorities(null, group, true)); - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#set(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.util.Pair) - */ - @Override - public void set(NodeRef nodeRef, Pair, Set> readersAndWriters) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - set(nodeRef, readersAndWriters.getFirst(), readersAndWriters.getSecond()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#set(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) - */ - @Override - public void set(NodeRef nodeRef, Set readers, Set writers) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // remove existing extended security, assuming there is any - remove(nodeRef); - - // find groups - Pair iprGroups = createOrFindIPRGroups(readers, writers); - - // assign groups to correct fileplan roles - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS, iprGroups.getFirst()); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS, iprGroups.getSecond()); - - // assign groups to node - assignIPRGroupsToNode(iprGroups, nodeRef); - - // apply the readers to any renditions of the content - if (isRecord(nodeRef)) - { - List assocs = nodeService.getChildAssocs(nodeRef, RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef child = assoc.getChildRef(); - assignIPRGroupsToNode(iprGroups, child); - } - } - } - - /** - * Get the IPR groups associated with a given node reference. - *

- * Return null if none found. - * - * @param nodeRef node reference - * @return Pair where first is the read group and second if the write group, null if none found - */ - private Pair getIPRGroups(NodeRef nodeRef) - { - Pair result = null; - String iprReaderGroup = null; - String iprWriterGroup = null; - - // get all the set permissions - Set permissions = permissionService.getAllSetPermissions(nodeRef); - for (AccessPermission permission : permissions) - { - // look for the presence of the reader group - if (permission.getAuthority().startsWith(GROUP_PREFIX + READER_GROUP_PREFIX)) - { - iprReaderGroup = permission.getAuthority(); - } - // look for the presence of the writer group - else if (permission.getAuthority().startsWith(GROUP_PREFIX + WRITER_GROUP_PREFIX)) - { - iprWriterGroup = permission.getAuthority(); - } - } - - // assuming the are both present then return - if (iprReaderGroup != null && iprWriterGroup != null) - { - result = new Pair(iprReaderGroup, iprWriterGroup); - } - - return result; - } - - /** - * Given a set of readers and writers find or create the appropriate IPR groups. - *

- * The IPR groups are named with hashes of the authority lists in order to reduce - * the set of groups that require exact match. A further index is used to handle - * a situation where there is a hash clash, but a difference in the authority lists. - *

- * When no match is found the groups are created. Once created - * - * @param filePlan file plan - * @param readers authorities with read - * @param writers authorities with write - * @return Pair where first is the full name of the read group and - * second is the full name of the write group - */ - private Pair createOrFindIPRGroups(Set readers, Set writers) - { - return new Pair( - createOrFindIPRGroup(READER_GROUP_PREFIX, readers), - createOrFindIPRGroup(WRITER_GROUP_PREFIX, writers)); - } - - /** - * Create or find an IPR group based on the provided prefix and authorities. - * - * @param groupPrefix group prefix - * @param authorities authorities - * @return String full group name - */ - private String createOrFindIPRGroup(String groupPrefix, Set authorities) - { - String group = null; - - // find group or determine what the next index is if no group exists or there is a clash - Pair groupResult = findIPRGroup(groupPrefix, authorities); - - if (groupResult.getFirst() == null) - { - group = createIPRGroup(groupPrefix, authorities, groupResult.getSecond()); - } - else - { - group = groupResult.getFirst(); - } - - return group; - } - - /** - * Given a group name prefix and the authorities, finds the exact match existing group. - *

- * If the group does not exist then the group returned is null and the index shows the next available - * group index for creation. - * - * @param groupPrefix group name prefix - * @param authorities authorities - * @return Pair where first is the name of the found group, null if none found and second - * if the next available create index - */ - private Pair findIPRGroup(String groupPrefix, Set authorities) - { - String iprGroup = null; - int nextGroupIndex = 0; - boolean hasMoreItems = true; - int pageCount = 0; - - // determine the short name prefix - String groupShortNamePrefix = getIPRGroupPrefixShortName(groupPrefix, authorities); - - // iterate over the authorities to find a match - while (hasMoreItems == true) - { - // get matching authorities - PagingResults results = authorityService.getAuthorities(AuthorityType.GROUP, - RMAuthority.ZONE_APP_RM, - groupShortNamePrefix, - false, - false, - new PagingRequest(MAX_ITEMS*pageCount, MAX_ITEMS)); - - // record the total count - nextGroupIndex = nextGroupIndex + results.getPage().size(); - - // see if any of the matching groups exactly match - for (String group : results.getPage()) - { - // if exists and matches we have found our group - if (isIPRGroupTrueMatch(group, authorities)) - { - iprGroup = group; - break; - } - } - - // determine if there are any more pages to inspect - hasMoreItems = results.hasMoreItems(); - pageCount ++; - } - - return new Pair(iprGroup, nextGroupIndex); - } - - /** - * Determines whether a group exactly matches a list of authorities. - * - * @param authorities list of authorities - * @param group group - * @return - */ - private boolean isIPRGroupTrueMatch(String group, Set authorities) - { - Set contained = authorityService.getContainedAuthorities(null, group, true); - return contained.equals(authorities); - } - - /** - * Get IPR group prefix short name. - *

- * 'package' scope to help testing. - * - * @param prefix prefix - * @param authorities authorities - * @return String group prefix short name - */ - /*package*/ String getIPRGroupPrefixShortName(String prefix, Set authorities) - { - StringBuilder builder = new StringBuilder(128) - .append(prefix) - .append(getAuthoritySetHashCode(authorities)); - - return builder.toString(); - } - - /** - * Get IPR group short name. - *

- * Note this excludes the "GROUP_" prefix. - *

- * 'package' scope to help testing. - * - * @param prefix prefix - * @param readers read authorities - * @param writers write authorities - * @param index group index - * @return String group short name - */ - /*package*/ String getIPRGroupShortName(String prefix, Set authorities, int index) - { - return getIPRGroupShortName(prefix, authorities, Integer.toString(index)); - } - - /** - * Get IPR group short name. - *

- * Note this excludes the "GROUP_" prefix. - * - * @param prefix prefix - * @param readers read authorities - * @param writers write authorities - * @param index group index - * @return String group short name - */ - private String getIPRGroupShortName(String prefix, Set authorities, String index) - { - StringBuilder builder = new StringBuilder(128) - .append(getIPRGroupPrefixShortName(prefix, authorities)) - .append(index); - - return builder.toString(); - } - - /** - * Gets the hashcode value of a set of authorities. - * - * @param authorities set of authorities - * @return int hash code - */ - private int getAuthoritySetHashCode(Set authorities) - { - int result = 0; - if (authorities != null && !authorities.isEmpty()) - { - result = StringUtils.join(authorities.toArray(), "").hashCode(); - } - return result; - } - - /** - * Creates a new IPR group. - * - * @param groupNamePrefix group name prefix - * @param children child authorities - * @param index group index - * @return String full name of created group - */ - private String createIPRGroup(String groupNamePrefix, Set children, int index) - { - ParameterCheck.mandatory("groupNamePrefix", groupNamePrefix); - - // get the group name - String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index); - - // create group - String group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM)); - - // add root parent - authorityService.addAuthority(getRootIRPGroup(), group); - - // add children if provided - if (children != null) - { - for (String child : children) - { - if (authorityService.authorityExists(child) && - !PermissionService.ALL_AUTHORITIES.equals(child)) - { - authorityService.addAuthority(group, child); - } - } - } - - return group; - } - - /** - * Assign IPR groups to a node reference with the correct permissions. - * - * @param iprGroups iprGroups, first read and second write - * @param nodeRef node reference - */ - private void assignIPRGroupsToNode(Pair iprGroups, NodeRef nodeRef) - { - permissionService.setPermission(nodeRef, iprGroups.getFirst(), RMPermissionModel.READ_RECORDS, true); - permissionService.setPermission(nodeRef, iprGroups.getSecond(), RMPermissionModel.FILING, true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#remove(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void remove(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - Pair iprGroups = getIPRGroups(nodeRef); - if (iprGroups != null) - { - // remove any extended security that might be present - clearPermissions(nodeRef, iprGroups); - - // remove the readers from any renditions of the content - if (isRecord(nodeRef)) - { - List assocs = nodeService.getChildAssocs(nodeRef, RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef child = assoc.getChildRef(); - clearPermissions(child, iprGroups); - } - } - } - } - - /** - * Clear the nodes IPR permissions - * - * @param nodeRef node reference - */ - private void clearPermissions(NodeRef nodeRef, Pair iprGroups) - { - // remove group permissions from node - permissionService.clearPermission(nodeRef, iprGroups.getFirst()); - permissionService.clearPermission(nodeRef, iprGroups.getSecond()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#getExtendedReaders(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override @Deprecated public Set getExtendedReaders(NodeRef nodeRef) - { - return getReaders(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#getExtendedWriters(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override @Deprecated public Set getExtendedWriters(NodeRef nodeRef) - { - return getWriters(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#addExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) - */ - @Override @Deprecated public void addExtendedSecurity(NodeRef nodeRef, Set readers, Set writers) - { - set(nodeRef, readers, writers); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#addExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean) - */ - @Override @Deprecated public void addExtendedSecurity(NodeRef nodeRef, Set readers, Set writers, boolean applyToParents) - { - set(nodeRef, readers, writers); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override @Deprecated public void removeAllExtendedSecurity(NodeRef nodeRef) - { - remove(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) - */ - @Override @Deprecated public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Set writers) - { - remove(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean) - */ - @Override @Deprecated public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Setwriters, boolean applyToParents) - { - remove(nodeRef); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override @Deprecated public void removeAllExtendedSecurity(NodeRef nodeRef, boolean applyToParents) - { - remove(nodeRef); - } -} +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ + +package org.alfresco.module.org_alfresco_module_rm.security; + + +import static org.alfresco.service.cmr.security.PermissionService.GROUP_PREFIX; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.alfresco.model.RenditionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.query.PagingRequest; +import org.alfresco.query.PagingResults; +import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.extensions.webscripts.ui.common.StringUtils; + +/** + * Extended security service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ExtendedSecurityServiceImpl extends ServiceBaseImpl + implements ExtendedSecurityService, + RecordsManagementModel, + ApplicationListener +{ + /** ipr group names */ + static final String ROOT_IPR_GROUP = "INPLACE_RECORD_MANAGEMENT"; + static final String READER_GROUP_PREFIX = ExtendedSecurityService.IPR_GROUP_PREFIX + "R"; + static final String WRITER_GROUP_PREFIX = ExtendedSecurityService.IPR_GROUP_PREFIX + "W"; + + /** max page size for authority query */ + private static final int MAX_ITEMS = 50; + + /** File plan service */ + private FilePlanService filePlanService; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** authority service */ + private AuthorityService authorityService; + + /** permission service */ + private PermissionService permissionService; + + /** transaction service */ + private TransactionService transactionService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * @param authorityService authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + /** + * Application context refresh event handler + */ + @Override + public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) + { + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // if the root group doesn't exist then create it + if (!authorityService.authorityExists(getRootIRPGroup())) + { + authorityService.createAuthority(AuthorityType.GROUP, ROOT_IPR_GROUP, ROOT_IPR_GROUP, Collections.singleton(RMAuthority.ZONE_APP_RM)); + } + + return null; + } + }); + } + + /** + * Get root IPR group name + */ + private String getRootIRPGroup() + { + return GROUP_PREFIX + ROOT_IPR_GROUP; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#hasExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean hasExtendedSecurity(NodeRef nodeRef) + { + return (getIPRGroups(nodeRef) != null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getReaders(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + public Set getReaders(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + Set result = Collections.EMPTY_SET; + Pair iprGroups = getIPRGroups(nodeRef); + if (iprGroups != null) + { + result = getAuthorities(iprGroups.getFirst()); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#getWriters(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + public Set getWriters(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + Set result = Collections.EMPTY_SET; + Pair iprGroups = getIPRGroups(nodeRef); + if (iprGroups != null) + { + result = getAuthorities(iprGroups.getSecond()); + } + + return result; + } + + /** + * Helper to get authorities for a given group + * + * @param group group name + * @return Set immediate authorities + */ + private Set getAuthorities(String group) + { + Set result = new HashSet(); + result.addAll(authorityService.getContainedAuthorities(null, group, true)); + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#set(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.util.Pair) + */ + @Override + public void set(NodeRef nodeRef, Pair, Set> readersAndWriters) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + set(nodeRef, readersAndWriters.getFirst(), readersAndWriters.getSecond()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#set(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) + */ + @Override + public void set(NodeRef nodeRef, Set readers, Set writers) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // remove existing extended security, assuming there is any + remove(nodeRef); + + // find groups + Pair iprGroups = createOrFindIPRGroups(readers, writers); + + // assign groups to correct fileplan roles + NodeRef filePlan = filePlanService.getFilePlan(nodeRef); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS, iprGroups.getFirst()); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS, iprGroups.getSecond()); + + // assign groups to node + assignIPRGroupsToNode(iprGroups, nodeRef); + + // apply the readers to any renditions of the content + if (isRecord(nodeRef)) + { + List assocs = nodeService.getChildAssocs(nodeRef, RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef child = assoc.getChildRef(); + assignIPRGroupsToNode(iprGroups, child); + } + } + } + + /** + * Get the IPR groups associated with a given node reference. + *

+ * Return null if none found. + * + * @param nodeRef node reference + * @return Pair where first is the read group and second if the write group, null if none found + */ + private Pair getIPRGroups(NodeRef nodeRef) + { + Pair result = null; + String iprReaderGroup = null; + String iprWriterGroup = null; + + // get all the set permissions + Set permissions = permissionService.getAllSetPermissions(nodeRef); + for (AccessPermission permission : permissions) + { + // look for the presence of the reader group + if (permission.getAuthority().startsWith(GROUP_PREFIX + READER_GROUP_PREFIX)) + { + iprReaderGroup = permission.getAuthority(); + } + // look for the presence of the writer group + else if (permission.getAuthority().startsWith(GROUP_PREFIX + WRITER_GROUP_PREFIX)) + { + iprWriterGroup = permission.getAuthority(); + } + } + + // assuming the are both present then return + if (iprReaderGroup != null && iprWriterGroup != null) + { + result = new Pair(iprReaderGroup, iprWriterGroup); + } + + return result; + } + + /** + * Given a set of readers and writers find or create the appropriate IPR groups. + *

+ * The IPR groups are named with hashes of the authority lists in order to reduce + * the set of groups that require exact match. A further index is used to handle + * a situation where there is a hash clash, but a difference in the authority lists. + *

+ * When no match is found the groups are created. Once created + * + * @param filePlan file plan + * @param readers authorities with read + * @param writers authorities with write + * @return Pair where first is the full name of the read group and + * second is the full name of the write group + */ + private Pair createOrFindIPRGroups(Set readers, Set writers) + { + return new Pair( + createOrFindIPRGroup(READER_GROUP_PREFIX, readers), + createOrFindIPRGroup(WRITER_GROUP_PREFIX, writers)); + } + + /** + * Create or find an IPR group based on the provided prefix and authorities. + * + * @param groupPrefix group prefix + * @param authorities authorities + * @return String full group name + */ + private String createOrFindIPRGroup(String groupPrefix, Set authorities) + { + String group = null; + + // find group or determine what the next index is if no group exists or there is a clash + Pair groupResult = findIPRGroup(groupPrefix, authorities); + + if (groupResult.getFirst() == null) + { + group = createIPRGroup(groupPrefix, authorities, groupResult.getSecond()); + } + else + { + group = groupResult.getFirst(); + } + + return group; + } + + /** + * Given a group name prefix and the authorities, finds the exact match existing group. + *

+ * If the group does not exist then the group returned is null and the index shows the next available + * group index for creation. + * + * @param groupPrefix group name prefix + * @param authorities authorities + * @return Pair where first is the name of the found group, null if none found and second + * if the next available create index + */ + private Pair findIPRGroup(String groupPrefix, Set authorities) + { + String iprGroup = null; + int nextGroupIndex = 0; + boolean hasMoreItems = true; + int pageCount = 0; + + // determine the short name prefix + String groupShortNamePrefix = getIPRGroupPrefixShortName(groupPrefix, authorities); + + // iterate over the authorities to find a match + while (hasMoreItems == true) + { + // get matching authorities + PagingResults results = authorityService.getAuthorities(AuthorityType.GROUP, + RMAuthority.ZONE_APP_RM, + groupShortNamePrefix, + false, + false, + new PagingRequest(MAX_ITEMS*pageCount, MAX_ITEMS)); + + // record the total count + nextGroupIndex = nextGroupIndex + results.getPage().size(); + + // see if any of the matching groups exactly match + for (String group : results.getPage()) + { + // if exists and matches we have found our group + if (isIPRGroupTrueMatch(group, authorities)) + { + iprGroup = group; + break; + } + } + + // determine if there are any more pages to inspect + hasMoreItems = results.hasMoreItems(); + pageCount ++; + } + + return new Pair(iprGroup, nextGroupIndex); + } + + /** + * Determines whether a group exactly matches a list of authorities. + * + * @param authorities list of authorities + * @param group group + * @return + */ + private boolean isIPRGroupTrueMatch(String group, Set authorities) + { + Set contained = authorityService.getContainedAuthorities(null, group, true); + return contained.equals(authorities); + } + + /** + * Get IPR group prefix short name. + *

+ * 'package' scope to help testing. + * + * @param prefix prefix + * @param authorities authorities + * @return String group prefix short name + */ + /*package*/ String getIPRGroupPrefixShortName(String prefix, Set authorities) + { + StringBuilder builder = new StringBuilder(128) + .append(prefix) + .append(getAuthoritySetHashCode(authorities)); + + return builder.toString(); + } + + /** + * Get IPR group short name. + *

+ * Note this excludes the "GROUP_" prefix. + *

+ * 'package' scope to help testing. + * + * @param prefix prefix + * @param readers read authorities + * @param writers write authorities + * @param index group index + * @return String group short name + */ + /*package*/ String getIPRGroupShortName(String prefix, Set authorities, int index) + { + return getIPRGroupShortName(prefix, authorities, Integer.toString(index)); + } + + /** + * Get IPR group short name. + *

+ * Note this excludes the "GROUP_" prefix. + * + * @param prefix prefix + * @param readers read authorities + * @param writers write authorities + * @param index group index + * @return String group short name + */ + private String getIPRGroupShortName(String prefix, Set authorities, String index) + { + StringBuilder builder = new StringBuilder(128) + .append(getIPRGroupPrefixShortName(prefix, authorities)) + .append(index); + + return builder.toString(); + } + + /** + * Gets the hashcode value of a set of authorities. + * + * @param authorities set of authorities + * @return int hash code + */ + private int getAuthoritySetHashCode(Set authorities) + { + int result = 0; + if (authorities != null && !authorities.isEmpty()) + { + result = StringUtils.join(authorities.toArray(), "").hashCode(); + } + return result; + } + + /** + * Creates a new IPR group. + * + * @param groupNamePrefix group name prefix + * @param children child authorities + * @param index group index + * @return String full name of created group + */ + private String createIPRGroup(String groupNamePrefix, Set children, int index) + { + ParameterCheck.mandatory("groupNamePrefix", groupNamePrefix); + + // get the group name + String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index); + + // create group + String group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM)); + + // add root parent + authorityService.addAuthority(getRootIRPGroup(), group); + + // add children if provided + if (children != null) + { + for (String child : children) + { + if (authorityService.authorityExists(child) && + !PermissionService.ALL_AUTHORITIES.equals(child)) + { + authorityService.addAuthority(group, child); + } + } + } + + return group; + } + + /** + * Assign IPR groups to a node reference with the correct permissions. + * + * @param iprGroups iprGroups, first read and second write + * @param nodeRef node reference + */ + private void assignIPRGroupsToNode(Pair iprGroups, NodeRef nodeRef) + { + permissionService.setPermission(nodeRef, iprGroups.getFirst(), RMPermissionModel.READ_RECORDS, true); + permissionService.setPermission(nodeRef, iprGroups.getSecond(), RMPermissionModel.FILING, true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#remove(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void remove(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + Pair iprGroups = getIPRGroups(nodeRef); + if (iprGroups != null) + { + // remove any extended security that might be present + clearPermissions(nodeRef, iprGroups); + + // remove the readers from any renditions of the content + if (isRecord(nodeRef)) + { + List assocs = nodeService.getChildAssocs(nodeRef, RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef child = assoc.getChildRef(); + clearPermissions(child, iprGroups); + } + } + } + } + + /** + * Clear the nodes IPR permissions + * + * @param nodeRef node reference + */ + private void clearPermissions(NodeRef nodeRef, Pair iprGroups) + { + // remove group permissions from node + permissionService.clearPermission(nodeRef, iprGroups.getFirst()); + permissionService.clearPermission(nodeRef, iprGroups.getSecond()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#getExtendedReaders(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override @Deprecated public Set getExtendedReaders(NodeRef nodeRef) + { + return getReaders(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#getExtendedWriters(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override @Deprecated public Set getExtendedWriters(NodeRef nodeRef) + { + return getWriters(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#addExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) + */ + @Override @Deprecated public void addExtendedSecurity(NodeRef nodeRef, Set readers, Set writers) + { + set(nodeRef, readers, writers); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#addExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean) + */ + @Override @Deprecated public void addExtendedSecurity(NodeRef nodeRef, Set readers, Set writers, boolean applyToParents) + { + set(nodeRef, readers, writers); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override @Deprecated public void removeAllExtendedSecurity(NodeRef nodeRef) + { + remove(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set) + */ + @Override @Deprecated public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Set writers) + { + remove(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean) + */ + @Override @Deprecated public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Setwriters, boolean applyToParents) + { + remove(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.DeprecatedExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override @Deprecated public void removeAllExtendedSecurity(NodeRef nodeRef, boolean applyToParents) + { + remove(nodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java index a34b4b7da5..40f65ce9d0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * File plan permission service. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface FilePlanPermissionService -{ - /** - * Setup permissions for a record category - * - * @param nodeRef record category node reference - */ - void setupRecordCategoryPermissions(NodeRef recordCategory); - - /** - * Setup permissions for an object within a given parent. - * - * @param parent parent node to inherit permissions from - * @param nodeRef node ref to setup permissions on - */ - void setupPermissions(NodeRef parent, NodeRef nodeRef); - - /** - * Sets a permission on a file plan object. Assumes allow is true. Cascades permission down to record folder. - * Cascades ReadRecord up to file plan. - * - * @param nodeRef node reference - * @param authority authority - * @param permission permission - */ - void setPermission(NodeRef nodeRef, String authority, String permission); - - /** - * Deletes a permission from a file plan object. Cascades removal down to record folder. - * - * @param nodeRef node reference - * @param authority authority - * @param permission permission - */ - void deletePermission(NodeRef nodeRef, String authority, String permission); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * File plan permission service. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface FilePlanPermissionService +{ + /** + * Setup permissions for a record category + * + * @param nodeRef record category node reference + */ + void setupRecordCategoryPermissions(NodeRef recordCategory); + + /** + * Setup permissions for an object within a given parent. + * + * @param parent parent node to inherit permissions from + * @param nodeRef node ref to setup permissions on + */ + void setupPermissions(NodeRef parent, NodeRef nodeRef); + + /** + * Sets a permission on a file plan object. Assumes allow is true. Cascades permission down to record folder. + * Cascades ReadRecord up to file plan. + * + * @param nodeRef node reference + * @param authority authority + * @param permission permission + */ + void setPermission(NodeRef nodeRef, String authority, String permission); + + /** + * Deletes a permission from a file plan object. Cascades removal down to record folder. + * + * @param nodeRef node reference + * @param authority authority + * @param permission permission + */ + void deletePermission(NodeRef nodeRef, String authority, String permission); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java index 17f40991ad..d4b37094d9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java @@ -1,616 +1,616 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT; -import static org.alfresco.repo.policy.annotation.BehaviourKind.CLASS; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName; -import static org.alfresco.service.cmr.security.OwnableService.NO_OWNER; -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.apache.commons.lang.BooleanUtils.isTrue; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * File plan permission service. - * - * @author Roy Wetherall - * @since 2.1 - */ -@BehaviourBean -public class FilePlanPermissionServiceImpl extends ServiceBaseImpl - implements FilePlanPermissionService, - RMPermissionModel, - NodeServicePolicies.OnMoveNodePolicy -{ - /** Permission service */ - private PermissionService permissionService; - - /** Ownable service */ - private OwnableService ownableService; - - /** Policy component */ - private PolicyComponent policyComponent; - - /** Authority service */ - private AuthorityService authorityService; - - /** File plan role service */ - private FilePlanRoleService filePlanRoleService; - - /** File plan service */ - private FilePlanService filePlanService; - - /** Logger */ - private static final Log LOGGER = LogFactory.getLog(FilePlanPermissionServiceImpl.class); - - /** - * Initialisation method - */ - public void init() - { - getPolicyComponent().bindClassBehaviour( - NodeServicePolicies.OnAddAspectPolicy.QNAME, - ASPECT_RECORD, - new JavaBehaviour(this, "onAddRecord", TRANSACTION_COMMIT)); - getPolicyComponent().bindClassBehaviour( - NodeServicePolicies.OnMoveNodePolicy.QNAME, - ASPECT_RECORD, - new JavaBehaviour(this, "onMoveRecord", TRANSACTION_COMMIT)); - getPolicyComponent().bindClassBehaviour( - NodeServicePolicies.OnMoveNodePolicy.QNAME, - TYPE_RECORD_CATEGORY, - new JavaBehaviour(this, "onMoveNode", TRANSACTION_COMMIT)); - } - - /** - * Gets the permission service - * - * @return The permission service - */ - protected PermissionService getPermissionService() - { - return this.permissionService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * Gets the policy component - * - * @return The policy component - */ - protected PolicyComponent getPolicyComponent() - { - return this.policyComponent; - } - - /** - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * Gets the ownable service - * - * @return The ownable service - */ - protected OwnableService getOwnableService() - { - return this.ownableService; - } - - /** - * @param ownableService ownable service - */ - public void setOwnableService(OwnableService ownableService) - { - this.ownableService = ownableService; - } - - /** - * Gets the authority service - * - * @return The authority service - */ - public AuthorityService getAuthorityService() - { - return this.authorityService; - } - - /** - * Sets the authority service - * - * @param authorityService The authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * Gets the file plan role service - * - * @return The file plan role service - */ - public FilePlanRoleService getFilePlanRoleService() - { - return this.filePlanRoleService; - } - - /** - * Sets the file plan role service - * - * @param filePlanRoleService The file plan role service to set - */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) - { - this.filePlanRoleService = filePlanRoleService; - } - - /** - * Gets the file plan service - * - * @return The file plan service - */ - public FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * Sets the file plan service - * - * @param filePlanService The file plan service to set - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService#setupRecordCategoryPermissions(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void setupRecordCategoryPermissions(final NodeRef recordCategory) - { - mandatory("recordCategory", recordCategory); - - // assert that we have a record category in our hands - if (!instanceOf(recordCategory, TYPE_RECORD_CATEGORY)) - { - throw new AlfrescoRuntimeException("Unable to setup record category permissions, because node is not a record category."); - } - - // setup category permissions - NodeRef parentNodeRef = nodeService.getPrimaryParent(recordCategory).getParentRef(); - setupPermissions(parentNodeRef, recordCategory); - } - - /** - * Setup permissions on new unfiled record folder - * - * @param childAssocRef child association reference - */ - @Behaviour - ( - type = "rma:unfiledRecordFolder", - kind = CLASS, - policy = "alf:onCreateNode", - notificationFrequency = TRANSACTION_COMMIT - ) - public void onCreateUnfiledRecordFolder(ChildAssociationRef childAssocRef) - { - mandatory("childAssocRef", childAssocRef); - setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); - } - - /** - * Setup permissions on new record folder - * - * @param childAssocRef child association reference - */ - @Behaviour - ( - type = "rma:recordFolder", - kind = CLASS, - policy = "alf:onCreateNode", - notificationFrequency = TRANSACTION_COMMIT - ) - public void onCreateRecordFolder(ChildAssociationRef childAssocRef) - { - mandatory("childAssocRef", childAssocRef); - setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); - } - - /** - * Setup permissions on newly created hold. - * - * @param childAssocRef child association reference - */ - @Behaviour - ( - type = "rma:hold", - kind = CLASS, - policy = "alf:onCreateNode", - notificationFrequency = TRANSACTION_COMMIT - ) - public void onCreateHold(final ChildAssociationRef childAssocRef) - { - createContainerElement(childAssocRef); - } - - /** - * Setup permissions on newly created transfer. - * - * @param childAssocRef child association reference - */ - @Behaviour - ( - type = "rma:transfer", - kind = CLASS, - policy = "alf:onCreateNode", - notificationFrequency = TRANSACTION_COMMIT - ) - public void onCreateTransfer(final ChildAssociationRef childAssocRef) - { - createContainerElement(childAssocRef); - } - - /** - * Helper method to create a container element, e.g. transfer folder or hold - * - * @param childAssocRef - */ - private void createContainerElement(final ChildAssociationRef childAssocRef) - { - mandatory("childAssocRef", childAssocRef); - NodeRef childRef = childAssocRef.getChildRef(); - setupPermissions(childAssocRef.getParentRef(), childRef); - grantFilingPermissionToCreator(childRef); - } - - /** - * Helper method to give filing permissions to the currently logged in user who creates the node (transfer folder, hold, etc.) - * - * @param nodeRef The node reference of the created object - */ - private void grantFilingPermissionToCreator(final NodeRef nodeRef) - { - final String user = AuthenticationUtil.getFullyAuthenticatedUser(); - - final boolean hasUserPermission = authenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Boolean doWork() - { - return getPermissionService().hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED; - } - }, user); - - if (!hasUserPermission) - { - authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - getPermissionService().setPermission(nodeRef, user, RMPermissionModel.FILING, true); - return null; - } - }); - } - } - - /** - * Helper method to setup permissions. - * - * @param parent parent node reference - * @param nodeRef child node reference - */ - public void setupPermissions(final NodeRef parent, final NodeRef nodeRef) - { - mandatory("parent", parent); - mandatory("nodeRef", nodeRef); - - if (nodeService.exists(nodeRef) && nodeService.exists(parent)) - { - authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - // set inheritance - boolean isParentNodeFilePlan = isRecordCategory(nodeRef) && isFilePlan(parent); - boolean inheritanceAllowed = isInheritanceAllowed(nodeRef, isParentNodeFilePlan); - getPermissionService().setInheritParentPermissions(nodeRef, inheritanceAllowed); - - Set keepPerms = new HashSet(5); - Set origionalPerms= getPermissionService().getAllSetPermissions(nodeRef); - - for (AccessPermission perm : origionalPerms) - { - if (perm.getAuthority().startsWith(PermissionService.GROUP_PREFIX + ExtendedSecurityService.IPR_GROUP_PREFIX)) - { - // then we can assume this is a permission we want to preserve - keepPerms.add(perm); - } - } - - // clear all existing permissions and start again - getPermissionService().clearPermission(nodeRef, null); - - // re-add keep'er permissions - for (AccessPermission keeper : keepPerms) - { - setPermission(nodeRef, keeper.getAuthority(), keeper.getPermission()); - } - - if (!inheritanceAllowed) - { - String adminRole = getAdminRole(nodeRef); - getPermissionService().setPermission(nodeRef, adminRole, RMPermissionModel.FILING, true); - } - - // remove owner - getOwnableService().setOwner(nodeRef, NO_OWNER); - - if (isParentNodeFilePlan) - { - Set perms = permissionService.getAllSetPermissions(parent); - for (AccessPermission perm : perms) - { - if (RMPermissionModel.FILING.equals(perm.getPermission())) - { - AccessStatus accessStatus = perm.getAccessStatus(); - boolean allow = false; - if (AccessStatus.ALLOWED.equals(accessStatus)) - { - allow = true; - } - permissionService.setPermission( - nodeRef, - perm.getAuthority(), - perm.getPermission(), - allow); - } - } - } - - return null; - } - }); - } - } - - private String getAdminRole(NodeRef nodeRef) - { - NodeRef filePlan = getFilePlan(nodeRef); - if (filePlan == null) - { - throw new AlfrescoRuntimeException("The file plan could not be found for the give node: '" + nodeRef + "'."); - } - return authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); - } - - /** - * Indicates whether the default behaviour is to inherit permissions or not. - * - * @param nodeRef node reference - * @param isParentNodeFilePlan true if parent node is a file plan, false otherwise - * @return boolean true if inheritance true, false otherwise - */ - private boolean isInheritanceAllowed(NodeRef nodeRef, Boolean isParentNodeFilePlan) - { - return !(isFilePlan(nodeRef) || - isTransfer(nodeRef) || - isHold(nodeRef) || - isUnfiledRecordsContainer(nodeRef) || - (isRecordCategory(nodeRef) && isTrue(isParentNodeFilePlan))); - } - - /** - * Sets ups records permission when aspect is added. - * - * @see NodeServicePolicies.OnAddAspectPolicy#onAddAspect(NodeRef, QName) - * - * @param record - * @param aspectTypeQName - */ - public void onAddRecord(final NodeRef record, final QName aspectTypeQName) - { - mandatory("childAssocRef", record); - mandatory("childAssocRef", aspectTypeQName); - - authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Object doWork() - { - if (nodeService.exists(record) && nodeService.hasAspect(record, aspectTypeQName)) - { - NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); - setupPermissions(recordFolder, record); - } - - return null; - } - }); - } - - /** - * onMoveRecord behaviour - * - * @param sourceAssocRef source association reference - * @param destinationAssocRef destination association reference - */ - public void onMoveRecord(final ChildAssociationRef sourceAssocRef, final ChildAssociationRef destinationAssocRef) - { - mandatory("sourceAssocRef", sourceAssocRef); - mandatory("destinationAssocRef", destinationAssocRef); - - authenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - NodeRef record = sourceAssocRef.getChildRef(); - if (nodeService.exists(record) && nodeService.hasAspect(record, ASPECT_RECORD)) - { - boolean inheritParentPermissions = permissionService.getInheritParentPermissions(record); - - Set keepPerms = new HashSet(5); - Set origionalRecordPerms= permissionService.getAllSetPermissions(record); - - for (AccessPermission recordPermission : origionalRecordPerms) - { - String permission = recordPermission.getPermission(); - if ((RMPermissionModel.FILING.equals(permission) || RMPermissionModel.READ_RECORDS.equals(permission)) && - recordPermission.isSetDirectly()) - { - // then we can assume this is a permission we want to preserve - keepPerms.add(recordPermission); - } - } - - // re-setup the records permissions - setupPermissions(destinationAssocRef.getParentRef(), record); - - // re-add keep'er permissions - for (AccessPermission keeper : keepPerms) - { - setPermission(record, keeper.getAuthority(), keeper.getPermission()); - } - - permissionService.setInheritParentPermissions(record, inheritParentPermissions); - } - - return null; - } - }, getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, boolean) - */ - public void setPermission(final NodeRef nodeRef, final String authority, final String permission) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("authority", authority); - ParameterCheck.mandatory("permission", permission); - - authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - if (canPerformPermissionAction(nodeRef)) - { - // Set the permission on the node - getPermissionService().setPermission(nodeRef, authority, permission, true); - } - else - { - if (LOGGER.isWarnEnabled()) - { - LOGGER.warn("Setting permissions for this node is not supported. (nodeRef=" + nodeRef + ", authority=" + authority + ", permission=" + permission + ")"); - } - } - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deletePermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - public void deletePermission(final NodeRef nodeRef, final String authority, final String permission) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("authority", authority); - ParameterCheck.mandatory("permission", permission); - - authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - if (canPerformPermissionAction(nodeRef)) - { - // Delete permission on this node - getPermissionService().deletePermission(nodeRef, authority, permission); - } - else - { - if (LOGGER.isWarnEnabled()) - { - LOGGER.warn("Deleting permissions for this node is not supported. (nodeRef=" + nodeRef + ", authority=" + authority + ", permission=" + permission + ")"); - } - } - - return null; - } - }); - } - - private boolean canPerformPermissionAction(NodeRef nodeRef) - { - return isFilePlanContainer(nodeRef) || isRecordFolder(nodeRef) || isRecord(nodeRef) || isTransfer(nodeRef) || isHold(nodeRef); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - if (isFilePlan(newChildAssocRef.getParentRef())) - { - permissionService.setInheritParentPermissions(oldChildAssocRef.getChildRef(), false); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT; +import static org.alfresco.repo.policy.annotation.BehaviourKind.CLASS; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName; +import static org.alfresco.service.cmr.security.OwnableService.NO_OWNER; +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.apache.commons.lang.BooleanUtils.isTrue; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * File plan permission service. + * + * @author Roy Wetherall + * @since 2.1 + */ +@BehaviourBean +public class FilePlanPermissionServiceImpl extends ServiceBaseImpl + implements FilePlanPermissionService, + RMPermissionModel, + NodeServicePolicies.OnMoveNodePolicy +{ + /** Permission service */ + private PermissionService permissionService; + + /** Ownable service */ + private OwnableService ownableService; + + /** Policy component */ + private PolicyComponent policyComponent; + + /** Authority service */ + private AuthorityService authorityService; + + /** File plan role service */ + private FilePlanRoleService filePlanRoleService; + + /** File plan service */ + private FilePlanService filePlanService; + + /** Logger */ + private static final Log LOGGER = LogFactory.getLog(FilePlanPermissionServiceImpl.class); + + /** + * Initialisation method + */ + public void init() + { + getPolicyComponent().bindClassBehaviour( + NodeServicePolicies.OnAddAspectPolicy.QNAME, + ASPECT_RECORD, + new JavaBehaviour(this, "onAddRecord", TRANSACTION_COMMIT)); + getPolicyComponent().bindClassBehaviour( + NodeServicePolicies.OnMoveNodePolicy.QNAME, + ASPECT_RECORD, + new JavaBehaviour(this, "onMoveRecord", TRANSACTION_COMMIT)); + getPolicyComponent().bindClassBehaviour( + NodeServicePolicies.OnMoveNodePolicy.QNAME, + TYPE_RECORD_CATEGORY, + new JavaBehaviour(this, "onMoveNode", TRANSACTION_COMMIT)); + } + + /** + * Gets the permission service + * + * @return The permission service + */ + protected PermissionService getPermissionService() + { + return this.permissionService; + } + + /** + * @param permissionService permission service + */ + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + /** + * Gets the policy component + * + * @return The policy component + */ + protected PolicyComponent getPolicyComponent() + { + return this.policyComponent; + } + + /** + * @param policyComponent policy component + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * Gets the ownable service + * + * @return The ownable service + */ + protected OwnableService getOwnableService() + { + return this.ownableService; + } + + /** + * @param ownableService ownable service + */ + public void setOwnableService(OwnableService ownableService) + { + this.ownableService = ownableService; + } + + /** + * Gets the authority service + * + * @return The authority service + */ + public AuthorityService getAuthorityService() + { + return this.authorityService; + } + + /** + * Sets the authority service + * + * @param authorityService The authority service + */ + public void setAuthorityService(AuthorityService authorityService) + { + this.authorityService = authorityService; + } + + /** + * Gets the file plan role service + * + * @return The file plan role service + */ + public FilePlanRoleService getFilePlanRoleService() + { + return this.filePlanRoleService; + } + + /** + * Sets the file plan role service + * + * @param filePlanRoleService The file plan role service to set + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + + /** + * Gets the file plan service + * + * @return The file plan service + */ + public FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * Sets the file plan service + * + * @param filePlanService The file plan service to set + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService#setupRecordCategoryPermissions(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void setupRecordCategoryPermissions(final NodeRef recordCategory) + { + mandatory("recordCategory", recordCategory); + + // assert that we have a record category in our hands + if (!instanceOf(recordCategory, TYPE_RECORD_CATEGORY)) + { + throw new AlfrescoRuntimeException("Unable to setup record category permissions, because node is not a record category."); + } + + // setup category permissions + NodeRef parentNodeRef = nodeService.getPrimaryParent(recordCategory).getParentRef(); + setupPermissions(parentNodeRef, recordCategory); + } + + /** + * Setup permissions on new unfiled record folder + * + * @param childAssocRef child association reference + */ + @Behaviour + ( + type = "rma:unfiledRecordFolder", + kind = CLASS, + policy = "alf:onCreateNode", + notificationFrequency = TRANSACTION_COMMIT + ) + public void onCreateUnfiledRecordFolder(ChildAssociationRef childAssocRef) + { + mandatory("childAssocRef", childAssocRef); + setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); + } + + /** + * Setup permissions on new record folder + * + * @param childAssocRef child association reference + */ + @Behaviour + ( + type = "rma:recordFolder", + kind = CLASS, + policy = "alf:onCreateNode", + notificationFrequency = TRANSACTION_COMMIT + ) + public void onCreateRecordFolder(ChildAssociationRef childAssocRef) + { + mandatory("childAssocRef", childAssocRef); + setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); + } + + /** + * Setup permissions on newly created hold. + * + * @param childAssocRef child association reference + */ + @Behaviour + ( + type = "rma:hold", + kind = CLASS, + policy = "alf:onCreateNode", + notificationFrequency = TRANSACTION_COMMIT + ) + public void onCreateHold(final ChildAssociationRef childAssocRef) + { + createContainerElement(childAssocRef); + } + + /** + * Setup permissions on newly created transfer. + * + * @param childAssocRef child association reference + */ + @Behaviour + ( + type = "rma:transfer", + kind = CLASS, + policy = "alf:onCreateNode", + notificationFrequency = TRANSACTION_COMMIT + ) + public void onCreateTransfer(final ChildAssociationRef childAssocRef) + { + createContainerElement(childAssocRef); + } + + /** + * Helper method to create a container element, e.g. transfer folder or hold + * + * @param childAssocRef + */ + private void createContainerElement(final ChildAssociationRef childAssocRef) + { + mandatory("childAssocRef", childAssocRef); + NodeRef childRef = childAssocRef.getChildRef(); + setupPermissions(childAssocRef.getParentRef(), childRef); + grantFilingPermissionToCreator(childRef); + } + + /** + * Helper method to give filing permissions to the currently logged in user who creates the node (transfer folder, hold, etc.) + * + * @param nodeRef The node reference of the created object + */ + private void grantFilingPermissionToCreator(final NodeRef nodeRef) + { + final String user = AuthenticationUtil.getFullyAuthenticatedUser(); + + final boolean hasUserPermission = authenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Boolean doWork() + { + return getPermissionService().hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED; + } + }, user); + + if (!hasUserPermission) + { + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + getPermissionService().setPermission(nodeRef, user, RMPermissionModel.FILING, true); + return null; + } + }); + } + } + + /** + * Helper method to setup permissions. + * + * @param parent parent node reference + * @param nodeRef child node reference + */ + public void setupPermissions(final NodeRef parent, final NodeRef nodeRef) + { + mandatory("parent", parent); + mandatory("nodeRef", nodeRef); + + if (nodeService.exists(nodeRef) && nodeService.exists(parent)) + { + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + // set inheritance + boolean isParentNodeFilePlan = isRecordCategory(nodeRef) && isFilePlan(parent); + boolean inheritanceAllowed = isInheritanceAllowed(nodeRef, isParentNodeFilePlan); + getPermissionService().setInheritParentPermissions(nodeRef, inheritanceAllowed); + + Set keepPerms = new HashSet(5); + Set origionalPerms= getPermissionService().getAllSetPermissions(nodeRef); + + for (AccessPermission perm : origionalPerms) + { + if (perm.getAuthority().startsWith(PermissionService.GROUP_PREFIX + ExtendedSecurityService.IPR_GROUP_PREFIX)) + { + // then we can assume this is a permission we want to preserve + keepPerms.add(perm); + } + } + + // clear all existing permissions and start again + getPermissionService().clearPermission(nodeRef, null); + + // re-add keep'er permissions + for (AccessPermission keeper : keepPerms) + { + setPermission(nodeRef, keeper.getAuthority(), keeper.getPermission()); + } + + if (!inheritanceAllowed) + { + String adminRole = getAdminRole(nodeRef); + getPermissionService().setPermission(nodeRef, adminRole, RMPermissionModel.FILING, true); + } + + // remove owner + getOwnableService().setOwner(nodeRef, NO_OWNER); + + if (isParentNodeFilePlan) + { + Set perms = permissionService.getAllSetPermissions(parent); + for (AccessPermission perm : perms) + { + if (RMPermissionModel.FILING.equals(perm.getPermission())) + { + AccessStatus accessStatus = perm.getAccessStatus(); + boolean allow = false; + if (AccessStatus.ALLOWED.equals(accessStatus)) + { + allow = true; + } + permissionService.setPermission( + nodeRef, + perm.getAuthority(), + perm.getPermission(), + allow); + } + } + } + + return null; + } + }); + } + } + + private String getAdminRole(NodeRef nodeRef) + { + NodeRef filePlan = getFilePlan(nodeRef); + if (filePlan == null) + { + throw new AlfrescoRuntimeException("The file plan could not be found for the give node: '" + nodeRef + "'."); + } + return authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); + } + + /** + * Indicates whether the default behaviour is to inherit permissions or not. + * + * @param nodeRef node reference + * @param isParentNodeFilePlan true if parent node is a file plan, false otherwise + * @return boolean true if inheritance true, false otherwise + */ + private boolean isInheritanceAllowed(NodeRef nodeRef, Boolean isParentNodeFilePlan) + { + return !(isFilePlan(nodeRef) || + isTransfer(nodeRef) || + isHold(nodeRef) || + isUnfiledRecordsContainer(nodeRef) || + (isRecordCategory(nodeRef) && isTrue(isParentNodeFilePlan))); + } + + /** + * Sets ups records permission when aspect is added. + * + * @see NodeServicePolicies.OnAddAspectPolicy#onAddAspect(NodeRef, QName) + * + * @param record + * @param aspectTypeQName + */ + public void onAddRecord(final NodeRef record, final QName aspectTypeQName) + { + mandatory("childAssocRef", record); + mandatory("childAssocRef", aspectTypeQName); + + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Object doWork() + { + if (nodeService.exists(record) && nodeService.hasAspect(record, aspectTypeQName)) + { + NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); + setupPermissions(recordFolder, record); + } + + return null; + } + }); + } + + /** + * onMoveRecord behaviour + * + * @param sourceAssocRef source association reference + * @param destinationAssocRef destination association reference + */ + public void onMoveRecord(final ChildAssociationRef sourceAssocRef, final ChildAssociationRef destinationAssocRef) + { + mandatory("sourceAssocRef", sourceAssocRef); + mandatory("destinationAssocRef", destinationAssocRef); + + authenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + NodeRef record = sourceAssocRef.getChildRef(); + if (nodeService.exists(record) && nodeService.hasAspect(record, ASPECT_RECORD)) + { + boolean inheritParentPermissions = permissionService.getInheritParentPermissions(record); + + Set keepPerms = new HashSet(5); + Set origionalRecordPerms= permissionService.getAllSetPermissions(record); + + for (AccessPermission recordPermission : origionalRecordPerms) + { + String permission = recordPermission.getPermission(); + if ((RMPermissionModel.FILING.equals(permission) || RMPermissionModel.READ_RECORDS.equals(permission)) && + recordPermission.isSetDirectly()) + { + // then we can assume this is a permission we want to preserve + keepPerms.add(recordPermission); + } + } + + // re-setup the records permissions + setupPermissions(destinationAssocRef.getParentRef(), record); + + // re-add keep'er permissions + for (AccessPermission keeper : keepPerms) + { + setPermission(record, keeper.getAuthority(), keeper.getPermission()); + } + + permissionService.setInheritParentPermissions(record, inheritParentPermissions); + } + + return null; + } + }, getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, boolean) + */ + public void setPermission(final NodeRef nodeRef, final String authority, final String permission) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("authority", authority); + ParameterCheck.mandatory("permission", permission); + + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + if (canPerformPermissionAction(nodeRef)) + { + // Set the permission on the node + getPermissionService().setPermission(nodeRef, authority, permission, true); + } + else + { + if (LOGGER.isWarnEnabled()) + { + LOGGER.warn("Setting permissions for this node is not supported. (nodeRef=" + nodeRef + ", authority=" + authority + ", permission=" + permission + ")"); + } + } + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#deletePermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) + */ + public void deletePermission(final NodeRef nodeRef, final String authority, final String permission) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("authority", authority); + ParameterCheck.mandatory("permission", permission); + + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + if (canPerformPermissionAction(nodeRef)) + { + // Delete permission on this node + getPermissionService().deletePermission(nodeRef, authority, permission); + } + else + { + if (LOGGER.isWarnEnabled()) + { + LOGGER.warn("Deleting permissions for this node is not supported. (nodeRef=" + nodeRef + ", authority=" + authority + ", permission=" + permission + ")"); + } + } + + return null; + } + }); + } + + private boolean canPerformPermissionAction(NodeRef nodeRef) + { + return isFilePlanContainer(nodeRef) || isRecordFolder(nodeRef) || isRecord(nodeRef) || isTransfer(nodeRef) || isHold(nodeRef); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + if (isFilePlan(newChildAssocRef.getParentRef())) + { + permissionService.setInheritParentPermissions(oldChildAssocRef.getChildRef(), false); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityInterceptor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityInterceptor.java index 1d4e1e5f3d..14143d0141 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityInterceptor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityInterceptor.java @@ -1,335 +1,335 @@ - -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.acegisecurity.AccessDeniedException; -import net.sf.acegisecurity.intercept.InterceptorStatusToken; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor; -import org.alfresco.service.cmr.security.AccessStatus; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Records Management Method Security Interceptor. - *

- * Provides a way to record information about the capabilities being executed and report - * when an access denied exception is thrown. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMMethodSecurityInterceptor extends MethodSecurityInterceptor -{ - /** logger */ - protected static final Log LOGGER = LogFactory.getLog(RMMethodSecurityInterceptor.class); - - /** - * Helper class to hold capability report information - */ - private static class CapabilityReport - { - public String name; - public AccessStatus status; - public Map conditions = new HashMap(); - } - - /** - * Helper method to translate vote to access status. - * - * @param vote vote - * @return {@link AccessStatus} access status - */ - private static AccessStatus translate(int vote) - { - switch (vote) - { - case AccessDecisionVoter.ACCESS_ABSTAIN: - return AccessStatus.UNDETERMINED; - case AccessDecisionVoter.ACCESS_GRANTED: - return AccessStatus.ALLOWED; - case AccessDecisionVoter.ACCESS_DENIED: - return AccessStatus.DENIED; - default: - return AccessStatus.UNDETERMINED; - } - } - - /** - * Current capability report details. - *

- * Used to generate the capability error report. - */ - private static final ThreadLocal> CAPABILITIES = new ThreadLocal>() - { - @Override - protected Map initialValue() - { - return new HashMap(); - }; - }; - - /** - * Indicates whether this is an RM security check or not - */ - private static final ThreadLocal IS_RM_SECURITY_CHECK = new ThreadLocal() - { - protected Boolean initialValue() {return false;}; - }; - - /** - * Messages to display in error report. - */ - private static final ThreadLocal> MESSAGES = new ThreadLocal>() - { - protected List initialValue() {return new ArrayList();}; - }; - - /** - * Get capability report object from the thread local, creating one for - * the given capability name if one does not already exist. - * - * @param name capability name - * @return {@link CapabilityReport} object containing information about the capability - */ - private static CapabilityReport getCapabilityReport(String name) - { - Map map = RMMethodSecurityInterceptor.CAPABILITIES.get(); - CapabilityReport capability = map.get(name); - if (capability == null) - { - capability = new CapabilityReport(); - capability.name = name; - - map.put(name, capability); - } - return capability; - } - - /** - * Indicates whether this is a RM security check or not - * - * @param newValue true if RM security check, false otherwise - */ - public static void isRMSecurityChecked(boolean newValue) - { - if (LOGGER.isDebugEnabled()) - { - RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.set(newValue); - } - } - - /** - * Add a message to be displayed in the error report. - * - * @param message error message - */ - public static void addMessage(String message) - { - if (LOGGER.isDebugEnabled()) - { - List messages = RMMethodSecurityInterceptor.MESSAGES.get(); - messages.add(message); - } - } - - public static void addMessage(String message, Object ... params) - { - if (LOGGER.isDebugEnabled()) - { - addMessage(MessageFormat.format(message, params)); - } - } - - /** - * Report capability status. - * - * @param name capability name - * @param status capability status - */ - public static void reportCapabilityStatus(String name, int status) - { - if (LOGGER.isDebugEnabled()) - { - CapabilityReport capability = getCapabilityReport(name); - capability.status = translate(status); - } - } - - /** - * Report capability condition. - * - * @param name capability name - * @param conditionName capability condition name - * @param expected expected value - * @param actual actual value - */ - public static void reportCapabilityCondition(String name, String conditionName, boolean expected, boolean actual) - { - if (LOGGER.isDebugEnabled()) - { - CapabilityReport capability = getCapabilityReport(name); - if (!expected) - { - conditionName = "!" + conditionName; - } - capability.conditions.put(conditionName, (expected == actual)); - } - } - - /** - * Gets the failure report for the currently recorded capabilities. - * - * @return {@link String} capability error report - */ - public String getFailureReport() - { - String result = null; - - if (LOGGER.isDebugEnabled()) - { - Collection capabilities = RMMethodSecurityInterceptor.CAPABILITIES.get().values(); - - if (!capabilities.isEmpty()) - { - StringBuffer buffer = new StringBuffer("\n"); - for (CapabilityReport capability : capabilities) - { - buffer.append(" ").append(capability.name).append(" (").append(capability.status).append(")\n"); - if (!capability.conditions.isEmpty()) - { - for (Map.Entry entry : capability.conditions.entrySet()) - { - buffer.append(" - ").append(entry.getKey()).append(" ("); - if (entry.getValue()) - { - buffer.append("passed"); - } - else - { - buffer.append("failed"); - } - buffer.append(")\n"); - } - } - } - - result = buffer.toString(); - } - } - - return result; - } - - /** - * @see net.sf.acegisecurity.intercept.AbstractSecurityInterceptor#beforeInvocation(java.lang.Object) - */ - @Override - protected InterceptorStatusToken beforeInvocation(Object object) - { - InterceptorStatusToken result = null; - try - { - // clear the capability report information - RMMethodSecurityInterceptor.CAPABILITIES.remove(); - RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.remove(); - RMMethodSecurityInterceptor.MESSAGES.remove(); - - // before invocation (where method security check takes place) - result = super.beforeInvocation(object); - } - catch (AccessDeniedException exception) - { - if (LOGGER.isDebugEnabled()) - { - MethodInvocation mi = (MethodInvocation)object; - - StringBuilder methodDetails = new StringBuilder("\n"); - if (RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.get()) - { - methodDetails.append("RM method security check was performed.\n"); - } - else - { - methodDetails.append("Standard DM method security check was performed.\n"); - } - - boolean first = true; - methodDetails.append("Failed on method: ").append(mi.getMethod().getName()).append("("); - for (Object arg : mi.getArguments()) - { - if (first) - { - first = false; - } - else - { - methodDetails.append(", "); - } - - if (arg != null) - { - methodDetails.append(arg.toString()); - } - else - { - methodDetails.append("null"); - } - } - methodDetails.append(")\n"); - - List messages = RMMethodSecurityInterceptor.MESSAGES.get(); - for (String message : messages) - { - methodDetails.append(message).append("\n"); - } - - String failureReport = getFailureReport(); - if (failureReport == null) - { - // rethrow with additional information - throw new AccessDeniedException(exception.getMessage() + methodDetails, exception); - } - else - { - // rethrow with additional information - throw new AccessDeniedException(exception.getMessage() + methodDetails + getFailureReport(), exception); - } - } - else - { - throw exception; - } - } - return result; - } - - /** - * @see net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) - */ - @Override - public Object invoke(MethodInvocation mi) throws Throwable - { - Object result = null; - InterceptorStatusToken token = beforeInvocation(mi); - - try - { - result = mi.proceed(); - } - finally - { - result = super.afterInvocation(token, result); - } - - return result; - } -} + +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.acegisecurity.AccessDeniedException; +import net.sf.acegisecurity.intercept.InterceptorStatusToken; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor; +import org.alfresco.service.cmr.security.AccessStatus; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Records Management Method Security Interceptor. + *

+ * Provides a way to record information about the capabilities being executed and report + * when an access denied exception is thrown. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMMethodSecurityInterceptor extends MethodSecurityInterceptor +{ + /** logger */ + protected static final Log LOGGER = LogFactory.getLog(RMMethodSecurityInterceptor.class); + + /** + * Helper class to hold capability report information + */ + private static class CapabilityReport + { + public String name; + public AccessStatus status; + public Map conditions = new HashMap(); + } + + /** + * Helper method to translate vote to access status. + * + * @param vote vote + * @return {@link AccessStatus} access status + */ + private static AccessStatus translate(int vote) + { + switch (vote) + { + case AccessDecisionVoter.ACCESS_ABSTAIN: + return AccessStatus.UNDETERMINED; + case AccessDecisionVoter.ACCESS_GRANTED: + return AccessStatus.ALLOWED; + case AccessDecisionVoter.ACCESS_DENIED: + return AccessStatus.DENIED; + default: + return AccessStatus.UNDETERMINED; + } + } + + /** + * Current capability report details. + *

+ * Used to generate the capability error report. + */ + private static final ThreadLocal> CAPABILITIES = new ThreadLocal>() + { + @Override + protected Map initialValue() + { + return new HashMap(); + }; + }; + + /** + * Indicates whether this is an RM security check or not + */ + private static final ThreadLocal IS_RM_SECURITY_CHECK = new ThreadLocal() + { + protected Boolean initialValue() {return false;}; + }; + + /** + * Messages to display in error report. + */ + private static final ThreadLocal> MESSAGES = new ThreadLocal>() + { + protected List initialValue() {return new ArrayList();}; + }; + + /** + * Get capability report object from the thread local, creating one for + * the given capability name if one does not already exist. + * + * @param name capability name + * @return {@link CapabilityReport} object containing information about the capability + */ + private static CapabilityReport getCapabilityReport(String name) + { + Map map = RMMethodSecurityInterceptor.CAPABILITIES.get(); + CapabilityReport capability = map.get(name); + if (capability == null) + { + capability = new CapabilityReport(); + capability.name = name; + + map.put(name, capability); + } + return capability; + } + + /** + * Indicates whether this is a RM security check or not + * + * @param newValue true if RM security check, false otherwise + */ + public static void isRMSecurityChecked(boolean newValue) + { + if (LOGGER.isDebugEnabled()) + { + RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.set(newValue); + } + } + + /** + * Add a message to be displayed in the error report. + * + * @param message error message + */ + public static void addMessage(String message) + { + if (LOGGER.isDebugEnabled()) + { + List messages = RMMethodSecurityInterceptor.MESSAGES.get(); + messages.add(message); + } + } + + public static void addMessage(String message, Object ... params) + { + if (LOGGER.isDebugEnabled()) + { + addMessage(MessageFormat.format(message, params)); + } + } + + /** + * Report capability status. + * + * @param name capability name + * @param status capability status + */ + public static void reportCapabilityStatus(String name, int status) + { + if (LOGGER.isDebugEnabled()) + { + CapabilityReport capability = getCapabilityReport(name); + capability.status = translate(status); + } + } + + /** + * Report capability condition. + * + * @param name capability name + * @param conditionName capability condition name + * @param expected expected value + * @param actual actual value + */ + public static void reportCapabilityCondition(String name, String conditionName, boolean expected, boolean actual) + { + if (LOGGER.isDebugEnabled()) + { + CapabilityReport capability = getCapabilityReport(name); + if (!expected) + { + conditionName = "!" + conditionName; + } + capability.conditions.put(conditionName, (expected == actual)); + } + } + + /** + * Gets the failure report for the currently recorded capabilities. + * + * @return {@link String} capability error report + */ + public String getFailureReport() + { + String result = null; + + if (LOGGER.isDebugEnabled()) + { + Collection capabilities = RMMethodSecurityInterceptor.CAPABILITIES.get().values(); + + if (!capabilities.isEmpty()) + { + StringBuffer buffer = new StringBuffer("\n"); + for (CapabilityReport capability : capabilities) + { + buffer.append(" ").append(capability.name).append(" (").append(capability.status).append(")\n"); + if (!capability.conditions.isEmpty()) + { + for (Map.Entry entry : capability.conditions.entrySet()) + { + buffer.append(" - ").append(entry.getKey()).append(" ("); + if (entry.getValue()) + { + buffer.append("passed"); + } + else + { + buffer.append("failed"); + } + buffer.append(")\n"); + } + } + } + + result = buffer.toString(); + } + } + + return result; + } + + /** + * @see net.sf.acegisecurity.intercept.AbstractSecurityInterceptor#beforeInvocation(java.lang.Object) + */ + @Override + protected InterceptorStatusToken beforeInvocation(Object object) + { + InterceptorStatusToken result = null; + try + { + // clear the capability report information + RMMethodSecurityInterceptor.CAPABILITIES.remove(); + RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.remove(); + RMMethodSecurityInterceptor.MESSAGES.remove(); + + // before invocation (where method security check takes place) + result = super.beforeInvocation(object); + } + catch (AccessDeniedException exception) + { + if (LOGGER.isDebugEnabled()) + { + MethodInvocation mi = (MethodInvocation)object; + + StringBuilder methodDetails = new StringBuilder("\n"); + if (RMMethodSecurityInterceptor.IS_RM_SECURITY_CHECK.get()) + { + methodDetails.append("RM method security check was performed.\n"); + } + else + { + methodDetails.append("Standard DM method security check was performed.\n"); + } + + boolean first = true; + methodDetails.append("Failed on method: ").append(mi.getMethod().getName()).append("("); + for (Object arg : mi.getArguments()) + { + if (first) + { + first = false; + } + else + { + methodDetails.append(", "); + } + + if (arg != null) + { + methodDetails.append(arg.toString()); + } + else + { + methodDetails.append("null"); + } + } + methodDetails.append(")\n"); + + List messages = RMMethodSecurityInterceptor.MESSAGES.get(); + for (String message : messages) + { + methodDetails.append(message).append("\n"); + } + + String failureReport = getFailureReport(); + if (failureReport == null) + { + // rethrow with additional information + throw new AccessDeniedException(exception.getMessage() + methodDetails, exception); + } + else + { + // rethrow with additional information + throw new AccessDeniedException(exception.getMessage() + methodDetails + getFailureReport(), exception); + } + } + else + { + throw exception; + } + } + return result; + } + + /** + * @see net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) + */ + @Override + public Object invoke(MethodInvocation mi) throws Throwable + { + Object result = null; + InterceptorStatusToken token = beforeInvocation(mi); + + try + { + result = mi.proceed(); + } + finally + { + result = super.afterInvocation(token, result); + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityPostProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityPostProcessor.java index d440cff2b5..37cef7d5c0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityPostProcessor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RMMethodSecurityPostProcessor.java @@ -1,200 +1,200 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.PropertyValue; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.config.TypedStringValue; - -/** - * Records management method security post processor. - *

- * Combines RM method security configuration with that of the core server before the security - * bean is instantiated. - * - * @author Roy Wetherall - */ -public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor -{ - private static Log logger = LogFactory.getLog(RMMethodSecurityPostProcessor.class); - - public static final String PROP_OBJECT_DEFINITION_SOURCE = "objectDefinitionSource"; - public static final String PROPERTY_PREFIX = "rm.methodsecurity."; - public static final String SECURITY_BEAN_POSTFIX = "_security"; - - /** Security bean names */ - private Set securityBeanNames; - private Set securityBeanNameCache; - - /** Configuration properties */ - private Properties properties; - - /** - * Set of security beans to apply RM configuration to. - *

- * Used in the case where the security bean does not follow the standard naming convention. - * - * @param securityBeanNames security bean names - */ - public void setSecurityBeanNames(Set securityBeanNames) - { - this.securityBeanNames = securityBeanNames; - } - - /** - * @param properties configuration properties - */ - public void setProperties(Properties properties) - { - this.properties = properties; - } - - /** - * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) - */ - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) - { - for (String bean : getSecurityBeanNames(beanFactory)) - { - if (beanFactory.containsBeanDefinition(bean)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Adding RM method security definitions for " + bean); - } - - BeanDefinition beanDef = beanFactory.getBeanDefinition(bean); - PropertyValue beanValue = beanDef.getPropertyValues().getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE); - if (beanValue != null) - { - String beanStringValue = (String)((TypedStringValue)beanValue.getValue()).getValue(); - String mergedStringValue = merge(beanStringValue); - beanDef.getPropertyValues().addPropertyValue(PROP_OBJECT_DEFINITION_SOURCE, new TypedStringValue(mergedStringValue)); - } - } - } - } - - /** - * Get all the security bean names by looking at the property values set. - * - * @param beanFactory - * @return - */ - private Set getSecurityBeanNames(ConfigurableListableBeanFactory beanFactory) - { - if (securityBeanNameCache == null) - { - securityBeanNameCache = new HashSet(21); - if (securityBeanNames != null) - { - securityBeanNameCache.addAll(securityBeanNames); - } - - for (Object key : properties.keySet()) - { - String[] split = ((String)key).split("\\."); - int index = split.length - 2; - String securityBeanName = split[index] + SECURITY_BEAN_POSTFIX; - if (!securityBeanNameCache.contains(securityBeanName) && beanFactory.containsBean(securityBeanName)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Adding " + securityBeanName + " to list from properties."); - } - - securityBeanNameCache.add(securityBeanName); - } - } - } - - return securityBeanNameCache; - } - - /** - * @param beanStringValue - * @param rmBeanStringValue - * @return - */ - private String merge(String beanStringValue) - { - Map map = convertToMap(beanStringValue); - - for (Map.Entry entry : map.entrySet()) - { - String key = entry.getKey(); - String propKey = PROPERTY_PREFIX + key; - if (properties.containsKey(propKey)) - { - map.put(key, entry.getValue() + "," + properties.getProperty(propKey)); - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn("Missing RM security definition for method " + key); - } - } - } - - return convertToString(map); - } - - /** - * @param stringValue - * @return - */ - private Map convertToMap(String stringValue) - { - String[] values = stringValue.trim().split("\n"); - Map map = new HashMap(values.length); - for (String value : values) - { - String[] pair = value.trim().split("="); - map.put(pair[0], pair[1]); - } - return map; - } - - /** - * @param map - * @return - */ - private String convertToString(Map map) - { - StringBuffer buffer = new StringBuffer(256); - for (Map.Entry entry : map.entrySet()) - { - buffer.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); - } - - return buffer.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.PropertyValue; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.config.TypedStringValue; + +/** + * Records management method security post processor. + *

+ * Combines RM method security configuration with that of the core server before the security + * bean is instantiated. + * + * @author Roy Wetherall + */ +public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor +{ + private static Log logger = LogFactory.getLog(RMMethodSecurityPostProcessor.class); + + public static final String PROP_OBJECT_DEFINITION_SOURCE = "objectDefinitionSource"; + public static final String PROPERTY_PREFIX = "rm.methodsecurity."; + public static final String SECURITY_BEAN_POSTFIX = "_security"; + + /** Security bean names */ + private Set securityBeanNames; + private Set securityBeanNameCache; + + /** Configuration properties */ + private Properties properties; + + /** + * Set of security beans to apply RM configuration to. + *

+ * Used in the case where the security bean does not follow the standard naming convention. + * + * @param securityBeanNames security bean names + */ + public void setSecurityBeanNames(Set securityBeanNames) + { + this.securityBeanNames = securityBeanNames; + } + + /** + * @param properties configuration properties + */ + public void setProperties(Properties properties) + { + this.properties = properties; + } + + /** + * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) + */ + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) + { + for (String bean : getSecurityBeanNames(beanFactory)) + { + if (beanFactory.containsBeanDefinition(bean)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Adding RM method security definitions for " + bean); + } + + BeanDefinition beanDef = beanFactory.getBeanDefinition(bean); + PropertyValue beanValue = beanDef.getPropertyValues().getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE); + if (beanValue != null) + { + String beanStringValue = (String)((TypedStringValue)beanValue.getValue()).getValue(); + String mergedStringValue = merge(beanStringValue); + beanDef.getPropertyValues().addPropertyValue(PROP_OBJECT_DEFINITION_SOURCE, new TypedStringValue(mergedStringValue)); + } + } + } + } + + /** + * Get all the security bean names by looking at the property values set. + * + * @param beanFactory + * @return + */ + private Set getSecurityBeanNames(ConfigurableListableBeanFactory beanFactory) + { + if (securityBeanNameCache == null) + { + securityBeanNameCache = new HashSet(21); + if (securityBeanNames != null) + { + securityBeanNameCache.addAll(securityBeanNames); + } + + for (Object key : properties.keySet()) + { + String[] split = ((String)key).split("\\."); + int index = split.length - 2; + String securityBeanName = split[index] + SECURITY_BEAN_POSTFIX; + if (!securityBeanNameCache.contains(securityBeanName) && beanFactory.containsBean(securityBeanName)) + { + if (logger.isDebugEnabled()) + { + logger.debug("Adding " + securityBeanName + " to list from properties."); + } + + securityBeanNameCache.add(securityBeanName); + } + } + } + + return securityBeanNameCache; + } + + /** + * @param beanStringValue + * @param rmBeanStringValue + * @return + */ + private String merge(String beanStringValue) + { + Map map = convertToMap(beanStringValue); + + for (Map.Entry entry : map.entrySet()) + { + String key = entry.getKey(); + String propKey = PROPERTY_PREFIX + key; + if (properties.containsKey(propKey)) + { + map.put(key, entry.getValue() + "," + properties.getProperty(propKey)); + } + else + { + if (logger.isWarnEnabled()) + { + logger.warn("Missing RM security definition for method " + key); + } + } + } + + return convertToString(map); + } + + /** + * @param stringValue + * @return + */ + private Map convertToMap(String stringValue) + { + String[] values = stringValue.trim().split("\n"); + Map map = new HashMap(values.length); + for (String value : values) + { + String[] pair = value.trim().split("="); + map.put(pair[0], pair[1]); + } + return map; + } + + /** + * @param map + * @return + */ + private String convertToString(Map map) + { + StringBuffer buffer = new StringBuffer(256); + for (Map.Entry entry : map.entrySet()) + { + buffer.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); + } + + return buffer.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/site/GetChildrenCannedQueryFactory.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/site/GetChildrenCannedQueryFactory.java index c8d60aa97c..daf50c6e3c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/site/GetChildrenCannedQueryFactory.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/site/GetChildrenCannedQueryFactory.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.site; - -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.query.CannedQuery; -import org.alfresco.query.PagingRequest; -import org.alfresco.repo.node.getchildren.FilterProp; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * Override default implementation to add rma:rmsite to list of returned site types. - * - * See https://issues.alfresco.com/jira/browse/RM-387 - * - * @author Roy Wetherall - */ -public class GetChildrenCannedQueryFactory extends org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory - implements RecordsManagementModel -{ - @Override - public CannedQuery getCannedQuery(NodeRef parentRef, String pattern, Set assocTypeQNames, Set childTypeQNames, List filterProps, List> sortProps, PagingRequest pagingRequest) - { - childTypeQNames.add(TYPE_RM_SITE); - return super.getCannedQuery(parentRef, pattern, assocTypeQNames, childTypeQNames, filterProps, sortProps, pagingRequest); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.site; + +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.query.CannedQuery; +import org.alfresco.query.PagingRequest; +import org.alfresco.repo.node.getchildren.FilterProp; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; + +/** + * Override default implementation to add rma:rmsite to list of returned site types. + * + * See https://issues.alfresco.com/jira/browse/RM-387 + * + * @author Roy Wetherall + */ +public class GetChildrenCannedQueryFactory extends org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory + implements RecordsManagementModel +{ + @Override + public CannedQuery getCannedQuery(NodeRef parentRef, String pattern, Set assocTypeQNames, Set childTypeQNames, List filterProps, List> sortProps, PagingRequest pagingRequest) + { + childTypeQNames.add(TYPE_RM_SITE); + return super.getCannedQuery(parentRef, pattern, assocTypeQNames, childTypeQNames, filterProps, sortProps, pagingRequest); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferService.java index ccb53b74dc..1a1bf990b4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferService.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.transfer; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Transfer Service Interface - * - * @author Tuna Aksoy - * @since 2.2 - */ -public interface TransferService -{ - /** - * Indicates whether the given node is a transfer (container) or not. - * - * @param nodeRef node reference - * @return boolean true if transfer, false otherwise - * - * @since 2.0 - */ - boolean isTransfer(NodeRef nodeRef); - - /** - * Create the transfer node and link the disposition lifecycle node beneath it - * - * @param nodeRef node reference to transfer - * @param isAccession Indicates whether this transfer is an accession or not - * @return Returns the transfer object node reference - * - * @since 2.2 - */ - NodeRef transfer(NodeRef nodeRef, boolean isAccession); - - /** - * Completes the transfer for the given node. - * - * @param nodeRef node reference to complete the transfer - * - * @since 2.2 - */ - void completeTransfer(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.transfer; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Transfer Service Interface + * + * @author Tuna Aksoy + * @since 2.2 + */ +public interface TransferService +{ + /** + * Indicates whether the given node is a transfer (container) or not. + * + * @param nodeRef node reference + * @return boolean true if transfer, false otherwise + * + * @since 2.0 + */ + boolean isTransfer(NodeRef nodeRef); + + /** + * Create the transfer node and link the disposition lifecycle node beneath it + * + * @param nodeRef node reference to transfer + * @param isAccession Indicates whether this transfer is an accession or not + * @return Returns the transfer object node reference + * + * @since 2.2 + */ + NodeRef transfer(NodeRef nodeRef, boolean isAccession); + + /** + * Completes the transfer for the given node. + * + * @param nodeRef node reference to complete the transfer + * + * @since 2.2 + */ + void completeTransfer(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java index 027b9d9920..fb9ca66dd5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java @@ -1,312 +1,312 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.transfer; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Transfer service implementation - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class TransferServiceImpl extends ServiceBaseImpl - implements TransferService, RecordsManagementModel -{ - /** Transfer node reference key */ - public static final String KEY_TRANSFER_NODEREF = "transferNodeRef"; - - /** I18N */ - private static final String MSG_NODE_ALREADY_TRANSFER = "rm.action.node-already-transfer"; - - /** File Plan Service */ - protected FilePlanService filePlanService; - - /** Disposition service */ - protected DispositionService dispositionService; - - /** Record service */ - protected RecordService recordService; - - /** Record folder service */ - protected RecordFolderService recordFolderService; - - /** Freeze Service */ - protected FreezeService freezeService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param dispositionService disposition service - */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param recordFolderService record folder service - */ - public void setRecordFolderService(RecordFolderService recordFolderService) - { - this.recordFolderService = recordFolderService; - } - - /** - * @param freezeService freeze service - */ - public void setFreezeService(FreezeService freezeService) - { - this.freezeService = freezeService; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean) - */ - @Override - public NodeRef transfer(NodeRef nodeRef, boolean isAccession) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Get the root rm node - NodeRef root = filePlanService.getFilePlan(nodeRef); - - // Get the transfer object - NodeRef transferNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); - if (transferNodeRef == null) - { - // Calculate a transfer name - QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid"); - Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid); - String transferName = StringUtils.leftPad(dbId.toString(), 10, "0"); - - // Create the transfer object - Map transferProps = new HashMap(2); - transferProps.put(ContentModel.PROP_NAME, transferName); - transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, isAccession); - - // setup location property from disposition schedule - DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); - if (da != null) - { - DispositionActionDefinition actionDef = da.getDispositionActionDefinition(); - if (actionDef != null) - { - transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation()); - } - } - - NodeRef transferContainer = filePlanService.getTransferContainer(root); - transferNodeRef = nodeService.createNode(transferContainer, - ContentModel.ASSOC_CONTAINS, - QName.createQName(RM_URI, transferName), - TYPE_TRANSFER, - transferProps).getChildRef(); - - // Bind the hold node reference to the transaction - AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef); - } - else - { - // ensure this node has not already in the process of being transferred - List transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED); - for(ChildAssociationRef car : transferredAlready) - { - if(car.getChildRef().equals(nodeRef)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, nodeRef.toString())); - - } - } - } - - // Link the record to the trasnfer object - nodeService.addChild(transferNodeRef, - nodeRef, - ASSOC_TRANSFERRED, - ASSOC_TRANSFERRED); - - // Set PDF indicator flag - setPDFIndicationFlag(transferNodeRef, nodeRef); - - // Set the transferring indicator aspect - nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null); - if (isRecordFolder(nodeRef)) - { - // add the transferring indicator aspect to all the child records - for (NodeRef record : recordService.getRecords(nodeRef)) - { - nodeService.addAspect(record, ASPECT_TRANSFERRING, null); - } - } - - return transferNodeRef; - } - - /** - * - * @param transferNodeRef - * @param dispositionLifeCycleNodeRef - */ - private void setPDFIndicationFlag(NodeRef transferNodeRef, NodeRef dispositionLifeCycleNodeRef) - { - if (recordFolderService.isRecordFolder(dispositionLifeCycleNodeRef)) - { - List records = recordService.getRecords(dispositionLifeCycleNodeRef); - for (NodeRef record : records) - { - setPDFIndicationFlag(transferNodeRef, record); - } - } - else - { - ContentData contentData = (ContentData)nodeService.getProperty(dispositionLifeCycleNodeRef, ContentModel.PROP_CONTENT); - if (contentData != null && - MimetypeMap.MIMETYPE_PDF.equals(contentData.getMimetype())) - { - // Set the property indicator - nodeService.setProperty(transferNodeRef, PROP_TRANSFER_PDF_INDICATOR, true); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#completeTransfer(NodeRef) - */ - @Override - public void completeTransfer(NodeRef nodeRef) - { - boolean accessionIndicator = ((Boolean)nodeService.getProperty(nodeRef, PROP_TRANSFER_ACCESSION_INDICATOR)).booleanValue(); - String transferLocation = nodeService.getProperty(nodeRef, PROP_TRANSFER_LOCATION).toString(); - - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - if(freezeService.isFrozen(assoc.getChildRef())) - { - throw new AlfrescoRuntimeException("Could not complete a transfer that contains held folders"); - } - - if(freezeService.hasFrozenChildren(assoc.getChildRef())) - { - throw new AlfrescoRuntimeException("Cound not complete a transfer that contains folders with held children"); - } - - markComplete(assoc.getChildRef(), accessionIndicator, transferLocation); - } - - // Delete the transfer object - nodeService.deleteNode(nodeRef); - - NodeRef transferNodeRef = (NodeRef) AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); - if (transferNodeRef != null && transferNodeRef.equals(nodeRef)) - { - AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, null); - } - } - - /** - * Marks the node complete - * - * @param nodeRef - * disposition lifecycle node reference - */ - private void markComplete(NodeRef nodeRef, boolean accessionIndicator, String transferLocation) - { - // Set the completed date - DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); - if (da != null) - { - nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); - nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); - } - - // Remove the transferring indicator aspect - nodeService.removeAspect(nodeRef, ASPECT_TRANSFERRING); - nodeService.setProperty(nodeRef, PROP_LOCATION, transferLocation); - - // Determine which marker aspect to use - QName markerAspectQName = null; - if (accessionIndicator) - { - markerAspectQName = ASPECT_ASCENDED; - } - else - { - markerAspectQName = ASPECT_TRANSFERRED; - } - - // Mark the object and children accordingly - nodeService.addAspect(nodeRef, markerAspectQName, null); - if (recordFolderService.isRecordFolder(nodeRef)) - { - List records = recordService.getRecords(nodeRef); - for (NodeRef record : records) - { - nodeService.addAspect(record, markerAspectQName, null); - nodeService.setProperty(record, PROP_LOCATION, transferLocation); - } - } - - // Update to the next disposition action - dispositionService.updateNextDispositionAction(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.transfer; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.extensions.surf.util.ParameterCheck; + +/** + * Transfer service implementation + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class TransferServiceImpl extends ServiceBaseImpl + implements TransferService, RecordsManagementModel +{ + /** Transfer node reference key */ + public static final String KEY_TRANSFER_NODEREF = "transferNodeRef"; + + /** I18N */ + private static final String MSG_NODE_ALREADY_TRANSFER = "rm.action.node-already-transfer"; + + /** File Plan Service */ + protected FilePlanService filePlanService; + + /** Disposition service */ + protected DispositionService dispositionService; + + /** Record service */ + protected RecordService recordService; + + /** Record folder service */ + protected RecordFolderService recordFolderService; + + /** Freeze Service */ + protected FreezeService freezeService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param freezeService freeze service + */ + public void setFreezeService(FreezeService freezeService) + { + this.freezeService = freezeService; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean) + */ + @Override + public NodeRef transfer(NodeRef nodeRef, boolean isAccession) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Get the root rm node + NodeRef root = filePlanService.getFilePlan(nodeRef); + + // Get the transfer object + NodeRef transferNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); + if (transferNodeRef == null) + { + // Calculate a transfer name + QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid"); + Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid); + String transferName = StringUtils.leftPad(dbId.toString(), 10, "0"); + + // Create the transfer object + Map transferProps = new HashMap(2); + transferProps.put(ContentModel.PROP_NAME, transferName); + transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, isAccession); + + // setup location property from disposition schedule + DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); + if (da != null) + { + DispositionActionDefinition actionDef = da.getDispositionActionDefinition(); + if (actionDef != null) + { + transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation()); + } + } + + NodeRef transferContainer = filePlanService.getTransferContainer(root); + transferNodeRef = nodeService.createNode(transferContainer, + ContentModel.ASSOC_CONTAINS, + QName.createQName(RM_URI, transferName), + TYPE_TRANSFER, + transferProps).getChildRef(); + + // Bind the hold node reference to the transaction + AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef); + } + else + { + // ensure this node has not already in the process of being transferred + List transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED); + for(ChildAssociationRef car : transferredAlready) + { + if(car.getChildRef().equals(nodeRef)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, nodeRef.toString())); + + } + } + } + + // Link the record to the trasnfer object + nodeService.addChild(transferNodeRef, + nodeRef, + ASSOC_TRANSFERRED, + ASSOC_TRANSFERRED); + + // Set PDF indicator flag + setPDFIndicationFlag(transferNodeRef, nodeRef); + + // Set the transferring indicator aspect + nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null); + if (isRecordFolder(nodeRef)) + { + // add the transferring indicator aspect to all the child records + for (NodeRef record : recordService.getRecords(nodeRef)) + { + nodeService.addAspect(record, ASPECT_TRANSFERRING, null); + } + } + + return transferNodeRef; + } + + /** + * + * @param transferNodeRef + * @param dispositionLifeCycleNodeRef + */ + private void setPDFIndicationFlag(NodeRef transferNodeRef, NodeRef dispositionLifeCycleNodeRef) + { + if (recordFolderService.isRecordFolder(dispositionLifeCycleNodeRef)) + { + List records = recordService.getRecords(dispositionLifeCycleNodeRef); + for (NodeRef record : records) + { + setPDFIndicationFlag(transferNodeRef, record); + } + } + else + { + ContentData contentData = (ContentData)nodeService.getProperty(dispositionLifeCycleNodeRef, ContentModel.PROP_CONTENT); + if (contentData != null && + MimetypeMap.MIMETYPE_PDF.equals(contentData.getMimetype())) + { + // Set the property indicator + nodeService.setProperty(transferNodeRef, PROP_TRANSFER_PDF_INDICATOR, true); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#completeTransfer(NodeRef) + */ + @Override + public void completeTransfer(NodeRef nodeRef) + { + boolean accessionIndicator = ((Boolean)nodeService.getProperty(nodeRef, PROP_TRANSFER_ACCESSION_INDICATOR)).booleanValue(); + String transferLocation = nodeService.getProperty(nodeRef, PROP_TRANSFER_LOCATION).toString(); + + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + if(freezeService.isFrozen(assoc.getChildRef())) + { + throw new AlfrescoRuntimeException("Could not complete a transfer that contains held folders"); + } + + if(freezeService.hasFrozenChildren(assoc.getChildRef())) + { + throw new AlfrescoRuntimeException("Cound not complete a transfer that contains folders with held children"); + } + + markComplete(assoc.getChildRef(), accessionIndicator, transferLocation); + } + + // Delete the transfer object + nodeService.deleteNode(nodeRef); + + NodeRef transferNodeRef = (NodeRef) AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); + if (transferNodeRef != null && transferNodeRef.equals(nodeRef)) + { + AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, null); + } + } + + /** + * Marks the node complete + * + * @param nodeRef + * disposition lifecycle node reference + */ + private void markComplete(NodeRef nodeRef, boolean accessionIndicator, String transferLocation) + { + // Set the completed date + DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); + if (da != null) + { + nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); + nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); + } + + // Remove the transferring indicator aspect + nodeService.removeAspect(nodeRef, ASPECT_TRANSFERRING); + nodeService.setProperty(nodeRef, PROP_LOCATION, transferLocation); + + // Determine which marker aspect to use + QName markerAspectQName = null; + if (accessionIndicator) + { + markerAspectQName = ASPECT_ASCENDED; + } + else + { + markerAspectQName = ASPECT_TRANSFERRED; + } + + // Mark the object and children accordingly + nodeService.addAspect(nodeRef, markerAspectQName, null); + if (recordFolderService.isRecordFolder(nodeRef)) + { + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + nodeService.addAspect(record, markerAspectQName, null); + nodeService.setProperty(record, PROP_LOCATION, transferLocation); + } + } + + // Update to the next disposition action + dispositionService.updateNextDispositionAction(nodeRef); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AlfrescoTransactionSupport.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AlfrescoTransactionSupport.java index 8ac49d5ded..cba16677ca 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AlfrescoTransactionSupport.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AlfrescoTransactionSupport.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - - -/** - * Alfresco Transaction Support delegation bean. - * - * @author Roy Wetherall - * @since 2.3 - * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport - */ -public class AlfrescoTransactionSupport -{ - /** - * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#bindResource(Object, Object) - */ - public void bindResource(Object key, Object resource) - { - org.alfresco.repo.transaction.AlfrescoTransactionSupport.bindResource(key, resource); - } - - /** - * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#unbindResource(Object) - */ - public void unbindResource(Object key) - { - org.alfresco.repo.transaction.AlfrescoTransactionSupport.unbindResource(key); - } - - /** - * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#getResource(Object) - */ - public R getResource(Object key) - { - return org.alfresco.repo.transaction.AlfrescoTransactionSupport.getResource(key); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.util; + + +/** + * Alfresco Transaction Support delegation bean. + * + * @author Roy Wetherall + * @since 2.3 + * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport + */ +public class AlfrescoTransactionSupport +{ + /** + * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#bindResource(Object, Object) + */ + public void bindResource(Object key, Object resource) + { + org.alfresco.repo.transaction.AlfrescoTransactionSupport.bindResource(key, resource); + } + + /** + * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#unbindResource(Object) + */ + public void unbindResource(Object key) + { + org.alfresco.repo.transaction.AlfrescoTransactionSupport.unbindResource(key); + } + + /** + * @see org.alfresco.repo.transaction.AlfrescoTransactionSupport#getResource(Object) + */ + public R getResource(Object key) + { + return org.alfresco.repo.transaction.AlfrescoTransactionSupport.getResource(key); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java index a302118b20..92b339a8c0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; - -/** - * Helper bean to allow injection of AuthenticationUtil methods. - *

- * Useful when testing using mocks. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class AuthenticationUtil -{ - /** - * Helper method that executed work as system user. - *

- * Useful when testing using mocks. - * - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAsSystem(RunAsWork, String) - */ - public R runAsSystem(RunAsWork runAsWork) - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem(runAsWork); - } - - /** - * Helper method that executed work as given user. - *

- * Useful when testing using mocks. - * - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAs(RunAsWork, String) - */ - public R runAs(RunAsWork runAsWork, String uid) - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(runAsWork, uid); - } - - /** - * Helper method that gets the fully authenticated user. - *

- * Useful when testing using mocks. - * - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getFullyAuthenticatedUser() - */ - public String getFullyAuthenticatedUser() - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.getFullyAuthenticatedUser(); - } - - /** - * Helper method that gets the admin user name. - *

- * Useful when testing using mocks. - * - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getAdminUserName() - */ - public String getAdminUserName() - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName(); - } - - /** - * Helper method that gets the system user name. - * - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getSystemUserName() - */ - public String getSystemUserName() - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName(); - } - - /** - * @see org.alfresco.repo.security.authentication.AuthenticationUtil#isRunAsUserTheSystemUser() - */ - public boolean isRunAsUserTheSystemUser() - { - return org.alfresco.repo.security.authentication.AuthenticationUtil.isRunAsUserTheSystemUser(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.util; + +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; + +/** + * Helper bean to allow injection of AuthenticationUtil methods. + *

+ * Useful when testing using mocks. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class AuthenticationUtil +{ + /** + * Helper method that executed work as system user. + *

+ * Useful when testing using mocks. + * + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAsSystem(RunAsWork, String) + */ + public R runAsSystem(RunAsWork runAsWork) + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem(runAsWork); + } + + /** + * Helper method that executed work as given user. + *

+ * Useful when testing using mocks. + * + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAs(RunAsWork, String) + */ + public R runAs(RunAsWork runAsWork, String uid) + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(runAsWork, uid); + } + + /** + * Helper method that gets the fully authenticated user. + *

+ * Useful when testing using mocks. + * + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getFullyAuthenticatedUser() + */ + public String getFullyAuthenticatedUser() + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.getFullyAuthenticatedUser(); + } + + /** + * Helper method that gets the admin user name. + *

+ * Useful when testing using mocks. + * + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getAdminUserName() + */ + public String getAdminUserName() + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName(); + } + + /** + * Helper method that gets the system user name. + * + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#getSystemUserName() + */ + public String getSystemUserName() + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName(); + } + + /** + * @see org.alfresco.repo.security.authentication.AuthenticationUtil#isRunAsUserTheSystemUser() + */ + public boolean isRunAsUserTheSystemUser() + { + return org.alfresco.repo.security.authentication.AuthenticationUtil.isRunAsUserTheSystemUser(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/PoliciesUtil.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/PoliciesUtil.java index 0be8fb6699..b6c9932e3b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/PoliciesUtil.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/PoliciesUtil.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; - -/** - * Utility class with policy helper methods. - * - * @author Roy Wetherall - */ -public final class PoliciesUtil -{ - private PoliciesUtil() - { - // Will not be called - } - - /** - * Get all aspect and node type qualified names - * - * @param nodeRef - * the node we are interested in - * @return Returns a set of qualified names containing the node type and all - * the node aspects, or null if the node no longer exists - */ - public static Set getTypeAndAspectQNames(final NodeService nodeService, final NodeRef nodeRef) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public Set doWork() - { - Set qnames = null; - try - { - Set aspectQNames = nodeService.getAspects(nodeRef); - - QName typeQName = nodeService.getType(nodeRef); - - qnames = new HashSet(aspectQNames.size() + 1); - qnames.addAll(aspectQNames); - qnames.add(typeQName); - } - catch (InvalidNodeRefException e) - { - qnames = Collections.emptySet(); - } - // done - return qnames; - } - }, AuthenticationUtil.getAdminUserName()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.util; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.InvalidNodeRefException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Utility class with policy helper methods. + * + * @author Roy Wetherall + */ +public final class PoliciesUtil +{ + private PoliciesUtil() + { + // Will not be called + } + + /** + * Get all aspect and node type qualified names + * + * @param nodeRef + * the node we are interested in + * @return Returns a set of qualified names containing the node type and all + * the node aspects, or null if the node no longer exists + */ + public static Set getTypeAndAspectQNames(final NodeService nodeService, final NodeRef nodeRef) + { + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() + { + public Set doWork() + { + Set qnames = null; + try + { + Set aspectQNames = nodeService.getAspects(nodeRef); + + QName typeQName = nodeService.getType(nodeRef); + + qnames = new HashSet(aspectQNames.size() + 1); + qnames.addAll(aspectQNames); + qnames.add(typeQName); + } + catch (InvalidNodeRefException e) + { + qnames = Collections.emptySet(); + } + // done + return qnames; + } + }, AuthenticationUtil.getAdminUserName()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java index 84ae926006..630c0ddfac 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java @@ -1,528 +1,528 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.PropertyMap; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * Helper base class for service implementations. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ServiceBaseImpl implements RecordsManagementModel, ApplicationContextAware -{ - /** Node service */ - protected NodeService nodeService; - - /** Dictionary service */ - protected DictionaryService dictionaryService; - - /** Rendition service */ - protected RenditionService renditionService; - - /** Application context */ - protected ApplicationContext applicationContext; - - /** internal node service */ - private NodeService internalNodeService; - - /** authentication helper */ - protected AuthenticationUtil authenticationUtil; - - /** transactional resource helper */ - protected TransactionalResourceHelper transactionalResourceHelper; - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - { - this.applicationContext = applicationContext; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param service service - */ - public void setRenditionService(RenditionService service) - { - this.renditionService = service; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param authenticationUtil authentication util helper - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * @param transactionalResourceHelper transactional resource helper - */ - public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) - { - this.transactionalResourceHelper = transactionalResourceHelper; - } - - /** - * Helper to get internal node service. - *

- * Used for performance reasons. - */ - protected NodeService getInternalNodeService() - { - if (internalNodeService == null) - { - internalNodeService = (NodeService)applicationContext.getBean("dbNodeService"); - } - - return internalNodeService; - } - - /** - * Gets the file plan component kind from the given node reference - * - * @see FilePlanService#getFilePlanComponentKind(org.alfresco.service.cmr.repository.NodeRef) - */ - public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) - { - FilePlanComponentKind result = null; - - Map map = transactionalResourceHelper.getMap("rm.transaction.filePlanComponentByNodeRef"); - if (map.containsKey(nodeRef)) - { - result = map.get(nodeRef); - } - else - { - if (isFilePlanComponent(nodeRef)) - { - result = FilePlanComponentKind.FILE_PLAN_COMPONENT; - - if (isFilePlan(nodeRef)) - { - result = FilePlanComponentKind.FILE_PLAN; - } - else if (isRecordCategory(nodeRef)) - { - result = FilePlanComponentKind.RECORD_CATEGORY; - } - else if (isRecordFolder(nodeRef)) - { - result = FilePlanComponentKind.RECORD_FOLDER; - } - else if (isRecord(nodeRef)) - { - result = FilePlanComponentKind.RECORD; - } - else if (instanceOf(nodeRef, TYPE_HOLD_CONTAINER)) - { - result = FilePlanComponentKind.HOLD_CONTAINER; - } - else if (isHold(nodeRef)) - { - result = FilePlanComponentKind.HOLD; - } - else if (instanceOf(nodeRef, TYPE_TRANSFER_CONTAINER)) - { - result = FilePlanComponentKind.TRANSFER_CONTAINER; - } - else if (isTransfer(nodeRef)) - { - result = FilePlanComponentKind.TRANSFER; - } - else if (instanceOf(nodeRef, TYPE_DISPOSITION_SCHEDULE) || instanceOf(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION)) - { - result = FilePlanComponentKind.DISPOSITION_SCHEDULE; - } - else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER)) - { - result = FilePlanComponentKind.UNFILED_RECORD_CONTAINER; - } - else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_FOLDER)) - { - result = FilePlanComponentKind.UNFILED_RECORD_FOLDER; - } - } - - if (result != null) - { - map.put(nodeRef, result); - } - } - - return result; - } - - /** - * Gets the file plan component kind from the given type. - * - * @see FilePlanService#getFilePlanComponentKindFromType(QName) - */ - public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) - { - FilePlanComponentKind result = null; - - if (ASPECT_FILE_PLAN_COMPONENT.equals(type)) - { - result = FilePlanComponentKind.FILE_PLAN_COMPONENT; - } - else if (instanceOf(type, ASPECT_RECORD)) - { - result = FilePlanComponentKind.RECORD; - } - else if (instanceOf(type, TYPE_FILE_PLAN)) - { - result = FilePlanComponentKind.FILE_PLAN; - } - else if (instanceOf(type, TYPE_RECORD_CATEGORY)) - { - result = FilePlanComponentKind.RECORD_CATEGORY; - } - else if (instanceOf(type, TYPE_RECORD_FOLDER)) - { - result = FilePlanComponentKind.RECORD_FOLDER; - } - else if (instanceOf(type, TYPE_HOLD)) - { - result = FilePlanComponentKind.HOLD; - } - else if (instanceOf(type, TYPE_TRANSFER)) - { - result = FilePlanComponentKind.TRANSFER; - } - else if (instanceOf(type, TYPE_DISPOSITION_SCHEDULE) || - instanceOf(type, TYPE_DISPOSITION_ACTION_DEFINITION)) - { - result = FilePlanComponentKind.DISPOSITION_SCHEDULE; - } - - return result; - } - - /** - * Indicates whether the given node is a file plan component or not. - *

- * Exposed in the FilePlan service. - * - * @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isFilePlanComponent(NodeRef nodeRef) - { - boolean result = false; - if (getInternalNodeService().exists(nodeRef) && - getInternalNodeService().hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT)) - { - result = true; - } - return result; - } - - /** - * Indicates whether the given node is a file plan or not. - *

- * Exposed in the FilePlan service. - * - * @see FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isFilePlan(NodeRef nodeRef) - { - return instanceOf(nodeRef, TYPE_FILE_PLAN); - } - - /** - * Indicates whether the given node is a file plan container or not. - * - * @see FilePlanService#isFilePlanContainer(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isFilePlanContainer(NodeRef nodeRef) - { - return instanceOf(nodeRef, TYPE_RECORDS_MANAGEMENT_CONTAINER); - } - - /** - * Indicates whether the given node is a record category or not. - * - * @see FilePlanService#isRecordCategory(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isRecordCategory(NodeRef nodeRef) - { - return instanceOf(nodeRef, TYPE_RECORD_CATEGORY); - } - - /** - * Indicates whether the given node is a record folder or not. - *

- * Exposed in the RecordFolder service. - * - * @param nodeRef node reference - * @return boolean true if record folder, false otherwise - */ - public boolean isRecordFolder(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - return instanceOf(nodeRef, TYPE_RECORD_FOLDER); - } - - /** - * Indicates whether the given node reference is a record or not. - * - * @param nodeRef node reference - * @return boolean true if node reference is a record, false otherwise - */ - public boolean isRecord(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return getInternalNodeService().hasAspect(nodeRef, ASPECT_RECORD); - } - - /** - * Indicates whether the given node reference is a hold or not. - *

- * Exposed publicly in the {@link HoldService} - * - * @param nodeRef node reference - * @return boolean true if rma:hold or sub-type, false otherwise - */ - public boolean isHold(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - boolean isHold = false; - if (getInternalNodeService().exists(nodeRef) && - instanceOf(nodeRef, TYPE_HOLD)) - { - isHold = true; - } - return isHold; - } - - /** - * Indicates whether the given node reference is a transfer or not. - * - * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#isTransfer(NodeRef) - */ - public boolean isTransfer(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return instanceOf(nodeRef, TYPE_TRANSFER); - } - - /** - * Indicates whether the given node reference is an unfiled records container or not. - * - * @param nodeRef node reference - * @return boolean true if rma:unfiledRecordContainer or sub-type, false otherwise - */ - public boolean isUnfiledRecordsContainer(NodeRef nodeRef) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - - return instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER); - } - - /** - * Indicates whether a record is complete or not. - * - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isDeclared(NodeRef record) - { - ParameterCheck.mandatory("record", record); - - return getInternalNodeService().hasAspect(record, ASPECT_DECLARED_RECORD); - } - - /** - * Gets the file plan that a given file plan component resides within. - * - * @param nodeRef node reference - * @return {@link NodeRef} file plan, null if none - */ - public NodeRef getFilePlan(final NodeRef nodeRef) - { - NodeRef result = null; - if (nodeRef != null) - { - Map transactionCache = transactionalResourceHelper.getMap("rm.servicebase.getFilePlan"); - if (transactionCache.containsKey(nodeRef)) - { - result = transactionCache.get(nodeRef); - } - else - { - result = (NodeRef)getInternalNodeService().getProperty(nodeRef, PROP_ROOT_NODEREF); - if (result == null || !instanceOf(result, TYPE_FILE_PLAN)) - { - if (instanceOf(nodeRef, TYPE_FILE_PLAN)) - { - result = nodeRef; - } - else - { - ChildAssociationRef parentAssocRef = getInternalNodeService().getPrimaryParent(nodeRef); - if (parentAssocRef != null) - { - result = getFilePlan(parentAssocRef.getParentRef()); - } - } - } - - // cache result in transaction - transactionCache.put(nodeRef, result); - } - } - - return result; - } - - /** - * Utility method to safely and quickly determine if a node is a type (or sub-type) of the one specified. - * - * @param nodeRef node reference - * @param ofClassName class name to check - */ - protected boolean instanceOf(NodeRef nodeRef, QName ofClassName) - { - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("ofClassName", ofClassName); - QName className = getInternalNodeService().getType(nodeRef); - return instanceOf(className, ofClassName); - } - - private static Map instanceOfCache = new HashMap(); - - /** - * Utility method to quickly determine whether one class is equal to or sub of another. - * - * @param className class name - * @param ofClassName class name to check against - * @return boolean true if equal to or sub, false otherwise - */ - protected boolean instanceOf(QName className, QName ofClassName) - { - ParameterCheck.mandatory("className", className); - ParameterCheck.mandatory("ofClassName", ofClassName); - - boolean result = false; - - String key = className.toString() + "|" + ofClassName.toString(); - if (instanceOfCache.containsKey(key)) - { - result = instanceOfCache.get(key); - } - else - { - if (ofClassName.equals(className) || - dictionaryService.isSubClass(className, ofClassName)) - { - result = true; - } - - instanceOfCache.put(key, result); - } - - return result; - } - - /** - * Utility method to get the next counter for a node. - *

- * If the node is not already countable, then rma:countable is added and 0 returned. - * - * @param nodeRef node reference - * @return int next counter value - */ - protected int getNextCount(NodeRef nodeRef) - { - int counter = 0; - if (!nodeService.hasAspect(nodeRef, ASPECT_COUNTABLE)) - { - PropertyMap props = new PropertyMap(1); - props.put(PROP_COUNT, 1); - nodeService.addAspect(nodeRef, ASPECT_COUNTABLE, props); - counter = 1; - } - else - { - Integer value = (Integer)this.nodeService.getProperty(nodeRef, PROP_COUNT); - if (value != null) - { - counter = value.intValue() + 1; - } - else - { - counter = 1; - } - nodeService.setProperty(nodeRef, PROP_COUNT, counter); - - } - return counter; - } - - /** - * Helper method to get a set containing the node's type and all it's aspects - * - * @param nodeRef nodeRef - * @return Set set of qname's - */ - protected Set getTypeAndApsects(NodeRef nodeRef) - { - Set result = nodeService.getAspects(nodeRef); - result.add(nodeService.getType(nodeRef)); - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.util; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.rendition.RenditionService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.alfresco.util.PropertyMap; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * Helper base class for service implementations. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ServiceBaseImpl implements RecordsManagementModel, ApplicationContextAware +{ + /** Node service */ + protected NodeService nodeService; + + /** Dictionary service */ + protected DictionaryService dictionaryService; + + /** Rendition service */ + protected RenditionService renditionService; + + /** Application context */ + protected ApplicationContext applicationContext; + + /** internal node service */ + private NodeService internalNodeService; + + /** authentication helper */ + protected AuthenticationUtil authenticationUtil; + + /** transactional resource helper */ + protected TransactionalResourceHelper transactionalResourceHelper; + + /** + * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) + { + this.applicationContext = applicationContext; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param service service + */ + public void setRenditionService(RenditionService service) + { + this.renditionService = service; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param authenticationUtil authentication util helper + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * @param transactionalResourceHelper transactional resource helper + */ + public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) + { + this.transactionalResourceHelper = transactionalResourceHelper; + } + + /** + * Helper to get internal node service. + *

+ * Used for performance reasons. + */ + protected NodeService getInternalNodeService() + { + if (internalNodeService == null) + { + internalNodeService = (NodeService)applicationContext.getBean("dbNodeService"); + } + + return internalNodeService; + } + + /** + * Gets the file plan component kind from the given node reference + * + * @see FilePlanService#getFilePlanComponentKind(org.alfresco.service.cmr.repository.NodeRef) + */ + public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) + { + FilePlanComponentKind result = null; + + Map map = transactionalResourceHelper.getMap("rm.transaction.filePlanComponentByNodeRef"); + if (map.containsKey(nodeRef)) + { + result = map.get(nodeRef); + } + else + { + if (isFilePlanComponent(nodeRef)) + { + result = FilePlanComponentKind.FILE_PLAN_COMPONENT; + + if (isFilePlan(nodeRef)) + { + result = FilePlanComponentKind.FILE_PLAN; + } + else if (isRecordCategory(nodeRef)) + { + result = FilePlanComponentKind.RECORD_CATEGORY; + } + else if (isRecordFolder(nodeRef)) + { + result = FilePlanComponentKind.RECORD_FOLDER; + } + else if (isRecord(nodeRef)) + { + result = FilePlanComponentKind.RECORD; + } + else if (instanceOf(nodeRef, TYPE_HOLD_CONTAINER)) + { + result = FilePlanComponentKind.HOLD_CONTAINER; + } + else if (isHold(nodeRef)) + { + result = FilePlanComponentKind.HOLD; + } + else if (instanceOf(nodeRef, TYPE_TRANSFER_CONTAINER)) + { + result = FilePlanComponentKind.TRANSFER_CONTAINER; + } + else if (isTransfer(nodeRef)) + { + result = FilePlanComponentKind.TRANSFER; + } + else if (instanceOf(nodeRef, TYPE_DISPOSITION_SCHEDULE) || instanceOf(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION)) + { + result = FilePlanComponentKind.DISPOSITION_SCHEDULE; + } + else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER)) + { + result = FilePlanComponentKind.UNFILED_RECORD_CONTAINER; + } + else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_FOLDER)) + { + result = FilePlanComponentKind.UNFILED_RECORD_FOLDER; + } + } + + if (result != null) + { + map.put(nodeRef, result); + } + } + + return result; + } + + /** + * Gets the file plan component kind from the given type. + * + * @see FilePlanService#getFilePlanComponentKindFromType(QName) + */ + public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) + { + FilePlanComponentKind result = null; + + if (ASPECT_FILE_PLAN_COMPONENT.equals(type)) + { + result = FilePlanComponentKind.FILE_PLAN_COMPONENT; + } + else if (instanceOf(type, ASPECT_RECORD)) + { + result = FilePlanComponentKind.RECORD; + } + else if (instanceOf(type, TYPE_FILE_PLAN)) + { + result = FilePlanComponentKind.FILE_PLAN; + } + else if (instanceOf(type, TYPE_RECORD_CATEGORY)) + { + result = FilePlanComponentKind.RECORD_CATEGORY; + } + else if (instanceOf(type, TYPE_RECORD_FOLDER)) + { + result = FilePlanComponentKind.RECORD_FOLDER; + } + else if (instanceOf(type, TYPE_HOLD)) + { + result = FilePlanComponentKind.HOLD; + } + else if (instanceOf(type, TYPE_TRANSFER)) + { + result = FilePlanComponentKind.TRANSFER; + } + else if (instanceOf(type, TYPE_DISPOSITION_SCHEDULE) || + instanceOf(type, TYPE_DISPOSITION_ACTION_DEFINITION)) + { + result = FilePlanComponentKind.DISPOSITION_SCHEDULE; + } + + return result; + } + + /** + * Indicates whether the given node is a file plan component or not. + *

+ * Exposed in the FilePlan service. + * + * @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) + */ + public boolean isFilePlanComponent(NodeRef nodeRef) + { + boolean result = false; + if (getInternalNodeService().exists(nodeRef) && + getInternalNodeService().hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT)) + { + result = true; + } + return result; + } + + /** + * Indicates whether the given node is a file plan or not. + *

+ * Exposed in the FilePlan service. + * + * @see FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef) + */ + public boolean isFilePlan(NodeRef nodeRef) + { + return instanceOf(nodeRef, TYPE_FILE_PLAN); + } + + /** + * Indicates whether the given node is a file plan container or not. + * + * @see FilePlanService#isFilePlanContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + public boolean isFilePlanContainer(NodeRef nodeRef) + { + return instanceOf(nodeRef, TYPE_RECORDS_MANAGEMENT_CONTAINER); + } + + /** + * Indicates whether the given node is a record category or not. + * + * @see FilePlanService#isRecordCategory(org.alfresco.service.cmr.repository.NodeRef) + */ + public boolean isRecordCategory(NodeRef nodeRef) + { + return instanceOf(nodeRef, TYPE_RECORD_CATEGORY); + } + + /** + * Indicates whether the given node is a record folder or not. + *

+ * Exposed in the RecordFolder service. + * + * @param nodeRef node reference + * @return boolean true if record folder, false otherwise + */ + public boolean isRecordFolder(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return instanceOf(nodeRef, TYPE_RECORD_FOLDER); + } + + /** + * Indicates whether the given node reference is a record or not. + * + * @param nodeRef node reference + * @return boolean true if node reference is a record, false otherwise + */ + public boolean isRecord(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return getInternalNodeService().hasAspect(nodeRef, ASPECT_RECORD); + } + + /** + * Indicates whether the given node reference is a hold or not. + *

+ * Exposed publicly in the {@link HoldService} + * + * @param nodeRef node reference + * @return boolean true if rma:hold or sub-type, false otherwise + */ + public boolean isHold(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + boolean isHold = false; + if (getInternalNodeService().exists(nodeRef) && + instanceOf(nodeRef, TYPE_HOLD)) + { + isHold = true; + } + return isHold; + } + + /** + * Indicates whether the given node reference is a transfer or not. + * + * @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#isTransfer(NodeRef) + */ + public boolean isTransfer(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return instanceOf(nodeRef, TYPE_TRANSFER); + } + + /** + * Indicates whether the given node reference is an unfiled records container or not. + * + * @param nodeRef node reference + * @return boolean true if rma:unfiledRecordContainer or sub-type, false otherwise + */ + public boolean isUnfiledRecordsContainer(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + return instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER); + } + + /** + * Indicates whether a record is complete or not. + * + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) + */ + public boolean isDeclared(NodeRef record) + { + ParameterCheck.mandatory("record", record); + + return getInternalNodeService().hasAspect(record, ASPECT_DECLARED_RECORD); + } + + /** + * Gets the file plan that a given file plan component resides within. + * + * @param nodeRef node reference + * @return {@link NodeRef} file plan, null if none + */ + public NodeRef getFilePlan(final NodeRef nodeRef) + { + NodeRef result = null; + if (nodeRef != null) + { + Map transactionCache = transactionalResourceHelper.getMap("rm.servicebase.getFilePlan"); + if (transactionCache.containsKey(nodeRef)) + { + result = transactionCache.get(nodeRef); + } + else + { + result = (NodeRef)getInternalNodeService().getProperty(nodeRef, PROP_ROOT_NODEREF); + if (result == null || !instanceOf(result, TYPE_FILE_PLAN)) + { + if (instanceOf(nodeRef, TYPE_FILE_PLAN)) + { + result = nodeRef; + } + else + { + ChildAssociationRef parentAssocRef = getInternalNodeService().getPrimaryParent(nodeRef); + if (parentAssocRef != null) + { + result = getFilePlan(parentAssocRef.getParentRef()); + } + } + } + + // cache result in transaction + transactionCache.put(nodeRef, result); + } + } + + return result; + } + + /** + * Utility method to safely and quickly determine if a node is a type (or sub-type) of the one specified. + * + * @param nodeRef node reference + * @param ofClassName class name to check + */ + protected boolean instanceOf(NodeRef nodeRef, QName ofClassName) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("ofClassName", ofClassName); + QName className = getInternalNodeService().getType(nodeRef); + return instanceOf(className, ofClassName); + } + + private static Map instanceOfCache = new HashMap(); + + /** + * Utility method to quickly determine whether one class is equal to or sub of another. + * + * @param className class name + * @param ofClassName class name to check against + * @return boolean true if equal to or sub, false otherwise + */ + protected boolean instanceOf(QName className, QName ofClassName) + { + ParameterCheck.mandatory("className", className); + ParameterCheck.mandatory("ofClassName", ofClassName); + + boolean result = false; + + String key = className.toString() + "|" + ofClassName.toString(); + if (instanceOfCache.containsKey(key)) + { + result = instanceOfCache.get(key); + } + else + { + if (ofClassName.equals(className) || + dictionaryService.isSubClass(className, ofClassName)) + { + result = true; + } + + instanceOfCache.put(key, result); + } + + return result; + } + + /** + * Utility method to get the next counter for a node. + *

+ * If the node is not already countable, then rma:countable is added and 0 returned. + * + * @param nodeRef node reference + * @return int next counter value + */ + protected int getNextCount(NodeRef nodeRef) + { + int counter = 0; + if (!nodeService.hasAspect(nodeRef, ASPECT_COUNTABLE)) + { + PropertyMap props = new PropertyMap(1); + props.put(PROP_COUNT, 1); + nodeService.addAspect(nodeRef, ASPECT_COUNTABLE, props); + counter = 1; + } + else + { + Integer value = (Integer)this.nodeService.getProperty(nodeRef, PROP_COUNT); + if (value != null) + { + counter = value.intValue() + 1; + } + else + { + counter = 1; + } + nodeService.setProperty(nodeRef, PROP_COUNT, counter); + + } + return counter; + } + + /** + * Helper method to get a set containing the node's type and all it's aspects + * + * @param nodeRef nodeRef + * @return Set set of qname's + */ + protected Set getTypeAndApsects(NodeRef nodeRef) + { + Set result = nodeService.getAspects(nodeRef); + result.add(nodeService.getType(nodeRef)); + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/TransactionalResourceHelper.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/TransactionalResourceHelper.java index 9f62a1512d..afc4c94d14 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/TransactionalResourceHelper.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/TransactionalResourceHelper.java @@ -1,106 +1,106 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -/** - * Delegate spring bean for TransactionResourceHelper - * - * @author Roy Wetherall - * @since 2.3 - * @see org.alfresco.repo.transaction.TransactionalResourceHelper - */ -public class TransactionalResourceHelper -{ - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) - */ - public int getCount(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.getCount(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) - */ - public void resetCount(Object resourceKey) - { - org.alfresco.repo.transaction.TransactionalResourceHelper.resetCount(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#incrementCount(Object) - */ - public int incrementCount(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.incrementCount(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#decrementCount(Object, boolean) - */ - public int decrementCount(Object resourceKey, boolean allowNegative) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.decrementCount(resourceKey, allowNegative); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) - */ - public boolean isResourcePresent(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.isResourcePresent(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getMap(Object) - */ - public Map getMap(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.getMap(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getSet(Object) - */ - public Set getSet(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.getSet(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getTreeSet(Object) - */ - public TreeSet getTreeSet(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.getTreeSet(resourceKey); - } - - /** - * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getList(Object) - */ - public List getList(Object resourceKey) - { - return org.alfresco.repo.transaction.TransactionalResourceHelper.getList(resourceKey); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.util; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +/** + * Delegate spring bean for TransactionResourceHelper + * + * @author Roy Wetherall + * @since 2.3 + * @see org.alfresco.repo.transaction.TransactionalResourceHelper + */ +public class TransactionalResourceHelper +{ + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) + */ + public int getCount(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.getCount(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) + */ + public void resetCount(Object resourceKey) + { + org.alfresco.repo.transaction.TransactionalResourceHelper.resetCount(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#incrementCount(Object) + */ + public int incrementCount(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.incrementCount(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#decrementCount(Object, boolean) + */ + public int decrementCount(Object resourceKey, boolean allowNegative) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.decrementCount(resourceKey, allowNegative); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getCount(Object) + */ + public boolean isResourcePresent(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.isResourcePresent(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getMap(Object) + */ + public Map getMap(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.getMap(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getSet(Object) + */ + public Set getSet(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.getSet(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getTreeSet(Object) + */ + public TreeSet getTreeSet(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.getTreeSet(resourceKey); + } + + /** + * @see org.alfresco.repo.transaction.TransactionalResourceHelper#getList(Object) + */ + public List getList(Object resourceKey) + { + return org.alfresco.repo.transaction.TransactionalResourceHelper.getList(resourceKey); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspect.java index 31200792e8..c9abfc216e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspect.java @@ -1,215 +1,215 @@ -/* - * Copyright (C) 2005-2015 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.version; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.lock.LockUtils; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.lock.LockService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Extend versionable aspect auto-version behaviour to allow versions to be - * created when the content type is changed. - * - * Note: this behaviour should be merged into core asap - * - * @author Roy Wetherall - * @since 2.3.1 - */ -@BehaviourBean -public class ExtendedVersionableAspect implements NodeServicePolicies.OnSetNodeTypePolicy -{ - /** The i18n'ized messages */ - private static final String MSG_AUTO_VERSION = "create_version.auto_version"; - - /** Transaction resource key */ - private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs"; - - /** node service */ - private NodeService nodeService; - - /** version service */ - private VersionService versionService; - - /** lock service */ - private LockService lockService; - - /** alfresco transaction support */ - private AlfrescoTransactionSupport alfrescoTransactionSupport; - - /** authentication util */ - private AuthenticationUtil authenticationUtil; - - /** indicates whether auto version should be triggered on type change */ - private boolean isAutoVersionOnTypeChange = false; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param versionService version service - */ - public void setVersionService(VersionService versionService) - { - this.versionService = versionService; - } - - /** - * @param lockService lock service - */ - public void setLockService(LockService lockService) - { - this.lockService = lockService; - } - - /** - * @param alfrescoTransactionSupport alfresco transaction support - */ - public void setAlfrescoTransactionSupport(AlfrescoTransactionSupport alfrescoTransactionSupport) - { - this.alfrescoTransactionSupport = alfrescoTransactionSupport; - } - - /** - * @param authenticationUtil authentication util - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * @param isAutoVersionOnTypeChange true if auto version on type change, false otherwise - */ - public void setAutoVersionOnTypeChange(boolean isAutoVersionOnTypeChange) - { - this.isAutoVersionOnTypeChange = isAutoVersionOnTypeChange; - } - - /** - * On set node type behaviour - * - * @param nodeRef node reference - * @param oldType old type - * @param newType new type - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @Behaviour - ( - type="cm:versionable", - kind=BehaviourKind.CLASS, - notificationFrequency=NotificationFrequency.TRANSACTION_COMMIT - ) - public void onSetNodeType(NodeRef nodeRef, QName oldType, QName newType) - { - if (isAutoVersionOnTypeChange && - nodeService.exists(nodeRef) && - !LockUtils.isLockedAndReadOnly(nodeRef, lockService) && - nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) && - !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) - { - Map versionedNodeRefs = (Map)alfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS); - if (versionedNodeRefs == null || !versionedNodeRefs.containsKey(nodeRef)) - { - // Determine whether the node is auto versionable (for content updates) or not - boolean autoVersion = false; - Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION); - if (value != null) - { - // If the value is not null then - autoVersion = value.booleanValue(); - } - - // NOTE: auto version on type change is a global setting, if thins extension was moved into the - // core then cm:versionable could be extended with a property consistent with the current - // implementation - - if (autoVersion) - { - // Create the auto-version - Map versionProperties = new HashMap(1); - versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION)); - - createVersionImpl(nodeRef, versionProperties); - } - } - } - } - - /** - * On create version implementation method. - * - * @param nodeRef node reference - * @param versionProperties version properties - */ - private void createVersionImpl(final NodeRef nodeRef, final Map versionProperties) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - recordCreateVersion(nodeRef, null); - versionService.createVersion(nodeRef, versionProperties); - return null; - } - }); - } - - /** - * Record that the new version has been created - * - * @param versionableNode versionable node reference - * @param version version - */ - @SuppressWarnings("unchecked") - private void recordCreateVersion(NodeRef versionableNode, Version version) - { - Map versionedNodeRefs = (Map)alfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS); - if (versionedNodeRefs == null) - { - versionedNodeRefs = new HashMap(); - alfrescoTransactionSupport.bindResource(KEY_VERSIONED_NODEREFS, versionedNodeRefs); - } - versionedNodeRefs.put(versionableNode, versionableNode); - } -} +/* + * Copyright (C) 2005-2015 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.version; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.repo.lock.LockUtils; +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.lock.LockService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Extend versionable aspect auto-version behaviour to allow versions to be + * created when the content type is changed. + * + * Note: this behaviour should be merged into core asap + * + * @author Roy Wetherall + * @since 2.3.1 + */ +@BehaviourBean +public class ExtendedVersionableAspect implements NodeServicePolicies.OnSetNodeTypePolicy +{ + /** The i18n'ized messages */ + private static final String MSG_AUTO_VERSION = "create_version.auto_version"; + + /** Transaction resource key */ + private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs"; + + /** node service */ + private NodeService nodeService; + + /** version service */ + private VersionService versionService; + + /** lock service */ + private LockService lockService; + + /** alfresco transaction support */ + private AlfrescoTransactionSupport alfrescoTransactionSupport; + + /** authentication util */ + private AuthenticationUtil authenticationUtil; + + /** indicates whether auto version should be triggered on type change */ + private boolean isAutoVersionOnTypeChange = false; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param versionService version service + */ + public void setVersionService(VersionService versionService) + { + this.versionService = versionService; + } + + /** + * @param lockService lock service + */ + public void setLockService(LockService lockService) + { + this.lockService = lockService; + } + + /** + * @param alfrescoTransactionSupport alfresco transaction support + */ + public void setAlfrescoTransactionSupport(AlfrescoTransactionSupport alfrescoTransactionSupport) + { + this.alfrescoTransactionSupport = alfrescoTransactionSupport; + } + + /** + * @param authenticationUtil authentication util + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * @param isAutoVersionOnTypeChange true if auto version on type change, false otherwise + */ + public void setAutoVersionOnTypeChange(boolean isAutoVersionOnTypeChange) + { + this.isAutoVersionOnTypeChange = isAutoVersionOnTypeChange; + } + + /** + * On set node type behaviour + * + * @param nodeRef node reference + * @param oldType old type + * @param newType new type + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + @Behaviour + ( + type="cm:versionable", + kind=BehaviourKind.CLASS, + notificationFrequency=NotificationFrequency.TRANSACTION_COMMIT + ) + public void onSetNodeType(NodeRef nodeRef, QName oldType, QName newType) + { + if (isAutoVersionOnTypeChange && + nodeService.exists(nodeRef) && + !LockUtils.isLockedAndReadOnly(nodeRef, lockService) && + nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) && + !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) + { + Map versionedNodeRefs = (Map)alfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS); + if (versionedNodeRefs == null || !versionedNodeRefs.containsKey(nodeRef)) + { + // Determine whether the node is auto versionable (for content updates) or not + boolean autoVersion = false; + Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION); + if (value != null) + { + // If the value is not null then + autoVersion = value.booleanValue(); + } + + // NOTE: auto version on type change is a global setting, if thins extension was moved into the + // core then cm:versionable could be extended with a property consistent with the current + // implementation + + if (autoVersion) + { + // Create the auto-version + Map versionProperties = new HashMap(1); + versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION)); + + createVersionImpl(nodeRef, versionProperties); + } + } + } + } + + /** + * On create version implementation method. + * + * @param nodeRef node reference + * @param versionProperties version properties + */ + private void createVersionImpl(final NodeRef nodeRef, final Map versionProperties) + { + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + recordCreateVersion(nodeRef, null); + versionService.createVersion(nodeRef, versionProperties); + return null; + } + }); + } + + /** + * Record that the new version has been created + * + * @param versionableNode versionable node reference + * @param version version + */ + @SuppressWarnings("unchecked") + private void recordCreateVersion(NodeRef versionableNode, Version version) + { + Map versionedNodeRefs = (Map)alfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS); + if (versionedNodeRefs == null) + { + versionedNodeRefs = new HashMap(); + alfrescoTransactionSupport.bindResource(KEY_VERSIONED_NODEREFS, versionedNodeRefs); + } + versionedNodeRefs.put(versionableNode, versionableNode); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionModel.java index 180b191bfd..97a86aea39 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionModel.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -import org.alfresco.service.namespace.QName; - -/** - * Helper class containing recordable version model qualified names - * - * @author Roy Wetherall - * @since 2.3 - */ -public interface RecordableVersionModel -{ - /** Namespace details */ - String RMV_URI = "http://www.alfresco.org/model/recordableversion/1.0"; - String RMV_PREFIX = "rmv"; - - /** versionable aspect */ - QName ASPECT_VERSIONABLE = QName.createQName(RMV_URI, "versionable"); - QName PROP_RECORDABLE_VERSION_POLICY = QName.createQName(RMV_URI, "recordableVersionPolicy"); - QName PROP_FILE_PLAN = QName.createQName(RMV_URI, "filePlan"); - - /** recorded version aspect */ - QName ASPECT_RECORDED_VERSION = QName.createQName(RMV_URI, "recordedVersion"); - QName PROP_RECORD_NODE_REF = QName.createQName(RMV_URI, "recordNodeRef"); - QName PROP_FROZEN_OWNER = QName.createQName(RMV_URI, "frozenOwner"); - QName PROP_DESTROYED = QName.createQName(RMV_URI, "destroyed"); - - /** version record aspect */ - QName ASPECT_VERSION_RECORD = QName.createQName(RMV_URI, "versionRecord"); - QName PROP_VERSIONED_NODEREF = QName.createQName(RMV_URI, "versionedNodeRef"); - QName PROP_VERSION_LABEL = QName.createQName(RMV_URI, "versionLabel"); - QName PROP_VERSION_DESCRIPTION = QName.createQName(RMV_URI, "versionDescription"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +import org.alfresco.service.namespace.QName; + +/** + * Helper class containing recordable version model qualified names + * + * @author Roy Wetherall + * @since 2.3 + */ +public interface RecordableVersionModel +{ + /** Namespace details */ + String RMV_URI = "http://www.alfresco.org/model/recordableversion/1.0"; + String RMV_PREFIX = "rmv"; + + /** versionable aspect */ + QName ASPECT_VERSIONABLE = QName.createQName(RMV_URI, "versionable"); + QName PROP_RECORDABLE_VERSION_POLICY = QName.createQName(RMV_URI, "recordableVersionPolicy"); + QName PROP_FILE_PLAN = QName.createQName(RMV_URI, "filePlan"); + + /** recorded version aspect */ + QName ASPECT_RECORDED_VERSION = QName.createQName(RMV_URI, "recordedVersion"); + QName PROP_RECORD_NODE_REF = QName.createQName(RMV_URI, "recordNodeRef"); + QName PROP_FROZEN_OWNER = QName.createQName(RMV_URI, "frozenOwner"); + QName PROP_DESTROYED = QName.createQName(RMV_URI, "destroyed"); + + /** version record aspect */ + QName ASPECT_VERSION_RECORD = QName.createQName(RMV_URI, "versionRecord"); + QName PROP_VERSIONED_NODEREF = QName.createQName(RMV_URI, "versionedNodeRef"); + QName PROP_VERSION_LABEL = QName.createQName(RMV_URI, "versionLabel"); + QName PROP_VERSION_DESCRIPTION = QName.createQName(RMV_URI, "versionDescription"); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java index 066f69ccb1..6b77fbb868 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java @@ -1,248 +1,248 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -import static org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl.RECORD_MODEL_URIS; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.version.Node2ServiceImpl; -import org.alfresco.repo.version.Version2Model; -import org.alfresco.repo.version.common.VersionUtil; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Extended version node service implementation that supports the retrieval of - * recorded version state. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordableVersionNodeServiceImpl extends Node2ServiceImpl - implements RecordableVersionModel -{ - /** record service */ - private RecordService recordService; - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @see org.alfresco.repo.version.Node2ServiceImpl#getProperties(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - public Map getProperties(NodeRef nodeRef) throws InvalidNodeRefException - { - // TODO only supported for Version2 - - NodeRef converted = VersionUtil.convertNodeRef(nodeRef); - if (dbNodeService.hasAspect(converted, ASPECT_RECORDED_VERSION)) - { - NodeRef record = (NodeRef)dbNodeService.getProperty(converted, PROP_RECORD_NODE_REF); - if (record != null && dbNodeService.exists(record)) - { - Map properties = dbNodeService.getProperties(record); - return processProperties(converted, properties); - } - else - { - return (Map)Collections.EMPTY_MAP; - } - } - else - { - return super.getProperties(nodeRef); - } - } - - /** - * Process properties map before returning as frozen state. - * - * @param properties properties map - * @return {@link Map}<{@link QName}, {@link Serializable}> processed property map - */ - protected Map processProperties(NodeRef version, Map properties) - { - Map cloneProperties = new HashMap(properties); - - // revert modified record name - properties.put(ContentModel.PROP_NAME, properties.get(RecordsManagementModel.PROP_ORIGIONAL_NAME)); - - // remove all rma, rmc, rmr and rmv properties - for (QName property : cloneProperties.keySet()) - { - if (!PROP_RECORDABLE_VERSION_POLICY.equals(property) && - !PROP_FILE_PLAN.equals(property) && - (recordService.isRecordMetadataProperty(property) || - RECORD_MODEL_URIS.contains(property.getNamespaceURI()))) - { - properties.remove(property); - } - } - - // do standard property processing - processVersionProperties(version, properties); - - return properties; - } - - /** - * Process version properties. - * - * @param version version node reference - * @param properties properties map - */ - protected void processVersionProperties(NodeRef version, Map properties) throws InvalidNodeRefException - { - // get version properties - Map versionProperties = dbNodeService.getProperties(version); - - if (versionProperties != null) - { - String versionLabel = (String)versionProperties.get(Version2Model.PROP_QNAME_VERSION_LABEL); - properties.put(ContentModel.PROP_VERSION_LABEL, versionLabel); - - // Convert frozen sys:referenceable properties - NodeRef nodeRef = (NodeRef)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF); - if (nodeRef != null) - { - properties.put(ContentModel.PROP_STORE_PROTOCOL, nodeRef.getStoreRef().getProtocol()); - properties.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier()); - properties.put(ContentModel.PROP_NODE_UUID, nodeRef.getId()); - } - - Long dbid = (Long)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_DBID); - properties.put(ContentModel.PROP_NODE_DBID, dbid); - - // Convert frozen cm:auditable properties - String creator = (String)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_CREATOR); - if (creator != null) - { - properties.put(ContentModel.PROP_CREATOR, creator); - } - - Date created = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_CREATED); - if (created != null) - { - properties.put(ContentModel.PROP_CREATED, created); - } - - // TODO - check use-cases for get version, revert, restore .... - String modifier = (String)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_MODIFIER); - if (modifier != null) - { - properties.put(ContentModel.PROP_MODIFIER, modifier); - } - - Date modified = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_MODIFIED); - if (modified != null) - { - properties.put(ContentModel.PROP_MODIFIED, modified); - } - - Date accessed = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_ACCESSED); - if (accessed != null) - { - properties.put(ContentModel.PROP_ACCESSED, accessed); - } - - String owner = (String)versionProperties.get(PROP_FROZEN_OWNER); - if (owner != null) - { - properties.put(ContentModel.PROP_OWNER, owner); - } - } - } - - /** - * @see org.alfresco.repo.version.Node2ServiceImpl#getAspects(org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException - { - // TODO only supported for Version2 - - NodeRef converted = VersionUtil.convertNodeRef(nodeRef); - if (dbNodeService.hasAspect(converted, ASPECT_RECORDED_VERSION)) - { - NodeRef record = (NodeRef)dbNodeService.getProperty(converted, PROP_RECORD_NODE_REF); - if (record != null && dbNodeService.exists(record)) - { - Set aspects = dbNodeService.getAspects(record); - return processAspects(aspects); - } - else - { - return (Set)Collections.EMPTY_SET; - } - } - else - { - return super.getAspects(nodeRef); - } - } - - /** - * Process frozen aspects. - * - * @param aspects aspect set - * @return {@link Set}<{@link QName}> processed aspect set - */ - protected Set processAspects(Set aspects) - { - Set result = new HashSet(aspects); - - // remove version aspects - result.remove(ASPECT_VERSION); - result.remove(ASPECT_RECORDED_VERSION); - - // remove rm aspects - for (QName aspect : aspects) - { - if (!ASPECT_VERSIONABLE.equals(aspect) && - (recordService.isRecordMetadataAspect(aspect) || - RECORD_MODEL_URIS.contains(aspect.getNamespaceURI()))) - { - result.remove(aspect); - } - } - - // remove custom record meta-data aspects - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +import static org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl.RECORD_MODEL_URIS; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.version.Node2ServiceImpl; +import org.alfresco.repo.version.Version2Model; +import org.alfresco.repo.version.common.VersionUtil; +import org.alfresco.service.cmr.repository.InvalidNodeRefException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Extended version node service implementation that supports the retrieval of + * recorded version state. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordableVersionNodeServiceImpl extends Node2ServiceImpl + implements RecordableVersionModel +{ + /** record service */ + private RecordService recordService; + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @see org.alfresco.repo.version.Node2ServiceImpl#getProperties(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + public Map getProperties(NodeRef nodeRef) throws InvalidNodeRefException + { + // TODO only supported for Version2 + + NodeRef converted = VersionUtil.convertNodeRef(nodeRef); + if (dbNodeService.hasAspect(converted, ASPECT_RECORDED_VERSION)) + { + NodeRef record = (NodeRef)dbNodeService.getProperty(converted, PROP_RECORD_NODE_REF); + if (record != null && dbNodeService.exists(record)) + { + Map properties = dbNodeService.getProperties(record); + return processProperties(converted, properties); + } + else + { + return (Map)Collections.EMPTY_MAP; + } + } + else + { + return super.getProperties(nodeRef); + } + } + + /** + * Process properties map before returning as frozen state. + * + * @param properties properties map + * @return {@link Map}<{@link QName}, {@link Serializable}> processed property map + */ + protected Map processProperties(NodeRef version, Map properties) + { + Map cloneProperties = new HashMap(properties); + + // revert modified record name + properties.put(ContentModel.PROP_NAME, properties.get(RecordsManagementModel.PROP_ORIGIONAL_NAME)); + + // remove all rma, rmc, rmr and rmv properties + for (QName property : cloneProperties.keySet()) + { + if (!PROP_RECORDABLE_VERSION_POLICY.equals(property) && + !PROP_FILE_PLAN.equals(property) && + (recordService.isRecordMetadataProperty(property) || + RECORD_MODEL_URIS.contains(property.getNamespaceURI()))) + { + properties.remove(property); + } + } + + // do standard property processing + processVersionProperties(version, properties); + + return properties; + } + + /** + * Process version properties. + * + * @param version version node reference + * @param properties properties map + */ + protected void processVersionProperties(NodeRef version, Map properties) throws InvalidNodeRefException + { + // get version properties + Map versionProperties = dbNodeService.getProperties(version); + + if (versionProperties != null) + { + String versionLabel = (String)versionProperties.get(Version2Model.PROP_QNAME_VERSION_LABEL); + properties.put(ContentModel.PROP_VERSION_LABEL, versionLabel); + + // Convert frozen sys:referenceable properties + NodeRef nodeRef = (NodeRef)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF); + if (nodeRef != null) + { + properties.put(ContentModel.PROP_STORE_PROTOCOL, nodeRef.getStoreRef().getProtocol()); + properties.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier()); + properties.put(ContentModel.PROP_NODE_UUID, nodeRef.getId()); + } + + Long dbid = (Long)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_DBID); + properties.put(ContentModel.PROP_NODE_DBID, dbid); + + // Convert frozen cm:auditable properties + String creator = (String)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_CREATOR); + if (creator != null) + { + properties.put(ContentModel.PROP_CREATOR, creator); + } + + Date created = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_CREATED); + if (created != null) + { + properties.put(ContentModel.PROP_CREATED, created); + } + + // TODO - check use-cases for get version, revert, restore .... + String modifier = (String)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_MODIFIER); + if (modifier != null) + { + properties.put(ContentModel.PROP_MODIFIER, modifier); + } + + Date modified = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_MODIFIED); + if (modified != null) + { + properties.put(ContentModel.PROP_MODIFIED, modified); + } + + Date accessed = (Date)versionProperties.get(Version2Model.PROP_QNAME_FROZEN_ACCESSED); + if (accessed != null) + { + properties.put(ContentModel.PROP_ACCESSED, accessed); + } + + String owner = (String)versionProperties.get(PROP_FROZEN_OWNER); + if (owner != null) + { + properties.put(ContentModel.PROP_OWNER, owner); + } + } + } + + /** + * @see org.alfresco.repo.version.Node2ServiceImpl#getAspects(org.alfresco.service.cmr.repository.NodeRef) + */ + @SuppressWarnings("unchecked") + @Override + public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException + { + // TODO only supported for Version2 + + NodeRef converted = VersionUtil.convertNodeRef(nodeRef); + if (dbNodeService.hasAspect(converted, ASPECT_RECORDED_VERSION)) + { + NodeRef record = (NodeRef)dbNodeService.getProperty(converted, PROP_RECORD_NODE_REF); + if (record != null && dbNodeService.exists(record)) + { + Set aspects = dbNodeService.getAspects(record); + return processAspects(aspects); + } + else + { + return (Set)Collections.EMPTY_SET; + } + } + else + { + return super.getAspects(nodeRef); + } + } + + /** + * Process frozen aspects. + * + * @param aspects aspect set + * @return {@link Set}<{@link QName}> processed aspect set + */ + protected Set processAspects(Set aspects) + { + Set result = new HashSet(aspects); + + // remove version aspects + result.remove(ASPECT_VERSION); + result.remove(ASPECT_RECORDED_VERSION); + + // remove rm aspects + for (QName aspect : aspects) + { + if (!ASPECT_VERSIONABLE.equals(aspect) && + (recordService.isRecordMetadataAspect(aspect) || + RECORD_MODEL_URIS.contains(aspect.getNamespaceURI()))) + { + result.remove(aspect); + } + } + + // remove custom record meta-data aspects + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionPolicy.java index ec730d4909..83fccaa4f5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionPolicy.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionPolicy.java @@ -1,30 +1,30 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -/** - * @author Roy Wetherall - * @since 2.3 - */ -public enum RecordableVersionPolicy -{ - NONE, - MAJOR_ONLY, - ALL -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +/** + * @author Roy Wetherall + * @since 2.3 + */ +public enum RecordableVersionPolicy +{ + NONE, + MAJOR_ONLY, + ALL +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java index 15f3757333..2f66e9d775 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java @@ -1,96 +1,96 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; - -/** - * Recordable version service interface. - * - * @author Roy Wetherall - * @since 2.3 - */ -public interface RecordableVersionService -{ - /** - * Indicates whether the current version of a node is recorded or not. - *

- * Returns false if not versionable or no version. - * - * @param nodeRef node reference - * @return boolean true if latest version recorded, false otherwise - */ - boolean isCurrentVersionRecorded(NodeRef nodeRef); - - /** - * Indicates whether a version is recorded or not. - * - * @param version version - * @return boolean true if recorded version, false otherwise - */ - boolean isRecordedVersion(Version version); - - /** - * If the version is a recorded version, gets the related version - * record. - * - * @param version version - * @return NodeRef node reference of version record - */ - NodeRef getVersionRecord(Version version); - - /** - * Gets the version that relates to the version record - * - * @param versionRecord version record node reference - * @return Version version or null if not found - */ - Version getRecordedVersion(NodeRef record); - - /** - * Creates a record from the latest version, marking it as recorded. - *

- * Does not create a record if the node is not versionable or the latest - * version is already recorded. - * - * @param nodeRef node reference - * @return NodeRef node reference to the created record. - */ - NodeRef createRecordFromLatestVersion(NodeRef filePlan, NodeRef nodeRef); - - /** - * Indicates whether a record version is destroyed or not. - * - * @param version version - * @return boolean true if destroyed, false otherwise - */ - boolean isRecordedVersionDestroyed(Version version); - - /** - * Marks a recorded version as destroyed. - *

- * Note this method does not destroy the associated record, instead it marks the - * version as destroyed. - * - * @param version version - */ - void destroyRecordedVersion(Version version); - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; + +/** + * Recordable version service interface. + * + * @author Roy Wetherall + * @since 2.3 + */ +public interface RecordableVersionService +{ + /** + * Indicates whether the current version of a node is recorded or not. + *

+ * Returns false if not versionable or no version. + * + * @param nodeRef node reference + * @return boolean true if latest version recorded, false otherwise + */ + boolean isCurrentVersionRecorded(NodeRef nodeRef); + + /** + * Indicates whether a version is recorded or not. + * + * @param version version + * @return boolean true if recorded version, false otherwise + */ + boolean isRecordedVersion(Version version); + + /** + * If the version is a recorded version, gets the related version + * record. + * + * @param version version + * @return NodeRef node reference of version record + */ + NodeRef getVersionRecord(Version version); + + /** + * Gets the version that relates to the version record + * + * @param versionRecord version record node reference + * @return Version version or null if not found + */ + Version getRecordedVersion(NodeRef record); + + /** + * Creates a record from the latest version, marking it as recorded. + *

+ * Does not create a record if the node is not versionable or the latest + * version is already recorded. + * + * @param nodeRef node reference + * @return NodeRef node reference to the created record. + */ + NodeRef createRecordFromLatestVersion(NodeRef filePlan, NodeRef nodeRef); + + /** + * Indicates whether a record version is destroyed or not. + * + * @param version version + * @return boolean true if destroyed, false otherwise + */ + boolean isRecordedVersionDestroyed(Version version); + + /** + * Marks a recorded version as destroyed. + *

+ * Note this method does not destroy the associated record, instead it marks the + * version as destroyed. + * + * @param version version + */ + void destroyRecordedVersion(Version version); + +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java index d3ae6b9ecf..e63d5b696b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java @@ -1,872 +1,872 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel.CUSTOM_REF_VERSIONS; -import static org.codehaus.plexus.util.StringUtils.isNotBlank; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.CmObjectType; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.policy.PolicyScope; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; -import org.alfresco.repo.version.Version2Model; -import org.alfresco.repo.version.Version2ServiceImpl; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.version.ReservedVersionNameException; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.PropertyMap; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Recordable version service implementation - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordableVersionServiceImpl extends Version2ServiceImpl - implements RecordableVersionModel, - RecordableVersionService -{ - /** share logger with version2ServiceImpl */ - private static Log logger = LogFactory.getLog(Version2ServiceImpl.class); - - /** key used to indicate a recordable version */ - public static final String KEY_RECORDABLE_VERSION = "recordable-version"; - public static final String KEY_FILE_PLAN = "file-plan"; - - /** version record property */ - protected static final String PROP_VERSION_RECORD = "RecordVersion"; - protected static final String PROP_RECORDED_VERSION_DESTROYED = "RecordedVersionDestroyed"; - - /** version aspect property names */ - private static final String[] VERSION_PROPERTY_NAMES = new String[] - { - Version2Model.PROP_CREATED_DATE, - Version2Model.PROP_VERSION_LABEL, - Version2Model.PROP_VERSION_DESCRIPTION, - - Version2Model.PROP_FROZEN_NODE_DBID, - Version2Model.PROP_FROZEN_NODE_REF, - - Version2Model.PROP_FROZEN_CREATED, - Version2Model.PROP_FROZEN_CREATOR, - Version2Model.PROP_FROZEN_MODIFIED, - Version2Model.PROP_FROZEN_MODIFIER, - Version2Model.PROP_FROZEN_ACCESSED - }; - - /** file plan service */ - private FilePlanService filePlanService; - - /** authentication util helper */ - private AuthenticationUtil authenticationUtil; - - /** relationship service */ - private RelationshipService relationshipService; - - /** record service */ - private RecordService recordService; - - /** model security service */ - private ModelSecurityService modelSecurityService; - - /** cm object type */ - private CmObjectType cmObjectType; - - /** extended permission service */ - private ExtendedPermissionService extendedPermissionService; - - /** extended security service */ - private ExtendedSecurityService extendedSecurityService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param authenticationUtil authentication util helper - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * @param relationshipService relationship service - */ - public void setRelationshipService(RelationshipService relationshipService) - { - this.relationshipService = relationshipService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param modelSecurityService model security service - */ - public void setModelSecurityService(ModelSecurityService modelSecurityService) - { - this.modelSecurityService = modelSecurityService; - } - - /** - * @param cmObjectType the cmObjectType to set - */ - public void setCmObjectType(CmObjectType cmObjectType) - { - this.cmObjectType = cmObjectType; - } - - /** - * @param extendedPermissionService extended permission service - */ - public void setExtendedPermissionService(ExtendedPermissionService extendedPermissionService) - { - this.extendedPermissionService = extendedPermissionService; - } - - /** - * @param extendedSecurityService extended security service - */ - public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) - { - this.extendedSecurityService = extendedSecurityService; - } - - /** - * @see org.alfresco.repo.version.Version2ServiceImpl#createVersion(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, int) - */ - @Override - protected Version createVersion(NodeRef nodeRef, Map origVersionProperties, int versionNumber) throws ReservedVersionNameException - { - // TODO we only support recorded versions for sub types of cm:content - - // create version properties if null - if (origVersionProperties == null) - { - origVersionProperties = new HashMap(2); - } - - // only need to check the recordable version policy when the recordable version indicator is missing from the version properties - if (!origVersionProperties.containsKey(KEY_RECORDABLE_VERSION)) - { - // get the version type - VersionType versionType = null; - if (origVersionProperties != null) - { - versionType = (VersionType)origVersionProperties.get(VersionModel.PROP_VERSION_TYPE); - } - - // determine whether this is a recorded version or not - if (isCreateRecordedVersion(nodeRef, versionType)) - { - origVersionProperties.put(KEY_RECORDABLE_VERSION, true); - if (!origVersionProperties.containsKey(KEY_FILE_PLAN)) - { - // make sure the file plan is set to the default if not specified - origVersionProperties.put(KEY_FILE_PLAN, getFilePlan(nodeRef)); - } - } - } - else - { - if (!origVersionProperties.containsKey(KEY_FILE_PLAN)) - { - // make sure the file plan is set to the default if not specified - origVersionProperties.put(KEY_FILE_PLAN, getFilePlan(nodeRef)); - } - } - - return super.createVersion(nodeRef, origVersionProperties, versionNumber); - } - - /** - * @param nodeRef node reference - * @return {@link NodeRef} associated file plan, default if none - */ - private NodeRef getFilePlan(NodeRef nodeRef) - { - NodeRef filePlan = (NodeRef)nodeService.getProperty(nodeRef, PROP_FILE_PLAN); - if (filePlan == null) - { - filePlan = getFilePlan(); - } - return filePlan; - } - - /** - * @return {@link NodeRef} default file plan, exception if none - */ - private NodeRef getFilePlan() - { - return authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() throws Exception - { - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - throw new AlfrescoRuntimeException("Can't create a recorded version, because there is no file plan."); - } - return filePlan; - } - }); - } - - /** - * Determine whether this is a recorded version or not. - * - * @param nodeRef - * @return - */ - private boolean isCreateRecordedVersion(NodeRef nodeRef, VersionType versionType) - { - boolean result = false; - if (nodeService.hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE)) - { - String policyString = (String)nodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); - if (policyString != null) - { - RecordableVersionPolicy policy = RecordableVersionPolicy.valueOf(policyString.toUpperCase()); - if (RecordableVersionPolicy.ALL.equals(policy) || - (RecordableVersionPolicy.MAJOR_ONLY.equals(policy) && - VersionType.MAJOR.equals(versionType))) - { - result = true; - } - } - } - - return result; - } - - /** - * @see org.alfresco.repo.version.Version2ServiceImpl#createNewVersion(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map, int, org.alfresco.repo.policy.PolicyScope) - */ - @Override - protected NodeRef createNewVersion( QName sourceTypeRef, - NodeRef versionHistoryRef, - Map standardVersionProperties, - Map versionProperties, - int versionNumber, - PolicyScope nodeDetails) - { - NodeRef version = null; - - if (versionProperties.containsKey(KEY_RECORDABLE_VERSION) && - ((Boolean)versionProperties.get(KEY_RECORDABLE_VERSION)).booleanValue()) - { - // create a recorded version - version = createNewRecordedVersion(sourceTypeRef, versionHistoryRef, standardVersionProperties, versionProperties, versionNumber, nodeDetails); - } - else - { - // create a normal version - version = super.createNewVersion(sourceTypeRef, versionHistoryRef, standardVersionProperties, versionProperties, versionNumber, nodeDetails); - } - - return version; - } - - /** - * Creates a new recorded version - * - * @param sourceTypeRef source type name - * @param versionHistoryRef version history reference - * @param standardVersionProperties standard version properties - * @param versionProperties version properties - * @param versionNumber version number - * @param nodeDetails policy scope - * @return {@link NodeRef} record version - */ - protected NodeRef createNewRecordedVersion(QName sourceTypeRef, - NodeRef versionHistoryRef, - Map standardVersionProperties, - Map versionProperties, - int versionNumber, - PolicyScope nodeDetails) - { - NodeRef versionNodeRef = null; - - // Disable auto-version behaviour - policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE); - - // disable other behaviours that we don't want to trigger during this process - policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); - policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER); - - // disable model security check - modelSecurityService.disable(); - - // disable property editable check - recordService.disablePropertyEditableCheck(); - - try - { - // get the destination file plan - final NodeRef filePlan = (NodeRef)versionProperties.get(KEY_FILE_PLAN); - if (filePlan == null) - { - throw new AlfrescoRuntimeException("Can't create a new recorded version, because no file plan has been specified in the version properties."); - } - - // create a copy of the source node and place in the file plan - final NodeRef nodeRef = (NodeRef)standardVersionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF); - - cmObjectType.disableCopy(); - try - { - // create record - final NodeRef record = recordService.createRecordFromCopy(filePlan, nodeRef); - - // apply version record aspect to record - PropertyMap versionRecordProps = new PropertyMap(3); - versionRecordProps.put(PROP_VERSIONED_NODEREF, nodeRef); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, - standardVersionProperties.get( - QName.createQName(Version2Model.NAMESPACE_URI, - Version2Model.PROP_VERSION_LABEL))); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, - standardVersionProperties.get( - QName.createQName(Version2Model.NAMESPACE_URI, - Version2Model.PROP_VERSION_DESCRIPTION))); - nodeService.addAspect(record, ASPECT_VERSION_RECORD, versionRecordProps); - - // wire record up to previous record - linkToPreviousVersionRecord(nodeRef, record); - - // create version nodeRef - ChildAssociationRef childAssocRef = dbNodeService.createNode( - versionHistoryRef, - Version2Model.CHILD_QNAME_VERSIONS, - QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS + "-" + versionNumber), - sourceTypeRef, - null); - versionNodeRef = childAssocRef.getChildRef(); - - // add aspect with the standard version properties to the 'version' node - nodeService.addAspect(versionNodeRef, Version2Model.ASPECT_VERSION, standardVersionProperties); - - // add the recordedVersion aspect with link to record - nodeService.addAspect(versionNodeRef, ASPECT_RECORDED_VERSION, Collections.singletonMap(PROP_RECORD_NODE_REF, (Serializable)record)); - - // freeze auditable aspect information - freezeAuditableAspect(nodeRef, versionNodeRef); - } - finally - { - cmObjectType.enableCopy(); - } - } - finally - { - // enable model security check - modelSecurityService.enable(); - - // enable property editable check - recordService.enablePropertyEditableCheck(); - - // Enable behaviours - this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE); - this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); - this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER); - } - - // If the auditable aspect is not there then add it to the 'version' node (after original aspects have been frozen) - if (!dbNodeService.hasAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE)) - { - dbNodeService.addAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE, null); - } - - if (logger.isTraceEnabled()) - { - logger.trace("createNewRecordedVersion created (" + versionNumber + ") " + versionNodeRef); - } - - return versionNodeRef; - } - - /** - * Helper method to link the record to the previous version record - * - * @param nodeRef noderef source node reference - * @param record record record node reference - */ - private void linkToPreviousVersionRecord(final NodeRef nodeRef, final NodeRef record) - { - final NodeRef latestRecordVersion = getLatestVersionRecord(nodeRef); - if (latestRecordVersion != null) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - // indicate that the new record versions the previous record - relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), record, latestRecordVersion); - return null; - } - }); - } - } - - /** - * Helper to get the latest version record for a given document (ie non-record) - * - * @param nodeRef node reference - * @return NodeRef latest version record, null otherwise - */ - private NodeRef getLatestVersionRecord(NodeRef nodeRef) - { - NodeRef versionRecord = null; - - // wire record up to previous record - VersionHistory versionHistory = getVersionHistory(nodeRef); - if (versionHistory != null) - { - Collection previousVersions = versionHistory.getAllVersions(); - for (Version previousVersion : previousVersions) - { - // look for the associated record - final NodeRef previousRecord = (NodeRef)previousVersion.getVersionProperties().get(PROP_VERSION_RECORD); - if (previousRecord != null && - nodeService.exists(previousRecord)) - { - versionRecord = previousRecord; - break; - } - } - } - - return versionRecord; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#getRecordedVersion(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Version getRecordedVersion(NodeRef versionRecord) - { - Version version = null; - NodeRef versionedNodeRef = (NodeRef) nodeService.getProperty(versionRecord, RecordableVersionModel.PROP_VERSIONED_NODEREF); - if (versionedNodeRef != null) - { - String versionLabel = (String) nodeService.getProperty(versionRecord, RecordableVersionModel.PROP_VERSION_LABEL); - if (StringUtils.isNotBlank(versionLabel)) - { - VersionHistory versionHistory = getVersionHistory(versionedNodeRef); - if (versionHistory != null) - { - version = versionHistory.getVersion(versionLabel); - } - } - } - return version; - } - - /** - * Freezes audit aspect properties. - * - * @param nodeRef - * @param versionNodeRef - */ - private void freezeAuditableAspect(NodeRef nodeRef, NodeRef versionNodeRef) - { - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUDITABLE)) - { - Map properties = dbNodeService.getProperties(nodeRef); - dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_CREATOR, properties.get(ContentModel.PROP_CREATOR)); - dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_CREATED, properties.get(ContentModel.PROP_CREATED)); - dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIER, properties.get(ContentModel.PROP_MODIFIER)); - dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIED, properties.get(ContentModel.PROP_MODIFIED)); - dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_ACCESSED, properties.get(ContentModel.PROP_ACCESSED)); - if (properties.get(ContentModel.PROP_OWNER) != null) - { - dbNodeService.setProperty(versionNodeRef, PROP_FROZEN_OWNER, properties.get(ContentModel.PROP_OWNER)); - } - } - } - - /** - * @see org.alfresco.repo.version.Version2ServiceImpl#getVersion(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected Version getVersion(NodeRef versionRef) - { - Version version = super.getVersion(versionRef); - - // place the version record reference in the version properties - NodeRef record = (NodeRef)dbNodeService.getProperty(versionRef, PROP_RECORD_NODE_REF); - if (record != null) - { - version.getVersionProperties().put(PROP_VERSION_RECORD, record); - } - - // place information about the destruction of the version record in the properties - Boolean destroyed = (Boolean)dbNodeService.getProperty(versionRef, PROP_DESTROYED); - if (destroyed == null) { destroyed = Boolean.FALSE; } - version.getVersionProperties().put(PROP_RECORDED_VERSION_DESTROYED, destroyed); - - return version; - } - - /** - * @see org.alfresco.repo.version.Version2ServiceImpl#revert(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version, boolean) - */ - @Override - public void revert(NodeRef nodeRef, Version version, boolean deep) - { - String versionPolicy = (String) dbNodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); - - super.revert(nodeRef, version, deep); - - if (isNotBlank(versionPolicy)) - { - dbNodeService.setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, versionPolicy); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isLatestVersionRecorded(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isCurrentVersionRecorded(NodeRef nodeRef) - { - boolean result = false; - Version version = getCurrentVersion(nodeRef); - if (version != null) - { - result = isRecordedVersion(version); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isRecordedVersion(org.alfresco.service.cmr.version.Version) - */ - @Override - public boolean isRecordedVersion(Version version) - { - NodeRef versionNodeRef = getVersionNodeRef(version); - return dbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#getVersionRecord(org.alfresco.service.cmr.version.Version) - */ - @Override - public NodeRef getVersionRecord(Version version) - { - NodeRef result = null; - NodeRef versionNodeRef = getVersionNodeRef(version); - if (dbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) - { - // get the version record - result = (NodeRef)dbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF); - - // check that the version record exists - if (result != null && - !dbNodeService.exists(result)) - { - throw new AlfrescoRuntimeException("Version record node doesn't exist. Indicates version has not been updated " - + "when associated version record was deleted. " - + "(nodeRef=" + result.toString() + ")"); - } - } - return result; - } - - /** - * Create Version Store Ref - * - * @param store ref - * @return store ref for version store - */ - public StoreRef convertStoreRef(StoreRef storeRef) - { - return new StoreRef(StoreRef.PROTOCOL_WORKSPACE, storeRef.getIdentifier()); - } - - /** - * Convert the incomming node ref (with the version store protocol specified) - * to the internal representation with the workspace protocol. - * - * @param nodeRef the incomming verison protocol node reference - * @return the internal version node reference - */ - public NodeRef convertNodeRef(NodeRef nodeRef) - { - return new NodeRef(convertStoreRef(nodeRef.getStoreRef()), nodeRef.getId()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#createRecordFromLatestVersion(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public NodeRef createRecordFromLatestVersion(final NodeRef filePlan, final NodeRef nodeRef) - { - ParameterCheck.mandatory("filePlan", filePlan); - ParameterCheck.mandatory("nodeRef", nodeRef); - - NodeRef record = null; - - // check for versionable aspect - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - { - // get the latest version - final Version currentVersion = getCurrentVersion(nodeRef); - - if (currentVersion != null && - !isRecordedVersion(currentVersion)) - { - // create the record from the current frozen state - record = authenticationUtil.runAsSystem(new RunAsWork() - { - public NodeRef doWork() throws Exception - { - // get the documents readers and writers - Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); - - // grab the frozen state - NodeRef currentFrozenState = currentVersion.getFrozenStateNodeRef(); - - // determine the type of the object - QName type = nodeService.getType(currentFrozenState); - - // grab all the properties - Map properties = nodeService.getProperties(currentFrozenState); - - // grab all the aspects - Set aspects = nodeService.getAspects(currentFrozenState); - - // create the record - NodeRef record = recordService.createRecordFromContent( - filePlan, - (String)properties.get(ContentModel.PROP_NAME), - type, - properties, - null); - - // apply aspects to record - for (QName aspect : aspects) - { - // add the aspect, properties have already been set - nodeService.addAspect(record, aspect, null); - } - - // apply version record aspect to record - PropertyMap versionRecordProps = new PropertyMap(3); - versionRecordProps.put(PROP_VERSIONED_NODEREF, nodeRef); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, currentVersion.getVersionLabel()); - versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, currentVersion.getDescription()); - nodeService.addAspect(record, ASPECT_VERSION_RECORD, versionRecordProps); - - // wire record up to previous record - linkToPreviousVersionRecord(nodeRef, record); - - // set the extended security - extendedSecurityService.set(record, readersAndWriters); - - return record; - } - }); - - // get the version history - NodeRef versionHistoryRef = getVersionHistoryNodeRef(nodeRef); - - // get details from the version before we remove it - int versionNumber = getVersionNumber(currentVersion); - Map versionProperties = getVersionAspectProperties(currentVersion); - QName sourceTypeRef = getVersionType(currentVersion); - - // patch-up owner information, which needs to be frozen for recorded versions - String owner = (String)nodeService.getProperty(currentVersion.getFrozenStateNodeRef(), ContentModel.PROP_OWNER); - if (owner != null) - { - versionProperties.put(PROP_FROZEN_OWNER, owner); - } - - // delete the current version - this.dbNodeService.deleteNode(convertNodeRef(currentVersion.getFrozenStateNodeRef())); - - // create a new version history if we need to - if (!nodeService.exists(versionHistoryRef)) - { - versionHistoryRef = createVersionHistory(nodeRef); - } - - // create recorded version nodeRef - ChildAssociationRef childAssocRef = dbNodeService.createNode( - versionHistoryRef, - Version2Model.CHILD_QNAME_VERSIONS, - QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS + "-" + versionNumber), - sourceTypeRef, - null); - NodeRef versionNodeRef = childAssocRef.getChildRef(); - - // add aspect with the standard version properties to the 'version' node - nodeService.addAspect(versionNodeRef, Version2Model.ASPECT_VERSION, versionProperties); - - // add the recordedVersion aspect with link to record - nodeService.addAspect(versionNodeRef, ASPECT_RECORDED_VERSION, Collections.singletonMap(PROP_RECORD_NODE_REF, (Serializable)record)); - } - } - - return record; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isRecordedVersionDestroyed(org.alfresco.service.cmr.version.Version) - */ - @Override - public boolean isRecordedVersionDestroyed(Version version) - { - boolean result = false; - - // get the version node reference - NodeRef versionNodeRef = getVersionNodeRef(version); - - // get the destroyed property value - Boolean isDestroyed = (Boolean)dbNodeService.getProperty(versionNodeRef, PROP_DESTROYED); - if (isDestroyed != null) - { - result = isDestroyed.booleanValue(); - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#destroyRecordedVersion(org.alfresco.service.cmr.version.Version) - */ - @Override - public void destroyRecordedVersion(Version version) - { - // get the version node reference - NodeRef versionNodeRef = getVersionNodeRef(version); - - // if it's a recorded version - if (dbNodeService.hasAspect(versionNodeRef, ASPECT_RECORDED_VERSION)) - { - // mark it as destroyed - dbNodeService.setProperty(versionNodeRef, PROP_DESTROYED, true); - - // clear the record node reference property - dbNodeService.setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); - } - } - - /** - * Helper method to get the version number of a given version by inspecting the - * name of the parent association. - * - * @param version version - * @return int version number - */ - private int getVersionNumber(Version version) - { - NodeRef versionNodeRef = getVersionNodeRef(version); - ChildAssociationRef assoc = dbNodeService.getPrimaryParent(versionNodeRef); - String fullVersionNumber = assoc.getQName().getLocalName(); - String versionNumber = fullVersionNumber.substring(fullVersionNumber.indexOf("-") + 1); - return Integer.parseInt(versionNumber); - } - - /** - * Helper method to get all the version aspect properties from an existing version - * - * @param version version - * @return Map property values - */ - private Map getVersionAspectProperties(Version version) - { - NodeRef versionNodeRef = getVersionNodeRef(version); - Map versionProps = dbNodeService.getProperties(versionNodeRef); - Map result = new HashMap(9); - for (String propertyName : VERSION_PROPERTY_NAMES) - { - QName propertyQName = QName.createQName(Version2Model.NAMESPACE_URI, propertyName); - result.put(propertyQName, versionProps.get(propertyQName)); - - if (propertyName.equals(Version2Model.PROP_FROZEN_NODE_DBID)) - { - System.out.println(versionProps.get(propertyQName)); - } - } - return result; - } - - /** - * Helper method to get the type of a versions frozen state - * - * @param currentVersion - * @return - */ - private QName getVersionType(Version version) - { - return nodeService.getType(getVersionNodeRef(version)); - } - - /** - * Helper method to get the internal node reference of a version - * - * @param version version - * @return NodeRef internal node reference to version - */ - private NodeRef getVersionNodeRef(Version version) - { - return convertNodeRef(version.getFrozenStateNodeRef()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel.CUSTOM_REF_VERSIONS; +import static org.codehaus.plexus.util.StringUtils.isNotBlank; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.CmObjectType; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.repo.policy.PolicyScope; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; +import org.alfresco.repo.version.Version2Model; +import org.alfresco.repo.version.Version2ServiceImpl; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.version.ReservedVersionNameException; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.cmr.version.VersionType; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.alfresco.util.ParameterCheck; +import org.alfresco.util.PropertyMap; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Recordable version service implementation + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordableVersionServiceImpl extends Version2ServiceImpl + implements RecordableVersionModel, + RecordableVersionService +{ + /** share logger with version2ServiceImpl */ + private static Log logger = LogFactory.getLog(Version2ServiceImpl.class); + + /** key used to indicate a recordable version */ + public static final String KEY_RECORDABLE_VERSION = "recordable-version"; + public static final String KEY_FILE_PLAN = "file-plan"; + + /** version record property */ + protected static final String PROP_VERSION_RECORD = "RecordVersion"; + protected static final String PROP_RECORDED_VERSION_DESTROYED = "RecordedVersionDestroyed"; + + /** version aspect property names */ + private static final String[] VERSION_PROPERTY_NAMES = new String[] + { + Version2Model.PROP_CREATED_DATE, + Version2Model.PROP_VERSION_LABEL, + Version2Model.PROP_VERSION_DESCRIPTION, + + Version2Model.PROP_FROZEN_NODE_DBID, + Version2Model.PROP_FROZEN_NODE_REF, + + Version2Model.PROP_FROZEN_CREATED, + Version2Model.PROP_FROZEN_CREATOR, + Version2Model.PROP_FROZEN_MODIFIED, + Version2Model.PROP_FROZEN_MODIFIER, + Version2Model.PROP_FROZEN_ACCESSED + }; + + /** file plan service */ + private FilePlanService filePlanService; + + /** authentication util helper */ + private AuthenticationUtil authenticationUtil; + + /** relationship service */ + private RelationshipService relationshipService; + + /** record service */ + private RecordService recordService; + + /** model security service */ + private ModelSecurityService modelSecurityService; + + /** cm object type */ + private CmObjectType cmObjectType; + + /** extended permission service */ + private ExtendedPermissionService extendedPermissionService; + + /** extended security service */ + private ExtendedSecurityService extendedSecurityService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param authenticationUtil authentication util helper + */ + public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + { + this.authenticationUtil = authenticationUtil; + } + + /** + * @param relationshipService relationship service + */ + public void setRelationshipService(RelationshipService relationshipService) + { + this.relationshipService = relationshipService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param modelSecurityService model security service + */ + public void setModelSecurityService(ModelSecurityService modelSecurityService) + { + this.modelSecurityService = modelSecurityService; + } + + /** + * @param cmObjectType the cmObjectType to set + */ + public void setCmObjectType(CmObjectType cmObjectType) + { + this.cmObjectType = cmObjectType; + } + + /** + * @param extendedPermissionService extended permission service + */ + public void setExtendedPermissionService(ExtendedPermissionService extendedPermissionService) + { + this.extendedPermissionService = extendedPermissionService; + } + + /** + * @param extendedSecurityService extended security service + */ + public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService) + { + this.extendedSecurityService = extendedSecurityService; + } + + /** + * @see org.alfresco.repo.version.Version2ServiceImpl#createVersion(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, int) + */ + @Override + protected Version createVersion(NodeRef nodeRef, Map origVersionProperties, int versionNumber) throws ReservedVersionNameException + { + // TODO we only support recorded versions for sub types of cm:content + + // create version properties if null + if (origVersionProperties == null) + { + origVersionProperties = new HashMap(2); + } + + // only need to check the recordable version policy when the recordable version indicator is missing from the version properties + if (!origVersionProperties.containsKey(KEY_RECORDABLE_VERSION)) + { + // get the version type + VersionType versionType = null; + if (origVersionProperties != null) + { + versionType = (VersionType)origVersionProperties.get(VersionModel.PROP_VERSION_TYPE); + } + + // determine whether this is a recorded version or not + if (isCreateRecordedVersion(nodeRef, versionType)) + { + origVersionProperties.put(KEY_RECORDABLE_VERSION, true); + if (!origVersionProperties.containsKey(KEY_FILE_PLAN)) + { + // make sure the file plan is set to the default if not specified + origVersionProperties.put(KEY_FILE_PLAN, getFilePlan(nodeRef)); + } + } + } + else + { + if (!origVersionProperties.containsKey(KEY_FILE_PLAN)) + { + // make sure the file plan is set to the default if not specified + origVersionProperties.put(KEY_FILE_PLAN, getFilePlan(nodeRef)); + } + } + + return super.createVersion(nodeRef, origVersionProperties, versionNumber); + } + + /** + * @param nodeRef node reference + * @return {@link NodeRef} associated file plan, default if none + */ + private NodeRef getFilePlan(NodeRef nodeRef) + { + NodeRef filePlan = (NodeRef)nodeService.getProperty(nodeRef, PROP_FILE_PLAN); + if (filePlan == null) + { + filePlan = getFilePlan(); + } + return filePlan; + } + + /** + * @return {@link NodeRef} default file plan, exception if none + */ + private NodeRef getFilePlan() + { + return authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public NodeRef doWork() throws Exception + { + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + throw new AlfrescoRuntimeException("Can't create a recorded version, because there is no file plan."); + } + return filePlan; + } + }); + } + + /** + * Determine whether this is a recorded version or not. + * + * @param nodeRef + * @return + */ + private boolean isCreateRecordedVersion(NodeRef nodeRef, VersionType versionType) + { + boolean result = false; + if (nodeService.hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE)) + { + String policyString = (String)nodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); + if (policyString != null) + { + RecordableVersionPolicy policy = RecordableVersionPolicy.valueOf(policyString.toUpperCase()); + if (RecordableVersionPolicy.ALL.equals(policy) || + (RecordableVersionPolicy.MAJOR_ONLY.equals(policy) && + VersionType.MAJOR.equals(versionType))) + { + result = true; + } + } + } + + return result; + } + + /** + * @see org.alfresco.repo.version.Version2ServiceImpl#createNewVersion(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map, int, org.alfresco.repo.policy.PolicyScope) + */ + @Override + protected NodeRef createNewVersion( QName sourceTypeRef, + NodeRef versionHistoryRef, + Map standardVersionProperties, + Map versionProperties, + int versionNumber, + PolicyScope nodeDetails) + { + NodeRef version = null; + + if (versionProperties.containsKey(KEY_RECORDABLE_VERSION) && + ((Boolean)versionProperties.get(KEY_RECORDABLE_VERSION)).booleanValue()) + { + // create a recorded version + version = createNewRecordedVersion(sourceTypeRef, versionHistoryRef, standardVersionProperties, versionProperties, versionNumber, nodeDetails); + } + else + { + // create a normal version + version = super.createNewVersion(sourceTypeRef, versionHistoryRef, standardVersionProperties, versionProperties, versionNumber, nodeDetails); + } + + return version; + } + + /** + * Creates a new recorded version + * + * @param sourceTypeRef source type name + * @param versionHistoryRef version history reference + * @param standardVersionProperties standard version properties + * @param versionProperties version properties + * @param versionNumber version number + * @param nodeDetails policy scope + * @return {@link NodeRef} record version + */ + protected NodeRef createNewRecordedVersion(QName sourceTypeRef, + NodeRef versionHistoryRef, + Map standardVersionProperties, + Map versionProperties, + int versionNumber, + PolicyScope nodeDetails) + { + NodeRef versionNodeRef = null; + + // Disable auto-version behaviour + policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE); + + // disable other behaviours that we don't want to trigger during this process + policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); + policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER); + + // disable model security check + modelSecurityService.disable(); + + // disable property editable check + recordService.disablePropertyEditableCheck(); + + try + { + // get the destination file plan + final NodeRef filePlan = (NodeRef)versionProperties.get(KEY_FILE_PLAN); + if (filePlan == null) + { + throw new AlfrescoRuntimeException("Can't create a new recorded version, because no file plan has been specified in the version properties."); + } + + // create a copy of the source node and place in the file plan + final NodeRef nodeRef = (NodeRef)standardVersionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF); + + cmObjectType.disableCopy(); + try + { + // create record + final NodeRef record = recordService.createRecordFromCopy(filePlan, nodeRef); + + // apply version record aspect to record + PropertyMap versionRecordProps = new PropertyMap(3); + versionRecordProps.put(PROP_VERSIONED_NODEREF, nodeRef); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, + standardVersionProperties.get( + QName.createQName(Version2Model.NAMESPACE_URI, + Version2Model.PROP_VERSION_LABEL))); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, + standardVersionProperties.get( + QName.createQName(Version2Model.NAMESPACE_URI, + Version2Model.PROP_VERSION_DESCRIPTION))); + nodeService.addAspect(record, ASPECT_VERSION_RECORD, versionRecordProps); + + // wire record up to previous record + linkToPreviousVersionRecord(nodeRef, record); + + // create version nodeRef + ChildAssociationRef childAssocRef = dbNodeService.createNode( + versionHistoryRef, + Version2Model.CHILD_QNAME_VERSIONS, + QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS + "-" + versionNumber), + sourceTypeRef, + null); + versionNodeRef = childAssocRef.getChildRef(); + + // add aspect with the standard version properties to the 'version' node + nodeService.addAspect(versionNodeRef, Version2Model.ASPECT_VERSION, standardVersionProperties); + + // add the recordedVersion aspect with link to record + nodeService.addAspect(versionNodeRef, ASPECT_RECORDED_VERSION, Collections.singletonMap(PROP_RECORD_NODE_REF, (Serializable)record)); + + // freeze auditable aspect information + freezeAuditableAspect(nodeRef, versionNodeRef); + } + finally + { + cmObjectType.enableCopy(); + } + } + finally + { + // enable model security check + modelSecurityService.enable(); + + // enable property editable check + recordService.enablePropertyEditableCheck(); + + // Enable behaviours + this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE); + this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); + this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER); + } + + // If the auditable aspect is not there then add it to the 'version' node (after original aspects have been frozen) + if (!dbNodeService.hasAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE)) + { + dbNodeService.addAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE, null); + } + + if (logger.isTraceEnabled()) + { + logger.trace("createNewRecordedVersion created (" + versionNumber + ") " + versionNodeRef); + } + + return versionNodeRef; + } + + /** + * Helper method to link the record to the previous version record + * + * @param nodeRef noderef source node reference + * @param record record record node reference + */ + private void linkToPreviousVersionRecord(final NodeRef nodeRef, final NodeRef record) + { + final NodeRef latestRecordVersion = getLatestVersionRecord(nodeRef); + if (latestRecordVersion != null) + { + authenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + // indicate that the new record versions the previous record + relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), record, latestRecordVersion); + return null; + } + }); + } + } + + /** + * Helper to get the latest version record for a given document (ie non-record) + * + * @param nodeRef node reference + * @return NodeRef latest version record, null otherwise + */ + private NodeRef getLatestVersionRecord(NodeRef nodeRef) + { + NodeRef versionRecord = null; + + // wire record up to previous record + VersionHistory versionHistory = getVersionHistory(nodeRef); + if (versionHistory != null) + { + Collection previousVersions = versionHistory.getAllVersions(); + for (Version previousVersion : previousVersions) + { + // look for the associated record + final NodeRef previousRecord = (NodeRef)previousVersion.getVersionProperties().get(PROP_VERSION_RECORD); + if (previousRecord != null && + nodeService.exists(previousRecord)) + { + versionRecord = previousRecord; + break; + } + } + } + + return versionRecord; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#getRecordedVersion(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Version getRecordedVersion(NodeRef versionRecord) + { + Version version = null; + NodeRef versionedNodeRef = (NodeRef) nodeService.getProperty(versionRecord, RecordableVersionModel.PROP_VERSIONED_NODEREF); + if (versionedNodeRef != null) + { + String versionLabel = (String) nodeService.getProperty(versionRecord, RecordableVersionModel.PROP_VERSION_LABEL); + if (StringUtils.isNotBlank(versionLabel)) + { + VersionHistory versionHistory = getVersionHistory(versionedNodeRef); + if (versionHistory != null) + { + version = versionHistory.getVersion(versionLabel); + } + } + } + return version; + } + + /** + * Freezes audit aspect properties. + * + * @param nodeRef + * @param versionNodeRef + */ + private void freezeAuditableAspect(NodeRef nodeRef, NodeRef versionNodeRef) + { + if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUDITABLE)) + { + Map properties = dbNodeService.getProperties(nodeRef); + dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_CREATOR, properties.get(ContentModel.PROP_CREATOR)); + dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_CREATED, properties.get(ContentModel.PROP_CREATED)); + dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIER, properties.get(ContentModel.PROP_MODIFIER)); + dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_MODIFIED, properties.get(ContentModel.PROP_MODIFIED)); + dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_FROZEN_ACCESSED, properties.get(ContentModel.PROP_ACCESSED)); + if (properties.get(ContentModel.PROP_OWNER) != null) + { + dbNodeService.setProperty(versionNodeRef, PROP_FROZEN_OWNER, properties.get(ContentModel.PROP_OWNER)); + } + } + } + + /** + * @see org.alfresco.repo.version.Version2ServiceImpl#getVersion(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected Version getVersion(NodeRef versionRef) + { + Version version = super.getVersion(versionRef); + + // place the version record reference in the version properties + NodeRef record = (NodeRef)dbNodeService.getProperty(versionRef, PROP_RECORD_NODE_REF); + if (record != null) + { + version.getVersionProperties().put(PROP_VERSION_RECORD, record); + } + + // place information about the destruction of the version record in the properties + Boolean destroyed = (Boolean)dbNodeService.getProperty(versionRef, PROP_DESTROYED); + if (destroyed == null) { destroyed = Boolean.FALSE; } + version.getVersionProperties().put(PROP_RECORDED_VERSION_DESTROYED, destroyed); + + return version; + } + + /** + * @see org.alfresco.repo.version.Version2ServiceImpl#revert(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version, boolean) + */ + @Override + public void revert(NodeRef nodeRef, Version version, boolean deep) + { + String versionPolicy = (String) dbNodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY); + + super.revert(nodeRef, version, deep); + + if (isNotBlank(versionPolicy)) + { + dbNodeService.setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, versionPolicy); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isLatestVersionRecorded(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isCurrentVersionRecorded(NodeRef nodeRef) + { + boolean result = false; + Version version = getCurrentVersion(nodeRef); + if (version != null) + { + result = isRecordedVersion(version); + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isRecordedVersion(org.alfresco.service.cmr.version.Version) + */ + @Override + public boolean isRecordedVersion(Version version) + { + NodeRef versionNodeRef = getVersionNodeRef(version); + return dbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#getVersionRecord(org.alfresco.service.cmr.version.Version) + */ + @Override + public NodeRef getVersionRecord(Version version) + { + NodeRef result = null; + NodeRef versionNodeRef = getVersionNodeRef(version); + if (dbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) + { + // get the version record + result = (NodeRef)dbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF); + + // check that the version record exists + if (result != null && + !dbNodeService.exists(result)) + { + throw new AlfrescoRuntimeException("Version record node doesn't exist. Indicates version has not been updated " + + "when associated version record was deleted. " + + "(nodeRef=" + result.toString() + ")"); + } + } + return result; + } + + /** + * Create Version Store Ref + * + * @param store ref + * @return store ref for version store + */ + public StoreRef convertStoreRef(StoreRef storeRef) + { + return new StoreRef(StoreRef.PROTOCOL_WORKSPACE, storeRef.getIdentifier()); + } + + /** + * Convert the incomming node ref (with the version store protocol specified) + * to the internal representation with the workspace protocol. + * + * @param nodeRef the incomming verison protocol node reference + * @return the internal version node reference + */ + public NodeRef convertNodeRef(NodeRef nodeRef) + { + return new NodeRef(convertStoreRef(nodeRef.getStoreRef()), nodeRef.getId()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#createRecordFromLatestVersion(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef createRecordFromLatestVersion(final NodeRef filePlan, final NodeRef nodeRef) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("nodeRef", nodeRef); + + NodeRef record = null; + + // check for versionable aspect + if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + { + // get the latest version + final Version currentVersion = getCurrentVersion(nodeRef); + + if (currentVersion != null && + !isRecordedVersion(currentVersion)) + { + // create the record from the current frozen state + record = authenticationUtil.runAsSystem(new RunAsWork() + { + public NodeRef doWork() throws Exception + { + // get the documents readers and writers + Pair, Set> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef); + + // grab the frozen state + NodeRef currentFrozenState = currentVersion.getFrozenStateNodeRef(); + + // determine the type of the object + QName type = nodeService.getType(currentFrozenState); + + // grab all the properties + Map properties = nodeService.getProperties(currentFrozenState); + + // grab all the aspects + Set aspects = nodeService.getAspects(currentFrozenState); + + // create the record + NodeRef record = recordService.createRecordFromContent( + filePlan, + (String)properties.get(ContentModel.PROP_NAME), + type, + properties, + null); + + // apply aspects to record + for (QName aspect : aspects) + { + // add the aspect, properties have already been set + nodeService.addAspect(record, aspect, null); + } + + // apply version record aspect to record + PropertyMap versionRecordProps = new PropertyMap(3); + versionRecordProps.put(PROP_VERSIONED_NODEREF, nodeRef); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, currentVersion.getVersionLabel()); + versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, currentVersion.getDescription()); + nodeService.addAspect(record, ASPECT_VERSION_RECORD, versionRecordProps); + + // wire record up to previous record + linkToPreviousVersionRecord(nodeRef, record); + + // set the extended security + extendedSecurityService.set(record, readersAndWriters); + + return record; + } + }); + + // get the version history + NodeRef versionHistoryRef = getVersionHistoryNodeRef(nodeRef); + + // get details from the version before we remove it + int versionNumber = getVersionNumber(currentVersion); + Map versionProperties = getVersionAspectProperties(currentVersion); + QName sourceTypeRef = getVersionType(currentVersion); + + // patch-up owner information, which needs to be frozen for recorded versions + String owner = (String)nodeService.getProperty(currentVersion.getFrozenStateNodeRef(), ContentModel.PROP_OWNER); + if (owner != null) + { + versionProperties.put(PROP_FROZEN_OWNER, owner); + } + + // delete the current version + this.dbNodeService.deleteNode(convertNodeRef(currentVersion.getFrozenStateNodeRef())); + + // create a new version history if we need to + if (!nodeService.exists(versionHistoryRef)) + { + versionHistoryRef = createVersionHistory(nodeRef); + } + + // create recorded version nodeRef + ChildAssociationRef childAssocRef = dbNodeService.createNode( + versionHistoryRef, + Version2Model.CHILD_QNAME_VERSIONS, + QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS + "-" + versionNumber), + sourceTypeRef, + null); + NodeRef versionNodeRef = childAssocRef.getChildRef(); + + // add aspect with the standard version properties to the 'version' node + nodeService.addAspect(versionNodeRef, Version2Model.ASPECT_VERSION, versionProperties); + + // add the recordedVersion aspect with link to record + nodeService.addAspect(versionNodeRef, ASPECT_RECORDED_VERSION, Collections.singletonMap(PROP_RECORD_NODE_REF, (Serializable)record)); + } + } + + return record; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isRecordedVersionDestroyed(org.alfresco.service.cmr.version.Version) + */ + @Override + public boolean isRecordedVersionDestroyed(Version version) + { + boolean result = false; + + // get the version node reference + NodeRef versionNodeRef = getVersionNodeRef(version); + + // get the destroyed property value + Boolean isDestroyed = (Boolean)dbNodeService.getProperty(versionNodeRef, PROP_DESTROYED); + if (isDestroyed != null) + { + result = isDestroyed.booleanValue(); + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#destroyRecordedVersion(org.alfresco.service.cmr.version.Version) + */ + @Override + public void destroyRecordedVersion(Version version) + { + // get the version node reference + NodeRef versionNodeRef = getVersionNodeRef(version); + + // if it's a recorded version + if (dbNodeService.hasAspect(versionNodeRef, ASPECT_RECORDED_VERSION)) + { + // mark it as destroyed + dbNodeService.setProperty(versionNodeRef, PROP_DESTROYED, true); + + // clear the record node reference property + dbNodeService.setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); + } + } + + /** + * Helper method to get the version number of a given version by inspecting the + * name of the parent association. + * + * @param version version + * @return int version number + */ + private int getVersionNumber(Version version) + { + NodeRef versionNodeRef = getVersionNodeRef(version); + ChildAssociationRef assoc = dbNodeService.getPrimaryParent(versionNodeRef); + String fullVersionNumber = assoc.getQName().getLocalName(); + String versionNumber = fullVersionNumber.substring(fullVersionNumber.indexOf("-") + 1); + return Integer.parseInt(versionNumber); + } + + /** + * Helper method to get all the version aspect properties from an existing version + * + * @param version version + * @return Map property values + */ + private Map getVersionAspectProperties(Version version) + { + NodeRef versionNodeRef = getVersionNodeRef(version); + Map versionProps = dbNodeService.getProperties(versionNodeRef); + Map result = new HashMap(9); + for (String propertyName : VERSION_PROPERTY_NAMES) + { + QName propertyQName = QName.createQName(Version2Model.NAMESPACE_URI, propertyName); + result.put(propertyQName, versionProps.get(propertyQName)); + + if (propertyName.equals(Version2Model.PROP_FROZEN_NODE_DBID)) + { + System.out.println(versionProps.get(propertyQName)); + } + } + return result; + } + + /** + * Helper method to get the type of a versions frozen state + * + * @param currentVersion + * @return + */ + private QName getVersionType(Version version) + { + return nodeService.getType(getVersionNodeRef(version)); + } + + /** + * Helper method to get the internal node reference of a version + * + * @param version version + * @return NodeRef internal node reference to version + */ + private NodeRef getVersionNodeRef(Version version) + { + return convertNodeRef(version.getFrozenStateNodeRef()); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/model/VersionableAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/model/VersionableAspect.java index b8d6a51e30..48bf42221c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/model/VersionableAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/version/model/VersionableAspect.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version.model; - -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.namespace.QName; - -/** - * rmv:versionsable aspect behaviour bean implementation - * - * @author Roy Wetherall - * @since 2.3 - */ -@BehaviourBean -( - defaultType="rmv:versionable" -) -public class VersionableAspect extends BaseBehaviourBean -{ - /** - * Copy callback. - * - * Cutoff aspect should not be copied. - */ - @Behaviour - ( - kind = BehaviourKind.CLASS, - policy = "alf:getCopyCallback" - ) - public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) - { - return new DoNothingCopyBehaviourCallback(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version.model; + +import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; +import org.alfresco.repo.copy.CopyBehaviourCallback; +import org.alfresco.repo.copy.CopyDetails; +import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.namespace.QName; + +/** + * rmv:versionsable aspect behaviour bean implementation + * + * @author Roy Wetherall + * @since 2.3 + */ +@BehaviourBean +( + defaultType="rmv:versionable" +) +public class VersionableAspect extends BaseBehaviourBean +{ + /** + * Copy callback. + * + * Cutoff aspect should not be copied. + */ + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:getCopyCallback" + ) + public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails) + { + return new DoNothingCopyBehaviourCallback(); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/BroadcastVitalRecordDefinitionAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/BroadcastVitalRecordDefinitionAction.java index b7957d7b71..e588bf591b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/BroadcastVitalRecordDefinitionAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/BroadcastVitalRecordDefinitionAction.java @@ -1,134 +1,134 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Action to implement the consequences of a change to the value of the VitalRecordDefinition properties. When the - * VitalRecordIndicator or the reviewPeriod properties are changed on a record container, then any descendant folders or - * records must be updated as a consequence. Descendant folders should have their reviewPeriods and/or - * vitalRecordIndicators updated to match the new value. Descendant records should have their reviewAsOf date updated. - * - * @author Neil McErlean - */ -public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstractBase -{ - protected FilePlanService filePlanService; - - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, final NodeRef actionedUponNodeRef) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - propagateChangeToChildrenOf(actionedUponNodeRef); - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - /** - * Propagates the changes to the children of the node specified. - * - * @param actionedUponNodeRef actioned upon node reference - */ - private void propagateChangeToChildrenOf(NodeRef actionedUponNodeRef) - { - Map parentProps = getNodeService().getProperties(actionedUponNodeRef); - - // parent vital record indicator, default to null if not set - boolean parentVri = false; - Boolean parentVriValue = (Boolean) parentProps.get(PROP_VITAL_RECORD_INDICATOR); - if (parentVriValue != null) - { - parentVri = parentVriValue.booleanValue(); - } - - Period parentReviewPeriod = (Period) parentProps.get(PROP_REVIEW_PERIOD); - - List assocs = this.getNodeService().getChildAssocs(actionedUponNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef nextAssoc : assocs) - { - NodeRef nextChild = nextAssoc.getChildRef(); - - if (filePlanService.isFilePlanComponent(nextChild) && - !getFreezeService().isFrozen(nextChild)) - { - // If the child is a record, then the VitalRecord aspect needs to be applied or updated - if (getRecordService().isRecord(nextChild)) - { - if (parentVri) - { - VitalRecordDefinition vrDefn = getVitalRecordService().getVitalRecordDefinition(nextChild); - Map aspectProps = new HashMap(); - aspectProps.put(PROP_REVIEW_AS_OF, vrDefn.getNextReviewDate()); - - getNodeService().addAspect(nextChild, RecordsManagementModel.ASPECT_VITAL_RECORD, aspectProps); - } - else - { - getNodeService().removeAspect(nextChild, RecordsManagementModel.ASPECT_VITAL_RECORD); - } - } - else - // copy the vitalRecordDefinition properties from the parent to the child - { - Map childProps = getNodeService().getProperties(nextChild); - childProps.put(PROP_REVIEW_PERIOD, parentReviewPeriod); - childProps.put(PROP_VITAL_RECORD_INDICATOR, parentVri); - getNodeService().setProperties(nextChild, childProps); - } - - // Recurse down the containment hierarchy to all containers - if (!getRecordService().isRecord(nextChild)) - { - this.propagateChangeToChildrenOf(nextChild); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; + +/** + * Action to implement the consequences of a change to the value of the VitalRecordDefinition properties. When the + * VitalRecordIndicator or the reviewPeriod properties are changed on a record container, then any descendant folders or + * records must be updated as a consequence. Descendant folders should have their reviewPeriods and/or + * vitalRecordIndicators updated to match the new value. Descendant records should have their reviewAsOf date updated. + * + * @author Neil McErlean + */ +public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstractBase +{ + protected FilePlanService filePlanService; + + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, final NodeRef actionedUponNodeRef) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + propagateChangeToChildrenOf(actionedUponNodeRef); + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + /** + * Propagates the changes to the children of the node specified. + * + * @param actionedUponNodeRef actioned upon node reference + */ + private void propagateChangeToChildrenOf(NodeRef actionedUponNodeRef) + { + Map parentProps = getNodeService().getProperties(actionedUponNodeRef); + + // parent vital record indicator, default to null if not set + boolean parentVri = false; + Boolean parentVriValue = (Boolean) parentProps.get(PROP_VITAL_RECORD_INDICATOR); + if (parentVriValue != null) + { + parentVri = parentVriValue.booleanValue(); + } + + Period parentReviewPeriod = (Period) parentProps.get(PROP_REVIEW_PERIOD); + + List assocs = this.getNodeService().getChildAssocs(actionedUponNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef nextAssoc : assocs) + { + NodeRef nextChild = nextAssoc.getChildRef(); + + if (filePlanService.isFilePlanComponent(nextChild) && + !getFreezeService().isFrozen(nextChild)) + { + // If the child is a record, then the VitalRecord aspect needs to be applied or updated + if (getRecordService().isRecord(nextChild)) + { + if (parentVri) + { + VitalRecordDefinition vrDefn = getVitalRecordService().getVitalRecordDefinition(nextChild); + Map aspectProps = new HashMap(); + aspectProps.put(PROP_REVIEW_AS_OF, vrDefn.getNextReviewDate()); + + getNodeService().addAspect(nextChild, RecordsManagementModel.ASPECT_VITAL_RECORD, aspectProps); + } + else + { + getNodeService().removeAspect(nextChild, RecordsManagementModel.ASPECT_VITAL_RECORD); + } + } + else + // copy the vitalRecordDefinition properties from the parent to the child + { + Map childProps = getNodeService().getProperties(nextChild); + childProps.put(PROP_REVIEW_PERIOD, parentReviewPeriod); + childProps.put(PROP_VITAL_RECORD_INDICATOR, parentVri); + getNodeService().setProperties(nextChild, childProps); + } + + // Recurse down the containment hierarchy to all containers + if (!getRecordService().isRecord(nextChild)) + { + this.propagateChangeToChildrenOf(nextChild); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java index 7f3b517f26..a65d9b57e9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java @@ -1,90 +1,90 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import java.util.Date; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Reviewed action. - * - * @author Neil McErlean - */ -public class ReviewedAction extends RMActionExecuterAbstractBase -{ - private static Log logger = LogFactory.getLog(ReviewedAction.class); - - /** - * - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, - * org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - VitalRecordDefinition vrDef = getVitalRecordService().getVitalRecordDefinition(actionedUponNodeRef); - if (vrDef != null && vrDef.isEnabled()) - { - if (getRecordService().isRecord(actionedUponNodeRef)) - { - reviewRecord(actionedUponNodeRef, vrDef); - } - else if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) - { - for (NodeRef record : getRecordService().getRecords(actionedUponNodeRef)) - { - reviewRecord(record, vrDef); - } - } - } - } - - /** - * Make record as reviewed. - * - * @param nodeRef - * @param vrDef - */ - private void reviewRecord(NodeRef nodeRef, VitalRecordDefinition vrDef) - { - // Calculate the next review date - Date reviewAsOf = vrDef.getNextReviewDate(); - if (reviewAsOf != null) - { - // Log - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Setting new reviewAsOf property [") - .append(reviewAsOf) - .append("] on ") - .append(nodeRef); - logger.debug(msg.toString()); - } - - this.getNodeService().setProperty(nodeRef, PROP_REVIEW_AS_OF, reviewAsOf); - //TODO And record previous review date, time, user - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import java.util.Date; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Reviewed action. + * + * @author Neil McErlean + */ +public class ReviewedAction extends RMActionExecuterAbstractBase +{ + private static Log logger = LogFactory.getLog(ReviewedAction.class); + + /** + * + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, + * org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + VitalRecordDefinition vrDef = getVitalRecordService().getVitalRecordDefinition(actionedUponNodeRef); + if (vrDef != null && vrDef.isEnabled()) + { + if (getRecordService().isRecord(actionedUponNodeRef)) + { + reviewRecord(actionedUponNodeRef, vrDef); + } + else if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) + { + for (NodeRef record : getRecordService().getRecords(actionedUponNodeRef)) + { + reviewRecord(record, vrDef); + } + } + } + } + + /** + * Make record as reviewed. + * + * @param nodeRef + * @param vrDef + */ + private void reviewRecord(NodeRef nodeRef, VitalRecordDefinition vrDef) + { + // Calculate the next review date + Date reviewAsOf = vrDef.getNextReviewDate(); + if (reviewAsOf != null) + { + // Log + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Setting new reviewAsOf property [") + .append(reviewAsOf) + .append("] on ") + .append(nodeRef); + logger.debug(msg.toString()); + } + + this.getNodeService().setProperty(nodeRef, PROP_REVIEW_AS_OF, reviewAsOf); + //TODO And record previous review date, time, user + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinition.java index 74625b12a1..5f298fa8fb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinition.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import java.util.Date; - -import org.alfresco.service.cmr.repository.Period; - -/** - * Vital record definition interface - * - * @author Roy Wetherall - */ -public interface VitalRecordDefinition -{ - /** - * Indicates whether the vital record definition is enabled or not. - *

- * Note: a result of false indicates that the vital record definition is inactive - * therefore does not impose the rules associated with vital record review on - * associated nodes. - * - * @return boolean true if enabled, false otherwise - */ - boolean isEnabled(); - - /** - * Review period for vital records - * - * @return Period review period - */ - Period getReviewPeriod(); - - /** - * Gets the next review date based on the review period - * - * @return Date date of the next review - */ - Date getNextReviewDate(); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import java.util.Date; + +import org.alfresco.service.cmr.repository.Period; + +/** + * Vital record definition interface + * + * @author Roy Wetherall + */ +public interface VitalRecordDefinition +{ + /** + * Indicates whether the vital record definition is enabled or not. + *

+ * Note: a result of false indicates that the vital record definition is inactive + * therefore does not impose the rules associated with vital record review on + * associated nodes. + * + * @return boolean true if enabled, false otherwise + */ + boolean isEnabled(); + + /** + * Review period for vital records + * + * @return Period review period + */ + Period getReviewPeriod(); + + /** + * Gets the next review date based on the review period + * + * @return Date date of the next review + */ + Date getNextReviewDate(); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinitionImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinitionImpl.java index 3e17685a64..234a750ca4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinitionImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordDefinitionImpl.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import java.util.Date; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; - -/** - * Vital record definition implementation class - * - * @author Roy Wetherall - */ -public class VitalRecordDefinitionImpl implements VitalRecordDefinition, RecordsManagementModel -{ - /** Indicates whether the vital record definition is enabled or not */ - private boolean enabled = false; - - /** Vital record review period */ - private Period reviewPeriod = new Period("none|0"); - - /** - * Constructor. - * - * @param enabled - * @param reviewPeriod - */ - /* package */ VitalRecordDefinitionImpl(boolean enabled, Period reviewPeriod) - { - this.enabled = enabled; - if (reviewPeriod != null) - { - this.reviewPeriod = reviewPeriod; - } - } - - /** - * Helper method to create vital record definition from node reference. - * - * @param nodeService - * @param nodeRef - * @return - */ - /* package */ static VitalRecordDefinition create(NodeService nodeService, NodeRef nodeRef) - { - Boolean enabled = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); - if (enabled == null) - { - enabled = Boolean.FALSE; - } - Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); - return new VitalRecordDefinitionImpl(enabled, reviewPeriod); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#isEnabled() - */ - @Override - public boolean isEnabled() - { - return enabled; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#getNextReviewDate() - */ - public Date getNextReviewDate() - { - return getReviewPeriod().getNextDate(new Date()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#getReviewPeriod() - */ - public Period getReviewPeriod() - { - return reviewPeriod; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import java.util.Date; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; + +/** + * Vital record definition implementation class + * + * @author Roy Wetherall + */ +public class VitalRecordDefinitionImpl implements VitalRecordDefinition, RecordsManagementModel +{ + /** Indicates whether the vital record definition is enabled or not */ + private boolean enabled = false; + + /** Vital record review period */ + private Period reviewPeriod = new Period("none|0"); + + /** + * Constructor. + * + * @param enabled + * @param reviewPeriod + */ + /* package */ VitalRecordDefinitionImpl(boolean enabled, Period reviewPeriod) + { + this.enabled = enabled; + if (reviewPeriod != null) + { + this.reviewPeriod = reviewPeriod; + } + } + + /** + * Helper method to create vital record definition from node reference. + * + * @param nodeService + * @param nodeRef + * @return + */ + /* package */ static VitalRecordDefinition create(NodeService nodeService, NodeRef nodeRef) + { + Boolean enabled = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); + if (enabled == null) + { + enabled = Boolean.FALSE; + } + Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); + return new VitalRecordDefinitionImpl(enabled, reviewPeriod); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#isEnabled() + */ + @Override + public boolean isEnabled() + { + return enabled; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#getNextReviewDate() + */ + public Date getNextReviewDate() + { + return getReviewPeriod().getNextDate(new Date()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition#getReviewPeriod() + */ + public Period getReviewPeriod() + { + return reviewPeriod; + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordService.java index 38446eeee0..54ef21398e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordService.java @@ -1,74 +1,74 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; - -/** - * Vital Record Service. - * - * @author Roy Wetherall - * @since 2.0 - */ -public interface VitalRecordService -{ - /** Period 'none' */ - Period PERIOD_NONE = new Period("none|0"); - - /** - * Setup the vital record definition for the given node. - * - * @param nodeRef node reference - */ - void setupVitalRecordDefinition(NodeRef nodeRef); - - /** - * Gets the vital record definition details for the node. - * - * @param nodeRef node reference - * @return VitalRecordDefinition vital record definition details - */ - VitalRecordDefinition getVitalRecordDefinition(NodeRef nodeRef); - - /** - * Sets the vital record definition values for a given node. - * - * @param nodeRef - * @param enabled - * @param reviewPeriod - * @return - */ - VitalRecordDefinition setVitalRecordDefintion(NodeRef nodeRef, boolean enabled, Period reviewPeriod); - - /** - * Indicates whether the record is a vital one or not. - * - * @param nodeRef node reference - * @return boolean true if this is a vital record, false otherwise - */ - boolean isVitalRecord(NodeRef nodeRef); - - /** - * Initialises the vital record details. - * - * @param nodeRef node reference to initialise with vital record details - */ - //void initialiseVitalRecord(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; + +/** + * Vital Record Service. + * + * @author Roy Wetherall + * @since 2.0 + */ +public interface VitalRecordService +{ + /** Period 'none' */ + Period PERIOD_NONE = new Period("none|0"); + + /** + * Setup the vital record definition for the given node. + * + * @param nodeRef node reference + */ + void setupVitalRecordDefinition(NodeRef nodeRef); + + /** + * Gets the vital record definition details for the node. + * + * @param nodeRef node reference + * @return VitalRecordDefinition vital record definition details + */ + VitalRecordDefinition getVitalRecordDefinition(NodeRef nodeRef); + + /** + * Sets the vital record definition values for a given node. + * + * @param nodeRef + * @param enabled + * @param reviewPeriod + * @return + */ + VitalRecordDefinition setVitalRecordDefintion(NodeRef nodeRef, boolean enabled, Period reviewPeriod); + + /** + * Indicates whether the record is a vital one or not. + * + * @param nodeRef node reference + * @return boolean true if this is a vital record, false otherwise + */ + boolean isVitalRecord(NodeRef nodeRef); + + /** + * Initialises the vital record details. + * + * @param nodeRef node reference to initialise with vital record details + */ + //void initialiseVitalRecord(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java index c55a6aff65..86b3fbdae3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java @@ -1,204 +1,204 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.vital; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; - -/** - * Vital record service interface implementation. - * - * @author Roy Wetherall - * @since 2.0 - */ -@BehaviourBean -public class VitalRecordServiceImpl extends ServiceBaseImpl - implements VitalRecordService, - RecordsManagementModel, - RecordsManagementPolicies.OnFileRecord -{ - /** file plan service */ - private FilePlanService filePlanService; - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Behavior to initialize vital record. - * - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord#onFileRecord(org.alfresco.service.cmr.repository.NodeRef) - * @since 2.2 - */ - @Override - @Behaviour(kind=BehaviourKind.CLASS, type="rma:record") - public void onFileRecord(NodeRef nodeRef) - { - // Calculate the review schedule - VitalRecordDefinition viDef = getVitalRecordDefinition(nodeRef); - if (viDef != null && viDef.isEnabled()) - { - Date reviewAsOf = viDef.getNextReviewDate(); - if (reviewAsOf != null) - { - Map reviewProps = new HashMap(1); - reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf); - - if (!nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) - { - nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps); - } - else - { - Map props = nodeService.getProperties(nodeRef); - props.putAll(reviewProps); - nodeService.setProperties(nodeRef, props); - } - } - } - else - { - // if we are re-filling then remove the vital aspect if it is not longer a vital record - if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) - { - nodeService.removeAspect(nodeRef, ASPECT_VITAL_RECORD); - } - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setupVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void setupVitalRecordDefinition(NodeRef nodeRef) - { - // get the current review period value - Period currentReviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); - if (currentReviewPeriod == null || - PERIOD_NONE.equals(currentReviewPeriod)) - { - // get the immediate parent - NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - - // is the parent a record category - if (parentRef != null && - FilePlanComponentKind.RECORD_CATEGORY.equals(filePlanService.getFilePlanComponentKind(parentRef))) - { - // is the child a record category or folder - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) || - kind.equals(FilePlanComponentKind.RECORD_FOLDER)) - { - // set the vital record definition values to match that of the parent - nodeService.setProperty(nodeRef, - PROP_VITAL_RECORD_INDICATOR, - nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR)); - nodeService.setProperty(nodeRef, - PROP_REVIEW_PERIOD, - nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD)); - } - } - } - } - - /** - * @see VitalRecordService#getVitalRecordDefinition(NodeRef) - */ - public VitalRecordDefinition getVitalRecordDefinition(NodeRef nodeRef) - { - VitalRecordDefinition result = null; - - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - if (FilePlanComponentKind.RECORD.equals(kind)) - { - result = resolveVitalRecordDefinition(nodeRef); - } - else - { - if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION)) - { - result = VitalRecordDefinitionImpl.create(nodeService, nodeRef); - } - } - - return result; - } - - /** - * Resolves the record vital definition. - *

- * NOTE: Currently we only support the resolution of the vital record definition from the - * primary record parent. ie the record folder the record was originally filed within. - *

- * TODO: Add an algorithm to resolve the correct vital record definition when a record is filed in many - * record folders. - * - * @param record - * @return VitalRecordDefinition - */ - private VitalRecordDefinition resolveVitalRecordDefinition(NodeRef record) - { - NodeRef parent = nodeService.getPrimaryParent(record).getParentRef(); - return getVitalRecordDefinition(parent); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setVitalRecordDefintion(org.alfresco.service.cmr.repository.NodeRef, boolean, org.alfresco.service.cmr.repository.Period) - */ - @Override - public VitalRecordDefinition setVitalRecordDefintion(NodeRef nodeRef, boolean enabled, Period reviewPeriod) - { - // Check params - ParameterCheck.mandatory("nodeRef", nodeRef); - ParameterCheck.mandatory("enabled", enabled); - - // Set the properties (will automatically add the vital record definition aspect) - nodeService.setProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR, enabled); - nodeService.setProperty(nodeRef, PROP_REVIEW_PERIOD, reviewPeriod); - - return new VitalRecordDefinitionImpl(enabled, reviewPeriod); - } - - /** - * @see VitalRecordService#isVitalRecord(NodeRef) - */ - public boolean isVitalRecord(NodeRef nodeRef) - { - return nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; + +/** + * Vital record service interface implementation. + * + * @author Roy Wetherall + * @since 2.0 + */ +@BehaviourBean +public class VitalRecordServiceImpl extends ServiceBaseImpl + implements VitalRecordService, + RecordsManagementModel, + RecordsManagementPolicies.OnFileRecord +{ + /** file plan service */ + private FilePlanService filePlanService; + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Behavior to initialize vital record. + * + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord#onFileRecord(org.alfresco.service.cmr.repository.NodeRef) + * @since 2.2 + */ + @Override + @Behaviour(kind=BehaviourKind.CLASS, type="rma:record") + public void onFileRecord(NodeRef nodeRef) + { + // Calculate the review schedule + VitalRecordDefinition viDef = getVitalRecordDefinition(nodeRef); + if (viDef != null && viDef.isEnabled()) + { + Date reviewAsOf = viDef.getNextReviewDate(); + if (reviewAsOf != null) + { + Map reviewProps = new HashMap(1); + reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf); + + if (!nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) + { + nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps); + } + else + { + Map props = nodeService.getProperties(nodeRef); + props.putAll(reviewProps); + nodeService.setProperties(nodeRef, props); + } + } + } + else + { + // if we are re-filling then remove the vital aspect if it is not longer a vital record + if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) + { + nodeService.removeAspect(nodeRef, ASPECT_VITAL_RECORD); + } + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setupVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void setupVitalRecordDefinition(NodeRef nodeRef) + { + // get the current review period value + Period currentReviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); + if (currentReviewPeriod == null || + PERIOD_NONE.equals(currentReviewPeriod)) + { + // get the immediate parent + NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); + + // is the parent a record category + if (parentRef != null && + FilePlanComponentKind.RECORD_CATEGORY.equals(filePlanService.getFilePlanComponentKind(parentRef))) + { + // is the child a record category or folder + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) || + kind.equals(FilePlanComponentKind.RECORD_FOLDER)) + { + // set the vital record definition values to match that of the parent + nodeService.setProperty(nodeRef, + PROP_VITAL_RECORD_INDICATOR, + nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR)); + nodeService.setProperty(nodeRef, + PROP_REVIEW_PERIOD, + nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD)); + } + } + } + } + + /** + * @see VitalRecordService#getVitalRecordDefinition(NodeRef) + */ + public VitalRecordDefinition getVitalRecordDefinition(NodeRef nodeRef) + { + VitalRecordDefinition result = null; + + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + if (FilePlanComponentKind.RECORD.equals(kind)) + { + result = resolveVitalRecordDefinition(nodeRef); + } + else + { + if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION)) + { + result = VitalRecordDefinitionImpl.create(nodeService, nodeRef); + } + } + + return result; + } + + /** + * Resolves the record vital definition. + *

+ * NOTE: Currently we only support the resolution of the vital record definition from the + * primary record parent. ie the record folder the record was originally filed within. + *

+ * TODO: Add an algorithm to resolve the correct vital record definition when a record is filed in many + * record folders. + * + * @param record + * @return VitalRecordDefinition + */ + private VitalRecordDefinition resolveVitalRecordDefinition(NodeRef record) + { + NodeRef parent = nodeService.getPrimaryParent(record).getParentRef(); + return getVitalRecordDefinition(parent); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setVitalRecordDefintion(org.alfresco.service.cmr.repository.NodeRef, boolean, org.alfresco.service.cmr.repository.Period) + */ + @Override + public VitalRecordDefinition setVitalRecordDefintion(NodeRef nodeRef, boolean enabled, Period reviewPeriod) + { + // Check params + ParameterCheck.mandatory("nodeRef", nodeRef); + ParameterCheck.mandatory("enabled", enabled); + + // Set the properties (will automatically add the vital record definition aspect) + nodeService.setProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR, enabled); + nodeService.setProperty(nodeRef, PROP_REVIEW_PERIOD, reviewPeriod); + + return new VitalRecordDefinitionImpl(enabled, reviewPeriod); + } + + /** + * @see VitalRecordService#isVitalRecord(NodeRef) + */ + public boolean isVitalRecord(NodeRef nodeRef) + { + return nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD); + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java index 4d6d313465..fc19762d79 100644 --- a/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java @@ -1,132 +1,132 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.repo.action.evaluator.ActionConditionEvaluator; -import org.alfresco.service.cmr.action.ActionConditionDefinition; -import org.alfresco.service.cmr.action.ActionDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * Extended action service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ExtendedActionServiceImpl extends ActionServiceImpl implements ApplicationContextAware -{ - /** File plan service */ - private FilePlanService filePlanService; - - /** Application context */ - private ApplicationContext extendedApplicationContext; - - /** - * @see org.alfresco.repo.action.ActionServiceImpl#setApplicationContext(org.springframework.context.ApplicationContext) - */ - public void setApplicationContext(ApplicationContext applicationContext) - { - super.setApplicationContext(applicationContext); - extendedApplicationContext = applicationContext; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String) - */ - public ActionConditionDefinition getActionConditionDefinition(String name) - { - // get direct access to action condition definition (i.e. ignoring public flag of executer) - ActionConditionDefinition definition = null; - Object bean = extendedApplicationContext.getBean(name); - if (bean instanceof ActionConditionEvaluator) - { - ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean; - definition = evaluator.getActionConditionDefintion(); - } - return definition; - } - - /** - * @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public List getActionDefinitions(NodeRef nodeRef) - { - List result = null; - - // first use the base implementation to get the list of action definitions - List actionDefinitions = super.getActionDefinitions(nodeRef); - - if (nodeRef == null) - { - // nothing to filter - result = actionDefinitions; - } - else - { - // get the file component kind of the node reference - FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); - result = new ArrayList(actionDefinitions.size()); - - // check each action definition - for (ActionDefinition actionDefinition : actionDefinitions) - { - if (actionDefinition instanceof RecordsManagementActionDefinition) - { - if (kind != null) - { - Set applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds(); - if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind)) - { - // an RM action can only act on a RM artifact - result.add(actionDefinition); - } - } - } - else - { - if (kind == null) - { - // a non-RM action can only act on a non-RM artifact - result.add(actionDefinition); - } - } - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.repo.action.evaluator.ActionConditionEvaluator; +import org.alfresco.service.cmr.action.ActionConditionDefinition; +import org.alfresco.service.cmr.action.ActionDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * Extended action service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ExtendedActionServiceImpl extends ActionServiceImpl implements ApplicationContextAware +{ + /** File plan service */ + private FilePlanService filePlanService; + + /** Application context */ + private ApplicationContext extendedApplicationContext; + + /** + * @see org.alfresco.repo.action.ActionServiceImpl#setApplicationContext(org.springframework.context.ApplicationContext) + */ + public void setApplicationContext(ApplicationContext applicationContext) + { + super.setApplicationContext(applicationContext); + extendedApplicationContext = applicationContext; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String) + */ + public ActionConditionDefinition getActionConditionDefinition(String name) + { + // get direct access to action condition definition (i.e. ignoring public flag of executer) + ActionConditionDefinition definition = null; + Object bean = extendedApplicationContext.getBean(name); + if (bean instanceof ActionConditionEvaluator) + { + ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean; + definition = evaluator.getActionConditionDefintion(); + } + return definition; + } + + /** + * @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public List getActionDefinitions(NodeRef nodeRef) + { + List result = null; + + // first use the base implementation to get the list of action definitions + List actionDefinitions = super.getActionDefinitions(nodeRef); + + if (nodeRef == null) + { + // nothing to filter + result = actionDefinitions; + } + else + { + // get the file component kind of the node reference + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); + result = new ArrayList(actionDefinitions.size()); + + // check each action definition + for (ActionDefinition actionDefinition : actionDefinitions) + { + if (actionDefinition instanceof RecordsManagementActionDefinition) + { + if (kind != null) + { + Set applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds(); + if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind)) + { + // an RM action can only act on a RM artifact + result.add(actionDefinition); + } + } + } + else + { + if (kind == null) + { + // a non-RM action can only act on a non-RM artifact + result.add(actionDefinition); + } + } + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java b/rm-server/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java index 1c475bc5bd..235680b6d2 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java @@ -1,250 +1,250 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; - -/** - * Date parameter processor. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class DateParameterProcessor extends ParameterProcessor implements ParameterSubstitutionSuggester -{ - private static final String DAY = "day"; - private static final String WEEK = "week"; - private static final String MONTH = "month"; - private static final String YEAR = "year"; - private static final String SHORT = "short"; - private static final String LONG = "long"; - private static final String NUMBER = "number"; - - private static final String SEP = "."; - - private static final String[] ALL_FIELDS_FOR_SUBSTITUTION_QUERY = { - DAY + SEP + SHORT, - DAY, - DAY + SEP + LONG, - DAY + SEP + NUMBER, - DAY + SEP + MONTH, - DAY + SEP + YEAR, - MONTH + SEP + SHORT, - MONTH, - MONTH + SEP + LONG, - MONTH + SEP + NUMBER, - YEAR + SEP + SHORT, - YEAR, - YEAR + SEP + LONG, - YEAR + SEP + WEEK - }; - - private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS; - - /** - * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String process(String value, NodeRef actionedUponNodeRef) - { - // the default position is to return the value un-changed - String result = value; - - // strip the processor name from the value - value = stripName(value); - - if (!value.isEmpty()) - { - String[] values = value.split("\\.", 2); - String field = values[0].trim(); - - if (DAY.equalsIgnoreCase(field)) - { - result = handleDay(values); - } - else if (MONTH.equalsIgnoreCase(field)) - { - result = handleMonth(values); - } - else if (YEAR.equalsIgnoreCase(field)) - { - result = handleYear(values); - } - else - { - throw new AlfrescoRuntimeException("Cannot process the field '" + field + "'."); - } - } - - return result; - } - - private String handleDay(String[] values) - { - String style = getStyle(values); - String pattern; - - if (SHORT.equalsIgnoreCase(style)) - { - pattern = "EE"; - } - else if (LONG.equalsIgnoreCase(style)) - { - pattern = "EEEE"; - } - else if (NUMBER.equalsIgnoreCase(style)) - { - pattern = "uu"; - } - else if (MONTH.equalsIgnoreCase(style)) - { - pattern = "dd"; - } - else if (YEAR.equalsIgnoreCase(style)) - { - pattern = "DDD"; - } - else - { - throw new AlfrescoRuntimeException("The pattern 'date.day." + style + "' is not supported!"); - } - - return new SimpleDateFormat(pattern).format(new Date()); - } - - private String handleMonth(String[] values) - { - String style = getStyle(values); - String pattern; - - if (SHORT.equalsIgnoreCase(style)) - { - pattern = "MMM"; - } - else if (LONG.equalsIgnoreCase(style)) - { - pattern = "MMMM"; - } - else if (NUMBER.equalsIgnoreCase(style)) - { - pattern = "MM"; - } - else - { - throw new AlfrescoRuntimeException("The pattern 'date.month." + style + "' is not supported!"); - } - - return new SimpleDateFormat(pattern).format(new Date()); - } - - private String handleYear(String[] values) - { - String style = getStyle(values); - String pattern; - - if (SHORT.equalsIgnoreCase(style)) - { - pattern = "yy"; - } - else if (LONG.equalsIgnoreCase(style)) - { - pattern = "yyyy"; - } - else if (WEEK.equalsIgnoreCase(style)) - { - pattern = "ww"; - } - else - { - throw new AlfrescoRuntimeException("The pattern 'date.year." + style + "' is not supported!"); - } - - return new SimpleDateFormat(pattern).format(new Date()); - } - - private String getStyle(String[] values) - { - String style; - - if (values.length == 1) - { - style = SHORT; - } - else - { - style = values[1].trim(); - } - - return style; - } - - /** - * Set the maxmimum number of suggestions returned from the global property - * - * @param maximumNumberSuggestions - */ - public void setMaximumNumberSuggestions(int maximumNumberSuggestions) - { - this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String) - */ - @Override - public List getSubstitutionSuggestions(String substitutionFragment) - { - List suggestions = new ArrayList(); - String namePrefix = this.getName() + "."; - if(StringUtils.isBlank(substitutionFragment) || this.getName().toLowerCase().contains(substitutionFragment.toLowerCase())) - { - for(String field: ALL_FIELDS_FOR_SUBSTITUTION_QUERY) - { - suggestions.add(namePrefix + field); - if(suggestions.size() >= maximumNumberSuggestions) - { - break; - } - } - } - else - { - for(String field: ALL_FIELDS_FOR_SUBSTITUTION_QUERY) - { - String prefixFieldName = namePrefix + field; - if(prefixFieldName.toLowerCase().contains(substitutionFragment.toLowerCase())) - { - suggestions.add(namePrefix + field); - if(suggestions.size() >= maximumNumberSuggestions) - { - break; - } - } - } - } - return suggestions; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.StringUtils; + +/** + * Date parameter processor. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class DateParameterProcessor extends ParameterProcessor implements ParameterSubstitutionSuggester +{ + private static final String DAY = "day"; + private static final String WEEK = "week"; + private static final String MONTH = "month"; + private static final String YEAR = "year"; + private static final String SHORT = "short"; + private static final String LONG = "long"; + private static final String NUMBER = "number"; + + private static final String SEP = "."; + + private static final String[] ALL_FIELDS_FOR_SUBSTITUTION_QUERY = { + DAY + SEP + SHORT, + DAY, + DAY + SEP + LONG, + DAY + SEP + NUMBER, + DAY + SEP + MONTH, + DAY + SEP + YEAR, + MONTH + SEP + SHORT, + MONTH, + MONTH + SEP + LONG, + MONTH + SEP + NUMBER, + YEAR + SEP + SHORT, + YEAR, + YEAR + SEP + LONG, + YEAR + SEP + WEEK + }; + + private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS; + + /** + * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String process(String value, NodeRef actionedUponNodeRef) + { + // the default position is to return the value un-changed + String result = value; + + // strip the processor name from the value + value = stripName(value); + + if (!value.isEmpty()) + { + String[] values = value.split("\\.", 2); + String field = values[0].trim(); + + if (DAY.equalsIgnoreCase(field)) + { + result = handleDay(values); + } + else if (MONTH.equalsIgnoreCase(field)) + { + result = handleMonth(values); + } + else if (YEAR.equalsIgnoreCase(field)) + { + result = handleYear(values); + } + else + { + throw new AlfrescoRuntimeException("Cannot process the field '" + field + "'."); + } + } + + return result; + } + + private String handleDay(String[] values) + { + String style = getStyle(values); + String pattern; + + if (SHORT.equalsIgnoreCase(style)) + { + pattern = "EE"; + } + else if (LONG.equalsIgnoreCase(style)) + { + pattern = "EEEE"; + } + else if (NUMBER.equalsIgnoreCase(style)) + { + pattern = "uu"; + } + else if (MONTH.equalsIgnoreCase(style)) + { + pattern = "dd"; + } + else if (YEAR.equalsIgnoreCase(style)) + { + pattern = "DDD"; + } + else + { + throw new AlfrescoRuntimeException("The pattern 'date.day." + style + "' is not supported!"); + } + + return new SimpleDateFormat(pattern).format(new Date()); + } + + private String handleMonth(String[] values) + { + String style = getStyle(values); + String pattern; + + if (SHORT.equalsIgnoreCase(style)) + { + pattern = "MMM"; + } + else if (LONG.equalsIgnoreCase(style)) + { + pattern = "MMMM"; + } + else if (NUMBER.equalsIgnoreCase(style)) + { + pattern = "MM"; + } + else + { + throw new AlfrescoRuntimeException("The pattern 'date.month." + style + "' is not supported!"); + } + + return new SimpleDateFormat(pattern).format(new Date()); + } + + private String handleYear(String[] values) + { + String style = getStyle(values); + String pattern; + + if (SHORT.equalsIgnoreCase(style)) + { + pattern = "yy"; + } + else if (LONG.equalsIgnoreCase(style)) + { + pattern = "yyyy"; + } + else if (WEEK.equalsIgnoreCase(style)) + { + pattern = "ww"; + } + else + { + throw new AlfrescoRuntimeException("The pattern 'date.year." + style + "' is not supported!"); + } + + return new SimpleDateFormat(pattern).format(new Date()); + } + + private String getStyle(String[] values) + { + String style; + + if (values.length == 1) + { + style = SHORT; + } + else + { + style = values[1].trim(); + } + + return style; + } + + /** + * Set the maxmimum number of suggestions returned from the global property + * + * @param maximumNumberSuggestions + */ + public void setMaximumNumberSuggestions(int maximumNumberSuggestions) + { + this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions); + } + + /* (non-Javadoc) + * @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String) + */ + @Override + public List getSubstitutionSuggestions(String substitutionFragment) + { + List suggestions = new ArrayList(); + String namePrefix = this.getName() + "."; + if(StringUtils.isBlank(substitutionFragment) || this.getName().toLowerCase().contains(substitutionFragment.toLowerCase())) + { + for(String field: ALL_FIELDS_FOR_SUBSTITUTION_QUERY) + { + suggestions.add(namePrefix + field); + if(suggestions.size() >= maximumNumberSuggestions) + { + break; + } + } + } + else + { + for(String field: ALL_FIELDS_FOR_SUBSTITUTION_QUERY) + { + String prefixFieldName = namePrefix + field; + if(prefixFieldName.toLowerCase().contains(substitutionFragment.toLowerCase())) + { + suggestions.add(namePrefix + field); + if(suggestions.size() >= maximumNumberSuggestions) + { + break; + } + } + } + } + return suggestions; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/MessageParameterProcessor.java b/rm-server/source/java/org/alfresco/repo/action/parameter/MessageParameterProcessor.java index fd239301d5..3ac29a4877 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/MessageParameterProcessor.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/MessageParameterProcessor.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Message parameter processor. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class MessageParameterProcessor extends ParameterProcessor -{ - /** - * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String process(String value, NodeRef actionedUponNodeRef) - { - // the default position is to return the value un-changed - String result = value; - - // strip the processor name from the value - value = stripName(value); - if (!value.isEmpty()) - { - result = I18NUtil.getMessage(value); - if (result == null) - { - throw new AlfrescoRuntimeException("The message parameter processor could not resolve the message for the id " + value); - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Message parameter processor. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class MessageParameterProcessor extends ParameterProcessor +{ + /** + * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String process(String value, NodeRef actionedUponNodeRef) + { + // the default position is to return the value un-changed + String result = value; + + // strip the processor name from the value + value = stripName(value); + if (!value.isEmpty()) + { + result = I18NUtil.getMessage(value); + if (result == null) + { + throw new AlfrescoRuntimeException("The message parameter processor could not resolve the message for the id " + value); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java index f750999a21..c12ae14c8f 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java @@ -1,294 +1,294 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.ArrayUtils; - -/** - * Node parameter processor. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class NodeParameterProcessor extends ParameterProcessor implements ParameterSubstitutionSuggester -{ - /** Supported data types */ - private QName[] supportedDataTypes = - { - DataTypeDefinition.TEXT, - DataTypeDefinition.BOOLEAN, - DataTypeDefinition.DATE, - DataTypeDefinition.DATETIME, - DataTypeDefinition.DOUBLE, - DataTypeDefinition.FLOAT, - DataTypeDefinition.INT, - DataTypeDefinition.MLTEXT - }; - - private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS; - - /** Node service */ - private NodeService nodeService; - - /** Namespace service */ - private NamespaceService namespaceService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Records management admin service */ - private RecordsManagementAdminService recordsManagementAdminService; - - /** List of definitions (aspects and types) to use for substitution suggestions */ - private List suggestionDefinitions = null; - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param recordsManagementAdminService Records management admin service - */ - public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) - { - this.recordsManagementAdminService = recordsManagementAdminService; - } - - /** - * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public String process(String value, NodeRef actionedUponNodeRef) - { - // the default position is to return the value un-changed - String result = value; - - // strip the processor name from the value - value = stripName(value); - if (!value.isEmpty()) - { - QName qname = QName.createQName(value, namespaceService); - - PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname); - if (propertyDefinition == null) - { - throw new AlfrescoRuntimeException("The property " + value + " does not have a property definition."); - } - - QName type = propertyDefinition.getDataType().getName(); - if (ArrayUtils.contains(supportedDataTypes, type)) - { - Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname); - if (propertyValue != null) - { - result = propertyValue.toString(); - } - else - { - // set the result to the empty string - result = ""; - } - } - else - { - throw new AlfrescoRuntimeException("The property " + value + " is of type " + type.toString() + " which is not supported by parameter substitution."); - } - } - - return result; - } - - /** - * Set the maxmimum number of suggestions returned from the global property - * - * @param maximumNumberSuggestions - */ - public void setMaximumNumberSuggestions(int maximumNumberSuggestions) - { - this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions); - } - - /** - * Add suggestion definition to the list used to get properties suggestions from. - * - * @param definition Type or aspect - */ - public void addSuggestionDefinition(QName definition) - { - if(this.suggestionDefinitions == null) - { - this.suggestionDefinitions = Collections.synchronizedList(new ArrayList()); - } - this.suggestionDefinitions.add(definition); - } - - /** - * Get a list of node substitution suggestions for the specified fragment. - * - * @param substitutionFragment The fragment to search for - * @returns A list of node substitution suggestions, for example 'node.cm:title' - * - * @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String) - */ - @Override - public List getSubstitutionSuggestions(String substitutionFragment) - { - Set suggestionSet = Collections.synchronizedSet(new HashSet()); - if(this.suggestionDefinitions != null) - { - for(QName definition : this.suggestionDefinitions) - { - if(getSubstitutionSuggestions(definition, substitutionFragment.toLowerCase(), suggestionSet)) - { - break; - } - } - } - List suggestions = new ArrayList(); - suggestions.addAll(suggestionSet); - Collections.sort(suggestions); - return suggestions; - } - - /** - * Get a list of node substitution suggestions for the given definition and specified fragment. - * - * @param definitionName Definition (aspect or type) to get properties of and the call this method for associated aspects - * @param substitutionFragment Substitution fragment to search for - * @param suggestions The current list of suggestions to which we will add newly found suggestions - */ - private boolean getSubstitutionSuggestions(QName definitionName, String substitutionFragment, Set suggestions) - { - boolean gotMaximumSuggestions = false; - ClassDefinition definition = this.dictionaryService.getAspect(definitionName); - if(definition == null) - { - definition = this.dictionaryService.getType(definitionName); - } - if(definition != null) - { - gotMaximumSuggestions = getSubstitutionSuggestionsForDefinition(definition, substitutionFragment, suggestions); - } - if(recordsManagementAdminService.isCustomisable(definitionName) && !gotMaximumSuggestions) - { - gotMaximumSuggestions = processPropertyDefinitions(recordsManagementAdminService.getCustomPropertyDefinitions(definitionName), substitutionFragment, suggestions); - } - return gotMaximumSuggestions; - } - - /** - * Get a list of node substitution suggestions for the given definition and specified fragment. Calls itself recursively for - * associated aspects. - * - * @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects - * @param substitutionFragment Substitution fragment to search for - * @param suggestions The current list of suggestions to which we will add newly found suggestions - */ - private boolean getSubstitutionSuggestionsForDefinition(ClassDefinition definition, String substitutionFragment, Set suggestions) - { - boolean gotMaximumSuggestions = processPropertyDefinitions(definition.getProperties(), substitutionFragment, suggestions); - if(!gotMaximumSuggestions) - { - for(QName defaultAspect : definition.getDefaultAspectNames()) - { - gotMaximumSuggestions = getSubstitutionSuggestions(defaultAspect, substitutionFragment, suggestions); - if(gotMaximumSuggestions) - { - break; - } - } - } - return gotMaximumSuggestions; - } - - /** - * Process the supplied map of property definitions and add the ones that match the supplied fragment to the list of suggestions. - * - * @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects - * @param substitutionFragment Substitution fragment to search for - * @param suggestions The current list of suggestions to which we will add newly found suggestions - */ - private boolean processPropertyDefinitions(Map properties, String substitutionFragment, Set suggestions) - { - boolean gotMaximumSuggestions = false; - if (properties != null) - { - for (Map.Entry entry : properties.entrySet()) - { - PropertyDefinition propertyDefinition = entry.getValue(); - QName type = propertyDefinition.getDataType().getName(); - if(ArrayUtils.contains(supportedDataTypes, type)) - { - String suggestion = getName() + "." + entry.getKey().getPrefixString(); - if(suggestion.toLowerCase().contains(substitutionFragment)) - { - if(suggestions.size() < this.maximumNumberSuggestions) - { - suggestions.add(suggestion); - } - else - { - gotMaximumSuggestions = true; - break; - } - } - } - } - } - return gotMaximumSuggestions; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.service.cmr.dictionary.ClassDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.ArrayUtils; + +/** + * Node parameter processor. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class NodeParameterProcessor extends ParameterProcessor implements ParameterSubstitutionSuggester +{ + /** Supported data types */ + private QName[] supportedDataTypes = + { + DataTypeDefinition.TEXT, + DataTypeDefinition.BOOLEAN, + DataTypeDefinition.DATE, + DataTypeDefinition.DATETIME, + DataTypeDefinition.DOUBLE, + DataTypeDefinition.FLOAT, + DataTypeDefinition.INT, + DataTypeDefinition.MLTEXT + }; + + private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS; + + /** Node service */ + private NodeService nodeService; + + /** Namespace service */ + private NamespaceService namespaceService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + + /** Records management admin service */ + private RecordsManagementAdminService recordsManagementAdminService; + + /** List of definitions (aspects and types) to use for substitution suggestions */ + private List suggestionDefinitions = null; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @param recordsManagementAdminService Records management admin service + */ + public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService) + { + this.recordsManagementAdminService = recordsManagementAdminService; + } + + /** + * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public String process(String value, NodeRef actionedUponNodeRef) + { + // the default position is to return the value un-changed + String result = value; + + // strip the processor name from the value + value = stripName(value); + if (!value.isEmpty()) + { + QName qname = QName.createQName(value, namespaceService); + + PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname); + if (propertyDefinition == null) + { + throw new AlfrescoRuntimeException("The property " + value + " does not have a property definition."); + } + + QName type = propertyDefinition.getDataType().getName(); + if (ArrayUtils.contains(supportedDataTypes, type)) + { + Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname); + if (propertyValue != null) + { + result = propertyValue.toString(); + } + else + { + // set the result to the empty string + result = ""; + } + } + else + { + throw new AlfrescoRuntimeException("The property " + value + " is of type " + type.toString() + " which is not supported by parameter substitution."); + } + } + + return result; + } + + /** + * Set the maxmimum number of suggestions returned from the global property + * + * @param maximumNumberSuggestions + */ + public void setMaximumNumberSuggestions(int maximumNumberSuggestions) + { + this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions); + } + + /** + * Add suggestion definition to the list used to get properties suggestions from. + * + * @param definition Type or aspect + */ + public void addSuggestionDefinition(QName definition) + { + if(this.suggestionDefinitions == null) + { + this.suggestionDefinitions = Collections.synchronizedList(new ArrayList()); + } + this.suggestionDefinitions.add(definition); + } + + /** + * Get a list of node substitution suggestions for the specified fragment. + * + * @param substitutionFragment The fragment to search for + * @returns A list of node substitution suggestions, for example 'node.cm:title' + * + * @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String) + */ + @Override + public List getSubstitutionSuggestions(String substitutionFragment) + { + Set suggestionSet = Collections.synchronizedSet(new HashSet()); + if(this.suggestionDefinitions != null) + { + for(QName definition : this.suggestionDefinitions) + { + if(getSubstitutionSuggestions(definition, substitutionFragment.toLowerCase(), suggestionSet)) + { + break; + } + } + } + List suggestions = new ArrayList(); + suggestions.addAll(suggestionSet); + Collections.sort(suggestions); + return suggestions; + } + + /** + * Get a list of node substitution suggestions for the given definition and specified fragment. + * + * @param definitionName Definition (aspect or type) to get properties of and the call this method for associated aspects + * @param substitutionFragment Substitution fragment to search for + * @param suggestions The current list of suggestions to which we will add newly found suggestions + */ + private boolean getSubstitutionSuggestions(QName definitionName, String substitutionFragment, Set suggestions) + { + boolean gotMaximumSuggestions = false; + ClassDefinition definition = this.dictionaryService.getAspect(definitionName); + if(definition == null) + { + definition = this.dictionaryService.getType(definitionName); + } + if(definition != null) + { + gotMaximumSuggestions = getSubstitutionSuggestionsForDefinition(definition, substitutionFragment, suggestions); + } + if(recordsManagementAdminService.isCustomisable(definitionName) && !gotMaximumSuggestions) + { + gotMaximumSuggestions = processPropertyDefinitions(recordsManagementAdminService.getCustomPropertyDefinitions(definitionName), substitutionFragment, suggestions); + } + return gotMaximumSuggestions; + } + + /** + * Get a list of node substitution suggestions for the given definition and specified fragment. Calls itself recursively for + * associated aspects. + * + * @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects + * @param substitutionFragment Substitution fragment to search for + * @param suggestions The current list of suggestions to which we will add newly found suggestions + */ + private boolean getSubstitutionSuggestionsForDefinition(ClassDefinition definition, String substitutionFragment, Set suggestions) + { + boolean gotMaximumSuggestions = processPropertyDefinitions(definition.getProperties(), substitutionFragment, suggestions); + if(!gotMaximumSuggestions) + { + for(QName defaultAspect : definition.getDefaultAspectNames()) + { + gotMaximumSuggestions = getSubstitutionSuggestions(defaultAspect, substitutionFragment, suggestions); + if(gotMaximumSuggestions) + { + break; + } + } + } + return gotMaximumSuggestions; + } + + /** + * Process the supplied map of property definitions and add the ones that match the supplied fragment to the list of suggestions. + * + * @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects + * @param substitutionFragment Substitution fragment to search for + * @param suggestions The current list of suggestions to which we will add newly found suggestions + */ + private boolean processPropertyDefinitions(Map properties, String substitutionFragment, Set suggestions) + { + boolean gotMaximumSuggestions = false; + if (properties != null) + { + for (Map.Entry entry : properties.entrySet()) + { + PropertyDefinition propertyDefinition = entry.getValue(); + QName type = propertyDefinition.getDataType().getName(); + if(ArrayUtils.contains(supportedDataTypes, type)) + { + String suggestion = getName() + "." + entry.getKey().getPrefixString(); + if(suggestion.toLowerCase().contains(substitutionFragment)) + { + if(suggestions.size() < this.maximumNumberSuggestions) + { + suggestions.add(suggestion); + } + else + { + gotMaximumSuggestions = true; + break; + } + } + } + } + } + return gotMaximumSuggestions; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java index 2b7910e1fc..ea5d25438b 100755 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; - -/** - * Record metadata bootstrap bean. - *

- * This method of bootstrapping record metadata aspects into the RecordService deprecates the - * previous practice of extending rma:recordMetaData. - * - * @author Mark Hibbins - * @since 2.2 - */ -public class NodeParameterSuggesterBootstrap -{ - /** namespace service */ - private NamespaceService namespaceService; - - /** configured node parameter processor aspect and type names, comma separated */ - private String nodeParameterProcessorAspectsNames; - - /** node parameter processor */ - private NodeParameterProcessor nodeParameterProcessor; - - /** - * @param recordMetadataAspects map of record metadata aspects against file plan types - */ - public void setNodeParameterProcessorAspects(String nodeParameterProcessorAspectsNames) - { - this.nodeParameterProcessorAspectsNames = nodeParameterProcessorAspectsNames; - } - - /** - * @param namespaceService namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param nodeParameterProcessor Node parameter processor - */ - public void setNodeParameterProcessor(NodeParameterProcessor nodeParameterProcessor) - { - this.nodeParameterProcessor = nodeParameterProcessor; - } - - /** - * Init method - */ - public void init() - { - ParameterCheck.mandatory("namespaceService", namespaceService); - - if (nodeParameterProcessorAspectsNames != null) - { - String[] aspectsNames = this.nodeParameterProcessorAspectsNames.split(","); - for (String name : aspectsNames) - { - if((name != null) && !"".equals(name.trim())) - { - // convert to qname and save it - QName aspect = QName.createQName(name.trim(), namespaceService); - - // register with node parameter processor - this.nodeParameterProcessor.addSuggestionDefinition(aspect); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; + +/** + * Record metadata bootstrap bean. + *

+ * This method of bootstrapping record metadata aspects into the RecordService deprecates the + * previous practice of extending rma:recordMetaData. + * + * @author Mark Hibbins + * @since 2.2 + */ +public class NodeParameterSuggesterBootstrap +{ + /** namespace service */ + private NamespaceService namespaceService; + + /** configured node parameter processor aspect and type names, comma separated */ + private String nodeParameterProcessorAspectsNames; + + /** node parameter processor */ + private NodeParameterProcessor nodeParameterProcessor; + + /** + * @param recordMetadataAspects map of record metadata aspects against file plan types + */ + public void setNodeParameterProcessorAspects(String nodeParameterProcessorAspectsNames) + { + this.nodeParameterProcessorAspectsNames = nodeParameterProcessorAspectsNames; + } + + /** + * @param namespaceService namespace service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param nodeParameterProcessor Node parameter processor + */ + public void setNodeParameterProcessor(NodeParameterProcessor nodeParameterProcessor) + { + this.nodeParameterProcessor = nodeParameterProcessor; + } + + /** + * Init method + */ + public void init() + { + ParameterCheck.mandatory("namespaceService", namespaceService); + + if (nodeParameterProcessorAspectsNames != null) + { + String[] aspectsNames = this.nodeParameterProcessorAspectsNames.split(","); + for (String name : aspectsNames) + { + if((name != null) && !"".equals(name.trim())) + { + // convert to qname and save it + QName aspect = QName.createQName(name.trim(), namespaceService); + + // register with node parameter processor + this.nodeParameterProcessor.addSuggestionDefinition(aspect); + } + } + } + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessor.java b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessor.java index ac7fb0f8ce..e18f8f9953 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessor.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessor.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Abstract parameter processor implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public abstract class ParameterProcessor -{ - /** Processor name */ - private String name; - - /** Parameter processor component */ - private ParameterProcessorComponent parameterProcessorComponent; - - /** - * @return parameter processor name - */ - public String getName() - { - return name; - } - - /** - * @param name parameter processor name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @param parameterProcessorComponent parameter processor component - */ - public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) - { - this.parameterProcessorComponent = parameterProcessorComponent; - } - - /** - * Init method - */ - public void init() - { - parameterProcessorComponent.register(this); - } - - /** - * Process the parameter value. - * - * @param value substitution value - * @param actionedUponNodeRef actioned upon node reference - * @return String processed string, original string if subs string invalid - */ - public abstract String process(String value, NodeRef actionedUponNodeRef); - - /** - * Strips the name of the processor from the subs value. - * - * @param value subs value - * @return String subs value with the name and '.' delimiter removed - */ - protected String stripName(String value) - { - String result = ""; - String[] values = value.split("\\.", 2); - if (values.length == 2) - { - result = values[1]; - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Abstract parameter processor implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public abstract class ParameterProcessor +{ + /** Processor name */ + private String name; + + /** Parameter processor component */ + private ParameterProcessorComponent parameterProcessorComponent; + + /** + * @return parameter processor name + */ + public String getName() + { + return name; + } + + /** + * @param name parameter processor name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @param parameterProcessorComponent parameter processor component + */ + public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) + { + this.parameterProcessorComponent = parameterProcessorComponent; + } + + /** + * Init method + */ + public void init() + { + parameterProcessorComponent.register(this); + } + + /** + * Process the parameter value. + * + * @param value substitution value + * @param actionedUponNodeRef actioned upon node reference + * @return String processed string, original string if subs string invalid + */ + public abstract String process(String value, NodeRef actionedUponNodeRef); + + /** + * Strips the name of the processor from the subs value. + * + * @param value subs value + * @return String subs value with the name and '.' delimiter removed + */ + protected String stripName(String value) + { + String result = ""; + String[] values = value.split("\\.", 2); + if (values.length == 2) + { + result = values[1]; + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java index 6b8abf78d4..3d727e162f 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java @@ -1,166 +1,166 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.action.ParameterizedItem; -import org.alfresco.service.cmr.action.ParameterizedItemDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Parameter processor component - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ParameterProcessorComponent implements ParameterSubstitutionSuggester -{ - /** regex used to parse parameters */ - private static final String REG_EX_OLD = "\\$\\{([^\\$\\{]+)\\}"; - private static final String REG_EX = "\\{([^\\{]+)\\}"; - - /** registry of parameter processors */ - private Map processors = new HashMap(5); - private List subtitutionSuggesterProcessors = new ArrayList(5); - - /** - * Register parameter processor - * - * @param processor - */ - public void register(ParameterProcessor processor) - { - this.processors.put(processor.getName(), processor); - if(processor instanceof ParameterSubstitutionSuggester) - { - this.subtitutionSuggesterProcessors.add((ParameterSubstitutionSuggester)processor); - } - } - - /** - * - * @param ruleItem - * @param ruleItemDefinition - * @param actionedUponNodeRef - */ - public void process(ParameterizedItem ruleItem, ParameterizedItemDefinition ruleItemDefinition, NodeRef actionedUponNodeRef) - { - for (Map.Entry entry : ruleItem.getParameterValues().entrySet()) - { - String parameterName = entry.getKey(); - Object parameterValue = entry.getValue(); - - // only sub string property values - if (parameterValue instanceof String) - { - // set the updated parameter value - ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef)); - } - } - } - - /** - * Process the value for substitution within the context of the provided node. - * - * @param value value - * @param nodeRef node reference - * @return String resulting value - */ - public String process(String value, NodeRef nodeRef) - { - return process(process(value, nodeRef, REG_EX_OLD), nodeRef, REG_EX); - } - - public String process(String value, NodeRef nodeRef, String regExp) - { - // match the substitution pattern - Pattern patt = Pattern.compile(regExp); - Matcher m = patt.matcher(value); - StringBuffer sb = new StringBuffer(value.length()); - - while (m.find()) - { - String text = m.group(1); - - // lookup parameter processor to use - ParameterProcessor processor = lookupProcessor(text); - if (processor == null) - { - throw new AlfrescoRuntimeException("A parameter processor has not been found for the substitution string " + text); - } - else - { - // process each substitution value - text = processor.process(text, nodeRef); - } - - // append new value - m.appendReplacement(sb, Matcher.quoteReplacement(text)); - } - m.appendTail(sb); - return sb.toString(); - } - - /** - * Return a list of substitution suggestions for the passed string fragment. - * - * @param subtitutionFragment Text fragment to search on. - * @return A list of substitutions that match the substitution fragment. - */ - public List getSubstitutionSuggestions(final String substitutionFragment) - { - List suggestions = new ArrayList(); - for (ParameterSubstitutionSuggester suggestor : this.subtitutionSuggesterProcessors) - { - suggestions.addAll(suggestor.getSubstitutionSuggestions(substitutionFragment.toLowerCase())); - } - return suggestions; - } - - /** - * Look up parameter processor - * - * @param value - * @return - */ - private ParameterProcessor lookupProcessor(String value) - { - ParameterProcessor result = null; - - if (value != null && !value.isEmpty()) - { - String[] values = value.split("\\.", 2); - if (values.length != 0) - { - // get the processor from the registered map - result = processors.get(values[0]); - } - } - - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.action.ParameterizedItem; +import org.alfresco.service.cmr.action.ParameterizedItemDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Parameter processor component + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ParameterProcessorComponent implements ParameterSubstitutionSuggester +{ + /** regex used to parse parameters */ + private static final String REG_EX_OLD = "\\$\\{([^\\$\\{]+)\\}"; + private static final String REG_EX = "\\{([^\\{]+)\\}"; + + /** registry of parameter processors */ + private Map processors = new HashMap(5); + private List subtitutionSuggesterProcessors = new ArrayList(5); + + /** + * Register parameter processor + * + * @param processor + */ + public void register(ParameterProcessor processor) + { + this.processors.put(processor.getName(), processor); + if(processor instanceof ParameterSubstitutionSuggester) + { + this.subtitutionSuggesterProcessors.add((ParameterSubstitutionSuggester)processor); + } + } + + /** + * + * @param ruleItem + * @param ruleItemDefinition + * @param actionedUponNodeRef + */ + public void process(ParameterizedItem ruleItem, ParameterizedItemDefinition ruleItemDefinition, NodeRef actionedUponNodeRef) + { + for (Map.Entry entry : ruleItem.getParameterValues().entrySet()) + { + String parameterName = entry.getKey(); + Object parameterValue = entry.getValue(); + + // only sub string property values + if (parameterValue instanceof String) + { + // set the updated parameter value + ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef)); + } + } + } + + /** + * Process the value for substitution within the context of the provided node. + * + * @param value value + * @param nodeRef node reference + * @return String resulting value + */ + public String process(String value, NodeRef nodeRef) + { + return process(process(value, nodeRef, REG_EX_OLD), nodeRef, REG_EX); + } + + public String process(String value, NodeRef nodeRef, String regExp) + { + // match the substitution pattern + Pattern patt = Pattern.compile(regExp); + Matcher m = patt.matcher(value); + StringBuffer sb = new StringBuffer(value.length()); + + while (m.find()) + { + String text = m.group(1); + + // lookup parameter processor to use + ParameterProcessor processor = lookupProcessor(text); + if (processor == null) + { + throw new AlfrescoRuntimeException("A parameter processor has not been found for the substitution string " + text); + } + else + { + // process each substitution value + text = processor.process(text, nodeRef); + } + + // append new value + m.appendReplacement(sb, Matcher.quoteReplacement(text)); + } + m.appendTail(sb); + return sb.toString(); + } + + /** + * Return a list of substitution suggestions for the passed string fragment. + * + * @param subtitutionFragment Text fragment to search on. + * @return A list of substitutions that match the substitution fragment. + */ + public List getSubstitutionSuggestions(final String substitutionFragment) + { + List suggestions = new ArrayList(); + for (ParameterSubstitutionSuggester suggestor : this.subtitutionSuggesterProcessors) + { + suggestions.addAll(suggestor.getSubstitutionSuggestions(substitutionFragment.toLowerCase())); + } + return suggestions; + } + + /** + * Look up parameter processor + * + * @param value + * @return + */ + private ParameterProcessor lookupProcessor(String value) + { + ParameterProcessor result = null; + + if (value != null && !value.isEmpty()) + { + String[] values = value.split("\\.", 2); + if (values.length != 0) + { + // get the processor from the registered map + result = processors.get(values[0]); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java index 849e098431..1d724e2fc8 100644 --- a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java +++ b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java @@ -1,28 +1,28 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import java.util.List; - -public interface ParameterSubstitutionSuggester -{ - int DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS = 10; - - List getSubstitutionSuggestions(final String substitutionFragment); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import java.util.List; + +public interface ParameterSubstitutionSuggester +{ + int DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS = 10; + + List getSubstitutionSuggestions(final String substitutionFragment); +} diff --git a/rm-server/source/java/org/alfresco/repo/jscript/ExtendedSearch.java b/rm-server/source/java/org/alfresco/repo/jscript/ExtendedSearch.java index f285c2a8a8..48dc50fbc6 100644 --- a/rm-server/source/java/org/alfresco/repo/jscript/ExtendedSearch.java +++ b/rm-server/source/java/org/alfresco/repo/jscript/ExtendedSearch.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.jscript; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.util.ParameterCheck; - -/** - * Extended jscript search implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ExtendedSearch extends Search -{ - /** - * Extended to take into account record read permission check. - * - * @see org.alfresco.repo.jscript.Search#findNode(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public ScriptNode findNode(NodeRef ref) - { - ParameterCheck.mandatory("ref", ref); - if (this.services.getNodeService().exists(ref) && - (this.services.getPermissionService().hasPermission(ref, PermissionService.READ) == AccessStatus.ALLOWED || - this.services.getPermissionService().hasPermission(ref, RMPermissionModel.READ_RECORDS) == AccessStatus.ALLOWED)) - { - return new ScriptNode(ref, this.services, getScope()); - } - return null; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.jscript; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.util.ParameterCheck; + +/** + * Extended jscript search implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ExtendedSearch extends Search +{ + /** + * Extended to take into account record read permission check. + * + * @see org.alfresco.repo.jscript.Search#findNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public ScriptNode findNode(NodeRef ref) + { + ParameterCheck.mandatory("ref", ref); + if (this.services.getNodeService().exists(ref) && + (this.services.getPermissionService().hasPermission(ref, PermissionService.READ) == AccessStatus.ALLOWED || + this.services.getPermissionService().hasPermission(ref, RMPermissionModel.READ_RECORDS) == AccessStatus.ALLOWED)) + { + return new ScriptNode(ref, this.services, getScope()); + } + return null; + } + +} diff --git a/rm-server/source/java/org/alfresco/repo/model/filefolder/ExtendedFileFolderServiceImpl.java b/rm-server/source/java/org/alfresco/repo/model/filefolder/ExtendedFileFolderServiceImpl.java index 3fc319814b..32afe1bf73 100644 --- a/rm-server/source/java/org/alfresco/repo/model/filefolder/ExtendedFileFolderServiceImpl.java +++ b/rm-server/source/java/org/alfresco/repo/model/filefolder/ExtendedFileFolderServiceImpl.java @@ -1,50 +1,50 @@ -/** - * - */ -package org.alfresco.repo.model.filefolder; - -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - */ -public class ExtendedFileFolderServiceImpl extends FileFolderServiceImpl -{ - protected RecordService recordService; - - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - @Override - public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName) - { - return create(parentNodeRef, name, typeQName, null); - } - - @Override - public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName, QName assocQName) - { - FileInfo result = null; - - recordService.disablePropertyEditableCheck(); - try - { - result = super.create(parentNodeRef, name, typeQName, assocQName); - } - finally - { - recordService.enablePropertyEditableCheck(); - if (result != null) - { - recordService.disablePropertyEditableCheck(result.getNodeRef()); - } - } - - return result; - } -} +/** + * + */ +package org.alfresco.repo.model.filefolder; + +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + */ +public class ExtendedFileFolderServiceImpl extends FileFolderServiceImpl +{ + protected RecordService recordService; + + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + @Override + public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName) + { + return create(parentNodeRef, name, typeQName, null); + } + + @Override + public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName, QName assocQName) + { + FileInfo result = null; + + recordService.disablePropertyEditableCheck(); + try + { + result = super.create(parentNodeRef, name, typeQName, assocQName); + } + finally + { + recordService.enablePropertyEditableCheck(); + if (result != null) + { + recordService.disablePropertyEditableCheck(result.getNodeRef()); + } + } + + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java b/rm-server/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java index db0fd4d67e..837dd0f2b9 100644 --- a/rm-server/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java +++ b/rm-server/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java @@ -1,251 +1,251 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.rule; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.rule.Rule; -import org.alfresco.service.namespace.QName; - -/** - * Extended rule service implementation. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ExtendedRuleServiceImpl extends RuleServiceImpl -{ - /** indicates whether the rules should be run as admin or not */ - private boolean runAsAdmin = true; - - /** ignore types */ - private Set ignoredTypes = new HashSet(); - - /** file plan service */ - private FilePlanService filePlanService; - - /** node service */ - protected NodeService nodeService; - - /** Record service */ - protected RecordService recordService; - - /** - * @param nodeService node service - */ - public void setNodeService2(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param recordService record service - */ - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } - - /** - * @param runAsAdmin true if run rules as admin, false otherwise - */ - public void setRunAsAdmin(boolean runAsAdmin) - { - this.runAsAdmin = runAsAdmin; - } - - /** - * Init method - */ - @Override - public void init() - { - super.init(); - - // Specify a set of system types to be ignored by rule executions - ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE); - ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_ACTION); - ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION); - ignoredTypes.add(RecordsManagementModel.TYPE_EVENT_EXECUTION); - } - - /** - * @see org.alfresco.repo.rule.RuleServiceImpl#saveRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule) - */ - @Override - public void saveRule(final NodeRef nodeRef, final Rule rule) - { - if (filePlanService.isFilePlanComponent(nodeRef)) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - ExtendedRuleServiceImpl.super.saveRule(nodeRef, rule); - return null; - } - - }); - } - else - { - super.saveRule(nodeRef, rule); - } - } - - /** - * @see org.alfresco.repo.rule.RuleServiceImpl#removeRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule) - */ - @Override - public void removeRule(final NodeRef nodeRef, final Rule rule) - { - if (filePlanService.isFilePlanComponent(nodeRef)) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - ExtendedRuleServiceImpl.super.removeRule(nodeRef, rule); - return null; - } - - }); - } - else - { - super.removeRule(nodeRef, rule); - } - } - - /** - * @see org.alfresco.repo.rule.RuleServiceImpl#executeRule(org.alfresco.service.cmr.rule.Rule, org.alfresco.service.cmr.repository.NodeRef, java.util.Set) - */ - @Override - public void executeRule(final Rule rule, final NodeRef nodeRef, final Set executedRules) - { - if (nodeService.exists(nodeRef)) - { - QName typeQName = nodeService.getType(nodeRef); - if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName)) - { - // check if this is a rm rule on a rm artifact - if (filePlanService.isFilePlanComponent(nodeRef) && - isFilePlanComponentRule(rule)) - { - // ignore and - if (!isIgnoredType(typeQName)) - { - if (runAsAdmin) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() - { - ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules); - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - else - { - // run as current user - ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules); - } - } - } - else - { - // just execute the rule as the current user - super.executeRule(rule, nodeRef, executedRules); - } - } - } - } - - /** - * Indicates whether the rule is a file plan component - * - * @param rule rule - * @return boolean true if rule is set on a file plan component, false otherwise - */ - private boolean isFilePlanComponentRule(Rule rule) - { - NodeRef nodeRef = getOwningNodeRef(rule); - return filePlanService.isFilePlanComponent(nodeRef); - } - - /** - * @param typeQName type qname - * @return boolean true if ignore type, false otherwise - */ - private boolean isIgnoredType(QName typeQName) - { - return ignoredTypes.contains(typeQName); - } - - /** - * Check if the rule is associated with the file plan component that the node it is being - * applied to isn't a hold container, a hold, a transfer container, a transfer, an unfiled - * record container, an unfiled record folder or unfiled content - * - * @param rule - * @param nodeRef - * @param typeQName - * @return - */ - private boolean shouldRuleBeAppliedToNode(Rule rule, NodeRef nodeRef, QName typeQName) - { - boolean result = true; - NodeRef ruleNodeRef = getOwningNodeRef(rule); - if(filePlanService.isFilePlan(ruleNodeRef)) - { - // if this rule is defined at the root of the file plan then we do not want to apply - // it to holds/transfers/unfiled content... - result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) || - RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || - !recordService.isFiled(nodeRef)); - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.rule; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.rule.Rule; +import org.alfresco.service.namespace.QName; + +/** + * Extended rule service implementation. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ExtendedRuleServiceImpl extends RuleServiceImpl +{ + /** indicates whether the rules should be run as admin or not */ + private boolean runAsAdmin = true; + + /** ignore types */ + private Set ignoredTypes = new HashSet(); + + /** file plan service */ + private FilePlanService filePlanService; + + /** node service */ + protected NodeService nodeService; + + /** Record service */ + protected RecordService recordService; + + /** + * @param nodeService node service + */ + public void setNodeService2(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param runAsAdmin true if run rules as admin, false otherwise + */ + public void setRunAsAdmin(boolean runAsAdmin) + { + this.runAsAdmin = runAsAdmin; + } + + /** + * Init method + */ + @Override + public void init() + { + super.init(); + + // Specify a set of system types to be ignored by rule executions + ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE); + ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_ACTION); + ignoredTypes.add(RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION); + ignoredTypes.add(RecordsManagementModel.TYPE_EVENT_EXECUTION); + } + + /** + * @see org.alfresco.repo.rule.RuleServiceImpl#saveRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule) + */ + @Override + public void saveRule(final NodeRef nodeRef, final Rule rule) + { + if (filePlanService.isFilePlanComponent(nodeRef)) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + ExtendedRuleServiceImpl.super.saveRule(nodeRef, rule); + return null; + } + + }); + } + else + { + super.saveRule(nodeRef, rule); + } + } + + /** + * @see org.alfresco.repo.rule.RuleServiceImpl#removeRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule) + */ + @Override + public void removeRule(final NodeRef nodeRef, final Rule rule) + { + if (filePlanService.isFilePlanComponent(nodeRef)) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + ExtendedRuleServiceImpl.super.removeRule(nodeRef, rule); + return null; + } + + }); + } + else + { + super.removeRule(nodeRef, rule); + } + } + + /** + * @see org.alfresco.repo.rule.RuleServiceImpl#executeRule(org.alfresco.service.cmr.rule.Rule, org.alfresco.service.cmr.repository.NodeRef, java.util.Set) + */ + @Override + public void executeRule(final Rule rule, final NodeRef nodeRef, final Set executedRules) + { + if (nodeService.exists(nodeRef)) + { + QName typeQName = nodeService.getType(nodeRef); + if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName)) + { + // check if this is a rm rule on a rm artifact + if (filePlanService.isFilePlanComponent(nodeRef) && + isFilePlanComponentRule(rule)) + { + // ignore and + if (!isIgnoredType(typeQName)) + { + if (runAsAdmin) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() + { + ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules); + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + else + { + // run as current user + ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules); + } + } + } + else + { + // just execute the rule as the current user + super.executeRule(rule, nodeRef, executedRules); + } + } + } + } + + /** + * Indicates whether the rule is a file plan component + * + * @param rule rule + * @return boolean true if rule is set on a file plan component, false otherwise + */ + private boolean isFilePlanComponentRule(Rule rule) + { + NodeRef nodeRef = getOwningNodeRef(rule); + return filePlanService.isFilePlanComponent(nodeRef); + } + + /** + * @param typeQName type qname + * @return boolean true if ignore type, false otherwise + */ + private boolean isIgnoredType(QName typeQName) + { + return ignoredTypes.contains(typeQName); + } + + /** + * Check if the rule is associated with the file plan component that the node it is being + * applied to isn't a hold container, a hold, a transfer container, a transfer, an unfiled + * record container, an unfiled record folder or unfiled content + * + * @param rule + * @param nodeRef + * @param typeQName + * @return + */ + private boolean shouldRuleBeAppliedToNode(Rule rule, NodeRef nodeRef, QName typeQName) + { + boolean result = true; + NodeRef ruleNodeRef = getOwningNodeRef(rule); + if(filePlanService.isFilePlan(ruleNodeRef)) + { + // if this rule is defined at the root of the file plan then we do not want to apply + // it to holds/transfers/unfiled content... + result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) || + RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) || + RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) || + RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) || + RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) || + RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || + nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || + nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || + !recordService.isFiled(nodeRef)); + } + return result; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/rule/ruletrigger/ExtendedBeforeDeleteChildAssociationRuleTrigger.java b/rm-server/source/java/org/alfresco/repo/rule/ruletrigger/ExtendedBeforeDeleteChildAssociationRuleTrigger.java index 54cd9aa031..a56326592a 100644 --- a/rm-server/source/java/org/alfresco/repo/rule/ruletrigger/ExtendedBeforeDeleteChildAssociationRuleTrigger.java +++ b/rm-server/source/java/org/alfresco/repo/rule/ruletrigger/ExtendedBeforeDeleteChildAssociationRuleTrigger.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.rule.ruletrigger; - -import java.util.Set; - -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.transaction.TransactionalResourceHelper; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Prevent multiple triggering of outbound rules when moving records. - * - * @author Roy Wetherall - */ -public class ExtendedBeforeDeleteChildAssociationRuleTrigger - extends RuleTriggerAbstractBase - implements NodeServicePolicies.BeforeDeleteChildAssociationPolicy -{ - /** - * The logger - */ - private static Log logger = LogFactory.getLog(BeforeDeleteChildAssociationRuleTrigger.class); - - private static final String POLICY = "beforeDeleteChildAssociation"; - - private boolean isClassBehaviour = false; - - public void setIsClassBehaviour(boolean isClassBehaviour) - { - this.isClassBehaviour = isClassBehaviour; - } - - /** - * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger() - */ - public void registerRuleTrigger() - { - if (isClassBehaviour) - { - this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), - this, - new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT)); - } - else - { - this.policyComponent.bindAssociationBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), - this, - new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT)); - } - } - - public void beforeDeleteChildAssociation(ChildAssociationRef childAssocRef) - { - // Break out early if rules are not enabled - if (!areRulesEnabled()) - { - return; - } - - NodeRef childNodeRef = childAssocRef.getChildRef(); - - // Avoid renamed nodes - Set renamedNodeRefSet = TransactionalResourceHelper.getSet(RULE_TRIGGER_RENAMED_NODES); - if (renamedNodeRefSet.contains(childNodeRef)) - { - return; - } - - if (logger.isDebugEnabled()) - { - logger.debug("Single child assoc trigger (policy = " + POLICY + ") fired for parent node " + childAssocRef.getParentRef() + " and child node " + childAssocRef.getChildRef()); - } - - triggerRules(childAssocRef.getParentRef(), childNodeRef); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.rule.ruletrigger; + +import java.util.Set; + +import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.transaction.TransactionalResourceHelper; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Prevent multiple triggering of outbound rules when moving records. + * + * @author Roy Wetherall + */ +public class ExtendedBeforeDeleteChildAssociationRuleTrigger + extends RuleTriggerAbstractBase + implements NodeServicePolicies.BeforeDeleteChildAssociationPolicy +{ + /** + * The logger + */ + private static Log logger = LogFactory.getLog(BeforeDeleteChildAssociationRuleTrigger.class); + + private static final String POLICY = "beforeDeleteChildAssociation"; + + private boolean isClassBehaviour = false; + + public void setIsClassBehaviour(boolean isClassBehaviour) + { + this.isClassBehaviour = isClassBehaviour; + } + + /** + * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger() + */ + public void registerRuleTrigger() + { + if (isClassBehaviour) + { + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), + this, + new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT)); + } + else + { + this.policyComponent.bindAssociationBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), + this, + new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT)); + } + } + + public void beforeDeleteChildAssociation(ChildAssociationRef childAssocRef) + { + // Break out early if rules are not enabled + if (!areRulesEnabled()) + { + return; + } + + NodeRef childNodeRef = childAssocRef.getChildRef(); + + // Avoid renamed nodes + Set renamedNodeRefSet = TransactionalResourceHelper.getSet(RULE_TRIGGER_RENAMED_NODES); + if (renamedNodeRefSet.contains(childNodeRef)) + { + return; + } + + if (logger.isDebugEnabled()) + { + logger.debug("Single child assoc trigger (policy = " + POLICY + ") fired for parent node " + childAssocRef.getParentRef() + " and child node " + childAssocRef.getChildRef()); + } + + triggerRules(childAssocRef.getParentRef(), childNodeRef); + } + +} diff --git a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthority.java b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthority.java index 4342662b1f..55fd146d50 100644 --- a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthority.java +++ b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthority.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.security.authority; - -/** - * Interface for defining constants - * - * @author Tuna Aksoy - * @since 2.1 - */ -public interface RMAuthority -{ - /** - * The default rm zone. - */ - String ZONE_APP_RM = "APP.RM"; - - /** - * The constant for all roles display name - */ - String ALL_ROLES_DISPLAY_NAME = "All Roles"; - - /** - * The constant for all roles prefix - */ - String ALL_ROLES_PREFIX = "AllRoles"; -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.security.authority; + +/** + * Interface for defining constants + * + * @author Tuna Aksoy + * @since 2.1 + */ +public interface RMAuthority +{ + /** + * The default rm zone. + */ + String ZONE_APP_RM = "APP.RM"; + + /** + * The constant for all roles display name + */ + String ALL_ROLES_DISPLAY_NAME = "All Roles"; + + /** + * The constant for all roles prefix + */ + String ALL_ROLES_PREFIX = "AllRoles"; +} diff --git a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java index 96435aacd6..3060acf8b2 100644 --- a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java +++ b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java @@ -1,81 +1,81 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.security.authority; - -import java.util.Set; -import java.util.regex.Pattern; - -import org.alfresco.service.cmr.security.AuthorityType; - -/** - * This class extends {@link AuthorityDAOImpl}
- * and overrides two methods from the original class
- *
- * addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type)
- *
- * and
- *
- * addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern)
- */ -public class RMAuthorityDAOImpl extends AuthorityDAOImpl -{ - protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type) - { - if (isAuthorityNameMatching(authorityName, type)) - { - authorities.add(authorityName); - } - } - - protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern) - { - if (isAuthorityNameMatching(authorityName, type)) - { - if (pattern == null) - { - authorities.add(authorityName); - } - else - { - if (pattern.matcher(getShortName(authorityName)).matches()) - { - authorities.add(authorityName); - } - else - { - String displayName = getAuthorityDisplayName(authorityName); - if (displayName != null && pattern.matcher(displayName).matches()) - { - authorities.add(authorityName); - } - } - } - } - } - - private boolean isAuthorityNameMatching(String authorityName, AuthorityType type) - { - boolean isMatching = false; - if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type) && !getAuthorityZones(authorityName).contains("APP.RM")) - { - isMatching = true; - } - return isMatching; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.security.authority; + +import java.util.Set; +import java.util.regex.Pattern; + +import org.alfresco.service.cmr.security.AuthorityType; + +/** + * This class extends {@link AuthorityDAOImpl}
+ * and overrides two methods from the original class
+ *
+ * addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type)
+ *
+ * and
+ *
+ * addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern)
+ */ +public class RMAuthorityDAOImpl extends AuthorityDAOImpl +{ + protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type) + { + if (isAuthorityNameMatching(authorityName, type)) + { + authorities.add(authorityName); + } + } + + protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern) + { + if (isAuthorityNameMatching(authorityName, type)) + { + if (pattern == null) + { + authorities.add(authorityName); + } + else + { + if (pattern.matcher(getShortName(authorityName)).matches()) + { + authorities.add(authorityName); + } + else + { + String displayName = getAuthorityDisplayName(authorityName); + if (displayName != null && pattern.matcher(displayName).matches()) + { + authorities.add(authorityName); + } + } + } + } + } + + private boolean isAuthorityNameMatching(String authorityName, AuthorityType type) + { + boolean isMatching = false; + if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type) && !getAuthorityZones(authorityName).contains("APP.RM")) + { + isMatching = true; + } + return isMatching; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java index 6fcce8196d..652437c3de 100644 --- a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java +++ b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.security.permissions.impl; - -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.util.Pair; - -/** - * Extended Permission Service Interface used in RM. - * - * @author Roy Wetherall - * @since 2.1 - */ -public interface ExtendedPermissionService extends PermissionService -{ - Set getWriters(Long aclId); - - /** - * Get the readers and writers for a given node. - *

- * The writers list includes the owner for the node. - * - * @param nodeRef node reference - * @return Pair, Set> first is a set containing all the authorities that have read permission on the - * document and second is a set containing all the authorities that have write - * permission on the document, including the owner. - * - * @since 2.5 - */ - Pair, Set> getReadersAndWriters(NodeRef nodeRef); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.security.permissions.impl; + +import java.util.Set; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.util.Pair; + +/** + * Extended Permission Service Interface used in RM. + * + * @author Roy Wetherall + * @since 2.1 + */ +public interface ExtendedPermissionService extends PermissionService +{ + Set getWriters(Long aclId); + + /** + * Get the readers and writers for a given node. + *

+ * The writers list includes the owner for the node. + * + * @param nodeRef node reference + * @return Pair, Set> first is a set containing all the authorities that have read permission on the + * document and second is a set containing all the authorities that have write + * permission on the document, including the owner. + * + * @since 2.5 + */ + Pair, Set> getReadersAndWriters(NodeRef nodeRef); +} diff --git a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/RMPermissionServiceImpl.java b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/RMPermissionServiceImpl.java index c2b7e30cbb..da1f851615 100644 --- a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/RMPermissionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/RMPermissionServiceImpl.java @@ -1,352 +1,352 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.security.permissions.impl; - -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.security.permissions.AccessControlEntry; -import org.alfresco.repo.security.permissions.AccessControlList; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.util.Pair; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.lang.StringUtils; -import org.springframework.context.ApplicationEvent; - -/** - * Extends the core permission service implementation allowing the consideration of the read records - * permission. - *

- * This is required for SOLR support. - * - * @author Roy Wetherall - */ -public class RMPermissionServiceImpl extends PermissionServiceImpl - implements ExtendedPermissionService -{ - /** Writers simple cache */ - protected SimpleCache> writersCache; - - /** File plan service */ - private FilePlanService filePlanService; - - /** - * Gets the file plan service - * - * @return the filePlanService - */ - public FilePlanService getFilePlanService() - { - return this.filePlanService; - } - - /** - * Sets the file plan service - * - * @param filePlanService the filePlanService to set - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#setAnyDenyDenies(boolean) - */ - @Override - public void setAnyDenyDenies(boolean anyDenyDenies) - { - super.setAnyDenyDenies(anyDenyDenies); - writersCache.clear(); - } - - /** - * @param writersCache the writersCache to set - */ - public void setWritersCache(SimpleCache> writersCache) - { - this.writersCache = writersCache; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent) - */ - @Override - protected void onBootstrap(ApplicationEvent event) - { - super.onBootstrap(event); - PropertyCheck.mandatory(this, "writersCache", writersCache); - } - - /** - * Override to deal with the possibility of hard coded permission checks in core code. - * - * Note: Eventually we need to merge the RM permission model into the core to make this more rebust. - * - * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#hasPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public AccessStatus hasPermission(NodeRef nodeRef, String perm) - { - AccessStatus acs = super.hasPermission(nodeRef, perm); - if (AccessStatus.DENIED.equals(acs) && - PermissionService.READ.equals(perm) && - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - return super.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS); - } - else if (AccessStatus.DENIED.equals(acs) && - PermissionService.WRITE.equals(perm) && - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) - { - return super.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS); - } - - return acs; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#canRead(java.lang.Long) - */ - @Override - protected AccessStatus canRead(Long aclId) - { - Set authorities = getAuthorisations(); - - // test denied - - if(anyDenyDenies) - { - - Set aclReadersDenied = getReadersDenied(aclId); - - for(String auth : aclReadersDenied) - { - if(authorities.contains(auth)) - { - return AccessStatus.DENIED; - } - } - - } - - // test acl readers - Set aclReaders = getReaders(aclId); - - for(String auth : aclReaders) - { - if(authorities.contains(auth)) - { - return AccessStatus.ALLOWED; - } - } - - return AccessStatus.DENIED; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#getReaders(java.lang.Long) - */ - @Override - public Set getReaders(Long aclId) - { - AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); - if (acl == null) - { - return Collections.emptySet(); - } - - Set aclReaders = readersCache.get((Serializable)acl.getProperties()); - if (aclReaders != null) - { - return aclReaders; - } - - HashSet assigned = new HashSet(); - HashSet readers = new HashSet(); - - for (AccessControlEntry ace : acl.getEntries()) - { - assigned.add(ace.getAuthority()); - } - - for (String authority : assigned) - { - UnconditionalAclTest test = new UnconditionalAclTest(getPermissionReference(PermissionService.READ)); - UnconditionalAclTest rmTest = new UnconditionalAclTest(getPermissionReference(RMPermissionModel.READ_RECORDS)); - if (test.evaluate(authority, aclId) || rmTest.evaluate(authority, aclId)) - { - readers.add(authority); - } - } - - aclReaders = Collections.unmodifiableSet(readers); - readersCache.put((Serializable)acl.getProperties(), aclReaders); - return aclReaders; - } - - /** - * Override with check for RM read - * - * @param aclId - * @return - */ - public Set getReadersDenied(Long aclId) - { - AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); - - if (acl == null) - { - return Collections.emptySet(); - } - Set denied = readersDeniedCache.get(aclId); - if (denied != null) - { - return denied; - } - denied = new HashSet(); - Set assigned = new HashSet(); - - for (AccessControlEntry ace : acl.getEntries()) - { - assigned.add(ace.getAuthority()); - } - - for(String authority : assigned) - { - UnconditionalDeniedAclTest test = new UnconditionalDeniedAclTest(getPermissionReference(PermissionService.READ)); - UnconditionalDeniedAclTest rmTest = new UnconditionalDeniedAclTest(getPermissionReference(RMPermissionModel.READ_RECORDS)); - if(test.evaluate(authority, aclId) || rmTest.evaluate(authority, aclId)) - { - denied.add(authority); - } - } - - readersDeniedCache.put((Serializable)acl.getProperties(), denied); - - return denied; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#getWriters(java.lang.Long) - */ - public Set getWriters(Long aclId) - { - AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); - if (acl == null) - { - return Collections.emptySet(); - } - - Set aclWriters = writersCache.get((Serializable)acl.getProperties()); - if (aclWriters != null) - { - return aclWriters; - } - - HashSet assigned = new HashSet(); - HashSet readers = new HashSet(); - - for (AccessControlEntry ace : acl.getEntries()) - { - assigned.add(ace.getAuthority()); - } - - for (String authority : assigned) - { - UnconditionalAclTest test = new UnconditionalAclTest(getPermissionReference(PermissionService.WRITE)); - if (test.evaluate(authority, aclId)) - { - readers.add(authority); - } - } - - aclWriters = Collections.unmodifiableSet(readers); - writersCache.put((Serializable)acl.getProperties(), aclWriters); - return aclWriters; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#setInheritParentPermissions(org.alfresco.service.cmr.repository.NodeRef, boolean) - */ - @Override - public void setInheritParentPermissions(final NodeRef nodeRef, boolean inheritParentPermissions) - { - final String adminRole = getAdminRole(nodeRef); - if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) && isNotBlank(adminRole) && !inheritParentPermissions) - { - setPermission(nodeRef, adminRole, RMPermissionModel.FILING, true); - } - super.setInheritParentPermissions(nodeRef, inheritParentPermissions); - } - - /** - * Helper method to the RM admin role scoped by the correct file plan. - * - * @param nodeRef node reference - * @return String RM admin role - */ - private String getAdminRole(NodeRef nodeRef) - { - String adminRole = null; - NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); - if (filePlan != null) - { - adminRole = authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); - } - return adminRole; - } - - /** - * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#getReadersAndWriters(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public Pair, Set> getReadersAndWriters(NodeRef nodeRef) - { - // get the documents readers - Long aclId = nodeService.getNodeAclId(nodeRef); - Set readers = getReaders(aclId); - Set writers = getWriters(aclId); - - // add the current owner to the list of extended writers - Set modifiedWrtiers = new HashSet(writers); - String owner = ownableService.getOwner(nodeRef); - if (StringUtils.isNotBlank(owner) && - !owner.equals(OwnableService.NO_OWNER) && - authorityService.authorityExists(owner)) - { - modifiedWrtiers.add(owner); - } - - return new Pair, Set> (readers, modifiedWrtiers); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.security.permissions.impl; + +import static org.apache.commons.lang.StringUtils.isNotBlank; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.security.permissions.AccessControlEntry; +import org.alfresco.repo.security.permissions.AccessControlList; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.util.Pair; +import org.alfresco.util.PropertyCheck; +import org.apache.commons.lang.StringUtils; +import org.springframework.context.ApplicationEvent; + +/** + * Extends the core permission service implementation allowing the consideration of the read records + * permission. + *

+ * This is required for SOLR support. + * + * @author Roy Wetherall + */ +public class RMPermissionServiceImpl extends PermissionServiceImpl + implements ExtendedPermissionService +{ + /** Writers simple cache */ + protected SimpleCache> writersCache; + + /** File plan service */ + private FilePlanService filePlanService; + + /** + * Gets the file plan service + * + * @return the filePlanService + */ + public FilePlanService getFilePlanService() + { + return this.filePlanService; + } + + /** + * Sets the file plan service + * + * @param filePlanService the filePlanService to set + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#setAnyDenyDenies(boolean) + */ + @Override + public void setAnyDenyDenies(boolean anyDenyDenies) + { + super.setAnyDenyDenies(anyDenyDenies); + writersCache.clear(); + } + + /** + * @param writersCache the writersCache to set + */ + public void setWritersCache(SimpleCache> writersCache) + { + this.writersCache = writersCache; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onBootstrap(ApplicationEvent event) + { + super.onBootstrap(event); + PropertyCheck.mandatory(this, "writersCache", writersCache); + } + + /** + * Override to deal with the possibility of hard coded permission checks in core code. + * + * Note: Eventually we need to merge the RM permission model into the core to make this more rebust. + * + * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#hasPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) + */ + @Override + public AccessStatus hasPermission(NodeRef nodeRef, String perm) + { + AccessStatus acs = super.hasPermission(nodeRef, perm); + if (AccessStatus.DENIED.equals(acs) && + PermissionService.READ.equals(perm) && + nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + return super.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS); + } + else if (AccessStatus.DENIED.equals(acs) && + PermissionService.WRITE.equals(perm) && + nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) + { + return super.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS); + } + + return acs; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#canRead(java.lang.Long) + */ + @Override + protected AccessStatus canRead(Long aclId) + { + Set authorities = getAuthorisations(); + + // test denied + + if(anyDenyDenies) + { + + Set aclReadersDenied = getReadersDenied(aclId); + + for(String auth : aclReadersDenied) + { + if(authorities.contains(auth)) + { + return AccessStatus.DENIED; + } + } + + } + + // test acl readers + Set aclReaders = getReaders(aclId); + + for(String auth : aclReaders) + { + if(authorities.contains(auth)) + { + return AccessStatus.ALLOWED; + } + } + + return AccessStatus.DENIED; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#getReaders(java.lang.Long) + */ + @Override + public Set getReaders(Long aclId) + { + AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); + if (acl == null) + { + return Collections.emptySet(); + } + + Set aclReaders = readersCache.get((Serializable)acl.getProperties()); + if (aclReaders != null) + { + return aclReaders; + } + + HashSet assigned = new HashSet(); + HashSet readers = new HashSet(); + + for (AccessControlEntry ace : acl.getEntries()) + { + assigned.add(ace.getAuthority()); + } + + for (String authority : assigned) + { + UnconditionalAclTest test = new UnconditionalAclTest(getPermissionReference(PermissionService.READ)); + UnconditionalAclTest rmTest = new UnconditionalAclTest(getPermissionReference(RMPermissionModel.READ_RECORDS)); + if (test.evaluate(authority, aclId) || rmTest.evaluate(authority, aclId)) + { + readers.add(authority); + } + } + + aclReaders = Collections.unmodifiableSet(readers); + readersCache.put((Serializable)acl.getProperties(), aclReaders); + return aclReaders; + } + + /** + * Override with check for RM read + * + * @param aclId + * @return + */ + public Set getReadersDenied(Long aclId) + { + AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); + + if (acl == null) + { + return Collections.emptySet(); + } + Set denied = readersDeniedCache.get(aclId); + if (denied != null) + { + return denied; + } + denied = new HashSet(); + Set assigned = new HashSet(); + + for (AccessControlEntry ace : acl.getEntries()) + { + assigned.add(ace.getAuthority()); + } + + for(String authority : assigned) + { + UnconditionalDeniedAclTest test = new UnconditionalDeniedAclTest(getPermissionReference(PermissionService.READ)); + UnconditionalDeniedAclTest rmTest = new UnconditionalDeniedAclTest(getPermissionReference(RMPermissionModel.READ_RECORDS)); + if(test.evaluate(authority, aclId) || rmTest.evaluate(authority, aclId)) + { + denied.add(authority); + } + } + + readersDeniedCache.put((Serializable)acl.getProperties(), denied); + + return denied; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#getWriters(java.lang.Long) + */ + public Set getWriters(Long aclId) + { + AccessControlList acl = aclDaoComponent.getAccessControlList(aclId); + if (acl == null) + { + return Collections.emptySet(); + } + + Set aclWriters = writersCache.get((Serializable)acl.getProperties()); + if (aclWriters != null) + { + return aclWriters; + } + + HashSet assigned = new HashSet(); + HashSet readers = new HashSet(); + + for (AccessControlEntry ace : acl.getEntries()) + { + assigned.add(ace.getAuthority()); + } + + for (String authority : assigned) + { + UnconditionalAclTest test = new UnconditionalAclTest(getPermissionReference(PermissionService.WRITE)); + if (test.evaluate(authority, aclId)) + { + readers.add(authority); + } + } + + aclWriters = Collections.unmodifiableSet(readers); + writersCache.put((Serializable)acl.getProperties(), aclWriters); + return aclWriters; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#setInheritParentPermissions(org.alfresco.service.cmr.repository.NodeRef, boolean) + */ + @Override + public void setInheritParentPermissions(final NodeRef nodeRef, boolean inheritParentPermissions) + { + final String adminRole = getAdminRole(nodeRef); + if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) && isNotBlank(adminRole) && !inheritParentPermissions) + { + setPermission(nodeRef, adminRole, RMPermissionModel.FILING, true); + } + super.setInheritParentPermissions(nodeRef, inheritParentPermissions); + } + + /** + * Helper method to the RM admin role scoped by the correct file plan. + * + * @param nodeRef node reference + * @return String RM admin role + */ + private String getAdminRole(NodeRef nodeRef) + { + String adminRole = null; + NodeRef filePlan = getFilePlanService().getFilePlan(nodeRef); + if (filePlan != null) + { + adminRole = authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); + } + return adminRole; + } + + /** + * @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#getReadersAndWriters(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public Pair, Set> getReadersAndWriters(NodeRef nodeRef) + { + // get the documents readers + Long aclId = nodeService.getNodeAclId(nodeRef); + Set readers = getReaders(aclId); + Set writers = getWriters(aclId); + + // add the current owner to the list of extended writers + Set modifiedWrtiers = new HashSet(writers); + String owner = ownableService.getOwner(nodeRef); + if (StringUtils.isNotBlank(owner) && + !owner.equals(OwnableService.NO_OWNER) && + authorityService.authorityExists(owner)) + { + modifiedWrtiers.add(owner); + } + + return new Pair, Set> (readers, modifiedWrtiers); + } +} diff --git a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/acegi/RMACLEntryVoter.java b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/acegi/RMACLEntryVoter.java index 75f65f2eaf..670a37daa8 100644 --- a/rm-server/source/java/org/alfresco/repo/security/permissions/impl/acegi/RMACLEntryVoter.java +++ b/rm-server/source/java/org/alfresco/repo/security/permissions/impl/acegi/RMACLEntryVoter.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.security.permissions.impl.acegi; - -import java.lang.reflect.Method; - -import org.alfresco.service.cmr.security.OwnableService; - -/** - * This is a workaround to make RM 2.1 backwards compatible with the Community version 4.2.d. - * This class will be removed after Community 4.2.e has been released. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RMACLEntryVoter extends ACLEntryVoter -{ - public void setOwnableService(OwnableService ownableService) - { - boolean exists = false; - Method[] declaredMethods = ACLEntryVoter.class.getDeclaredMethods(); - for (Method method : declaredMethods) - { - if (method.getName().equals("setOwnableService")) - { - exists = true; - break; - } - } - if (exists) - { - super.setOwnableService(ownableService); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.security.permissions.impl.acegi; + +import java.lang.reflect.Method; + +import org.alfresco.service.cmr.security.OwnableService; + +/** + * This is a workaround to make RM 2.1 backwards compatible with the Community version 4.2.d. + * This class will be removed after Community 4.2.e has been released. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RMACLEntryVoter extends ACLEntryVoter +{ + public void setOwnableService(OwnableService ownableService) + { + boolean exists = false; + Method[] declaredMethods = ACLEntryVoter.class.getDeclaredMethods(); + for (Method method : declaredMethods) + { + if (method.getName().equals("setOwnableService")) + { + exists = true; + break; + } + } + if (exists) + { + super.setOwnableService(ownableService); + } + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java index 265ecc9941..52049cdc27 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java @@ -1,241 +1,241 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.dictionary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Webscript to get the Classdefinitions using classfilter , namespaceprefix and name - * - * This class makes it possible to get only RM related class definitions - * @see ClassesGet for the original implementation - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmClassesGet extends DictionaryWebServiceBase implements RecordsManagementModel -{ - private static final String MODEL_PROP_KEY_CLASS_DEFS = "classdefs"; - private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs"; - private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs"; - - private static final String CLASS_FILTER_OPTION_TYPE1 = "all"; - private static final String CLASS_FILTER_OPTION_TYPE2 = "aspect"; - private static final String CLASS_FILTER_OPTION_TYPE3 = "type"; - - private static final String REQ_URL_TEMPL_VAR_CLASS_FILTER = "cf"; - private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp"; - private static final String REQ_URL_TEMPL_VAR_NAME = "n"; - - /** Site service*/ - private SiteService siteService; - - /** - * @param siteService the site service to set - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - return executeImpl(req, RmDictionaryWebServiceUtils.isRmSite(req, siteService)); - } - - /** - * Execute custom Java logic - * - * @param req Web Script request - * @param isRM indicates whether the request comes from an RM site or not - * @return custom service model - */ - private Map executeImpl(WebScriptRequest req, boolean isRM) - { - String classFilter = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER)); - String namespacePrefix = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX)); - String name = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME)); - String className = null; - - Map classdef = new HashMap(); - Map> propdef = new HashMap>(); - Map> assocdef = new HashMap>(); - Map model = new HashMap(); - - List qnames = new ArrayList(); - QName classQname = null; - QName myModel = null; - - //if classfilter is not given, then it defaults to all - if (classFilter == null) - { - classFilter = "all"; - } - - //validate classfilter - if (!isValidClassFilter(classFilter)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classFilter + " provided in the URL"); - } - - //name alone has no meaning without namespaceprefix - if (namespacePrefix == null && name != null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed"); - } - - //validate the namespaceprefix and name parameters => if namespaceprefix is given, then name has to be validated along with it - if (namespacePrefix != null) - { - //validate name parameter if present along with the namespaceprefix - if (name != null) - { - className = namespacePrefix + "_" + name; - if (!isValidClassname(className)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL"); - } - classQname = QName.createQName(getFullNamespaceURI(className)); - classdef.put(classQname, this.dictionaryservice.getClass(classQname)); - propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values()); - assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values()); - } - else - { - //if name is not given then the model is extracted from the namespaceprefix, there can be more than one model associated with one namespaceprefix - String namespaceUri = namespaceService.getNamespaceURI(namespacePrefix); - for (QName qnameObj : this.dictionaryservice.getAllModels()) - { - if (qnameObj.getNamespaceURI().equals(namespaceUri)) - { - name = qnameObj.getLocalName(); - myModel = QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name)); - - // check the classfilter to pull out either all or type or aspects - if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) - { - qnames.addAll(this.dictionaryservice.getAspects(myModel)); - qnames.addAll(this.dictionaryservice.getTypes(myModel)); - } - else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) - { - qnames.addAll(this.dictionaryservice.getTypes(myModel)); - } - else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) - { - qnames.addAll(this.dictionaryservice.getAspects(myModel)); - } - } - } - } - } - - // if namespacePrefix is null, then check the class filter to pull out either all, type or aspects - if (myModel == null) - { - if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) - { - qnames.addAll(getAspects(isRM)); - qnames.addAll(getTypes(isRM)); - } - else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) - { - qnames.addAll(getTypes(isRM)); - } - else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) - { - qnames.addAll(getAspects(isRM)); - } - } - - if (classdef.isEmpty()) - { - for (QName qnameObj : qnames) - { - classdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj)); - propdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getProperties().values()); - assocdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getAssociations().values()); - } - } - - List classDefinitions = new ArrayList(classdef.values()); - Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); - model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); - model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values()); - model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values()); - model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); - - return model; - } - - /** - * Returns the names of the types depending on {@link isRM} parameter - * - * @param isRM if true only RM related types will be retrieved - * @return The names of the types defined within the specified model or all of them depending on {@link isRM} parameter - */ - private Collection getTypes(boolean isRM) - { - if (isRM) - { - return this.dictionaryservice.getTypes(RM_MODEL); - } - else - { - return this.dictionaryservice.getAllTypes(); - } - } - - /** - * Returns the names of the aspects depending on {@link isRM} parameter - * - * @param isRM if true only RM related aspects will be retrieved - * @return The names of the aspects defined within the specified model or all of them depending on {@link isRM} parameter - */ - private Collection getAspects(boolean isRM) - { - if (isRM) - { - return this.dictionaryservice.getAspects(RM_MODEL); - } - else - { - return this.dictionaryservice.getAllAspects(); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.dictionary; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.ClassDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Webscript to get the Classdefinitions using classfilter , namespaceprefix and name + * + * This class makes it possible to get only RM related class definitions + * @see ClassesGet for the original implementation + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmClassesGet extends DictionaryWebServiceBase implements RecordsManagementModel +{ + private static final String MODEL_PROP_KEY_CLASS_DEFS = "classdefs"; + private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs"; + private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs"; + + private static final String CLASS_FILTER_OPTION_TYPE1 = "all"; + private static final String CLASS_FILTER_OPTION_TYPE2 = "aspect"; + private static final String CLASS_FILTER_OPTION_TYPE3 = "type"; + + private static final String REQ_URL_TEMPL_VAR_CLASS_FILTER = "cf"; + private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp"; + private static final String REQ_URL_TEMPL_VAR_NAME = "n"; + + /** Site service*/ + private SiteService siteService; + + /** + * @param siteService the site service to set + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + return executeImpl(req, RmDictionaryWebServiceUtils.isRmSite(req, siteService)); + } + + /** + * Execute custom Java logic + * + * @param req Web Script request + * @param isRM indicates whether the request comes from an RM site or not + * @return custom service model + */ + private Map executeImpl(WebScriptRequest req, boolean isRM) + { + String classFilter = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER)); + String namespacePrefix = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX)); + String name = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME)); + String className = null; + + Map classdef = new HashMap(); + Map> propdef = new HashMap>(); + Map> assocdef = new HashMap>(); + Map model = new HashMap(); + + List qnames = new ArrayList(); + QName classQname = null; + QName myModel = null; + + //if classfilter is not given, then it defaults to all + if (classFilter == null) + { + classFilter = "all"; + } + + //validate classfilter + if (!isValidClassFilter(classFilter)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classFilter + " provided in the URL"); + } + + //name alone has no meaning without namespaceprefix + if (namespacePrefix == null && name != null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed"); + } + + //validate the namespaceprefix and name parameters => if namespaceprefix is given, then name has to be validated along with it + if (namespacePrefix != null) + { + //validate name parameter if present along with the namespaceprefix + if (name != null) + { + className = namespacePrefix + "_" + name; + if (!isValidClassname(className)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL"); + } + classQname = QName.createQName(getFullNamespaceURI(className)); + classdef.put(classQname, this.dictionaryservice.getClass(classQname)); + propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values()); + assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values()); + } + else + { + //if name is not given then the model is extracted from the namespaceprefix, there can be more than one model associated with one namespaceprefix + String namespaceUri = namespaceService.getNamespaceURI(namespacePrefix); + for (QName qnameObj : this.dictionaryservice.getAllModels()) + { + if (qnameObj.getNamespaceURI().equals(namespaceUri)) + { + name = qnameObj.getLocalName(); + myModel = QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name)); + + // check the classfilter to pull out either all or type or aspects + if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) + { + qnames.addAll(this.dictionaryservice.getAspects(myModel)); + qnames.addAll(this.dictionaryservice.getTypes(myModel)); + } + else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) + { + qnames.addAll(this.dictionaryservice.getTypes(myModel)); + } + else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) + { + qnames.addAll(this.dictionaryservice.getAspects(myModel)); + } + } + } + } + } + + // if namespacePrefix is null, then check the class filter to pull out either all, type or aspects + if (myModel == null) + { + if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) + { + qnames.addAll(getAspects(isRM)); + qnames.addAll(getTypes(isRM)); + } + else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) + { + qnames.addAll(getTypes(isRM)); + } + else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) + { + qnames.addAll(getAspects(isRM)); + } + } + + if (classdef.isEmpty()) + { + for (QName qnameObj : qnames) + { + classdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj)); + propdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getProperties().values()); + assocdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getAssociations().values()); + } + } + + List classDefinitions = new ArrayList(classdef.values()); + Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); + model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); + model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values()); + model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values()); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); + + return model; + } + + /** + * Returns the names of the types depending on {@link isRM} parameter + * + * @param isRM if true only RM related types will be retrieved + * @return The names of the types defined within the specified model or all of them depending on {@link isRM} parameter + */ + private Collection getTypes(boolean isRM) + { + if (isRM) + { + return this.dictionaryservice.getTypes(RM_MODEL); + } + else + { + return this.dictionaryservice.getAllTypes(); + } + } + + /** + * Returns the names of the aspects depending on {@link isRM} parameter + * + * @param isRM if true only RM related aspects will be retrieved + * @return The names of the aspects defined within the specified model or all of them depending on {@link isRM} parameter + */ + private Collection getAspects(boolean isRM) + { + if (isRM) + { + return this.dictionaryservice.getAspects(RM_MODEL); + } + else + { + return this.dictionaryservice.getAllAspects(); + } + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java index 7013187876..7e20186129 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.dictionary; - -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Util class for dictionary web services - * - * @author Tuna Aksoy - * @since 2.1 - */ -public final class RmDictionaryWebServiceUtils -{ - private static final String SITE_ID = "siteId"; - private static final String SITE_PRESET = "rm-site-dashboard"; - - private RmDictionaryWebServiceUtils() - { - // Will not be called - } - - public static boolean isRmSite(WebScriptRequest req, SiteService siteService) - { - boolean isRmSite = false; - String siteId = req.getParameter(SITE_ID); - if (StringUtils.isNotBlank(siteId)) - { - SiteInfo site = siteService.getSite(siteId); - if (site != null && site.getSitePreset().equals(SITE_PRESET)) - { - isRmSite = true; - } - } - return isRmSite; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.dictionary; + +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Util class for dictionary web services + * + * @author Tuna Aksoy + * @since 2.1 + */ +public final class RmDictionaryWebServiceUtils +{ + private static final String SITE_ID = "siteId"; + private static final String SITE_PRESET = "rm-site-dashboard"; + + private RmDictionaryWebServiceUtils() + { + // Will not be called + } + + public static boolean isRmSite(WebScriptRequest req, SiteService siteService) + { + boolean isRmSite = false; + String siteId = req.getParameter(SITE_ID); + if (StringUtils.isNotBlank(siteId)) + { + SiteInfo site = siteService.getSite(siteId); + if (site != null && site.getSitePreset().equals(SITE_PRESET)) + { + isRmSite = true; + } + } + return isRmSite; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java index 31656bd1e9..e00fd8583b 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java @@ -1,175 +1,175 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.dictionary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Webscript to get the Propertydefinitions for a given classname eg. =>cm_person - * - * This class makes it possible to get only RM related property definitions - * @see PropertiesGet for the original implementation - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmPropertiesGet extends DictionaryWebServiceBase implements RecordsManagementModel -{ - private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs"; - private static final String DICTIONARY_CLASS_NAME = "classname"; - private static final String PARAM_NAME = "name"; - private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp"; - - /** Site service*/ - private SiteService siteService; - - /** - * @param siteService the site service to set - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - return executeImpl(req, RmDictionaryWebServiceUtils.isRmSite(req, siteService)); - } - - /** - * Execute custom Java logic - * - * @param req Web Script request - * @param isRM indicates whether the request comes from an RM site or not - * @return custom service model - */ - private Map executeImpl(WebScriptRequest req, boolean isRM) - { - QName classQName = null; - String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME); - if (className != null && className.length() != 0) - { - classQName = createClassQName(className); - if (classQName == null) - { - // Error - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL"); - } - } - - String[] names = req.getParameterValues(PARAM_NAME); - - String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX); - String namespaceURI = null; - if (namespacePrefix != null) - { - namespaceURI = this.namespaceService.getNamespaceURI(namespacePrefix); - } - - Map propMap = null; - if (classQName == null) - { - if (names != null) - { - propMap = new HashMap(names.length); - for (String name : names) - { - QName propQName = QName.createQName(name, namespaceService); - PropertyDefinition propDef = dictionaryservice.getProperty(propQName); - if (propDef != null) - { - propMap.put(propQName, propDef); - } - } - } - else - { - Collection propQNames = getProperties(isRM); - propMap = new HashMap(propQNames.size()); - for (QName propQName : propQNames) - { - propMap.put(propQName, dictionaryservice.getProperty(propQName)); - } - } - - } - else - { - // Get all the property definitions for the class - propMap = dictionaryservice.getClass(classQName).getProperties(); - } - - // Filter the properties by URI - List props = new ArrayList(propMap.size()); - for (Map.Entry entry : propMap.entrySet()) - { - if ((namespaceURI != null && - namespaceURI.equals(entry.getKey().getNamespaceURI())) || - namespaceURI == null) - { - props.add(entry.getValue()); - } - } - - // Order property definitions by title - Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator(dictionaryservice)); - - // Pass list of property definitions to template - Map model = new HashMap(); - model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, props); - model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); - - return model; - } - - /** - * Returns the names of the properties depending on {@link isRM} parameter - * - * @param isRM if true only RM related properties will be retrieved - * @return The names of the properties defined within the specified model or all of them depending on {@link isRM} parameter - */ - private Collection getProperties(boolean isRM) - { - if (isRM) - { - return dictionaryservice.getProperties(RM_MODEL); - } - else - { - return dictionaryservice.getAllProperties(null); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.dictionary; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Webscript to get the Propertydefinitions for a given classname eg. =>cm_person + * + * This class makes it possible to get only RM related property definitions + * @see PropertiesGet for the original implementation + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmPropertiesGet extends DictionaryWebServiceBase implements RecordsManagementModel +{ + private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs"; + private static final String DICTIONARY_CLASS_NAME = "classname"; + private static final String PARAM_NAME = "name"; + private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp"; + + /** Site service*/ + private SiteService siteService; + + /** + * @param siteService the site service to set + */ + public void setSiteService(SiteService siteService) + { + this.siteService = siteService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + return executeImpl(req, RmDictionaryWebServiceUtils.isRmSite(req, siteService)); + } + + /** + * Execute custom Java logic + * + * @param req Web Script request + * @param isRM indicates whether the request comes from an RM site or not + * @return custom service model + */ + private Map executeImpl(WebScriptRequest req, boolean isRM) + { + QName classQName = null; + String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME); + if (className != null && className.length() != 0) + { + classQName = createClassQName(className); + if (classQName == null) + { + // Error + throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL"); + } + } + + String[] names = req.getParameterValues(PARAM_NAME); + + String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX); + String namespaceURI = null; + if (namespacePrefix != null) + { + namespaceURI = this.namespaceService.getNamespaceURI(namespacePrefix); + } + + Map propMap = null; + if (classQName == null) + { + if (names != null) + { + propMap = new HashMap(names.length); + for (String name : names) + { + QName propQName = QName.createQName(name, namespaceService); + PropertyDefinition propDef = dictionaryservice.getProperty(propQName); + if (propDef != null) + { + propMap.put(propQName, propDef); + } + } + } + else + { + Collection propQNames = getProperties(isRM); + propMap = new HashMap(propQNames.size()); + for (QName propQName : propQNames) + { + propMap.put(propQName, dictionaryservice.getProperty(propQName)); + } + } + + } + else + { + // Get all the property definitions for the class + propMap = dictionaryservice.getClass(classQName).getProperties(); + } + + // Filter the properties by URI + List props = new ArrayList(propMap.size()); + for (Map.Entry entry : propMap.entrySet()) + { + if ((namespaceURI != null && + namespaceURI.equals(entry.getKey().getNamespaceURI())) || + namespaceURI == null) + { + props.add(entry.getValue()); + } + } + + // Order property definitions by title + Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator(dictionaryservice)); + + // Pass list of property definitions to template + Map model = new HashMap(); + model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, props); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); + + return model; + } + + /** + * Returns the names of the properties depending on {@link isRM} parameter + * + * @param isRM if true only RM related properties will be retrieved + * @return The names of the properties defined within the specified model or all of them depending on {@link isRM} parameter + */ + private Collection getProperties(boolean isRM) + { + if (isRM) + { + return dictionaryservice.getProperties(RM_MODEL); + } + else + { + return dictionaryservice.getAllProperties(null); + } + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java index 7fa98ac7ef..7b4f486687 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java @@ -1,99 +1,99 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.roles; - -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.script.admin.RoleDeclarativeWebScript; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Abstract class for adding/removing a user/group to/from a role - * This class contains the common methods needed in the sub classes. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class AbstractRmAuthorities extends RoleDeclarativeWebScript -{ - /** Constants for the url parameters */ - private static final String ROLE_ID = "roleId"; - private static final String AUTHORITY_NAME = "authorityName"; - - /** - * Util method for getting the nodeRef from the request - * - * @param req The webscript request - * @return The nodeRef passed in the request - */ - protected NodeRef getFilePlan(WebScriptRequest req) - { - NodeRef filePlan = super.getFilePlan(req); - if (filePlan == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No filePlan was provided on the URL."); - } - return filePlan; - } - - /** - * Util method for getting the roleId from the request - * - * @param req The webscript request - * @return The role id passed in the request - */ - protected String getRoleId(WebScriptRequest req) - { - return getParamValue(req, ROLE_ID); - } - - /** - * Util method for getting the authorityName from the request - * - * @param req The webscript request - * @return The authorityName passed in the request - */ - protected String getAuthorityName(WebScriptRequest req) - { - return getParamValue(req, AUTHORITY_NAME); - } - - /** - * Helper method to get the value of parameter from the request - * - * @param req The webscript request - * @param param The name of the parameter for which the value is requested - * @return The value for the requested parameter - */ - private String getParamValue(WebScriptRequest req, String param) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - - String authorityName = templateVars.get(param); - if (StringUtils.isBlank(authorityName)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No '" + param + "' was provided on the URL."); - } - return authorityName; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.roles; + +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.script.admin.RoleDeclarativeWebScript; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Abstract class for adding/removing a user/group to/from a role + * This class contains the common methods needed in the sub classes. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class AbstractRmAuthorities extends RoleDeclarativeWebScript +{ + /** Constants for the url parameters */ + private static final String ROLE_ID = "roleId"; + private static final String AUTHORITY_NAME = "authorityName"; + + /** + * Util method for getting the nodeRef from the request + * + * @param req The webscript request + * @return The nodeRef passed in the request + */ + protected NodeRef getFilePlan(WebScriptRequest req) + { + NodeRef filePlan = super.getFilePlan(req); + if (filePlan == null) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No filePlan was provided on the URL."); + } + return filePlan; + } + + /** + * Util method for getting the roleId from the request + * + * @param req The webscript request + * @return The role id passed in the request + */ + protected String getRoleId(WebScriptRequest req) + { + return getParamValue(req, ROLE_ID); + } + + /** + * Util method for getting the authorityName from the request + * + * @param req The webscript request + * @return The authorityName passed in the request + */ + protected String getAuthorityName(WebScriptRequest req) + { + return getParamValue(req, AUTHORITY_NAME); + } + + /** + * Helper method to get the value of parameter from the request + * + * @param req The webscript request + * @param param The name of the parameter for which the value is requested + * @return The value for the requested parameter + */ + private String getParamValue(WebScriptRequest req, String param) + { + Map templateVars = req.getServiceMatch().getTemplateVars(); + + String authorityName = templateVars.get(param); + if (StringUtils.isBlank(authorityName)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "No '" + param + "' was provided on the URL."); + } + return authorityName; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesDelete.java b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesDelete.java index 352f0ac623..2e73be182e 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesDelete.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesDelete.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.roles; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Webscript for removing a user or a group from a role - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmAuthoritiesDelete extends AbstractRmAuthorities -{ - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - NodeRef filePlan = getFilePlan(req); - String roleId = getRoleId(req); - String authorityName = getAuthorityName(req); - - filePlanRoleService.unassignRoleFromAuthority(filePlan, roleId, authorityName); - - return new HashMap(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.roles; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Webscript for removing a user or a group from a role + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmAuthoritiesDelete extends AbstractRmAuthorities +{ + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + NodeRef filePlan = getFilePlan(req); + String roleId = getRoleId(req); + String authorityName = getAuthorityName(req); + + filePlanRoleService.unassignRoleFromAuthority(filePlan, roleId, authorityName); + + return new HashMap(); + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesPost.java b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesPost.java index 09add874d6..011c7fd28c 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesPost.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/RmAuthoritiesPost.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.roles; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Webscript for adding a user or a group to a role - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmAuthoritiesPost extends AbstractRmAuthorities -{ - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - NodeRef filePlan = getFilePlan(req); - String roleId = getRoleId(req); - String authorityName = getAuthorityName(req); - - filePlanRoleService.assignRoleToAuthority(filePlan, roleId, authorityName); - - return new HashMap(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.roles; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Webscript for adding a user or a group to a role + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmAuthoritiesPost extends AbstractRmAuthorities +{ + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + NodeRef filePlan = getFilePlan(req); + String roleId = getRoleId(req); + String authorityName = getAuthorityName(req); + + filePlanRoleService.assignRoleToAuthority(filePlan, roleId, authorityName); + + return new HashMap(); + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionConditionDefinitionsGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionConditionDefinitionsGet.java index c564c54f64..250c070da1 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionConditionDefinitionsGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionConditionDefinitionsGet.java @@ -1,81 +1,81 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.rule; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.service.cmr.action.ActionConditionDefinition; -import org.alfresco.service.cmr.action.ActionService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the RM related action condition definition list. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RmActionConditionDefinitionsGet extends DeclarativeWebScript -{ - private ActionService actionService; - - private RecordsManagementActionService recordsManagementActionService; - - public void setActionService(ActionService actionService) - { - this.actionService = actionService; - } - - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - List dmDefs = actionService.getActionConditionDefinitions(); - List conditions = recordsManagementActionService.getRecordsManagementActionConditions(); - - List defs = new ArrayList(dmDefs.size()+conditions.size()); - defs.addAll(dmDefs); - for (RecordsManagementActionCondition condition: conditions) - { - if (condition.isPublicCondition()) - { - defs.add(condition.getRecordsManagementActionConditionDefinition()); - } - } - - Map model = new HashMap(); - model.put("actionconditiondefinitions", defs); - - return model; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.rule; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.service.cmr.action.ActionConditionDefinition; +import org.alfresco.service.cmr.action.ActionService; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get the RM related action condition definition list. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RmActionConditionDefinitionsGet extends DeclarativeWebScript +{ + private ActionService actionService; + + private RecordsManagementActionService recordsManagementActionService; + + public void setActionService(ActionService actionService) + { + this.actionService = actionService; + } + + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + List dmDefs = actionService.getActionConditionDefinitions(); + List conditions = recordsManagementActionService.getRecordsManagementActionConditions(); + + List defs = new ArrayList(dmDefs.size()+conditions.size()); + defs.addAll(dmDefs); + for (RecordsManagementActionCondition condition: conditions) + { + if (condition.isPublicCondition()) + { + defs.add(condition.getRecordsManagementActionConditionDefinition()); + } + } + + Map model = new HashMap(); + model.put("actionconditiondefinitions", defs); + + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java index f417b10b24..c20ea57870 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java @@ -1,71 +1,71 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.rule; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.service.cmr.action.ActionDefinition; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the RM related action definition list. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmActionDefinitionsGet extends DeclarativeWebScript -{ - private RecordsManagementActionService recordsManagementActionService; - - public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) - { - this.recordsManagementActionService = recordsManagementActionService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - List actions = recordsManagementActionService.getRecordsManagementActions(); - Set defs = new HashSet(actions.size()); - for (RecordsManagementAction action : actions) - { - if (action.isPublicAction()) - { - defs.add(action.getRecordsManagementActionDefinition()); - } - } - - Map model = new HashMap(); - model.put("actiondefinitions", defs); - - return model; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.rule; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.service.cmr.action.ActionDefinition; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get the RM related action definition list. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmActionDefinitionsGet extends DeclarativeWebScript +{ + private RecordsManagementActionService recordsManagementActionService; + + public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) + { + this.recordsManagementActionService = recordsManagementActionService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + List actions = recordsManagementActionService.getRecordsManagementActions(); + Set defs = new HashSet(actions.size()); + for (RecordsManagementAction action : actions) + { + if (action.isPublicAction()) + { + defs.add(action.getRecordsManagementActionDefinition()); + } + } + + Map model = new HashMap(); + model.put("actiondefinitions", defs); + + return model; + } +} diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java index 29249ec9fb..73004f673c 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java @@ -1,307 +1,307 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.substitutionsuggestions; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.action.parameter.ParameterProcessorComponent; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get substitution suggestions - * given a text fragment (e.g. date.month for 'mon'). - * - * @author Mark Hibbins - * @since 2.2 - */ -public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript -{ - private static final String FRAGMENT_PARAMETER = "fragment"; - private static final String PATH_PARAMETER = "path"; - private static final String UNFILED_PARAMETER = "unfiled"; - private static final String UNFILED = "true"; - - private static final String SUBSTITUTIONS_MODEL_KEY = "substitutions"; - - private static final String CREATE_CAPABILITY = "Create"; - private static final String VIEW_CAPABILITY = "ViewRecords"; - - private static final int DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH = 0; - private static final int DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS = 10; - - private int pathSubstitutionMaximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS; - private int substitutionMinimumFragmentSize = DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH; - - private ParameterProcessorComponent parameterProcessorComponent; - private NodeService nodeService; - private FilePlanService filePlanService; - private CapabilityService capabilityService; - - /** - * Set the parameter processor component bean - * - * @param parameterProcessorComponent - */ - public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) - { - this.parameterProcessorComponent = parameterProcessorComponent; - } - - /** - * Set the parameter processor component bean - * - * @param parameterProcessorComponent - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param filePlanService file plan service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * Set the minimum fragment size to process for suggestion processing - * - * @param maximumNumberSuggestions - */ - public void setSubstitutionMinimumFragmentSize(int substitutionMinimumFragmentSize) - { - this.substitutionMinimumFragmentSize = Math.max(substitutionMinimumFragmentSize, DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH); - } - - /** - * Set the maxmimum number of suggestions returned from the global property - * - * @param maximumNumberSuggestions - */ - public void setPathSubstitutionMaximumNumberSuggestions(int pathSubstitutionMaximumNumberSuggestions) - { - this.pathSubstitutionMaximumNumberSuggestions = (pathSubstitutionMaximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS: pathSubstitutionMaximumNumberSuggestions); - } - - /** - * Return a list of substitutions for the given fragment. - * - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String fragment = req.getParameter(FRAGMENT_PARAMETER); - String path = req.getParameter(PATH_PARAMETER); - String unfiledString = req.getParameter(UNFILED_PARAMETER); - boolean unfiled = (unfiledString != null) && UNFILED.equals(unfiledString); - - List substitutionSuggestions = new ArrayList(); - - if((fragment != null) && (fragment.length() >= this.substitutionMinimumFragmentSize)) - { - substitutionSuggestions.addAll(getSubPathSuggestions(req, path, fragment, unfiled)); - substitutionSuggestions.addAll(this.parameterProcessorComponent.getSubstitutionSuggestions(fragment)); - } - - Map model = new HashMap(); - model.put(SUBSTITUTIONS_MODEL_KEY, substitutionSuggestions); - - return model; - } - - /** - * Return a list of path suggestions for the path fragment supplied. - * - * @param path - * @param fragment - * @return - */ - private List getSubPathSuggestions(WebScriptRequest req, final String path, final String fragment, boolean unfiled) - { - List pathSuggestions = new ArrayList(); - if((path != null) && path.startsWith("/") && (fragment != null)) - { - String[] pathFragments = path.split("/"); - - NodeRef currentNode = getFilePlan(req, unfiled); - for(String pathFragment : pathFragments) - { - // ignore empty elements of the path produced by split - if(!pathFragment.isEmpty()) - { - boolean foundThisPathFragment = false; - List children = nodeService.getChildAssocs(currentNode); - for (ChildAssociationRef childAssoc : children) - { - NodeRef childNodeRef = childAssoc.getChildRef(); - String fileName = (String) nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME); - if(fileName.equals(pathFragment) && isNodeRefAppropriateForPathSuggestion(childNodeRef, unfiled)) - { - foundThisPathFragment = true; - currentNode = childNodeRef; - break; - } - } - if(!foundThisPathFragment) - { - currentNode = null; - break; - } - } - } - - if(currentNode != null) - { - String lowerCaseFragment = fragment.toLowerCase(); - List children = nodeService.getChildAssocs(currentNode); - for (ChildAssociationRef childAssoc : children) - { - NodeRef childNodeRef = childAssoc.getChildRef(); - String fileName = (String) nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME); - if((fragment.isEmpty() || fileName.toLowerCase().startsWith(lowerCaseFragment)) && isNodeRefAppropriateForPathSuggestion(childNodeRef, unfiled)) - { - pathSuggestions.add("/" + fileName); - if(pathSuggestions.size() >= pathSubstitutionMaximumNumberSuggestions) - { - break; - } - } - } - } - } - return pathSuggestions; - } - - /** - * Utility method to get the file plan from the passed parameters. - * - * @param req - * @return - */ - protected NodeRef getFilePlan(WebScriptRequest req, boolean unfiled) - { - NodeRef filePlan = null; - - Map templateVars = req.getServiceMatch().getTemplateVars(); - String siteId = templateVars.get("siteid"); - if (siteId != null) - { - filePlan = filePlanService.getFilePlanBySiteId(siteId); - } - - if (filePlan == null) - { - String storeType = templateVars.get("store_type"); - String storeId = templateVars.get("store_id"); - String id = templateVars.get("id"); - - if (!StringUtils.isEmpty(storeType) && - !StringUtils.isEmpty(storeId) && - !StringUtils.isEmpty(id)) - { - StoreRef storeRef = new StoreRef(storeType, storeId); - NodeRef nodeRef = new NodeRef(storeRef, id); - if (filePlanService.isFilePlan(nodeRef)) - { - filePlan = nodeRef; - } - } - } - - if (filePlan == null) - { - // Assume we are in a legacy repository and we will grab the default file plan - filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - } - - return unfiled ? filePlanService.getUnfiledContainer(filePlan) : filePlan; - } - - /** - * Identifies record category and record folder types of nodeRef - * - * @param nodeRef Instance of NodeRef to be tested - * @return True if the passed NodeRef instance is a record category or record folder - */ - private boolean isNodeRefAppropriateForPathSuggestion(NodeRef nodeRef, boolean unfiled) - { - // check node type - QName type = nodeService.getType(nodeRef); - boolean isCorrectType = (!unfiled - && (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(type) || RecordsManagementModel.TYPE_RECORD_CATEGORY - .equals(type)) || (unfiled && RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(type))); - - // check permissions - boolean canView = false; - if(isCorrectType) - { - Capability createCapability = capabilityService.getCapability(CREATE_CAPABILITY); - Capability viewCapability = capabilityService.getCapability(VIEW_CAPABILITY); - if ((createCapability != null) && (viewCapability != null)) - { - List requiredCapabilities = new ArrayList(); - requiredCapabilities.add(CREATE_CAPABILITY); - requiredCapabilities.add(VIEW_CAPABILITY); - Map map = capabilityService.getCapabilitiesAccessState(nodeRef, requiredCapabilities); - if (map.containsKey(createCapability) && map.containsKey(viewCapability)) - { - AccessStatus createAccessStatus = map.get(createCapability); - AccessStatus viewAccessStatus = map.get(viewCapability); - if (createAccessStatus.equals(AccessStatus.ALLOWED) && viewAccessStatus.equals(AccessStatus.ALLOWED)) - { - canView = true; - } - } - } - } - - return isCorrectType && canView; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.substitutionsuggestions; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.action.parameter.ParameterProcessorComponent; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get substitution suggestions + * given a text fragment (e.g. date.month for 'mon'). + * + * @author Mark Hibbins + * @since 2.2 + */ +public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript +{ + private static final String FRAGMENT_PARAMETER = "fragment"; + private static final String PATH_PARAMETER = "path"; + private static final String UNFILED_PARAMETER = "unfiled"; + private static final String UNFILED = "true"; + + private static final String SUBSTITUTIONS_MODEL_KEY = "substitutions"; + + private static final String CREATE_CAPABILITY = "Create"; + private static final String VIEW_CAPABILITY = "ViewRecords"; + + private static final int DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH = 0; + private static final int DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS = 10; + + private int pathSubstitutionMaximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS; + private int substitutionMinimumFragmentSize = DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH; + + private ParameterProcessorComponent parameterProcessorComponent; + private NodeService nodeService; + private FilePlanService filePlanService; + private CapabilityService capabilityService; + + /** + * Set the parameter processor component bean + * + * @param parameterProcessorComponent + */ + public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent) + { + this.parameterProcessorComponent = parameterProcessorComponent; + } + + /** + * Set the parameter processor component bean + * + * @param parameterProcessorComponent + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param filePlanService file plan service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * Set the minimum fragment size to process for suggestion processing + * + * @param maximumNumberSuggestions + */ + public void setSubstitutionMinimumFragmentSize(int substitutionMinimumFragmentSize) + { + this.substitutionMinimumFragmentSize = Math.max(substitutionMinimumFragmentSize, DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH); + } + + /** + * Set the maxmimum number of suggestions returned from the global property + * + * @param maximumNumberSuggestions + */ + public void setPathSubstitutionMaximumNumberSuggestions(int pathSubstitutionMaximumNumberSuggestions) + { + this.pathSubstitutionMaximumNumberSuggestions = (pathSubstitutionMaximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS: pathSubstitutionMaximumNumberSuggestions); + } + + /** + * Return a list of substitutions for the given fragment. + * + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + String fragment = req.getParameter(FRAGMENT_PARAMETER); + String path = req.getParameter(PATH_PARAMETER); + String unfiledString = req.getParameter(UNFILED_PARAMETER); + boolean unfiled = (unfiledString != null) && UNFILED.equals(unfiledString); + + List substitutionSuggestions = new ArrayList(); + + if((fragment != null) && (fragment.length() >= this.substitutionMinimumFragmentSize)) + { + substitutionSuggestions.addAll(getSubPathSuggestions(req, path, fragment, unfiled)); + substitutionSuggestions.addAll(this.parameterProcessorComponent.getSubstitutionSuggestions(fragment)); + } + + Map model = new HashMap(); + model.put(SUBSTITUTIONS_MODEL_KEY, substitutionSuggestions); + + return model; + } + + /** + * Return a list of path suggestions for the path fragment supplied. + * + * @param path + * @param fragment + * @return + */ + private List getSubPathSuggestions(WebScriptRequest req, final String path, final String fragment, boolean unfiled) + { + List pathSuggestions = new ArrayList(); + if((path != null) && path.startsWith("/") && (fragment != null)) + { + String[] pathFragments = path.split("/"); + + NodeRef currentNode = getFilePlan(req, unfiled); + for(String pathFragment : pathFragments) + { + // ignore empty elements of the path produced by split + if(!pathFragment.isEmpty()) + { + boolean foundThisPathFragment = false; + List children = nodeService.getChildAssocs(currentNode); + for (ChildAssociationRef childAssoc : children) + { + NodeRef childNodeRef = childAssoc.getChildRef(); + String fileName = (String) nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME); + if(fileName.equals(pathFragment) && isNodeRefAppropriateForPathSuggestion(childNodeRef, unfiled)) + { + foundThisPathFragment = true; + currentNode = childNodeRef; + break; + } + } + if(!foundThisPathFragment) + { + currentNode = null; + break; + } + } + } + + if(currentNode != null) + { + String lowerCaseFragment = fragment.toLowerCase(); + List children = nodeService.getChildAssocs(currentNode); + for (ChildAssociationRef childAssoc : children) + { + NodeRef childNodeRef = childAssoc.getChildRef(); + String fileName = (String) nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME); + if((fragment.isEmpty() || fileName.toLowerCase().startsWith(lowerCaseFragment)) && isNodeRefAppropriateForPathSuggestion(childNodeRef, unfiled)) + { + pathSuggestions.add("/" + fileName); + if(pathSuggestions.size() >= pathSubstitutionMaximumNumberSuggestions) + { + break; + } + } + } + } + } + return pathSuggestions; + } + + /** + * Utility method to get the file plan from the passed parameters. + * + * @param req + * @return + */ + protected NodeRef getFilePlan(WebScriptRequest req, boolean unfiled) + { + NodeRef filePlan = null; + + Map templateVars = req.getServiceMatch().getTemplateVars(); + String siteId = templateVars.get("siteid"); + if (siteId != null) + { + filePlan = filePlanService.getFilePlanBySiteId(siteId); + } + + if (filePlan == null) + { + String storeType = templateVars.get("store_type"); + String storeId = templateVars.get("store_id"); + String id = templateVars.get("id"); + + if (!StringUtils.isEmpty(storeType) && + !StringUtils.isEmpty(storeId) && + !StringUtils.isEmpty(id)) + { + StoreRef storeRef = new StoreRef(storeType, storeId); + NodeRef nodeRef = new NodeRef(storeRef, id); + if (filePlanService.isFilePlan(nodeRef)) + { + filePlan = nodeRef; + } + } + } + + if (filePlan == null) + { + // Assume we are in a legacy repository and we will grab the default file plan + filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + + return unfiled ? filePlanService.getUnfiledContainer(filePlan) : filePlan; + } + + /** + * Identifies record category and record folder types of nodeRef + * + * @param nodeRef Instance of NodeRef to be tested + * @return True if the passed NodeRef instance is a record category or record folder + */ + private boolean isNodeRefAppropriateForPathSuggestion(NodeRef nodeRef, boolean unfiled) + { + // check node type + QName type = nodeService.getType(nodeRef); + boolean isCorrectType = (!unfiled + && (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(type) || RecordsManagementModel.TYPE_RECORD_CATEGORY + .equals(type)) || (unfiled && RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(type))); + + // check permissions + boolean canView = false; + if(isCorrectType) + { + Capability createCapability = capabilityService.getCapability(CREATE_CAPABILITY); + Capability viewCapability = capabilityService.getCapability(VIEW_CAPABILITY); + if ((createCapability != null) && (viewCapability != null)) + { + List requiredCapabilities = new ArrayList(); + requiredCapabilities.add(CREATE_CAPABILITY); + requiredCapabilities.add(VIEW_CAPABILITY); + Map map = capabilityService.getCapabilitiesAccessState(nodeRef, requiredCapabilities); + if (map.containsKey(createCapability) && map.containsKey(viewCapability)) + { + AccessStatus createAccessStatus = map.get(createCapability); + AccessStatus viewAccessStatus = map.get(viewCapability); + if (createAccessStatus.equals(AccessStatus.ALLOWED) && viewAccessStatus.equals(AccessStatus.ALLOWED)) + { + canView = true; + } + } + } + } + + return isCorrectType && canView; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/util/WebScriptUtils.java b/rm-server/source/java/org/alfresco/util/WebScriptUtils.java index 131687fe7a..ffe58a27e5 100644 --- a/rm-server/source/java/org/alfresco/util/WebScriptUtils.java +++ b/rm-server/source/java/org/alfresco/util/WebScriptUtils.java @@ -1,322 +1,322 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.util; - -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.alfresco.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isBlank; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.springframework.extensions.surf.util.Content; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Utility class for handling webscript requests - * - * @author Tuna Aksoy - * @since 2.3 - */ -public final class WebScriptUtils -{ - private WebScriptUtils() - { - // Will not be called - } - - /** - * Gets the template variable substitutions map - * - * @param req The webscript request - * @return The template variable substitutions - */ - public static Map getTemplateVars(WebScriptRequest req) - { - mandatory("req", req); - - if (req.getServiceMatch() == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The matching API Service for the request is null."); - } - - Map templateVars = req.getServiceMatch().getTemplateVars(); - if (templateVars == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The template variable substitutions map is null"); - } - - return templateVars; - } - - /** - * Gets the value of a request parameter - * - * @param req The webscript request - * @param parameter The request parameter - * @return The value of the request parameter - */ - public static String getRequestParameterValue(WebScriptRequest req, String parameter) - { - mandatory("req", req); - mandatoryString("parameter", parameter); - - return getRequestParameterValue(req, parameter, true); - } - - /** - * Gets the value of a request parameter - * - * @param req The webscript request - * @param parameter The request parameter - * @param checkValue Determines if the value of the parameter should be checked or not - * @return The value of the request parameter - */ - public static String getRequestParameterValue(WebScriptRequest req, String parameter, boolean checkValue) - { - mandatory("req", req); - mandatoryString("parameter", parameter); - - Map templateVars = getTemplateVars(req); - String value = templateVars.get(parameter); - - if (checkValue && isBlank(value)) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The value for the parameter '" + parameter + "' is blank."); - } - - return value; - } - - /** - * Gets the request content as JSON object - * - * @param req The webscript request - * @return The request content as JSON object - */ - public static JSONObject getRequestContentAsJsonObject(WebScriptRequest req) - { - mandatory("req", req); - - Content reqContent = req.getContent(); - if (reqContent == null) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Missing request body."); - } - - String content; - try - { - content = reqContent.getContent(); - } - catch (IOException error) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get content from the request.", error); - } - - if (StringUtils.isBlank(content)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Content does not exist."); - } - - JSONTokener jsonTokener = new JSONTokener(content); - - JSONObject json; - try - { - json = new JSONObject(jsonTokener); - } - catch (JSONException error) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request body.", error); - } - - return json; - } - - /** - * Checks if the json object contains an entry with the specified parameter name - * - * @param jsonObject The json object - * @param paramName The parameter name to check for - */ - public static void checkMandatoryJsonParam(JSONObject jsonObject, String paramName) - { - mandatory("jsonObject", jsonObject); - mandatoryString("paramName", paramName); - - if (!jsonObject.has(paramName)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The json object does not contain en entry with parameter '" + paramName + "'."); - } - } - - /** - * Checks if the json object contains entries with the specified parameter names - * - * @param jsonObject The json object. - * @param paramNames The parameter names to check for - */ - public static void checkMandatoryJsonParams(JSONObject jsonObject, List paramNames) - { - mandatory("jsonObject", jsonObject); - mandatory("paramNames", paramNames); - - for (String name : paramNames) - { - checkMandatoryJsonParam(jsonObject, name); - } - } - - /** - * Gets the {@link String} value of a given key from a json object - * - * @param jsonObject The json object - * @param key The key - * @return The {@link String} value of the given key from the json object - */ - public static String getStringValueFromJSONObject(JSONObject jsonObject, String key) - { - mandatory("jsonObject", jsonObject); - mandatoryString("key", key); - - return getStringValueFromJSONObject(jsonObject, key, true, true); - } - - /** - * Gets the {@link String} value of a given key from a json object - * - * @param jsonObject The json object - * @param key The key - * @param checkKey Determines if the existence of the key should be checked - * @param checkValue Determines if the value should be checked if it is blank or not - * @return The {@link String} value of the given key from the json object - */ - public static String getStringValueFromJSONObject(JSONObject jsonObject, String key, boolean checkKey, boolean checkValue) - { - mandatory("jsonObject", jsonObject); - mandatoryString("key", key); - - if (checkKey) - { - checkMandatoryJsonParam(jsonObject, key); - } - - String value = null; - - try - { - value = jsonObject.getString(key); - if (checkValue && isBlank(value)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The vale is missing for the key '" + key + "'."); - } - } - catch (JSONException error) - { - if (checkValue) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error); - } - } - - return value; - } - - /** - * Puts the given key and value to the json object - * - * @param jsonObject The json object - * @param key The key - * @param value The value - */ - public static void putValuetoJSONObject(JSONObject jsonObject, String key, Object value) - { - mandatory("jsonObject", jsonObject); - mandatoryString("key", key); - mandatory("value", value); - - try - { - jsonObject.put(key, value); - } - catch (JSONException error) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not put the key '" + key + "' with the value '" + value + "' to the json object.", error); - } - } - - /** - * Gets the value of an element from a json array at the given index - * - * @param jsonArray The json array - * @param index The index - * @return The value of the element - */ - public static Object getJSONArrayValue(JSONArray jsonArray, int index) - { - mandatory("jsonArray", jsonArray); - - Object value; - - try - { - value = jsonArray.get(index); - } - catch (JSONException error) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the index '" + index + "' from the JSON Array.", error); - } - - return value; - } - - /** - * Creates a json object from the given {@link String} - * - * @param json The json object as {@link String} - * @return The json object created from the given {@link String} - */ - public static JSONObject createJSONObject(String json) - { - mandatory("json", json); - - JSONObject jsonObject; - - try - { - jsonObject = new JSONObject(json); - } - catch (JSONException error) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Cannot create a json object from the given string '" + json + "'.", error); - } - - return jsonObject; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.util; + +import static org.alfresco.util.ParameterCheck.mandatory; +import static org.alfresco.util.ParameterCheck.mandatoryString; +import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isBlank; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.extensions.surf.util.Content; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Utility class for handling webscript requests + * + * @author Tuna Aksoy + * @since 2.3 + */ +public final class WebScriptUtils +{ + private WebScriptUtils() + { + // Will not be called + } + + /** + * Gets the template variable substitutions map + * + * @param req The webscript request + * @return The template variable substitutions + */ + public static Map getTemplateVars(WebScriptRequest req) + { + mandatory("req", req); + + if (req.getServiceMatch() == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The matching API Service for the request is null."); + } + + Map templateVars = req.getServiceMatch().getTemplateVars(); + if (templateVars == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The template variable substitutions map is null"); + } + + return templateVars; + } + + /** + * Gets the value of a request parameter + * + * @param req The webscript request + * @param parameter The request parameter + * @return The value of the request parameter + */ + public static String getRequestParameterValue(WebScriptRequest req, String parameter) + { + mandatory("req", req); + mandatoryString("parameter", parameter); + + return getRequestParameterValue(req, parameter, true); + } + + /** + * Gets the value of a request parameter + * + * @param req The webscript request + * @param parameter The request parameter + * @param checkValue Determines if the value of the parameter should be checked or not + * @return The value of the request parameter + */ + public static String getRequestParameterValue(WebScriptRequest req, String parameter, boolean checkValue) + { + mandatory("req", req); + mandatoryString("parameter", parameter); + + Map templateVars = getTemplateVars(req); + String value = templateVars.get(parameter); + + if (checkValue && isBlank(value)) + { + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The value for the parameter '" + parameter + "' is blank."); + } + + return value; + } + + /** + * Gets the request content as JSON object + * + * @param req The webscript request + * @return The request content as JSON object + */ + public static JSONObject getRequestContentAsJsonObject(WebScriptRequest req) + { + mandatory("req", req); + + Content reqContent = req.getContent(); + if (reqContent == null) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Missing request body."); + } + + String content; + try + { + content = reqContent.getContent(); + } + catch (IOException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get content from the request.", error); + } + + if (StringUtils.isBlank(content)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Content does not exist."); + } + + JSONTokener jsonTokener = new JSONTokener(content); + + JSONObject json; + try + { + json = new JSONObject(jsonTokener); + } + catch (JSONException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request body.", error); + } + + return json; + } + + /** + * Checks if the json object contains an entry with the specified parameter name + * + * @param jsonObject The json object + * @param paramName The parameter name to check for + */ + public static void checkMandatoryJsonParam(JSONObject jsonObject, String paramName) + { + mandatory("jsonObject", jsonObject); + mandatoryString("paramName", paramName); + + if (!jsonObject.has(paramName)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The json object does not contain en entry with parameter '" + paramName + "'."); + } + } + + /** + * Checks if the json object contains entries with the specified parameter names + * + * @param jsonObject The json object. + * @param paramNames The parameter names to check for + */ + public static void checkMandatoryJsonParams(JSONObject jsonObject, List paramNames) + { + mandatory("jsonObject", jsonObject); + mandatory("paramNames", paramNames); + + for (String name : paramNames) + { + checkMandatoryJsonParam(jsonObject, name); + } + } + + /** + * Gets the {@link String} value of a given key from a json object + * + * @param jsonObject The json object + * @param key The key + * @return The {@link String} value of the given key from the json object + */ + public static String getStringValueFromJSONObject(JSONObject jsonObject, String key) + { + mandatory("jsonObject", jsonObject); + mandatoryString("key", key); + + return getStringValueFromJSONObject(jsonObject, key, true, true); + } + + /** + * Gets the {@link String} value of a given key from a json object + * + * @param jsonObject The json object + * @param key The key + * @param checkKey Determines if the existence of the key should be checked + * @param checkValue Determines if the value should be checked if it is blank or not + * @return The {@link String} value of the given key from the json object + */ + public static String getStringValueFromJSONObject(JSONObject jsonObject, String key, boolean checkKey, boolean checkValue) + { + mandatory("jsonObject", jsonObject); + mandatoryString("key", key); + + if (checkKey) + { + checkMandatoryJsonParam(jsonObject, key); + } + + String value = null; + + try + { + value = jsonObject.getString(key); + if (checkValue && isBlank(value)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The vale is missing for the key '" + key + "'."); + } + } + catch (JSONException error) + { + if (checkValue) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error); + } + } + + return value; + } + + /** + * Puts the given key and value to the json object + * + * @param jsonObject The json object + * @param key The key + * @param value The value + */ + public static void putValuetoJSONObject(JSONObject jsonObject, String key, Object value) + { + mandatory("jsonObject", jsonObject); + mandatoryString("key", key); + mandatory("value", value); + + try + { + jsonObject.put(key, value); + } + catch (JSONException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not put the key '" + key + "' with the value '" + value + "' to the json object.", error); + } + } + + /** + * Gets the value of an element from a json array at the given index + * + * @param jsonArray The json array + * @param index The index + * @return The value of the element + */ + public static Object getJSONArrayValue(JSONArray jsonArray, int index) + { + mandatory("jsonArray", jsonArray); + + Object value; + + try + { + value = jsonArray.get(index); + } + catch (JSONException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the index '" + index + "' from the JSON Array.", error); + } + + return value; + } + + /** + * Creates a json object from the given {@link String} + * + * @param json The json object as {@link String} + * @return The json object created from the given {@link String} + */ + public static JSONObject createJSONObject(String json) + { + mandatory("json", json); + + JSONObject jsonObject; + + try + { + jsonObject = new JSONObject(json); + } + catch (JSONException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Cannot create a json object from the given string '" + json + "'.", error); + } + + return jsonObject; + } +} diff --git a/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java b/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java index 0eca155da8..56c297d58b 100644 --- a/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java +++ b/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.workflow; - -import org.alfresco.service.namespace.QName; - -/** - * Workflow Constants for Records Management - * - * @author Tuna Aksoy - * @since 2.1 - */ -public interface RMWorkflowModel -{ - // Namespace URI - String RM_WORKFLOW_URI = "http://www.alfresco.org/model/rmworkflow/1.0"; - - // Namespace prefix - String RM_WORKFLOW_PREFIX = "rmwf"; - - // Mixed Assignees - QName RM_MIXED_ASSIGNEES = QName.createQName(RM_WORKFLOW_URI, "mixedAssignees"); - - // Requested Information - QName RM_REQUESTED_INFORMATION = QName.createQName(RM_WORKFLOW_URI, "requestedInformation"); - - // Rule creator - QName RM_RULE_CREATOR = QName.createQName(RM_WORKFLOW_URI, "ruleCreator"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.workflow; + +import org.alfresco.service.namespace.QName; + +/** + * Workflow Constants for Records Management + * + * @author Tuna Aksoy + * @since 2.1 + */ +public interface RMWorkflowModel +{ + // Namespace URI + String RM_WORKFLOW_URI = "http://www.alfresco.org/model/rmworkflow/1.0"; + + // Namespace prefix + String RM_WORKFLOW_PREFIX = "rmwf"; + + // Mixed Assignees + QName RM_MIXED_ASSIGNEES = QName.createQName(RM_WORKFLOW_URI, "mixedAssignees"); + + // Requested Information + QName RM_REQUESTED_INFORMATION = QName.createQName(RM_WORKFLOW_URI, "requestedInformation"); + + // Rule creator + QName RM_RULE_CREATOR = QName.createQName(RM_WORKFLOW_URI, "ruleCreator"); +} diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoAssignmentHandler.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoAssignmentHandler.java index dd56f7eac6..60098a4943 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoAssignmentHandler.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoAssignmentHandler.java @@ -1,131 +1,131 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.workflow.requestInfo; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.activiti.engine.delegate.DelegateTask; -import org.activiti.engine.delegate.TaskListener; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.workflow.activiti.ActivitiScriptNode; -import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList; -import org.alfresco.util.ParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * An assignment handler for the request info workflow. - * An RM manager/admin can select one or more user(s) and/or - * one or more group(s) when starting the request info workflow. - * This assignment handler assigns for everyone a task (it is a pooled task). - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RequestInfoAssignmentHandler implements TaskListener -{ - private static final long serialVersionUID = -3179929030094957978L; - - /** - * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) - */ - @Override - public void notify(DelegateTask delegateTask) - { - ParameterCheck.mandatory("delegateTask", delegateTask); - - // Set the workflow description for the task - delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(RequestInfoUtils.getRecordName(delegateTask))); - - // Get the list of user(s) and/or group(s) - ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees"); - - // Check if it was possible to extract the user(s) and/or group(s) - if (usersAndGroups == null) - { - throw new AlfrescoRuntimeException("It was not possible to extract the user(s) and/or group(s)!!!"); - } - - // Define lists for candidate user(s)/group(s) - List candidateUsers = new ArrayList(); - List candidateGroups = new ArrayList(); - - // Iterate through the list add user(s)/group(s) to the lists - for (ActivitiScriptNode activitiScriptNode : usersAndGroups) - { - // Get the node type - String type = activitiScriptNode.getType(); - // Get the properties - Map properties = activitiScriptNode.getProperties(); - - // Check if it is a user or a group - if (type.equalsIgnoreCase(ContentModel.TYPE_PERSON.toString())) - { - // Add the user - candidateUsers.add((String) properties.get(ContentModel.PROP_USERNAME.toString())); - } - else if (type.equalsIgnoreCase(ContentModel.TYPE_AUTHORITY_CONTAINER.toString())) - { - // Add the group - candidateGroups.add((String) properties.get(ContentModel.PROP_AUTHORITY_NAME.toString())); - } - else - { - throw new AlfrescoRuntimeException("The type '" + type + "' is neither a user nor a group!!!"); - } - } - - // Check if there is at least one user or one group - if (candidateUsers.size() == 0 && candidateGroups.size() == 0) - { - throw new AlfrescoRuntimeException("Neither a user nor a group was found!!!"); - } - - // Add the user(s) to the task - if (candidateUsers.size() > 0) - { - delegateTask.addCandidateUsers(candidateUsers); - } - - // Add the group(s) to the task - if (candidateGroups.size() > 0) - { - delegateTask.addCandidateGroups(candidateGroups); - } - } - - /** - * Helper method for building the workflow description - * - * @param recordName The name of the record - * @return Returns the workflow description - */ - private String getWorkflowDescription(String recordName) - { - StringBuilder sb = new StringBuilder(); - sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.requested")); - sb.append(" '"); - sb.append(recordName); - sb.append("'"); - return sb.toString(); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.workflow.requestInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.activiti.engine.delegate.DelegateTask; +import org.activiti.engine.delegate.TaskListener; +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.workflow.activiti.ActivitiScriptNode; +import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList; +import org.alfresco.util.ParameterCheck; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * An assignment handler for the request info workflow. + * An RM manager/admin can select one or more user(s) and/or + * one or more group(s) when starting the request info workflow. + * This assignment handler assigns for everyone a task (it is a pooled task). + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RequestInfoAssignmentHandler implements TaskListener +{ + private static final long serialVersionUID = -3179929030094957978L; + + /** + * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) + */ + @Override + public void notify(DelegateTask delegateTask) + { + ParameterCheck.mandatory("delegateTask", delegateTask); + + // Set the workflow description for the task + delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(RequestInfoUtils.getRecordName(delegateTask))); + + // Get the list of user(s) and/or group(s) + ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees"); + + // Check if it was possible to extract the user(s) and/or group(s) + if (usersAndGroups == null) + { + throw new AlfrescoRuntimeException("It was not possible to extract the user(s) and/or group(s)!!!"); + } + + // Define lists for candidate user(s)/group(s) + List candidateUsers = new ArrayList(); + List candidateGroups = new ArrayList(); + + // Iterate through the list add user(s)/group(s) to the lists + for (ActivitiScriptNode activitiScriptNode : usersAndGroups) + { + // Get the node type + String type = activitiScriptNode.getType(); + // Get the properties + Map properties = activitiScriptNode.getProperties(); + + // Check if it is a user or a group + if (type.equalsIgnoreCase(ContentModel.TYPE_PERSON.toString())) + { + // Add the user + candidateUsers.add((String) properties.get(ContentModel.PROP_USERNAME.toString())); + } + else if (type.equalsIgnoreCase(ContentModel.TYPE_AUTHORITY_CONTAINER.toString())) + { + // Add the group + candidateGroups.add((String) properties.get(ContentModel.PROP_AUTHORITY_NAME.toString())); + } + else + { + throw new AlfrescoRuntimeException("The type '" + type + "' is neither a user nor a group!!!"); + } + } + + // Check if there is at least one user or one group + if (candidateUsers.size() == 0 && candidateGroups.size() == 0) + { + throw new AlfrescoRuntimeException("Neither a user nor a group was found!!!"); + } + + // Add the user(s) to the task + if (candidateUsers.size() > 0) + { + delegateTask.addCandidateUsers(candidateUsers); + } + + // Add the group(s) to the task + if (candidateGroups.size() > 0) + { + delegateTask.addCandidateGroups(candidateGroups); + } + } + + /** + * Helper method for building the workflow description + * + * @param recordName The name of the record + * @return Returns the workflow description + */ + private String getWorkflowDescription(String recordName) + { + StringBuilder sb = new StringBuilder(); + sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.requested")); + sb.append(" '"); + sb.append(recordName); + sb.append("'"); + return sb.toString(); + } + +} diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java index e087e2af5e..6573311421 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.workflow.requestInfo; - -import org.activiti.engine.delegate.DelegateTask; -import org.activiti.engine.delegate.TaskListener; -import org.alfresco.util.ParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Request info workflow notifier. - * After the pooled task has been finished the initiator of the workflow will - * get a task to verify the information. The initiator will also receive an email. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RequestInfoNotifier implements TaskListener -{ - private static final long serialVersionUID = -7169400062409052556L; - - /** - * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) - */ - @Override - public void notify(DelegateTask delegateTask) - { - ParameterCheck.mandatory("delegateTask", delegateTask); - - // Get the record name - String recordName = RequestInfoUtils.getRecordName(delegateTask); - - // Set the workflow description for the task - delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(recordName)); - - // Assign the task to the initiator - String initiator = RequestInfoUtils.getInitiator(delegateTask); - delegateTask.setAssignee(initiator); - } - - /** - * Helper method for building the workflow description - * - * @param recordName The name of the record - * @return Returns the workflow description - */ - private String getWorkflowDescription(String recordName) - { - StringBuilder sb = new StringBuilder(); - sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.provided")); - sb.append(" '"); - sb.append(recordName); - sb.append("'"); - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.workflow.requestInfo; + +import org.activiti.engine.delegate.DelegateTask; +import org.activiti.engine.delegate.TaskListener; +import org.alfresco.util.ParameterCheck; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Request info workflow notifier. + * After the pooled task has been finished the initiator of the workflow will + * get a task to verify the information. The initiator will also receive an email. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RequestInfoNotifier implements TaskListener +{ + private static final long serialVersionUID = -7169400062409052556L; + + /** + * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) + */ + @Override + public void notify(DelegateTask delegateTask) + { + ParameterCheck.mandatory("delegateTask", delegateTask); + + // Get the record name + String recordName = RequestInfoUtils.getRecordName(delegateTask); + + // Set the workflow description for the task + delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(recordName)); + + // Assign the task to the initiator + String initiator = RequestInfoUtils.getInitiator(delegateTask); + delegateTask.setAssignee(initiator); + } + + /** + * Helper method for building the workflow description + * + * @param recordName The name of the record + * @return Returns the workflow description + */ + private String getWorkflowDescription(String recordName) + { + StringBuilder sb = new StringBuilder(); + sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.provided")); + sb.append(" '"); + sb.append(recordName); + sb.append("'"); + return sb.toString(); + } +} diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java index ce435543da..6e4a89be8c 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java @@ -1,137 +1,137 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.workflow.requestInfo; - -import java.util.List; - -import org.activiti.engine.delegate.DelegateTask; -import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.activiti.engine.impl.context.Context; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.workflow.activiti.ActivitiConstants; -import org.alfresco.repo.workflow.activiti.ActivitiScriptNode; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; - -/** - * Util class for the request info workflow - * - * @author Tuna Aksoy - * @since 2.1 - */ -public final class RequestInfoUtils -{ - private RequestInfoUtils() - { - // Will not be called - } - - /** - * Helper method to get the service registry in order to call services - * - * @return Returns the service registry - */ - public static ServiceRegistry getServiceRegistry() - { - ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); - if (config != null) - { - // Fetch the registry that is injected in the activiti spring-configuration - ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); - if (registry == null) - { - throw new AlfrescoRuntimeException( - "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + - ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); - } - return registry; - } - throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context"); - } - - /** - * Helper method to extract the record name from the task - * - * @param delegateTask The delegate task - * @return Returns the name of the record or an empty string if the record name could not be found - (may be because the record has been deleted in the mean time) - */ - public static String getRecordName(DelegateTask delegateTask) - { - ParameterCheck.mandatory("delegateTask", delegateTask); - - String recordName = StringUtils.EMPTY; - - NodeService nodeService = getServiceRegistry().getNodeService(); - ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package"); - List childAssocs = nodeService.getChildAssocs(scriptNode.getNodeRef()); - - if (childAssocs.size() > 0) - { - NodeRef docRef= childAssocs.get(0).getChildRef(); - recordName = (String) nodeService.getProperty(docRef, ContentModel.PROP_NAME); - } - - return recordName; - } - - /** - * Helper method to extract the initiator from the task - * - * @param delegateTask The delegate task - * @return Returns the initiator of the workflow. First it will be checked if - * a rule creator exists, which means the the workflow was started via rule. - * In this case the creator of the rule will receive the review task. - * If a rule creator cannot be found the code will try to find the initiator - * of the workflow. If also this is not the case the admin user will be returned. - */ - public static String getInitiator(DelegateTask delegateTask) - { - ParameterCheck.mandatory("delegateTask", delegateTask); - - String userName = null; - - String ruleCreator = (String) delegateTask.getVariable("rmwf_ruleCreator"); - if (StringUtils.isBlank(ruleCreator)) - { - ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator"); - if (initiator.exists()) - { - userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString()); - } - else - { - userName = AuthenticationUtil.getAdminUserName(); - } - } - else - { - userName = ruleCreator; - } - - return userName; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.workflow.requestInfo; + +import java.util.List; + +import org.activiti.engine.delegate.DelegateTask; +import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.activiti.engine.impl.context.Context; +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.workflow.activiti.ActivitiConstants; +import org.alfresco.repo.workflow.activiti.ActivitiScriptNode; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; + +/** + * Util class for the request info workflow + * + * @author Tuna Aksoy + * @since 2.1 + */ +public final class RequestInfoUtils +{ + private RequestInfoUtils() + { + // Will not be called + } + + /** + * Helper method to get the service registry in order to call services + * + * @return Returns the service registry + */ + public static ServiceRegistry getServiceRegistry() + { + ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); + if (config != null) + { + // Fetch the registry that is injected in the activiti spring-configuration + ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); + if (registry == null) + { + throw new AlfrescoRuntimeException( + "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + + ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); + } + return registry; + } + throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context"); + } + + /** + * Helper method to extract the record name from the task + * + * @param delegateTask The delegate task + * @return Returns the name of the record or an empty string if the record name could not be found + (may be because the record has been deleted in the mean time) + */ + public static String getRecordName(DelegateTask delegateTask) + { + ParameterCheck.mandatory("delegateTask", delegateTask); + + String recordName = StringUtils.EMPTY; + + NodeService nodeService = getServiceRegistry().getNodeService(); + ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package"); + List childAssocs = nodeService.getChildAssocs(scriptNode.getNodeRef()); + + if (childAssocs.size() > 0) + { + NodeRef docRef= childAssocs.get(0).getChildRef(); + recordName = (String) nodeService.getProperty(docRef, ContentModel.PROP_NAME); + } + + return recordName; + } + + /** + * Helper method to extract the initiator from the task + * + * @param delegateTask The delegate task + * @return Returns the initiator of the workflow. First it will be checked if + * a rule creator exists, which means the the workflow was started via rule. + * In this case the creator of the rule will receive the review task. + * If a rule creator cannot be found the code will try to find the initiator + * of the workflow. If also this is not the case the admin user will be returned. + */ + public static String getInitiator(DelegateTask delegateTask) + { + ParameterCheck.mandatory("delegateTask", delegateTask); + + String userName = null; + + String ruleCreator = (String) delegateTask.getVariable("rmwf_ruleCreator"); + if (StringUtils.isBlank(ruleCreator)) + { + ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator"); + if (initiator.exists()) + { + userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString()); + } + else + { + userName = AuthenticationUtil.getAdminUserName(); + } + } + else + { + userName = ruleCreator; + } + + return userName; + } + +} diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoVariableHandler.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoVariableHandler.java index dec5ebc9b3..5467d47f2a 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoVariableHandler.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoVariableHandler.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.workflow.requestInfo; - -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.DelegateTask; -import org.activiti.engine.delegate.TaskListener; -import org.alfresco.util.ParameterCheck; - -/** - * A variable handler for saving the task variables to the execution context. - * Some of the information will be needed in other tasks (e.g. "rmwf_message"). - * This variable handler saves the local task variable to the execution context. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RequestInfoVariableHandler implements TaskListener -{ - private static final long serialVersionUID = -1759557028641631768L; - - /** - * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) - */ - @Override - public void notify(DelegateTask delegateTask) - { - ParameterCheck.mandatory("delegateTask", delegateTask); - - // Save the variable from the task - DelegateExecution execution = delegateTask.getExecution(); - execution.setVariable("rmwf_message", delegateTask.getVariable("rmwf_message")); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.workflow.requestInfo; + +import org.activiti.engine.delegate.DelegateExecution; +import org.activiti.engine.delegate.DelegateTask; +import org.activiti.engine.delegate.TaskListener; +import org.alfresco.util.ParameterCheck; + +/** + * A variable handler for saving the task variables to the execution context. + * Some of the information will be needed in other tasks (e.g. "rmwf_message"). + * This variable handler saves the local task variable to the execution context. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RequestInfoVariableHandler implements TaskListener +{ + private static final long serialVersionUID = -1759557028641631768L; + + /** + * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask) + */ + @Override + public void notify(DelegateTask delegateTask) + { + ParameterCheck.mandatory("delegateTask", delegateTask); + + // Save the variable from the task + DelegateExecution execution = delegateTask.getExecution(); + execution.setVariable("rmwf_message", delegateTask.getVariable("rmwf_message")); + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java index 2be90e2dab..998e846d9f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test; - -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; -import org.junit.extensions.cpsuite.ClasspathSuite.SuiteTypes; -import org.junit.extensions.cpsuite.SuiteType; -import org.junit.runner.RunWith; - -/** - * Convenience test suite that runs all the tests. - * - * @author Roy Wetherall - * @since 2.1 - */ -@RunWith(ClasspathSuite.class) -@SuiteTypes({SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES, SuiteType.JUNIT38_TEST_CLASSES}) -@ClassnameFilters({ - // Execute all test classes ending with "Test" - ".*Test", - // Exclude the ones ending with "UnitTest" - "!.*UnitTest", - // Put the test classes you want to exclude here - "!.*DataLoadSystemTest", - "!.*RM2072Test", - "!.*RM2190Test", - "!.*RM981SystemTest", - "!.*RecordsManagementEventServiceImplTest", - "!.*RmRestApiTest", - "!.*NotificationServiceHelperSystemTest", - "!.*RetryingTransactionHelperBaseTest", - "!.*RMCaveatConfigServiceImplTest", - // This test is running successfully locally but not on bamboo (if executed as a single test). - // The problem can be reproduced if the whole test suite is run locally as well. - // Tests should not be dependent on other test classes and should run in any order without any problems. - "!.*EmailMapScriptTest" -}) -public class AllTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test; + +import org.junit.extensions.cpsuite.ClasspathSuite; +import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; +import org.junit.extensions.cpsuite.ClasspathSuite.SuiteTypes; +import org.junit.extensions.cpsuite.SuiteType; +import org.junit.runner.RunWith; + +/** + * Convenience test suite that runs all the tests. + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(ClasspathSuite.class) +@SuiteTypes({SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES, SuiteType.JUNIT38_TEST_CLASSES}) +@ClassnameFilters({ + // Execute all test classes ending with "Test" + ".*Test", + // Exclude the ones ending with "UnitTest" + "!.*UnitTest", + // Put the test classes you want to exclude here + "!.*DataLoadSystemTest", + "!.*RM2072Test", + "!.*RM2190Test", + "!.*RM981SystemTest", + "!.*RecordsManagementEventServiceImplTest", + "!.*RmRestApiTest", + "!.*NotificationServiceHelperSystemTest", + "!.*RetryingTransactionHelperBaseTest", + "!.*RMCaveatConfigServiceImplTest", + // This test is running successfully locally but not on bamboo (if executed as a single test). + // The problem can be reproduced if the whole test suite is run locally as well. + // Tests should not be dependent on other test classes and should run in any order without any problems. + "!.*EmailMapScriptTest" +}) +public class AllTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java index 9fc384de39..698a00a588 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration; - -import org.alfresco.module.org_alfresco_module_rm.test.integration.disposition.DispositionTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.HoldTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.job.JobTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.record.RecordTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.RecordFolderTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.relationship.RelationshipTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.integration.version.VersionTestSuite; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * RM Integration Test Suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - DoD5015TestSuite.class, - IssueTestSuite.class, - EventTestSuite.class, - ReportTestSuite.class, - DispositionTestSuite.class, - RecordTestSuite.class, - RecordFolderTestSuite.class, - JobTestSuite.class, - HoldTestSuite.class, - VersionTestSuite.class, - RelationshipTestSuite.class/*, - TransferTestSuite.class*/ -}) -public class IntegrationTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration; + +import org.alfresco.module.org_alfresco_module_rm.test.integration.disposition.DispositionTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.HoldTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.job.JobTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.record.RecordTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.RecordFolderTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.relationship.RelationshipTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.integration.version.VersionTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * RM Integration Test Suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + DoD5015TestSuite.class, + IssueTestSuite.class, + EventTestSuite.class, + ReportTestSuite.class, + DispositionTestSuite.class, + RecordTestSuite.class, + RecordFolderTestSuite.class, + JobTestSuite.class, + HoldTestSuite.class, + VersionTestSuite.class, + RelationshipTestSuite.class/*, + TransferTestSuite.class*/ +}) +public class IntegrationTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/CutOffTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/CutOffTest.java index 2534fa64c4..d29f1f6122 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/CutOffTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/CutOffTest.java @@ -1,218 +1,218 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.GUID; - -/** - * Cut off integration tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class CutOffTest extends BaseRMTestCase -{ - /** - * given we have a record folder that is eligible for cutoff ensure that the - * record can be cut off successfully. - */ - public void testCutOffRecordFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - @Override - public void given() - { - //create record folder - recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - - // TODO add some records - - // make eligible for cutoff - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - @Override - public void when() - { - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); - } - - @Override - public void then() - { - // ensure the record folder is cut off - assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); - } - }); - - } - - /** - * given that we have a closed record folder eligible for cut off ensure that it can - * be cut off. - *

- * relates to https://issues.alfresco.com/jira/browse/RM-1340 - */ - public void testCutOffClosedRecordFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - @Override - public void given() - { - //create record folder - recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - - // TODO add some records - - // make eligible for cutoff - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - - // close the record folder - recordFolderService.closeRecordFolder(recordFolder); - } - - @Override - public void when() - { - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); - } - - @Override - public void then() - { - // ensure the record folder is cut off - assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); - } - }); - } - - /** - * given we have a record folder that is eligible for cutoff ensure that the - * record can be cut off successfully. - */ - public void testCutOffUncutOffRecordFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - @Override - public void given() - { - //create record folder - recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - nodeService.addAspect(recordFolder, ASPECT_UNCUT_OFF, null); - - // TODO add some records - - // make eligible for cutoff - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - @Override - public void when() - { - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); - } - - @Override - public void then() - { - // ensure the record folder is cut off - assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); - } - }); - - } - - /** - * given we have a record folder that is eligible for cutoff ensure that the - * record can be cut off successfully. - */ - public void testCutOffUncutOffRecordFolderFromSchedule() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - @Override - public void given() - { - //create record folder - recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - nodeService.addAspect(recordFolder, ASPECT_UNCUT_OFF, null); - - // TODO add some records - - // make eligible for cutoff - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - @Override - public void when() - { - // complete event - Map params = new HashMap(1); - params.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE); - try - { - rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, params); - } - catch(AlfrescoRuntimeException e) { } // expected - } - - @Override - public void then() - { - // ensure the record folder is cut off - assertFalse(dispositionService.isDisposableItemCutoff(recordFolder)); - } - }); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.GUID; + +/** + * Cut off integration tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class CutOffTest extends BaseRMTestCase +{ + /** + * given we have a record folder that is eligible for cutoff ensure that the + * record can be cut off successfully. + */ + public void testCutOffRecordFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + @Override + public void given() + { + //create record folder + recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + + // TODO add some records + + // make eligible for cutoff + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + @Override + public void when() + { + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); + } + + @Override + public void then() + { + // ensure the record folder is cut off + assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); + } + }); + + } + + /** + * given that we have a closed record folder eligible for cut off ensure that it can + * be cut off. + *

+ * relates to https://issues.alfresco.com/jira/browse/RM-1340 + */ + public void testCutOffClosedRecordFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + @Override + public void given() + { + //create record folder + recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + + // TODO add some records + + // make eligible for cutoff + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + + // close the record folder + recordFolderService.closeRecordFolder(recordFolder); + } + + @Override + public void when() + { + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); + } + + @Override + public void then() + { + // ensure the record folder is cut off + assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); + } + }); + } + + /** + * given we have a record folder that is eligible for cutoff ensure that the + * record can be cut off successfully. + */ + public void testCutOffUncutOffRecordFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + @Override + public void given() + { + //create record folder + recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + nodeService.addAspect(recordFolder, ASPECT_UNCUT_OFF, null); + + // TODO add some records + + // make eligible for cutoff + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + @Override + public void when() + { + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null); + } + + @Override + public void then() + { + // ensure the record folder is cut off + assertTrue(dispositionService.isDisposableItemCutoff(recordFolder)); + } + }); + + } + + /** + * given we have a record folder that is eligible for cutoff ensure that the + * record can be cut off successfully. + */ + public void testCutOffUncutOffRecordFolderFromSchedule() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + @Override + public void given() + { + //create record folder + recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + nodeService.addAspect(recordFolder, ASPECT_UNCUT_OFF, null); + + // TODO add some records + + // make eligible for cutoff + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + @Override + public void when() + { + // complete event + Map params = new HashMap(1); + params.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE); + try + { + rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, params); + } + catch(AlfrescoRuntimeException e) { } // expected + } + + @Override + public void then() + { + // ensure the record folder is cut off + assertFalse(dispositionService.isDisposableItemCutoff(recordFolder)); + } + }); + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/DispositionTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/DispositionTestSuite.java index 6d5fc61f83..71fe483156 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/DispositionTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/DispositionTestSuite.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Disposition integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - CutOffTest.class -}) -public class DispositionTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Disposition integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + CutOffTest.class +}) +public class DispositionTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/DoD5015TestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/DoD5015TestSuite.java index aa049ab276..1d878af197 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/DoD5015TestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/DoD5015TestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * DoD 5015 integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - RM1147DODRMSiteTest.class, - RM1194ExcludeDoDRecordTypesTest.class -}) -public class DoD5015TestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * DoD 5015 integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + RM1147DODRMSiteTest.class, + RM1194ExcludeDoDRecordTypesTest.class +}) +public class DoD5015TestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1147DODRMSiteTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1147DODRMSiteTest.java index 284c7e926c..3b1f5c36bf 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1147DODRMSiteTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1147DODRMSiteTest.java @@ -1,176 +1,176 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.util.GUID; - - -/** - * Integration test for RM1147 - A user can create a 'vanilla' or DOD compliant records management site. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RM1147DODRMSiteTest extends BaseRMTestCase implements DOD5015Model -{ - /** - * Don't create a RM test site in setup - */ - @Override - protected boolean isRMSiteTest() - { - return false; - } - - /** - * Test the creation of a DOD file plan via the file plan service - */ - public void testCreateDODFilePlan() - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return filePlanService.createFilePlan(folder, "myDODfileplan", TYPE_DOD_5015_FILE_PLAN); - } - - @Override - public void test(NodeRef filePlan) throws Exception - { - assertNotNull(filePlan); - assertEquals(TYPE_DOD_5015_FILE_PLAN, nodeService.getType(filePlan)); - assertTrue(filePlanService.isFilePlanComponent(filePlan)); - assertTrue(filePlanService.isFilePlan(filePlan)); - assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); - assertNotNull(filePlanService.getUnfiledContainer(filePlan)); - assertNotNull(filePlanService.getHoldContainer(filePlan)); - assertNotNull(filePlanService.getTransferContainer(filePlan)); - assertTrue(filePlanService.getFilePlans().contains(filePlan)); - assertFalse(filePlanRoleService.getRoles(filePlan).isEmpty()); - } - }); - } - - /** - * Test the creation of a DOD site via the site service - */ - public void testCreateDODRMSite() - { - doTestInTransaction(new Test() - { - String siteId = GUID.generate(); - - @Override - public SiteInfo run() throws Exception - { - return siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); - } - - @Override - public void test(SiteInfo siteInfo) throws Exception - { - assertNotNull(siteInfo); - assertEquals(TYPE_DOD_5015_SITE, nodeService.getType(siteInfo.getNodeRef())); - - NodeRef filePlan = siteService.getContainer(siteId, "documentLibrary"); - assertNotNull(filePlan); - assertEquals(TYPE_DOD_5015_FILE_PLAN, nodeService.getType(filePlan)); - assertTrue(filePlanService.isFilePlanComponent(filePlan)); - assertTrue(filePlanService.isFilePlan(filePlan)); - assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); - assertNotNull(filePlanService.getUnfiledContainer(filePlan)); - assertNotNull(filePlanService.getHoldContainer(filePlan)); - assertNotNull(filePlanService.getTransferContainer(filePlan)); - assertTrue(filePlanService.getFilePlans().contains(filePlan)); - assertFalse(filePlanRoleService.getRoles(filePlan).isEmpty()); - } - }); - } - - /** - * Test to ensure that a record created in the a DOD site does have the DOD meta-data attached - */ - public void testDODRecord() - { - doTestInTransaction(new Test() - { - String siteId = GUID.generate(); - - @Override - public NodeRef run() throws Exception - { - siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); - NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); - assertNotNull(filePlan); - - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); - NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertNotNull(record); - assertTrue(nodeService.hasAspect(record, ASPECT_DOD_5015_RECORD)); - } - }); - } - - /** - * Test to ensure a record created in a vanilla site does not have the DOD meta-data attached - */ - public void testVanillaRecord() - { - doTestInTransaction(new Test() - { - String siteId = GUID.generate(); - - @Override - public NodeRef run() throws Exception - { - siteService.createSite("rmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_RM_SITE); - NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); - assertNotNull(filePlan); - - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); - NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertNotNull(record); - assertFalse(nodeService.hasAspect(record, ASPECT_DOD_5015_RECORD)); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.util.GUID; + + +/** + * Integration test for RM1147 - A user can create a 'vanilla' or DOD compliant records management site. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RM1147DODRMSiteTest extends BaseRMTestCase implements DOD5015Model +{ + /** + * Don't create a RM test site in setup + */ + @Override + protected boolean isRMSiteTest() + { + return false; + } + + /** + * Test the creation of a DOD file plan via the file plan service + */ + public void testCreateDODFilePlan() + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return filePlanService.createFilePlan(folder, "myDODfileplan", TYPE_DOD_5015_FILE_PLAN); + } + + @Override + public void test(NodeRef filePlan) throws Exception + { + assertNotNull(filePlan); + assertEquals(TYPE_DOD_5015_FILE_PLAN, nodeService.getType(filePlan)); + assertTrue(filePlanService.isFilePlanComponent(filePlan)); + assertTrue(filePlanService.isFilePlan(filePlan)); + assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); + assertNotNull(filePlanService.getUnfiledContainer(filePlan)); + assertNotNull(filePlanService.getHoldContainer(filePlan)); + assertNotNull(filePlanService.getTransferContainer(filePlan)); + assertTrue(filePlanService.getFilePlans().contains(filePlan)); + assertFalse(filePlanRoleService.getRoles(filePlan).isEmpty()); + } + }); + } + + /** + * Test the creation of a DOD site via the site service + */ + public void testCreateDODRMSite() + { + doTestInTransaction(new Test() + { + String siteId = GUID.generate(); + + @Override + public SiteInfo run() throws Exception + { + return siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); + } + + @Override + public void test(SiteInfo siteInfo) throws Exception + { + assertNotNull(siteInfo); + assertEquals(TYPE_DOD_5015_SITE, nodeService.getType(siteInfo.getNodeRef())); + + NodeRef filePlan = siteService.getContainer(siteId, "documentLibrary"); + assertNotNull(filePlan); + assertEquals(TYPE_DOD_5015_FILE_PLAN, nodeService.getType(filePlan)); + assertTrue(filePlanService.isFilePlanComponent(filePlan)); + assertTrue(filePlanService.isFilePlan(filePlan)); + assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); + assertNotNull(filePlanService.getUnfiledContainer(filePlan)); + assertNotNull(filePlanService.getHoldContainer(filePlan)); + assertNotNull(filePlanService.getTransferContainer(filePlan)); + assertTrue(filePlanService.getFilePlans().contains(filePlan)); + assertFalse(filePlanRoleService.getRoles(filePlan).isEmpty()); + } + }); + } + + /** + * Test to ensure that a record created in the a DOD site does have the DOD meta-data attached + */ + public void testDODRecord() + { + doTestInTransaction(new Test() + { + String siteId = GUID.generate(); + + @Override + public NodeRef run() throws Exception + { + siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); + NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); + assertNotNull(filePlan); + + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); + NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertNotNull(record); + assertTrue(nodeService.hasAspect(record, ASPECT_DOD_5015_RECORD)); + } + }); + } + + /** + * Test to ensure a record created in a vanilla site does not have the DOD meta-data attached + */ + public void testVanillaRecord() + { + doTestInTransaction(new Test() + { + String siteId = GUID.generate(); + + @Override + public NodeRef run() throws Exception + { + siteService.createSite("rmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_RM_SITE); + NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); + assertNotNull(filePlan); + + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); + NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertNotNull(record); + assertFalse(nodeService.hasAspect(record, ASPECT_DOD_5015_RECORD)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java index f44d4bb753..d539e59578 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java @@ -1,115 +1,115 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - - -/** - * Integration test for RM1147 - A user can create a 'vanilla' or DOD compliant records management site. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements DOD5015Model -{ - /** - * Don't create a RM test site in setup - */ - @Override - protected boolean isRMSiteTest() - { - return false; - } - - /** - * Ensure that the correct record metadata aspects are available for a DoD record. - */ - public void testDODRecord() - { - doTestInTransaction(new Test() - { - String siteId = GUID.generate(); - - @Override - public NodeRef run() throws Exception - { - siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); - NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); - assertNotNull(filePlan); - - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); - NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertNotNull(record); - Set aspects = recordService.getRecordMetadataAspects(record); - assertNotNull(aspects); - assertEquals(5, aspects.size()); - } - }); - } - - /** - * Ensure that the correct record metadata aspects are available for a vanilla record. - */ - public void testVanillaRecord() - { - doTestInTransaction(new Test() - { - String siteId = GUID.generate(); - - @Override - public NodeRef run() throws Exception - { - siteService.createSite("rmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_RM_SITE); - NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); - assertNotNull(filePlan); - - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); - NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertNotNull(record); - Set aspects = recordService.getRecordMetadataAspects(record); - assertNotNull(aspects); - assertEquals(2, aspects.size()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.dod; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + + +/** + * Integration test for RM1147 - A user can create a 'vanilla' or DOD compliant records management site. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements DOD5015Model +{ + /** + * Don't create a RM test site in setup + */ + @Override + protected boolean isRMSiteTest() + { + return false; + } + + /** + * Ensure that the correct record metadata aspects are available for a DoD record. + */ + public void testDODRecord() + { + doTestInTransaction(new Test() + { + String siteId = GUID.generate(); + + @Override + public NodeRef run() throws Exception + { + siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE); + NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); + assertNotNull(filePlan); + + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); + NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertNotNull(record); + Set aspects = recordService.getRecordMetadataAspects(record); + assertNotNull(aspects); + assertEquals(5, aspects.size()); + } + }); + } + + /** + * Ensure that the correct record metadata aspects are available for a vanilla record. + */ + public void testVanillaRecord() + { + doTestInTransaction(new Test() + { + String siteId = GUID.generate(); + + @Override + public NodeRef run() throws Exception + { + siteService.createSite("rmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_RM_SITE); + NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary"); + assertNotNull(filePlan); + + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne"); + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne"); + NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertNotNull(record); + Set aspects = recordService.getRecordMetadataAspects(record); + assertNotNull(aspects); + assertEquals(2, aspects.size()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/CompleteEventsTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/CompleteEventsTest.java index 8be49d0b3e..3e58657765 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/CompleteEventsTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/CompleteEventsTest.java @@ -1,447 +1,447 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.event; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.GUID; - -/** - * Complete events integration tests. - *

- * Relates to: - * - https://issues.alfresco.com/jira/browse/RM-1341 - * - * @author Roy Wetherall - * @since 2.2 - */ -public class CompleteEventsTest extends BaseRMTestCase -{ - private static final String ANOTHER_EVENT = "abolished"; - - /** - * test completion of a single event on a record level disposition schedule - */ - public void testCompleteSingleEventRecordLevel() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true); - - // create record folder - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // file record - record = utils.createRecord(recordFolder, GUID.generate(), "title"); - utils.completeRecord(record); - } - - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params); - - } - - public void then() - { - // check that the record is now eligible for the next disposition action - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - - // check the next disposition action - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - } - }); - } - - /** - * test completion of a single event at the record level - */ - public void testCompleteSimpleSingleEventRecordFolderLevel() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef recordFolder; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, true); - - // create record folder - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // file record - NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); - utils.completeRecord(record); - - } - - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - public void then() - { - // check that the record is now eligible for the next disposition action - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - - // check the next disposition action - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - } - }); - } - - /** - * test complete event given at least one event is needed for the disposition action to be eligible - */ - public void testAtLeastOneEventToBeEligible() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); - - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); - - List events = new ArrayList(1); - events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); - events.add(ANOTHER_EVENT); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - dispositionService.addDispositionActionDefinition(mySchedule, adParams); - - // create record folder - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // file record - NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); - utils.completeRecord(record); - - } - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - public void then() - { - // check that the record is now eligible for the next disposition action - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - - // check the next disposition action - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - - eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); - assertNotNull(eventDetails); - assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); - assertFalse(eventDetails.isEventComplete()); - assertNull(eventDetails.getEventCompletedAt()); - assertNull(eventDetails.getEventCompletedBy()); - } - }); - } - - /** - * test that disposition action is not eligible given all events need to be completed and only has been - */ - public void testOnlyOneOfAllEventsSoNotEligible() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); - - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); - adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and"); - - List events = new ArrayList(1); - events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); - events.add(ANOTHER_EVENT); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - dispositionService.addDispositionActionDefinition(mySchedule, adParams); - - // create record folder - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // file record - NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); - utils.completeRecord(record); - } - - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - public void then() - { - assertFalse(dispositionService.isNextDispositionActionEligible(recordFolder)); - - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - - eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); - assertNotNull(eventDetails); - assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); - assertFalse(eventDetails.isEventComplete()); - assertNull(eventDetails.getEventCompletedAt()); - assertNull(eventDetails.getEventCompletedBy()); - } - }); - } - - /** - * test event complete makes disposition eligible given that all events are complete and required - */ - public void testAllEventsSoEligible() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef recordFolder = null; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); - - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); - adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and"); - - List events = new ArrayList(1); - events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); - events.add(ANOTHER_EVENT); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - dispositionService.addDispositionActionDefinition(mySchedule, adParams); - - // create record folder - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // file record - NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); - utils.completeRecord(record); - } - - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - - // build action properties - params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, ANOTHER_EVENT); - - // complete event - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - } - - public void then() - { - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - - eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); - assertNotNull(eventDetails); - assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - - } - }); - } - - /** - * test complete event works for multi-filed record - */ - public void testCompleteEventWhenCutoffMultiFiled_RM1341() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - - public void given() - { - // create record category - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - NodeRef recordCategory2 = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - // create disposition schedule - utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true); - - // create record folder - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - NodeRef recordFolder2 = recordFolderService.createRecordFolder(recordCategory2, GUID.generate()); - - // file record - String recordName = GUID.generate(); - record = utils.createRecord(recordFolder, recordName, "title"); - utils.completeRecord(record); - - // link record to second record folder - nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName)); - } - - public void when() - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - - // complete event - rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params); - } - - public void then() - { - // check that the record is now eligible for the next disposition action - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - - // check the next disposition action - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - - EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); - assertNotNull(eventDetails); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); - assertTrue(eventDetails.isEventComplete()); - assertNotNull(eventDetails.getEventCompletedAt()); - assertNotNull(eventDetails.getEventCompletedBy()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.event; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.GUID; + +/** + * Complete events integration tests. + *

+ * Relates to: + * - https://issues.alfresco.com/jira/browse/RM-1341 + * + * @author Roy Wetherall + * @since 2.2 + */ +public class CompleteEventsTest extends BaseRMTestCase +{ + private static final String ANOTHER_EVENT = "abolished"; + + /** + * test completion of a single event on a record level disposition schedule + */ + public void testCompleteSingleEventRecordLevel() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true); + + // create record folder + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // file record + record = utils.createRecord(recordFolder, GUID.generate(), "title"); + utils.completeRecord(record); + } + + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params); + + } + + public void then() + { + // check that the record is now eligible for the next disposition action + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + + // check the next disposition action + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + } + }); + } + + /** + * test completion of a single event at the record level + */ + public void testCompleteSimpleSingleEventRecordFolderLevel() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef recordFolder; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, true); + + // create record folder + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // file record + NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); + utils.completeRecord(record); + + } + + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + public void then() + { + // check that the record is now eligible for the next disposition action + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + + // check the next disposition action + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + } + }); + } + + /** + * test complete event given at least one event is needed for the disposition action to be eligible + */ + public void testAtLeastOneEventToBeEligible() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); + + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); + + List events = new ArrayList(1); + events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); + events.add(ANOTHER_EVENT); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + dispositionService.addDispositionActionDefinition(mySchedule, adParams); + + // create record folder + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // file record + NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); + utils.completeRecord(record); + + } + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + public void then() + { + // check that the record is now eligible for the next disposition action + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + + // check the next disposition action + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + + eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); + assertNotNull(eventDetails); + assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); + assertFalse(eventDetails.isEventComplete()); + assertNull(eventDetails.getEventCompletedAt()); + assertNull(eventDetails.getEventCompletedBy()); + } + }); + } + + /** + * test that disposition action is not eligible given all events need to be completed and only has been + */ + public void testOnlyOneOfAllEventsSoNotEligible() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); + + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); + adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and"); + + List events = new ArrayList(1); + events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); + events.add(ANOTHER_EVENT); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + dispositionService.addDispositionActionDefinition(mySchedule, adParams); + + // create record folder + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // file record + NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); + utils.completeRecord(record); + } + + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + public void then() + { + assertFalse(dispositionService.isNextDispositionActionEligible(recordFolder)); + + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + + eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); + assertNotNull(eventDetails); + assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); + assertFalse(eventDetails.isEventComplete()); + assertNull(eventDetails.getEventCompletedAt()); + assertNull(eventDetails.getEventCompletedBy()); + } + }); + } + + /** + * test event complete makes disposition eligible given that all events are complete and required + */ + public void testAllEventsSoEligible() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef recordFolder = null; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false); + + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION); + adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and"); + + List events = new ArrayList(1); + events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); + events.add(ANOTHER_EVENT); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + dispositionService.addDispositionActionDefinition(mySchedule, adParams); + + // create record folder + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // file record + NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title"); + utils.completeRecord(record); + } + + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + + // build action properties + params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, ANOTHER_EVENT); + + // complete event + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + } + + public void then() + { + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + + eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT); + assertNotNull(eventDetails); + assertEquals(ANOTHER_EVENT, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + + } + }); + } + + /** + * test complete event works for multi-filed record + */ + public void testCompleteEventWhenCutoffMultiFiled_RM1341() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + + public void given() + { + // create record category + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + NodeRef recordCategory2 = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + // create disposition schedule + utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true); + + // create record folder + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + NodeRef recordFolder2 = recordFolderService.createRecordFolder(recordCategory2, GUID.generate()); + + // file record + String recordName = GUID.generate(); + record = utils.createRecord(recordFolder, recordName, "title"); + utils.completeRecord(record); + + // link record to second record folder + nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName)); + } + + public void when() + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + + // complete event + rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params); + } + + public void then() + { + // check that the record is now eligible for the next disposition action + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + + // check the next disposition action + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + + EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME); + assertNotNull(eventDetails); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName()); + assertTrue(eventDetails.isEventComplete()); + assertNotNull(eventDetails.getEventCompletedAt()); + assertNotNull(eventDetails.getEventCompletedBy()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/EventTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/EventTestSuite.java index f379874344..ed906a0642 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/EventTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/event/EventTestSuite.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.event; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Event integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - CompleteEventsTest.class -}) -public class EventTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.event; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Event integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + CompleteEventsTest.class +}) +public class EventTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/AddRemoveFromHoldTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/AddRemoveFromHoldTest.java index 843bb36d6d..52285add49 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/AddRemoveFromHoldTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/AddRemoveFromHoldTest.java @@ -1,415 +1,415 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.GUID; - -/** - * Hold service integration test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class AddRemoveFromHoldTest extends BaseRMTestCase -{ - private static final int RECORD_COUNT = 10; - - public void testAddRecordToHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private NodeRef record; - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - record = recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null); - - // assert current states - assertFalse(freezeService.isFrozen(recordFolder)); - assertFalse(freezeService.isFrozen(record)); - assertFalse(freezeService.hasFrozenChildren(recordFolder)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - - public void when() throws Exception - { - // add the record to hold - holdService.addToHold(hold, record); - } - - public void then() - { - // record is held - assertTrue(freezeService.isFrozen(record)); - - // record folder has frozen children - assertFalse(freezeService.isFrozen(recordFolder)); - assertTrue(freezeService.hasFrozenChildren(recordFolder)); - - // record folder is not held - assertFalse(holdService.getHeld(hold).contains(recordFolder)); - assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); - - // hold contains record - assertTrue(holdService.getHeld(hold).contains(record)); - assertTrue(holdService.heldBy(record, true).contains(hold)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(1, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - - } - - public void testAddRecordsToHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private List records = new ArrayList(RECORD_COUNT); - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - for (int i = 0; i < RECORD_COUNT; i++) - { - records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); - } - - // assert current states - assertFalse(freezeService.isFrozen(recordFolder)); - assertFalse(freezeService.hasFrozenChildren(recordFolder)); - for (NodeRef record : records) - { - assertFalse(freezeService.isFrozen(record)); - } - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - - public void when() throws Exception - { - // add the record to hold - holdService.addToHold(hold, records); - } - - public void then() - { - // record is held - for (NodeRef record : records) - { - assertTrue(freezeService.isFrozen(record)); - } - - // record folder has frozen children - assertFalse(freezeService.isFrozen(recordFolder)); - assertTrue(freezeService.hasFrozenChildren(recordFolder)); - - // record folder is not held - assertFalse(holdService.getHeld(hold).contains(recordFolder)); - assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); - - for (NodeRef record : records) - { - // hold contains record - assertTrue(holdService.getHeld(hold).contains(record)); - assertTrue(holdService.heldBy(record, true).contains(hold)); - } - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(RECORD_COUNT, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - } - - public void testAddRecordFolderToHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private List records = new ArrayList(RECORD_COUNT); - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - for (int i = 0; i < RECORD_COUNT; i++) - { - records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); - } - - // assert current states - assertFalse(freezeService.isFrozen(recordFolder)); - assertFalse(freezeService.hasFrozenChildren(recordFolder)); - for (NodeRef record : records) - { - assertFalse(freezeService.isFrozen(record)); - } - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - - public void when() throws Exception - { - // add the record to hold - holdService.addToHold(hold, recordFolder); - } - - public void then() - { - for (NodeRef record : records) - { - // record is held - assertTrue(freezeService.isFrozen(record)); - assertFalse(holdService.getHeld(hold).contains(record)); - assertTrue(holdService.heldBy(record, true).contains(hold)); - } - - // record folder has frozen children - assertTrue(freezeService.isFrozen(recordFolder)); - assertTrue(freezeService.hasFrozenChildren(recordFolder)); - - // hold contains record folder - assertTrue(holdService.getHeld(hold).contains(recordFolder)); - assertTrue(holdService.heldBy(recordFolder, true).contains(hold)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(RECORD_COUNT, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - - } - - public void testRemoveRecordsFromHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private List records = new ArrayList(RECORD_COUNT); - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - for (int i = 0; i < RECORD_COUNT; i++) - { - records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); - } - - // add records to hold - holdService.addToHold(hold, records); - } - - public void when() throws Exception - { - // remove *some* of the records - holdService.removeFromHold(hold, records.subList(0, 5)); - } - - public void then() - { - // check record state (no longer held) - for (NodeRef record : records.subList(0, 5)) - { - assertFalse(freezeService.isFrozen(record)); - assertFalse(holdService.getHeld(hold).contains(record)); - assertFalse(holdService.heldBy(record, true).contains(hold)); - } - - // check record state (still held) - for (NodeRef record : records.subList(5, 10)) - { - assertTrue(freezeService.isFrozen(record)); - assertTrue(holdService.getHeld(hold).contains(record)); - assertTrue(holdService.heldBy(record, true).contains(hold)); - } - - // record folder has frozen children - assertFalse(freezeService.isFrozen(recordFolder)); - assertTrue(freezeService.hasFrozenChildren(recordFolder)); - - // record folder is not held - assertFalse(holdService.getHeld(hold).contains(recordFolder)); - assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(5, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - } - - public void testRemoveAllRecordsFromHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private List records = new ArrayList(RECORD_COUNT); - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - for (int i = 0; i < RECORD_COUNT; i++) - { - records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); - } - - // add records to hold - holdService.addToHold(hold, records); - } - - public void when() throws Exception - { - // remove all of the records - holdService.removeFromHold(hold, records); - } - - public void then() - { - // check record state (no longer held) - for (NodeRef record : records) - { - assertFalse(freezeService.isFrozen(record)); - assertFalse(holdService.getHeld(hold).contains(record)); - assertFalse(holdService.heldBy(record, true).contains(hold)); - } - - // record folder has frozen children - assertFalse(freezeService.isFrozen(recordFolder)); - assertFalse(freezeService.hasFrozenChildren(recordFolder)); - - // record folder is not held - assertFalse(holdService.getHeld(hold).contains(recordFolder)); - assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - } - - public void testRemoveRecordFolderFromHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef hold; - private NodeRef recordCategory; - private NodeRef recordFolder; - private List records = new ArrayList(RECORD_COUNT); - - public void given() - { - // create a hold - hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - - // create a record folder that contains records - recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - for (int i = 0; i < RECORD_COUNT; i++) - { - records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); - } - - // add record folder to hold - holdService.addToHold(hold, recordFolder); - } - - public void when() throws Exception - { - // remove record folder from hold - holdService.removeFromHold(hold, recordFolder); - } - - public void then() - { - // check record states - for (NodeRef record : records) - { - assertFalse(freezeService.isFrozen(record)); - assertFalse(holdService.getHeld(hold).contains(record)); - assertFalse(holdService.heldBy(record, true).contains(hold)); - } - - // record folder has frozen children - assertFalse(freezeService.isFrozen(recordFolder)); - assertFalse(freezeService.hasFrozenChildren(recordFolder)); - - // record folder is not held - assertFalse(holdService.getHeld(hold).contains(recordFolder)); - assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); - - // additional check for child held caching - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); - assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.GUID; + +/** + * Hold service integration test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class AddRemoveFromHoldTest extends BaseRMTestCase +{ + private static final int RECORD_COUNT = 10; + + public void testAddRecordToHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private NodeRef record; + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + record = recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null); + + // assert current states + assertFalse(freezeService.isFrozen(recordFolder)); + assertFalse(freezeService.isFrozen(record)); + assertFalse(freezeService.hasFrozenChildren(recordFolder)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + + public void when() throws Exception + { + // add the record to hold + holdService.addToHold(hold, record); + } + + public void then() + { + // record is held + assertTrue(freezeService.isFrozen(record)); + + // record folder has frozen children + assertFalse(freezeService.isFrozen(recordFolder)); + assertTrue(freezeService.hasFrozenChildren(recordFolder)); + + // record folder is not held + assertFalse(holdService.getHeld(hold).contains(recordFolder)); + assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); + + // hold contains record + assertTrue(holdService.getHeld(hold).contains(record)); + assertTrue(holdService.heldBy(record, true).contains(hold)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(1, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + + } + + public void testAddRecordsToHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private List records = new ArrayList(RECORD_COUNT); + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + for (int i = 0; i < RECORD_COUNT; i++) + { + records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); + } + + // assert current states + assertFalse(freezeService.isFrozen(recordFolder)); + assertFalse(freezeService.hasFrozenChildren(recordFolder)); + for (NodeRef record : records) + { + assertFalse(freezeService.isFrozen(record)); + } + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + + public void when() throws Exception + { + // add the record to hold + holdService.addToHold(hold, records); + } + + public void then() + { + // record is held + for (NodeRef record : records) + { + assertTrue(freezeService.isFrozen(record)); + } + + // record folder has frozen children + assertFalse(freezeService.isFrozen(recordFolder)); + assertTrue(freezeService.hasFrozenChildren(recordFolder)); + + // record folder is not held + assertFalse(holdService.getHeld(hold).contains(recordFolder)); + assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); + + for (NodeRef record : records) + { + // hold contains record + assertTrue(holdService.getHeld(hold).contains(record)); + assertTrue(holdService.heldBy(record, true).contains(hold)); + } + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(RECORD_COUNT, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + } + + public void testAddRecordFolderToHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private List records = new ArrayList(RECORD_COUNT); + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + for (int i = 0; i < RECORD_COUNT; i++) + { + records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); + } + + // assert current states + assertFalse(freezeService.isFrozen(recordFolder)); + assertFalse(freezeService.hasFrozenChildren(recordFolder)); + for (NodeRef record : records) + { + assertFalse(freezeService.isFrozen(record)); + } + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + + public void when() throws Exception + { + // add the record to hold + holdService.addToHold(hold, recordFolder); + } + + public void then() + { + for (NodeRef record : records) + { + // record is held + assertTrue(freezeService.isFrozen(record)); + assertFalse(holdService.getHeld(hold).contains(record)); + assertTrue(holdService.heldBy(record, true).contains(hold)); + } + + // record folder has frozen children + assertTrue(freezeService.isFrozen(recordFolder)); + assertTrue(freezeService.hasFrozenChildren(recordFolder)); + + // hold contains record folder + assertTrue(holdService.getHeld(hold).contains(recordFolder)); + assertTrue(holdService.heldBy(recordFolder, true).contains(hold)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(RECORD_COUNT, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + + } + + public void testRemoveRecordsFromHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private List records = new ArrayList(RECORD_COUNT); + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + for (int i = 0; i < RECORD_COUNT; i++) + { + records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); + } + + // add records to hold + holdService.addToHold(hold, records); + } + + public void when() throws Exception + { + // remove *some* of the records + holdService.removeFromHold(hold, records.subList(0, 5)); + } + + public void then() + { + // check record state (no longer held) + for (NodeRef record : records.subList(0, 5)) + { + assertFalse(freezeService.isFrozen(record)); + assertFalse(holdService.getHeld(hold).contains(record)); + assertFalse(holdService.heldBy(record, true).contains(hold)); + } + + // check record state (still held) + for (NodeRef record : records.subList(5, 10)) + { + assertTrue(freezeService.isFrozen(record)); + assertTrue(holdService.getHeld(hold).contains(record)); + assertTrue(holdService.heldBy(record, true).contains(hold)); + } + + // record folder has frozen children + assertFalse(freezeService.isFrozen(recordFolder)); + assertTrue(freezeService.hasFrozenChildren(recordFolder)); + + // record folder is not held + assertFalse(holdService.getHeld(hold).contains(recordFolder)); + assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(5, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + } + + public void testRemoveAllRecordsFromHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private List records = new ArrayList(RECORD_COUNT); + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + for (int i = 0; i < RECORD_COUNT; i++) + { + records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); + } + + // add records to hold + holdService.addToHold(hold, records); + } + + public void when() throws Exception + { + // remove all of the records + holdService.removeFromHold(hold, records); + } + + public void then() + { + // check record state (no longer held) + for (NodeRef record : records) + { + assertFalse(freezeService.isFrozen(record)); + assertFalse(holdService.getHeld(hold).contains(record)); + assertFalse(holdService.heldBy(record, true).contains(hold)); + } + + // record folder has frozen children + assertFalse(freezeService.isFrozen(recordFolder)); + assertFalse(freezeService.hasFrozenChildren(recordFolder)); + + // record folder is not held + assertFalse(holdService.getHeld(hold).contains(recordFolder)); + assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + } + + public void testRemoveRecordFolderFromHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef hold; + private NodeRef recordCategory; + private NodeRef recordFolder; + private List records = new ArrayList(RECORD_COUNT); + + public void given() + { + // create a hold + hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + + // create a record folder that contains records + recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + for (int i = 0; i < RECORD_COUNT; i++) + { + records.add(recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null)); + } + + // add record folder to hold + holdService.addToHold(hold, recordFolder); + } + + public void when() throws Exception + { + // remove record folder from hold + holdService.removeFromHold(hold, recordFolder); + } + + public void then() + { + // check record states + for (NodeRef record : records) + { + assertFalse(freezeService.isFrozen(record)); + assertFalse(holdService.getHeld(hold).contains(record)); + assertFalse(holdService.heldBy(record, true).contains(hold)); + } + + // record folder has frozen children + assertFalse(freezeService.isFrozen(recordFolder)); + assertFalse(freezeService.hasFrozenChildren(recordFolder)); + + // record folder is not held + assertFalse(holdService.getHeld(hold).contains(recordFolder)); + assertFalse(holdService.heldBy(recordFolder, true).contains(hold)); + + // additional check for child held caching + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN)); + assertEquals(0, nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/CreateHoldTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/CreateHoldTest.java index 08f6af286f..c38ccebfb6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/CreateHoldTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/CreateHoldTest.java @@ -1,128 +1,128 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.hold; - -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; -import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; -import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; -import static org.alfresco.util.GUID.generate; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Tests that the user who created the hold has filing permissions on the created hold. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class CreateHoldTest extends BaseRMTestCase -{ - // Test user - private String testUser = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Create test user - testUser = generate(); - createPerson(testUser); - - // Join the RM site - siteService.setMembership(siteId, testUser, SITE_CONSUMER); - - // Create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability(VIEW_RECORDS)); - capabilities.add(capabilityService.getCapability(CREATE_HOLD)); - Role role = filePlanRoleService.createRole(filePlan, generate(), generate(), capabilities); - - // Add the test user to RM Records Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, role.getName(), testUser); - } - - public void testFilingPermissionOnCreatedHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(testUser) - { - // Hold - private NodeRef hold; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - // Give test user filing permissions on hold container - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // ensure the user has the correct permission to create the hold - filePlanPermissionService.setPermission(holdsContainer, testUser, FILING); - - return null; - } - }, getAdminUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - // Create a hold - hold = holdService.createHold(filePlan, generate(), generate(), generate()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - // Check the permission on the hold - assertEquals(ALLOWED, permissionService.hasPermission(hold, FILING)); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.hold; + +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; +import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.util.GUID.generate; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Tests that the user who created the hold has filing permissions on the created hold. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class CreateHoldTest extends BaseRMTestCase +{ + // Test user + private String testUser = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Create test user + testUser = generate(); + createPerson(testUser); + + // Join the RM site + siteService.setMembership(siteId, testUser, SITE_CONSUMER); + + // Create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability(VIEW_RECORDS)); + capabilities.add(capabilityService.getCapability(CREATE_HOLD)); + Role role = filePlanRoleService.createRole(filePlan, generate(), generate(), capabilities); + + // Add the test user to RM Records Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, role.getName(), testUser); + } + + public void testFilingPermissionOnCreatedHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(testUser) + { + // Hold + private NodeRef hold; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() + */ + @Override + public void given() throws Exception + { + // Give test user filing permissions on hold container + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // ensure the user has the correct permission to create the hold + filePlanPermissionService.setPermission(holdsContainer, testUser, FILING); + + return null; + } + }, getAdminUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() + */ + @Override + public void when() throws Exception + { + // Create a hold + hold = holdService.createHold(filePlan, generate(), generate(), generate()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() + */ + @Override + public void then() throws Exception + { + // Check the permission on the hold + assertEquals(ALLOWED, permissionService.hasPermission(hold, FILING)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/DeleteHoldTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/DeleteHoldTest.java index cc329063b2..9265531132 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/DeleteHoldTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/DeleteHoldTest.java @@ -1,213 +1,213 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Hold service integration test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class DeleteHoldTest extends BaseRMTestCase -{ - /** Constants for the holds */ - protected static final String HOLD1_NAME = "hold one"; - protected static final String HOLD2_NAME = "hold two"; - protected static final String HOLD1_REASON = "I have my reasons"; - protected static final String HOLD2_REASON = "secrets are everything"; - protected static final String HOLD1_DESC = "but I'll not describe them here!"; - protected static final String HOLD2_DESC = "no then! that's just not on!"; - - @Override - protected boolean isRecordTest() - { - return true; - } - - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * Creates a hold and checks if the hold is null or not - * - * @return {@link NodeRef} Node reference of the hold. - */ - protected NodeRef createAndCheckHold() - { - NodeRef hold = holdService.createHold(filePlan, HOLD1_NAME, HOLD1_REASON, HOLD1_DESC); - assertNotNull(hold); - return hold; - } - - /** - * Creates two holds and checks them if they are null or not - * - * @return List of {@link NodeRef}s of the holds. - */ - protected List createAndCheckHolds() - { - List holds = new ArrayList(2); - holds.add(createAndCheckHold()); - NodeRef hold2 = holdService.createHold(filePlan, HOLD2_NAME, HOLD2_REASON, HOLD2_DESC); - assertNotNull(hold2); - holds.add(hold2); - assertEquals(2, holds.size()); - return holds; - } - - public void testDeleteHoldBehaviourForRecordFolder() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // create test holds - NodeRef hold1 = createAndCheckHold(); - - // add the record folder to hold1 - holdService.addToHold(hold1, rmFolder); - - // assert that the folder and records are frozen - assertTrue(freezeService.isFrozen(rmFolder)); - assertTrue(freezeService.isFrozen(recordOne)); - assertTrue(freezeService.isFrozen(recordDeclaredOne)); - - // check the contents of the hold - List frozenNodes = holdService.getHeld(hold1); - assertNotNull(frozenNodes); - assertEquals(1, frozenNodes.size()); - assertEquals(rmFolder, frozenNodes.get(0)); - - // delete the hold - holdService.deleteHold(hold1); - - // assert that the folder and records no longer frozen - assertFalse(freezeService.isFrozen(rmFolder)); - assertFalse(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(recordDeclaredOne)); - - // confirm the hold has been deleted - assertNull(holdService.getHold(filePlan, "hold one")); - - return null; - } - }); - } - - public void testDeleteHoldBehaviourForMultipleHolds() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // create test holds - List holds = createAndCheckHolds(); - NodeRef hold1 = holds.get(0); - NodeRef hold2 = holds.get(1); - - // add the record folder to hold1 - holdService.addToHold(hold1, rmFolder); - - // assert that the folder and records are frozen - assertTrue(freezeService.isFrozen(rmFolder)); - assertTrue(freezeService.isFrozen(recordOne)); - assertTrue(freezeService.isFrozen(recordDeclaredOne)); - - // check the contents of the hold - List frozenNodes = holdService.getHeld(hold1); - assertNotNull(frozenNodes); - assertEquals(1, frozenNodes.size()); - assertEquals(rmFolder, frozenNodes.get(0)); - - holdService.addToHold(hold2, recordOne); - - // assert that the folder and records are frozen - assertTrue(freezeService.isFrozen(rmFolder)); - assertTrue(freezeService.isFrozen(recordOne)); - assertTrue(freezeService.isFrozen(recordDeclaredOne)); - - // delete the hold - holdService.deleteHold(hold1); - - // assert that the folder and records no longer frozen - assertFalse(freezeService.isFrozen(rmFolder)); - assertTrue(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(recordDeclaredOne)); - - // confirm the hold has been deleted - assertNull(holdService.getHold(filePlan, "hold one")); - - // delete the hold - holdService.deleteHold(hold2); - - // assert that the folder and records no longer frozen - assertFalse(freezeService.isFrozen(rmFolder)); - assertFalse(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(recordDeclaredOne)); - - // confirm the hold has been deleted - assertNull(holdService.getHold(filePlan, "hold two")); - - return null; - } - }); - } - - public void testHeldByNothing() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Create the test holds - createAndCheckHolds(); - - // Check that the record folder isn't held by anything - List holds = new ArrayList(); - holds.addAll(holdService.heldBy(rmFolder, true)); - assertTrue(holds.isEmpty()); - holds.clear(); - holds.addAll(holdService.heldBy(rmFolder, false)); - assertEquals(2, holds.size()); - - // Check that record isn't held by anything (recordOne is a child of the rmFolder) - holds.clear(); - holds.addAll(holdService.heldBy(recordOne, true)); - assertTrue(holds.isEmpty()); - holds.clear(); - holds.addAll(holdService.heldBy(recordOne, false)); - assertEquals(2, holds.size()); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Hold service integration test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class DeleteHoldTest extends BaseRMTestCase +{ + /** Constants for the holds */ + protected static final String HOLD1_NAME = "hold one"; + protected static final String HOLD2_NAME = "hold two"; + protected static final String HOLD1_REASON = "I have my reasons"; + protected static final String HOLD2_REASON = "secrets are everything"; + protected static final String HOLD1_DESC = "but I'll not describe them here!"; + protected static final String HOLD2_DESC = "no then! that's just not on!"; + + @Override + protected boolean isRecordTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * Creates a hold and checks if the hold is null or not + * + * @return {@link NodeRef} Node reference of the hold. + */ + protected NodeRef createAndCheckHold() + { + NodeRef hold = holdService.createHold(filePlan, HOLD1_NAME, HOLD1_REASON, HOLD1_DESC); + assertNotNull(hold); + return hold; + } + + /** + * Creates two holds and checks them if they are null or not + * + * @return List of {@link NodeRef}s of the holds. + */ + protected List createAndCheckHolds() + { + List holds = new ArrayList(2); + holds.add(createAndCheckHold()); + NodeRef hold2 = holdService.createHold(filePlan, HOLD2_NAME, HOLD2_REASON, HOLD2_DESC); + assertNotNull(hold2); + holds.add(hold2); + assertEquals(2, holds.size()); + return holds; + } + + public void testDeleteHoldBehaviourForRecordFolder() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // create test holds + NodeRef hold1 = createAndCheckHold(); + + // add the record folder to hold1 + holdService.addToHold(hold1, rmFolder); + + // assert that the folder and records are frozen + assertTrue(freezeService.isFrozen(rmFolder)); + assertTrue(freezeService.isFrozen(recordOne)); + assertTrue(freezeService.isFrozen(recordDeclaredOne)); + + // check the contents of the hold + List frozenNodes = holdService.getHeld(hold1); + assertNotNull(frozenNodes); + assertEquals(1, frozenNodes.size()); + assertEquals(rmFolder, frozenNodes.get(0)); + + // delete the hold + holdService.deleteHold(hold1); + + // assert that the folder and records no longer frozen + assertFalse(freezeService.isFrozen(rmFolder)); + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordDeclaredOne)); + + // confirm the hold has been deleted + assertNull(holdService.getHold(filePlan, "hold one")); + + return null; + } + }); + } + + public void testDeleteHoldBehaviourForMultipleHolds() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // create test holds + List holds = createAndCheckHolds(); + NodeRef hold1 = holds.get(0); + NodeRef hold2 = holds.get(1); + + // add the record folder to hold1 + holdService.addToHold(hold1, rmFolder); + + // assert that the folder and records are frozen + assertTrue(freezeService.isFrozen(rmFolder)); + assertTrue(freezeService.isFrozen(recordOne)); + assertTrue(freezeService.isFrozen(recordDeclaredOne)); + + // check the contents of the hold + List frozenNodes = holdService.getHeld(hold1); + assertNotNull(frozenNodes); + assertEquals(1, frozenNodes.size()); + assertEquals(rmFolder, frozenNodes.get(0)); + + holdService.addToHold(hold2, recordOne); + + // assert that the folder and records are frozen + assertTrue(freezeService.isFrozen(rmFolder)); + assertTrue(freezeService.isFrozen(recordOne)); + assertTrue(freezeService.isFrozen(recordDeclaredOne)); + + // delete the hold + holdService.deleteHold(hold1); + + // assert that the folder and records no longer frozen + assertFalse(freezeService.isFrozen(rmFolder)); + assertTrue(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordDeclaredOne)); + + // confirm the hold has been deleted + assertNull(holdService.getHold(filePlan, "hold one")); + + // delete the hold + holdService.deleteHold(hold2); + + // assert that the folder and records no longer frozen + assertFalse(freezeService.isFrozen(rmFolder)); + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordDeclaredOne)); + + // confirm the hold has been deleted + assertNull(holdService.getHold(filePlan, "hold two")); + + return null; + } + }); + } + + public void testHeldByNothing() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Create the test holds + createAndCheckHolds(); + + // Check that the record folder isn't held by anything + List holds = new ArrayList(); + holds.addAll(holdService.heldBy(rmFolder, true)); + assertTrue(holds.isEmpty()); + holds.clear(); + holds.addAll(holdService.heldBy(rmFolder, false)); + assertEquals(2, holds.size()); + + // Check that record isn't held by anything (recordOne is a child of the rmFolder) + holds.clear(); + holds.addAll(holdService.heldBy(recordOne, true)); + assertTrue(holds.isEmpty()); + holds.clear(); + holds.addAll(holdService.heldBy(recordOne, false)); + assertEquals(2, holds.size()); + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/HoldTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/HoldTestSuite.java index fc81361be2..06e89ccd5b 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/HoldTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/hold/HoldTestSuite.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Hold test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - DeleteHoldTest.class, - AddRemoveFromHoldTest.class, - CreateHoldTest.class -}) -public class HoldTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.hold; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Hold test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + DeleteHoldTest.class, + AddRemoveFromHoldTest.class, + CreateHoldTest.class +}) +public class HoldTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java index 4b6c387171..74ad459f61 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Issue test suite - * - * @author Roy Wetherall - * @since 2.1 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - RM1008Test.class, - RM1027Test.class, - RM1030Test.class, - RM1424Test.class, - RM1429Test.class, - RM1463Test.class, - RM1464Test.class, - RM452Test.class, - RM804Test.class, - RM994Test.class, - RM1039Test.class, - RM1799Test.class, - RM1814Test.class, - RM978Test.class, - RM1887Test.class, - RM1914Test.class, - //RM2190Test.class, - RM2192Test.class, - RM3314Test.class -}) -public class IssueTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314Test; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Issue test suite + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + RM1008Test.class, + RM1027Test.class, + RM1030Test.class, + RM1424Test.class, + RM1429Test.class, + RM1463Test.class, + RM1464Test.class, + RM452Test.class, + RM804Test.class, + RM994Test.class, + RM1039Test.class, + RM1799Test.class, + RM1814Test.class, + RM978Test.class, + RM1887Test.class, + RM1914Test.class, + //RM2190Test.class, + RM2192Test.class, + RM3314Test.class +}) +public class IssueTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1008Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1008Test.java index 0066a3ea58..334cd3de19 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1008Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1008Test.java @@ -1,359 +1,359 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; - - -/** - * Test for RM-1008 - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM1008Test extends BaseRMTestCase -{ - private String myUser; - - @Override - protected boolean isRecordTest() - { - return true; - } - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - myUser = GUID.generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, myUser); - } - - public void testContainers() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); - assertNotNull(holdContainer); - NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); - assertNotNull(transferContainer); - - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); - - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); - assertNotNull(holdContainer); - NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); - assertNotNull(transferContainer); - - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - } - - public void testHold() - { - final NodeRef hold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create hold object - NodeRef hold = holdService.createHold(filePlan, "my hold", "my reason", "my description"); - holdService.addToHold(hold, rmFolder); - return hold; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.setPermission(filePlan, myUser, FILING); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.deletePermission(filePlan, myUser, FILING); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - } - - public void testTransfer() - { - final NodeRef transferFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - NodeRef transferCat = filePlanService.createRecordCategory(filePlan, "transferCat"); - - Map dsProps = new HashMap(3); - dsProps.put(PROP_DISPOSITION_AUTHORITY, "test"); - dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test"); - dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false); - DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps); - - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); - adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); - adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); - - dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - - adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer"); - adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); - adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); - - dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - - return recordFolderService.createRecordFolder(transferCat, "transferFolder"); - } - }); - - final NodeRef transfer = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - rmActionService.executeRecordsManagementAction(transferFolder, "cutoff"); - rmActionService.executeRecordsManagementAction(transferFolder, "transfer"); - - NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); - List childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - return childAssocs.get(0).getChildRef(); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertEquals(TYPE_TRANSFER, nodeService.getType(result)); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.setPermission(filePlan, myUser, FILING); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.deletePermission(filePlan, myUser, FILING); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Capability viewRecords = capabilityService.getCapability("ViewRecords"); - assertNotNull(viewRecords); - - assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - - return null; - } - }, myUser); - - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.GUID; + + +/** + * Test for RM-1008 + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM1008Test extends BaseRMTestCase +{ + private String myUser; + + @Override + protected boolean isRecordTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + myUser = GUID.generate(); + createPerson(myUser); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, myUser); + } + + public void testContainers() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + assertNotNull(holdContainer); + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + assertNotNull(transferContainer); + + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); + + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + assertNotNull(holdContainer); + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + assertNotNull(transferContainer); + + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + } + + public void testHold() + { + final NodeRef hold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create hold object + NodeRef hold = holdService.createHold(filePlan, "my hold", "my reason", "my description"); + holdService.addToHold(hold, rmFolder); + return hold; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(filePlan, myUser, FILING); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.deletePermission(filePlan, myUser, FILING); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(hold)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + } + + public void testTransfer() + { + final NodeRef transferFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + NodeRef transferCat = filePlanService.createRecordCategory(filePlan, "transferCat"); + + Map dsProps = new HashMap(3); + dsProps.put(PROP_DISPOSITION_AUTHORITY, "test"); + dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test"); + dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false); + DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps); + + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); + adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); + adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); + + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); + + adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer"); + adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); + adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); + + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); + + return recordFolderService.createRecordFolder(transferCat, "transferFolder"); + } + }); + + final NodeRef transfer = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + rmActionService.executeRecordsManagementAction(transferFolder, "cutoff"); + rmActionService.executeRecordsManagementAction(transferFolder, "transfer"); + + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + List childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + return childAssocs.get(0).getChildRef(); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertEquals(TYPE_TRANSFER, nodeService.getType(result)); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(filePlan, myUser, FILING); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.deletePermission(filePlan, myUser, FILING); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Capability viewRecords = capabilityService.getCapability("ViewRecords"); + assertNotNull(viewRecords); + + assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); + + return null; + } + }, myUser); + + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1027Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1027Test.java index ac329a9ad6..68ca52ff1c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1027Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1027Test.java @@ -1,117 +1,117 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * Unit test for RM-1027 .. can't copy a closed folder - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM1027Test extends BaseRMTestCase -{ - public void testCopyingAClosedFolder() throws Exception - { - final NodeRef recordFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a folder and close it - NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); - utils.closeFolder(recordFolder); - - assertTrue((Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED)); - - return recordFolder; - } - }); - - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - // create a destination for the copy - NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); - - // try and copy the closed record folder - FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); - - return copyInfo.getNodeRef(); - } - - @Override - public void test(NodeRef copy) throws Exception - { - assertNotNull(copy); - - assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); - assertFalse((Boolean)nodeService.getProperty(copy, PROP_IS_CLOSED)); - } - }); - } - - public void testCopyingAFolderWithADispositionSchedule() throws Exception - { - final NodeRef recordFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a folder - NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); - - // show that the default disposition schedule has been applied - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - - return recordFolder; - } - }); - - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - // create a destination for the copy - NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); - - // try and copy the closed record folder - FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); - - return copyInfo.getNodeRef(); - } - - @Override - public void test(NodeRef copy) throws Exception - { - assertNotNull(copy); - - assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); - assertFalse(nodeService.hasAspect(copy, ASPECT_DISPOSITION_LIFECYCLE)); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Unit test for RM-1027 .. can't copy a closed folder + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM1027Test extends BaseRMTestCase +{ + public void testCopyingAClosedFolder() throws Exception + { + final NodeRef recordFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a folder and close it + NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); + utils.closeFolder(recordFolder); + + assertTrue((Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED)); + + return recordFolder; + } + }); + + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + // create a destination for the copy + NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); + + // try and copy the closed record folder + FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); + + return copyInfo.getNodeRef(); + } + + @Override + public void test(NodeRef copy) throws Exception + { + assertNotNull(copy); + + assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); + assertFalse((Boolean)nodeService.getProperty(copy, PROP_IS_CLOSED)); + } + }); + } + + public void testCopyingAFolderWithADispositionSchedule() throws Exception + { + final NodeRef recordFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a folder + NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); + + // show that the default disposition schedule has been applied + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + + return recordFolder; + } + }); + + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + // create a destination for the copy + NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); + + // try and copy the closed record folder + FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); + + return copyInfo.getNodeRef(); + } + + @Override + public void test(NodeRef copy) throws Exception + { + assertNotNull(copy); + + assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); + assertFalse(nodeService.hasAspect(copy, ASPECT_DISPOSITION_LIFECYCLE)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1030Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1030Test.java index 3f692b4adb..c118a08bab 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1030Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1030Test.java @@ -1,155 +1,155 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * Unit test for RM-1030 .. can't freeze a record folder that already has a frozen record contained within - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM1030Test extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - public void testRM1030() throws Exception - { - final NodeRef recordHold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - Set auths = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_ADMIN); - for (String auth : auths) - { - System.out.println(auth); - } - - // show there are no holds when we start - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(0, holds.size()); - - // freeze record contained within the record folder - NodeRef hold = holdService.createHold(filePlan, "my hold 2", "in true life for serious", "my decription"); - holdService.addToHold(hold, recordOne); - assertNotNull(hold); - - return hold; - } - - @Override - public void test(NodeRef hold) throws Exception - { - // show the record is frozen - assertTrue(freezeService.isFrozen(recordOne)); - - // count the number of holds - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(1, holds.size()); - } - - }); - - final NodeRef recordFolderHold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // freeze the record folder that contains the frozen record - NodeRef folderHold = holdService.createHold(filePlan, "my hold 3", "innit but", "my decription"); - holdService.addToHold(folderHold, rmFolder); - assertNotNull(folderHold); - - return folderHold; - } - - @Override - public void test(NodeRef hold) throws Exception - { - // show that the record and the record folder are frozen - assertTrue(freezeService.isFrozen(recordOne)); - assertTrue(freezeService.isFrozen(rmFolder)); - - // count the number of holds - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(2, holds.size()); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // relinquish the record folder hold - holdService.deleteHold(recordFolderHold); - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertTrue(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(rmFolder)); - - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(1, holds.size()); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // relinquish the record hold - holdService.deleteHold(recordHold); - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertFalse(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(rmFolder)); - - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(0, holds.size()); - } - }); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Unit test for RM-1030 .. can't freeze a record folder that already has a frozen record contained within + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM1030Test extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testRM1030() throws Exception + { + final NodeRef recordHold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + Set auths = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_ADMIN); + for (String auth : auths) + { + System.out.println(auth); + } + + // show there are no holds when we start + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + + // freeze record contained within the record folder + NodeRef hold = holdService.createHold(filePlan, "my hold 2", "in true life for serious", "my decription"); + holdService.addToHold(hold, recordOne); + assertNotNull(hold); + + return hold; + } + + @Override + public void test(NodeRef hold) throws Exception + { + // show the record is frozen + assertTrue(freezeService.isFrozen(recordOne)); + + // count the number of holds + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + } + + }); + + final NodeRef recordFolderHold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // freeze the record folder that contains the frozen record + NodeRef folderHold = holdService.createHold(filePlan, "my hold 3", "innit but", "my decription"); + holdService.addToHold(folderHold, rmFolder); + assertNotNull(folderHold); + + return folderHold; + } + + @Override + public void test(NodeRef hold) throws Exception + { + // show that the record and the record folder are frozen + assertTrue(freezeService.isFrozen(recordOne)); + assertTrue(freezeService.isFrozen(rmFolder)); + + // count the number of holds + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(2, holds.size()); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // relinquish the record folder hold + holdService.deleteHold(recordFolderHold); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertTrue(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(rmFolder)); + + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // relinquish the record hold + holdService.deleteHold(recordHold); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(rmFolder)); + + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + } + }); + + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java index 512d16709d..8ef86eef6e 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java @@ -1,186 +1,186 @@ -/* - * 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.test.integration.issue; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM1039Test extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - // try and move a folder from no disposition schedule to a disposition schedule - public void testMoveRecordFolderFromNoDisToDis() throws Exception - { - final NodeRef recordFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record category (no disposition schedule) - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); - - // create a record folder - return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall"); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNull(dispositionService.getDispositionSchedule(result)); - assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - } - }); - - final NodeRef record = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record - return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNull(dispositionService.getDispositionSchedule(result)); - assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - } - }); - - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders"); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder)); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer)); - - // take a look at the move capability - Capability moveCapability = capabilityService.getCapability("Move"); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer)); - - // move the node - return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef(); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNotNull(dispositionService.getDispositionSchedule(result)); - assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result); - assertNotNull(dispositionAction); - - assertNull(dispositionAction.getAsOfDate()); - assertEquals("cutoff", dispositionAction.getName()); - assertEquals(1, dispositionAction.getEventCompletionDetails().size()); - - // take a look at the record and check things are as we would expect - assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - } - }); - } - - // move from a disposition schedule to another .. both record folder level - - // move from a disposition schedule to another .. from record to folder level - - - // try and move a cutoff folder - public void testMoveCutoffRecordFolder() throws Exception - { - final NodeRef destination = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record category (no disposition schedule) - return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); - } - }); - - final NodeRef testFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create folder - NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis"); - - // complete event - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params); - - // cutoff folder - rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME); - - return testFolder; - } - - @Override - public void test(NodeRef result) throws Exception - { - // take a look at the move capability - Capability moveCapability = capabilityService.getCapability("Move"); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(result, destination)); - - } - }); - - doTestInTransaction(new FailureTest() - { - @Override - public void run() throws Exception - { - fileFolderService.move(testFolder, destination, null).getNodeRef(); - } - }); - } -} +/* + * 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.test.integration.issue; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM1039Test extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + // try and move a folder from no disposition schedule to a disposition schedule + public void testMoveRecordFolderFromNoDisToDis() throws Exception + { + final NodeRef recordFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record category (no disposition schedule) + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); + + // create a record folder + return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall"); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNull(dispositionService.getDispositionSchedule(result)); + assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + } + }); + + final NodeRef record = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record + return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNull(dispositionService.getDispositionSchedule(result)); + assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + } + }); + + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders"); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder)); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer)); + + // take a look at the move capability + Capability moveCapability = capabilityService.getCapability("Move"); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer)); + + // move the node + return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef(); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNotNull(dispositionService.getDispositionSchedule(result)); + assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result); + assertNotNull(dispositionAction); + + assertNull(dispositionAction.getAsOfDate()); + assertEquals("cutoff", dispositionAction.getName()); + assertEquals(1, dispositionAction.getEventCompletionDetails().size()); + + // take a look at the record and check things are as we would expect + assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + } + }); + } + + // move from a disposition schedule to another .. both record folder level + + // move from a disposition schedule to another .. from record to folder level + + + // try and move a cutoff folder + public void testMoveCutoffRecordFolder() throws Exception + { + final NodeRef destination = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record category (no disposition schedule) + return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); + } + }); + + final NodeRef testFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create folder + NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis"); + + // complete event + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params); + + // cutoff folder + rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME); + + return testFolder; + } + + @Override + public void test(NodeRef result) throws Exception + { + // take a look at the move capability + Capability moveCapability = capabilityService.getCapability("Move"); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(result, destination)); + + } + }); + + doTestInTransaction(new FailureTest() + { + @Override + public void run() throws Exception + { + fileFolderService.move(testFolder, destination, null).getNodeRef(); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java index 78eacc5927..b17642959c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java @@ -1,119 +1,119 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unit test for https://issues.alfresco.com/jira/browse/RM-1424 - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class RM1424Test extends DeleteHoldTest -{ - public void testGettingHolds() - { - final List listWithTwoHolds = new ArrayList(2); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // No holds - List emptyHoldList = holdService.getHolds(filePlan); - assertNotNull(emptyHoldList); - assertTrue(emptyHoldList.isEmpty()); - - // Create 2 holds - createAndCheckHolds(); - - // Check the list of holds - listWithTwoHolds.addAll(holdService.getHolds(filePlan)); - assertNotNull(listWithTwoHolds); - assertEquals(2, listWithTwoHolds.size()); - - // Check the first hold - NodeRef hold1 = listWithTwoHolds.get(0); - assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1)); - assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME)); - assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON)); - assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION)); - - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Get the holds the test user without having any permissions on the holds - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(0, holds.size()); - - return null; - } - }, userName); - - final NodeRef hold2 = listWithTwoHolds.get(1); - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Give the user read permissions on the hold - permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(1, holds.size()); - assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2)); - assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME)); - assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON)); - assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION)); - - return null; - } - }, userName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1424 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1424Test extends DeleteHoldTest +{ + public void testGettingHolds() + { + final List listWithTwoHolds = new ArrayList(2); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // No holds + List emptyHoldList = holdService.getHolds(filePlan); + assertNotNull(emptyHoldList); + assertTrue(emptyHoldList.isEmpty()); + + // Create 2 holds + createAndCheckHolds(); + + // Check the list of holds + listWithTwoHolds.addAll(holdService.getHolds(filePlan)); + assertNotNull(listWithTwoHolds); + assertEquals(2, listWithTwoHolds.size()); + + // Check the first hold + NodeRef hold1 = listWithTwoHolds.get(0); + assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1)); + assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME)); + assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON)); + assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION)); + + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Get the holds the test user without having any permissions on the holds + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + + return null; + } + }, userName); + + final NodeRef hold2 = listWithTwoHolds.get(1); + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Give the user read permissions on the hold + permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2)); + assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME)); + assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON)); + assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION)); + + return null; + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429Test.java index f35e2f10e9..d2f84e0e03 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429Test.java @@ -1,71 +1,71 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unit test for https://issues.alfresco.com/jira/browse/RM-1429 - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class RM1429Test extends DeleteHoldTest -{ - public void testDeleteHoldWithoutPermissionsOnChildren() - { - final NodeRef hold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // Create the test hold - NodeRef hold = createAndCheckHold(); - - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); - - // Give the user filing permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); - - // Give the user read permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); - - // Add record folder to the hold - holdService.addToHold(hold, rmFolder); - - return hold; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() - { - holdService.deleteHold(hold); - } - }, userName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1429 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1429Test extends DeleteHoldTest +{ + public void testDeleteHoldWithoutPermissionsOnChildren() + { + final NodeRef hold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // Create the test hold + NodeRef hold = createAndCheckHold(); + + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); + + // Give the user filing permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); + + // Give the user read permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); + + // Add record folder to the hold + holdService.addToHold(hold, rmFolder); + + return hold; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.deleteHold(hold); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java index 517b316ab1..4a7eb1a975 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unit test for https://issues.alfresco.com/jira/browse/RM-1463 - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class RM1463Test extends DeleteHoldTest -{ - public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder() - { - final NodeRef hold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // Create hold - NodeRef hold = createAndCheckHold(); - - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); - - // Give the user filing permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); - - // Give the user only read permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); - - return hold; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() - { - holdService.addToHold(hold, rmFolder); - } - }, userName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1463 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1463Test extends DeleteHoldTest +{ + public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder() + { + final NodeRef hold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // Create hold + NodeRef hold = createAndCheckHold(); + + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); + + // Give the user filing permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); + + // Give the user only read permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); + + return hold; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.addToHold(hold, rmFolder); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java index 83ef6cbf6d..76b6ddab20 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Unit test for https://issues.alfresco.com/jira/browse/RM-1464 - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class RM1464Test extends DeleteHoldTest -{ - public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold() - { - final NodeRef hold = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // Create hold - NodeRef hold = createAndCheckHold(); - - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); - - // Give the user read permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true); - - // Give the user filing permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true); - - return hold; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() - { - holdService.addToHold(hold, rmFolder); - } - }, userName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1464 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1464Test extends DeleteHoldTest +{ + public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold() + { + final NodeRef hold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // Create hold + NodeRef hold = createAndCheckHold(); + + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, userName); + + // Give the user read permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true); + + // Give the user filing permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true); + + return hold; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.addToHold(hold, rmFolder); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java index 5a1253ade4..db18552f1f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java @@ -1,93 +1,93 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.util.GUID; - -/** - * Test for RM-1799 - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RM1799Test extends BaseRMTestCase -{ - private String myUser; - private NodeRef category; - - @Override - protected boolean isRecordTest() - { - return true; - } - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - myUser = GUID.generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser); - } - - public void testRM1799() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.setPermission(filePlan, myUser, RMPermissionModel.FILING); - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - category = filePlanService.createRecordCategory(filePlan, GUID.generate()); - return null; - } - }, myUser); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category, RMPermissionModel.FILING)); - return null; - } - }, myUser); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.util.GUID; + +/** + * Test for RM-1799 + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RM1799Test extends BaseRMTestCase +{ + private String myUser; + private NodeRef category; + + @Override + protected boolean isRecordTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + myUser = GUID.generate(); + createPerson(myUser); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser); + } + + public void testRM1799() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(filePlan, myUser, RMPermissionModel.FILING); + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + category = filePlanService.createRecordCategory(filePlan, GUID.generate()); + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category, RMPermissionModel.FILING)); + return null; + } + }, myUser); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1814Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1814Test.java index e680de2c67..55929c8d54 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1814Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1814Test.java @@ -1,84 +1,84 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * Test for RM-1814 - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RM1814Test extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - public void testRM1814() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - NodeRef hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); - holdService.addToHold(hold, recordTwo); - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), recordOne, recordThree); - return null; - } - }); - - doTestInTransaction(new FailureTest - ( - "Target node is in a hold." - ) - { - @Override - public void run() throws Exception - { - relationshipService.addRelationship(CUSTOM_REF_OBSOLETES.getLocalName(), recordOne, recordTwo); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - relationshipService.addRelationship(CUSTOM_REF_SUPPORTS.getLocalName(), recordOne, recordFour); - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * Test for RM-1814 + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RM1814Test extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testRM1814() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate()); + holdService.addToHold(hold, recordTwo); + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), recordOne, recordThree); + return null; + } + }); + + doTestInTransaction(new FailureTest + ( + "Target node is in a hold." + ) + { + @Override + public void run() throws Exception + { + relationshipService.addRelationship(CUSTOM_REF_OBSOLETES.getLocalName(), recordOne, recordTwo); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + relationshipService.addRelationship(CUSTOM_REF_SUPPORTS.getLocalName(), recordOne, recordFour); + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1887Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1887Test.java index 556e736631..dfb8c8d53b 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1887Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1887Test.java @@ -1,82 +1,82 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * Integration test for RM-1887 - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RM1887Test extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * Given that a record is unfiled - * And an unfiled folder has been created - * When I move the unfiled record into the unfiled folder - * Then the filed date of the unfiled record remains unset - */ - public void testMoveUnfiledRecord() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef unfiledRecordFolder; - private NodeRef unfiledRecord; - - public void given() throws Exception - { - // create unfiled folder - unfiledRecordFolder = fileFolderService.create(filePlanService.getUnfiledContainer(filePlan), "my test folder", TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); - - // crate unfiled record - unfiledRecord = recordService.createRecordFromContent(filePlan, "test.txt", TYPE_CONTENT, null, null); - - // check the record - assertTrue(recordService.isRecord(unfiledRecord)); - assertFalse(recordService.isFiled(unfiledRecord)); - } - - public void when() throws Exception - { - // move the record into the unfiled folder - fileFolderService.move(unfiledRecord, unfiledRecordFolder, null); - } - - public void then() - { - // check the record - assertTrue(recordService.isRecord(unfiledRecord)); - assertFalse(recordService.isFiled(unfiledRecord)); - } - }); - - } - - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Integration test for RM-1887 + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RM1887Test extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Given that a record is unfiled + * And an unfiled folder has been created + * When I move the unfiled record into the unfiled folder + * Then the filed date of the unfiled record remains unset + */ + public void testMoveUnfiledRecord() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef unfiledRecordFolder; + private NodeRef unfiledRecord; + + public void given() throws Exception + { + // create unfiled folder + unfiledRecordFolder = fileFolderService.create(filePlanService.getUnfiledContainer(filePlan), "my test folder", TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); + + // crate unfiled record + unfiledRecord = recordService.createRecordFromContent(filePlan, "test.txt", TYPE_CONTENT, null, null); + + // check the record + assertTrue(recordService.isRecord(unfiledRecord)); + assertFalse(recordService.isFiled(unfiledRecord)); + } + + public void when() throws Exception + { + // move the record into the unfiled folder + fileFolderService.move(unfiledRecord, unfiledRecordFolder, null); + } + + public void then() + { + // check the record + assertTrue(recordService.isRecord(unfiledRecord)); + assertFalse(recordService.isFiled(unfiledRecord)); + } + }); + + } + + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java index 4f75c5bb68..3961fabe33 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java @@ -1,139 +1,139 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; -import org.apache.commons.lang.StringUtils; - -/** - * - * @author Ana Bozianu - * @since 2.3 - */ -public class RM1914Test extends BaseRMTestCase -{ - - public void testRM1914() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - - NodeRef record1; - NodeRef record2; - - public void given() - { - // 1. Any Category1, Category2 are created - NodeRef category1 = filePlanService.createRecordCategory(filePlan, GUID.generate()); - NodeRef category2 = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - - // 2. Disposition schedule is created for the Category1: - // - applied on Record - Map dsProps = new HashMap(3); - dsProps.put(PROP_DISPOSITION_AUTHORITY, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY); - dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, GUID.generate()); - dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, true); - - DispositionSchedule dispositionSchedule1 = dispositionService.createDispositionSchedule(category1, dsProps); - - // - add cutoff after "Related Record Transferred To Inactive Storage" completion event - Map dispositionAction1 = new HashMap(3); - dispositionAction1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - dispositionAction1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - - List events = new ArrayList(1); - events.add("related_record_trasfered_inactive_storage"); - dispositionAction1.put(PROP_DISPOSITION_EVENT, (Serializable)events); - - dispositionService.addDispositionActionDefinition(dispositionSchedule1, dispositionAction1); - - - // 3. Folder1 > Record1 is created inside Category1 - NodeRef folder1 = recordFolderService.createRecordFolder(category1, GUID.generate()); - record1 = recordService.createRecordFromContent(folder1, GUID.generate(), TYPE_CONTENT, null, null); - - - // 4. Disposition schedule is created for the Category2: - // applied on Record - DispositionSchedule dispositionSchedule2 = dispositionService.createDispositionSchedule(category2, dsProps); - - // - cutoff immediatelly - Map dispositionAction2_1 = new HashMap(3); - dispositionAction2_1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - dispositionAction2_1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - dispositionAction2_1.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - - dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_1); - - // - Transfer Immediatelly - Map dispositionAction2_2 = new HashMap(4); - dispositionAction2_2.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME); - dispositionAction2_2.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - dispositionAction2_2.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - dispositionAction2_2.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY); - - dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_2); - - // 5. Folder2 > Record2 is created inside Category2 - NodeRef folder2 = recordFolderService.createRecordFolder(category2, GUID.generate()); - record2 = recordService.createRecordFromContent(folder2, GUID.generate(), TYPE_CONTENT, null, null); - - // 6. Record1 and Record2 are completed - utils.completeRecord(record1); - utils.completeRecord(record2); - - // 7. Create Cross-Reference link from Record1 to Record2 - relationshipService.addRelationship(CUSTOM_REF_CROSSREFERENCE.getLocalName(), record1, record2); - - - } - - public void when() - { - // 8. Cut off and transfer Record2 - rmActionService.executeRecordsManagementAction(record2, CutOffAction.NAME, null); - NodeRef transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(record2, TransferAction.NAME).getValue(); - rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); - - } - - public void then() - { - // 9. Verify Record1 - assertTrue(dispositionService.isNextDispositionActionEligible(record1)); - - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; +import org.apache.commons.lang.StringUtils; + +/** + * + * @author Ana Bozianu + * @since 2.3 + */ +public class RM1914Test extends BaseRMTestCase +{ + + public void testRM1914() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + + NodeRef record1; + NodeRef record2; + + public void given() + { + // 1. Any Category1, Category2 are created + NodeRef category1 = filePlanService.createRecordCategory(filePlan, GUID.generate()); + NodeRef category2 = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + + // 2. Disposition schedule is created for the Category1: + // - applied on Record + Map dsProps = new HashMap(3); + dsProps.put(PROP_DISPOSITION_AUTHORITY, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY); + dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, GUID.generate()); + dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, true); + + DispositionSchedule dispositionSchedule1 = dispositionService.createDispositionSchedule(category1, dsProps); + + // - add cutoff after "Related Record Transferred To Inactive Storage" completion event + Map dispositionAction1 = new HashMap(3); + dispositionAction1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + dispositionAction1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + + List events = new ArrayList(1); + events.add("related_record_trasfered_inactive_storage"); + dispositionAction1.put(PROP_DISPOSITION_EVENT, (Serializable)events); + + dispositionService.addDispositionActionDefinition(dispositionSchedule1, dispositionAction1); + + + // 3. Folder1 > Record1 is created inside Category1 + NodeRef folder1 = recordFolderService.createRecordFolder(category1, GUID.generate()); + record1 = recordService.createRecordFromContent(folder1, GUID.generate(), TYPE_CONTENT, null, null); + + + // 4. Disposition schedule is created for the Category2: + // applied on Record + DispositionSchedule dispositionSchedule2 = dispositionService.createDispositionSchedule(category2, dsProps); + + // - cutoff immediatelly + Map dispositionAction2_1 = new HashMap(3); + dispositionAction2_1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + dispositionAction2_1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + dispositionAction2_1.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_1); + + // - Transfer Immediatelly + Map dispositionAction2_2 = new HashMap(4); + dispositionAction2_2.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME); + dispositionAction2_2.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + dispositionAction2_2.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionAction2_2.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_2); + + // 5. Folder2 > Record2 is created inside Category2 + NodeRef folder2 = recordFolderService.createRecordFolder(category2, GUID.generate()); + record2 = recordService.createRecordFromContent(folder2, GUID.generate(), TYPE_CONTENT, null, null); + + // 6. Record1 and Record2 are completed + utils.completeRecord(record1); + utils.completeRecord(record2); + + // 7. Create Cross-Reference link from Record1 to Record2 + relationshipService.addRelationship(CUSTOM_REF_CROSSREFERENCE.getLocalName(), record1, record2); + + + } + + public void when() + { + // 8. Cut off and transfer Record2 + rmActionService.executeRecordsManagementAction(record2, CutOffAction.NAME, null); + NodeRef transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(record2, TransferAction.NAME).getValue(); + rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); + + } + + public void then() + { + // 9. Verify Record1 + assertTrue(dispositionService.isNextDispositionActionEligible(record1)); + + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java index 37cf0048aa..58fd6cf298 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java @@ -1,182 +1,182 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.rule.Rule; -import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.service.cmr.rule.RuleType; - - -/** - * System test for RM-2072: Concurrency exceptions and deadlocks on Records Management "File to" rule - * - * @author Roy Wetherall - * @since 2.2.1.1 - */ -public class RM2072Test extends BaseRMTestCase -{ - private static final int NUMBER_OF_BATCHES = 1; - private static final int NUMBER_IN_BATCH = 500; - - private RuleService ruleService; - private NodeRef ruleFolder; - - @Override - protected void initServices() - { - super.initServices(); - - ruleService = (RuleService)applicationContext.getBean("RuleService"); - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * Given that I have auto declare configured - * And that I have auto file configured to a path where only the record folder needs to be created - * When I add lots of documents in the same transaction - * Then the rules should fire - * And the documents should be filed in the new record folder - */ - public void testAutoDeclareAutoFileCreateRecordFolderOnly() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // create the folder - ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER).getNodeRef(); - - // create record category - NodeRef nodeRefA = filePlanService.createRecordCategory(filePlan, "A"); - NodeRef nodeRefB = filePlanService.createRecordCategory(nodeRefA, "B"); - filePlanService.createRecordCategory(nodeRefB, "C"); - - Action action = actionService.createAction(CreateRecordAction.NAME); - action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - - Rule rule = new Rule(); - rule.setRuleType(RuleType.INBOUND); - rule.setTitle("my rule"); - rule.setAction(action); - rule.setExecuteAsynchronously(true); - ruleService.saveRule(ruleFolder, rule); - - Action fileAction = actionService.createAction(FileToAction.NAME); - fileAction.setParameterValue(FileToAction.PARAM_PATH, "/A/B/C/{date.year.long}/{date.month.long}/{date.day.month}"); - fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true); - - Rule fileRule = new Rule(); - fileRule.setRuleType(RuleType.INBOUND); - fileRule.setTitle("my rule"); - fileRule.setAction(fileAction); - fileRule.setExecuteAsynchronously(true); - ruleService.saveRule(filePlanService.getUnfiledContainer(filePlan), fileRule); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertFalse(ruleService.getRules(ruleFolder).isEmpty()); - } - }); - - List records = new ArrayList(NUMBER_OF_BATCHES*NUMBER_IN_BATCH); - - for (int i = 0; i < NUMBER_OF_BATCHES; i++) - { - final int finali = i; - records.addAll(doTestInTransaction(new Test>() - { - @Override - public List run() throws Exception - { - List records = new ArrayList(NUMBER_IN_BATCH); - for (int j = 0; j < NUMBER_IN_BATCH; j++) - { - int count = (finali+1)*(j+1); - String name = "content" + count + ".txt"; - System.out.println(name + " - creating"); - - NodeRef record = fileFolderService.create(ruleFolder, name, ContentModel.TYPE_CONTENT).getNodeRef(); - records.add(record); - } - return records; - } - })); - } - - try - { - while(!records.isEmpty()) - { - Thread.sleep(1000); - - final Iterator temp = records.iterator(); - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - while (temp.hasNext()) - { - NodeRef record = temp.next(); - if (nodeService.hasAspect(record, ASPECT_RECORD) && recordService.isFiled(record)) - { - String name = (String) nodeService.getProperty(record, ContentModel.PROP_NAME); - System.out.println(name + " - complete"); - temp.remove(); - } - } - - return null; - } - }); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - throw exception; - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.rule.Rule; +import org.alfresco.service.cmr.rule.RuleService; +import org.alfresco.service.cmr.rule.RuleType; + + +/** + * System test for RM-2072: Concurrency exceptions and deadlocks on Records Management "File to" rule + * + * @author Roy Wetherall + * @since 2.2.1.1 + */ +public class RM2072Test extends BaseRMTestCase +{ + private static final int NUMBER_OF_BATCHES = 1; + private static final int NUMBER_IN_BATCH = 500; + + private RuleService ruleService; + private NodeRef ruleFolder; + + @Override + protected void initServices() + { + super.initServices(); + + ruleService = (RuleService)applicationContext.getBean("RuleService"); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Given that I have auto declare configured + * And that I have auto file configured to a path where only the record folder needs to be created + * When I add lots of documents in the same transaction + * Then the rules should fire + * And the documents should be filed in the new record folder + */ + public void testAutoDeclareAutoFileCreateRecordFolderOnly() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // create the folder + ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER).getNodeRef(); + + // create record category + NodeRef nodeRefA = filePlanService.createRecordCategory(filePlan, "A"); + NodeRef nodeRefB = filePlanService.createRecordCategory(nodeRefA, "B"); + filePlanService.createRecordCategory(nodeRefB, "C"); + + Action action = actionService.createAction(CreateRecordAction.NAME); + action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + + Rule rule = new Rule(); + rule.setRuleType(RuleType.INBOUND); + rule.setTitle("my rule"); + rule.setAction(action); + rule.setExecuteAsynchronously(true); + ruleService.saveRule(ruleFolder, rule); + + Action fileAction = actionService.createAction(FileToAction.NAME); + fileAction.setParameterValue(FileToAction.PARAM_PATH, "/A/B/C/{date.year.long}/{date.month.long}/{date.day.month}"); + fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + Rule fileRule = new Rule(); + fileRule.setRuleType(RuleType.INBOUND); + fileRule.setTitle("my rule"); + fileRule.setAction(fileAction); + fileRule.setExecuteAsynchronously(true); + ruleService.saveRule(filePlanService.getUnfiledContainer(filePlan), fileRule); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(ruleService.getRules(ruleFolder).isEmpty()); + } + }); + + List records = new ArrayList(NUMBER_OF_BATCHES*NUMBER_IN_BATCH); + + for (int i = 0; i < NUMBER_OF_BATCHES; i++) + { + final int finali = i; + records.addAll(doTestInTransaction(new Test>() + { + @Override + public List run() throws Exception + { + List records = new ArrayList(NUMBER_IN_BATCH); + for (int j = 0; j < NUMBER_IN_BATCH; j++) + { + int count = (finali+1)*(j+1); + String name = "content" + count + ".txt"; + System.out.println(name + " - creating"); + + NodeRef record = fileFolderService.create(ruleFolder, name, ContentModel.TYPE_CONTENT).getNodeRef(); + records.add(record); + } + return records; + } + })); + } + + try + { + while(!records.isEmpty()) + { + Thread.sleep(1000); + + final Iterator temp = records.iterator(); + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + while (temp.hasNext()) + { + NodeRef record = temp.next(); + if (nodeService.hasAspect(record, ASPECT_RECORD) && recordService.isFiled(record)) + { + String name = (String) nodeService.getProperty(record, ContentModel.PROP_NAME); + System.out.println(name + " - complete"); + temp.remove(); + } + } + + return null; + } + }); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + throw exception; + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM3993Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM3993Test.java index 5f0955d097..8dfcf2da86 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM3993Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM3993Test.java @@ -31,8 +31,8 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; @@ -189,22 +189,22 @@ public class RM3993Test extends BaseRMTestCase throw exception; } - Integer numberOfRecords = AuthenticationUtil.runAsSystem(new RunAsWork() - { - - @Override - public Integer doWork() throws Exception - { - List containedRecordFolders = filePlanService.getContainedRecordFolders(nodeRefCategory1); - int numberOfRecords = 0; - for(NodeRef recordFolder : containedRecordFolders) - { - numberOfRecords = numberOfRecords + fileFolderService.list(recordFolder).size(); - } - return numberOfRecords; - } - }); - assertTrue(numberOfRecords == NUMBER_OF_BATCHES * NUMBER_IN_BATCH); + Integer numberOfRecords = AuthenticationUtil.runAsSystem(new RunAsWork() + { + + @Override + public Integer doWork() throws Exception + { + List containedRecordFolders = filePlanService.getContainedRecordFolders(nodeRefCategory1); + int numberOfRecords = 0; + for(NodeRef recordFolder : containedRecordFolders) + { + numberOfRecords = numberOfRecords + fileFolderService.list(recordFolder).size(); + } + return numberOfRecords; + } + }); + assertTrue(numberOfRecords == NUMBER_OF_BATCHES * NUMBER_IN_BATCH); } private NodeRef createFile(NodeRef parentNodeRef, String name, String descrption, QName typeQName) diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM452Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM452Test.java index 0d8fc2f343..ef7decb69d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM452Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM452Test.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestService; - - -/** - * System test for RM-452 - * - * See alfresco.extension.rm-method-security.properties - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM452Test extends BaseRMTestCase -{ - private TestService testService; - - @Override - protected void initServices() - { - super.initServices(); - - testService = (TestService)applicationContext.getBean("TestService"); - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isRecordTest() - { - return true; - } - - public void testRM452() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(folder); - assertNotNull(recordOne); - assertFalse(filePlanService.isFilePlanComponent(folder)); - assertTrue(filePlanService.isFilePlanComponent(recordOne)); - - // call methodOne with non-RM artifact .. expect success - testService.testMethodOne(folder); - - // call methodTwo with non-RM artifact .. expect success - testService.testMethodTwo(folder); - - // call methodOne with an RM artifact .. expect success - testService.testMethodOne(recordOne); - - return null; - } - }); - - doTestInTransaction(new FailureTest - ( - "Shouldn't be able to call testMethodTwo on TestService, because override RM security for method is not configred.", - AlfrescoRuntimeException.class - ) - { - - @Override - public void run() throws Exception - { - // call methodTwo with an RM artifact .. expect failure - testService.testMethodTwo(recordOne); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestService; + + +/** + * System test for RM-452 + * + * See alfresco.extension.rm-method-security.properties + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM452Test extends BaseRMTestCase +{ + private TestService testService; + + @Override + protected void initServices() + { + super.initServices(); + + testService = (TestService)applicationContext.getBean("TestService"); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testRM452() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertNotNull(folder); + assertNotNull(recordOne); + assertFalse(filePlanService.isFilePlanComponent(folder)); + assertTrue(filePlanService.isFilePlanComponent(recordOne)); + + // call methodOne with non-RM artifact .. expect success + testService.testMethodOne(folder); + + // call methodTwo with non-RM artifact .. expect success + testService.testMethodTwo(folder); + + // call methodOne with an RM artifact .. expect success + testService.testMethodOne(recordOne); + + return null; + } + }); + + doTestInTransaction(new FailureTest + ( + "Shouldn't be able to call testMethodTwo on TestService, because override RM security for method is not configred.", + AlfrescoRuntimeException.class + ) + { + + @Override + public void run() throws Exception + { + // call methodTwo with an RM artifact .. expect failure + testService.testMethodTwo(recordOne); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM804Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM804Test.java index a8c96e8df2..b51eb7047a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM804Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM804Test.java @@ -1,190 +1,190 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.site.SiteRole; - - -/** - * Unit test for RM-804 .. site managers are able to delete file plans - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM804Test extends BaseRMTestCase -{ - @Override - protected void initServices() - { - super.initServices(); - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isUserTest() - { - return true; - } - - public void testUsersHaveDeletePermissionsOnFilePlan() throws Exception - { - // as rmuser - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); - - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); - - return null; - } - }, rmUserName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); - - return null; - } - }, userName); - } - - public void testTryAndDeleteSiteAsSiteManagerOnly() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - siteService.setMembership(siteId, userName, SiteRole.SiteManager.toString()); - - return null; - } - }, "admin"); - - doTestInTransaction(new FailureTest - ( - "Should not be able to delete site as a site manager only.", - AlfrescoRuntimeException.class - ) - { - @Override - public void run() throws Exception - { - siteService.deleteSite(siteId); - - } - }, userName); - - // give the user a RM role (but not sufficient to delete the file plan node ref) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, userName); - - return null; - } - }, "admin"); - - doTestInTransaction(new FailureTest - ( - "Should not be able to delete site as a site manager with an RM role that doesn't have the capability.", - AlfrescoRuntimeException.class - ) - { - @Override - public void run() throws Exception - { - siteService.deleteSite(siteId); - - } - }, userName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, userName); - - return null; - } - }, "admin"); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - siteService.deleteSite(siteId); - - return null; - } - }, userName); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.site.SiteRole; + + +/** + * Unit test for RM-804 .. site managers are able to delete file plans + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM804Test extends BaseRMTestCase +{ + @Override + protected void initServices() + { + super.initServices(); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + public void testUsersHaveDeletePermissionsOnFilePlan() throws Exception + { + // as rmuser + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); + + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); + + return null; + } + }, rmUserName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete")); + + return null; + } + }, userName); + } + + public void testTryAndDeleteSiteAsSiteManagerOnly() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + siteService.setMembership(siteId, userName, SiteRole.SiteManager.toString()); + + return null; + } + }, "admin"); + + doTestInTransaction(new FailureTest + ( + "Should not be able to delete site as a site manager only.", + AlfrescoRuntimeException.class + ) + { + @Override + public void run() throws Exception + { + siteService.deleteSite(siteId); + + } + }, userName); + + // give the user a RM role (but not sufficient to delete the file plan node ref) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, userName); + + return null; + } + }, "admin"); + + doTestInTransaction(new FailureTest + ( + "Should not be able to delete site as a site manager with an RM role that doesn't have the capability.", + AlfrescoRuntimeException.class + ) + { + @Override + public void run() throws Exception + { + siteService.deleteSite(siteId); + + } + }, userName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, userName); + + return null; + } + }, "admin"); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + siteService.deleteSite(siteId); + + return null; + } + }, userName); + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM978Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM978Test.java index d4270d2d7f..73ed1b6d6c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM978Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM978Test.java @@ -1,868 +1,868 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.issue; - -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.repo.site.SiteServiceImpl; -import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.util.GUID; - -/** - * Test for RM-978 - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RM978Test extends BaseRMTestCase -{ - private NodeRef documentLibrary2; - private String user; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupCollaborationSiteTestDataImpl() - */ - @Override - protected void setupCollaborationSiteTestDataImpl() - { - super.setupCollaborationSiteTestDataImpl(); - - String collabSiteId2 = GUID.generate(); - siteService.createSite("site-dashboard", collabSiteId2, GUID.generate(), GUID.generate(), SiteVisibility.PUBLIC); - documentLibrary2 = SiteServiceImpl.getSiteContainer( - collabSiteId2, - SiteService.DOCUMENT_LIBRARY, - true, - siteService, - transactionService, - taggingService); - - assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary2); - - user = GUID.generate(); - createPerson(user); - siteService.setMembership(collabSiteId, user, SiteModel.SITE_CONTRIBUTOR); - siteService.setMembership(collabSiteId2, user, SiteModel.SITE_CONTRIBUTOR); - siteService.setMembership(siteId, user, SiteModel.SITE_CONSUMER); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_POWER_USER, user); - } - - public void testMoveDocumentToFolderInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, folder2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(0, folder1ChildAssocs.size()); - - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertNotNull(folder2ChildAssocs); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); - assertEquals(document1Name, movedDocumentName); - } - }); - } - - public void testMoveDocumentToDocumentLibraryInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, documentLibrary, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(0, folder1ChildAssocs.size()); - - List childAssocs = nodeService.getChildAssocs(documentLibrary); - assertNotNull(childAssocs); - - List childNames = new ArrayList(); - for (ChildAssociationRef childAssociationRef : childAssocs) - { - NodeRef childRef = childAssociationRef.getChildRef(); - childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); - } - - assertTrue(childNames.contains(document1Name)); - } - }); - } - - public void testMoveFolderToFolderInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private String folder1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(folder1, folder2, null); - } - - public void then() - { - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); - assertEquals(folder1Name, movedDocumentName); - } - }); - } - - public void testMoveDocumentToFolderInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, folder2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(0, folder1ChildAssocs.size()); - - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertNotNull(folder2ChildAssocs); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); - assertEquals(document1Name, movedDocumentName); - } - }); - } - - public void testMoveDocumentToDocumentLibraryInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, documentLibrary2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(0, folder1ChildAssocs.size()); - - List childAssocs = nodeService.getChildAssocs(documentLibrary2); - assertNotNull(childAssocs); - - List childNames = new ArrayList(); - for (ChildAssociationRef childAssociationRef : childAssocs) - { - NodeRef childRef = childAssociationRef.getChildRef(); - childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); - } - - assertTrue(childNames.contains(document1Name)); - } - }); - } - - public void testMoveFolderToFolderInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private String folder1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(folder1, folder2, null); - } - - public void then() - { - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); - assertEquals(folder1Name, movedDocumentName); - } - }); - } - - public void testMoveDocumentInFilePlanInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef document1; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, filePlan, GUID.generate()); - } - }); - } - - public void testMoveDocumentInCategoryInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef document1; - private NodeRef rmCategory; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(document1, rmCategory, GUID.generate()); - } - }); - } - - public void testMoveDocumentInFolderInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - private NodeRef rmCategory; - private NodeRef rmFolder; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); - - return null; - } - }, getAdminUserName()); - - fileFolderService.move(document1, rmFolder, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(0, folder1ChildAssocs.size()); - - List rmFolderChildAssocs = nodeService.getChildAssocs(rmFolder); - assertEquals(1, rmFolderChildAssocs.size()); - NodeRef movedDocument = rmFolderChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); - assertEquals(document1Name, movedDocumentName); - } - }); - } - - public void testMoveFolderInFilePlanInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(folder1, filePlan, GUID.generate()); - } - }); - } - - public void testMoveFolderInCategoryInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef rmCategory; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(folder1, rmCategory, GUID.generate()); - } - }); - } - - public void testMoveFolderInFolderInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef rmCategory; - private NodeRef rmFolder; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.move(folder1, rmFolder, GUID.generate()); - } - }); - } - - public void testCopyDocumentToFolderInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, folder2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(1, folder1ChildAssocs.size()); - - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertNotNull(folder2ChildAssocs); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); - assertEquals(document1Name, movedDocumentName); - } - }); - } - - public void testCopyDocumentToDocumentLibraryInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, documentLibrary, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(1, folder1ChildAssocs.size()); - - List childAssocs = nodeService.getChildAssocs(documentLibrary); - assertNotNull(childAssocs); - - List childNames = new ArrayList(); - for (ChildAssociationRef childAssociationRef : childAssocs) - { - NodeRef childRef = childAssociationRef.getChildRef(); - childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); - } - - assertTrue(childNames.contains(document1Name)); - } - }); - } - - public void testCopyFolderToFolderInCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private String folder1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(folder1, folder2, null); - } - - public void then() - { - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); - assertEquals(folder1Name, movedDocumentName); - } - }); - } - - public void testCopyDocumentToFolderInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, folder2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(1, folder1ChildAssocs.size()); - - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertNotNull(folder2ChildAssocs); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); - assertEquals(document1Name, movedDocumentName); - } - }); - } - - public void testCopyDocumentToDocumentLibraryInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, documentLibrary2, null); - } - - public void then() - { - List folder1ChildAssocs = nodeService.getChildAssocs(folder1); - assertEquals(1, folder1ChildAssocs.size()); - - List childAssocs = nodeService.getChildAssocs(documentLibrary2); - assertNotNull(childAssocs); - - List childNames = new ArrayList(); - for (ChildAssociationRef childAssociationRef : childAssocs) - { - NodeRef childRef = childAssociationRef.getChildRef(); - childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); - } - - assertTrue(childNames.contains(document1Name)); - } - }); - } - - public void testCopyFolderToFolderInDifferentCollabSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(user) - { - private NodeRef folder1; - private NodeRef folder2; - private String folder1Name = GUID.generate(); - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(folder1, folder2, null); - } - - public void then() - { - List folder2ChildAssocs = nodeService.getChildAssocs(folder2); - assertEquals(1, folder2ChildAssocs.size()); - NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); - String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); - assertEquals(folder1Name, movedDocumentName); - } - }); - } - - public void testCopyDocumentInFilePlanInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef document1; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, filePlan, GUID.generate()); - } - }); - } - - public void testCopyDocumentInCategoryInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef document1; - private NodeRef rmCategory; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(document1, rmCategory, GUID.generate()); - } - }); - } - - public void testCopyDocumentInFolderInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef document1; - private String document1Name = GUID.generate(); - private NodeRef rmCategory; - private NodeRef rmFolder; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); - - return null; - } - }, getAdminUserName()); - - fileFolderService.copy(document1, rmFolder, null); - } - }); - } - - public void testCopyFolderInFilePlanInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(folder1, filePlan, GUID.generate()); - } - }); - } - - public void testCopyFolderInCategoryInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef rmCategory; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(folder1, rmCategory, GUID.generate()); - } - }); - } - - public void testCopyFolderInFolderInRmSite() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) - { - private NodeRef folder1; - private NodeRef rmCategory; - private NodeRef rmFolder; - - public void given() - { - folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - - runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); - - return null; - } - }, getAdminUserName()); - } - - public void when() throws FileExistsException, FileNotFoundException - { - fileFolderService.copy(folder1, rmFolder, GUID.generate()); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.issue; + +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.site.SiteModel; +import org.alfresco.repo.site.SiteServiceImpl; +import org.alfresco.service.cmr.model.FileExistsException; +import org.alfresco.service.cmr.model.FileNotFoundException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.util.GUID; + +/** + * Test for RM-978 + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RM978Test extends BaseRMTestCase +{ + private NodeRef documentLibrary2; + private String user; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupCollaborationSiteTestDataImpl() + */ + @Override + protected void setupCollaborationSiteTestDataImpl() + { + super.setupCollaborationSiteTestDataImpl(); + + String collabSiteId2 = GUID.generate(); + siteService.createSite("site-dashboard", collabSiteId2, GUID.generate(), GUID.generate(), SiteVisibility.PUBLIC); + documentLibrary2 = SiteServiceImpl.getSiteContainer( + collabSiteId2, + SiteService.DOCUMENT_LIBRARY, + true, + siteService, + transactionService, + taggingService); + + assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary2); + + user = GUID.generate(); + createPerson(user); + siteService.setMembership(collabSiteId, user, SiteModel.SITE_CONTRIBUTOR); + siteService.setMembership(collabSiteId2, user, SiteModel.SITE_CONTRIBUTOR); + siteService.setMembership(siteId, user, SiteModel.SITE_CONSUMER); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_POWER_USER, user); + } + + public void testMoveDocumentToFolderInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, folder2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(0, folder1ChildAssocs.size()); + + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertNotNull(folder2ChildAssocs); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); + assertEquals(document1Name, movedDocumentName); + } + }); + } + + public void testMoveDocumentToDocumentLibraryInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, documentLibrary, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(0, folder1ChildAssocs.size()); + + List childAssocs = nodeService.getChildAssocs(documentLibrary); + assertNotNull(childAssocs); + + List childNames = new ArrayList(); + for (ChildAssociationRef childAssociationRef : childAssocs) + { + NodeRef childRef = childAssociationRef.getChildRef(); + childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); + } + + assertTrue(childNames.contains(document1Name)); + } + }); + } + + public void testMoveFolderToFolderInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private String folder1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(folder1, folder2, null); + } + + public void then() + { + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); + assertEquals(folder1Name, movedDocumentName); + } + }); + } + + public void testMoveDocumentToFolderInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, folder2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(0, folder1ChildAssocs.size()); + + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertNotNull(folder2ChildAssocs); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); + assertEquals(document1Name, movedDocumentName); + } + }); + } + + public void testMoveDocumentToDocumentLibraryInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, documentLibrary2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(0, folder1ChildAssocs.size()); + + List childAssocs = nodeService.getChildAssocs(documentLibrary2); + assertNotNull(childAssocs); + + List childNames = new ArrayList(); + for (ChildAssociationRef childAssociationRef : childAssocs) + { + NodeRef childRef = childAssociationRef.getChildRef(); + childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); + } + + assertTrue(childNames.contains(document1Name)); + } + }); + } + + public void testMoveFolderToFolderInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private String folder1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(folder1, folder2, null); + } + + public void then() + { + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); + assertEquals(folder1Name, movedDocumentName); + } + }); + } + + public void testMoveDocumentInFilePlanInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef document1; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, filePlan, GUID.generate()); + } + }); + } + + public void testMoveDocumentInCategoryInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef document1; + private NodeRef rmCategory; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(document1, rmCategory, GUID.generate()); + } + }); + } + + public void testMoveDocumentInFolderInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + private NodeRef rmCategory; + private NodeRef rmFolder; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); + + return null; + } + }, getAdminUserName()); + + fileFolderService.move(document1, rmFolder, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(0, folder1ChildAssocs.size()); + + List rmFolderChildAssocs = nodeService.getChildAssocs(rmFolder); + assertEquals(1, rmFolderChildAssocs.size()); + NodeRef movedDocument = rmFolderChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); + assertEquals(document1Name, movedDocumentName); + } + }); + } + + public void testMoveFolderInFilePlanInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(folder1, filePlan, GUID.generate()); + } + }); + } + + public void testMoveFolderInCategoryInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef rmCategory; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(folder1, rmCategory, GUID.generate()); + } + }); + } + + public void testMoveFolderInFolderInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef rmCategory; + private NodeRef rmFolder; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.move(folder1, rmFolder, GUID.generate()); + } + }); + } + + public void testCopyDocumentToFolderInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, folder2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(1, folder1ChildAssocs.size()); + + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertNotNull(folder2ChildAssocs); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); + assertEquals(document1Name, movedDocumentName); + } + }); + } + + public void testCopyDocumentToDocumentLibraryInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, documentLibrary, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(1, folder1ChildAssocs.size()); + + List childAssocs = nodeService.getChildAssocs(documentLibrary); + assertNotNull(childAssocs); + + List childNames = new ArrayList(); + for (ChildAssociationRef childAssociationRef : childAssocs) + { + NodeRef childRef = childAssociationRef.getChildRef(); + childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); + } + + assertTrue(childNames.contains(document1Name)); + } + }); + } + + public void testCopyFolderToFolderInCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private String folder1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(folder1, folder2, null); + } + + public void then() + { + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); + assertEquals(folder1Name, movedDocumentName); + } + }); + } + + public void testCopyDocumentToFolderInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, folder2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(1, folder1ChildAssocs.size()); + + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertNotNull(folder2ChildAssocs); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedDocument = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME); + assertEquals(document1Name, movedDocumentName); + } + }); + } + + public void testCopyDocumentToDocumentLibraryInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, documentLibrary2, null); + } + + public void then() + { + List folder1ChildAssocs = nodeService.getChildAssocs(folder1); + assertEquals(1, folder1ChildAssocs.size()); + + List childAssocs = nodeService.getChildAssocs(documentLibrary2); + assertNotNull(childAssocs); + + List childNames = new ArrayList(); + for (ChildAssociationRef childAssociationRef : childAssocs) + { + NodeRef childRef = childAssociationRef.getChildRef(); + childNames.add((String) nodeService.getProperty(childRef, ContentModel.PROP_NAME)); + } + + assertTrue(childNames.contains(document1Name)); + } + }); + } + + public void testCopyFolderToFolderInDifferentCollabSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(user) + { + private NodeRef folder1; + private NodeRef folder2; + private String folder1Name = GUID.generate(); + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); + folder2 = fileFolderService.create(documentLibrary2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(folder1, folder2, null); + } + + public void then() + { + List folder2ChildAssocs = nodeService.getChildAssocs(folder2); + assertEquals(1, folder2ChildAssocs.size()); + NodeRef movedFolder = folder2ChildAssocs.iterator().next().getChildRef(); + String movedDocumentName = (String) nodeService.getProperty(movedFolder, ContentModel.PROP_NAME); + assertEquals(folder1Name, movedDocumentName); + } + }); + } + + public void testCopyDocumentInFilePlanInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef document1; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, filePlan, GUID.generate()); + } + }); + } + + public void testCopyDocumentInCategoryInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef document1; + private NodeRef rmCategory; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(document1, rmCategory, GUID.generate()); + } + }); + } + + public void testCopyDocumentInFolderInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef document1; + private String document1Name = GUID.generate(); + private NodeRef rmCategory; + private NodeRef rmFolder; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); + + return null; + } + }, getAdminUserName()); + + fileFolderService.copy(document1, rmFolder, null); + } + }); + } + + public void testCopyFolderInFilePlanInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(folder1, filePlan, GUID.generate()); + } + }); + } + + public void testCopyFolderInCategoryInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef rmCategory; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(folder1, rmCategory, GUID.generate()); + } + }); + } + + public void testCopyFolderInFolderInRmSite() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) + { + private NodeRef folder1; + private NodeRef rmCategory; + private NodeRef rmFolder; + + public void given() + { + folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); + + runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate()); + + return null; + } + }, getAdminUserName()); + } + + public void when() throws FileExistsException, FileNotFoundException + { + fileFolderService.copy(folder1, rmFolder, GUID.generate()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM981SystemTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM981SystemTest.java index fef186cd1a..dd88162bc6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM981SystemTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM981SystemTest.java @@ -1,116 +1,116 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import junit.framework.TestCase; - -/** - * See https://issues.alfresco.com/jira/browse/RM-981. - * - * Instance of the repository needs to be running on localhost:8080 before executing this - * system test. - * - * @author Roy Wetherall - */ -public class RM981SystemTest extends TestCase -{ - public void testRM981() throws Exception - { - ExecutorService pool = Executors.newFixedThreadPool(2); - SecureRandom rnd = new SecureRandom(); - List data = new ArrayList(); - for (int i = 0; i < 100; i++) - { - String definitionname = "test_" + i + "_" + rnd.nextInt(Integer.MAX_VALUE); - data.add(definitionname); - } - - for (String definitionname : data) - { - pool.submit(new SendRequest(definitionname)); - } - pool.shutdown(); - pool.awaitTermination(60L, TimeUnit.SECONDS); - } - - - class SendRequest implements Runnable - { - - private String definitionname; - - public SendRequest(String definitionname) - { - this.definitionname = definitionname; - } - - @Override - public void run() - { - try - { - URL url = new URL("http://localhost:8080/alfresco/service/api/rma/admin/customreferencedefinitions"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod("POST"); - conn.setDoOutput(true); - conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); - conn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); - String body = "{\"referenceType\":\"bidirectional\",\"label\":\"" + definitionname + "\"}"; - OutputStream out = conn.getOutputStream(); - - out.write(body.getBytes("UTF-8")); - out.flush(); - out.close(); - - int status = conn.getResponseCode(); - - if (status != 200) - { - System.out.println("Reproduced"); - System.out.println("---------------------------------"); - String line; - BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - while ((line = reader.readLine()) != null) - { - System.out.println(line); - } - reader.close(); - System.exit(0); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import junit.framework.TestCase; + +/** + * See https://issues.alfresco.com/jira/browse/RM-981. + * + * Instance of the repository needs to be running on localhost:8080 before executing this + * system test. + * + * @author Roy Wetherall + */ +public class RM981SystemTest extends TestCase +{ + public void testRM981() throws Exception + { + ExecutorService pool = Executors.newFixedThreadPool(2); + SecureRandom rnd = new SecureRandom(); + List data = new ArrayList(); + for (int i = 0; i < 100; i++) + { + String definitionname = "test_" + i + "_" + rnd.nextInt(Integer.MAX_VALUE); + data.add(definitionname); + } + + for (String definitionname : data) + { + pool.submit(new SendRequest(definitionname)); + } + pool.shutdown(); + pool.awaitTermination(60L, TimeUnit.SECONDS); + } + + + class SendRequest implements Runnable + { + + private String definitionname; + + public SendRequest(String definitionname) + { + this.definitionname = definitionname; + } + + @Override + public void run() + { + try + { + URL url = new URL("http://localhost:8080/alfresco/service/api/rma/admin/customreferencedefinitions"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + conn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); + String body = "{\"referenceType\":\"bidirectional\",\"label\":\"" + definitionname + "\"}"; + OutputStream out = conn.getOutputStream(); + + out.write(body.getBytes("UTF-8")); + out.flush(); + out.close(); + + int status = conn.getResponseCode(); + + if (status != 200) + { + System.out.println("Reproduced"); + System.out.println("---------------------------------"); + String line; + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + while ((line = reader.readLine()) != null) + { + System.out.println(line); + } + reader.close(); + System.exit(0); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + + } + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM994Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM994Test.java index 085cd63e8a..216567f0fc 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM994Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM994Test.java @@ -1,126 +1,126 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; - - -/** - * System test for RM-994 - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RM994Test extends BaseRMTestCase -{ - @Override - protected void initServices() - { - super.initServices(); - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isRecordTest() - { - return true; - } - - public void testRM944() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - checkVitalRecordNotSet(rmContainer); - checkVitalRecordNotSet(rmFolder); - checkVitalRecordNotSet(recordOne); - assertNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF)); - - vitalRecordService.setVitalRecordDefintion(rmContainer, true, new Period("month|1")); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - checkVitalRecordSet(rmContainer); - checkVitalRecordSet(rmFolder); - checkVitalRecordSet(recordOne); - assertNotNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF)); - - recordService.createRecord(filePlan, dmDocument, true); - - assertTrue(recordService.isRecord(dmDocument)); - checkVitalRecordNotSet(dmDocument); - - fileFolderService.move(dmDocument, rmFolder, null); - - checkVitalRecordSet(dmDocument); - - return null; - } - }, "admin"); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - checkVitalRecordSet(dmDocument); - - return null; - } - }); - - } - - private void checkVitalRecordSet(NodeRef nodeRef) - { - VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef); - assertNotNull(def); - assertTrue(def.isEnabled()); - assertEquals("month", def.getReviewPeriod().getPeriodType()); - assertEquals("1", def.getReviewPeriod().getExpression()); - } - - private void checkVitalRecordNotSet(NodeRef nodeRef) - { - VitalRecordDefinition recordDef = vitalRecordService.getVitalRecordDefinition(nodeRef); - if (recordDef != null) - { - assertFalse(recordDef.isEnabled()); - assertEquals("none", recordDef.getReviewPeriod().getPeriodType()); - assertNull(recordDef.getNextReviewDate()); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; + + +/** + * System test for RM-994 + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM994Test extends BaseRMTestCase +{ + @Override + protected void initServices() + { + super.initServices(); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testRM944() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + checkVitalRecordNotSet(rmContainer); + checkVitalRecordNotSet(rmFolder); + checkVitalRecordNotSet(recordOne); + assertNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF)); + + vitalRecordService.setVitalRecordDefintion(rmContainer, true, new Period("month|1")); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + checkVitalRecordSet(rmContainer); + checkVitalRecordSet(rmFolder); + checkVitalRecordSet(recordOne); + assertNotNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF)); + + recordService.createRecord(filePlan, dmDocument, true); + + assertTrue(recordService.isRecord(dmDocument)); + checkVitalRecordNotSet(dmDocument); + + fileFolderService.move(dmDocument, rmFolder, null); + + checkVitalRecordSet(dmDocument); + + return null; + } + }, "admin"); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + checkVitalRecordSet(dmDocument); + + return null; + } + }); + + } + + private void checkVitalRecordSet(NodeRef nodeRef) + { + VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef); + assertNotNull(def); + assertTrue(def.isEnabled()); + assertEquals("month", def.getReviewPeriod().getPeriodType()); + assertEquals("1", def.getReviewPeriod().getExpression()); + } + + private void checkVitalRecordNotSet(NodeRef nodeRef) + { + VitalRecordDefinition recordDef = vitalRecordService.getVitalRecordDefinition(nodeRef); + if (recordDef != null) + { + assertFalse(recordDef.isEnabled()); + assertEquals("none", recordDef.getReviewPeriod().getPeriodType()); + assertNull(recordDef.getNextReviewDate()); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java index 7bc0a982bf..8d2674e2b1 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2005-2016 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.test.integration.issue.rm3314; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Test for https://issues.alfresco.com/jira/browse/RM-3114 - * - * @author Roy Wetherall - * @since 2.2.1.5 - */ -public class RM3314Test extends BaseRMTestCase -{ - /** registry to record callback from test beans "test.rm3114.1" and "test.rm3114.2" */ - public static Map callback = new HashMap(2); - - /** - * Given that the custom model hasn't been initialised - * When an aspect is added - * Then nothing happens - * - * Given that the custom model has been initialised - * When an aspect is added - * Then something happens - */ - public void testListenersExecutedInTheCorrectOrder() - { - /** - * The related test beans will call back into the callback map showing - * whether at the end of their execution whether the custom model has been - * initialised or not. Given the order in which these test beans are executed - * on spring context load, we would expect that .1 executes with the custom - * map unloaded, and the .2 with it loaded. - */ - - assertFalse(callback.isEmpty()); - assertFalse(callback.get("test.rm3314.1")); - assertTrue(callback.get("test.rm3314.2")); - } -} +/* + * Copyright (C) 2005-2016 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.test.integration.issue.rm3314; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Test for https://issues.alfresco.com/jira/browse/RM-3114 + * + * @author Roy Wetherall + * @since 2.2.1.5 + */ +public class RM3314Test extends BaseRMTestCase +{ + /** registry to record callback from test beans "test.rm3114.1" and "test.rm3114.2" */ + public static Map callback = new HashMap(2); + + /** + * Given that the custom model hasn't been initialised + * When an aspect is added + * Then nothing happens + * + * Given that the custom model has been initialised + * When an aspect is added + * Then something happens + */ + public void testListenersExecutedInTheCorrectOrder() + { + /** + * The related test beans will call back into the callback map showing + * whether at the end of their execution whether the custom model has been + * initialised or not. Given the order in which these test beans are executed + * on spring context load, we would expect that .1 executes with the custom + * map unloaded, and the .2 with it loaded. + */ + + assertFalse(callback.isEmpty()); + assertFalse(callback.get("test.rm3314.1")); + assertTrue(callback.get("test.rm3314.2")); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java index d162d0fe95..ae23cf1ce6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java @@ -1,134 +1,134 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminServiceImpl; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.core.Ordered; -import org.springframework.jdbc.BadSqlGrammarException; - -/** - * Simple bean used to test RM-3314 - * - * @author rwetherall - * @since 2.2.1.5 - */ -public class RM3314TestListener implements ApplicationListener, - Ordered, - BeanNameAware -{ - private RecordsManagementAdminServiceImpl recordsManagementAdminService; - private NodeService nodeService; - private FileFolderService fileFolderService; - private Repository repository; - - private String name; - private int order = Ordered.LOWEST_PRECEDENCE; - - public void setRecordsManagementAdminService(RecordsManagementAdminServiceImpl recordsManagementAdminService) - { - this.recordsManagementAdminService = recordsManagementAdminService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - public void setRepository(Repository repository) - { - this.repository = repository; - } - - @Override - public void setBeanName(String name) - { - this.name = name; - } - - public void setOrder(int order) - { - this.order = order; - } - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) - { - // call back to show whether the custom map is initialised or not - RM3314Test.callback.put(name, recordsManagementAdminService.isCustomMapInit()); - - // Do some work on a node to show that reguardless of whether the custom map is - // init or not, things still work. - // Note: using public services to ensure new transaction for each service call - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - try - { - // create node - NodeRef folder = fileFolderService.create( - repository.getCompanyHome(), - name, - ContentModel.TYPE_FOLDER).getNodeRef(); - try - { - // add aspect - nodeService.addAspect(folder, ContentModel.ASPECT_CLASSIFIABLE, null); - - // remove aspect - nodeService.removeAspect(folder, ContentModel.ASPECT_CLASSIFIABLE); - } - finally - { - // delete node - nodeService.deleteNode(folder); - } - } - catch (BadSqlGrammarException e) - { - // ignore and carry on - } - - return null; - } - }); - } - - @Override - public int getOrder() - { - return order; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminServiceImpl; +import org.alfresco.repo.model.Repository; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.springframework.beans.factory.BeanNameAware; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.core.Ordered; +import org.springframework.jdbc.BadSqlGrammarException; + +/** + * Simple bean used to test RM-3314 + * + * @author rwetherall + * @since 2.2.1.5 + */ +public class RM3314TestListener implements ApplicationListener, + Ordered, + BeanNameAware +{ + private RecordsManagementAdminServiceImpl recordsManagementAdminService; + private NodeService nodeService; + private FileFolderService fileFolderService; + private Repository repository; + + private String name; + private int order = Ordered.LOWEST_PRECEDENCE; + + public void setRecordsManagementAdminService(RecordsManagementAdminServiceImpl recordsManagementAdminService) + { + this.recordsManagementAdminService = recordsManagementAdminService; + } + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + public void setRepository(Repository repository) + { + this.repository = repository; + } + + @Override + public void setBeanName(String name) + { + this.name = name; + } + + public void setOrder(int order) + { + this.order = order; + } + + @Override + public void onApplicationEvent(ContextRefreshedEvent event) + { + // call back to show whether the custom map is initialised or not + RM3314Test.callback.put(name, recordsManagementAdminService.isCustomMapInit()); + + // Do some work on a node to show that reguardless of whether the custom map is + // init or not, things still work. + // Note: using public services to ensure new transaction for each service call + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() throws Exception + { + try + { + // create node + NodeRef folder = fileFolderService.create( + repository.getCompanyHome(), + name, + ContentModel.TYPE_FOLDER).getNodeRef(); + try + { + // add aspect + nodeService.addAspect(folder, ContentModel.ASPECT_CLASSIFIABLE, null); + + // remove aspect + nodeService.removeAspect(folder, ContentModel.ASPECT_CLASSIFIABLE); + } + finally + { + // delete node + nodeService.deleteNode(folder); + } + } + catch (BadSqlGrammarException e) + { + // ignore and carry on + } + + return null; + } + }); + } + + @Override + public int getOrder() + { + return order; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/AutomaticDispositionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/AutomaticDispositionTest.java index d2491dcd28..9d7cde4731 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/AutomaticDispositionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/AutomaticDispositionTest.java @@ -1,132 +1,132 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.job; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - -/** - * Test automatic disposition via scheduled job. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class AutomaticDispositionTest extends BaseRMTestCase -{ - @SuppressWarnings("unused") - private RecordsManagementAuditService auditService; - - /** additional job context to override job frequency */ - protected String[] getConfigLocations() - { - return new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml", - "classpath:test-job-context.xml" - }; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - auditService = (RecordsManagementAuditService)applicationContext.getBean("recordsManagementAuditService"); - } - - /** - * Given there is a complete record eligible for cut off, when the correct frequency of time passes, then - * the record will be automatically cut off - */ - public void testAutomaticCutOff() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef sourceCategory; - NodeRef sourceRecordFolder; - NodeRef record; - - public void given() - { - // create test data - sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - DispositionSchedule dis = utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, false); - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - dispositionService.addDispositionActionDefinition(dis, adParams); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); - - // create and complete record - record = utils.createRecord(sourceRecordFolder, GUID.generate()); - utils.completeRecord(record); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - } - - public void when() throws Exception - { - // sleep .. allowing the job time to execute - Thread.sleep(30000); - } - - public void then() - { - // record should now be cut off - assertTrue(dispositionService.isDisposableItemCutoff(record)); - - // TODO .. automatic dispoistion does not log entry in audit - // .. the following test checks for this, but is currently commented out - // .. because it doesn't work! -// RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); -// params.setEvent(CutOffAction.NAME); -// params.setMaxEntries(1); -// List entries = auditService.getAuditTrail(params); -// assertNotNull(entries); -// assertEquals(1, entries.size()); -// -// RecordsManagementAuditEntry entry = entries.get(0); -// assertEquals(record, entry.getNodeRef()); - } - }); - } - - // TODO automatic retain - - // TODO automatic destroy -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.job; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + +/** + * Test automatic disposition via scheduled job. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class AutomaticDispositionTest extends BaseRMTestCase +{ + @SuppressWarnings("unused") + private RecordsManagementAuditService auditService; + + /** additional job context to override job frequency */ + protected String[] getConfigLocations() + { + return new String[] + { + "classpath:alfresco/application-context.xml", + "classpath:test-context.xml", + "classpath:test-job-context.xml" + }; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + auditService = (RecordsManagementAuditService)applicationContext.getBean("recordsManagementAuditService"); + } + + /** + * Given there is a complete record eligible for cut off, when the correct frequency of time passes, then + * the record will be automatically cut off + */ + public void testAutomaticCutOff() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef sourceCategory; + NodeRef sourceRecordFolder; + NodeRef record; + + public void given() + { + // create test data + sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + DispositionSchedule dis = utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, false); + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dis, adParams); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); + + // create and complete record + record = utils.createRecord(sourceRecordFolder, GUID.generate()); + utils.completeRecord(record); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + } + + public void when() throws Exception + { + // sleep .. allowing the job time to execute + Thread.sleep(30000); + } + + public void then() + { + // record should now be cut off + assertTrue(dispositionService.isDisposableItemCutoff(record)); + + // TODO .. automatic dispoistion does not log entry in audit + // .. the following test checks for this, but is currently commented out + // .. because it doesn't work! +// RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); +// params.setEvent(CutOffAction.NAME); +// params.setMaxEntries(1); +// List entries = auditService.getAuditTrail(params); +// assertNotNull(entries); +// assertEquals(1, entries.size()); +// +// RecordsManagementAuditEntry entry = entries.get(0); +// assertEquals(record, entry.getNodeRef()); + } + }); + } + + // TODO automatic retain + + // TODO automatic destroy +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/JobTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/JobTestSuite.java index 12022f2cf2..b93b6c98e0 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/JobTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/job/JobTestSuite.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.job; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Job integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - AutomaticDispositionTest.class -}) -public class JobTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.job; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Job integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + AutomaticDispositionTest.class +}) +public class JobTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java index c86a12e277..30692cf0a0 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java @@ -1,233 +1,233 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; -import org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Complete record tests. - * - * @author Roy Wetherall - * @since 2.2.1 - */ -public class CompleteRecordTest extends BaseRMTestCase -{ - private static final QName ASPECT_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "recordMetaDataWithProperty"); - private static final QName PROP_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customMandatoryProperty"); - - /** complete record action */ - private DeclareRecordAction action; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - - // get the action - action = (DeclareRecordAction)applicationContext.getBean("declareRecord"); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() - */ - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - - // ensure action is returned to original state - action.setCheckMandatoryPropertiesEnabled(true); - } - - /** - * Given the the application is configured to check for mandatory values before complete - * And a filed record is missing mandatory values - * When I try to complete the record - * Then the missing properties parameter of the action will be populated - * And the record will not be complete - */ - public void testCheckForMandatoryValuesMissing() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private RecordsManagementActionResult result; - - public void given() - { - // enable mandatory parameter check - action.setCheckMandatoryPropertiesEnabled(true); - - // create a record - record = utils.createRecord(rmFolder, "record.txt", "title"); - - // add the record aspect (that has a mandatory property) - nodeService.addAspect(record, ASPECT_TEST, null); - } - - public void when() - { - // complete record - result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); - } - - public void then() - { - assertNotNull(result); - assertNotNull(result.getValue()); - assertFalse(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); - } - }); - } - - /** - * Given the the application is configured to check for mandatory values before complete - * And a filed record has all mandatory values - * When I try to complete the record - * Then the record is completed - */ - public void testCheckForMandatoryValuePresent() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private RecordsManagementActionResult result; - - public void given() - { - // enable mandatory parameter check - action.setCheckMandatoryPropertiesEnabled(true); - - // create a record - record = utils.createRecord(rmFolder, "record.txt", "title"); - - // add the record aspect (that has a mandatory property) - Map properties = new HashMap(1); - properties.put(PROP_TEST, "something"); - nodeService.addAspect(record, ASPECT_TEST, properties); - } - - public void when() - { - // complete record - result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); - } - - public void then() - { - assertNotNull(result); - assertNull(result.getValue()); - assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); - } - }); - } - - /** - * Given the the application is configured not to check for mandatory values before complete - * And a filed record is missing mandatory values - * When I try to complete the record - * Then the record is completed - */ - public void testDontCheckForMandatoryValuesMissing() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private RecordsManagementActionResult result; - - public void given() - { - // disable mandatory parameter check - action.setCheckMandatoryPropertiesEnabled(false); - - // create a record - record = utils.createRecord(rmFolder, "record.txt", "title"); - - // add the record aspect (that has a mandatory property) - nodeService.addAspect(record, ASPECT_TEST, null); - } - - public void when() - { - // complete record - result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); - } - - public void then() - { - assertNotNull(result); - assertNull(result.getValue()); - assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); - } - }); - } - - /** - * Given the the application is configured to not to check for mandatory values before complete - * And a filed record has all mandatory values - * When I try to complete the record - * Then the record is completed - */ - public void testDontCheckForMandatoryValuePresent() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private RecordsManagementActionResult result; - - public void given() - { - // enable mandatory parameter check - action.setCheckMandatoryPropertiesEnabled(false); - - // create a record - record = utils.createRecord(rmFolder, "record.txt", "title"); - - // add the record aspect (that has a mandatory property) - Map properties = new HashMap(1); - properties.put(PROP_TEST, "something"); - nodeService.addAspect(record, ASPECT_TEST, properties); - } - - public void when() - { - // complete record - result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); - } - - public void then() - { - assertNotNull(result); - assertNull(result.getValue()); - assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; +import org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Complete record tests. + * + * @author Roy Wetherall + * @since 2.2.1 + */ +public class CompleteRecordTest extends BaseRMTestCase +{ + private static final QName ASPECT_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "recordMetaDataWithProperty"); + private static final QName PROP_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customMandatoryProperty"); + + /** complete record action */ + private DeclareRecordAction action; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + + // get the action + action = (DeclareRecordAction)applicationContext.getBean("declareRecord"); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() + */ + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + // ensure action is returned to original state + action.setCheckMandatoryPropertiesEnabled(true); + } + + /** + * Given the the application is configured to check for mandatory values before complete + * And a filed record is missing mandatory values + * When I try to complete the record + * Then the missing properties parameter of the action will be populated + * And the record will not be complete + */ + public void testCheckForMandatoryValuesMissing() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(true); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + nodeService.addAspect(record, ASPECT_TEST, null); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNotNull(result.getValue()); + assertFalse(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured to check for mandatory values before complete + * And a filed record has all mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testCheckForMandatoryValuePresent() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(true); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + Map properties = new HashMap(1); + properties.put(PROP_TEST, "something"); + nodeService.addAspect(record, ASPECT_TEST, properties); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured not to check for mandatory values before complete + * And a filed record is missing mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testDontCheckForMandatoryValuesMissing() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // disable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(false); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + nodeService.addAspect(record, ASPECT_TEST, null); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured to not to check for mandatory values before complete + * And a filed record has all mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testDontCheckForMandatoryValuePresent() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(false); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + Map properties = new HashMap(1); + properties.put(PROP_TEST, "something"); + nodeService.addAspect(record, ASPECT_TEST, properties); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CreateRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CreateRecordTest.java index fa9162ea48..2309361990 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CreateRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CreateRecordTest.java @@ -1,287 +1,287 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * Create record tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class CreateRecordTest extends BaseRMTestCase -{ - public void testCreateRecordCapabilityOnly() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - String roleName = GUID.generate(); - String user = GUID.generate(); - NodeRef recordFolder; - NodeRef record; - - public void given() - { - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("CreateRecords")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create file plan structure - NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); - } - - public void when() - { - // give read and file permissions to user - filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null); - - return null; - } - }, user); - } - - public void then() - { - // check the details of the record - assertTrue(recordService.isRecord(record)); - } - }); - } - - /** - * - */ - public void testCreateRecordCapabilityOnlyFromFileFolderService() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - String roleName = GUID.generate(); - String user = GUID.generate(); - NodeRef recordFolder; - NodeRef record; - - public void given() - { - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("CreateRecords")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create file plan structure - NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); - } - - public void when() - { - // give read and file permissions to user - filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - record = fileFolderService.create(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - ContentWriter writer = contentService.getWriter(record, ContentModel.TYPE_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - writer.putContent("Lucy Wetherall"); - - return null; - } - }, user); - } - - public void then() - { - // check the details of the record - assertTrue(recordService.isRecord(record)); - } - }); - } - - /** - * unit test for RM1649 fix - * test if a user with create record permissions and without file record permission is able to create a record within unfiled record container - */ - public void testCreateRecordCapabilityInsideUnfiledRecordsContainer() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - String roleName = GUID.generate(); - String user = GUID.generate(); - NodeRef record; - - public void given() - { - // create a role with view and create capabilities - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("CreateRecords")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - //give read and file permission to user on unfiled records container - filePlanPermissionService.setPermission(unfiledContainer , user, RMPermissionModel.FILING); - } - - public void when() - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - record = recordService.createRecordFromContent(unfiledContainer, GUID.generate(), TYPE_CONTENT, null, null); - - return null; - } - }, user); - } - - public void then() - { - // check the details of the record - assertTrue(recordService.isRecord(record)); - - } - }); - } - - /** - * Given I have ViewRecord and CreateRecord capabilities - * And I have filling on a record folder - * When I create content via ScriptNode (simulated) - * Then the record is successfully created - * - * @see https://issues.alfresco.com/jira/browse/RM-1956 - */ - public void testCreateRecordViaCoreServices() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - String roleName = GUID.generate(); - String user = GUID.generate(); - NodeRef recordFolder; - NodeRef record; - - public void given() - { - // create a role with view and create capabilities - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("CreateRecords")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create file plan structure - NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); - } - - public void when() - { - // give read and file permissions to user - filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); - - record = AuthenticationUtil.runAs(new RunAsWork() - { - public NodeRef doWork() throws Exception - { - NodeRef record = fileFolderService.create(recordFolder, "testRecord.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - ContentData content = (ContentData)nodeService.getProperty(record, PROP_CONTENT); - nodeService.setProperty(record, PROP_CONTENT, ContentData.setMimetype(content, MimetypeMap.MIMETYPE_TEXT_PLAIN)); - return record; - } - }, user); - } - - public void then() - { - // check the details of the record - assertTrue(recordService.isRecord(record)); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // we are expecting an expception here - try - { - ContentData content = (ContentData)nodeService.getProperty(record, PROP_CONTENT); - nodeService.setProperty(record, PROP_CONTENT, ContentData.setMimetype(content, MimetypeMap.MIMETYPE_TEXT_PLAIN)); - fail("Expecting access denied exception"); - } - catch (AccessDeniedException exception) - { - // expceted - } - - return null; - } - }, user); - } - - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * Create record tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class CreateRecordTest extends BaseRMTestCase +{ + public void testCreateRecordCapabilityOnly() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef recordFolder; + NodeRef record; + + public void given() + { + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("CreateRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create file plan structure + NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); + } + + public void when() + { + // give read and file permissions to user + filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null); + + return null; + } + }, user); + } + + public void then() + { + // check the details of the record + assertTrue(recordService.isRecord(record)); + } + }); + } + + /** + * + */ + public void testCreateRecordCapabilityOnlyFromFileFolderService() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef recordFolder; + NodeRef record; + + public void given() + { + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("CreateRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create file plan structure + NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); + } + + public void when() + { + // give read and file permissions to user + filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + record = fileFolderService.create(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + ContentWriter writer = contentService.getWriter(record, ContentModel.TYPE_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.setEncoding("UTF-8"); + writer.putContent("Lucy Wetherall"); + + return null; + } + }, user); + } + + public void then() + { + // check the details of the record + assertTrue(recordService.isRecord(record)); + } + }); + } + + /** + * unit test for RM1649 fix + * test if a user with create record permissions and without file record permission is able to create a record within unfiled record container + */ + public void testCreateRecordCapabilityInsideUnfiledRecordsContainer() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef record; + + public void given() + { + // create a role with view and create capabilities + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("CreateRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + //give read and file permission to user on unfiled records container + filePlanPermissionService.setPermission(unfiledContainer , user, RMPermissionModel.FILING); + } + + public void when() + { + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + record = recordService.createRecordFromContent(unfiledContainer, GUID.generate(), TYPE_CONTENT, null, null); + + return null; + } + }, user); + } + + public void then() + { + // check the details of the record + assertTrue(recordService.isRecord(record)); + + } + }); + } + + /** + * Given I have ViewRecord and CreateRecord capabilities + * And I have filling on a record folder + * When I create content via ScriptNode (simulated) + * Then the record is successfully created + * + * @see https://issues.alfresco.com/jira/browse/RM-1956 + */ + public void testCreateRecordViaCoreServices() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef recordFolder; + NodeRef record; + + public void given() + { + // create a role with view and create capabilities + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("CreateRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create file plan structure + NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate()); + } + + public void when() + { + // give read and file permissions to user + filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING); + + record = AuthenticationUtil.runAs(new RunAsWork() + { + public NodeRef doWork() throws Exception + { + NodeRef record = fileFolderService.create(recordFolder, "testRecord.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + ContentData content = (ContentData)nodeService.getProperty(record, PROP_CONTENT); + nodeService.setProperty(record, PROP_CONTENT, ContentData.setMimetype(content, MimetypeMap.MIMETYPE_TEXT_PLAIN)); + return record; + } + }, user); + } + + public void then() + { + // check the details of the record + assertTrue(recordService.isRecord(record)); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // we are expecting an expception here + try + { + ContentData content = (ContentData)nodeService.getProperty(record, PROP_CONTENT); + nodeService.setProperty(record, PROP_CONTENT, ContentData.setMimetype(content, MimetypeMap.MIMETYPE_TEXT_PLAIN)); + fail("Expecting access denied exception"); + } + catch (AccessDeniedException exception) + { + // expceted + } + + return null; + } + }, user); + } + + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/HideInplaceRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/HideInplaceRecordTest.java index 5ca049d849..2f616b2aac 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/HideInplaceRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/HideInplaceRecordTest.java @@ -1,98 +1,98 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; - -/** - * Hide Inplace Record Test - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class HideInplaceRecordTest extends BaseRMTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * Tests hiding inplace records - */ - public void testHideInplaceRecord() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - public void given() - { - // Check that the document is not a record - assertFalse(recordService.isRecord(dmDocument)); - - // Check that the record has one parent association - assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); - - // Declare the document as a record - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // Declare record - recordService.createRecord(filePlan, dmDocument); - - return null; - } - }, dmCollaborator); - - // Check that the document is a record - assertTrue(recordService.isRecord(dmDocument)); - - // Check that the record has two parent associations - assertEquals(2, nodeService.getParentAssocs(dmDocument).size()); - } - - public void when() - { - // Hide the document - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // Hide record - inplaceRecordService.hideRecord(dmDocument); - - return null; - } - }, dmCollaborator); - } - - public void then() - { - // Check that the record has one parent association - assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; + +/** + * Hide Inplace Record Test + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class HideInplaceRecordTest extends BaseRMTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * Tests hiding inplace records + */ + public void testHideInplaceRecord() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + public void given() + { + // Check that the document is not a record + assertFalse(recordService.isRecord(dmDocument)); + + // Check that the record has one parent association + assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); + + // Declare the document as a record + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // Declare record + recordService.createRecord(filePlan, dmDocument); + + return null; + } + }, dmCollaborator); + + // Check that the document is a record + assertTrue(recordService.isRecord(dmDocument)); + + // Check that the record has two parent associations + assertEquals(2, nodeService.getParentAssocs(dmDocument).size()); + } + + public void when() + { + // Hide the document + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // Hide record + inplaceRecordService.hideRecord(dmDocument); + + return null; + } + }, dmCollaborator); + } + + public void then() + { + // Check that the record has one parent association + assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/LinkRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/LinkRecordTest.java index df22b25f2b..a15af46a40 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/LinkRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/LinkRecordTest.java @@ -1,156 +1,156 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.webscripts.GUID; - -/** - * Link/Unlink Record Tests - * - * @author Roy Wetherall - * @since 2.3 - */ -public class LinkRecordTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected void initServices() - { - super.initServices(); - } - - /** - * Given source and destination disposition schedules are compatible - * When I link a record to the record folder - * Then it is successful - */ - public void testLinkWithCompatibleDispositionSchedules() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef myRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - myRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - - // create disposition schedules on record folders - utils.createBasicDispositionSchedule( - sourceRecordCategory, - "disposition instructions", - "disposition authority", - false, - true); - utils.createBasicDispositionSchedule( - targetRecordCategory, - "disposition instructions", - "disposition authority", - false, - true); - } - - public void when() throws Exception - { - // link the record into the record folder - recordService.link(myRecord, targetRecordFolder); - } - - public void then() throws Exception - { - // assert that the record now has two parents - List assocs = nodeService.getParentAssocs(myRecord); - assertNotNull(assocs); - assertEquals(2, assocs.size()); - } - }); - } - - /** - * Given source and destination disposition schedules are incompatible - * When I link a record to the record folder - * Then it is fails - */ - public void testLinkWithIncompatibleDispositionSchedules() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class) - { - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef myRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - myRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - - // create disposition schedules on record folders - utils.createBasicDispositionSchedule( - sourceRecordCategory, - "disposition instructions", - "disposition authority", - false, - true); - utils.createBasicDispositionSchedule( - targetRecordCategory, - "disposition instructions", - "disposition authority", - true, - true); - } - - public void when() throws Exception - { - // link the record into the record folder - recordService.link(myRecord, targetRecordFolder); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.webscripts.GUID; + +/** + * Link/Unlink Record Tests + * + * @author Roy Wetherall + * @since 2.3 + */ +public class LinkRecordTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected void initServices() + { + super.initServices(); + } + + /** + * Given source and destination disposition schedules are compatible + * When I link a record to the record folder + * Then it is successful + */ + public void testLinkWithCompatibleDispositionSchedules() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef myRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + myRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + + // create disposition schedules on record folders + utils.createBasicDispositionSchedule( + sourceRecordCategory, + "disposition instructions", + "disposition authority", + false, + true); + utils.createBasicDispositionSchedule( + targetRecordCategory, + "disposition instructions", + "disposition authority", + false, + true); + } + + public void when() throws Exception + { + // link the record into the record folder + recordService.link(myRecord, targetRecordFolder); + } + + public void then() throws Exception + { + // assert that the record now has two parents + List assocs = nodeService.getParentAssocs(myRecord); + assertNotNull(assocs); + assertEquals(2, assocs.size()); + } + }); + } + + /** + * Given source and destination disposition schedules are incompatible + * When I link a record to the record folder + * Then it is fails + */ + public void testLinkWithIncompatibleDispositionSchedules() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class) + { + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef myRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + myRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + + // create disposition schedules on record folders + utils.createBasicDispositionSchedule( + sourceRecordCategory, + "disposition instructions", + "disposition authority", + false, + true); + utils.createBasicDispositionSchedule( + targetRecordCategory, + "disposition instructions", + "disposition authority", + true, + true); + } + + public void when() throws Exception + { + // link the record into the record folder + recordService.link(myRecord, targetRecordFolder); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java index d647def3e5..3c96c9f499 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java @@ -1,147 +1,147 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import static org.apache.commons.collections.ListUtils.removeAll; - -import java.util.List; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Move Inplace Record Test - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class MoveInplaceRecordTest extends BaseRMTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * Tests moving inplace records - */ - public void testMoveInplaceRecord() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - // The destination folder in collaboration site - private NodeRef destinationDmFolder; - - // Extended Readers/Writers - private Set extendedReadersBeforeMove; - private Set extendedWritersBeforeMove; - - // primary parent of record - private NodeRef primaryParentBeforeMove; - - public void given() - { - // Create the destination folder - destinationDmFolder = fileFolderService.create(documentLibrary, "destinationCollabFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - - // Check that the document is not a record - assertFalse(recordService.isRecord(dmDocument)); - - // Declare the document as a record - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // Declare record - recordService.createRecord(filePlan, dmDocument); - - return null; - } - }, dmCollaborator); - - // Check that the document is a record now - assertTrue(recordService.isRecord(dmDocument)); - - extendedReadersBeforeMove = extendedSecurityService.getReaders(dmDocument); - extendedWritersBeforeMove = extendedSecurityService.getWriters(dmDocument); - - // get the primary parent and assert that it's a record management artifact - primaryParentBeforeMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertTrue("Primary parent of newly created should be a records management artifact.", - filePlanService.isFilePlanComponent(primaryParentBeforeMove)); - - } - - public void when() - { - // Move the document - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // Move record - inplaceRecordService.moveRecord(dmDocument, destinationDmFolder); - - return null; - } - }, dmCollaborator); - } - - public void then() - { - // assert that the document is still a record - assertTrue("After move the document should still be a record.", - recordService.isRecord(dmDocument)); - - // Check that the source folder is empty now and the destination folder has the document - assertEquals(0, nodeService.getChildAssocs(dmFolder).size()); - List destinationFolderChildAssocs = nodeService.getChildAssocs(destinationDmFolder); - assertEquals(1, destinationFolderChildAssocs.size()); - assertEquals(dmDocument, destinationFolderChildAssocs.get(0).getChildRef()); - - // Check that the primary parent of the record has remained unchanged - NodeRef primaryParentAfterMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertTrue("Primary parent of record after inplace move should be a records management artifact.", - filePlanService.isFilePlanComponent(primaryParentAfterMove)); - assertEquals("Primary parent of record after inplace move should remain the same.", - primaryParentBeforeMove, - primaryParentAfterMove); - - // Check extended readers/writers - Set extendedReadersAfterMove = extendedSecurityService.getReaders(dmDocument); - Set extendedWritersAfterMove = extendedSecurityService.getWriters(dmDocument); - - assertEquals(extendedReadersBeforeMove.size(), extendedReadersAfterMove.size()); - assertEquals(extendedWritersBeforeMove.size(), extendedWritersAfterMove.size()); - - assertEquals(0, removeAll(extendedReadersBeforeMove, extendedReadersAfterMove).size()); - assertEquals(0, removeAll(extendedWritersBeforeMove, extendedWritersAfterMove).size()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import static org.apache.commons.collections.ListUtils.removeAll; + +import java.util.List; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Move Inplace Record Test + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class MoveInplaceRecordTest extends BaseRMTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * Tests moving inplace records + */ + public void testMoveInplaceRecord() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + // The destination folder in collaboration site + private NodeRef destinationDmFolder; + + // Extended Readers/Writers + private Set extendedReadersBeforeMove; + private Set extendedWritersBeforeMove; + + // primary parent of record + private NodeRef primaryParentBeforeMove; + + public void given() + { + // Create the destination folder + destinationDmFolder = fileFolderService.create(documentLibrary, "destinationCollabFolder", ContentModel.TYPE_FOLDER).getNodeRef(); + + // Check that the document is not a record + assertFalse(recordService.isRecord(dmDocument)); + + // Declare the document as a record + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // Declare record + recordService.createRecord(filePlan, dmDocument); + + return null; + } + }, dmCollaborator); + + // Check that the document is a record now + assertTrue(recordService.isRecord(dmDocument)); + + extendedReadersBeforeMove = extendedSecurityService.getReaders(dmDocument); + extendedWritersBeforeMove = extendedSecurityService.getWriters(dmDocument); + + // get the primary parent and assert that it's a record management artifact + primaryParentBeforeMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertTrue("Primary parent of newly created should be a records management artifact.", + filePlanService.isFilePlanComponent(primaryParentBeforeMove)); + + } + + public void when() + { + // Move the document + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // Move record + inplaceRecordService.moveRecord(dmDocument, destinationDmFolder); + + return null; + } + }, dmCollaborator); + } + + public void then() + { + // assert that the document is still a record + assertTrue("After move the document should still be a record.", + recordService.isRecord(dmDocument)); + + // Check that the source folder is empty now and the destination folder has the document + assertEquals(0, nodeService.getChildAssocs(dmFolder).size()); + List destinationFolderChildAssocs = nodeService.getChildAssocs(destinationDmFolder); + assertEquals(1, destinationFolderChildAssocs.size()); + assertEquals(dmDocument, destinationFolderChildAssocs.get(0).getChildRef()); + + // Check that the primary parent of the record has remained unchanged + NodeRef primaryParentAfterMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertTrue("Primary parent of record after inplace move should be a records management artifact.", + filePlanService.isFilePlanComponent(primaryParentAfterMove)); + assertEquals("Primary parent of record after inplace move should remain the same.", + primaryParentBeforeMove, + primaryParentAfterMove); + + // Check extended readers/writers + Set extendedReadersAfterMove = extendedSecurityService.getReaders(dmDocument); + Set extendedWritersAfterMove = extendedSecurityService.getWriters(dmDocument); + + assertEquals(extendedReadersBeforeMove.size(), extendedReadersAfterMove.size()); + assertEquals(extendedWritersBeforeMove.size(), extendedWritersAfterMove.size()); + + assertEquals(0, removeAll(extendedReadersBeforeMove, extendedReadersAfterMove).size()); + assertEquals(0, removeAll(extendedWritersBeforeMove, extendedWritersAfterMove).size()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java index cef22206d0..74408bfdf5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java @@ -1,341 +1,341 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.GUID; - -/** - * Move record tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -@SuppressWarnings("unchecked") -public class MoveRecordTest extends BaseRMTestCase -{ - private static final String OTHER_EVENT = "abolished"; - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * Given a record is filed in a event disposition and moved then the - * record no longer has any disposition. - * - * @see https://issues.alfresco.com/jira/browse/RM-1540 - */ - public void testMoveRecordEventDispositinoToNoDisposition() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef sourceCategory; - NodeRef sourceRecordFolder; - NodeRef destinationCategory; - NodeRef destinationRecordFolder; - NodeRef record; - - public void given() - { - // create test data - sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); - destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());; - destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); - - // create record - record = utils.createRecord(sourceRecordFolder, GUID.generate()); - - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNull(dispositionAction.getAsOfDate()); - assertFalse(dispositionService.isNextDispositionActionEligible(record)); - assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - } - - public void when() throws Exception - { - // check the search aspect details - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - - // move record - fileFolderService.move(record, destinationRecordFolder, null); - } - - public void then() - { - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - assertNull(dispositionService.getNextDispositionAction(record)); - - // check the search aspect properties - assertFalse(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - - } - }); - } - - /** - * Given a record in a event disposition, when it moved to another event disposition then the record should have the - * new events, rather than the old ones. - */ - public void testMoveRecordEventDisToEventDis() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef sourceCategory; - NodeRef sourceRecordFolder; - NodeRef destinationCategory; - NodeRef destinationRecordFolder; - NodeRef record; - - public void given() - { - // create test data - sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); - - destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, true, false, OTHER_EVENT); - destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); - - // create record - record = utils.createRecord(sourceRecordFolder, GUID.generate()); - - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNull(dispositionAction.getAsOfDate()); - assertFalse(dispositionService.isNextDispositionActionEligible(record)); - assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - assertNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); - } - - public void when() throws Exception - { - // check the search aspect details - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - - // move record - fileFolderService.move(record, destinationRecordFolder, null); - } - - public void then() - { - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNull(dispositionAction.getAsOfDate()); - assertFalse(dispositionService.isNextDispositionActionEligible(record)); - assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - assertNotNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); - - // check the search aspect details - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(OTHER_EVENT)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY)); - assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE)); - } - }); - - } - - /** - * Given a record in a event disposition, when it moved to a time disposition then the record should have the correct as of - * date and no longer have the events. - */ - public void testMoveRecordEventDisToTimeDis() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef sourceCategory; - NodeRef sourceRecordFolder; - NodeRef destinationCategory; - NodeRef destinationRecordFolder; - NodeRef record; - - public void given() - { - // create test data - sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); - - destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - DispositionSchedule dis = utils.createBasicDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, false); - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - dispositionService.addDispositionActionDefinition(dis, adParams); - destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); - - // create record - record = utils.createRecord(sourceRecordFolder, GUID.generate()); - - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNull(dispositionAction.getAsOfDate()); - assertFalse(dispositionService.isNextDispositionActionEligible(record)); - assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - assertNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); - } - - public void when() throws Exception - { - // check the search aspect details - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - - // move record - fileFolderService.move(record, destinationRecordFolder, null); - } - - public void then() - { - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - - // check the search aspect details - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertNull(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS))); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY)); - assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE)); - } - }); - } - - /** - * See https://issues.alfresco.com/jira/browse/RM-1502 - */ - public void testMoveDMtoRM() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef destinationCategory; - NodeRef destinationRecordFolder; - - public void given() - { - // destination category - destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - DispositionSchedule dis = utils.createBasicDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, false); - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - dispositionService.addDispositionActionDefinition(dis, adParams); - destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); - } - - public void when() throws Exception - { - // move document to record folder - fileFolderService.move(dmDocument, destinationRecordFolder, null); - } - - public void then() - { - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(dmDocument, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(dmDocument); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(dmDocument)); - assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); - - // check the search aspect details - assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_AS_OF)); - assertNull(((List)nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_EVENTS))); - assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_INSTRUCTIONS)); - assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_AUTHORITY)); - assertTrue((Boolean)nodeService.getProperty(dmDocument, PROP_RS_HAS_DISPOITION_SCHEDULE)); - } - }); - } - - // TODO moveRecordNoDisToEventDis - // TODO moveRecordRecordDisToFolderDis -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.GUID; + +/** + * Move record tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +@SuppressWarnings("unchecked") +public class MoveRecordTest extends BaseRMTestCase +{ + private static final String OTHER_EVENT = "abolished"; + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * Given a record is filed in a event disposition and moved then the + * record no longer has any disposition. + * + * @see https://issues.alfresco.com/jira/browse/RM-1540 + */ + public void testMoveRecordEventDispositinoToNoDisposition() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef sourceCategory; + NodeRef sourceRecordFolder; + NodeRef destinationCategory; + NodeRef destinationRecordFolder; + NodeRef record; + + public void given() + { + // create test data + sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); + destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());; + destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); + + // create record + record = utils.createRecord(sourceRecordFolder, GUID.generate()); + + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNull(dispositionAction.getAsOfDate()); + assertFalse(dispositionService.isNextDispositionActionEligible(record)); + assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + } + + public void when() throws Exception + { + // check the search aspect details + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + + // move record + fileFolderService.move(record, destinationRecordFolder, null); + } + + public void then() + { + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + assertNull(dispositionService.getNextDispositionAction(record)); + + // check the search aspect properties + assertFalse(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + + } + }); + } + + /** + * Given a record in a event disposition, when it moved to another event disposition then the record should have the + * new events, rather than the old ones. + */ + public void testMoveRecordEventDisToEventDis() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef sourceCategory; + NodeRef sourceRecordFolder; + NodeRef destinationCategory; + NodeRef destinationRecordFolder; + NodeRef record; + + public void given() + { + // create test data + sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); + + destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, true, false, OTHER_EVENT); + destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); + + // create record + record = utils.createRecord(sourceRecordFolder, GUID.generate()); + + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNull(dispositionAction.getAsOfDate()); + assertFalse(dispositionService.isNextDispositionActionEligible(record)); + assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + assertNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); + } + + public void when() throws Exception + { + // check the search aspect details + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + + // move record + fileFolderService.move(record, destinationRecordFolder, null); + } + + public void then() + { + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNull(dispositionAction.getAsOfDate()); + assertFalse(dispositionService.isNextDispositionActionEligible(record)); + assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + assertNotNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); + + // check the search aspect details + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(OTHER_EVENT)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY)); + assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE)); + } + }); + + } + + /** + * Given a record in a event disposition, when it moved to a time disposition then the record should have the correct as of + * date and no longer have the events. + */ + public void testMoveRecordEventDisToTimeDis() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef sourceCategory; + NodeRef sourceRecordFolder; + NodeRef destinationCategory; + NodeRef destinationRecordFolder; + NodeRef record; + + public void given() + { + // create test data + sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, true); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate()); + + destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + DispositionSchedule dis = utils.createBasicDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, false); + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dis, adParams); + destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); + + // create record + record = utils.createRecord(sourceRecordFolder, GUID.generate()); + + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(sourceRecordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNull(dispositionAction.getAsOfDate()); + assertFalse(dispositionService.isNextDispositionActionEligible(record)); + assertNotNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + assertNull(dispositionAction.getEventCompletionDetails(OTHER_EVENT)); + } + + public void when() throws Exception + { + // check the search aspect details + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertTrue(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + + // move record + fileFolderService.move(record, destinationRecordFolder, null); + } + + public void then() + { + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + + // check the search aspect details + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertNull(((List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS))); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY)); + assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE)); + } + }); + } + + /** + * See https://issues.alfresco.com/jira/browse/RM-1502 + */ + public void testMoveDMtoRM() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef destinationCategory; + NodeRef destinationRecordFolder; + + public void given() + { + // destination category + destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + DispositionSchedule dis = utils.createBasicDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, false); + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dis, adParams); + destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate()); + } + + public void when() throws Exception + { + // move document to record folder + fileFolderService.move(dmDocument, destinationRecordFolder, null); + } + + public void then() + { + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(dmDocument, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(dmDocument); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(dmDocument)); + assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME)); + + // check the search aspect details + assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_AS_OF)); + assertNull(((List)nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_EVENTS))); + assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_INSTRUCTIONS)); + assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_AUTHORITY)); + assertTrue((Boolean)nodeService.getProperty(dmDocument, PROP_RS_HAS_DISPOITION_SCHEDULE)); + } + }); + } + + // TODO moveRecordNoDisToEventDis + // TODO moveRecordRecordDisToFolderDis +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java index 40d7495bd6..acf5c1ddad 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Record integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - RejectRecordTest.class, - CreateRecordTest.class, - MoveRecordTest.class, - CompleteRecordTest.class, - HideInplaceRecordTest.class, - MoveInplaceRecordTest.class, - ViewRecordTest.class, - LinkRecordTest.class -}) -public class RecordTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Record integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + RejectRecordTest.class, + CreateRecordTest.class, + MoveRecordTest.class, + CompleteRecordTest.class, + HideInplaceRecordTest.class, + MoveInplaceRecordTest.class, + ViewRecordTest.class, + LinkRecordTest.class +}) +public class RecordTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java index 05f80f6181..bc926351b1 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java @@ -1,293 +1,293 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_FILE_PLAN; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; -import static org.alfresco.service.cmr.version.VersionType.MINOR; -import static org.springframework.extensions.webscripts.GUID.generate; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.coci.CheckOutCheckInService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.util.PropertyMap; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.extensions.webscripts.GUID; - -/** - * reject record tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RejectRecordTest extends BaseRMTestCase -{ - private VersionService versionService; - private CheckOutCheckInService checkOutCheckInService; - - private static final String REASON = GUID.generate(); - private static final String FINAL_VERSION = "rm.service.final-version"; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected void initServices() - { - super.initServices(); - - versionService = (VersionService) applicationContext.getBean("VersionService"); - checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckOutCheckInService"); - } - - /** - * - */ - public void testRejectedRecordInCorrectState() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - public void given() - { - assertFalse(recordService.isRecord(dmDocument)); - ownableService.setOwner(dmDocument, userName); - - // document is declared as a record by user - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // declare record - recordService.createRecord(filePlan, dmDocument); - return null; - } - }, userName); - } - - public void when() - { - // sanity checks - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(permissionService.getInheritParentPermissions(dmDocument)); - - // reject record - recordService.rejectRecord(dmDocument, REASON); - } - - public void then() - { - // document is no longer a record - assertFalse(recordService.isRecord(dmDocument)); - - // expected owner has be re-set - assertEquals(userName, ownableService.getOwner(dmDocument)); - assertTrue(permissionService.getInheritParentPermissions(dmDocument)); - assertFalse(nodeService.hasAspect(dmDocument, ASPECT_FILE_PLAN_COMPONENT)); - } - }); - } - - /** - * - */ - public void testRevertAfterReject() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef document; - - public void given() - { - NodeRef folder = fileFolderService.create(documentLibrary, GUID.generate(), TYPE_FOLDER).getNodeRef(); - document = fileFolderService.create(folder, GUID.generate(), TYPE_CONTENT).getNodeRef(); - - assertFalse(recordService.isRecord(document)); - ownableService.setOwner(document, userName); - versionService.ensureVersioningEnabled(document, null); - - // document is declared as a record by user - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // declare record - recordService.createRecord(filePlan, document); - return null; - } - }, userName); - - assertTrue(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); - } - - public void when() - { - // reject the record - recordService.rejectRecord(document, REASON); - assertFalse(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); - - // upload a new version of the document - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - ContentWriter writer = contentService.getWriter(document, ContentModel.PROP_CONTENT, true); - writer.putContent("This is a change to the content and should force a new version"); - versionService.createVersion(document, null); - - return null; - } - }, userName); - - assertFalse(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); - - VersionHistory history = versionService.getVersionHistory(document); - assertEquals(2, history.getAllVersions().size()); - final Version initial = history.getRootVersion(); - - assertFalse(nodeService.hasAspect(initial.getFrozenStateNodeRef(), ASPECT_FILE_PLAN_COMPONENT)); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // revert the document to a previous version - versionService.revert(document, initial); - - return null; - } - }, userName); - } - - public void then() - { - // document is no longer a record - assertFalse(recordService.isRecord(document)); - - // expected owner has be re-set - assertEquals(userName, ownableService.getOwner(document)); - } - }); - } - - public void testRelationshipAfterRevertingRecord() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - // Test document - private NodeRef document; - - public void given() - { - // Create a test document - NodeRef folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - - // Set Auto-Declare Versions to "For all major and minor versions" - PropertyMap recordableVersionProperties = new PropertyMap(2); - recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); - nodeService.addAspect(document, ASPECT_VERSIONABLE, recordableVersionProperties); - - // Upload New Version - document = checkOutCheckInService.checkout(document); - Map props = new HashMap(2); - props.put(Version.PROP_DESCRIPTION, generate()); - props.put(VersionModel.PROP_VERSION_TYPE, MINOR); - document = checkOutCheckInService.checkin(document, props); - - // Check the declared version - List childAssocs = nodeService.getChildAssocs(unfiledContainer); - assertEquals(1, childAssocs.size()); - - // Declare document as record - recordService.createRecord(filePlan, document); - - // Check the declared versions - childAssocs = nodeService.getChildAssocs(unfiledContainer); - assertEquals(2, childAssocs.size()); - - // Check that the document is a file plan component - assertTrue(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); - - // Get the final version - NodeRef finalVersion = null; - for (ChildAssociationRef childAssociationRef : nodeService.getChildAssocs(unfiledContainer)) - { - NodeRef childRef = childAssociationRef.getChildRef(); - String label = (String) nodeService.getProperty(document, RecordableVersionModel.PROP_VERSION_LABEL); - - if (label.equals(I18NUtil.getMessage(FINAL_VERSION))) - { - finalVersion = childRef; - break; - } - } - - // The final version should be the declared record - assertEquals(document, finalVersion); - - // Check the relationship - Set relationships = relationshipService.getRelationshipsFrom(document); - assertEquals(1, relationships.size()); - Relationship relationship = relationships.iterator().next(); - assertEquals(CUSTOM_REF_VERSIONS.getLocalName(), relationship.getUniqueName()); - } - - public void when() - { - // Reject record - recordService.rejectRecord(document, generate()); - } - - public void then() - { - // Check the relationship - Set relationships = relationshipService.getRelationshipsFrom(document); - assertEquals(0, relationships.size()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_FILE_PLAN; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; +import static org.alfresco.service.cmr.version.VersionType.MINOR; +import static org.springframework.extensions.webscripts.GUID.generate; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.coci.CheckOutCheckInService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.util.PropertyMap; +import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.extensions.webscripts.GUID; + +/** + * reject record tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RejectRecordTest extends BaseRMTestCase +{ + private VersionService versionService; + private CheckOutCheckInService checkOutCheckInService; + + private static final String REASON = GUID.generate(); + private static final String FINAL_VERSION = "rm.service.final-version"; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected void initServices() + { + super.initServices(); + + versionService = (VersionService) applicationContext.getBean("VersionService"); + checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckOutCheckInService"); + } + + /** + * + */ + public void testRejectedRecordInCorrectState() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + public void given() + { + assertFalse(recordService.isRecord(dmDocument)); + ownableService.setOwner(dmDocument, userName); + + // document is declared as a record by user + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // declare record + recordService.createRecord(filePlan, dmDocument); + return null; + } + }, userName); + } + + public void when() + { + // sanity checks + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(permissionService.getInheritParentPermissions(dmDocument)); + + // reject record + recordService.rejectRecord(dmDocument, REASON); + } + + public void then() + { + // document is no longer a record + assertFalse(recordService.isRecord(dmDocument)); + + // expected owner has be re-set + assertEquals(userName, ownableService.getOwner(dmDocument)); + assertTrue(permissionService.getInheritParentPermissions(dmDocument)); + assertFalse(nodeService.hasAspect(dmDocument, ASPECT_FILE_PLAN_COMPONENT)); + } + }); + } + + /** + * + */ + public void testRevertAfterReject() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef document; + + public void given() + { + NodeRef folder = fileFolderService.create(documentLibrary, GUID.generate(), TYPE_FOLDER).getNodeRef(); + document = fileFolderService.create(folder, GUID.generate(), TYPE_CONTENT).getNodeRef(); + + assertFalse(recordService.isRecord(document)); + ownableService.setOwner(document, userName); + versionService.ensureVersioningEnabled(document, null); + + // document is declared as a record by user + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // declare record + recordService.createRecord(filePlan, document); + return null; + } + }, userName); + + assertTrue(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); + } + + public void when() + { + // reject the record + recordService.rejectRecord(document, REASON); + assertFalse(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); + + // upload a new version of the document + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + ContentWriter writer = contentService.getWriter(document, ContentModel.PROP_CONTENT, true); + writer.putContent("This is a change to the content and should force a new version"); + versionService.createVersion(document, null); + + return null; + } + }, userName); + + assertFalse(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); + + VersionHistory history = versionService.getVersionHistory(document); + assertEquals(2, history.getAllVersions().size()); + final Version initial = history.getRootVersion(); + + assertFalse(nodeService.hasAspect(initial.getFrozenStateNodeRef(), ASPECT_FILE_PLAN_COMPONENT)); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // revert the document to a previous version + versionService.revert(document, initial); + + return null; + } + }, userName); + } + + public void then() + { + // document is no longer a record + assertFalse(recordService.isRecord(document)); + + // expected owner has be re-set + assertEquals(userName, ownableService.getOwner(document)); + } + }); + } + + public void testRelationshipAfterRevertingRecord() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + // Test document + private NodeRef document; + + public void given() + { + // Create a test document + NodeRef folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); + document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); + + // Set Auto-Declare Versions to "For all major and minor versions" + PropertyMap recordableVersionProperties = new PropertyMap(2); + recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); + nodeService.addAspect(document, ASPECT_VERSIONABLE, recordableVersionProperties); + + // Upload New Version + document = checkOutCheckInService.checkout(document); + Map props = new HashMap(2); + props.put(Version.PROP_DESCRIPTION, generate()); + props.put(VersionModel.PROP_VERSION_TYPE, MINOR); + document = checkOutCheckInService.checkin(document, props); + + // Check the declared version + List childAssocs = nodeService.getChildAssocs(unfiledContainer); + assertEquals(1, childAssocs.size()); + + // Declare document as record + recordService.createRecord(filePlan, document); + + // Check the declared versions + childAssocs = nodeService.getChildAssocs(unfiledContainer); + assertEquals(2, childAssocs.size()); + + // Check that the document is a file plan component + assertTrue(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT)); + + // Get the final version + NodeRef finalVersion = null; + for (ChildAssociationRef childAssociationRef : nodeService.getChildAssocs(unfiledContainer)) + { + NodeRef childRef = childAssociationRef.getChildRef(); + String label = (String) nodeService.getProperty(document, RecordableVersionModel.PROP_VERSION_LABEL); + + if (label.equals(I18NUtil.getMessage(FINAL_VERSION))) + { + finalVersion = childRef; + break; + } + } + + // The final version should be the declared record + assertEquals(document, finalVersion); + + // Check the relationship + Set relationships = relationshipService.getRelationshipsFrom(document); + assertEquals(1, relationships.size()); + Relationship relationship = relationships.iterator().next(); + assertEquals(CUSTOM_REF_VERSIONS.getLocalName(), relationship.getUniqueName()); + } + + public void when() + { + // Reject record + recordService.rejectRecord(document, generate()); + } + + public void then() + { + // Check the relationship + Set relationships = relationshipService.getRelationshipsFrom(document); + assertEquals(0, relationships.size()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java index 116e618982..b94dda442f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.record; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * View record tests. - * - * @author Ana Bozianu - * @since 2.3 - */ -public class ViewRecordTest extends BaseRMTestCase -{ - /** - * Given a user with read permission on a record and without read permission on the parent folder check if the user can check if the record is filed - * - * @see https://issues.alfresco.com/jira/browse/RM-1738 - */ - public void testReadIsFiledPropertyWithoutReadPermissionOnParentFolder() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - String roleName = GUID.generate(); - String user = GUID.generate(); - NodeRef rc; - NodeRef recordFolder; - NodeRef record; - boolean recordIsFiled = false; - - public void given() - { - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create file plan structure - rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); - NodeRef rsc = filePlanService.createRecordCategory(rc, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(rsc, GUID.generate()); - record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null); - } - - public void when() - { - // give read and file permissions on folder and remove permission from parent - filePlanPermissionService.setPermission(rc, user, RMPermissionModel.READ_RECORDS); - permissionService.setInheritParentPermissions(recordFolder, false); - filePlanPermissionService.setPermission(record, user, RMPermissionModel.READ_RECORDS); - - //check if the user can read the isFiled property - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - recordIsFiled = recordService.isFiled(record); - - return null; - } - }, user); - } - - public void then() - { - //check if the property is evaluated correctly - assertTrue(recordIsFiled); - } - - }); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.record; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * View record tests. + * + * @author Ana Bozianu + * @since 2.3 + */ +public class ViewRecordTest extends BaseRMTestCase +{ + /** + * Given a user with read permission on a record and without read permission on the parent folder check if the user can check if the record is filed + * + * @see https://issues.alfresco.com/jira/browse/RM-1738 + */ + public void testReadIsFiledPropertyWithoutReadPermissionOnParentFolder() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef rc; + NodeRef recordFolder; + NodeRef record; + boolean recordIsFiled = false; + + public void given() + { + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create file plan structure + rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + NodeRef rsc = filePlanService.createRecordCategory(rc, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rsc, GUID.generate()); + record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null); + } + + public void when() + { + // give read and file permissions on folder and remove permission from parent + filePlanPermissionService.setPermission(rc, user, RMPermissionModel.READ_RECORDS); + permissionService.setInheritParentPermissions(recordFolder, false); + filePlanPermissionService.setPermission(record, user, RMPermissionModel.READ_RECORDS); + + //check if the user can read the isFiled property + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + recordIsFiled = recordService.isFiled(record); + + return null; + } + }, user); + } + + public void then() + { + //check if the property is evaluated correctly + assertTrue(recordIsFiled); + } + + }); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java index 2cac3c292d..d8ecd511ed 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java @@ -1,452 +1,452 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.GUID; - -/** - * Move record folder tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class MoveRecordFolderTest extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * Given two categories, both with cut off immediately schedules, when the record is move - * then all the parts of the record should be correct based on the new schedule. - * - * @see https://issues.alfresco.com/jira/browse/RM-1345 - */ - public void testMoveRecordFolderBeforeCutOffFolderLevelDisposition() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) - { - NodeRef recordFolder; - NodeRef destinationRecordCategory; - - public void given() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - NodeRef rcOne = createRecordCategory(false); - destinationRecordCategory = createRecordCategory(false); - recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); - - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - } - }); - - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check the search aspect properties - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - } - - public void when() throws Exception - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // move record folder - fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); - } - }); - } - - public void then() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - - // check the search aspect properties - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - } - }); - } - - /** - * - */ - public void testMoveRecordFolderBeforeCutOffIntoAFolderWithNoDisposition() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) - { - NodeRef recordFolder; - NodeRef destinationRecordCategory; - - public void given() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - NodeRef rcOne = createRecordCategory(false); - destinationRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); - - // check for the lifecycle aspect - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); - } - }); - - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check the search aspect properties - assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - } - - public void when() throws Exception - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // move record folder - fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); - } - }); - } - - public void then() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - assertNull(dispositionService.getNextDispositionAction(recordFolder)); - - // check the search aspect properties - assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); - } - }); - } - }); - } - - /** - * - */ - public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) - { - NodeRef record; - NodeRef recordFolder; - NodeRef destinationRecordCategory; - - public void given() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - NodeRef rcOne = createRecordCategory(true); - destinationRecordCategory = createRecordCategory(true); - recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); - record = utils.createRecord(recordFolder, GUID.generate()); - - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - assertNull(dispositionService.getNextDispositionAction(recordFolder)); - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - } - }); - - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check the search aspect properties - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - } - - public void when() throws Exception - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // move record folder - fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); - } - }); - } - - public void then() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - // check for the lifecycle aspect - assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - - // check the disposition action details - assertNull(dispositionService.getNextDispositionAction(recordFolder)); - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); - assertNotNull(dispositionAction); - assertNotNull(CutOffAction.NAME, dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertTrue(dispositionService.isNextDispositionActionEligible(record)); - - // check the search aspect properties - assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); - assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - } - }); - } - - /** - * Try and move a folder from no disposition schedule to a disposition schedule - * - * @see https://issues.alfresco.com/jira/browse/RM-1039 - */ - public void testMoveRecordFolderFromNoDisToDis() throws Exception - { - final NodeRef recordFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record category (no disposition schedule) - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); - - // create a record folder - return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall"); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNull(dispositionService.getDispositionSchedule(result)); - assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING)); - } - }); - - final NodeRef record = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record - return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNull(dispositionService.getDispositionSchedule(result)); - assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING)); - } - }); - - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders"); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder)); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer)); - - // take a look at the move capability - Capability moveCapability = capabilityService.getCapability("Move"); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer)); - - // move the node - return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef(); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertNotNull(result); - assertNotNull(dispositionService.getDispositionSchedule(result)); - assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result); - assertNotNull(dispositionAction); - - assertNull(dispositionAction.getAsOfDate()); - assertEquals("cutoff", dispositionAction.getName()); - assertEquals(1, dispositionAction.getEventCompletionDetails().size()); - - // take a look at the record and check things are as we would expect - assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); - } - }); - } - - - // try and move a cutoff folder - public void testMoveCutoffRecordFolder() throws Exception - { - final NodeRef destination = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create a record category (no disposition schedule) - return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); - } - }); - - final NodeRef testFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // create folder - NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis"); - - // complete event - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params); - - // cutoff folder - rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME); - - return testFolder; - } - - @Override - public void test(NodeRef testFolder) throws Exception - { - // take a look at the move capability - Capability moveCapability = capabilityService.getCapability("Move"); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination)); - } - }); - - doTestInTransaction(new FailureTest() - { - @Override - public void run() throws Exception - { - fileFolderService.move(testFolder, destination, null).getNodeRef(); - } - }); - } - - - private NodeRef createRecordCategory(boolean recordLevel) - { - NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); - DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false); - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); - adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); - dispositionService.addDispositionActionDefinition(dis, adParams); - return rc; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.GUID; + +/** + * Move record folder tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class MoveRecordFolderTest extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Given two categories, both with cut off immediately schedules, when the record is move + * then all the parts of the record should be correct based on the new schedule. + * + * @see https://issues.alfresco.com/jira/browse/RM-1345 + */ + public void testMoveRecordFolderBeforeCutOffFolderLevelDisposition() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) + { + NodeRef recordFolder; + NodeRef destinationRecordCategory; + + public void given() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + NodeRef rcOne = createRecordCategory(false); + destinationRecordCategory = createRecordCategory(false); + recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); + + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + } + }); + + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check the search aspect properties + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + } + + public void when() throws Exception + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // move record folder + fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); + } + }); + } + + public void then() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + + // check the search aspect properties + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + } + }); + } + + /** + * + */ + public void testMoveRecordFolderBeforeCutOffIntoAFolderWithNoDisposition() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) + { + NodeRef recordFolder; + NodeRef destinationRecordCategory; + + public void given() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + NodeRef rcOne = createRecordCategory(false); + destinationRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); + + // check for the lifecycle aspect + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); + } + }); + + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check the search aspect properties + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + } + + public void when() throws Exception + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // move record folder + fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); + } + }); + } + + public void then() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + assertNull(dispositionService.getNextDispositionAction(recordFolder)); + + // check the search aspect properties + assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); + } + }); + } + }); + } + + /** + * + */ + public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) + { + NodeRef record; + NodeRef recordFolder; + NodeRef destinationRecordCategory; + + public void given() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + NodeRef rcOne = createRecordCategory(true); + destinationRecordCategory = createRecordCategory(true); + recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); + record = utils.createRecord(recordFolder, GUID.generate()); + + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + assertNull(dispositionService.getNextDispositionAction(recordFolder)); + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + } + }); + + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check the search aspect properties + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + } + + public void when() throws Exception + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // move record folder + fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); + } + }); + } + + public void then() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + // check for the lifecycle aspect + assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); + assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + + // check the disposition action details + assertNull(dispositionService.getNextDispositionAction(recordFolder)); + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); + assertNotNull(dispositionAction); + assertNotNull(CutOffAction.NAME, dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertTrue(dispositionService.isNextDispositionActionEligible(record)); + + // check the search aspect properties + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + } + }); + } + + /** + * Try and move a folder from no disposition schedule to a disposition schedule + * + * @see https://issues.alfresco.com/jira/browse/RM-1039 + */ + public void testMoveRecordFolderFromNoDisToDis() throws Exception + { + final NodeRef recordFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record category (no disposition schedule) + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); + + // create a record folder + return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall"); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNull(dispositionService.getDispositionSchedule(result)); + assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING)); + } + }); + + final NodeRef record = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record + return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNull(dispositionService.getDispositionSchedule(result)); + assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING)); + } + }); + + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders"); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder)); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer)); + + // take a look at the move capability + Capability moveCapability = capabilityService.getCapability("Move"); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer)); + + // move the node + return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef(); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertNotNull(result); + assertNotNull(dispositionService.getDispositionSchedule(result)); + assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); + + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result); + assertNotNull(dispositionAction); + + assertNull(dispositionAction.getAsOfDate()); + assertEquals("cutoff", dispositionAction.getName()); + assertEquals(1, dispositionAction.getEventCompletionDetails().size()); + + // take a look at the record and check things are as we would expect + assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + } + }); + } + + + // try and move a cutoff folder + public void testMoveCutoffRecordFolder() throws Exception + { + final NodeRef destination = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create a record category (no disposition schedule) + return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); + } + }); + + final NodeRef testFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // create folder + NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis"); + + // complete event + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params); + + // cutoff folder + rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME); + + return testFolder; + } + + @Override + public void test(NodeRef testFolder) throws Exception + { + // take a look at the move capability + Capability moveCapability = capabilityService.getCapability("Move"); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination)); + } + }); + + doTestInTransaction(new FailureTest() + { + @Override + public void run() throws Exception + { + fileFolderService.move(testFolder, destination, null).getNodeRef(); + } + }); + } + + + private NodeRef createRecordCategory(boolean recordLevel) + { + NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false); + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dis, adParams); + return rc; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java index 0dd120ab7a..695e04fe2a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder; - -import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.MoveRecordFolderTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Record folder integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - MoveRecordFolderTest.class -}) -public class RecordFolderTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder; + +import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.MoveRecordFolderTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Record folder integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + MoveRecordFolderTest.class +}) +public class RecordFolderTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/CreateRelationshipTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/CreateRelationshipTest.java index ffa21c8785..52f51e2498 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/CreateRelationshipTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/CreateRelationshipTest.java @@ -1,210 +1,210 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * Create relationship integration test. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class CreateRelationshipTest extends BaseRMTestCase -{ - public void testReadOnlyPermissionOnSource() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.READ_RECORDS); - filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - }); - } - - public void testReadOnlyPermissionOnTarget() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.READ_RECORDS); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - }); - } - - public void testFillingPermissionOnSourceAndTarget() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecordCategory, user, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(targetRecordCategory, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - - @Override - public void then() throws Exception - { - // assert that the relationship exists - assertEquals(1, relationshipService.getRelationshipsFrom(sourceRecord).size()); - assertEquals(0, relationshipService.getRelationshipsTo(sourceRecord).size()); - assertEquals(0, relationshipService.getRelationshipsFrom(targetRecord).size()); - assertEquals(1, relationshipService.getRelationshipsTo(targetRecord).size()); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * Create relationship integration test. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class CreateRelationshipTest extends BaseRMTestCase +{ + public void testReadOnlyPermissionOnSource() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.READ_RECORDS); + filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + }); + } + + public void testReadOnlyPermissionOnTarget() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.READ_RECORDS); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + }); + } + + public void testFillingPermissionOnSourceAndTarget() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecordCategory, user, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(targetRecordCategory, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + + @Override + public void then() throws Exception + { + // assert that the relationship exists + assertEquals(1, relationshipService.getRelationshipsFrom(sourceRecord).size()); + assertEquals(0, relationshipService.getRelationshipsTo(sourceRecord).size()); + assertEquals(0, relationshipService.getRelationshipsFrom(targetRecord).size()); + assertEquals(1, relationshipService.getRelationshipsTo(targetRecord).size()); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/DeleteRelationshipTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/DeleteRelationshipTest.java index 116541b597..243a4079d5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/DeleteRelationshipTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/DeleteRelationshipTest.java @@ -1,260 +1,260 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * Delete relationship test. - * - * @author Ana Bozianu - * @since 2.3 - */ -public class DeleteRelationshipTest extends BaseRMTestCase -{ - public void testDeleteRelationship() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - NodeRef sourceNode; - NodeRef targetNode; - String associationName = CUSTOM_REF_OBSOLETES.getLocalName(); - - public void given() - { - - // create the source record - sourceNode = utils.createRecord(rmFolder, GUID.generate()); - - //create the target record - targetNode = utils.createRecord(rmFolder, GUID.generate()); - - //create relationship - relationshipService.addRelationship(associationName, sourceNode, targetNode); - } - - public void when() - { - //delete relationship - relationshipService.removeRelationship(associationName, sourceNode, targetNode); - } - - public void then() - { - //check if relationship is deleted - Set relationships = relationshipService.getRelationshipsFrom(sourceNode); - for(Relationship r : relationships) - { - assertFalse(r.getTarget().equals(targetNode) && r.getUniqueName().equals(associationName)); - } - } - }); - } - - public void testReadOnlyPermissionOnSource() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // add relationship - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.READ_RECORDS); - filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - }); - } - - public void testReadOnlyPermissionOnTarget() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create relationship - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.READ_RECORDS); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - }); - } - - public void testFillingPermissionOnSourceAndTarget() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - /** test data */ - private String roleName = GUID.generate(); - private String user = GUID.generate(); - private NodeRef sourceRecordCategory; - private NodeRef targetRecordCategory; - private NodeRef sourceRecordFolder; - private NodeRef targetRecordFolder; - private NodeRef sourceRecord; - private NodeRef targetRecord; - - public void given() throws Exception - { - // test entities - sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); - sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); - targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); - targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); - - // create role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability("ViewRecords")); - capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); - filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - - // create user and assign to role - createPerson(user, true); - filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); - - // create relationship - relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); - } - - public void when() - { - // assign permissions - filePlanPermissionService.setPermission(sourceRecordCategory, user, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(targetRecordCategory, user, RMPermissionModel.FILING); - - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Void doWork() throws Exception - { - relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); - return null; - } - }, user); - } - - @Override - public void then() throws Exception - { - // assert that the relationship exists - assertEquals(0, relationshipService.getRelationshipsFrom(sourceRecord).size()); - assertEquals(0, relationshipService.getRelationshipsTo(sourceRecord).size()); - assertEquals(0, relationshipService.getRelationshipsFrom(targetRecord).size()); - assertEquals(0, relationshipService.getRelationshipsTo(targetRecord).size()); - } - }); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * Delete relationship test. + * + * @author Ana Bozianu + * @since 2.3 + */ +public class DeleteRelationshipTest extends BaseRMTestCase +{ + public void testDeleteRelationship() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + NodeRef sourceNode; + NodeRef targetNode; + String associationName = CUSTOM_REF_OBSOLETES.getLocalName(); + + public void given() + { + + // create the source record + sourceNode = utils.createRecord(rmFolder, GUID.generate()); + + //create the target record + targetNode = utils.createRecord(rmFolder, GUID.generate()); + + //create relationship + relationshipService.addRelationship(associationName, sourceNode, targetNode); + } + + public void when() + { + //delete relationship + relationshipService.removeRelationship(associationName, sourceNode, targetNode); + } + + public void then() + { + //check if relationship is deleted + Set relationships = relationshipService.getRelationshipsFrom(sourceNode); + for(Relationship r : relationships) + { + assertFalse(r.getTarget().equals(targetNode) && r.getUniqueName().equals(associationName)); + } + } + }); + } + + public void testReadOnlyPermissionOnSource() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // add relationship + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.READ_RECORDS); + filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + }); + } + + public void testReadOnlyPermissionOnTarget() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create relationship + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecord, user, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(targetRecord, user, RMPermissionModel.READ_RECORDS); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + }); + } + + public void testFillingPermissionOnSourceAndTarget() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + private String roleName = GUID.generate(); + private String user = GUID.generate(); + private NodeRef sourceRecordCategory; + private NodeRef targetRecordCategory; + private NodeRef sourceRecordFolder; + private NodeRef targetRecordFolder; + private NodeRef sourceRecord; + private NodeRef targetRecord; + + public void given() throws Exception + { + // test entities + sourceRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + sourceRecordFolder = recordFolderService.createRecordFolder(sourceRecordCategory, GUID.generate()); + sourceRecord = utils.createRecord(sourceRecordFolder, GUID.generate()); + targetRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + targetRecordFolder = recordFolderService.createRecordFolder(targetRecordCategory, GUID.generate()); + targetRecord = utils.createRecord(targetRecordFolder, GUID.generate()); + + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + capabilities.add(capabilityService.getCapability("ChangeOrDeleteReferences")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create relationship + relationshipService.addRelationship("crossreference", sourceRecord, targetRecord); + } + + public void when() + { + // assign permissions + filePlanPermissionService.setPermission(sourceRecordCategory, user, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(targetRecordCategory, user, RMPermissionModel.FILING); + + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + relationshipService.removeRelationship("crossreference", sourceRecord, targetRecord); + return null; + } + }, user); + } + + @Override + public void then() throws Exception + { + // assert that the relationship exists + assertEquals(0, relationshipService.getRelationshipsFrom(sourceRecord).size()); + assertEquals(0, relationshipService.getRelationshipsTo(sourceRecord).size()); + assertEquals(0, relationshipService.getRelationshipsFrom(targetRecord).size()); + assertEquals(0, relationshipService.getRelationshipsTo(targetRecord).size()); + } + }); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/RelationshipTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/RelationshipTestSuite.java index fd06625cfb..3e79d1e651 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/RelationshipTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/relationship/RelationshipTestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Relationship integration test suite - * - * @author Roy Wetherall - * @since 2.3 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - CreateRelationshipTest.class, - DeleteRelationshipTest.class -}) -public class RelationshipTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Relationship integration test suite + * + * @author Roy Wetherall + * @since 2.3 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + CreateRelationshipTest.class, + DeleteRelationshipTest.class +}) +public class RelationshipTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java index 2cb6eb3470..8c10ed8074 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java @@ -1,166 +1,166 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.report; - -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.report.Report; -import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.extensions.webscripts.GUID; - -/** - * Hold report integration tests. - *

- * Relates to: - * - https://issues.alfresco.com/jira/browse/RM-1211 - * - * @author Roy Wetherall - * @since 2.2 - */ -public class HoldReportTest extends BaseRMTestCase implements ReportModel -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * ensure that 'rmr:holdReport' is in the list of those available - */ - public void testHoldReportTypeAvailable() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private Set reportTypes; - - public void when() - { - reportTypes = reportService.getReportTypes(); - } - - public void then() - { - assertNotNull(reportTypes); - assertTrue(reportTypes.contains(TYPE_HOLD_REPORT)); - } - }); - } - - /** - * given that the reported upon node is not a hold, ensure that an error is raised when - * the report is generated. - */ - public void testReportedUponNodeIsNotAHold() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class) - { - private NodeRef reportedUponNodeRef; - - public void given() - { - reportedUponNodeRef = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - } - - public void when() - { - reportService.generateReport(TYPE_HOLD_REPORT, reportedUponNodeRef); - } - - public void after() - { - // remove created folder - nodeService.deleteNode(reportedUponNodeRef); - } - }); - } - - /** - * Given a hold that contains items, ensure the report is generated as expected - */ - public void testGenerateHoldReport() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private static final String HOLD_NAME = "holdName"; - private static final String HOLD_REASON = "holdReason"; - private static final String HOLD_DESCRIPTION = "holdDescription"; - private static final String FOLDER1_NAME = "folder1Name"; - - private NodeRef hold; - private NodeRef folder1; - private Report report; - - public void given() - { - // crate a hold - hold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); - - // add some items to the hold - folder1 = recordFolderService.createRecordFolder(rmContainer, FOLDER1_NAME); - holdService.addToHold(hold, folder1); - holdService.addToHold(hold, recordOne); - } - - public void when() - { - report = reportService.generateReport(TYPE_HOLD_REPORT, hold, MimetypeMap.MIMETYPE_HTML); - } - - public void then() - { - assertNotNull(report); - assertEquals(TYPE_HOLD_REPORT, report.getReportType()); - assertTrue(report.getReportProperties().isEmpty()); - - // check the name has been generated correctly - assertNotNull(report.getReportName()); - assertTrue(report.getReportName().contains("Hold Report")); - assertTrue(report.getReportName().contains(HOLD_NAME)); - assertTrue(report.getReportName().contains(".html")); - - // check the content reader - ContentReader reader = report.getReportContent(); - assertNotNull(reader); - assertEquals(MimetypeMap.MIMETYPE_HTML, reader.getMimetype()); - - // check the content - String reportContent = reader.getContentString(); - assertNotNull(reportContent); - assertTrue(reportContent.contains(HOLD_NAME)); - assertTrue(reportContent.contains(HOLD_REASON)); - assertTrue(reportContent.contains(HOLD_DESCRIPTION)); - assertTrue(reportContent.contains(FOLDER1_NAME)); - assertTrue(reportContent.contains("one")); - } - - public void after() - { - holdService.deleteHold(hold); - nodeService.deleteNode(folder1); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.report; + +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.report.Report; +import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.GUID; + +/** + * Hold report integration tests. + *

+ * Relates to: + * - https://issues.alfresco.com/jira/browse/RM-1211 + * + * @author Roy Wetherall + * @since 2.2 + */ +public class HoldReportTest extends BaseRMTestCase implements ReportModel +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * ensure that 'rmr:holdReport' is in the list of those available + */ + public void testHoldReportTypeAvailable() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private Set reportTypes; + + public void when() + { + reportTypes = reportService.getReportTypes(); + } + + public void then() + { + assertNotNull(reportTypes); + assertTrue(reportTypes.contains(TYPE_HOLD_REPORT)); + } + }); + } + + /** + * given that the reported upon node is not a hold, ensure that an error is raised when + * the report is generated. + */ + public void testReportedUponNodeIsNotAHold() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class) + { + private NodeRef reportedUponNodeRef; + + public void given() + { + reportedUponNodeRef = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + } + + public void when() + { + reportService.generateReport(TYPE_HOLD_REPORT, reportedUponNodeRef); + } + + public void after() + { + // remove created folder + nodeService.deleteNode(reportedUponNodeRef); + } + }); + } + + /** + * Given a hold that contains items, ensure the report is generated as expected + */ + public void testGenerateHoldReport() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private static final String HOLD_NAME = "holdName"; + private static final String HOLD_REASON = "holdReason"; + private static final String HOLD_DESCRIPTION = "holdDescription"; + private static final String FOLDER1_NAME = "folder1Name"; + + private NodeRef hold; + private NodeRef folder1; + private Report report; + + public void given() + { + // crate a hold + hold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); + + // add some items to the hold + folder1 = recordFolderService.createRecordFolder(rmContainer, FOLDER1_NAME); + holdService.addToHold(hold, folder1); + holdService.addToHold(hold, recordOne); + } + + public void when() + { + report = reportService.generateReport(TYPE_HOLD_REPORT, hold, MimetypeMap.MIMETYPE_HTML); + } + + public void then() + { + assertNotNull(report); + assertEquals(TYPE_HOLD_REPORT, report.getReportType()); + assertTrue(report.getReportProperties().isEmpty()); + + // check the name has been generated correctly + assertNotNull(report.getReportName()); + assertTrue(report.getReportName().contains("Hold Report")); + assertTrue(report.getReportName().contains(HOLD_NAME)); + assertTrue(report.getReportName().contains(".html")); + + // check the content reader + ContentReader reader = report.getReportContent(); + assertNotNull(reader); + assertEquals(MimetypeMap.MIMETYPE_HTML, reader.getMimetype()); + + // check the content + String reportContent = reader.getContentString(); + assertNotNull(reportContent); + assertTrue(reportContent.contains(HOLD_NAME)); + assertTrue(reportContent.contains(HOLD_REASON)); + assertTrue(reportContent.contains(HOLD_DESCRIPTION)); + assertTrue(reportContent.contains(FOLDER1_NAME)); + assertTrue(reportContent.contains("one")); + } + + public void after() + { + holdService.deleteHold(hold); + nodeService.deleteNode(folder1); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/ReportTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/ReportTestSuite.java index e32531429b..3a51c811a3 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/ReportTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/ReportTestSuite.java @@ -1,38 +1,38 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.report; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Report integration test suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - HoldReportTest.class -}) -public class ReportTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.report; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Report integration test suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + HoldReportTest.class +}) +public class ReportTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/CreateTransferFolderAsNonAdminUser.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/CreateTransferFolderAsNonAdminUser.java index 4409db99e8..082ed6ba3b 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/CreateTransferFolderAsNonAdminUser.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/CreateTransferFolderAsNonAdminUser.java @@ -1,157 +1,157 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.transfer; - -import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; -import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; -import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; -import static org.alfresco.util.GUID.generate; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Test case which shows that the user who creates the transfer gets filing permissions granted. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class CreateTransferFolderAsNonAdminUser extends BaseRMTestCase -{ - // Test user - private String testUser = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Create test user - testUser = generate(); - createPerson(testUser); - - // Join the RM site - siteService.setMembership(siteId, testUser, SITE_CONSUMER); - - // Add the test user to RM Records Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser); - } - - public void testCreateTransferFolderAsNonAdminUser() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(testUser) - { - // Records folder - private NodeRef recordsFolder = null; - - // Transfer folder - private NodeRef transferFolder = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() - { - runAs(new RunAsWork() - { - public Void doWork() - { - // Create category - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - - // Give filing permissions for the test users on the category - filePlanPermissionService.setPermission(category, testUser, FILING); - - // Create disposition schedule - utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); - - // Create folder - recordsFolder = recordFolderService.createRecordFolder(category, generate()); - - // Make eligible for cut off - Map params = new HashMap(1); - params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); - - // Cut off folder - rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); - - return null; - } - }, getAdminUserName()); - - // FIXME: This step should be executed in "when()". - transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() - { - // FIXME: If the transfer step is executed here the test fails?!? - //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() - { - // Check transfer folder - assertNotNull(transferFolder); - - // User should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if the user has filing permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.transfer; + +import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; +import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; +import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.util.GUID.generate; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test case which shows that the user who creates the transfer gets filing permissions granted. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class CreateTransferFolderAsNonAdminUser extends BaseRMTestCase +{ + // Test user + private String testUser = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Create test user + testUser = generate(); + createPerson(testUser); + + // Join the RM site + siteService.setMembership(siteId, testUser, SITE_CONSUMER); + + // Add the test user to RM Records Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser); + } + + public void testCreateTransferFolderAsNonAdminUser() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(testUser) + { + // Records folder + private NodeRef recordsFolder = null; + + // Transfer folder + private NodeRef transferFolder = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() + */ + @Override + public void given() + { + runAs(new RunAsWork() + { + public Void doWork() + { + // Create category + NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); + + // Give filing permissions for the test users on the category + filePlanPermissionService.setPermission(category, testUser, FILING); + + // Create disposition schedule + utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); + + // Create folder + recordsFolder = recordFolderService.createRecordFolder(category, generate()); + + // Make eligible for cut off + Map params = new HashMap(1); + params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); + + // Cut off folder + rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); + + return null; + } + }, getAdminUserName()); + + // FIXME: This step should be executed in "when()". + transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() + */ + @Override + public void when() + { + // FIXME: If the transfer step is executed here the test fails?!? + //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() + */ + @Override + public void then() + { + // Check transfer folder + assertNotNull(transferFolder); + + // User should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if the user has filing permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/FilingPermissionsOnTransferFolder.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/FilingPermissionsOnTransferFolder.java index 77778bad8d..b951854367 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/FilingPermissionsOnTransferFolder.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/FilingPermissionsOnTransferFolder.java @@ -1,192 +1,192 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.transfer; - -import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; -import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; -import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; -import static org.alfresco.util.GUID.generate; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Test case which shows that the user who did not create a transfer folder will - * be able to see and action on it if he gets filing permission on the transfer folder. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class FilingPermissionsOnTransferFolder extends BaseRMTestCase -{ - // Test users - private String testUser1 = null; - private String testUser2 = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Create test users - testUser1 = generate(); - createPerson(testUser1); - testUser2 = generate(); - createPerson(testUser2); - - // Join the RM site - siteService.setMembership(siteId, testUser1, SITE_CONSUMER); - siteService.setMembership(siteId, testUser2, SITE_CONSUMER); - - // Add the test users to RM Records Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); - } - - public void testFilingPermissionsOnTransferFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) - { - // Records folder - private NodeRef recordsFolder = null; - - // Transfer folder - private NodeRef transferFolder = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() - { - runAs(new RunAsWork() - { - public Void doWork() - { - // Create category - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - - // Give filing permissions for the test users on the category - filePlanPermissionService.setPermission(category, testUser1, FILING); - filePlanPermissionService.setPermission(category, testUser2, FILING); - - // Create disposition schedule - utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); - - // Create folder - recordsFolder = recordFolderService.createRecordFolder(category, generate()); - - // Make eligible for cut off - Map params = new HashMap(1); - params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); - - // Cut off folder - rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); - - return null; - } - }, getAdminUserName()); - - // FIXME: This step should be executed in "when()". - transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() - { - // FIXME: If the transfer step is executed here the test fails. - //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - - // Give testUser2 filing permissions on transfer folder - filePlanPermissionService.setPermission(transferFolder, testUser2, FILING); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser1 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser1 has filing permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); - - runAs(new RunAsWork() - { - public Void doWork() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser2 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser2 has read permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, READ_RECORDS)); - - // Check if testUser2 has filing permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); - - // FIXME: Should be able to execute the action. Failing intermittently. - // Execute transfer complete action as testUser2 who has filing permissions on the transfer folder - rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); - - return null; - } - }, testUser2); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.transfer; + +import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; +import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; +import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.util.GUID.generate; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test case which shows that the user who did not create a transfer folder will + * be able to see and action on it if he gets filing permission on the transfer folder. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class FilingPermissionsOnTransferFolder extends BaseRMTestCase +{ + // Test users + private String testUser1 = null; + private String testUser2 = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Create test users + testUser1 = generate(); + createPerson(testUser1); + testUser2 = generate(); + createPerson(testUser2); + + // Join the RM site + siteService.setMembership(siteId, testUser1, SITE_CONSUMER); + siteService.setMembership(siteId, testUser2, SITE_CONSUMER); + + // Add the test users to RM Records Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); + } + + public void testFilingPermissionsOnTransferFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) + { + // Records folder + private NodeRef recordsFolder = null; + + // Transfer folder + private NodeRef transferFolder = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() + */ + @Override + public void given() + { + runAs(new RunAsWork() + { + public Void doWork() + { + // Create category + NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); + + // Give filing permissions for the test users on the category + filePlanPermissionService.setPermission(category, testUser1, FILING); + filePlanPermissionService.setPermission(category, testUser2, FILING); + + // Create disposition schedule + utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); + + // Create folder + recordsFolder = recordFolderService.createRecordFolder(category, generate()); + + // Make eligible for cut off + Map params = new HashMap(1); + params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); + + // Cut off folder + rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); + + return null; + } + }, getAdminUserName()); + + // FIXME: This step should be executed in "when()". + transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() + */ + @Override + public void when() + { + // FIXME: If the transfer step is executed here the test fails. + //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + + // Give testUser2 filing permissions on transfer folder + filePlanPermissionService.setPermission(transferFolder, testUser2, FILING); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() + */ + @Override + public void then() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser1 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser1 has filing permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); + + runAs(new RunAsWork() + { + public Void doWork() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser2 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser2 has read permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, READ_RECORDS)); + + // Check if testUser2 has filing permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); + + // FIXME: Should be able to execute the action. Failing intermittently. + // Execute transfer complete action as testUser2 who has filing permissions on the transfer folder + rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); + + return null; + } + }, testUser2); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/NoPermissionsOnTransferFolder.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/NoPermissionsOnTransferFolder.java index 4ac4cf4fba..015ea18ea4 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/NoPermissionsOnTransferFolder.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/NoPermissionsOnTransferFolder.java @@ -1,181 +1,181 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.transfer; - -import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; -import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; -import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; -import static org.alfresco.service.cmr.security.AccessStatus.DENIED; -import static org.alfresco.util.GUID.generate; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Test case which shows that the user who did not create a transfer folder will not be able to see it. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class NoPermissionsOnTransferFolder extends BaseRMTestCase -{ - // Test users - private String testUser1 = null; - private String testUser2 = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Create test users - testUser1 = generate(); - createPerson(testUser1); - testUser2 = generate(); - createPerson(testUser2); - - // Join the RM site - siteService.setMembership(siteId, testUser1, SITE_CONSUMER); - siteService.setMembership(siteId, testUser2, SITE_CONSUMER); - - // Add the test users to RM Records Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); - } - - public void testNoPermissionsOnTransferFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) - { - // Records folder - private NodeRef recordsFolder = null; - - // Transfer folder - private NodeRef transferFolder = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() - { - runAs(new RunAsWork() - { - public Void doWork() - { - // Create category - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - - // Give filing permissions for the test users on the category - filePlanPermissionService.setPermission(category, testUser1, FILING); - filePlanPermissionService.setPermission(category, testUser2, FILING); - - // Create disposition schedule - utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); - - // Create folder - recordsFolder = recordFolderService.createRecordFolder(category, generate()); - - // Make eligible for cut off - Map params = new HashMap(1); - params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); - - // Cut off folder - rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); - - return null; - } - }, getAdminUserName()); - - // FIXME: This step should be executed in "when()". - transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() - { - // FIXME: If the transfer step is executed here the test fails. - //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser1 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser1 has filing permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); - - runAs(new RunAsWork() - { - public Void doWork() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser2 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser2 has read permissions on the transfer folder - assertEquals(DENIED, permissionService.hasPermission(transferFolder, READ_RECORDS)); - - return null; - } - }, testUser2); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.transfer; + +import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; +import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; +import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.service.cmr.security.AccessStatus.DENIED; +import static org.alfresco.util.GUID.generate; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test case which shows that the user who did not create a transfer folder will not be able to see it. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class NoPermissionsOnTransferFolder extends BaseRMTestCase +{ + // Test users + private String testUser1 = null; + private String testUser2 = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Create test users + testUser1 = generate(); + createPerson(testUser1); + testUser2 = generate(); + createPerson(testUser2); + + // Join the RM site + siteService.setMembership(siteId, testUser1, SITE_CONSUMER); + siteService.setMembership(siteId, testUser2, SITE_CONSUMER); + + // Add the test users to RM Records Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); + } + + public void testNoPermissionsOnTransferFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) + { + // Records folder + private NodeRef recordsFolder = null; + + // Transfer folder + private NodeRef transferFolder = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() + */ + @Override + public void given() + { + runAs(new RunAsWork() + { + public Void doWork() + { + // Create category + NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); + + // Give filing permissions for the test users on the category + filePlanPermissionService.setPermission(category, testUser1, FILING); + filePlanPermissionService.setPermission(category, testUser2, FILING); + + // Create disposition schedule + utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); + + // Create folder + recordsFolder = recordFolderService.createRecordFolder(category, generate()); + + // Make eligible for cut off + Map params = new HashMap(1); + params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); + + // Cut off folder + rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); + + return null; + } + }, getAdminUserName()); + + // FIXME: This step should be executed in "when()". + transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() + */ + @Override + public void when() + { + // FIXME: If the transfer step is executed here the test fails. + //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() + */ + @Override + public void then() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser1 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser1 has filing permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); + + runAs(new RunAsWork() + { + public Void doWork() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser2 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser2 has read permissions on the transfer folder + assertEquals(DENIED, permissionService.hasPermission(transferFolder, READ_RECORDS)); + + return null; + } + }, testUser2); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/ReadPermissionsOnTransferFolder.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/ReadPermissionsOnTransferFolder.java index 2ad2e58d49..f121f572ea 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/ReadPermissionsOnTransferFolder.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/ReadPermissionsOnTransferFolder.java @@ -1,201 +1,201 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.transfer; - -import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; -import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; -import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; -import static org.alfresco.service.cmr.security.AccessStatus.DENIED; -import static org.alfresco.util.GUID.generate; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Test case which shows that the user who did not create a transfer folder will - * be able to see the transfer folder if he gets read permissions, but will not - * be able to action on it. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class ReadPermissionsOnTransferFolder extends BaseRMTestCase -{ - // Test users - private String testUser1 = null; - private String testUser2 = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Create test users - testUser1 = generate(); - createPerson(testUser1); - testUser2 = generate(); - createPerson(testUser2); - - // Join the RM site - siteService.setMembership(siteId, testUser1, SITE_CONSUMER); - siteService.setMembership(siteId, testUser2, SITE_CONSUMER); - - // Add the users to RM Records Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); - } - - public void testReadPermissionsOnTransferFolder() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) - { - // Records folder - private NodeRef recordsFolder = null; - - // Transfer folder - private NodeRef transferFolder = null; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() - { - runAs(new RunAsWork() - { - public Void doWork() - { - // Create category - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - - // Give filing permissions for the test users on the category - filePlanPermissionService.setPermission(category, testUser1, FILING); - filePlanPermissionService.setPermission(category, testUser2, FILING); - - // Create disposition schedule - utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); - - // Create folder - recordsFolder = recordFolderService.createRecordFolder(category, generate()); - - // Make eligible for cut off - Map params = new HashMap(1); - params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); - - // Cut off folder - rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); - - return null; - } - }, getAdminUserName()); - - // FIXME: This step should be executed in "when()". - transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() - { - // FIXME: If the transfer step is executed here the test fails. - //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); - - // Give testUser2 read permissions on transfer folder - filePlanPermissionService.setPermission(transferFolder, testUser2, READ_RECORDS); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser1 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser1 has filing permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); - - runAs(new RunAsWork() - { - public Void doWork() - { - // Check transfer folder - assertNotNull(transferFolder); - - // testUser2 should have read permissions on the transfers container - assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); - - // Check if testUser2 has read permissions on the transfer folder - assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, READ_RECORDS)); - - // Check if testUser2 filing permissions on the transfer folder - assertEquals(DENIED, permissionService.hasPermission(transferFolder, FILING)); - - // Try to execute transfer complete action as testUser2 who has no filing permissions on the transfer folder - try - { - rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); - } - catch (AccessDeniedException ade) - { - // Expected - } - - return null; - } - }, testUser2); - } - }); - } -} +/* + * Copyright (C) 2005-2015 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.test.integration.transfer; + +import static org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction.PARAM_EVENT_NAME; +import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS; +import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAs; +import static org.alfresco.repo.site.SiteModel.SITE_CONSUMER; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.service.cmr.security.AccessStatus.DENIED; +import static org.alfresco.util.GUID.generate; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test case which shows that the user who did not create a transfer folder will + * be able to see the transfer folder if he gets read permissions, but will not + * be able to action on it. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class ReadPermissionsOnTransferFolder extends BaseRMTestCase +{ + // Test users + private String testUser1 = null; + private String testUser2 = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Create test users + testUser1 = generate(); + createPerson(testUser1); + testUser2 = generate(); + createPerson(testUser2); + + // Join the RM site + siteService.setMembership(siteId, testUser1, SITE_CONSUMER); + siteService.setMembership(siteId, testUser2, SITE_CONSUMER); + + // Add the users to RM Records Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser1); + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, testUser2); + } + + public void testReadPermissionsOnTransferFolder() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(testUser1) + { + // Records folder + private NodeRef recordsFolder = null; + + // Transfer folder + private NodeRef transferFolder = null; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() + */ + @Override + public void given() + { + runAs(new RunAsWork() + { + public Void doWork() + { + // Create category + NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); + + // Give filing permissions for the test users on the category + filePlanPermissionService.setPermission(category, testUser1, FILING); + filePlanPermissionService.setPermission(category, testUser2, FILING); + + // Create disposition schedule + utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true, true); + + // Create folder + recordsFolder = recordFolderService.createRecordFolder(category, generate()); + + // Make eligible for cut off + Map params = new HashMap(1); + params.put(PARAM_EVENT_NAME, DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordsFolder, CompleteEventAction.NAME, params); + + // Cut off folder + rmActionService.executeRecordsManagementAction(recordsFolder, CutOffAction.NAME); + + return null; + } + }, getAdminUserName()); + + // FIXME: This step should be executed in "when()". + transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() + */ + @Override + public void when() + { + // FIXME: If the transfer step is executed here the test fails. + //transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordsFolder, TransferAction.NAME).getValue(); + + // Give testUser2 read permissions on transfer folder + filePlanPermissionService.setPermission(transferFolder, testUser2, READ_RECORDS); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() + */ + @Override + public void then() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser1 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser1 has filing permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, FILING)); + + runAs(new RunAsWork() + { + public Void doWork() + { + // Check transfer folder + assertNotNull(transferFolder); + + // testUser2 should have read permissions on the transfers container + assertEquals(ALLOWED, permissionService.hasPermission(transfersContainer, READ_RECORDS)); + + // Check if testUser2 has read permissions on the transfer folder + assertEquals(ALLOWED, permissionService.hasPermission(transferFolder, READ_RECORDS)); + + // Check if testUser2 filing permissions on the transfer folder + assertEquals(DENIED, permissionService.hasPermission(transferFolder, FILING)); + + // Try to execute transfer complete action as testUser2 who has no filing permissions on the transfer folder + try + { + rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); + } + catch (AccessDeniedException ade) + { + // Expected + } + + return null; + } + }, testUser2); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/TransferTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/TransferTestSuite.java index ceb1a8dedb..6c940bef5b 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/TransferTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/transfer/TransferTestSuite.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2005-2015 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.test.integration.transfer; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Transfer test suite - * - * @author Tuna Aksoy - * @since 2.3 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - CreateTransferFolderAsNonAdminUser.class, - FilingPermissionsOnTransferFolder.class, - NoPermissionsOnTransferFolder.class, - ReadPermissionsOnTransferFolder.class -}) -public class TransferTestSuite -{ - -} +/* + * Copyright (C) 2005-2015 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.test.integration.transfer; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Transfer test suite + * + * @author Tuna Aksoy + * @since 2.3 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + CreateTransferFolderAsNonAdminUser.class, + FilingPermissionsOnTransferFolder.class, + NoPermissionsOnTransferFolder.class, + ReadPermissionsOnTransferFolder.class +}) +public class TransferTestSuite +{ + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AdHocRecordableVersionsTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AdHocRecordableVersionsTest.java index b8a2ed6e94..4f88f37158 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AdHocRecordableVersionsTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AdHocRecordableVersionsTest.java @@ -1,190 +1,190 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionType; - -/** - * AdHoc Recordable Versions Integration Test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class AdHocRecordableVersionsTest extends RecordableVersionsBaseTest -{ - /** - * Adhoc recorded version creation, with no policy defined as site collaborator - */ - public void testRecordAdHocVersionNoPolicy() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); - } - - public void when() - { - // create version - versionService.createVersion(dmDocument, versionProperties); - } - - public void then() - { - // check that the record has been recorded - checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); - } - }); - } - - /** - * Adhoc recordable version with recordable set as false - */ - public void testRecordableVersionFalseNoPolicy() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, false); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); - } - - public void when() - { - // create version - versionService.createVersion(dmDocument, versionProperties); - } - - public void then() - { - // check that the record has been recorded - checkNotRecordedAspect(dmDocument, DESCRIPTION, "0.1"); - } - }); - } - - /** - * Test no file plan specified (and no default available) - */ - public void testNoFilePlan() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, dmCollaborator) - { - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - } - - public void when() - { - // create version - versionService.createVersion(dmDocument, versionProperties); - } - - public void then() - { - // check that the record has been recorded - checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); - } - - }); - } - - /** - * Test recorded version with record metadata aspect (want to ensure additional non-rm URI properties and aspects - * don't find their way into the frozen state) - */ - public void testRecordedVersionWithRecordMetadataAspect() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); - } - - public void when() - { - // create version - final Version version = versionService.createVersion(dmDocument, versionProperties); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // add custom meta-data to record - NodeRef record = recordableVersionService.getVersionRecord(version); - assertNotNull(record); - recordService.addRecordType(record, TestModel.ASPECT_RECORD_METADATA); - nodeService.setProperty(record, TestModel.PROPERTY_RECORD_METADATA, "Peter Wetherall"); - - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - public void then() - { - // check that the record has been recorded - checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); - } - }); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionType; + +/** + * AdHoc Recordable Versions Integration Test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class AdHocRecordableVersionsTest extends RecordableVersionsBaseTest +{ + /** + * Adhoc recorded version creation, with no policy defined as site collaborator + */ + public void testRecordAdHocVersionNoPolicy() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); + } + + public void when() + { + // create version + versionService.createVersion(dmDocument, versionProperties); + } + + public void then() + { + // check that the record has been recorded + checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); + } + }); + } + + /** + * Adhoc recordable version with recordable set as false + */ + public void testRecordableVersionFalseNoPolicy() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, false); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); + } + + public void when() + { + // create version + versionService.createVersion(dmDocument, versionProperties); + } + + public void then() + { + // check that the record has been recorded + checkNotRecordedAspect(dmDocument, DESCRIPTION, "0.1"); + } + }); + } + + /** + * Test no file plan specified (and no default available) + */ + public void testNoFilePlan() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, dmCollaborator) + { + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + } + + public void when() + { + // create version + versionService.createVersion(dmDocument, versionProperties); + } + + public void then() + { + // check that the record has been recorded + checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); + } + + }); + } + + /** + * Test recorded version with record metadata aspect (want to ensure additional non-rm URI properties and aspects + * don't find their way into the frozen state) + */ + public void testRecordedVersionWithRecordMetadataAspect() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); + } + + public void when() + { + // create version + final Version version = versionService.createVersion(dmDocument, versionProperties); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // add custom meta-data to record + NodeRef record = recordableVersionService.getVersionRecord(version); + assertNotNull(record); + recordService.addRecordType(record, TestModel.ASPECT_RECORD_METADATA); + nodeService.setProperty(record, TestModel.PROPERTY_RECORD_METADATA, "Peter Wetherall"); + + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + public void then() + { + // check that the record has been recorded + checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); + } + }); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoRecordableVersionsTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoRecordableVersionsTest.java index 81a49f3652..8f732604ab 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoRecordableVersionsTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoRecordableVersionsTest.java @@ -1,170 +1,170 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.util.PropertyMap; - -/** - * Auto Recordable Versions Integration Test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class AutoRecordableVersionsTest extends RecordableVersionsBaseTest -{ - /** example content */ - public final static String MY_NEW_CONTENT = "this is some new content that I have changed to trigger auto version"; - - /** - * Given that all revisions will be recorded, - * When I update the content of a document, - * Then a recorded version will be created - */ - public void testAutoVersionRecordAllRevisions() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - public void given() throws Exception - { - // set the recordable version policy - PropertyMap recordableVersionProperties = new PropertyMap(1); - recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); - nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties); - - // make the node versionable - PropertyMap versionableProperties = new PropertyMap(1); - versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false); - nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties); - } - - public void when() - { - // generate new version by updating content - ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true); - writer.putContent(MY_NEW_CONTENT); - } - - public void then() - { - // check that the record has been recorded - checkRecordedVersion(dmDocument, null, "0.1"); - } - }); - } - - /** - * Given that all revisions will be automatically recorded, - * When I update a document 3 times, - * Then all 3 created records will be related together using the "VersionedBy" relationship - */ - public void testVersionRecordsRelated() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator, false) - { - /** given **/ - public void given() throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - // set the recordable version policy - PropertyMap recordableVersionProperties = new PropertyMap(1); - recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); - nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties); - - // make the node versionable - PropertyMap versionableProperties = new PropertyMap(1); - versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false); - nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties); - } - }); - } - - /** when **/ - public void when() - { - // update the content 3 times - updateContent(); - updateContent(); - updateContent(); - } - - /** then */ - public void then() - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - // check that the record has been recorded - checkRecordedVersion(dmDocument, null, "0.3"); - - Version version = versionService.getCurrentVersion(dmDocument); - NodeRef record = recordableVersionService.getVersionRecord(version); - - boolean foundPrevious = false; - Set relationships = relationshipService.getRelationshipsFrom(record); - assertNotNull(relationships); - assertEquals(1, relationships.size()); - for (Relationship relationship : relationships) - { - if (relationship.getUniqueName().equals(CUSTOM_REF_VERSIONS.getLocalName())) - { - NodeRef previousVersionRecord = relationship.getTarget(); - assertNotNull(previousVersionRecord); - foundPrevious = true; - } - } - assertTrue(foundPrevious); - } - }); - } - - /** - * Helper method to update content of dmDocument - */ - private void updateContent() - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true); - writer.putContent(MY_NEW_CONTENT); - } - }); - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.util.PropertyMap; + +/** + * Auto Recordable Versions Integration Test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class AutoRecordableVersionsTest extends RecordableVersionsBaseTest +{ + /** example content */ + public final static String MY_NEW_CONTENT = "this is some new content that I have changed to trigger auto version"; + + /** + * Given that all revisions will be recorded, + * When I update the content of a document, + * Then a recorded version will be created + */ + public void testAutoVersionRecordAllRevisions() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + public void given() throws Exception + { + // set the recordable version policy + PropertyMap recordableVersionProperties = new PropertyMap(1); + recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); + nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties); + + // make the node versionable + PropertyMap versionableProperties = new PropertyMap(1); + versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false); + nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties); + } + + public void when() + { + // generate new version by updating content + ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true); + writer.putContent(MY_NEW_CONTENT); + } + + public void then() + { + // check that the record has been recorded + checkRecordedVersion(dmDocument, null, "0.1"); + } + }); + } + + /** + * Given that all revisions will be automatically recorded, + * When I update a document 3 times, + * Then all 3 created records will be related together using the "VersionedBy" relationship + */ + public void testVersionRecordsRelated() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator, false) + { + /** given **/ + public void given() throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + // set the recordable version policy + PropertyMap recordableVersionProperties = new PropertyMap(1); + recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + recordableVersionProperties.put(PROP_FILE_PLAN, filePlan); + nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties); + + // make the node versionable + PropertyMap versionableProperties = new PropertyMap(1); + versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false); + nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties); + } + }); + } + + /** when **/ + public void when() + { + // update the content 3 times + updateContent(); + updateContent(); + updateContent(); + } + + /** then */ + public void then() + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + // check that the record has been recorded + checkRecordedVersion(dmDocument, null, "0.3"); + + Version version = versionService.getCurrentVersion(dmDocument); + NodeRef record = recordableVersionService.getVersionRecord(version); + + boolean foundPrevious = false; + Set relationships = relationshipService.getRelationshipsFrom(record); + assertNotNull(relationships); + assertEquals(1, relationships.size()); + for (Relationship relationship : relationships) + { + if (relationship.getUniqueName().equals(CUSTOM_REF_VERSIONS.getLocalName())) + { + NodeRef previousVersionRecord = relationship.getTarget(); + assertNotNull(previousVersionRecord); + foundPrevious = true; + } + } + assertTrue(foundPrevious); + } + }); + } + + /** + * Helper method to update content of dmDocument + */ + private void updateContent() + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true); + writer.putContent(MY_NEW_CONTENT); + } + }); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoVersionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoVersionTest.java index bad197926f..4a3963f6b0 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoVersionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/AutoVersionTest.java @@ -1,232 +1,232 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.version.ExtendedVersionableAspect; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - - -/** - * Test recorded version histories when interacting with cm:versionable aspect - * and the auto-version behvaiour. - * - * @author Roy Wetherall - * @since 2.3.1 - */ -public class AutoVersionTest extends RecordableVersionsBaseTest -{ - /** - * Given a versionable document - * When I specialise the type of the document - * Then the version history has only one initial version - * And it does not represent the current type of the document - */ - public void testSpecialisedNodeInitialVersionCreated() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private NodeRef myDocument; - - public void given() throws Exception - { - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - // make versionable - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); - } - - public void when() - { - // specialise document - nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); - } - - public void then() - { - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - - assertNotNull(versionHistory); - assertEquals(1, versionHistory.getAllVersions().size()); - - NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); - assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState)); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); - } - }); - } - - /** - * Given a versionable document with initial version turned off - * When I specialise the type of the document - * Then the version history remains empty - */ - public void testSpecialisedNodeInitialVersionNotCreated() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private NodeRef myDocument; - - public void given() throws Exception - { - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - // make versionable - Map props = new HashMap(1); - props.put(ContentModel.PROP_INITIAL_VERSION, false); - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); - } - - public void when() - { - // specialise document - nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); - } - - public void then() - { - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNull(versionHistory); - } - }); - } - - /** - * Given a versionable document with initial version turned off - * And auto version on type change is set on - * When I specialise the type of the document - * Then the version history contains the initial version - */ - public void testSpecialisedNodeInitialVersionNotCreatedOnTypeChangeOn() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private ExtendedVersionableAspect extendedVersionableAspect; - private NodeRef myDocument; - - public void given() throws Exception - { - // turn auto version on type change on - extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect"); - assertNotNull(extendedVersionableAspect); - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - // make versionable - Map props = new HashMap(1); - props.put(ContentModel.PROP_INITIAL_VERSION, false); - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); - } - - public void when() - { - // specialise document - nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); - } - - public void then() - { - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - assertEquals(1, versionHistory.getAllVersions().size()); - - NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState)); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); - } - - public void after() throws Exception - { - // reset auto version on type to default off - extendedVersionableAspect.setAutoVersionOnTypeChange(false); - } - }); - } - - /** - * Given a versionable document with initial version turned on - * And auto version on type change is set on - * When I specialise the type of the document - * Then the version history contains the initial version - */ - public void testSpecialisedNodeInitialVersionCreatedOnTypeChangeOn() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private ExtendedVersionableAspect extendedVersionableAspect; - private NodeRef myDocument; - - public void given() throws Exception - { - // turn auto version on type change on - extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect"); - assertNotNull(extendedVersionableAspect); - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - // make versionable - Map props = new HashMap(1); - props.put(ContentModel.PROP_INITIAL_VERSION, true); - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); - } - - public void when() - { - // specialise document - nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); - } - - public void then() - { - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - assertEquals(2, versionHistory.getAllVersions().size()); - - NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState)); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); - - frozenState = versionHistory.getVersion("1.0").getFrozenStateNodeRef(); - assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState)); - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); - } - - public void after() throws Exception - { - // reset auto version on type to default off - extendedVersionableAspect.setAutoVersionOnTypeChange(false); - } - }); - } - - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.version.ExtendedVersionableAspect; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + + +/** + * Test recorded version histories when interacting with cm:versionable aspect + * and the auto-version behvaiour. + * + * @author Roy Wetherall + * @since 2.3.1 + */ +public class AutoVersionTest extends RecordableVersionsBaseTest +{ + /** + * Given a versionable document + * When I specialise the type of the document + * Then the version history has only one initial version + * And it does not represent the current type of the document + */ + public void testSpecialisedNodeInitialVersionCreated() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private NodeRef myDocument; + + public void given() throws Exception + { + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + // make versionable + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); + } + + public void when() + { + // specialise document + nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); + } + + public void then() + { + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + + assertNotNull(versionHistory); + assertEquals(1, versionHistory.getAllVersions().size()); + + NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); + assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState)); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); + } + }); + } + + /** + * Given a versionable document with initial version turned off + * When I specialise the type of the document + * Then the version history remains empty + */ + public void testSpecialisedNodeInitialVersionNotCreated() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private NodeRef myDocument; + + public void given() throws Exception + { + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + // make versionable + Map props = new HashMap(1); + props.put(ContentModel.PROP_INITIAL_VERSION, false); + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); + } + + public void when() + { + // specialise document + nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); + } + + public void then() + { + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNull(versionHistory); + } + }); + } + + /** + * Given a versionable document with initial version turned off + * And auto version on type change is set on + * When I specialise the type of the document + * Then the version history contains the initial version + */ + public void testSpecialisedNodeInitialVersionNotCreatedOnTypeChangeOn() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private ExtendedVersionableAspect extendedVersionableAspect; + private NodeRef myDocument; + + public void given() throws Exception + { + // turn auto version on type change on + extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect"); + assertNotNull(extendedVersionableAspect); + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + // make versionable + Map props = new HashMap(1); + props.put(ContentModel.PROP_INITIAL_VERSION, false); + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); + } + + public void when() + { + // specialise document + nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); + } + + public void then() + { + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + assertEquals(1, versionHistory.getAllVersions().size()); + + NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState)); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); + } + + public void after() throws Exception + { + // reset auto version on type to default off + extendedVersionableAspect.setAutoVersionOnTypeChange(false); + } + }); + } + + /** + * Given a versionable document with initial version turned on + * And auto version on type change is set on + * When I specialise the type of the document + * Then the version history contains the initial version + */ + public void testSpecialisedNodeInitialVersionCreatedOnTypeChangeOn() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private ExtendedVersionableAspect extendedVersionableAspect; + private NodeRef myDocument; + + public void given() throws Exception + { + // turn auto version on type change on + extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect"); + assertNotNull(extendedVersionableAspect); + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + // make versionable + Map props = new HashMap(1); + props.put(ContentModel.PROP_INITIAL_VERSION, true); + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props); + } + + public void when() + { + // specialise document + nodeService.setType(myDocument, TYPE_CUSTOM_TYPE); + } + + public void then() + { + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + assertEquals(2, versionHistory.getAllVersions().size()); + + NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef(); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState)); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); + + frozenState = versionHistory.getVersion("1.0").getFrozenStateNodeRef(); + assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState)); + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument)); + } + + public void after() throws Exception + { + // reset auto version on type to default off + extendedVersionableAspect.setAutoVersionOnTypeChange(false); + } + }); + } + + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java index 31e4a430dc..b305a1801c 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java @@ -1,208 +1,208 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.util.GUID; - -/** - * Declare as record version integration tests - * - * @author Roy Wetherall - * @since 2.3 - */ -public class DeclareAsRecordVersionTest extends RecordableVersionsBaseTest -{ - /** recordable version service */ - private RecordableVersionService recordableVersionService; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - recordableVersionService = (RecordableVersionService)applicationContext.getBean("RecordableVersionService"); - } - - /** - * Given versionable content with a non-recorded latest version - * When I declare a version record - * Then the latest version is recorded and a record is created - */ - public void testDeclareLatestVersionAsRecord() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private NodeRef versionRecord; - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // create version - versionService.createVersion(dmDocument, versionProperties); - - // assert that the latest version is not recorded - assertFalse(recordableVersionService.isCurrentVersionRecorded(dmDocument)); - } - - public void when() - { - // create version record from latest version - versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, dmDocument); - } - - public void then() - { - // check the created record - assertNotNull(versionRecord); - assertTrue(recordService.isRecord(versionRecord)); - - // assert the current version is recorded - assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); - - // check the recorded version - checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); - } - }); - } - - /** - * Given versionable content with a recorded latest version - * When I declare a version record - * Then nothing happens since the latest version is already recorded - * And a warning is logged - */ - public void testDeclareLatestVersionAsRecordButAlreadyRecorded() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private NodeRef versionRecord; - private Map versionProperties; - - public void given() throws Exception - { - // setup version properties - versionProperties = new HashMap(4); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); - - // create version - versionService.createVersion(dmDocument, versionProperties); - - // assert that the latest version is not recorded - assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); - } - - public void when() - { - // create version record from latest version - versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, dmDocument); - } - - public void then() - { - // check that a record was not created - assertNull(versionRecord); - - // assert the current version is recorded - assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); - - // check the recorded version - checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); - } - }); - } - - /** - * Given that a document is a specialized type - * When version is declared as a record - * Then the record is the same type as the source document - * - * @see https://issues.alfresco.com/jira/browse/RM-2194 - */ - public void testSpecializedContentType() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) - { - private NodeRef customDocument; - private NodeRef versionRecord; - private Map versionProperties; - - public void given() throws Exception - { - // create content - customDocument = fileFolderService.create(dmFolder, GUID.generate(), TYPE_CUSTOM_TYPE).getNodeRef(); - prepareContent(customDocument); - - // setup version properties - versionProperties = new HashMap(2); - versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // create version - versionService.createVersion(customDocument, versionProperties); - - // assert that the latest version is not recorded - assertFalse(recordableVersionService.isCurrentVersionRecorded(customDocument)); - } - - public void when() - { - // create version record from latest version - versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, customDocument); - } - - public void then() - { - // check the created record - assertNotNull(versionRecord); - assertTrue(recordService.isRecord(versionRecord)); - - // check the record type is correct - assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(versionRecord)); - - // assert the current version is recorded - assertTrue(recordableVersionService.isCurrentVersionRecorded(customDocument)); - - // check the recorded version - checkRecordedVersion(customDocument, DESCRIPTION, "0.1"); - } - }); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionType; +import org.alfresco.util.GUID; + +/** + * Declare as record version integration tests + * + * @author Roy Wetherall + * @since 2.3 + */ +public class DeclareAsRecordVersionTest extends RecordableVersionsBaseTest +{ + /** recordable version service */ + private RecordableVersionService recordableVersionService; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + recordableVersionService = (RecordableVersionService)applicationContext.getBean("RecordableVersionService"); + } + + /** + * Given versionable content with a non-recorded latest version + * When I declare a version record + * Then the latest version is recorded and a record is created + */ + public void testDeclareLatestVersionAsRecord() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private NodeRef versionRecord; + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // create version + versionService.createVersion(dmDocument, versionProperties); + + // assert that the latest version is not recorded + assertFalse(recordableVersionService.isCurrentVersionRecorded(dmDocument)); + } + + public void when() + { + // create version record from latest version + versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, dmDocument); + } + + public void then() + { + // check the created record + assertNotNull(versionRecord); + assertTrue(recordService.isRecord(versionRecord)); + + // assert the current version is recorded + assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); + + // check the recorded version + checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); + } + }); + } + + /** + * Given versionable content with a recorded latest version + * When I declare a version record + * Then nothing happens since the latest version is already recorded + * And a warning is logged + */ + public void testDeclareLatestVersionAsRecordButAlreadyRecorded() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private NodeRef versionRecord; + private Map versionProperties; + + public void given() throws Exception + { + // setup version properties + versionProperties = new HashMap(4); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan); + + // create version + versionService.createVersion(dmDocument, versionProperties); + + // assert that the latest version is not recorded + assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); + } + + public void when() + { + // create version record from latest version + versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, dmDocument); + } + + public void then() + { + // check that a record was not created + assertNull(versionRecord); + + // assert the current version is recorded + assertTrue(recordableVersionService.isCurrentVersionRecorded(dmDocument)); + + // check the recorded version + checkRecordedVersion(dmDocument, DESCRIPTION, "0.1"); + } + }); + } + + /** + * Given that a document is a specialized type + * When version is declared as a record + * Then the record is the same type as the source document + * + * @see https://issues.alfresco.com/jira/browse/RM-2194 + */ + public void testSpecializedContentType() + { + doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) + { + private NodeRef customDocument; + private NodeRef versionRecord; + private Map versionProperties; + + public void given() throws Exception + { + // create content + customDocument = fileFolderService.create(dmFolder, GUID.generate(), TYPE_CUSTOM_TYPE).getNodeRef(); + prepareContent(customDocument); + + // setup version properties + versionProperties = new HashMap(2); + versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // create version + versionService.createVersion(customDocument, versionProperties); + + // assert that the latest version is not recorded + assertFalse(recordableVersionService.isCurrentVersionRecorded(customDocument)); + } + + public void when() + { + // create version record from latest version + versionRecord = recordableVersionService.createRecordFromLatestVersion(filePlan, customDocument); + } + + public void then() + { + // check the created record + assertNotNull(versionRecord); + assertTrue(recordService.isRecord(versionRecord)); + + // check the record type is correct + assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(versionRecord)); + + // assert the current version is recorded + assertTrue(recordableVersionService.isCurrentVersionRecorded(customDocument)); + + // check the recorded version + checkRecordedVersion(customDocument, DESCRIPTION, "0.1"); + } + }); + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeleteRecordVersionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeleteRecordVersionTest.java index 520ac8d318..78f9a244db 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeleteRecordVersionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeleteRecordVersionTest.java @@ -1,505 +1,505 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - - -/** - * Recordable version history integration tests. - * - * @author Roy Wetherall - * @since 2.3.1 - */ -public class DeleteRecordVersionTest extends RecordableVersionsBaseTest -{ - /** - * Given that a document is created - * And the initial version is record - * When I delete the version record - * Then the version is deleted - * And the version history is not deleted - * - * @see https://issues.alfresco.com/jira/browse/RM-2562 - */ - public void testDeleteFirstRecordedVersion() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef myDocument; - - public void given() throws Exception - { - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - // make versionable - Map props = new HashMap(2); - props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); - nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props); - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); - } - - public void when() - { - // check the initial version label - assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); - - // check that the version history contains a single version that is recorded - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - assertEquals(1, versionHistory.getAllVersions().size()); - - // check the recorded version is not marked as destroyed - Version head = versionHistory.getHeadVersion(); - assertNotNull(head); - assertFalse(recordableVersionService.isRecordedVersionDestroyed(head)); - - // check the version record - NodeRef record = recordableVersionService.getVersionRecord(head); - assertTrue(recordService.isRecord(record)); - - // record should not have a version history because it is immutable - assertFalse(nodeService.hasAspect(record, ContentModel.ASPECT_VERSIONABLE)); - VersionHistory recordVersionHistory = versionService.getVersionHistory(record); - assertNull(recordVersionHistory); - - // destroy record - nodeService.deleteNode(record); - } - - public void then() - { - // document is still versionable - assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE)); - - // check the initial version label - assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); - - // still has a version history, but the version is marked as destroyed - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - assertEquals(1, versionHistory.getAllVersions().size()); - - // check the recorded version is marked as destroyed and the record version is not longer available - Version version = versionHistory.getHeadVersion(); - assertNotNull(version); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(version)); - assertNull(recordableVersionService.getVersionRecord(version)); - } - }); - } - - /** - * Given that a document is created - * And the initial version is record - * And the associated version record is deleted - * When a new version is created - * Then a new associated version record is created - * And the version is 1.1 (not 1.0 since this was deleted, but the version history maintained) - * - * @see https://issues.alfresco.com/jira/browse/RM-2562 - */ - public void testDeleteFirstRecordedVersionAndCreateNewVersion() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef myDocument; - - public void given() throws Exception - { - // create a document - myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - ContentWriter writer = fileFolderService.getWriter(myDocument); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(GUID.generate()); - - // make versionable - Map props = new HashMap(2); - props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); - nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props); - nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); - } - - public void when() - { - // get the created version record - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - Version head = versionHistory.getHeadVersion(); - NodeRef record = recordableVersionService.getVersionRecord(head); - - // destroy record - nodeService.deleteNode(record); - - // update the content to create a new version (and version record) - ContentWriter writer = fileFolderService.getWriter(myDocument); - writer.putContent(GUID.generate()); - } - - public void then() - { - // document is still versionable - assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE)); - - // check the version number has been incremented - assertEquals("1.1", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); - - // still has a version history, with 2 enties - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - assertEquals(2, versionHistory.getAllVersions().size()); - - // latest version is current - Version head = versionHistory.getHeadVersion(); - assertFalse(recordableVersionService.isRecordedVersionDestroyed(head)); - assertNotNull(recordableVersionService.getVersionRecord(head)); - - // first version is destroyed - Version destroyed = versionHistory.getPredecessor(head); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(destroyed)); - assertNull(recordableVersionService.getVersionRecord(destroyed)); - - // get the version record for the current version - NodeRef versionRecord = recordableVersionService.getVersionRecord(head); - assertNotNull(versionRecord); - assertTrue(nodeService.exists(versionRecord)); - - Set from = relationshipService.getRelationshipsFrom(versionRecord); - assertTrue(from.isEmpty()); - - Set to = relationshipService.getRelationshipsTo(versionRecord); - assertTrue(to.isEmpty()); - } - }); - } - - /** - * Given a chain of version records (1.0, 1.1, 1.2) which are all related - * When I delete version record 1.0 - * Then 1.1 is the oldest version - */ - public void testDeleteOldestVersion() - { - final NodeRef myDocument = createDocumentWithRecordVersions(); - - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private VersionHistory versionHistory; - - public void given() throws Exception - { - // get version history - versionHistory = versionService.getVersionHistory(myDocument); - } - - public void when() - { - Version version10 = versionHistory.getVersion("1.0"); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - - // delete record version 1.0 - nodeService.deleteNode(recordVersion10); - } - - public void then() - { - // check the deleted version - Version version10 = versionHistory.getVersion("1.0"); - assertNotNull(version10); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(version10)); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - assertNull(recordVersion10); - - // verify 1.2 setup as expected - Version version12 = versionHistory.getHeadVersion(); - assertEquals("1.2", version12.getVersionLabel()); - NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); - assertNotNull(recordVersion12); - - assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - - Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, from12.size()); - - // verify 1.1 setup as expected - Version version11 = versionHistory.getPredecessor(version12); - assertEquals("1.1", version11.getVersionLabel()); - NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); - assertNotNull(recordVersion11); - - Set to11 = relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, to11.size()); - assertEquals(recordVersion12, to11.iterator().next().getSource()); - - assertTrue(relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - } - }); - } - - /** - * Given a chain of version records (1.0, 1.1, 1.2) which are all related - * When I delete version record 1.1 - * Then 1.2 now 'versions' 1.0 - */ - public void testDeleteMiddleVersion() - { - final NodeRef myDocument = createDocumentWithRecordVersions(); - - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private VersionHistory versionHistory; - - public void given() throws Exception - { - // get version history - versionHistory = versionService.getVersionHistory(myDocument); - } - - public void when() - { - Version version11 = versionHistory.getVersion("1.1"); - NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); - - // delete record version 1.1 - nodeService.deleteNode(recordVersion11); - } - - public void then() - { - // check the deleted version - Version version11 = versionHistory.getVersion("1.1"); - assertNotNull(version11); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11)); - NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); - assertNull(recordVersion11); - - // verify 1.2 setup as expected - Version version12 = versionHistory.getHeadVersion(); - assertEquals("1.2", version12.getVersionLabel()); - NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); - assertNotNull(recordVersion12); - - assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - - Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, from12.size()); - - // verify 1.0 setup as expected - Version version10 = versionHistory.getVersion("1.0"); - assertEquals("1.0", version10.getVersionLabel()); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - assertNotNull(recordVersion10); - - Set to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, to10.size()); - assertEquals(recordVersion12, to10.iterator().next().getSource()); - - assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - - } - }); - } - - /** - * Given a chain of version records (1.0, 1.1, 1.2) which are all related - * When I delete version record 1.2 - * Then 1.1 is the most recent version - */ - public void testDeleteCurrentVersion() - { - final NodeRef myDocument = createDocumentWithRecordVersions(); - - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private VersionHistory versionHistory; - - public void given() throws Exception - { - // get version history - versionHistory = versionService.getVersionHistory(myDocument); - } - - public void when() - { - Version version12 = versionHistory.getVersion("1.2"); - NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); - - // delete record version 1.2 - nodeService.deleteNode(recordVersion12); - } - - public void then() - { - // check 1.2 - Version version12 = versionHistory.getVersion("1.2"); - assertNotNull(version12); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(version12)); - assertNull(recordableVersionService.getVersionRecord(version12)); - - // verify 1.1 - Version version11 = versionHistory.getVersion("1.1"); - assertNotNull(version11); - NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); - assertNotNull(recordVersion11); - - assertTrue(relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - - Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, from11.size()); - - // verify 1.0 - Version version10 = versionHistory.getVersion("1.0"); - assertNotNull(version10); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - assertNotNull(recordVersion10); - - Set to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS); - assertEquals(1, to10.size()); - assertEquals(recordVersion11, to10.iterator().next().getSource()); - - assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); - } - }); - } - - /** - * Given that a version record - * When the version record is destroyed whilst retaining the meta data - * Then the version is marked as destroyed in the collab version history - */ - public void testDestroyVersionRecordWithMetadata() - { - final NodeRef myDocument = createDocumentWithRecordVersions(); - - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private VersionHistory versionHistory; - private NodeRef recordVersion11; - - public void given() throws Exception - { - // create file plan structure - NodeRef myCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createBasicDispositionSchedule(myCategory, GUID.generate(), GUID.generate(), true, true); - - NodeRef myRecordFolder = recordFolderService.createRecordFolder(myCategory, GUID.generate()); - - // get version history - versionHistory = versionService.getVersionHistory(myDocument); - - // file and complete all the version records into my record folder - for (Version version : versionHistory.getAllVersions()) - { - NodeRef record = recordableVersionService.getVersionRecord(version); - fileFolderService.move(record, myRecordFolder, null); - utils.completeRecord(record); - } - } - - public void when() - { - Version version11 = versionHistory.getVersion("1.1"); - recordVersion11 = recordableVersionService.getVersionRecord(version11); - - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordVersion11, CompleteEventAction.NAME, params); - - rmActionService.executeRecordsManagementAction(recordVersion11, CutOffAction.NAME); - - rmActionService.executeRecordsManagementAction(recordVersion11, DestroyAction.NAME); - } - - public void then() - { - // verify that the version history looks as expected - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - Collection versions = versionHistory.getAllVersions(); - assertEquals(3, versions.size()); - - // verify 1.2 setup as expected - Version version12 = versionHistory.getHeadVersion(); - assertEquals("1.2", version12.getVersionLabel()); - assertFalse(recordableVersionService.isRecordedVersionDestroyed(version12)); - NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); - assertNotNull(recordVersion12); - assertFalse(recordService.isMetadataStub(recordVersion12)); - - assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty()); - - Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions"); - assertEquals(1, from12.size()); - - // verify 1.1 setup as expected - Version version11 = versionHistory.getPredecessor(version12); - assertEquals("1.1", version11.getVersionLabel()); - assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11)); - assertNotNull(recordVersion11); - assertTrue(recordService.isMetadataStub(recordVersion11)); - - Set to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions"); - assertEquals(1, to11.size()); - assertEquals(recordVersion12, to11.iterator().next().getSource()); - - Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions"); - assertEquals(1, from11.size()); - - // verify 1.0 setup as expected - Version version10 = versionHistory.getPredecessor(version11); - assertEquals("1.0", version10.getVersionLabel()); - assertFalse(recordableVersionService.isRecordedVersionDestroyed(version10)); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - assertNotNull(recordVersion10); - assertFalse(recordService.isMetadataStub(recordVersion10)); - - Set to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions"); - assertEquals(1, to10.size()); - assertEquals(recordVersion11, to10.iterator().next().getSource()); - - assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty()); - - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + + +/** + * Recordable version history integration tests. + * + * @author Roy Wetherall + * @since 2.3.1 + */ +public class DeleteRecordVersionTest extends RecordableVersionsBaseTest +{ + /** + * Given that a document is created + * And the initial version is record + * When I delete the version record + * Then the version is deleted + * And the version history is not deleted + * + * @see https://issues.alfresco.com/jira/browse/RM-2562 + */ + public void testDeleteFirstRecordedVersion() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef myDocument; + + public void given() throws Exception + { + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + // make versionable + Map props = new HashMap(2); + props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); + nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props); + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); + } + + public void when() + { + // check the initial version label + assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); + + // check that the version history contains a single version that is recorded + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + assertEquals(1, versionHistory.getAllVersions().size()); + + // check the recorded version is not marked as destroyed + Version head = versionHistory.getHeadVersion(); + assertNotNull(head); + assertFalse(recordableVersionService.isRecordedVersionDestroyed(head)); + + // check the version record + NodeRef record = recordableVersionService.getVersionRecord(head); + assertTrue(recordService.isRecord(record)); + + // record should not have a version history because it is immutable + assertFalse(nodeService.hasAspect(record, ContentModel.ASPECT_VERSIONABLE)); + VersionHistory recordVersionHistory = versionService.getVersionHistory(record); + assertNull(recordVersionHistory); + + // destroy record + nodeService.deleteNode(record); + } + + public void then() + { + // document is still versionable + assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE)); + + // check the initial version label + assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); + + // still has a version history, but the version is marked as destroyed + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + assertEquals(1, versionHistory.getAllVersions().size()); + + // check the recorded version is marked as destroyed and the record version is not longer available + Version version = versionHistory.getHeadVersion(); + assertNotNull(version); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(version)); + assertNull(recordableVersionService.getVersionRecord(version)); + } + }); + } + + /** + * Given that a document is created + * And the initial version is record + * And the associated version record is deleted + * When a new version is created + * Then a new associated version record is created + * And the version is 1.1 (not 1.0 since this was deleted, but the version history maintained) + * + * @see https://issues.alfresco.com/jira/browse/RM-2562 + */ + public void testDeleteFirstRecordedVersionAndCreateNewVersion() + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef myDocument; + + public void given() throws Exception + { + // create a document + myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + ContentWriter writer = fileFolderService.getWriter(myDocument); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent(GUID.generate()); + + // make versionable + Map props = new HashMap(2); + props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); + nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props); + nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null); + } + + public void when() + { + // get the created version record + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + Version head = versionHistory.getHeadVersion(); + NodeRef record = recordableVersionService.getVersionRecord(head); + + // destroy record + nodeService.deleteNode(record); + + // update the content to create a new version (and version record) + ContentWriter writer = fileFolderService.getWriter(myDocument); + writer.putContent(GUID.generate()); + } + + public void then() + { + // document is still versionable + assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE)); + + // check the version number has been incremented + assertEquals("1.1", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL)); + + // still has a version history, with 2 enties + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + assertEquals(2, versionHistory.getAllVersions().size()); + + // latest version is current + Version head = versionHistory.getHeadVersion(); + assertFalse(recordableVersionService.isRecordedVersionDestroyed(head)); + assertNotNull(recordableVersionService.getVersionRecord(head)); + + // first version is destroyed + Version destroyed = versionHistory.getPredecessor(head); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(destroyed)); + assertNull(recordableVersionService.getVersionRecord(destroyed)); + + // get the version record for the current version + NodeRef versionRecord = recordableVersionService.getVersionRecord(head); + assertNotNull(versionRecord); + assertTrue(nodeService.exists(versionRecord)); + + Set from = relationshipService.getRelationshipsFrom(versionRecord); + assertTrue(from.isEmpty()); + + Set to = relationshipService.getRelationshipsTo(versionRecord); + assertTrue(to.isEmpty()); + } + }); + } + + /** + * Given a chain of version records (1.0, 1.1, 1.2) which are all related + * When I delete version record 1.0 + * Then 1.1 is the oldest version + */ + public void testDeleteOldestVersion() + { + final NodeRef myDocument = createDocumentWithRecordVersions(); + + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private VersionHistory versionHistory; + + public void given() throws Exception + { + // get version history + versionHistory = versionService.getVersionHistory(myDocument); + } + + public void when() + { + Version version10 = versionHistory.getVersion("1.0"); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + + // delete record version 1.0 + nodeService.deleteNode(recordVersion10); + } + + public void then() + { + // check the deleted version + Version version10 = versionHistory.getVersion("1.0"); + assertNotNull(version10); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(version10)); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + assertNull(recordVersion10); + + // verify 1.2 setup as expected + Version version12 = versionHistory.getHeadVersion(); + assertEquals("1.2", version12.getVersionLabel()); + NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); + assertNotNull(recordVersion12); + + assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + + Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, from12.size()); + + // verify 1.1 setup as expected + Version version11 = versionHistory.getPredecessor(version12); + assertEquals("1.1", version11.getVersionLabel()); + NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); + assertNotNull(recordVersion11); + + Set to11 = relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, to11.size()); + assertEquals(recordVersion12, to11.iterator().next().getSource()); + + assertTrue(relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + } + }); + } + + /** + * Given a chain of version records (1.0, 1.1, 1.2) which are all related + * When I delete version record 1.1 + * Then 1.2 now 'versions' 1.0 + */ + public void testDeleteMiddleVersion() + { + final NodeRef myDocument = createDocumentWithRecordVersions(); + + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private VersionHistory versionHistory; + + public void given() throws Exception + { + // get version history + versionHistory = versionService.getVersionHistory(myDocument); + } + + public void when() + { + Version version11 = versionHistory.getVersion("1.1"); + NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); + + // delete record version 1.1 + nodeService.deleteNode(recordVersion11); + } + + public void then() + { + // check the deleted version + Version version11 = versionHistory.getVersion("1.1"); + assertNotNull(version11); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11)); + NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); + assertNull(recordVersion11); + + // verify 1.2 setup as expected + Version version12 = versionHistory.getHeadVersion(); + assertEquals("1.2", version12.getVersionLabel()); + NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); + assertNotNull(recordVersion12); + + assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + + Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, from12.size()); + + // verify 1.0 setup as expected + Version version10 = versionHistory.getVersion("1.0"); + assertEquals("1.0", version10.getVersionLabel()); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + assertNotNull(recordVersion10); + + Set to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, to10.size()); + assertEquals(recordVersion12, to10.iterator().next().getSource()); + + assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + + } + }); + } + + /** + * Given a chain of version records (1.0, 1.1, 1.2) which are all related + * When I delete version record 1.2 + * Then 1.1 is the most recent version + */ + public void testDeleteCurrentVersion() + { + final NodeRef myDocument = createDocumentWithRecordVersions(); + + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private VersionHistory versionHistory; + + public void given() throws Exception + { + // get version history + versionHistory = versionService.getVersionHistory(myDocument); + } + + public void when() + { + Version version12 = versionHistory.getVersion("1.2"); + NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); + + // delete record version 1.2 + nodeService.deleteNode(recordVersion12); + } + + public void then() + { + // check 1.2 + Version version12 = versionHistory.getVersion("1.2"); + assertNotNull(version12); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(version12)); + assertNull(recordableVersionService.getVersionRecord(version12)); + + // verify 1.1 + Version version11 = versionHistory.getVersion("1.1"); + assertNotNull(version11); + NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); + assertNotNull(recordVersion11); + + assertTrue(relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + + Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, from11.size()); + + // verify 1.0 + Version version10 = versionHistory.getVersion("1.0"); + assertNotNull(version10); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + assertNotNull(recordVersion10); + + Set to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS); + assertEquals(1, to10.size()); + assertEquals(recordVersion11, to10.iterator().next().getSource()); + + assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty()); + } + }); + } + + /** + * Given that a version record + * When the version record is destroyed whilst retaining the meta data + * Then the version is marked as destroyed in the collab version history + */ + public void testDestroyVersionRecordWithMetadata() + { + final NodeRef myDocument = createDocumentWithRecordVersions(); + + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private VersionHistory versionHistory; + private NodeRef recordVersion11; + + public void given() throws Exception + { + // create file plan structure + NodeRef myCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createBasicDispositionSchedule(myCategory, GUID.generate(), GUID.generate(), true, true); + + NodeRef myRecordFolder = recordFolderService.createRecordFolder(myCategory, GUID.generate()); + + // get version history + versionHistory = versionService.getVersionHistory(myDocument); + + // file and complete all the version records into my record folder + for (Version version : versionHistory.getAllVersions()) + { + NodeRef record = recordableVersionService.getVersionRecord(version); + fileFolderService.move(record, myRecordFolder, null); + utils.completeRecord(record); + } + } + + public void when() + { + Version version11 = versionHistory.getVersion("1.1"); + recordVersion11 = recordableVersionService.getVersionRecord(version11); + + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordVersion11, CompleteEventAction.NAME, params); + + rmActionService.executeRecordsManagementAction(recordVersion11, CutOffAction.NAME); + + rmActionService.executeRecordsManagementAction(recordVersion11, DestroyAction.NAME); + } + + public void then() + { + // verify that the version history looks as expected + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + Collection versions = versionHistory.getAllVersions(); + assertEquals(3, versions.size()); + + // verify 1.2 setup as expected + Version version12 = versionHistory.getHeadVersion(); + assertEquals("1.2", version12.getVersionLabel()); + assertFalse(recordableVersionService.isRecordedVersionDestroyed(version12)); + NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); + assertNotNull(recordVersion12); + assertFalse(recordService.isMetadataStub(recordVersion12)); + + assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty()); + + Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions"); + assertEquals(1, from12.size()); + + // verify 1.1 setup as expected + Version version11 = versionHistory.getPredecessor(version12); + assertEquals("1.1", version11.getVersionLabel()); + assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11)); + assertNotNull(recordVersion11); + assertTrue(recordService.isMetadataStub(recordVersion11)); + + Set to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions"); + assertEquals(1, to11.size()); + assertEquals(recordVersion12, to11.iterator().next().getSource()); + + Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions"); + assertEquals(1, from11.size()); + + // verify 1.0 setup as expected + Version version10 = versionHistory.getPredecessor(version11); + assertEquals("1.0", version10.getVersionLabel()); + assertFalse(recordableVersionService.isRecordedVersionDestroyed(version10)); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + assertNotNull(recordVersion10); + assertFalse(recordService.isMetadataStub(recordVersion10)); + + Set to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions"); + assertEquals(1, to10.size()); + assertEquals(recordVersion11, to10.iterator().next().getSource()); + + assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty()); + + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/RecordableVersionsBaseTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/RecordableVersionsBaseTest.java index 32f1269bf3..ebf4fcd473 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/RecordableVersionsBaseTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/RecordableVersionsBaseTest.java @@ -1,402 +1,402 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; - -/** - * Recordable versions base integration test - * - * @author Roy Wetherall - * @since 2.3 - */ -public abstract class RecordableVersionsBaseTest extends BaseRMTestCase implements RecordableVersionModel -{ - protected static final QName QNAME_PUBLISHER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "publisher"); - protected static final QName QNAME_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subject"); - - protected static final String DESCRIPTION = "description"; - protected static final String PUBLISHER = "publisher"; - protected static final String SUBJECT = "subject"; - protected static final String OWNER = "GracieWetherall"; - - protected static final String CONTENT = - "Simple + Smart. A smarter way to build, a smarter way to deploy. Its simple because we focus on the end " - + "user and smart because we support more open standards than any other ECM platform, while delivering all " - + "the value a traditional platform provides."; - - protected RecordableVersionService recordableVersionService; - - @Override - protected void initServices() - { - super.initServices(); - recordableVersionService = (RecordableVersionService)applicationContext.getBean("RecordableVersionService"); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupCollaborationSiteTestDataImpl() - */ - @Override - protected void setupCollaborationSiteTestDataImpl() - { - super.setupCollaborationSiteTestDataImpl(); - - // create authentication for owner - createPerson(OWNER); - - // prepare content - prepareContent(dmDocument); - } - - protected void prepareContent(NodeRef content) - { - // add titled aspect - PropertyMap titledProperties = new PropertyMap(2); - titledProperties.put(ContentModel.PROP_TITLE, "document title"); - titledProperties.put(ContentModel.PROP_DESCRIPTION, "document description"); - nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProperties); - - // add ownable aspect - PropertyMap ownableProperties = new PropertyMap(1); - ownableProperties.put(ContentModel.PROP_OWNER, OWNER); - nodeService.addAspect(content, ContentModel.ASPECT_OWNABLE, ownableProperties); - - // add Dublin core aspect - PropertyMap dublinCoreProperties = new PropertyMap(2); - dublinCoreProperties.put(QNAME_PUBLISHER, PUBLISHER); - dublinCoreProperties.put(QNAME_SUBJECT, SUBJECT); - nodeService.addAspect(content, ContentModel.ASPECT_DUBLINCORE, dublinCoreProperties); - - // add content - ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(CONTENT); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() - */ - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - - // remove owner - personService.deletePerson(OWNER); - } - - /** - * Helper to check that the current version is recorded - */ - protected void checkRecordedVersion(NodeRef document, String description, String versionLabel) - { - // double check that the document is not a record - assertFalse(recordService.isRecord(document)); - - // store document state - Map beforeProperties = nodeService.getProperties(document); - Set beforeAspects = nodeService.getAspects(document); - - // get the current version - Version version = versionService.getCurrentVersion(document); - - // version has been created - assertNotNull(version); - - // check the version properties - assertEquals(description, version.getDescription()); - assertEquals(versionLabel, version.getVersionLabel()); - - // get the frozen state - NodeRef frozen = version.getFrozenStateNodeRef(); - - // check the properties - checkProperties(frozen, beforeProperties); - - // compare aspects - checkAspects(frozen, beforeAspects); - - // record version node reference is available on version - NodeRef record = recordableVersionService.getVersionRecord(version); - assertNotNull(record); - - // check that the version record information has been added - assertTrue(nodeService.hasAspect(record, ASPECT_VERSION_RECORD)); - assertEquals(versionLabel, nodeService.getProperty(record, RecordableVersionModel.PROP_VERSION_LABEL)); - assertEquals(description, nodeService.getProperty(record, RecordableVersionModel.PROP_VERSION_DESCRIPTION)); - - // record version is an unfiled record - assertTrue(recordService.isRecord(record)); - assertFalse(recordService.isFiled(record)); - - // check that the created record does not have either of the versionable aspects - assertFalse(nodeService.hasAspect(record, RecordableVersionModel.ASPECT_VERSIONABLE)); - - // check the version history - VersionHistory versionHistory = versionService.getVersionHistory(document); - assertNotNull(versionHistory); - Version headVersion = versionHistory.getHeadVersion(); - assertNotNull(headVersion); - } - - /** - * Helper method to check that the current version is not recorded - */ - protected void checkNotRecordedAspect(NodeRef document, String description, String versionLabel) - { - // double check that the document is not a record - assertFalse(recordService.isRecord(document)); - - // get the current version - Version version = versionService.getCurrentVersion(document); - - // version has been created - assertNotNull(version); - - // check the version properties - assertEquals(description, version.getDescription()); - assertEquals(versionLabel, version.getVersionLabel()); - - // record version node reference is available on version - NodeRef record = recordableVersionService.getVersionRecord(version); - assertNull(record); - - // check the version history - VersionHistory versionHistory = versionService.getVersionHistory(document); - assertNotNull(versionHistory); - Version headVersion = versionHistory.getHeadVersion(); - assertNotNull(headVersion); - } - - /** - * Helper to check the properties of a recorded version - */ - protected void checkProperties(NodeRef frozen, Map beforeProperies) - { - Map frozenProperties = nodeService.getProperties(frozen); - Map cloneFrozenProperties = new HashMap(frozenProperties); - for (Map.Entry entry : beforeProperies.entrySet()) - { - QName beforePropertyName = entry.getKey(); - if (frozenProperties.containsKey(beforePropertyName)) - { - Serializable frozenValue = frozenProperties.get(beforePropertyName); - assertEquals("Frozen property " + beforePropertyName.getLocalName() + " value is incorrect.", entry.getValue(), frozenValue); - cloneFrozenProperties.remove(beforePropertyName); - } - else if (!PROP_FILE_PLAN.equals(beforePropertyName) && - !PROP_RECORDABLE_VERSION_POLICY.equals(beforePropertyName) && - !ContentModel.PROP_AUTO_VERSION_PROPS.equals(beforePropertyName) && - !ContentModel.PROP_AUTO_VERSION.equals(beforePropertyName) && - !ContentModel.PROP_INITIAL_VERSION.equals(beforePropertyName)) - { - fail("Property missing from frozen state .. " + beforePropertyName); - } - } - - // filter out missing properties with null values - for (Map.Entry entry : frozenProperties.entrySet()) - { - if (entry.getValue() == null) - { - cloneFrozenProperties.remove(entry.getKey()); - } - } - - // remove "owner" from cloneFrozenProperties - cloneFrozenProperties.remove(ContentModel.PROP_OWNER); - - - // frozen properties should be empty - assertTrue("Properties in frozen state, but not in origional. " + cloneFrozenProperties.keySet(), cloneFrozenProperties.isEmpty()); - } - - /** - * Helper to check the aspects of a recorded version - */ - protected void checkAspects(NodeRef frozen, Set beforeAspects) - { - Set cloneBeforeAspects = new HashSet(beforeAspects); - - // compare origional and frozen aspects - Set frozenAspects = nodeService.getAspects(frozen); - cloneBeforeAspects.removeAll(frozenAspects); - cloneBeforeAspects.remove(RecordableVersionModel.ASPECT_VERSIONABLE); - cloneBeforeAspects.remove(ContentModel.ASPECT_VERSIONABLE); - if (!cloneBeforeAspects.isEmpty()) - { - fail("Aspects not present in frozen state. " + cloneBeforeAspects.toString()); - } - - frozenAspects.removeAll(beforeAspects); - if (!frozenAspects.isEmpty()) - { - fail("Aspects in the frozen state, but not in origional. " + frozenAspects.toString()); - } - } - - /** - * Creates a document with three versions (1.0, 1.1, 1.2) all of which - * are recorded. - * - * @return NodeRef node reference - */ - protected NodeRef createDocumentWithRecordVersions() - { - // create document and initial version (1.0) - final NodeRef myDocument = doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - // create a document - NodeRef testDoc = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - ContentWriter writer = fileFolderService.getWriter(testDoc); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(GUID.generate()); - - // make versionable - Map props = new HashMap(2); - props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); - props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); - nodeService.addAspect(testDoc, RecordableVersionModel.ASPECT_VERSIONABLE, props); - nodeService.addAspect(testDoc, ContentModel.ASPECT_VERSIONABLE, null); - - return testDoc; - } - }); - - // create 1.1 - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // update content - ContentWriter writer = fileFolderService.getWriter(myDocument); - writer.putContent(GUID.generate()); - - return null; - } - }); - - // create 1.2 - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // update content - ContentWriter writer = fileFolderService.getWriter(myDocument); - writer.putContent(GUID.generate()); - - return null; - } - }); - - // we do these checks to ensure that the test data is in the correct state before we - // start to manipulate the versions and execute tests - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // verify that the version history looks as expected - VersionHistory versionHistory = versionService.getVersionHistory(myDocument); - assertNotNull(versionHistory); - Collection versions = versionHistory.getAllVersions(); - assertEquals(3, versions.size()); - - // verify 1.2 setup as expected - Version version12 = versionHistory.getHeadVersion(); - assertEquals("1.2", version12.getVersionLabel()); - NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); - assertNotNull(recordVersion12); - - assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty()); - - Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions"); - assertEquals(1, from12.size()); - - // verify 1.1 setup as expected - Version version11 = versionHistory.getPredecessor(version12); - assertEquals("1.1", version11.getVersionLabel()); - NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); - assertNotNull(recordVersion11); - - Set to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions"); - assertEquals(1, to11.size()); - assertEquals(recordVersion12, to11.iterator().next().getSource()); - - Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions"); - assertEquals(1, from11.size()); - - // verify 1.0 setup as expected - Version version10 = versionHistory.getPredecessor(version11); - assertEquals("1.0", version10.getVersionLabel()); - NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); - assertNotNull(recordVersion10); - - Set to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions"); - assertEquals(1, to10.size()); - assertEquals(recordVersion11, to10.iterator().next().getSource()); - - assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty()); - - return null; - } - }); - - return myDocument; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; +import org.alfresco.util.PropertyMap; + +/** + * Recordable versions base integration test + * + * @author Roy Wetherall + * @since 2.3 + */ +public abstract class RecordableVersionsBaseTest extends BaseRMTestCase implements RecordableVersionModel +{ + protected static final QName QNAME_PUBLISHER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "publisher"); + protected static final QName QNAME_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subject"); + + protected static final String DESCRIPTION = "description"; + protected static final String PUBLISHER = "publisher"; + protected static final String SUBJECT = "subject"; + protected static final String OWNER = "GracieWetherall"; + + protected static final String CONTENT = + "Simple + Smart. A smarter way to build, a smarter way to deploy. Its simple because we focus on the end " + + "user and smart because we support more open standards than any other ECM platform, while delivering all " + + "the value a traditional platform provides."; + + protected RecordableVersionService recordableVersionService; + + @Override + protected void initServices() + { + super.initServices(); + recordableVersionService = (RecordableVersionService)applicationContext.getBean("RecordableVersionService"); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupCollaborationSiteTestDataImpl() + */ + @Override + protected void setupCollaborationSiteTestDataImpl() + { + super.setupCollaborationSiteTestDataImpl(); + + // create authentication for owner + createPerson(OWNER); + + // prepare content + prepareContent(dmDocument); + } + + protected void prepareContent(NodeRef content) + { + // add titled aspect + PropertyMap titledProperties = new PropertyMap(2); + titledProperties.put(ContentModel.PROP_TITLE, "document title"); + titledProperties.put(ContentModel.PROP_DESCRIPTION, "document description"); + nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProperties); + + // add ownable aspect + PropertyMap ownableProperties = new PropertyMap(1); + ownableProperties.put(ContentModel.PROP_OWNER, OWNER); + nodeService.addAspect(content, ContentModel.ASPECT_OWNABLE, ownableProperties); + + // add Dublin core aspect + PropertyMap dublinCoreProperties = new PropertyMap(2); + dublinCoreProperties.put(QNAME_PUBLISHER, PUBLISHER); + dublinCoreProperties.put(QNAME_SUBJECT, SUBJECT); + nodeService.addAspect(content, ContentModel.ASPECT_DUBLINCORE, dublinCoreProperties); + + // add content + ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent(CONTENT); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() + */ + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + // remove owner + personService.deletePerson(OWNER); + } + + /** + * Helper to check that the current version is recorded + */ + protected void checkRecordedVersion(NodeRef document, String description, String versionLabel) + { + // double check that the document is not a record + assertFalse(recordService.isRecord(document)); + + // store document state + Map beforeProperties = nodeService.getProperties(document); + Set beforeAspects = nodeService.getAspects(document); + + // get the current version + Version version = versionService.getCurrentVersion(document); + + // version has been created + assertNotNull(version); + + // check the version properties + assertEquals(description, version.getDescription()); + assertEquals(versionLabel, version.getVersionLabel()); + + // get the frozen state + NodeRef frozen = version.getFrozenStateNodeRef(); + + // check the properties + checkProperties(frozen, beforeProperties); + + // compare aspects + checkAspects(frozen, beforeAspects); + + // record version node reference is available on version + NodeRef record = recordableVersionService.getVersionRecord(version); + assertNotNull(record); + + // check that the version record information has been added + assertTrue(nodeService.hasAspect(record, ASPECT_VERSION_RECORD)); + assertEquals(versionLabel, nodeService.getProperty(record, RecordableVersionModel.PROP_VERSION_LABEL)); + assertEquals(description, nodeService.getProperty(record, RecordableVersionModel.PROP_VERSION_DESCRIPTION)); + + // record version is an unfiled record + assertTrue(recordService.isRecord(record)); + assertFalse(recordService.isFiled(record)); + + // check that the created record does not have either of the versionable aspects + assertFalse(nodeService.hasAspect(record, RecordableVersionModel.ASPECT_VERSIONABLE)); + + // check the version history + VersionHistory versionHistory = versionService.getVersionHistory(document); + assertNotNull(versionHistory); + Version headVersion = versionHistory.getHeadVersion(); + assertNotNull(headVersion); + } + + /** + * Helper method to check that the current version is not recorded + */ + protected void checkNotRecordedAspect(NodeRef document, String description, String versionLabel) + { + // double check that the document is not a record + assertFalse(recordService.isRecord(document)); + + // get the current version + Version version = versionService.getCurrentVersion(document); + + // version has been created + assertNotNull(version); + + // check the version properties + assertEquals(description, version.getDescription()); + assertEquals(versionLabel, version.getVersionLabel()); + + // record version node reference is available on version + NodeRef record = recordableVersionService.getVersionRecord(version); + assertNull(record); + + // check the version history + VersionHistory versionHistory = versionService.getVersionHistory(document); + assertNotNull(versionHistory); + Version headVersion = versionHistory.getHeadVersion(); + assertNotNull(headVersion); + } + + /** + * Helper to check the properties of a recorded version + */ + protected void checkProperties(NodeRef frozen, Map beforeProperies) + { + Map frozenProperties = nodeService.getProperties(frozen); + Map cloneFrozenProperties = new HashMap(frozenProperties); + for (Map.Entry entry : beforeProperies.entrySet()) + { + QName beforePropertyName = entry.getKey(); + if (frozenProperties.containsKey(beforePropertyName)) + { + Serializable frozenValue = frozenProperties.get(beforePropertyName); + assertEquals("Frozen property " + beforePropertyName.getLocalName() + " value is incorrect.", entry.getValue(), frozenValue); + cloneFrozenProperties.remove(beforePropertyName); + } + else if (!PROP_FILE_PLAN.equals(beforePropertyName) && + !PROP_RECORDABLE_VERSION_POLICY.equals(beforePropertyName) && + !ContentModel.PROP_AUTO_VERSION_PROPS.equals(beforePropertyName) && + !ContentModel.PROP_AUTO_VERSION.equals(beforePropertyName) && + !ContentModel.PROP_INITIAL_VERSION.equals(beforePropertyName)) + { + fail("Property missing from frozen state .. " + beforePropertyName); + } + } + + // filter out missing properties with null values + for (Map.Entry entry : frozenProperties.entrySet()) + { + if (entry.getValue() == null) + { + cloneFrozenProperties.remove(entry.getKey()); + } + } + + // remove "owner" from cloneFrozenProperties + cloneFrozenProperties.remove(ContentModel.PROP_OWNER); + + + // frozen properties should be empty + assertTrue("Properties in frozen state, but not in origional. " + cloneFrozenProperties.keySet(), cloneFrozenProperties.isEmpty()); + } + + /** + * Helper to check the aspects of a recorded version + */ + protected void checkAspects(NodeRef frozen, Set beforeAspects) + { + Set cloneBeforeAspects = new HashSet(beforeAspects); + + // compare origional and frozen aspects + Set frozenAspects = nodeService.getAspects(frozen); + cloneBeforeAspects.removeAll(frozenAspects); + cloneBeforeAspects.remove(RecordableVersionModel.ASPECT_VERSIONABLE); + cloneBeforeAspects.remove(ContentModel.ASPECT_VERSIONABLE); + if (!cloneBeforeAspects.isEmpty()) + { + fail("Aspects not present in frozen state. " + cloneBeforeAspects.toString()); + } + + frozenAspects.removeAll(beforeAspects); + if (!frozenAspects.isEmpty()) + { + fail("Aspects in the frozen state, but not in origional. " + frozenAspects.toString()); + } + } + + /** + * Creates a document with three versions (1.0, 1.1, 1.2) all of which + * are recorded. + * + * @return NodeRef node reference + */ + protected NodeRef createDocumentWithRecordVersions() + { + // create document and initial version (1.0) + final NodeRef myDocument = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + // create a document + NodeRef testDoc = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + ContentWriter writer = fileFolderService.getWriter(testDoc); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent(GUID.generate()); + + // make versionable + Map props = new HashMap(2); + props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL); + props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan); + nodeService.addAspect(testDoc, RecordableVersionModel.ASPECT_VERSIONABLE, props); + nodeService.addAspect(testDoc, ContentModel.ASPECT_VERSIONABLE, null); + + return testDoc; + } + }); + + // create 1.1 + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // update content + ContentWriter writer = fileFolderService.getWriter(myDocument); + writer.putContent(GUID.generate()); + + return null; + } + }); + + // create 1.2 + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // update content + ContentWriter writer = fileFolderService.getWriter(myDocument); + writer.putContent(GUID.generate()); + + return null; + } + }); + + // we do these checks to ensure that the test data is in the correct state before we + // start to manipulate the versions and execute tests + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // verify that the version history looks as expected + VersionHistory versionHistory = versionService.getVersionHistory(myDocument); + assertNotNull(versionHistory); + Collection versions = versionHistory.getAllVersions(); + assertEquals(3, versions.size()); + + // verify 1.2 setup as expected + Version version12 = versionHistory.getHeadVersion(); + assertEquals("1.2", version12.getVersionLabel()); + NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12); + assertNotNull(recordVersion12); + + assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty()); + + Set from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions"); + assertEquals(1, from12.size()); + + // verify 1.1 setup as expected + Version version11 = versionHistory.getPredecessor(version12); + assertEquals("1.1", version11.getVersionLabel()); + NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11); + assertNotNull(recordVersion11); + + Set to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions"); + assertEquals(1, to11.size()); + assertEquals(recordVersion12, to11.iterator().next().getSource()); + + Set from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions"); + assertEquals(1, from11.size()); + + // verify 1.0 setup as expected + Version version10 = versionHistory.getPredecessor(version11); + assertEquals("1.0", version10.getVersionLabel()); + NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10); + assertNotNull(recordVersion10); + + Set to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions"); + assertEquals(1, to10.size()); + assertEquals(recordVersion11, to10.iterator().next().getSource()); + + assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty()); + + return null; + } + }); + + return myDocument; + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/VersionTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/VersionTestSuite.java index 4cf00fec8a..2b00aa0e03 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/VersionTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/VersionTestSuite.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.version; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Recordable Version Test Suite - * - * @author Roy Wetherall - * @since 2.3 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - AdHocRecordableVersionsTest.class, - AutoRecordableVersionsTest.class, - DeclareAsRecordVersionTest.class, - AutoVersionTest.class, - DeleteRecordVersionTest.class -}) -public class VersionTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.version; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Recordable Version Test Suite + * + * @author Roy Wetherall + * @since 2.3 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + AdHocRecordableVersionsTest.class, + AutoRecordableVersionsTest.class, + DeclareAsRecordVersionTest.class, + AutoVersionTest.class, + DeleteRecordVersionTest.class +}) +public class VersionTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/LegacyTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/LegacyTestSuite.java index f3157d9ffa..8406de049f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/LegacyTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/LegacyTestSuite.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy; - -import org.alfresco.module.org_alfresco_module_rm.test.legacy.action.ActionTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities.CapabilitiesTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript.JScriptTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.legacy.security.SecurityTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.legacy.service.ServicesTestSuite; -import org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript.WebScriptTestSuite; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * Convenience test suite that runs all the tests. - * - * @author Roy Wetherall - * @since 2.1 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - ActionTestSuite.class, - CapabilitiesTestSuite.class, - ServicesTestSuite.class, - WebScriptTestSuite.class, - JScriptTestSuite.class, - SecurityTestSuite.class -}) -public class LegacyTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy; + +import org.alfresco.module.org_alfresco_module_rm.test.legacy.action.ActionTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities.CapabilitiesTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript.JScriptTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.legacy.security.SecurityTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.legacy.service.ServicesTestSuite; +import org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript.WebScriptTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * Convenience test suite that runs all the tests. + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + ActionTestSuite.class, + CapabilitiesTestSuite.class, + ServicesTestSuite.class, + WebScriptTestSuite.class, + JScriptTestSuite.class, + SecurityTestSuite.class +}) +public class LegacyTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/ActionTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/ActionTestSuite.java index 47b44bcab7..c3272dcf50 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/ActionTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/ActionTestSuite.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * RM test suite - * - * @author Roy Wetherall - * @since 2.1 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - CreateRecordActionTest.class, - HideRecordActionTest.class, - RejectActionTest.class, - FileToActionTest.class, - FileReportActionTest.class, - RecordableVersionConfigActionTest.class -}) -public class ActionTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * RM test suite + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + CreateRecordActionTest.class, + HideRecordActionTest.class, + RejectActionTest.class, + FileToActionTest.class, + FileReportActionTest.class, + RecordableVersionConfigActionTest.class +}) +public class ActionTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/CreateRecordActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/CreateRecordActionTest.java index cde723fbc6..79e5c87e70 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/CreateRecordActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/CreateRecordActionTest.java @@ -1,73 +1,73 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Record service implementation unit test. - * - * @author Roy Wetherall - */ -public class CreateRecordActionTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testCreateRecordAction() - { - doTestInTransaction(new Test() - { - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); - - Action action = actionService.createAction(CreateRecordAction.NAME); - action.setParameterValue(CreateRecordAction.PARAM_HIDE_RECORD, false); - action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - actionService.executeAction(action, dmDocument); - - return null; - } - - public void test(Void result) throws Exception - { - assertTrue(recordService.isRecord(dmDocument)); - - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); - }; - }, - dmCollaborator); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Record service implementation unit test. + * + * @author Roy Wetherall + */ +public class CreateRecordActionTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + public void testCreateRecordAction() + { + doTestInTransaction(new Test() + { + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); + + Action action = actionService.createAction(CreateRecordAction.NAME); + action.setParameterValue(CreateRecordAction.PARAM_HIDE_RECORD, false); + action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + actionService.executeAction(action, dmDocument); + + return null; + } + + public void test(Void result) throws Exception + { + assertTrue(recordService.isRecord(dmDocument)); + + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); + }; + }, + dmCollaborator); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java index 0a0573aae7..58016d0961 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java @@ -1,107 +1,107 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.alfresco.module.org_alfresco_module_rm.action.impl.FileReportAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.webscripts.GUID; - -/** - * File report action unit test - * - * @author Tuna Aksoy - * @since 2.2 - * @version 1.0 - */ -public class FileReportActionTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - public void testFileReport() - { - fileReport(MimetypeMap.MIMETYPE_HTML); - } - - public void testfileReportDefaultMimetype() - { - fileReport(null); - } - - private void fileReport(final String mimeType) - { - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - - // create record folder - final NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); - - // close the record folder - recordFolderService.closeRecordFolder(recordFolder); - - // create hold - final NodeRef hold = holdService.createHold(filePlan, "holdName", "holdReason", "holdDescription"); - - doTestInTransaction(new FailureTest() - { - @Override - public void run() throws Exception - { - // execute action - executeAction(mimeType, recordFolder, hold); - } - }); - - doTestInTransaction(new Test() - { - public Void run() - { - // reopen the record folder - rmActionService.executeRecordsManagementAction(recordFolder, "openRecordFolder"); - return null; - } - - @Override - public void test(Void result) throws Exception - { - // execute action - executeAction(mimeType, recordFolder, hold); - } - }); - } - - private void executeAction(String mimeType, NodeRef recordFolder, NodeRef hold) - { - Action action = actionService.createAction(FileReportAction.NAME); - if (StringUtils.isNotBlank(mimeType)) - { - action.setParameterValue(FileReportAction.MIMETYPE, mimeType); - } - action.setParameterValue(FileReportAction.DESTINATION, recordFolder.toString()); - action.setParameterValue(FileReportAction.REPORT_TYPE, "rmr:destructionReport"); - actionService.executeAction(action, hold); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileReportAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.webscripts.GUID; + +/** + * File report action unit test + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class FileReportActionTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + public void testFileReport() + { + fileReport(MimetypeMap.MIMETYPE_HTML); + } + + public void testfileReportDefaultMimetype() + { + fileReport(null); + } + + private void fileReport(final String mimeType) + { + AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); + + // create record folder + final NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate()); + + // close the record folder + recordFolderService.closeRecordFolder(recordFolder); + + // create hold + final NodeRef hold = holdService.createHold(filePlan, "holdName", "holdReason", "holdDescription"); + + doTestInTransaction(new FailureTest() + { + @Override + public void run() throws Exception + { + // execute action + executeAction(mimeType, recordFolder, hold); + } + }); + + doTestInTransaction(new Test() + { + public Void run() + { + // reopen the record folder + rmActionService.executeRecordsManagementAction(recordFolder, "openRecordFolder"); + return null; + } + + @Override + public void test(Void result) throws Exception + { + // execute action + executeAction(mimeType, recordFolder, hold); + } + }); + } + + private void executeAction(String mimeType, NodeRef recordFolder, NodeRef hold) + { + Action action = actionService.createAction(FileReportAction.NAME); + if (StringUtils.isNotBlank(mimeType)) + { + action.setParameterValue(FileReportAction.MIMETYPE, mimeType); + } + action.setParameterValue(FileReportAction.DESTINATION, recordFolder.toString()); + action.setParameterValue(FileReportAction.REPORT_TYPE, "rmr:destructionReport"); + actionService.executeAction(action, hold); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java index 9710698f43..8dff2efb07 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java @@ -1,327 +1,327 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.springframework.util.StringUtils; - -/** - * FileTo action unit test - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FileToActionTest extends BaseRMTestCase -{ - private static final String PATH = "rmContainer/rmFolder"; - private static final String PATH2 = "/rmContainer/rmFolder"; - private static final String PATH_BAD = "monkey/rmFolder"; - private static final String PATH_CREATE = "rmContainer/newRmFolder"; - private static final String LONG_PATH_CREATE = "/rmContainer/one/two/three/four/newRmFolder"; - - private static final String PATH_SUB1 = "rmContainer/${node.cm:title}"; - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isUserTest() - { - return true; - } - - public void testFileToNodeRef() - { - initRecord(); - - doTestInTransaction(new Test() - { - public Void run() - { - NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); - - Capability capability = capabilityService.getCapability("FileUnfiledRecords"); - assertNotNull(capability); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(dmDocument)); - - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_DESTINATION_RECORD_FOLDER, rmFolder); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(recordService.isFiled(dmDocument)); - - // is the record folder the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(rmFolder, parent); - - return null; - } - }, ADMIN_USER); - } - - private void initRecord() - { - doTestInTransaction(new Test() - { - public Void run() - { - nodeService.setProperty(dmDocument, ContentModel.PROP_TITLE, "mytestvalue"); - - // create record from document - recordService.createRecord(filePlan, dmDocument); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - AuthenticationUtil.runAs(() -> - { - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertFalse(recordService.isFiled(dmDocument)); - - // is the unfiled container the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); - - return null; - }, - AuthenticationUtil.getAdminUserName()); - } - - }, dmCollaborator); - } - - public void testFileToPath() - { - initRecord(); - - doTestInTransaction(new Test() - { - public Void run() - { - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, PATH); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(recordService.isFiled(dmDocument)); - - // is the record folder the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(rmFolder, parent); - - return null; - } - }, ADMIN_USER); - } - - public void testFileToPath2() - { - initRecord(); - - doTestInTransaction(new Test() - { - public Void run() - { - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, PATH2); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(recordService.isFiled(dmDocument)); - - // is the record folder the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(rmFolder, parent); - - return null; - } - }, ADMIN_USER); - } - - public void testCreate() throws Exception - { - initRecord(); - createRecord(PATH_CREATE, "newRmFolder"); - } - - public void testCreateSub() throws Exception - { - initRecord(); - createRecord(PATH_SUB1, "mytestvalue", "rmContainer/mytestvalue"); - } - - public void testCreatePath() throws Exception - { - initRecord(); - createRecord(LONG_PATH_CREATE, "newRmFolder", "rmContainer/one/two/three/four/newRmFolder"); - } - - private void createRecord(String path, String name) - { - createRecord(path, name, path); - } - - private void createRecord(final String path, final String name, final String resolvedPath) - { - final String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/"); - - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, path); - params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); - - doTestInTransaction(new Test() - { - public Void run() throws Exception - { - // show the folder doesn't exist to begin with - FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); - assertNull(createdRecordFolder); - - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, path); - params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); - - return null; - } - }, ADMIN_USER); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - doTestInTransaction(new Test() - { - public Void run() throws Exception - { - // show the folder has now been created - FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); - assertNotNull(createdRecordFolder); - assertEquals(name, createdRecordFolder.getName()); - NodeRef createdRecordFolderNodeRef = createdRecordFolder.getNodeRef(); - - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(recordService.isFiled(dmDocument)); - - // is the record folder the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(createdRecordFolderNodeRef, parent); - - return null; - } - }, ADMIN_USER); - } - - public void failureTests() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - // create record from document - recordService.createRecord(filePlan, dmDocument); - - // check things have gone according to plan - assertTrue(recordService.isRecord(dmDocument)); - assertFalse(recordService.isFiled(dmDocument)); - - // is the unfiled container the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); - - return null; - } - }, dmCollaborator); - - doTestInTransaction(new FailureTest - ( - "Path is invalid and record create not set." - ) - { - @Override - public void run() throws Exception - { - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, PATH_BAD); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - } - }); - - doTestInTransaction(new FailureTest - ( - "Path is for a new folder, but create not set." - ) - { - @Override - public void run() throws Exception - { - // set parameters - Map params = new HashMap(1); - params.put(FileToAction.PARAM_PATH, PATH_CREATE); - - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); - - } - }); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.springframework.util.StringUtils; + +/** + * FileTo action unit test + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FileToActionTest extends BaseRMTestCase +{ + private static final String PATH = "rmContainer/rmFolder"; + private static final String PATH2 = "/rmContainer/rmFolder"; + private static final String PATH_BAD = "monkey/rmFolder"; + private static final String PATH_CREATE = "rmContainer/newRmFolder"; + private static final String LONG_PATH_CREATE = "/rmContainer/one/two/three/four/newRmFolder"; + + private static final String PATH_SUB1 = "rmContainer/${node.cm:title}"; + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + public void testFileToNodeRef() + { + initRecord(); + + doTestInTransaction(new Test() + { + public Void run() + { + NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); + + Capability capability = capabilityService.getCapability("FileUnfiledRecords"); + assertNotNull(capability); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(dmDocument)); + + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_DESTINATION_RECORD_FOLDER, rmFolder); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(recordService.isFiled(dmDocument)); + + // is the record folder the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(rmFolder, parent); + + return null; + } + }, ADMIN_USER); + } + + private void initRecord() + { + doTestInTransaction(new Test() + { + public Void run() + { + nodeService.setProperty(dmDocument, ContentModel.PROP_TITLE, "mytestvalue"); + + // create record from document + recordService.createRecord(filePlan, dmDocument); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + AuthenticationUtil.runAs(() -> + { + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertFalse(recordService.isFiled(dmDocument)); + + // is the unfiled container the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); + + return null; + }, + AuthenticationUtil.getAdminUserName()); + } + + }, dmCollaborator); + } + + public void testFileToPath() + { + initRecord(); + + doTestInTransaction(new Test() + { + public Void run() + { + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, PATH); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(recordService.isFiled(dmDocument)); + + // is the record folder the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(rmFolder, parent); + + return null; + } + }, ADMIN_USER); + } + + public void testFileToPath2() + { + initRecord(); + + doTestInTransaction(new Test() + { + public Void run() + { + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, PATH2); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(recordService.isFiled(dmDocument)); + + // is the record folder the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(rmFolder, parent); + + return null; + } + }, ADMIN_USER); + } + + public void testCreate() throws Exception + { + initRecord(); + createRecord(PATH_CREATE, "newRmFolder"); + } + + public void testCreateSub() throws Exception + { + initRecord(); + createRecord(PATH_SUB1, "mytestvalue", "rmContainer/mytestvalue"); + } + + public void testCreatePath() throws Exception + { + initRecord(); + createRecord(LONG_PATH_CREATE, "newRmFolder", "rmContainer/one/two/three/four/newRmFolder"); + } + + private void createRecord(String path, String name) + { + createRecord(path, name, path); + } + + private void createRecord(final String path, final String name, final String resolvedPath) + { + final String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/"); + + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, path); + params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + doTestInTransaction(new Test() + { + public Void run() throws Exception + { + // show the folder doesn't exist to begin with + FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); + assertNull(createdRecordFolder); + + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, path); + params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + return null; + } + }, ADMIN_USER); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + doTestInTransaction(new Test() + { + public Void run() throws Exception + { + // show the folder has now been created + FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); + assertNotNull(createdRecordFolder); + assertEquals(name, createdRecordFolder.getName()); + NodeRef createdRecordFolderNodeRef = createdRecordFolder.getNodeRef(); + + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(recordService.isFiled(dmDocument)); + + // is the record folder the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(createdRecordFolderNodeRef, parent); + + return null; + } + }, ADMIN_USER); + } + + public void failureTests() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + // create record from document + recordService.createRecord(filePlan, dmDocument); + + // check things have gone according to plan + assertTrue(recordService.isRecord(dmDocument)); + assertFalse(recordService.isFiled(dmDocument)); + + // is the unfiled container the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); + + return null; + } + }, dmCollaborator); + + doTestInTransaction(new FailureTest + ( + "Path is invalid and record create not set." + ) + { + @Override + public void run() throws Exception + { + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, PATH_BAD); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + } + }); + + doTestInTransaction(new FailureTest + ( + "Path is for a new folder, but create not set." + ) + { + @Override + public void run() throws Exception + { + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, PATH_CREATE); + + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + } + }); + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/HideRecordActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/HideRecordActionTest.java index 8660f761b5..e6d30ba747 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/HideRecordActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/HideRecordActionTest.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.action.dm.HideRecordAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Hide Record Action Unit Test - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class HideRecordActionTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testHideRecordAction() - { - doTestInTransaction(new Test() - { - public Void run() - { - // Create a document so that the user has the write permissions for that document - NodeRef doc = fileFolderService.create(dmFolder, "testfile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - - // Create a record from that document - Action createAction = actionService.createAction(CreateRecordAction.NAME); - createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - actionService.executeAction(createAction, doc); - - // Check if the document is a record now - assertTrue(recordService.isRecord(doc)); - - // The record should have the original location information - assertNotNull(nodeService.getProperty(doc, PROP_RECORD_ORIGINATING_LOCATION)); - - // Check the parents. In this case the document should have two parents (doclib and fileplan) - assertTrue(nodeService.getParentAssocs(doc).size() == 2); - - // Hide the document. The user has the write permissions so he should be able to hide it - Action hideAction = actionService.createAction(HideRecordAction.NAME); - actionService.executeAction(hideAction, doc); - - // The document should be removed from the collaboration site - assertTrue(nodeService.getParentAssocs(doc).size() == 1); - - return null; - } - }, - dmCollaborator); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.dm.HideRecordAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Hide Record Action Unit Test + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class HideRecordActionTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + public void testHideRecordAction() + { + doTestInTransaction(new Test() + { + public Void run() + { + // Create a document so that the user has the write permissions for that document + NodeRef doc = fileFolderService.create(dmFolder, "testfile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + + // Create a record from that document + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + actionService.executeAction(createAction, doc); + + // Check if the document is a record now + assertTrue(recordService.isRecord(doc)); + + // The record should have the original location information + assertNotNull(nodeService.getProperty(doc, PROP_RECORD_ORIGINATING_LOCATION)); + + // Check the parents. In this case the document should have two parents (doclib and fileplan) + assertTrue(nodeService.getParentAssocs(doc).size() == 2); + + // Hide the document. The user has the write permissions so he should be able to hide it + Action hideAction = actionService.createAction(HideRecordAction.NAME); + actionService.executeAction(hideAction, doc); + + // The document should be removed from the collaboration site + assertTrue(nodeService.getParentAssocs(doc).size() == 1); + + return null; + } + }, + dmCollaborator); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/MoveRecordActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/MoveRecordActionTest.java index 71c7a50c81..81338fea3d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/MoveRecordActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/MoveRecordActionTest.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.action.dm.MoveDmRecordAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Move Record Action Unit Test. - * - * @author Tuna Aksoy - * @since 2.2 - */ -public class MoveRecordActionTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testMoveRecordAction() - { - doTestInTransaction(new Test() - { - public Void run() - { - // Create a new folder in a collaboration site - NodeRef testFolder = fileFolderService.create(dmFolder, "myTestFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - - // Create a document so that the user has the write permissions for that document - NodeRef document = fileFolderService.create(testFolder, "moveFile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - - // Create destination folder - String destination = fileFolderService.create(testFolder, "newDest", ContentModel.TYPE_FOLDER).getNodeRef().toString(); - - // Create a record from that document - Action createAction = actionService.createAction(CreateRecordAction.NAME); - createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - actionService.executeAction(createAction, document); - - // Check if the document is a record now - assertTrue(recordService.isRecord(document)); - - // The record should have the original location information - assertNotNull(nodeService.getProperty(document, PROP_RECORD_ORIGINATING_LOCATION)); - - // Check the parents. In this case the document should have two parents (doclib and fileplan) - assertEquals(nodeService.getParentAssocs(document).size(), 2); - - // Check the number of children of dmFolder before move - assertEquals(nodeService.getChildAssocs(testFolder).size(), 2); - - // Move the record - Action moveRecordAction = actionService.createAction(MoveDmRecordAction.NAME); - moveRecordAction.setParameterValue(MoveDmRecordAction.PARAM_TARGET_NODE_REF, destination); - actionService.executeAction(moveRecordAction, document); - - // Check the number of children of dmFolder after move - assertEquals(nodeService.getChildAssocs(testFolder).size(), 1); - - // Check the new document parent - ChildAssociationRef parent1 = nodeService.getParentAssocs(document).get(0); - ChildAssociationRef parent2 = nodeService.getParentAssocs(document).get(1); - NodeRef newDocParent = (parent1.isPrimary() ? parent2 : parent1).getParentRef(); - assertEquals(destination, newDocParent.toString()); - - // Check if the original location information has been updated - assertEquals((NodeRef) nodeService.getProperty(document, PROP_RECORD_ORIGINATING_LOCATION), newDocParent); - - return null; - } - }, - dmCollaborator); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.dm.MoveDmRecordAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Move Record Action Unit Test. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class MoveRecordActionTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + public void testMoveRecordAction() + { + doTestInTransaction(new Test() + { + public Void run() + { + // Create a new folder in a collaboration site + NodeRef testFolder = fileFolderService.create(dmFolder, "myTestFolder", ContentModel.TYPE_FOLDER).getNodeRef(); + + // Create a document so that the user has the write permissions for that document + NodeRef document = fileFolderService.create(testFolder, "moveFile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + + // Create destination folder + String destination = fileFolderService.create(testFolder, "newDest", ContentModel.TYPE_FOLDER).getNodeRef().toString(); + + // Create a record from that document + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + actionService.executeAction(createAction, document); + + // Check if the document is a record now + assertTrue(recordService.isRecord(document)); + + // The record should have the original location information + assertNotNull(nodeService.getProperty(document, PROP_RECORD_ORIGINATING_LOCATION)); + + // Check the parents. In this case the document should have two parents (doclib and fileplan) + assertEquals(nodeService.getParentAssocs(document).size(), 2); + + // Check the number of children of dmFolder before move + assertEquals(nodeService.getChildAssocs(testFolder).size(), 2); + + // Move the record + Action moveRecordAction = actionService.createAction(MoveDmRecordAction.NAME); + moveRecordAction.setParameterValue(MoveDmRecordAction.PARAM_TARGET_NODE_REF, destination); + actionService.executeAction(moveRecordAction, document); + + // Check the number of children of dmFolder after move + assertEquals(nodeService.getChildAssocs(testFolder).size(), 1); + + // Check the new document parent + ChildAssociationRef parent1 = nodeService.getParentAssocs(document).get(0); + ChildAssociationRef parent2 = nodeService.getParentAssocs(document).get(1); + NodeRef newDocParent = (parent1.isPrimary() ? parent2 : parent1).getParentRef(); + assertEquals(destination, newDocParent.toString()); + + // Check if the original location information has been updated + assertEquals((NodeRef) nodeService.getProperty(document, PROP_RECORD_ORIGINATING_LOCATION), newDocParent); + + return null; + } + }, + dmCollaborator); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RecordableVersionConfigActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RecordableVersionConfigActionTest.java index 448c00aa27..39d6702c44 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RecordableVersionConfigActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RecordableVersionConfigActionTest.java @@ -1,143 +1,143 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import static org.alfresco.module.org_alfresco_module_rm.action.dm.RecordableVersionConfigAction.NAME; -import static org.alfresco.module.org_alfresco_module_rm.action.dm.RecordableVersionConfigAction.PARAM_VERSION; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.MAJOR_ONLY; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Recordable version config action test - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordableVersionConfigActionTest extends BaseRMTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testRecordableVersionConfigAction() - { - // Uncommented due to the failures on bamboo. Also this is related to RM-1758 - /* - doTestInTransaction(new Test() - { - final NodeRef document1 = fileFolderService.create(dmFolder, "aDocument", ContentModel.TYPE_CONTENT).getNodeRef(); - public Void run() - { - Action action = actionService.createAction(NAME); - action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString()); - actionService.executeAction(action, document1); - return null; - } - - public void test(Void result) throws Exception - { - Serializable version = nodeService.getProperty(document1, PROP_RECORDABLE_VERSION_POLICY); - assertNotNull(version); - assertEquals(MAJOR_ONLY.toString(), (String) version); - }; - }, - dmCollaborator); - */ - - doTestInTransaction(new Test() - { - public Void run() - { - Action action = actionService.createAction(NAME); - action.setParameterValue(PARAM_VERSION, ALL.toString()); - actionService.executeAction(action, dmFolder); - return null; - } - - public void test(Void result) throws Exception - { - assertNull(nodeService.getProperty(dmFolder, PROP_RECORDABLE_VERSION_POLICY)); - }; - }, - dmCollaborator); - - doTestInTransaction(new Test() - { - final NodeRef document2 = fileFolderService.create(dmFolder, "another document", ContentModel.TYPE_CONTENT).getNodeRef(); - public Void run() - { - Action action = actionService.createAction(NAME); - action.setParameterValue(PARAM_VERSION, NONE.toString()); - actionService.executeAction(action, document2); - return null; - } - - public void test(Void result) throws Exception - { - assertNull(nodeService.getProperty(document2, PROP_RECORDABLE_VERSION_POLICY)); - }; - }, - dmCollaborator); - - - doTestInTransaction(new Test() - { - final NodeRef document3 = fileFolderService.create(dmFolder, "testfile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); - public Void run() - { - Action createAction = actionService.createAction(CreateRecordAction.NAME); - createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - actionService.executeAction(createAction, document3); - - Action action = actionService.createAction(NAME); - action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString()); - actionService.executeAction(action, document3); - return null; - } - - public void test(Void result) throws Exception - { - assertNull(nodeService.getProperty(document3, PROP_RECORDABLE_VERSION_POLICY)); - }; - }, - dmCollaborator); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import static org.alfresco.module.org_alfresco_module_rm.action.dm.RecordableVersionConfigAction.NAME; +import static org.alfresco.module.org_alfresco_module_rm.action.dm.RecordableVersionConfigAction.PARAM_VERSION; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.MAJOR_ONLY; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Recordable version config action test + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordableVersionConfigActionTest extends BaseRMTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + public void testRecordableVersionConfigAction() + { + // Uncommented due to the failures on bamboo. Also this is related to RM-1758 + /* + doTestInTransaction(new Test() + { + final NodeRef document1 = fileFolderService.create(dmFolder, "aDocument", ContentModel.TYPE_CONTENT).getNodeRef(); + public Void run() + { + Action action = actionService.createAction(NAME); + action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString()); + actionService.executeAction(action, document1); + return null; + } + + public void test(Void result) throws Exception + { + Serializable version = nodeService.getProperty(document1, PROP_RECORDABLE_VERSION_POLICY); + assertNotNull(version); + assertEquals(MAJOR_ONLY.toString(), (String) version); + }; + }, + dmCollaborator); + */ + + doTestInTransaction(new Test() + { + public Void run() + { + Action action = actionService.createAction(NAME); + action.setParameterValue(PARAM_VERSION, ALL.toString()); + actionService.executeAction(action, dmFolder); + return null; + } + + public void test(Void result) throws Exception + { + assertNull(nodeService.getProperty(dmFolder, PROP_RECORDABLE_VERSION_POLICY)); + }; + }, + dmCollaborator); + + doTestInTransaction(new Test() + { + final NodeRef document2 = fileFolderService.create(dmFolder, "another document", ContentModel.TYPE_CONTENT).getNodeRef(); + public Void run() + { + Action action = actionService.createAction(NAME); + action.setParameterValue(PARAM_VERSION, NONE.toString()); + actionService.executeAction(action, document2); + return null; + } + + public void test(Void result) throws Exception + { + assertNull(nodeService.getProperty(document2, PROP_RECORDABLE_VERSION_POLICY)); + }; + }, + dmCollaborator); + + + doTestInTransaction(new Test() + { + final NodeRef document3 = fileFolderService.create(dmFolder, "testfile.txt", ContentModel.TYPE_CONTENT).getNodeRef(); + public Void run() + { + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + actionService.executeAction(createAction, document3); + + Action action = actionService.createAction(NAME); + action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString()); + actionService.executeAction(action, document3); + return null; + } + + public void test(Void result) throws Exception + { + assertNull(nodeService.getProperty(document3, PROP_RECORDABLE_VERSION_POLICY)); + }; + }, + dmCollaborator); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RejectActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RejectActionTest.java index adee075ed1..6ae40e273a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RejectActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/RejectActionTest.java @@ -1,115 +1,115 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; - -import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.RejectAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.action.Action; - -/** - * Reject Action Unit Test - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RejectActionTest extends BaseRMTestCase -{ - /** Reject reason */ - private final String REJECT_REASON = "rejectReason:Not valid!£$%^&*()_+"; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testRejectAction() - { - doTestInTransaction(new Test() - { - public Void run() - { - // Create a record from the document - Action createAction = actionService.createAction(CreateRecordAction.NAME); - createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); - actionService.executeAction(createAction, dmDocument); - - // Check if the document is a record now - assertTrue(recordService.isRecord(dmDocument)); - - // The record should have the original location information - assertNotNull(nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); - - // Check the parents. In this case the document should have two parents (doclib and fileplan) - assertTrue(nodeService.getParentAssocs(dmDocument).size() == 2); - - return null; - } - }, - dmCollaborator); - - doTestInTransaction(new FailureTest("Cannot reject a record without a reason.", IllegalArgumentException.class) - { - public void run() - { - // The test should fail if the reject reason is not supplied - Action rejectAction = actionService.createAction(RejectAction.NAME); - actionService.executeAction(rejectAction, dmDocument); - } - }, - dmCollaborator); - - doTestInTransaction(new Test() - { - public Void run() - { - // Create the reject action and add the reject reason - Action rejectAction = actionService.createAction(RejectAction.NAME); - rejectAction.setParameterValue(RejectAction.PARAM_REASON, REJECT_REASON); - actionService.executeAction(rejectAction, dmDocument); - - // The "record" aspect should be removed - assertFalse(nodeService.hasAspect(dmDocument, ASPECT_RECORD)); - - // The "file plan component" should be removed - assertFalse(nodeService.hasAspect(dmDocument, ASPECT_FILE_PLAN_COMPONENT)); - - // The "identifier" property should be removed - assertNull(nodeService.getProperty(dmDocument, PROP_IDENTIFIER)); - - // The record should be removed from the file plan - assertTrue(nodeService.getParentAssocs(dmDocument).size() == 1); - - // The extended reader information should be removed - assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); - assertTrue(extendedSecurityService.getReaders(dmDocument).isEmpty()); - - return null; - } - }, - dmCollaborator); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.action; + +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.RejectAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; + +/** + * Reject Action Unit Test + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RejectActionTest extends BaseRMTestCase +{ + /** Reject reason */ + private final String REJECT_REASON = "rejectReason:Not valid!£$%^&*()_+"; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + public void testRejectAction() + { + doTestInTransaction(new Test() + { + public Void run() + { + // Create a record from the document + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + actionService.executeAction(createAction, dmDocument); + + // Check if the document is a record now + assertTrue(recordService.isRecord(dmDocument)); + + // The record should have the original location information + assertNotNull(nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); + + // Check the parents. In this case the document should have two parents (doclib and fileplan) + assertTrue(nodeService.getParentAssocs(dmDocument).size() == 2); + + return null; + } + }, + dmCollaborator); + + doTestInTransaction(new FailureTest("Cannot reject a record without a reason.", IllegalArgumentException.class) + { + public void run() + { + // The test should fail if the reject reason is not supplied + Action rejectAction = actionService.createAction(RejectAction.NAME); + actionService.executeAction(rejectAction, dmDocument); + } + }, + dmCollaborator); + + doTestInTransaction(new Test() + { + public Void run() + { + // Create the reject action and add the reject reason + Action rejectAction = actionService.createAction(RejectAction.NAME); + rejectAction.setParameterValue(RejectAction.PARAM_REASON, REJECT_REASON); + actionService.executeAction(rejectAction, dmDocument); + + // The "record" aspect should be removed + assertFalse(nodeService.hasAspect(dmDocument, ASPECT_RECORD)); + + // The "file plan component" should be removed + assertFalse(nodeService.hasAspect(dmDocument, ASPECT_FILE_PLAN_COMPONENT)); + + // The "identifier" property should be removed + assertNull(nodeService.getProperty(dmDocument, PROP_IDENTIFIER)); + + // The record should be removed from the file plan + assertTrue(nodeService.getParentAssocs(dmDocument).size() == 1); + + // The extended reader information should be removed + assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); + assertTrue(extendedSecurityService.getReaders(dmDocument).isEmpty()); + + return null; + } + }, + dmCollaborator); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CapabilitiesTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CapabilitiesTestSuite.java index c325ad13d3..c407f1ad0a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CapabilitiesTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CapabilitiesTestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * RM test suite - * - * @author Roy Wetherall - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - DeclarativeCapabilityTest.class, - CompositeCapabilityTest.class -}) -public class CapabilitiesTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * RM test suite + * + * @author Roy Wetherall + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + DeclarativeCapabilityTest.class, + CompositeCapabilityTest.class +}) +public class CapabilitiesTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CompositeCapabilityTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CompositeCapabilityTest.java index 34678071b9..d3a69dd810 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CompositeCapabilityTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/CompositeCapabilityTest.java @@ -1,163 +1,163 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; - -/** - * Declarative capability unit test - * - * @author Roy Wetherall - */ -public class CompositeCapabilityTest extends BaseRMTestCase -{ - private NodeRef record; - private NodeRef declaredRecord; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - // Pre-filed content - record = utils.createRecord(rmFolder, "record.txt"); - declaredRecord = utils.createRecord(rmFolder, "declaredRecord.txt"); - } - - @Override - protected void setupTestData() - { - super.setupTestData(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - utils.completeRecord(declaredRecord); - - return null; - } - }); - } - - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - } - - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Give all the users file permission objects - for (String user : testUsers) - { - filePlanPermissionService.setPermission(rmContainer, user, RMPermissionModel.FILING); - } - } - - public void testUpdate() - { - final Capability capability = capabilityService.getCapability("Update"); - assertNotNull(capability); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(declaredRecord)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - - return null; - } - }, userName); - - - } - - public void testUpdateProperties() - { - final Capability capability = capabilityService.getCapability("UpdateProperties"); - assertNotNull(capability); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(declaredRecord)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - - return null; - } - }, userName); - - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; + +/** + * Declarative capability unit test + * + * @author Roy Wetherall + */ +public class CompositeCapabilityTest extends BaseRMTestCase +{ + private NodeRef record; + private NodeRef declaredRecord; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + // Pre-filed content + record = utils.createRecord(rmFolder, "record.txt"); + declaredRecord = utils.createRecord(rmFolder, "declaredRecord.txt"); + } + + @Override + protected void setupTestData() + { + super.setupTestData(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + utils.completeRecord(declaredRecord); + + return null; + } + }); + } + + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + } + + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Give all the users file permission objects + for (String user : testUsers) + { + filePlanPermissionService.setPermission(rmContainer, user, RMPermissionModel.FILING); + } + } + + public void testUpdate() + { + final Capability capability = capabilityService.getCapability("Update"); + assertNotNull(capability); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(declaredRecord)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + + return null; + } + }, userName); + + + } + + public void testUpdateProperties() + { + final Capability capability = capabilityService.getCapability("UpdateProperties"); + assertNotNull(capability); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(declaredRecord)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + + return null; + } + }, userName); + + + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java index a21d341b5e..6249a96504 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java @@ -1,493 +1,493 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCompositeCapability; -import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.springframework.extensions.webscripts.GUID; - -/** - * Declarative capability unit test - * - * @author Roy Wetherall - */ -public class DeclarativeCapabilityTest extends BaseRMTestCase -{ - private NodeRef record; - private NodeRef declaredRecord; - private NodeRef undeclaredRecord; - - private NodeRef recordFolderContainsFrozen; - private NodeRef frozenRecord; - private NodeRef frozenRecord2; - private NodeRef frozenRecordFolder; - - private NodeRef closedFolder; - - private NodeRef moveToFolder; - private NodeRef moveToCategory; - - private NodeRef hold; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - // Pre-filed content - record = utils.createRecord(rmFolder, "record.txt"); - declaredRecord = utils.createRecord(rmFolder, "declaredRecord.txt"); - undeclaredRecord = utils.createRecord(rmFolder, "undeclaredRecord.txt"); - - // Closed folder - closedFolder = recordFolderService.createRecordFolder(rmContainer, "closedFolder"); - utils.closeFolder(closedFolder); - - // Frozen artifacts - recordFolderContainsFrozen = recordFolderService.createRecordFolder(rmContainer, "containsFrozen"); - frozenRecord = utils.createRecord(rmFolder, "frozenRecord.txt"); - frozenRecord2 = utils.createRecord(recordFolderContainsFrozen, "frozen2.txt"); - frozenRecordFolder = recordFolderService.createRecordFolder(rmContainer, "frozenRecordFolder"); - - // MoveTo artifacts - moveToFolder = recordFolderService.createRecordFolder(rmContainer, "moveToFolder"); - moveToCategory = filePlanService.createRecordCategory(rmContainer, "moveToCategory"); - } - - @Override - protected void setupTestData() - { - super.setupTestData(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - utils.completeRecord(declaredRecord); - utils.completeRecord(frozenRecord); - utils.completeRecord(frozenRecord2); - - hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description"); - - holdService.addToHold(hold, frozenRecord); - holdService.addToHold(hold, frozenRecordFolder); - holdService.addToHold(hold, frozenRecord2); - - return null; - } - }); - } - - @Override - protected void tearDownImpl() - { - // Unfreeze stuff so it can be deleted - holdService.removeFromHold(hold, frozenRecord); - holdService.removeFromHold(hold, frozenRecordFolder); - holdService.removeFromHold(hold, frozenRecord2); - - super.tearDownImpl(); - } - - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Give all the users file permission objects - for (String user : testUsers) - { - filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmContainer, user, RMPermissionModel.READ_RECORDS); - filePlanPermissionService.setPermission(moveToFolder, user, RMPermissionModel.READ_RECORDS); - filePlanPermissionService.setPermission(moveToCategory, user, RMPermissionModel.READ_RECORDS); - } - } - - public void testDeclarativeCapabilities() - { - Set capabilities = capabilityService.getCapabilities(); - for (Capability capability : capabilities) - { - if (capability instanceof DeclarativeCapability && - !(capability instanceof DeclarativeCompositeCapability) && - !capability.isPrivate() && - !capability.getName().equals("MoveRecords") && - !capability.getName().equals("DeleteLinks") && - !capability.getName().equals("ChangeOrDeleteReferences")) - { - testDeclarativeCapability((DeclarativeCapability)capability); - } - } - } - - private void testDeclarativeCapability(final DeclarativeCapability capability) - { - for (String user : testUsers) - { - testDeclarativeCapability(capability, user, filePlan); - testDeclarativeCapability(capability, user, rmContainer); - testDeclarativeCapability(capability, user, rmFolder); - testDeclarativeCapability(capability, user, record); - } - } - - private void testDeclarativeCapability(final DeclarativeCapability capability, final String userName, final NodeRef filePlanComponent) - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - AccessStatus accessStatus = capability.hasPermission(filePlanComponent); - - Set roles = filePlanRoleService.getRolesByUser(filePlan, userName); - if (roles.isEmpty()) - { - assertEquals("User " + userName + " has no RM role so we expect access to be denied for capability " + capability.getName(), - AccessStatus.DENIED, - accessStatus); - } - else - { - // Do the kind check here ... - FilePlanComponentKind actualKind = filePlanService.getFilePlanComponentKind(filePlanComponent); - List kinds = capability.getKinds(); - - if (kinds == null || - kinds.contains(actualKind.toString())) - { - Map conditions = capability.getConditions(); - boolean conditionResult = getConditionResult(filePlanComponent, conditions); - - assertEquals("User is expected to only have one role.", 1, roles.size()); - Role role = new ArrayList(roles).get(0); - assertNotNull(role); - - Set roleCapabilities = role.getCapabilities(); - if (roleCapabilities.contains(capability) && conditionResult) - { - assertEquals("User " + userName + " has the role " + role.getDisplayLabel() + - " so we expect access to be allowed for capability " + capability.getName() + " on the object " + - (String)nodeService.getProperty(filePlanComponent, ContentModel.PROP_NAME), - AccessStatus.ALLOWED, - accessStatus); - } - else - { - assertEquals("User " + userName + " has the role " + role.getDisplayLabel() + " so we expect access to be denied for capability " + capability.getName(), - AccessStatus.DENIED, - accessStatus); - } - } - else - { - // Expect fail since the kind is not expected by the capability - assertEquals("NodeRef is of kind" + actualKind + " so we expect access to be denied for capability " + capability.getName(), - AccessStatus.DENIED, - accessStatus); - } - } - - return null; - } - }, userName); - } - - private boolean getConditionResult(NodeRef nodeRef, Map conditions) - { - boolean result = true; - - if (conditions != null && conditions.size() != 0) - { - for (Map.Entry entry : conditions.entrySet()) - { - // Get the condition bean - CapabilityCondition condition = (CapabilityCondition)applicationContext.getBean(entry.getKey()); - assertNotNull("Invalid condition name.", condition); - - boolean actual = condition.evaluate(nodeRef); - if (actual != entry.getValue().booleanValue()) - { - result = false; - break; - } - } - } - - return result; - } - - /** Specific declarative capability tests */ - - public void testCreateRecordCapability() - { - final Capability capability = capabilityService.getCapability("CreateRecords"); - assertNotNull(capability); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - - return null; - } - }, rmUserName); - } - - public void testMoveRecordCapability() - { - // grab the move record capability - final Capability capability = capabilityService.getCapability("MoveRecords"); - assertNotNull(capability); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // first take a look at just the record - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord)); - - // now lets take a look when we know what the destination is - // NOTE: should be denied since we do not have file permission on the destination folder - // despite having the capability! - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - for (String user : testUsers) - { - filePlanPermissionService.setPermission(moveToFolder, user, RMPermissionModel.FILING); - } - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // first take a look at just the record - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord)); - - // now lets take a look when we know what the destination is - // NOTE: should be allowed now since we have filling permission on the destination folder - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(record, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(declaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(undeclaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // first take a look at just the record - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); - - // now lets take a look when we know what the destination is - // NOTE: should be allowed now since we have filling permission on the destination folder - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder)); - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); - - return null; - } - }, rmUserName); - } - - public void testMoveRecordFolderCapability() - { - // grab the move record capability - final Capability capability = capabilityService.getCapability("MoveRecordFolder"); - assertNotNull(capability); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // first take a look at just the record - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); - - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - for (String user : testUsers) - { - filePlanPermissionService.setPermission(moveToCategory, user, RMPermissionModel.FILING); - } - return null; - } - }, ADMIN_USER); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); - - assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(rmFolder, moveToCategory)); - - return null; - } - }, recordsManagerName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); - assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); - - assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory)); - - return null; - } - }, rmUserName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.capabilities; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCompositeCapability; +import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.springframework.extensions.webscripts.GUID; + +/** + * Declarative capability unit test + * + * @author Roy Wetherall + */ +public class DeclarativeCapabilityTest extends BaseRMTestCase +{ + private NodeRef record; + private NodeRef declaredRecord; + private NodeRef undeclaredRecord; + + private NodeRef recordFolderContainsFrozen; + private NodeRef frozenRecord; + private NodeRef frozenRecord2; + private NodeRef frozenRecordFolder; + + private NodeRef closedFolder; + + private NodeRef moveToFolder; + private NodeRef moveToCategory; + + private NodeRef hold; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + // Pre-filed content + record = utils.createRecord(rmFolder, "record.txt"); + declaredRecord = utils.createRecord(rmFolder, "declaredRecord.txt"); + undeclaredRecord = utils.createRecord(rmFolder, "undeclaredRecord.txt"); + + // Closed folder + closedFolder = recordFolderService.createRecordFolder(rmContainer, "closedFolder"); + utils.closeFolder(closedFolder); + + // Frozen artifacts + recordFolderContainsFrozen = recordFolderService.createRecordFolder(rmContainer, "containsFrozen"); + frozenRecord = utils.createRecord(rmFolder, "frozenRecord.txt"); + frozenRecord2 = utils.createRecord(recordFolderContainsFrozen, "frozen2.txt"); + frozenRecordFolder = recordFolderService.createRecordFolder(rmContainer, "frozenRecordFolder"); + + // MoveTo artifacts + moveToFolder = recordFolderService.createRecordFolder(rmContainer, "moveToFolder"); + moveToCategory = filePlanService.createRecordCategory(rmContainer, "moveToCategory"); + } + + @Override + protected void setupTestData() + { + super.setupTestData(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + utils.completeRecord(declaredRecord); + utils.completeRecord(frozenRecord); + utils.completeRecord(frozenRecord2); + + hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description"); + + holdService.addToHold(hold, frozenRecord); + holdService.addToHold(hold, frozenRecordFolder); + holdService.addToHold(hold, frozenRecord2); + + return null; + } + }); + } + + @Override + protected void tearDownImpl() + { + // Unfreeze stuff so it can be deleted + holdService.removeFromHold(hold, frozenRecord); + holdService.removeFromHold(hold, frozenRecordFolder); + holdService.removeFromHold(hold, frozenRecord2); + + super.tearDownImpl(); + } + + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Give all the users file permission objects + for (String user : testUsers) + { + filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmContainer, user, RMPermissionModel.READ_RECORDS); + filePlanPermissionService.setPermission(moveToFolder, user, RMPermissionModel.READ_RECORDS); + filePlanPermissionService.setPermission(moveToCategory, user, RMPermissionModel.READ_RECORDS); + } + } + + public void testDeclarativeCapabilities() + { + Set capabilities = capabilityService.getCapabilities(); + for (Capability capability : capabilities) + { + if (capability instanceof DeclarativeCapability && + !(capability instanceof DeclarativeCompositeCapability) && + !capability.isPrivate() && + !capability.getName().equals("MoveRecords") && + !capability.getName().equals("DeleteLinks") && + !capability.getName().equals("ChangeOrDeleteReferences")) + { + testDeclarativeCapability((DeclarativeCapability)capability); + } + } + } + + private void testDeclarativeCapability(final DeclarativeCapability capability) + { + for (String user : testUsers) + { + testDeclarativeCapability(capability, user, filePlan); + testDeclarativeCapability(capability, user, rmContainer); + testDeclarativeCapability(capability, user, rmFolder); + testDeclarativeCapability(capability, user, record); + } + } + + private void testDeclarativeCapability(final DeclarativeCapability capability, final String userName, final NodeRef filePlanComponent) + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + AccessStatus accessStatus = capability.hasPermission(filePlanComponent); + + Set roles = filePlanRoleService.getRolesByUser(filePlan, userName); + if (roles.isEmpty()) + { + assertEquals("User " + userName + " has no RM role so we expect access to be denied for capability " + capability.getName(), + AccessStatus.DENIED, + accessStatus); + } + else + { + // Do the kind check here ... + FilePlanComponentKind actualKind = filePlanService.getFilePlanComponentKind(filePlanComponent); + List kinds = capability.getKinds(); + + if (kinds == null || + kinds.contains(actualKind.toString())) + { + Map conditions = capability.getConditions(); + boolean conditionResult = getConditionResult(filePlanComponent, conditions); + + assertEquals("User is expected to only have one role.", 1, roles.size()); + Role role = new ArrayList(roles).get(0); + assertNotNull(role); + + Set roleCapabilities = role.getCapabilities(); + if (roleCapabilities.contains(capability) && conditionResult) + { + assertEquals("User " + userName + " has the role " + role.getDisplayLabel() + + " so we expect access to be allowed for capability " + capability.getName() + " on the object " + + (String)nodeService.getProperty(filePlanComponent, ContentModel.PROP_NAME), + AccessStatus.ALLOWED, + accessStatus); + } + else + { + assertEquals("User " + userName + " has the role " + role.getDisplayLabel() + " so we expect access to be denied for capability " + capability.getName(), + AccessStatus.DENIED, + accessStatus); + } + } + else + { + // Expect fail since the kind is not expected by the capability + assertEquals("NodeRef is of kind" + actualKind + " so we expect access to be denied for capability " + capability.getName(), + AccessStatus.DENIED, + accessStatus); + } + } + + return null; + } + }, userName); + } + + private boolean getConditionResult(NodeRef nodeRef, Map conditions) + { + boolean result = true; + + if (conditions != null && conditions.size() != 0) + { + for (Map.Entry entry : conditions.entrySet()) + { + // Get the condition bean + CapabilityCondition condition = (CapabilityCondition)applicationContext.getBean(entry.getKey()); + assertNotNull("Invalid condition name.", condition); + + boolean actual = condition.evaluate(nodeRef); + if (actual != entry.getValue().booleanValue()) + { + result = false; + break; + } + } + } + + return result; + } + + /** Specific declarative capability tests */ + + public void testCreateRecordCapability() + { + final Capability capability = capabilityService.getCapability("CreateRecords"); + assertNotNull(capability); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + + return null; + } + }, rmUserName); + } + + public void testMoveRecordCapability() + { + // grab the move record capability + final Capability capability = capabilityService.getCapability("MoveRecords"); + assertNotNull(capability); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // first take a look at just the record + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord)); + + // now lets take a look when we know what the destination is + // NOTE: should be denied since we do not have file permission on the destination folder + // despite having the capability! + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + for (String user : testUsers) + { + filePlanPermissionService.setPermission(moveToFolder, user, RMPermissionModel.FILING); + } + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // first take a look at just the record + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord)); + + // now lets take a look when we know what the destination is + // NOTE: should be allowed now since we have filling permission on the destination folder + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(record, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(declaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(undeclaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // first take a look at just the record + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); + + // now lets take a look when we know what the destination is + // NOTE: should be allowed now since we have filling permission on the destination folder + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder)); + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder)); + + return null; + } + }, rmUserName); + } + + public void testMoveRecordFolderCapability() + { + // grab the move record capability + final Capability capability = capabilityService.getCapability("MoveRecordFolder"); + assertNotNull(capability); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // first take a look at just the record + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); + + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + for (String user : testUsers) + { + filePlanPermissionService.setPermission(moveToCategory, user, RMPermissionModel.FILING); + } + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); + + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(rmFolder, moveToCategory)); + + return null; + } + }, recordsManagerName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(record)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder)); + assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord)); + + assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory)); + + return null; + } + }, rmUserName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java index 1af499ba9f..eaac94655c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java @@ -1,151 +1,151 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript; - -import java.io.Serializable; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.jscript.app.JSONConversionComponent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.ArrayUtils; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * @author Roy Wetherall - */ -public class JSONConversionComponentTest extends BaseRMTestCase -{ - private JSONConversionComponent converter; - - private NodeRef record; - - @Override - protected void initServices() - { - super.initServices(); - converter = (JSONConversionComponent)applicationContext.getBean("jsonConversionComponent"); - } - - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - // Create records - record = utils.createRecord(rmFolder, "testRecord.txt"); - } - - public void testJSON() throws Exception - { - doTestInTransaction(new JSONTest - ( - filePlan, - new String[]{"isRmNode", "true", "boolean"}, - new String[]{"rmNode.kind", "FILE_PLAN"} - ){}); - - doTestInTransaction(new JSONTest - ( - rmContainer, - new String[]{"isRmNode", "true", "boolean"}, - new String[]{"rmNode.kind", "RECORD_CATEGORY"} - ){}); - - doTestInTransaction(new JSONTest - ( - rmFolder, - new String[]{"isRmNode", "true", "boolean"}, - new String[]{"rmNode.kind", "RECORD_FOLDER"} - ){}); - - doTestInTransaction(new JSONTest - ( - record, - new String[]{"isRmNode", "true", "boolean"}, - new String[]{"rmNode.kind", "RECORD"} - ){}); - } - - class JSONTest extends Test - { - private NodeRef nodeRef; - private String[][] testValues; - - public JSONTest(NodeRef nodeRef, String[] ... testValues) - { - this.nodeRef = nodeRef; - this.testValues = testValues; - } - - @Override - public JSONObject run() throws Exception - { - String json = converter.toJSON(nodeRef, true); - System.out.println(json); - return new JSONObject(json); - } - - @Override - public void test(JSONObject result) throws Exception - { - for (String[] testValue : testValues) - { - String key = testValue[0]; - String type = "string"; - if (testValue.length == 3) - { - type = testValue[2]; - } - Serializable value = convertValue(testValue[1], type); - Serializable actualValue = (Serializable)getValue(result, key); - - assertEquals("The key " + key + " did not have the expected value.", value, actualValue); - } - } - - private Serializable convertValue(String stringValue, String type) - { - Serializable value = stringValue; - if (type.equals("boolean")) - { - value = new Boolean(stringValue); - } - return value; - } - - private Object getValue(JSONObject jsonObject, String key) throws JSONException - { - return getValue(jsonObject, key.split("\\.")); - } - - private Object getValue(JSONObject jsonObject, String[] key) throws JSONException - { - if (key.length == 1) - { - return jsonObject.get(key[0]); - } - else - { - return getValue(jsonObject.getJSONObject(key[0]), - (String[])ArrayUtils.subarray(key, 1, key.length)); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript; + +import java.io.Serializable; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.jscript.app.JSONConversionComponent; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.lang.ArrayUtils; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * @author Roy Wetherall + */ +public class JSONConversionComponentTest extends BaseRMTestCase +{ + private JSONConversionComponent converter; + + private NodeRef record; + + @Override + protected void initServices() + { + super.initServices(); + converter = (JSONConversionComponent)applicationContext.getBean("jsonConversionComponent"); + } + + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + // Create records + record = utils.createRecord(rmFolder, "testRecord.txt"); + } + + public void testJSON() throws Exception + { + doTestInTransaction(new JSONTest + ( + filePlan, + new String[]{"isRmNode", "true", "boolean"}, + new String[]{"rmNode.kind", "FILE_PLAN"} + ){}); + + doTestInTransaction(new JSONTest + ( + rmContainer, + new String[]{"isRmNode", "true", "boolean"}, + new String[]{"rmNode.kind", "RECORD_CATEGORY"} + ){}); + + doTestInTransaction(new JSONTest + ( + rmFolder, + new String[]{"isRmNode", "true", "boolean"}, + new String[]{"rmNode.kind", "RECORD_FOLDER"} + ){}); + + doTestInTransaction(new JSONTest + ( + record, + new String[]{"isRmNode", "true", "boolean"}, + new String[]{"rmNode.kind", "RECORD"} + ){}); + } + + class JSONTest extends Test + { + private NodeRef nodeRef; + private String[][] testValues; + + public JSONTest(NodeRef nodeRef, String[] ... testValues) + { + this.nodeRef = nodeRef; + this.testValues = testValues; + } + + @Override + public JSONObject run() throws Exception + { + String json = converter.toJSON(nodeRef, true); + System.out.println(json); + return new JSONObject(json); + } + + @Override + public void test(JSONObject result) throws Exception + { + for (String[] testValue : testValues) + { + String key = testValue[0]; + String type = "string"; + if (testValue.length == 3) + { + type = testValue[2]; + } + Serializable value = convertValue(testValue[1], type); + Serializable actualValue = (Serializable)getValue(result, key); + + assertEquals("The key " + key + " did not have the expected value.", value, actualValue); + } + } + + private Serializable convertValue(String stringValue, String type) + { + Serializable value = stringValue; + if (type.equals("boolean")) + { + value = new Boolean(stringValue); + } + return value; + } + + private Object getValue(JSONObject jsonObject, String key) throws JSONException + { + return getValue(jsonObject, key.split("\\.")); + } + + private Object getValue(JSONObject jsonObject, String[] key) throws JSONException + { + if (key.length == 1) + { + return jsonObject.get(key[0]); + } + else + { + return getValue(jsonObject.getJSONObject(key[0]), + (String[])ArrayUtils.subarray(key, 1, key.length)); + } + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JScriptTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JScriptTestSuite.java index fb16ad9b49..0fc4559440 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JScriptTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JScriptTestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * JScript Test Suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - JSONConversionComponentTest.class -}) -public class JScriptTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * JScript Test Suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + JSONConversionComponentTest.class +}) +public class JScriptTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/MethodSecurityTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/MethodSecurityTest.java index 82954749f9..5e2b317065 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/MethodSecurityTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/MethodSecurityTest.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.security; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Tests method level security of core alfresco services. - * - * @author Roy Wetherall - * @since 2.0 - */ -public class MethodSecurityTest extends BaseRMTestCase implements RMPermissionModel -{ - /** - * Indicate this is a user test. - * - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * Test node service security access - */ - public void testNodeService() - { - doTestInTransaction(new FailureTest - ( - "We don't have permission to access this node." - ) - { - @Override - public void run() - { - nodeService.getProperties(rmContainer); - } - - }, rmUserName); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.setPermission(rmContainer, rmUserName, READ_RECORDS); - return null; - } - - @Override - public void test(Void result) throws Exception - { - nodeService.getProperties(rmContainer); - } - - }, rmUserName); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.security; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Tests method level security of core alfresco services. + * + * @author Roy Wetherall + * @since 2.0 + */ +public class MethodSecurityTest extends BaseRMTestCase implements RMPermissionModel +{ + /** + * Indicate this is a user test. + * + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * Test node service security access + */ + public void testNodeService() + { + doTestInTransaction(new FailureTest + ( + "We don't have permission to access this node." + ) + { + @Override + public void run() + { + nodeService.getProperties(rmContainer); + } + + }, rmUserName); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(rmContainer, rmUserName, READ_RECORDS); + return null; + } + + @Override + public void test(Void result) throws Exception + { + nodeService.getProperties(rmContainer); + } + + }, rmUserName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/SecurityTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/SecurityTestSuite.java index 30d676bd1b..9f6c864d02 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/SecurityTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/security/SecurityTestSuite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.security; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * Security Test Suite - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - MethodSecurityTest.class -}) -public class SecurityTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.security; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * Security Test Suite + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + MethodSecurityTest.class +}) +public class SecurityTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CapabilityServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CapabilityServiceImplTest.java index 42b884683a..f4095d8cfa 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CapabilityServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CapabilityServiceImplTest.java @@ -1,135 +1,135 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.Group; -import org.alfresco.module.org_alfresco_module_rm.capability.GroupImpl; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Test class for testing the methods in {@link CapabilityService} - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class CapabilityServiceImplTest extends BaseRMTestCase -{ - public void testGetAddRemoveGroups() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Group auditGroup = capabilityService.getGroup("audit"); - assertNotNull(auditGroup); - assertEquals(10, auditGroup.getIndex()); - assertEquals("Audit", auditGroup.getTitle()); - assertEquals("audit", auditGroup.getId()); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - int initialSize = capabilityService.getGroups().size(); - - GroupImpl testGroup = new GroupImpl(); - testGroup.setId("testGroup"); - testGroup.setIndex(140); - testGroup.setTitle("Test group"); - capabilityService.addGroup(testGroup); - - assertEquals(initialSize+1, capabilityService.getGroups().size()); - - Group group = capabilityService.getGroup("testGroup"); - assertNotNull(group); - assertTrue(group.getId().equalsIgnoreCase("testGroup")); - assertTrue(group.getTitle().equalsIgnoreCase("Test group")); - assertTrue(group.getIndex() == 140); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Group testGroup = capabilityService.getGroup("testGroup"); - assertNotNull(testGroup); - int initialSize = capabilityService.getGroups().size(); - - capabilityService.removeGroup(testGroup); - assertEquals(initialSize-1, capabilityService.getGroups().size()); - - return null; - } - }); - } - - public void testGetCapabilitiesByGroup() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - List groups = capabilityService.getGroups(); - assertNotNull(groups); - - Group recordsGroup = groups.get(0); - assertNotNull(recordsGroup); - - List recordCapabilities = capabilityService.getCapabilitiesByGroup(recordsGroup); - assertNotNull(recordCapabilities); - - int recordCapabilitiesSize = recordCapabilities.size(); - assertTrue(recordCapabilitiesSize > 1); - - for (int i = 1; i == recordCapabilitiesSize; i++) - { - Capability capability = recordCapabilities.get(i); - assertNotNull(capability); - assertEquals(i * 10, capability.getIndex()); - } - - Group rulesGroup = groups.get(groups.size() - 2); - assertNotNull(rulesGroup); - - List ruleCapabilities = capabilityService.getCapabilitiesByGroupId(rulesGroup.getId()); - assertNotNull(ruleCapabilities); - - int ruleCapabilitiesSize = ruleCapabilities.size(); - assertTrue(ruleCapabilitiesSize > 0); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.Group; +import org.alfresco.module.org_alfresco_module_rm.capability.GroupImpl; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Test class for testing the methods in {@link CapabilityService} + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class CapabilityServiceImplTest extends BaseRMTestCase +{ + public void testGetAddRemoveGroups() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Group auditGroup = capabilityService.getGroup("audit"); + assertNotNull(auditGroup); + assertEquals(10, auditGroup.getIndex()); + assertEquals("Audit", auditGroup.getTitle()); + assertEquals("audit", auditGroup.getId()); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + int initialSize = capabilityService.getGroups().size(); + + GroupImpl testGroup = new GroupImpl(); + testGroup.setId("testGroup"); + testGroup.setIndex(140); + testGroup.setTitle("Test group"); + capabilityService.addGroup(testGroup); + + assertEquals(initialSize+1, capabilityService.getGroups().size()); + + Group group = capabilityService.getGroup("testGroup"); + assertNotNull(group); + assertTrue(group.getId().equalsIgnoreCase("testGroup")); + assertTrue(group.getTitle().equalsIgnoreCase("Test group")); + assertTrue(group.getIndex() == 140); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Group testGroup = capabilityService.getGroup("testGroup"); + assertNotNull(testGroup); + int initialSize = capabilityService.getGroups().size(); + + capabilityService.removeGroup(testGroup); + assertEquals(initialSize-1, capabilityService.getGroups().size()); + + return null; + } + }); + } + + public void testGetCapabilitiesByGroup() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + List groups = capabilityService.getGroups(); + assertNotNull(groups); + + Group recordsGroup = groups.get(0); + assertNotNull(recordsGroup); + + List recordCapabilities = capabilityService.getCapabilitiesByGroup(recordsGroup); + assertNotNull(recordCapabilities); + + int recordCapabilitiesSize = recordCapabilities.size(); + assertTrue(recordCapabilitiesSize > 1); + + for (int i = 1; i == recordCapabilitiesSize; i++) + { + Capability capability = recordCapabilities.get(i); + assertNotNull(capability); + assertEquals(i * 10, capability.getIndex()); + } + + Group rulesGroup = groups.get(groups.size() - 2); + assertNotNull(rulesGroup); + + List ruleCapabilities = capabilityService.getCapabilitiesByGroupId(rulesGroup.getId()); + assertNotNull(ruleCapabilities); + + int ruleCapabilitiesSize = ruleCapabilities.size(); + assertTrue(ruleCapabilitiesSize > 0); + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CustomEMailMappingServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CustomEMailMappingServiceImplTest.java index 9e11507605..9e8acbaa8a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CustomEMailMappingServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/CustomEMailMappingServiceImplTest.java @@ -1,146 +1,146 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; -import org.alfresco.module.org_alfresco_module_rm.email.CustomMapping; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Custom EMail Mapping Service - * - * @author Roy Wetherall - * @since 2.0 - */ -public class CustomEMailMappingServiceImplTest extends BaseRMTestCase -{ - private CustomEmailMappingService eMailMappingService; - - @Override - protected void initServices() - { - super.initServices(); - - eMailMappingService = (CustomEmailMappingService)applicationContext.getBean("customEmailMappingService"); - } - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setUp() throws Exception - { - super.setUp(); - eMailMappingService.registerEMailMappingKey("EmailMappingKeyTest1"); - eMailMappingService.registerEMailMappingKey("EmailMappingKeyTest2"); - } - - public void testCRUD() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - // Check the initial custom mapping size - assertTrue(checkCustomMappingsSize(20)); - - String firstKey = eMailMappingService.getEmailMappingKeys().get(0); - - // Add a custom mapping - eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); - - // Check the new size - assertTrue(checkCustomMappingsSize(21)); - - // Check the new added custom mapping - CustomMapping monkeyMapping = getCustomMapping(firstKey, "cm:monkeyFace"); - assertNotNull(monkeyMapping); - assertEquals(firstKey, monkeyMapping.getFrom()); - assertEquals("cm:monkeyFace", monkeyMapping.getTo()); - - // Delete the new added custom mapping - eMailMappingService.deleteCustomMapping(firstKey, "cm:monkeyFace"); - - // Check the size after deletion - assertTrue(checkCustomMappingsSize(20)); - - // Check the custom mapping after deletion if it exists - assertNull(getCustomMapping(firstKey, "cm:monkeyFace")); - - // Check the email mapping keys size - // There are 6 "standard" EmailMappingKeys + 2 CustomEmailMappingKeys are added on setUp - assertTrue(checkEmailMappingKeysSize(8)); - - try - { - eMailMappingService.addCustomMapping(" ", "cm:monkeyFace"); - fail("Should not get here. Invalid data."); - } - catch (AlfrescoRuntimeException are) - { - assertNotNull(are); //Must throw this exception - assertTrue(are.getMessage().contains("Invalid values for")); - } - - try - { - eMailMappingService.addCustomMapping("monkey", " "); - fail("Should not get here. Invalid data."); - } - catch (AlfrescoRuntimeException are) - { - assertNotNull(are); //Must throw this exception - assertTrue(are.getMessage().contains("Invalid values for")); - } - - eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); //valid key - - return null; - } - }, ADMIN_USER); - } - - private CustomMapping getCustomMapping(String from, String to) - { - CustomMapping result = null; - for (CustomMapping customMapping : eMailMappingService.getCustomMappings()) - { - if (customMapping.getFrom().equalsIgnoreCase(from) && customMapping.getTo().equalsIgnoreCase(to)) - { - result = customMapping; - break; - } - } - return result; - } - - private boolean checkCustomMappingsSize(int expected) - { - return expected == eMailMappingService.getCustomMappings().size() ? true : false; - } - - private boolean checkEmailMappingKeysSize(int expected) - { - return expected == eMailMappingService.getEmailMappingKeys().size() ? true : false; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.alfresco.module.org_alfresco_module_rm.email.CustomMapping; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Custom EMail Mapping Service + * + * @author Roy Wetherall + * @since 2.0 + */ +public class CustomEMailMappingServiceImplTest extends BaseRMTestCase +{ + private CustomEmailMappingService eMailMappingService; + + @Override + protected void initServices() + { + super.initServices(); + + eMailMappingService = (CustomEmailMappingService)applicationContext.getBean("customEmailMappingService"); + } + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setUp() throws Exception + { + super.setUp(); + eMailMappingService.registerEMailMappingKey("EmailMappingKeyTest1"); + eMailMappingService.registerEMailMappingKey("EmailMappingKeyTest2"); + } + + public void testCRUD() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + // Check the initial custom mapping size + assertTrue(checkCustomMappingsSize(20)); + + String firstKey = eMailMappingService.getEmailMappingKeys().get(0); + + // Add a custom mapping + eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); + + // Check the new size + assertTrue(checkCustomMappingsSize(21)); + + // Check the new added custom mapping + CustomMapping monkeyMapping = getCustomMapping(firstKey, "cm:monkeyFace"); + assertNotNull(monkeyMapping); + assertEquals(firstKey, monkeyMapping.getFrom()); + assertEquals("cm:monkeyFace", monkeyMapping.getTo()); + + // Delete the new added custom mapping + eMailMappingService.deleteCustomMapping(firstKey, "cm:monkeyFace"); + + // Check the size after deletion + assertTrue(checkCustomMappingsSize(20)); + + // Check the custom mapping after deletion if it exists + assertNull(getCustomMapping(firstKey, "cm:monkeyFace")); + + // Check the email mapping keys size + // There are 6 "standard" EmailMappingKeys + 2 CustomEmailMappingKeys are added on setUp + assertTrue(checkEmailMappingKeysSize(8)); + + try + { + eMailMappingService.addCustomMapping(" ", "cm:monkeyFace"); + fail("Should not get here. Invalid data."); + } + catch (AlfrescoRuntimeException are) + { + assertNotNull(are); //Must throw this exception + assertTrue(are.getMessage().contains("Invalid values for")); + } + + try + { + eMailMappingService.addCustomMapping("monkey", " "); + fail("Should not get here. Invalid data."); + } + catch (AlfrescoRuntimeException are) + { + assertNotNull(are); //Must throw this exception + assertTrue(are.getMessage().contains("Invalid values for")); + } + + eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); //valid key + + return null; + } + }, ADMIN_USER); + } + + private CustomMapping getCustomMapping(String from, String to) + { + CustomMapping result = null; + for (CustomMapping customMapping : eMailMappingService.getCustomMappings()) + { + if (customMapping.getFrom().equalsIgnoreCase(from) && customMapping.getTo().equalsIgnoreCase(to)) + { + result = customMapping; + break; + } + } + return result; + } + + private boolean checkCustomMappingsSize(int expected) + { + return expected == eMailMappingService.getCustomMappings().size() ? true : false; + } + + private boolean checkEmailMappingKeysSize(int expected) + { + return expected == eMailMappingService.getEmailMappingKeys().size() ? true : false; + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DataSetServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DataSetServiceImplTest.java index 668cb5e66c..357001ba14 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DataSetServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DataSetServiceImplTest.java @@ -1,264 +1,264 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet; -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Dataset Service Test - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class DataSetServiceImplTest extends BaseRMTestCase -{ - /** Id of the test data set*/ - private static final String DATA_SET_ID = "testExampleData"; - - /** - * @see DataSetService#getDataSets() - */ - public void testGetDataSets() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Map dataSets = dataSetService.getDataSets(); - // Test the data sets - assertNotNull(dataSets); - // At least the test data set must exist - assertTrue(dataSets.size() >= 1); - // The test data set must be in the list of available data sets - assertNotNull(dataSets.get(DATA_SET_ID)); - - for (Map.Entry entry : dataSets.entrySet()) - { - // Test the key - String key = entry.getKey(); - assertNotNull(key); - - // Test the value - DataSet dataSet = entry.getValue(); - assertNotNull(dataSet); - - // Test the id - String id = dataSet.getId(); - assertNotNull(id); - assertEquals(id, key); - - // Test the label - String label = dataSet.getLabel(); - assertNotNull(label); - - // Test the path - String path = dataSet.getPath(); - assertNotNull(path); - } - - return null; - } - }); - } - - /** - * @see DataSetService#loadDataSet(String, org.alfresco.service.cmr.repository.NodeRef) - */ - public void testLoadDataSet() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Test the file plan before importing the data sets - testFilePlanBeforeImportingDataSet(); - - // Load the data set into the specified file plan - dataSetService.loadDataSet(filePlan, DATA_SET_ID); - - // Test the file plan after importing the data sets - testFilePlanAfterImportingDataSet(); - - return null; - } - - /** - * Helper method for testing the test file plan before importing the data - */ - private void testFilePlanBeforeImportingDataSet() - { - // There should not be any categories before importing - assertNull(nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory1")); - assertNull(nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory2")); - - // The aspect should exist before loading a data set - assertNull(nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS)); - - // At the beginning the file plan is empty. So there should not be any data sets - assertTrue(dataSetService.getLoadedDataSets(filePlan).size() == 0); - assertFalse(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID)); - assertTrue(dataSetService.getDataSets(filePlan, true).size() > 0); - assertTrue(dataSetService.getDataSets(filePlan, false).size() > 0); - } - - /** - * Helper method for testing the test file plan after importing the data - */ - private void testFilePlanAfterImportingDataSet() - { - // Test the "first level" categories after importing if they exist - // TestRecordCategory1 - NodeRef recCat1 = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory1"); - assertNotNull(recCat1); - List recCat1ImmediateChildren = filePlanService.getAllContained(recCat1); - assertTrue(recCat1ImmediateChildren.size() == 3); - List recCat1AllChildren = filePlanService.getAllContained(recCat1, true); - assertTrue(recCat1AllChildren.size() == 6); - DispositionSchedule recCat1DispositionSchedule = dispositionService.getDispositionSchedule(recCat1); - assertNull(recCat1DispositionSchedule); - - // TestRecordCategory2 - NodeRef recCat2 = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory2"); - assertNotNull(recCat2); - List recCat2ImmediateChildren = filePlanService.getAllContained(recCat2); - assertTrue(recCat2ImmediateChildren.size() == 2); - List recCat2AllChildren = filePlanService.getAllContained(recCat2, true); - assertTrue(recCat2AllChildren.size() == 4); - DispositionSchedule recCat2DispositionSchedule = dispositionService.getDispositionSchedule(recCat2); - assertNull(recCat2DispositionSchedule); - - // TestRecordCategory1: Test the "second level" categories and record folders - NodeRef recCat11 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory11"); - assertNotNull(recCat11); - List recCat11ImmediateChilderen = filePlanService.getAllContained(recCat11); - assertTrue(recCat11ImmediateChilderen.size() == 2); - List recCat11Childeren = filePlanService.getAllContained(recCat11, true); - assertTrue(recCat11Childeren.size() == 2); - assertNotNull(nodeService.getChildByName(recCat11, ContentModel.ASSOC_CONTAINS, "TestRecordFolder1")); - assertNotNull(nodeService.getChildByName(recCat11, ContentModel.ASSOC_CONTAINS, "TestRecordFolder2")); - VitalRecordDefinition recCat11VitalRecordDefinition = vitalRecordService.getVitalRecordDefinition(recCat11); - assertNotNull(recCat11VitalRecordDefinition); - assertTrue(recCat11VitalRecordDefinition.getReviewPeriod().getExpression().equals("1")); - assertNotNull(recCat11VitalRecordDefinition.getNextReviewDate()); - - NodeRef recCat12 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory12"); - assertNotNull(recCat12); - List recCat12ImmediateChildren = filePlanService.getAllContained(recCat12); - assertTrue(recCat12ImmediateChildren.size() == 1); - List recCat12Children = filePlanService.getAllContained(recCat12, true); - assertTrue(recCat12Children.size() == 1); - assertNotNull(nodeService.getChildByName(recCat12, ContentModel.ASSOC_CONTAINS, "TestRecordFolder3")); - DispositionSchedule recCat12DispositionSchedule = dispositionService.getDispositionSchedule(recCat12); - assertNotNull(recCat12DispositionSchedule); - assertTrue(recCat12DispositionSchedule.getDispositionInstructions().equals("Cut off every 3 months, hold 3 months, then destroy.")); - assertTrue(recCat12DispositionSchedule.getDispositionAuthority().equals("T0-000-00-1 item 002")); - assertTrue(recCat12DispositionSchedule.getDispositionActionDefinitions().size() == 2); - assertNotNull(recCat12DispositionSchedule.getDispositionActionDefinitionByName("cutoff")); - assertNotNull(recCat12DispositionSchedule.getDispositionActionDefinitionByName("destroy")); - - NodeRef recCat13 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory13"); - assertNotNull(recCat13); - List recCat13ImmediateChildren = filePlanService.getAllContained(recCat13); - assertTrue(recCat13ImmediateChildren.size() == 0); - DispositionSchedule recCat13DispositionSchedule = dispositionService.getDispositionSchedule(recCat13); - assertNotNull(recCat13DispositionSchedule); - - // TestRecordCategory2: Test the "second level" categories and record folders - NodeRef recCat21 = nodeService.getChildByName(recCat2, ContentModel.ASSOC_CONTAINS, "TestRecordCategory21"); - assertNotNull(recCat21); - List recCat21ImmediateChildren = filePlanService.getAllContained(recCat21); - assertTrue(recCat21ImmediateChildren.size() == 0); - DispositionSchedule recCat21DispositionSchedule = dispositionService.getDispositionSchedule(recCat21); - assertNotNull(recCat21DispositionSchedule); - - NodeRef recCat22 = nodeService.getChildByName(recCat2, ContentModel.ASSOC_CONTAINS, "TestRecordCategory22"); - assertNotNull(recCat22); - List recCat22ImmediateChildren = filePlanService.getAllContained(recCat22); - assertTrue(recCat22ImmediateChildren.size() == 2); - List recCat22Children = filePlanService.getAllContained(recCat22, true); - assertTrue(recCat22Children.size() == 2); - assertNotNull(nodeService.getChildByName(recCat22, ContentModel.ASSOC_CONTAINS, "TestRecordFolder4")); - assertNotNull(nodeService.getChildByName(recCat22, ContentModel.ASSOC_CONTAINS, "TestRecordFolder5")); - DispositionSchedule recCat22DispositionSchedule = dispositionService.getDispositionSchedule(recCat22); - assertNotNull(recCat22DispositionSchedule); - - // After loading the data set into the file plan the custom aspect should contain the id of the loaded data set - Serializable nodeProperty = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); - assertNotNull(nodeProperty); - @SuppressWarnings("unchecked") - ArrayList loadedDataSetIds = (ArrayList)nodeProperty; - assertTrue(loadedDataSetIds.size() == 1); - assertTrue(loadedDataSetIds.contains(DATA_SET_ID)); - - // The data set has been loaded into the file plan, so the file plan should contain the data set id - Map loadedDataSets = dataSetService.getLoadedDataSets(filePlan); - assertTrue(loadedDataSets.size() == 1); - assertTrue(loadedDataSets.containsKey(DATA_SET_ID)); - assertTrue(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID)); - assertTrue(dataSetService.getDataSets(filePlan, true).size() > 0); - assertTrue(dataSetService.getDataSets(filePlan, false).size() > 1); - } - }); - } - - /** - * @see DataSetService#existsDataSet(String) - */ - public void testExistsDataSet() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Test if a data set with the specified data set id exists - assertTrue(dataSetService.existsDataSet(DATA_SET_ID)); - assertFalse(dataSetService.existsDataSet("AnotherDataSetId")); - - return null; - } - }); - } - - /* - * INFO: - * - * The tests for - * - * DataSetService#getDataSets(NodeRef, boolean) - * DataSetService#getLoadedDataSets(NodeRef) - * DataSetService#isLoadedDataSet(NodeRef, String) - * - * will be executed in testFilePlanBeforeImportingDataSet() and testFilePlanAfterImportingDataSet(). - */ - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet; +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Dataset Service Test + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class DataSetServiceImplTest extends BaseRMTestCase +{ + /** Id of the test data set*/ + private static final String DATA_SET_ID = "testExampleData"; + + /** + * @see DataSetService#getDataSets() + */ + public void testGetDataSets() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Map dataSets = dataSetService.getDataSets(); + // Test the data sets + assertNotNull(dataSets); + // At least the test data set must exist + assertTrue(dataSets.size() >= 1); + // The test data set must be in the list of available data sets + assertNotNull(dataSets.get(DATA_SET_ID)); + + for (Map.Entry entry : dataSets.entrySet()) + { + // Test the key + String key = entry.getKey(); + assertNotNull(key); + + // Test the value + DataSet dataSet = entry.getValue(); + assertNotNull(dataSet); + + // Test the id + String id = dataSet.getId(); + assertNotNull(id); + assertEquals(id, key); + + // Test the label + String label = dataSet.getLabel(); + assertNotNull(label); + + // Test the path + String path = dataSet.getPath(); + assertNotNull(path); + } + + return null; + } + }); + } + + /** + * @see DataSetService#loadDataSet(String, org.alfresco.service.cmr.repository.NodeRef) + */ + public void testLoadDataSet() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Test the file plan before importing the data sets + testFilePlanBeforeImportingDataSet(); + + // Load the data set into the specified file plan + dataSetService.loadDataSet(filePlan, DATA_SET_ID); + + // Test the file plan after importing the data sets + testFilePlanAfterImportingDataSet(); + + return null; + } + + /** + * Helper method for testing the test file plan before importing the data + */ + private void testFilePlanBeforeImportingDataSet() + { + // There should not be any categories before importing + assertNull(nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory1")); + assertNull(nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory2")); + + // The aspect should exist before loading a data set + assertNull(nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS)); + + // At the beginning the file plan is empty. So there should not be any data sets + assertTrue(dataSetService.getLoadedDataSets(filePlan).size() == 0); + assertFalse(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID)); + assertTrue(dataSetService.getDataSets(filePlan, true).size() > 0); + assertTrue(dataSetService.getDataSets(filePlan, false).size() > 0); + } + + /** + * Helper method for testing the test file plan after importing the data + */ + private void testFilePlanAfterImportingDataSet() + { + // Test the "first level" categories after importing if they exist + // TestRecordCategory1 + NodeRef recCat1 = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory1"); + assertNotNull(recCat1); + List recCat1ImmediateChildren = filePlanService.getAllContained(recCat1); + assertTrue(recCat1ImmediateChildren.size() == 3); + List recCat1AllChildren = filePlanService.getAllContained(recCat1, true); + assertTrue(recCat1AllChildren.size() == 6); + DispositionSchedule recCat1DispositionSchedule = dispositionService.getDispositionSchedule(recCat1); + assertNull(recCat1DispositionSchedule); + + // TestRecordCategory2 + NodeRef recCat2 = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, "TestRecordCategory2"); + assertNotNull(recCat2); + List recCat2ImmediateChildren = filePlanService.getAllContained(recCat2); + assertTrue(recCat2ImmediateChildren.size() == 2); + List recCat2AllChildren = filePlanService.getAllContained(recCat2, true); + assertTrue(recCat2AllChildren.size() == 4); + DispositionSchedule recCat2DispositionSchedule = dispositionService.getDispositionSchedule(recCat2); + assertNull(recCat2DispositionSchedule); + + // TestRecordCategory1: Test the "second level" categories and record folders + NodeRef recCat11 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory11"); + assertNotNull(recCat11); + List recCat11ImmediateChilderen = filePlanService.getAllContained(recCat11); + assertTrue(recCat11ImmediateChilderen.size() == 2); + List recCat11Childeren = filePlanService.getAllContained(recCat11, true); + assertTrue(recCat11Childeren.size() == 2); + assertNotNull(nodeService.getChildByName(recCat11, ContentModel.ASSOC_CONTAINS, "TestRecordFolder1")); + assertNotNull(nodeService.getChildByName(recCat11, ContentModel.ASSOC_CONTAINS, "TestRecordFolder2")); + VitalRecordDefinition recCat11VitalRecordDefinition = vitalRecordService.getVitalRecordDefinition(recCat11); + assertNotNull(recCat11VitalRecordDefinition); + assertTrue(recCat11VitalRecordDefinition.getReviewPeriod().getExpression().equals("1")); + assertNotNull(recCat11VitalRecordDefinition.getNextReviewDate()); + + NodeRef recCat12 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory12"); + assertNotNull(recCat12); + List recCat12ImmediateChildren = filePlanService.getAllContained(recCat12); + assertTrue(recCat12ImmediateChildren.size() == 1); + List recCat12Children = filePlanService.getAllContained(recCat12, true); + assertTrue(recCat12Children.size() == 1); + assertNotNull(nodeService.getChildByName(recCat12, ContentModel.ASSOC_CONTAINS, "TestRecordFolder3")); + DispositionSchedule recCat12DispositionSchedule = dispositionService.getDispositionSchedule(recCat12); + assertNotNull(recCat12DispositionSchedule); + assertTrue(recCat12DispositionSchedule.getDispositionInstructions().equals("Cut off every 3 months, hold 3 months, then destroy.")); + assertTrue(recCat12DispositionSchedule.getDispositionAuthority().equals("T0-000-00-1 item 002")); + assertTrue(recCat12DispositionSchedule.getDispositionActionDefinitions().size() == 2); + assertNotNull(recCat12DispositionSchedule.getDispositionActionDefinitionByName("cutoff")); + assertNotNull(recCat12DispositionSchedule.getDispositionActionDefinitionByName("destroy")); + + NodeRef recCat13 = nodeService.getChildByName(recCat1, ContentModel.ASSOC_CONTAINS, "TestRecordCategory13"); + assertNotNull(recCat13); + List recCat13ImmediateChildren = filePlanService.getAllContained(recCat13); + assertTrue(recCat13ImmediateChildren.size() == 0); + DispositionSchedule recCat13DispositionSchedule = dispositionService.getDispositionSchedule(recCat13); + assertNotNull(recCat13DispositionSchedule); + + // TestRecordCategory2: Test the "second level" categories and record folders + NodeRef recCat21 = nodeService.getChildByName(recCat2, ContentModel.ASSOC_CONTAINS, "TestRecordCategory21"); + assertNotNull(recCat21); + List recCat21ImmediateChildren = filePlanService.getAllContained(recCat21); + assertTrue(recCat21ImmediateChildren.size() == 0); + DispositionSchedule recCat21DispositionSchedule = dispositionService.getDispositionSchedule(recCat21); + assertNotNull(recCat21DispositionSchedule); + + NodeRef recCat22 = nodeService.getChildByName(recCat2, ContentModel.ASSOC_CONTAINS, "TestRecordCategory22"); + assertNotNull(recCat22); + List recCat22ImmediateChildren = filePlanService.getAllContained(recCat22); + assertTrue(recCat22ImmediateChildren.size() == 2); + List recCat22Children = filePlanService.getAllContained(recCat22, true); + assertTrue(recCat22Children.size() == 2); + assertNotNull(nodeService.getChildByName(recCat22, ContentModel.ASSOC_CONTAINS, "TestRecordFolder4")); + assertNotNull(nodeService.getChildByName(recCat22, ContentModel.ASSOC_CONTAINS, "TestRecordFolder5")); + DispositionSchedule recCat22DispositionSchedule = dispositionService.getDispositionSchedule(recCat22); + assertNotNull(recCat22DispositionSchedule); + + // After loading the data set into the file plan the custom aspect should contain the id of the loaded data set + Serializable nodeProperty = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS); + assertNotNull(nodeProperty); + @SuppressWarnings("unchecked") + ArrayList loadedDataSetIds = (ArrayList)nodeProperty; + assertTrue(loadedDataSetIds.size() == 1); + assertTrue(loadedDataSetIds.contains(DATA_SET_ID)); + + // The data set has been loaded into the file plan, so the file plan should contain the data set id + Map loadedDataSets = dataSetService.getLoadedDataSets(filePlan); + assertTrue(loadedDataSets.size() == 1); + assertTrue(loadedDataSets.containsKey(DATA_SET_ID)); + assertTrue(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID)); + assertTrue(dataSetService.getDataSets(filePlan, true).size() > 0); + assertTrue(dataSetService.getDataSets(filePlan, false).size() > 1); + } + }); + } + + /** + * @see DataSetService#existsDataSet(String) + */ + public void testExistsDataSet() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Test if a data set with the specified data set id exists + assertTrue(dataSetService.existsDataSet(DATA_SET_ID)); + assertFalse(dataSetService.existsDataSet("AnotherDataSetId")); + + return null; + } + }); + } + + /* + * INFO: + * + * The tests for + * + * DataSetService#getDataSets(NodeRef, boolean) + * DataSetService#getLoadedDataSets(NodeRef) + * DataSetService#isLoadedDataSet(NodeRef, String) + * + * will be executed in testFilePlanBeforeImportingDataSet() and testFilePlanAfterImportingDataSet(). + */ + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java index a2cdf3cdb7..e3853bfc30 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java @@ -1,1023 +1,1023 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; -import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; -import org.alfresco.module.org_alfresco_module_rm.job.PublishUpdatesJobExecuter; -import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor; -import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Disposition service implementation unit test. - * - * @author Roy Wetherall - */ -public class DispositionServiceImplTest extends BaseRMTestCase -{ - @Override - protected boolean isMultiHierarchyTest() - { - return true; - } - - public void testGetDispositionProperties() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Collection properties = dispositionService.getDispositionProperties(); - - assertNotNull(properties); - assertEquals(5, properties.size()); - - for (DispositionProperty property : properties) - { - assertNotNull(property.getQName()); - assertNotNull(property.getPropertyDefinition()); - } - - return null; - } - }); - } - - /** - * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) - */ - public void testGetDispositionSchedule() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Check for null lookup's - assertNull(dispositionService.getDispositionSchedule(filePlan)); - - // Get the containers disposition schedule - DispositionSchedule ds = dispositionService.getDispositionSchedule(rmContainer); - assertNotNull(ds); - checkDispositionSchedule(ds, false); - - // Get the folders disposition schedule - ds = dispositionService.getDispositionSchedule(rmContainer); - assertNotNull(ds); - checkDispositionSchedule(ds, false); - - return null; - } - - }); - - // Failure: Root node - doTestInTransaction(new FailureTest - ( - "Should not be able to get adisposition schedule for the root node", - AlfrescoRuntimeException.class - ) - { - @Override - public void run() - { - dispositionService.getDispositionSchedule(rootNodeRef); - } - }); - - // Failure: Non-rm node - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - dispositionService.getDispositionSchedule(folder); - } - }); - } - - /** - * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) - */ - public void testGetDispositionScheduleMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNull(dispositionService.getDispositionSchedule(mhContainer)); - - // Level 1 - doCheck(mhContainer11, "ds11", false); - doCheck(mhContainer12, "ds12", false); - - // Level 2 - doCheck(mhContainer21, "ds11", false); - doCheck(mhContainer22, "ds12", false); - doCheck(mhContainer23, "ds23", false); - - // Level 3 - doCheck(mhContainer31, "ds11", false); - doCheck(mhContainer32, "ds12", false); - doCheck(mhContainer33, "ds33", true); - doCheck(mhContainer34, "ds23", false); - doCheck(mhContainer35, "ds35", true); - - // Folders - doCheckFolder(mhRecordFolder41, "ds11", false); - doCheckFolder(mhRecordFolder42, "ds12", false); - doCheckFolder(mhRecordFolder43, "ds33", true); - doCheckFolder(mhRecordFolder44, "ds23", false); - doCheckFolder(mhRecordFolder45, "ds35", true); - - return null; - } - - private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) - { - DispositionSchedule ds = dispositionService.getDispositionSchedule(container); - assertNotNull(ds); - checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); - } - - private void doCheckFolder(NodeRef container, String dispositionInstructions, boolean isRecordLevel) - { - doCheck(container, dispositionInstructions, isRecordLevel); - if (!isRecordLevel) - { - assertNotNull(dispositionService.getNextDispositionAction(container)); - } - } - }); - - } - - /** - * Checks a disposition schedule - * - * @param ds disposition scheduleS - */ - private void checkDispositionSchedule(DispositionSchedule ds, String dispositionInstructions, String dispositionAuthority, boolean isRecordLevel) - { - assertEquals(dispositionAuthority, ds.getDispositionAuthority()); - assertEquals(dispositionInstructions, ds.getDispositionInstructions()); - assertEquals(isRecordLevel, ds.isRecordLevelDisposition()); - - List defs = ds.getDispositionActionDefinitions(); - assertNotNull(defs); - assertEquals(2, defs.size()); - - DispositionActionDefinition defCutoff = ds.getDispositionActionDefinitionByName("cutoff"); - assertNotNull(defCutoff); - assertEquals("cutoff", defCutoff.getName()); - - DispositionActionDefinition defDestroy = ds.getDispositionActionDefinitionByName("destroy"); - assertNotNull(defDestroy); - assertEquals("destroy", defDestroy.getName()); - } - - /** - * - * @param ds - */ - private void checkDispositionSchedule(DispositionSchedule ds, boolean isRecordLevel) - { - checkDispositionSchedule(ds, CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); - } - - /** - * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) - */ - public void testGetAssociatedDispositionSchedule() throws Exception - { - // Get associated disposition schedule for rmContainer - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Get the containers disposition schedule - DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(rmContainer); - assertNotNull(ds); - checkDispositionSchedule(ds, false); - - // Show the null disposition schedules - assertNull(dispositionService.getAssociatedDispositionSchedule(filePlan)); - assertNull(dispositionService.getAssociatedDispositionSchedule(rmFolder)); - - return null; - } - }); - - // Failure: associated disposition schedule for non-rm node - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - dispositionService.getAssociatedDispositionSchedule(folder); - } - }); - } - - /** - * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) - */ - public void testGetAssociatedDispositionScheduleMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer)); - - // Level 1 - doCheck(mhContainer11, "ds11", false); - doCheck(mhContainer12, "ds12", false); - - // Level 2 - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer21)); - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer22)); - doCheck(mhContainer23, "ds23", false); - - // Level 3 - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer31)); - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer32)); - doCheck(mhContainer33, "ds33", true); - assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer34)); - doCheck(mhContainer35, "ds35", true); - - return null; - } - - private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) - { - DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(container); - assertNotNull(ds); - checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); - } - }); - } - - /** - * @see DispositionService#hasDisposableItems(DispositionSchedule) - */ - public void testHasDisposableItems() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add a new disposition schedule - NodeRef container = filePlanService.createRecordCategory(rmContainer, "hasDisposableTest"); - DispositionSchedule ds = utils.createBasicDispositionSchedule(container); - - assertTrue(dispositionService.hasDisposableItems(dispositionSchedule)); - assertFalse(dispositionService.hasDisposableItems(ds)); - - return null; - } - }); - } - - /** - * @see DispositionService#hasDisposableItems(DispositionSchedule) - */ - public void testHasDisposableItemsMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule11)); - assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule12)); - assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule23)); - assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule33)); - assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule35)); - - return null; - } - }); - } - - /** - * @see DispositionService#getDisposableItems(DispositionSchedule) - */ - public void testGetDisposableItems() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List nodeRefs = dispositionService.getDisposableItems(dispositionSchedule); - assertNotNull(nodeRefs); - assertEquals(1, nodeRefs.size()); - assertTrue(nodeRefs.contains(rmFolder)); - - return null; - } - }); - } - - /** - * @see DispositionService#getDisposableItems(DispositionSchedule) - */ - public void testGetDisposableItemsMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule11); - assertNotNull(nodeRefs); - assertEquals(1, nodeRefs.size()); - assertTrue(nodeRefs.contains(mhRecordFolder41)); - - nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule12); - assertNotNull(nodeRefs); - assertEquals(1, nodeRefs.size()); - assertTrue(nodeRefs.contains(mhRecordFolder42)); - - nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule23); - assertNotNull(nodeRefs); - assertEquals(1, nodeRefs.size()); - assertTrue(nodeRefs.contains(mhRecordFolder44)); - - nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule33); - assertNotNull(nodeRefs); - assertEquals(0, nodeRefs.size()); - - nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule35); - assertNotNull(nodeRefs); - assertEquals(0, nodeRefs.size()); - - return null; - } - }); - } - - /** - * @see DispositionService#createDispositionSchedule(NodeRef, Map) - */ - public void testCreateDispositionSchedule() throws Exception - { - // Test: simple disposition create - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - // Create a new container - NodeRef container = filePlanService.createRecordCategory(filePlan, "testCreateDispositionSchedule"); - - // Create a new disposition schedule - utils.createBasicDispositionSchedule(container, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false, true); - - return container; - } - - @Override - public void test(NodeRef result) throws Exception - { - // Get the created disposition schedule - DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(result); - assertNotNull(ds); - - // Check the disposition schedule - checkDispositionSchedule(ds, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false); - } - }); - - // Failure: create disposition schedule on container with existing disposition schedule - doTestInTransaction(new FailureTest - ( - "Can not create a disposition schedule on a container with an existing disposition schedule" - ) - { - @Override - public void run() - { - utils.createBasicDispositionSchedule(rmContainer); - } - }); - } - - /** - * @see DispositionService#createDispositionSchedule(NodeRef, Map) - */ - public void testCreateDispositionScheduleMultiHier() throws Exception - { - // Test: simple disposition create - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Create a new structure container - NodeRef testA = filePlanService.createRecordCategory(mhContainer, "testA"); - NodeRef testB = filePlanService.createRecordCategory(testA, "testB"); - - // Create new disposition schedules - utils.createBasicDispositionSchedule(testA, "testA", "testA", false, true); - utils.createBasicDispositionSchedule(testB, "testB", "testB", false, true); - - // Add created containers to model - setNodeRef("testA", testA); - setNodeRef("testB", testB); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Get the created disposition schedule - DispositionSchedule testA = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testA")); - assertNotNull(testA); - DispositionSchedule testB = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testB")); - assertNotNull(testB); - - // Check the disposition schedule - checkDispositionSchedule(testA, "testA", "testA", false); - checkDispositionSchedule(testB, "testB", "testB", false); - } - }); - - // Failure: create disposition schedule on container with existing disposition schedule - doTestInTransaction(new FailureTest - ( - "Can not create a disposition schedule on container with an existing disposition schedule" - ) - { - @Override - public void run() - { - utils.createBasicDispositionSchedule(mhContainer11); - } - }); - - // Failure: create disposition schedule on a container where there are disposable items under management - doTestInTransaction(new FailureTest - ( - "Can not create a disposition schedule on a container where there are already disposable items under management" - ) - { - @Override - public void run() - { - utils.createBasicDispositionSchedule(mhContainer21); - } - }); - } - - /** - * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) - */ - public void testGetAssociatedRecordsManagementContainer() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - NodeRef nodeRef = dispositionService.getAssociatedRecordsManagementContainer(dispositionSchedule); - assertNotNull(nodeRef); - assertEquals(rmContainer, nodeRef); - - return null; - } - }); - } - - /** - * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) - */ - public void testGetAssociatedRecordsManagementContainerMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - NodeRef nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule11); - assertNotNull(nodeRef); - assertEquals(mhContainer11, nodeRef); - - nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule12); - assertNotNull(nodeRef); - assertEquals(mhContainer12, nodeRef); - - nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule23); - assertNotNull(nodeRef); - assertEquals(mhContainer23, nodeRef); - - nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule33); - assertNotNull(nodeRef); - assertEquals(mhContainer33, nodeRef); - - nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule35); - assertNotNull(nodeRef); - assertEquals(mhContainer35, nodeRef); - - return null; - } - }); - } - - // TODO DispositionActionDefinition addDispositionActionDefinition - - // TODO void removeDispositionActionDefinition( - - private NodeRef record43; - private NodeRef record45; - - public void testUpdateDispositionActionDefinitionMultiHier() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - record43 = utils.createRecord(mhRecordFolder43, "record1.txt"); - record45 = utils.createRecord(mhRecordFolder45, "record2.txt"); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Check all the current record folders first - checkDisposableItemUnchanged(mhRecordFolder41); - checkDisposableItemUnchanged(mhRecordFolder42); - checkDisposableItemUnchanged(record43); - checkDisposableItemUnchanged(mhRecordFolder44); - checkDisposableItemUnchanged(record45); - - updateDispositionScheduleOnContainer(mhContainer11); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Check all the current record folders first - checkDisposableItemChanged(mhRecordFolder41); - checkDisposableItemUnchanged(mhRecordFolder42); - checkDisposableItemUnchanged(record43); - checkDisposableItemUnchanged(mhRecordFolder44); - checkDisposableItemUnchanged(record45);; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - updateDispositionScheduleOnContainer(mhContainer12); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Check all the current record folders first - checkDisposableItemChanged(mhRecordFolder41); - checkDisposableItemChanged(mhRecordFolder42); - checkDisposableItemUnchanged(record43); - checkDisposableItemUnchanged(mhRecordFolder44); - checkDisposableItemUnchanged(record45);; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - updateDispositionScheduleOnContainer(mhContainer33); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Check all the current record folders first - checkDisposableItemChanged(mhRecordFolder41); - checkDisposableItemChanged(mhRecordFolder42); - checkDisposableItemChanged(record43); - checkDisposableItemUnchanged(mhRecordFolder44); - checkDisposableItemUnchanged(record45);; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - updateDispositionScheduleOnContainer(mhContainer23); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Check all the current record folders first - checkDisposableItemChanged(mhRecordFolder41); - checkDisposableItemChanged(mhRecordFolder42); - checkDisposableItemChanged(record43); - checkDisposableItemChanged(mhRecordFolder44); - checkDisposableItemUnchanged(record45); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - updateDispositionScheduleOnContainer(mhContainer35); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - // Check all the current record folders first - checkDisposableItemChanged(mhRecordFolder41); - checkDisposableItemChanged(mhRecordFolder42); - checkDisposableItemChanged(record43); - checkDisposableItemChanged(mhRecordFolder44); - checkDisposableItemChanged(record45); - } - }); - } - - private void publishDispositionActionDefinitionChange(DispositionActionDefinition dad) - { - PublishExecutorRegistry reg = (PublishExecutorRegistry)applicationContext.getBean("publishExecutorRegistry"); - PublishExecutor pub = reg.get(RecordsManagementModel.UPDATE_TO_DISPOSITION_ACTION_DEFINITION); - assertNotNull(pub); - pub.publish(dad.getNodeRef()); - } - - private void checkDisposableItemUnchanged(NodeRef recordFolder) - { - checkDispositionAction( - dispositionService.getNextDispositionAction(recordFolder), - "cutoff", - new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME}, - CommonRMTestUtils.PERIOD_NONE); - } - - private void checkDisposableItemChanged(NodeRef recordFolder) throws Exception - { - checkDispositionAction( - dispositionService.getNextDispositionAction(recordFolder), - "cutoff", - new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"}, - "week|1"); - } - - private void updateDispositionScheduleOnContainer(NodeRef nodeRef) - { - Map updateProps = new HashMap(3); - updateProps.put(PROP_DISPOSITION_PERIOD, "week|1"); - updateProps.put(PROP_DISPOSITION_EVENT, (Serializable)Arrays.asList(CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished")); - - DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); - DispositionActionDefinition dad = ds.getDispositionActionDefinitionByName("cutoff"); - dispositionService.updateDispositionActionDefinition(dad, updateProps); - publishDispositionActionDefinitionChange(dad); - } - - /** - * - * @param da - * @param name - * @param arrEventNames - * @param strPeriod - */ - private void checkDispositionAction(DispositionAction da, String name, String[] arrEventNames, String strPeriod) - { - assertNotNull(da); - assertEquals(name, da.getName()); - - List events = da.getEventCompletionDetails(); - assertNotNull(events); - assertEquals(arrEventNames.length, events.size()); - - List origEvents = new ArrayList(events.size()); - for (EventCompletionDetails event : events) - { - origEvents.add(event.getEventName()); - } - - List expectedEvents = Arrays.asList(arrEventNames); - Collection copy = new ArrayList(origEvents); - - for (Iterator i = origEvents.iterator(); i.hasNext(); ) - { - String origEvent = i.next(); - - if (expectedEvents.contains(origEvent)) - { - i.remove(); - copy.remove(origEvent); - } - } - - if (copy.size() != 0 && expectedEvents.size() != 0) - { - StringBuffer buff = new StringBuffer(255); - if (copy.size() != 0) - { - buff.append("The following events where found, but not expected: ("); - for (String eventName : copy) - { - buff.append(eventName).append(", "); - } - buff.append("). "); - } - if (expectedEvents.size() != 0) - { - buff.append("The following events where not found, but expected: ("); - for (String eventName : expectedEvents) - { - buff.append(eventName).append(", "); - } - buff.append(")."); - } - fail(buff.toString()); - } - - if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod)) - { - assertNull(da.getAsOfDate()); - } - else - { - assertNotNull(da.getAsOfDate()); - } - } - - // TODO boolean isNextDispositionActionEligible(NodeRef nodeRef); - - // TODO DispositionAction getNextDispositionAction(NodeRef nodeRef); - - // TODO List getCompletedDispositionActions(NodeRef nodeRef); - - // TODO DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); - - // TODO List getDispositionPeriodProperties(); - - /* === Issues === */ - - private NodeRef testRM263RecordCategory; - private DispositionSchedule testRM263DispositionSchedule; - private NodeRef testRM263Record; - - /** - * https://issues.alfresco.com/jira/browse/RM-263 - */ - public void testRM_263() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - testRM263RecordCategory = filePlanService.createRecordCategory(rmContainer, "rm263"); - testRM263DispositionSchedule = utils.createBasicDispositionSchedule( - testRM263RecordCategory, - "test", - "test", - true, - false); - - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); - adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); - adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); - adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, DOD5015Model.PROP_PUBLICATION_DATE.toString()); - - dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams); - - NodeRef recordFolder = recordFolderService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder"); - testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record"); - - return null; - } - }); - - doTestInTransaction(new Test() - { - private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf"); - - @Override - public Void run() throws Exception - { - Date pubDate = (Date)nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE); - assertNull(pubDate); - Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); - assertNull(asOfDate); - - DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); - assertNotNull(da); - assertNull(da.getAsOfDate()); - - //rma:recordSearchDispositionActionAsOf" - nodeService.setProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE, new Date()); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - Date pubDate = (Date)nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE); - assertNotNull(pubDate); - Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); - assertNotNull(asOfDate); - - DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); - assertNotNull(da); - assertNotNull(da.getAsOfDate()); - } - }); - } - - private NodeRef testRM386RecordCategory; - private DispositionSchedule testRM386DispositionSchedule; - private NodeRef testRM386Record; - - /** - * Test to make sure all the search rollups are correct after schedule is updated - * @throws Exception - */ - public void testRM386() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - testRM386RecordCategory = filePlanService.createRecordCategory(rmContainer, "RM386"); - testRM386DispositionSchedule = utils.createBasicDispositionSchedule( - testRM386RecordCategory, - "disposition instructions", - "disposition authority", - true, // record level - true); // set the default actions - - NodeRef recordFolder = recordFolderService.createRecordFolder(testRM386RecordCategory, "testRM386RecordFolder"); - testRM386Record = utils.createRecord(recordFolder, "testRM386Record", "testRM386Record"); - - return null; - } - - @SuppressWarnings("unchecked") - @Override - public void test(Void result) throws Exception - { - // Test the rollups for the record - Map properties = nodeService.getProperties(testRM386Record); - - assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); - - assertEquals("none", properties.get(PROP_RS_DISPOSITION_PERIOD)); - assertEquals("0", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); - - List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); - assertNotNull(events); - assertEquals(1, events.size()); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, events.get(0)); - assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - - assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); - assertNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - - doTestInTransaction(new Test() - { - @Override - public DispositionActionDefinition run() throws Exception - { - DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff"); - assertNotNull(actionDefinition); - - Map adParams = new HashMap(3); - - List events = new ArrayList(1); - events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); - events.add("obsolete"); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); - - dispositionService.updateDispositionActionDefinition( - actionDefinition, - adParams); - - return actionDefinition; - } - - @SuppressWarnings("unchecked") - @Override - public void test(DispositionActionDefinition result) throws Exception - { - DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff"); - assertNotNull(actionDefinition); - assertTrue(nodeService.hasAspect(actionDefinition.getNodeRef(), ASPECT_UNPUBLISHED_UPDATE)); - - // Publish the updates - PublishUpdatesJobExecuter updater = (PublishUpdatesJobExecuter)applicationContext.getBean("publishUpdatesJobExecuter"); - updater.executeImpl(); - - assertFalse(nodeService.hasAspect(actionDefinition.getNodeRef(), ASPECT_UNPUBLISHED_UPDATE)); - - // Check the record has been updated - DispositionAction dispositionAction = dispositionService.getNextDispositionAction(testRM386Record); - assertNotNull(dispositionAction); - assertEquals("cutoff", dispositionAction.getName()); - assertNotNull(dispositionAction.getAsOfDate()); - assertEquals(2, dispositionAction.getEventCompletionDetails().size()); - - // Test the rollups for the record - Map properties = nodeService.getProperties(testRM386Record); - - assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); - - assertEquals("week", properties.get(PROP_RS_DISPOSITION_PERIOD)); - assertEquals("1", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); - - List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); - assertNotNull(events); - assertEquals(2, events.size()); - assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - - assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); - assertNotNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - } - }); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; +import org.alfresco.module.org_alfresco_module_rm.job.PublishUpdatesJobExecuter; +import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor; +import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Disposition service implementation unit test. + * + * @author Roy Wetherall + */ +public class DispositionServiceImplTest extends BaseRMTestCase +{ + @Override + protected boolean isMultiHierarchyTest() + { + return true; + } + + public void testGetDispositionProperties() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Collection properties = dispositionService.getDispositionProperties(); + + assertNotNull(properties); + assertEquals(5, properties.size()); + + for (DispositionProperty property : properties) + { + assertNotNull(property.getQName()); + assertNotNull(property.getPropertyDefinition()); + } + + return null; + } + }); + } + + /** + * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testGetDispositionSchedule() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Check for null lookup's + assertNull(dispositionService.getDispositionSchedule(filePlan)); + + // Get the containers disposition schedule + DispositionSchedule ds = dispositionService.getDispositionSchedule(rmContainer); + assertNotNull(ds); + checkDispositionSchedule(ds, false); + + // Get the folders disposition schedule + ds = dispositionService.getDispositionSchedule(rmContainer); + assertNotNull(ds); + checkDispositionSchedule(ds, false); + + return null; + } + + }); + + // Failure: Root node + doTestInTransaction(new FailureTest + ( + "Should not be able to get adisposition schedule for the root node", + AlfrescoRuntimeException.class + ) + { + @Override + public void run() + { + dispositionService.getDispositionSchedule(rootNodeRef); + } + }); + + // Failure: Non-rm node + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + dispositionService.getDispositionSchedule(folder); + } + }); + } + + /** + * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testGetDispositionScheduleMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertNull(dispositionService.getDispositionSchedule(mhContainer)); + + // Level 1 + doCheck(mhContainer11, "ds11", false); + doCheck(mhContainer12, "ds12", false); + + // Level 2 + doCheck(mhContainer21, "ds11", false); + doCheck(mhContainer22, "ds12", false); + doCheck(mhContainer23, "ds23", false); + + // Level 3 + doCheck(mhContainer31, "ds11", false); + doCheck(mhContainer32, "ds12", false); + doCheck(mhContainer33, "ds33", true); + doCheck(mhContainer34, "ds23", false); + doCheck(mhContainer35, "ds35", true); + + // Folders + doCheckFolder(mhRecordFolder41, "ds11", false); + doCheckFolder(mhRecordFolder42, "ds12", false); + doCheckFolder(mhRecordFolder43, "ds33", true); + doCheckFolder(mhRecordFolder44, "ds23", false); + doCheckFolder(mhRecordFolder45, "ds35", true); + + return null; + } + + private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) + { + DispositionSchedule ds = dispositionService.getDispositionSchedule(container); + assertNotNull(ds); + checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); + } + + private void doCheckFolder(NodeRef container, String dispositionInstructions, boolean isRecordLevel) + { + doCheck(container, dispositionInstructions, isRecordLevel); + if (!isRecordLevel) + { + assertNotNull(dispositionService.getNextDispositionAction(container)); + } + } + }); + + } + + /** + * Checks a disposition schedule + * + * @param ds disposition scheduleS + */ + private void checkDispositionSchedule(DispositionSchedule ds, String dispositionInstructions, String dispositionAuthority, boolean isRecordLevel) + { + assertEquals(dispositionAuthority, ds.getDispositionAuthority()); + assertEquals(dispositionInstructions, ds.getDispositionInstructions()); + assertEquals(isRecordLevel, ds.isRecordLevelDisposition()); + + List defs = ds.getDispositionActionDefinitions(); + assertNotNull(defs); + assertEquals(2, defs.size()); + + DispositionActionDefinition defCutoff = ds.getDispositionActionDefinitionByName("cutoff"); + assertNotNull(defCutoff); + assertEquals("cutoff", defCutoff.getName()); + + DispositionActionDefinition defDestroy = ds.getDispositionActionDefinitionByName("destroy"); + assertNotNull(defDestroy); + assertEquals("destroy", defDestroy.getName()); + } + + /** + * + * @param ds + */ + private void checkDispositionSchedule(DispositionSchedule ds, boolean isRecordLevel) + { + checkDispositionSchedule(ds, CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); + } + + /** + * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) + */ + public void testGetAssociatedDispositionSchedule() throws Exception + { + // Get associated disposition schedule for rmContainer + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Get the containers disposition schedule + DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(rmContainer); + assertNotNull(ds); + checkDispositionSchedule(ds, false); + + // Show the null disposition schedules + assertNull(dispositionService.getAssociatedDispositionSchedule(filePlan)); + assertNull(dispositionService.getAssociatedDispositionSchedule(rmFolder)); + + return null; + } + }); + + // Failure: associated disposition schedule for non-rm node + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + dispositionService.getAssociatedDispositionSchedule(folder); + } + }); + } + + /** + * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) + */ + public void testGetAssociatedDispositionScheduleMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer)); + + // Level 1 + doCheck(mhContainer11, "ds11", false); + doCheck(mhContainer12, "ds12", false); + + // Level 2 + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer21)); + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer22)); + doCheck(mhContainer23, "ds23", false); + + // Level 3 + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer31)); + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer32)); + doCheck(mhContainer33, "ds33", true); + assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer34)); + doCheck(mhContainer35, "ds35", true); + + return null; + } + + private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) + { + DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(container); + assertNotNull(ds); + checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); + } + }); + } + + /** + * @see DispositionService#hasDisposableItems(DispositionSchedule) + */ + public void testHasDisposableItems() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add a new disposition schedule + NodeRef container = filePlanService.createRecordCategory(rmContainer, "hasDisposableTest"); + DispositionSchedule ds = utils.createBasicDispositionSchedule(container); + + assertTrue(dispositionService.hasDisposableItems(dispositionSchedule)); + assertFalse(dispositionService.hasDisposableItems(ds)); + + return null; + } + }); + } + + /** + * @see DispositionService#hasDisposableItems(DispositionSchedule) + */ + public void testHasDisposableItemsMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule11)); + assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule12)); + assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule23)); + assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule33)); + assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule35)); + + return null; + } + }); + } + + /** + * @see DispositionService#getDisposableItems(DispositionSchedule) + */ + public void testGetDisposableItems() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List nodeRefs = dispositionService.getDisposableItems(dispositionSchedule); + assertNotNull(nodeRefs); + assertEquals(1, nodeRefs.size()); + assertTrue(nodeRefs.contains(rmFolder)); + + return null; + } + }); + } + + /** + * @see DispositionService#getDisposableItems(DispositionSchedule) + */ + public void testGetDisposableItemsMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule11); + assertNotNull(nodeRefs); + assertEquals(1, nodeRefs.size()); + assertTrue(nodeRefs.contains(mhRecordFolder41)); + + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule12); + assertNotNull(nodeRefs); + assertEquals(1, nodeRefs.size()); + assertTrue(nodeRefs.contains(mhRecordFolder42)); + + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule23); + assertNotNull(nodeRefs); + assertEquals(1, nodeRefs.size()); + assertTrue(nodeRefs.contains(mhRecordFolder44)); + + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule33); + assertNotNull(nodeRefs); + assertEquals(0, nodeRefs.size()); + + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule35); + assertNotNull(nodeRefs); + assertEquals(0, nodeRefs.size()); + + return null; + } + }); + } + + /** + * @see DispositionService#createDispositionSchedule(NodeRef, Map) + */ + public void testCreateDispositionSchedule() throws Exception + { + // Test: simple disposition create + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // Create a new container + NodeRef container = filePlanService.createRecordCategory(filePlan, "testCreateDispositionSchedule"); + + // Create a new disposition schedule + utils.createBasicDispositionSchedule(container, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false, true); + + return container; + } + + @Override + public void test(NodeRef result) throws Exception + { + // Get the created disposition schedule + DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(result); + assertNotNull(ds); + + // Check the disposition schedule + checkDispositionSchedule(ds, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false); + } + }); + + // Failure: create disposition schedule on container with existing disposition schedule + doTestInTransaction(new FailureTest + ( + "Can not create a disposition schedule on a container with an existing disposition schedule" + ) + { + @Override + public void run() + { + utils.createBasicDispositionSchedule(rmContainer); + } + }); + } + + /** + * @see DispositionService#createDispositionSchedule(NodeRef, Map) + */ + public void testCreateDispositionScheduleMultiHier() throws Exception + { + // Test: simple disposition create + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Create a new structure container + NodeRef testA = filePlanService.createRecordCategory(mhContainer, "testA"); + NodeRef testB = filePlanService.createRecordCategory(testA, "testB"); + + // Create new disposition schedules + utils.createBasicDispositionSchedule(testA, "testA", "testA", false, true); + utils.createBasicDispositionSchedule(testB, "testB", "testB", false, true); + + // Add created containers to model + setNodeRef("testA", testA); + setNodeRef("testB", testB); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Get the created disposition schedule + DispositionSchedule testA = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testA")); + assertNotNull(testA); + DispositionSchedule testB = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testB")); + assertNotNull(testB); + + // Check the disposition schedule + checkDispositionSchedule(testA, "testA", "testA", false); + checkDispositionSchedule(testB, "testB", "testB", false); + } + }); + + // Failure: create disposition schedule on container with existing disposition schedule + doTestInTransaction(new FailureTest + ( + "Can not create a disposition schedule on container with an existing disposition schedule" + ) + { + @Override + public void run() + { + utils.createBasicDispositionSchedule(mhContainer11); + } + }); + + // Failure: create disposition schedule on a container where there are disposable items under management + doTestInTransaction(new FailureTest + ( + "Can not create a disposition schedule on a container where there are already disposable items under management" + ) + { + @Override + public void run() + { + utils.createBasicDispositionSchedule(mhContainer21); + } + }); + } + + /** + * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) + */ + public void testGetAssociatedRecordsManagementContainer() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef nodeRef = dispositionService.getAssociatedRecordsManagementContainer(dispositionSchedule); + assertNotNull(nodeRef); + assertEquals(rmContainer, nodeRef); + + return null; + } + }); + } + + /** + * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) + */ + public void testGetAssociatedRecordsManagementContainerMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule11); + assertNotNull(nodeRef); + assertEquals(mhContainer11, nodeRef); + + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule12); + assertNotNull(nodeRef); + assertEquals(mhContainer12, nodeRef); + + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule23); + assertNotNull(nodeRef); + assertEquals(mhContainer23, nodeRef); + + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule33); + assertNotNull(nodeRef); + assertEquals(mhContainer33, nodeRef); + + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule35); + assertNotNull(nodeRef); + assertEquals(mhContainer35, nodeRef); + + return null; + } + }); + } + + // TODO DispositionActionDefinition addDispositionActionDefinition + + // TODO void removeDispositionActionDefinition( + + private NodeRef record43; + private NodeRef record45; + + public void testUpdateDispositionActionDefinitionMultiHier() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + record43 = utils.createRecord(mhRecordFolder43, "record1.txt"); + record45 = utils.createRecord(mhRecordFolder45, "record2.txt"); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Check all the current record folders first + checkDisposableItemUnchanged(mhRecordFolder41); + checkDisposableItemUnchanged(mhRecordFolder42); + checkDisposableItemUnchanged(record43); + checkDisposableItemUnchanged(mhRecordFolder44); + checkDisposableItemUnchanged(record45); + + updateDispositionScheduleOnContainer(mhContainer11); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Check all the current record folders first + checkDisposableItemChanged(mhRecordFolder41); + checkDisposableItemUnchanged(mhRecordFolder42); + checkDisposableItemUnchanged(record43); + checkDisposableItemUnchanged(mhRecordFolder44); + checkDisposableItemUnchanged(record45);; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + updateDispositionScheduleOnContainer(mhContainer12); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Check all the current record folders first + checkDisposableItemChanged(mhRecordFolder41); + checkDisposableItemChanged(mhRecordFolder42); + checkDisposableItemUnchanged(record43); + checkDisposableItemUnchanged(mhRecordFolder44); + checkDisposableItemUnchanged(record45);; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + updateDispositionScheduleOnContainer(mhContainer33); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Check all the current record folders first + checkDisposableItemChanged(mhRecordFolder41); + checkDisposableItemChanged(mhRecordFolder42); + checkDisposableItemChanged(record43); + checkDisposableItemUnchanged(mhRecordFolder44); + checkDisposableItemUnchanged(record45);; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + updateDispositionScheduleOnContainer(mhContainer23); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Check all the current record folders first + checkDisposableItemChanged(mhRecordFolder41); + checkDisposableItemChanged(mhRecordFolder42); + checkDisposableItemChanged(record43); + checkDisposableItemChanged(mhRecordFolder44); + checkDisposableItemUnchanged(record45); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + updateDispositionScheduleOnContainer(mhContainer35); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + // Check all the current record folders first + checkDisposableItemChanged(mhRecordFolder41); + checkDisposableItemChanged(mhRecordFolder42); + checkDisposableItemChanged(record43); + checkDisposableItemChanged(mhRecordFolder44); + checkDisposableItemChanged(record45); + } + }); + } + + private void publishDispositionActionDefinitionChange(DispositionActionDefinition dad) + { + PublishExecutorRegistry reg = (PublishExecutorRegistry)applicationContext.getBean("publishExecutorRegistry"); + PublishExecutor pub = reg.get(RecordsManagementModel.UPDATE_TO_DISPOSITION_ACTION_DEFINITION); + assertNotNull(pub); + pub.publish(dad.getNodeRef()); + } + + private void checkDisposableItemUnchanged(NodeRef recordFolder) + { + checkDispositionAction( + dispositionService.getNextDispositionAction(recordFolder), + "cutoff", + new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME}, + CommonRMTestUtils.PERIOD_NONE); + } + + private void checkDisposableItemChanged(NodeRef recordFolder) throws Exception + { + checkDispositionAction( + dispositionService.getNextDispositionAction(recordFolder), + "cutoff", + new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"}, + "week|1"); + } + + private void updateDispositionScheduleOnContainer(NodeRef nodeRef) + { + Map updateProps = new HashMap(3); + updateProps.put(PROP_DISPOSITION_PERIOD, "week|1"); + updateProps.put(PROP_DISPOSITION_EVENT, (Serializable)Arrays.asList(CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished")); + + DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); + DispositionActionDefinition dad = ds.getDispositionActionDefinitionByName("cutoff"); + dispositionService.updateDispositionActionDefinition(dad, updateProps); + publishDispositionActionDefinitionChange(dad); + } + + /** + * + * @param da + * @param name + * @param arrEventNames + * @param strPeriod + */ + private void checkDispositionAction(DispositionAction da, String name, String[] arrEventNames, String strPeriod) + { + assertNotNull(da); + assertEquals(name, da.getName()); + + List events = da.getEventCompletionDetails(); + assertNotNull(events); + assertEquals(arrEventNames.length, events.size()); + + List origEvents = new ArrayList(events.size()); + for (EventCompletionDetails event : events) + { + origEvents.add(event.getEventName()); + } + + List expectedEvents = Arrays.asList(arrEventNames); + Collection copy = new ArrayList(origEvents); + + for (Iterator i = origEvents.iterator(); i.hasNext(); ) + { + String origEvent = i.next(); + + if (expectedEvents.contains(origEvent)) + { + i.remove(); + copy.remove(origEvent); + } + } + + if (copy.size() != 0 && expectedEvents.size() != 0) + { + StringBuffer buff = new StringBuffer(255); + if (copy.size() != 0) + { + buff.append("The following events where found, but not expected: ("); + for (String eventName : copy) + { + buff.append(eventName).append(", "); + } + buff.append("). "); + } + if (expectedEvents.size() != 0) + { + buff.append("The following events where not found, but expected: ("); + for (String eventName : expectedEvents) + { + buff.append(eventName).append(", "); + } + buff.append(")."); + } + fail(buff.toString()); + } + + if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod)) + { + assertNull(da.getAsOfDate()); + } + else + { + assertNotNull(da.getAsOfDate()); + } + } + + // TODO boolean isNextDispositionActionEligible(NodeRef nodeRef); + + // TODO DispositionAction getNextDispositionAction(NodeRef nodeRef); + + // TODO List getCompletedDispositionActions(NodeRef nodeRef); + + // TODO DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); + + // TODO List getDispositionPeriodProperties(); + + /* === Issues === */ + + private NodeRef testRM263RecordCategory; + private DispositionSchedule testRM263DispositionSchedule; + private NodeRef testRM263Record; + + /** + * https://issues.alfresco.com/jira/browse/RM-263 + */ + public void testRM_263() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + testRM263RecordCategory = filePlanService.createRecordCategory(rmContainer, "rm263"); + testRM263DispositionSchedule = utils.createBasicDispositionSchedule( + testRM263RecordCategory, + "test", + "test", + true, + false); + + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); + adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); + adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); + adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, DOD5015Model.PROP_PUBLICATION_DATE.toString()); + + dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams); + + NodeRef recordFolder = recordFolderService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder"); + testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record"); + + return null; + } + }); + + doTestInTransaction(new Test() + { + private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf"); + + @Override + public Void run() throws Exception + { + Date pubDate = (Date)nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE); + assertNull(pubDate); + Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); + assertNull(asOfDate); + + DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); + assertNotNull(da); + assertNull(da.getAsOfDate()); + + //rma:recordSearchDispositionActionAsOf" + nodeService.setProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE, new Date()); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + Date pubDate = (Date)nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE); + assertNotNull(pubDate); + Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); + assertNotNull(asOfDate); + + DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); + assertNotNull(da); + assertNotNull(da.getAsOfDate()); + } + }); + } + + private NodeRef testRM386RecordCategory; + private DispositionSchedule testRM386DispositionSchedule; + private NodeRef testRM386Record; + + /** + * Test to make sure all the search rollups are correct after schedule is updated + * @throws Exception + */ + public void testRM386() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + testRM386RecordCategory = filePlanService.createRecordCategory(rmContainer, "RM386"); + testRM386DispositionSchedule = utils.createBasicDispositionSchedule( + testRM386RecordCategory, + "disposition instructions", + "disposition authority", + true, // record level + true); // set the default actions + + NodeRef recordFolder = recordFolderService.createRecordFolder(testRM386RecordCategory, "testRM386RecordFolder"); + testRM386Record = utils.createRecord(recordFolder, "testRM386Record", "testRM386Record"); + + return null; + } + + @SuppressWarnings("unchecked") + @Override + public void test(Void result) throws Exception + { + // Test the rollups for the record + Map properties = nodeService.getProperties(testRM386Record); + + assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); + + assertEquals("none", properties.get(PROP_RS_DISPOSITION_PERIOD)); + assertEquals("0", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + + List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); + assertNotNull(events); + assertEquals(1, events.size()); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, events.get(0)); + assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + + assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); + assertNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + + doTestInTransaction(new Test() + { + @Override + public DispositionActionDefinition run() throws Exception + { + DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff"); + assertNotNull(actionDefinition); + + Map adParams = new HashMap(3); + + List events = new ArrayList(1); + events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); + events.add("obsolete"); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); + + dispositionService.updateDispositionActionDefinition( + actionDefinition, + adParams); + + return actionDefinition; + } + + @SuppressWarnings("unchecked") + @Override + public void test(DispositionActionDefinition result) throws Exception + { + DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff"); + assertNotNull(actionDefinition); + assertTrue(nodeService.hasAspect(actionDefinition.getNodeRef(), ASPECT_UNPUBLISHED_UPDATE)); + + // Publish the updates + PublishUpdatesJobExecuter updater = (PublishUpdatesJobExecuter)applicationContext.getBean("publishUpdatesJobExecuter"); + updater.executeImpl(); + + assertFalse(nodeService.hasAspect(actionDefinition.getNodeRef(), ASPECT_UNPUBLISHED_UPDATE)); + + // Check the record has been updated + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(testRM386Record); + assertNotNull(dispositionAction); + assertEquals("cutoff", dispositionAction.getName()); + assertNotNull(dispositionAction.getAsOfDate()); + assertEquals(2, dispositionAction.getEventCompletionDetails().size()); + + // Test the rollups for the record + Map properties = nodeService.getProperties(testRM386Record); + + assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); + + assertEquals("week", properties.get(PROP_RS_DISPOSITION_PERIOD)); + assertEquals("1", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + + List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); + assertNotNull(events); + assertEquals(2, events.size()); + assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + + assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); + assertNotNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + } + }); + + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedActionServiceTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedActionServiceTest.java index 3d363c78d4..ef180e1fa1 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedActionServiceTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedActionServiceTest.java @@ -1,172 +1,172 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestActionPropertySubs; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ActionDefinition; - -/** - * Extended action service test. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ExtendedActionServiceTest extends BaseRMTestCase -{ - /** Action names */ - public static final String TEST_ACTION = "testAction"; - public static final String TEST_ACTION_2 = "testAction2"; - public static final String TEST_DM_ACTION = "testDMAction"; - public static final String RECORD_ONLY_ACTION = "recordOnlyAction"; - public static final String RECORD_AND_FOLDER_ONLY_ACTION = "recordandFolderOnlyAction"; - public static final String DELEGATE_ACTION = "rmDelegateAction"; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - @Override - protected boolean isRecordTest() - { - return true; - } - - // NOTE: temporarily disabled test ... now that RM actions are no longer registered with the action service, aplicability - // may no longer be relevant ... possibly something to back out?? - public void xtestAvailableActions() - { - doTestInTransaction(new Test() - { - public Void run() - { - List result = actionService.getActionDefinitions(recordOne); - assertNotNull(result); - assertFalse(containsAction(result, TEST_ACTION)); - assertTrue(containsAction(result, TEST_ACTION_2)); - assertFalse(containsAction(result, TEST_DM_ACTION)); - assertTrue(containsAction(result, RECORD_ONLY_ACTION)); - assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); - assertTrue(containsAction(result, DELEGATE_ACTION)); - - result = actionService.getActionDefinitions(rmFolder); - assertNotNull(result); - assertFalse(containsAction(result, TEST_ACTION)); - assertTrue(containsAction(result, TEST_ACTION_2)); - assertFalse(containsAction(result, TEST_DM_ACTION)); - assertFalse(containsAction(result, RECORD_ONLY_ACTION)); - assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); - assertFalse(containsAction(result, DELEGATE_ACTION)); - - result = actionService.getActionDefinitions(rmContainer); - assertNotNull(result); - assertFalse(containsAction(result, TEST_ACTION)); - assertTrue(containsAction(result, TEST_ACTION_2)); - assertFalse(containsAction(result, TEST_DM_ACTION)); - assertFalse(containsAction(result, RECORD_ONLY_ACTION)); - assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); - assertFalse(containsAction(result, DELEGATE_ACTION)); - - result = actionService.getActionDefinitions(dmDocument); - assertNotNull(result); - assertFalse(containsAction(result, TEST_ACTION)); - assertFalse(containsAction(result, TEST_ACTION_2)); - assertTrue(containsAction(result, TEST_DM_ACTION)); - assertFalse(containsAction(result, RECORD_ONLY_ACTION)); - assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); - assertFalse(containsAction(result, DELEGATE_ACTION)); - - result = actionService.getActionDefinitions(dmFolder); - assertNotNull(result); - assertFalse(containsAction(result, TEST_ACTION)); - assertFalse(containsAction(result, TEST_ACTION_2)); - assertTrue(containsAction(result, TEST_DM_ACTION)); - assertFalse(containsAction(result, RECORD_ONLY_ACTION)); - assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); - assertFalse(containsAction(result, DELEGATE_ACTION)); - - return null; - } - }); - } - - private boolean containsAction(List list, String actionName) - { - boolean result = false; - - for (ActionDefinition actionDefinition : list) - { - if (actionDefinition.getName().equals(actionName)) - { - result = true; - break; - } - } - - return result; - } - - public void testActionPropertySubstitution() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Action action = actionService.createAction(TestActionPropertySubs.NAME); - - action.setParameterValue("dayShort", "${date.day.short}"); - action.setParameterValue("dayShort2", "${date.day}"); - action.setParameterValue("dayLong", "${date.day.long}"); - action.setParameterValue("dayNumber", "${date.day.number}"); - action.setParameterValue("dayYear", "${date.day.year}"); - - action.setParameterValue("monthShort", "${date.month.short}"); - action.setParameterValue("monthShort2", "${date.month}"); - action.setParameterValue("monthLong", "${date.month.long}"); - action.setParameterValue("monthNumber", "${date.month.number}"); - - action.setParameterValue("yearShort", "${date.year.short}"); - action.setParameterValue("yearShort2", "${date.year}"); - action.setParameterValue("yearLong", "${date.year.long}"); - action.setParameterValue("yearWeek", "${date.year.week}"); - - action.setParameterValue("name", "${node.cm:name}"); - - action.setParameterValue("company", "${message.test.company}"); - - action.setParameterValue("combo", "${date.year.long}/${date.month.short}/${node.cm:name}-${message.test.company}.txt"); - - actionService.executeAction(action, rmFolder); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestActionPropertySubs; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ActionDefinition; + +/** + * Extended action service test. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ExtendedActionServiceTest extends BaseRMTestCase +{ + /** Action names */ + public static final String TEST_ACTION = "testAction"; + public static final String TEST_ACTION_2 = "testAction2"; + public static final String TEST_DM_ACTION = "testDMAction"; + public static final String RECORD_ONLY_ACTION = "recordOnlyAction"; + public static final String RECORD_AND_FOLDER_ONLY_ACTION = "recordandFolderOnlyAction"; + public static final String DELEGATE_ACTION = "rmDelegateAction"; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + // NOTE: temporarily disabled test ... now that RM actions are no longer registered with the action service, aplicability + // may no longer be relevant ... possibly something to back out?? + public void xtestAvailableActions() + { + doTestInTransaction(new Test() + { + public Void run() + { + List result = actionService.getActionDefinitions(recordOne); + assertNotNull(result); + assertFalse(containsAction(result, TEST_ACTION)); + assertTrue(containsAction(result, TEST_ACTION_2)); + assertFalse(containsAction(result, TEST_DM_ACTION)); + assertTrue(containsAction(result, RECORD_ONLY_ACTION)); + assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); + assertTrue(containsAction(result, DELEGATE_ACTION)); + + result = actionService.getActionDefinitions(rmFolder); + assertNotNull(result); + assertFalse(containsAction(result, TEST_ACTION)); + assertTrue(containsAction(result, TEST_ACTION_2)); + assertFalse(containsAction(result, TEST_DM_ACTION)); + assertFalse(containsAction(result, RECORD_ONLY_ACTION)); + assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); + assertFalse(containsAction(result, DELEGATE_ACTION)); + + result = actionService.getActionDefinitions(rmContainer); + assertNotNull(result); + assertFalse(containsAction(result, TEST_ACTION)); + assertTrue(containsAction(result, TEST_ACTION_2)); + assertFalse(containsAction(result, TEST_DM_ACTION)); + assertFalse(containsAction(result, RECORD_ONLY_ACTION)); + assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); + assertFalse(containsAction(result, DELEGATE_ACTION)); + + result = actionService.getActionDefinitions(dmDocument); + assertNotNull(result); + assertFalse(containsAction(result, TEST_ACTION)); + assertFalse(containsAction(result, TEST_ACTION_2)); + assertTrue(containsAction(result, TEST_DM_ACTION)); + assertFalse(containsAction(result, RECORD_ONLY_ACTION)); + assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); + assertFalse(containsAction(result, DELEGATE_ACTION)); + + result = actionService.getActionDefinitions(dmFolder); + assertNotNull(result); + assertFalse(containsAction(result, TEST_ACTION)); + assertFalse(containsAction(result, TEST_ACTION_2)); + assertTrue(containsAction(result, TEST_DM_ACTION)); + assertFalse(containsAction(result, RECORD_ONLY_ACTION)); + assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION)); + assertFalse(containsAction(result, DELEGATE_ACTION)); + + return null; + } + }); + } + + private boolean containsAction(List list, String actionName) + { + boolean result = false; + + for (ActionDefinition actionDefinition : list) + { + if (actionDefinition.getName().equals(actionName)) + { + result = true; + break; + } + } + + return result; + } + + public void testActionPropertySubstitution() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Action action = actionService.createAction(TestActionPropertySubs.NAME); + + action.setParameterValue("dayShort", "${date.day.short}"); + action.setParameterValue("dayShort2", "${date.day}"); + action.setParameterValue("dayLong", "${date.day.long}"); + action.setParameterValue("dayNumber", "${date.day.number}"); + action.setParameterValue("dayYear", "${date.day.year}"); + + action.setParameterValue("monthShort", "${date.month.short}"); + action.setParameterValue("monthShort2", "${date.month}"); + action.setParameterValue("monthLong", "${date.month.long}"); + action.setParameterValue("monthNumber", "${date.month.number}"); + + action.setParameterValue("yearShort", "${date.year.short}"); + action.setParameterValue("yearShort2", "${date.year}"); + action.setParameterValue("yearLong", "${date.year.long}"); + action.setParameterValue("yearWeek", "${date.year.week}"); + + action.setParameterValue("name", "${node.cm:name}"); + + action.setParameterValue("company", "${message.test.company}"); + + action.setParameterValue("combo", "${date.year.long}/${date.month.short}/${node.cm:name}-${message.test.company}.txt"); + + actionService.executeAction(action, rmFolder); + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java index daaad3b005..740f3c9bba 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java @@ -1,296 +1,296 @@ -/* -it st * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * - - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - - * 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 . - * #L% - */ - -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.util.GUID; - -/** - * Records management security service test. - * - * @author Roy Wetherall - */ -public class ExtendedSecurityServiceImplTest extends BaseRMTestCase -{ - private NodeRef record; - private NodeRef recordToo; - private NodeRef moveRecordCategory; - private NodeRef moveRecordFolder; - - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - record = utils.createRecord(rmFolder, "record.txt"); - recordToo = utils.createRecord(rmFolder, "recordToo.txt"); - - moveRecordCategory = filePlanService.createRecordCategory(filePlan, "moveRecordCategory"); - moveRecordFolder = recordFolderService.createRecordFolder(moveRecordCategory, "moveRecordFolder"); - } - - private String createTestUser() - { - return doTestInTransaction(new Test() - { - public String run() - { - String userName = GUID.generate(); - createPerson(userName); - return userName; - } - }, AuthenticationUtil.getSystemUserName()); - } - - public void testExtendedSecurity() - { - final String monkey = createTestUser(); - final String elephant = createTestUser(); - final String snake = createTestUser(); - - doTestInTransaction(new Test() - { - public Void run() - { - assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan)); - assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); - assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); - assertFalse(extendedSecurityService.hasExtendedSecurity(record)); - - assertTrue(extendedSecurityService.getReaders(record).isEmpty()); - assertTrue(extendedSecurityService.getWriters(record).isEmpty()); - - Set extendedReaders = new HashSet(2); - extendedReaders.add(monkey); - extendedReaders.add(elephant); - - extendedSecurityService.set(record, extendedReaders, null); - checkExtendedReaders(record, extendedReaders); - - Set extendedReadersToo = new HashSet(2); - extendedReadersToo.add(monkey); - extendedReadersToo.add(snake); - - extendedSecurityService.set(recordToo, extendedReadersToo, null); - checkExtendedReaders(recordToo, extendedReadersToo); - - // test remove - extendedSecurityService.remove(recordToo); - - assertFalse(extendedSecurityService.hasExtendedSecurity(recordToo)); - assertTrue(extendedSecurityService.getReaders(recordToo).isEmpty()); - assertTrue(extendedSecurityService.getWriters(recordToo).isEmpty()); - - return null; - } - }); - } - - public void testMove() - { - final String monkey = createTestUser(); - final String elephant = createTestUser(); - - doTestInTransaction(new Test() - { - Set extendedReaders = new HashSet(2);; - - public Void run() throws Exception - { - extendedReaders.add(monkey); - extendedReaders.add(elephant); - - assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan)); - assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); - assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); - assertFalse(extendedSecurityService.hasExtendedSecurity(record)); - assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); - assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); - - assertTrue(extendedSecurityService.getReaders(record).isEmpty()); - - extendedSecurityService.set(record, extendedReaders, null); - - checkExtendedReaders(record, extendedReaders); - - assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); - assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); - - fileFolderService.move(record, moveRecordFolder, "movedRecord"); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - checkExtendedReaders(record, extendedReaders); - } - }); - } - - /** - * Check extended readers helper method - */ - private void checkExtendedReaders(NodeRef nodeRef, Set testReaders) - { - assertTrue(extendedSecurityService.hasExtendedSecurity(nodeRef)); - - Set readers = extendedSecurityService.getReaders(nodeRef); - assertNotNull(readers); - assertEquals(testReaders, readers); - } - - public void testDifferentUsersDifferentPermissions() - { - final String userNone = createTestUser(); - final String userRead = createTestUser(); - final String userWrite = createTestUser(); - final String siteShortName = GUID.generate(); - - doTestInTransaction(new Test() - { - public Void run() throws Exception - { - siteService.createSite(null, siteShortName, "test", "test", SiteVisibility.PRIVATE); - return null; - } - }); - - final NodeRef documentLibrary = doTestInTransaction(new Test() - { - public NodeRef run() throws Exception - { - siteService.setMembership(siteShortName, userRead, SiteModel.SITE_CONSUMER); - siteService.setMembership(siteShortName, userWrite, SiteModel.SITE_COLLABORATOR); - return siteService.createContainer(siteShortName, SiteService.DOCUMENT_LIBRARY, null, null); - } - }); - - final NodeRef record = doTestInTransaction(new Test() - { - public NodeRef run() throws Exception - { - NodeRef record = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - recordService.createRecord(filePlan, record); - return record; - } - }); - - doTestInTransaction(new Test() - { - public Void run() throws Exception - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userNone); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userRead); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userWrite); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userNone); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userRead); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - // check permissions - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, FILING)); - return null; - } - }, userWrite); - - return null; - } - }); - } -} +/* +it st * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ + +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.site.SiteModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.util.GUID; + +/** + * Records management security service test. + * + * @author Roy Wetherall + */ +public class ExtendedSecurityServiceImplTest extends BaseRMTestCase +{ + private NodeRef record; + private NodeRef recordToo; + private NodeRef moveRecordCategory; + private NodeRef moveRecordFolder; + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + record = utils.createRecord(rmFolder, "record.txt"); + recordToo = utils.createRecord(rmFolder, "recordToo.txt"); + + moveRecordCategory = filePlanService.createRecordCategory(filePlan, "moveRecordCategory"); + moveRecordFolder = recordFolderService.createRecordFolder(moveRecordCategory, "moveRecordFolder"); + } + + private String createTestUser() + { + return doTestInTransaction(new Test() + { + public String run() + { + String userName = GUID.generate(); + createPerson(userName); + return userName; + } + }, AuthenticationUtil.getSystemUserName()); + } + + public void testExtendedSecurity() + { + final String monkey = createTestUser(); + final String elephant = createTestUser(); + final String snake = createTestUser(); + + doTestInTransaction(new Test() + { + public Void run() + { + assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan)); + assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); + assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); + assertFalse(extendedSecurityService.hasExtendedSecurity(record)); + + assertTrue(extendedSecurityService.getReaders(record).isEmpty()); + assertTrue(extendedSecurityService.getWriters(record).isEmpty()); + + Set extendedReaders = new HashSet(2); + extendedReaders.add(monkey); + extendedReaders.add(elephant); + + extendedSecurityService.set(record, extendedReaders, null); + checkExtendedReaders(record, extendedReaders); + + Set extendedReadersToo = new HashSet(2); + extendedReadersToo.add(monkey); + extendedReadersToo.add(snake); + + extendedSecurityService.set(recordToo, extendedReadersToo, null); + checkExtendedReaders(recordToo, extendedReadersToo); + + // test remove + extendedSecurityService.remove(recordToo); + + assertFalse(extendedSecurityService.hasExtendedSecurity(recordToo)); + assertTrue(extendedSecurityService.getReaders(recordToo).isEmpty()); + assertTrue(extendedSecurityService.getWriters(recordToo).isEmpty()); + + return null; + } + }); + } + + public void testMove() + { + final String monkey = createTestUser(); + final String elephant = createTestUser(); + + doTestInTransaction(new Test() + { + Set extendedReaders = new HashSet(2);; + + public Void run() throws Exception + { + extendedReaders.add(monkey); + extendedReaders.add(elephant); + + assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan)); + assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); + assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); + assertFalse(extendedSecurityService.hasExtendedSecurity(record)); + assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); + assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); + + assertTrue(extendedSecurityService.getReaders(record).isEmpty()); + + extendedSecurityService.set(record, extendedReaders, null); + + checkExtendedReaders(record, extendedReaders); + + assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); + assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); + + fileFolderService.move(record, moveRecordFolder, "movedRecord"); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + checkExtendedReaders(record, extendedReaders); + } + }); + } + + /** + * Check extended readers helper method + */ + private void checkExtendedReaders(NodeRef nodeRef, Set testReaders) + { + assertTrue(extendedSecurityService.hasExtendedSecurity(nodeRef)); + + Set readers = extendedSecurityService.getReaders(nodeRef); + assertNotNull(readers); + assertEquals(testReaders, readers); + } + + public void testDifferentUsersDifferentPermissions() + { + final String userNone = createTestUser(); + final String userRead = createTestUser(); + final String userWrite = createTestUser(); + final String siteShortName = GUID.generate(); + + doTestInTransaction(new Test() + { + public Void run() throws Exception + { + siteService.createSite(null, siteShortName, "test", "test", SiteVisibility.PRIVATE); + return null; + } + }); + + final NodeRef documentLibrary = doTestInTransaction(new Test() + { + public NodeRef run() throws Exception + { + siteService.setMembership(siteShortName, userRead, SiteModel.SITE_CONSUMER); + siteService.setMembership(siteShortName, userWrite, SiteModel.SITE_COLLABORATOR); + return siteService.createContainer(siteShortName, SiteService.DOCUMENT_LIBRARY, null, null); + } + }); + + final NodeRef record = doTestInTransaction(new Test() + { + public NodeRef run() throws Exception + { + NodeRef record = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + recordService.createRecord(filePlan, record); + return record; + } + }); + + doTestInTransaction(new Test() + { + public Void run() throws Exception + { + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userNone); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userRead); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userWrite); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userNone); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userRead); + + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + // check permissions + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, FILING)); + return null; + } + }, userWrite); + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java index 365cf1db86..578a266dae 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java @@ -1,1258 +1,1258 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.AuthorityType; -import org.springframework.extensions.webscripts.GUID; - -/** - * File plan permission service unit test - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FilePlanPermissionServiceImplTest extends BaseRMTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() - */ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * Helper to create test user - */ - private String createTestUser() - { - return doTestInTransaction(new Test() - { - @Override - public String run() - { - String userName = GUID.generate(); - createPerson(userName); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, userName); - return userName; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Helper to set permission - */ - private void setPermission(final NodeRef nodeRef, final String userName, final String permission) - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.setPermission(nodeRef, userName, permission); - return null; - } - }); - } - - /** - * Helper to delete permission - */ - private void deletePermission(final NodeRef nodeRef, final String userName, final String permission) - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - filePlanPermissionService.deletePermission(nodeRef, userName, permission); - return null; - } - }); - } - - /** - * Test set/delete permissions on file plan - */ - public void testSetDeletePermissionFilePlan() throws Exception - { - String userName = createTestUser(); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - setPermission(filePlan, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.ALLOWED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - deletePermission(filePlan, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - //what happens if we try and remove READ for a normal user on the file plan ??? - deletePermission(filePlan, userName, RMPermissionModel.READ_RECORDS); - - // nothing .. user still has read on file plan .. only removing the user from all roles will remove read on file plan - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - } - - /** - * Test set/delete permission on record categorty - */ - public void testSetDeletePermissionRecordCategory() throws Exception - { - String userName = createTestUser(); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - setPermission(rmContainer, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // category read - AccessStatus.ALLOWED, // category file - AccessStatus.ALLOWED, // record folder read - AccessStatus.ALLOWED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - deletePermission(rmContainer, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - } - - /** - * Test set/delete permission on record folder - */ - public void testSetDeletePermissionRecordFolder() throws Exception - { - String userName = createTestUser(); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - setPermission(rmFolder, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.ALLOWED, // record folder read - AccessStatus.ALLOWED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - deletePermission(rmFolder, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - } - - /** - * Test set/delete permission on record - */ - public void testSetDeletePermissionRecord() throws Exception - { - String userName = createTestUser(); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - setPermission(recordOne, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - deletePermission(recordOne, userName, RMPermissionModel.FILING); - - assertPermissions(userName, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - } - - public void testMoveRecord() throws Exception - { - String userOne = createTestUser(); - String userTwo = createTestUser(); - String userThree = createTestUser(); - - final NodeRef otherFolder = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - return recordFolderService.createRecordFolder(rmContainer, "otherFolder"); - } - }); - - assertPermissions(userOne, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userOne); - - assertPermissions(userTwo, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userTwo); - - assertPermissions(userThree, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userThree); - - setPermission(rmFolder, userOne, RMPermissionModel.FILING); - setPermission(otherFolder, userTwo, RMPermissionModel.FILING); - setPermission(recordOne, userThree, RMPermissionModel.FILING); - - assertPermissions(userOne, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.ALLOWED, // record folder read - AccessStatus.ALLOWED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userOne); - - assertPermissions(userTwo, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userTwo); - - assertPermissions(userThree, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userThree); - - // move the record! - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - fileFolderService.move(recordOne, otherFolder, "movedRecord.txt"); - return null; - } - }); - - assertPermissions(userOne, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.ALLOWED, // record folder read - AccessStatus.ALLOWED, // record folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userOne); - - assertPermissions(userTwo, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userTwo); - - assertPermissions(userThree, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.DENIED, // category read - AccessStatus.DENIED, // category file - AccessStatus.DENIED, // record folder read - AccessStatus.DENIED, // record folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); - return null; - } - }, userThree); - - } - - /** - * Helper to assert permissions for passed user - */ - private void assertPermissions(final String userName, final AccessStatus ... accessStatus) - { - assertEquals(8, accessStatus.length); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals("Everyone who has a role has read permissions on the file plan", - accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING)); - - assertEquals(accessStatus[2], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[3], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING)); - - assertEquals(accessStatus[4], permissionService.hasPermission(rmFolder, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[5], permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); - - assertEquals(accessStatus[6], permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[7], permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); - - return null; - } - }, userName); - } - - /** - * Helper to assert permissions for the passed user - */ - private void assertPermissionsWithInheritance( - final String userName, - final NodeRef subCategory, - final NodeRef folder, - final NodeRef record, - final AccessStatus ... accessStatus) - { - assertEquals(16, accessStatus.length); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING)); - - assertEquals(accessStatus[2], permissionService.hasPermission(transfersContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[3], permissionService.hasPermission(transfersContainer, RMPermissionModel.FILING)); - - assertEquals(accessStatus[4], permissionService.hasPermission(holdsContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[5], permissionService.hasPermission(holdsContainer, RMPermissionModel.FILING)); - - assertEquals(accessStatus[6], permissionService.hasPermission(unfiledContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[7], permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING)); - - assertEquals(accessStatus[8], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[9], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING)); - - assertEquals(accessStatus[10], permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[11], permissionService.hasPermission(subCategory, RMPermissionModel.FILING)); - - assertEquals(accessStatus[12], permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[13], permissionService.hasPermission(folder, RMPermissionModel.FILING)); - - assertEquals(accessStatus[14], permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); - assertEquals(accessStatus[15], permissionService.hasPermission(record, RMPermissionModel.FILING)); - - return null; - } - }, userName); - } - - public void testFilePlanComponentInheritance() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Inheritance is turned off for file plan, transfer, holds, unfiled records and root categories - // it is turned on for sub categories, record folders and records - assertFalse(permissionService.getInheritParentPermissions(filePlan)); - assertFalse(permissionService.getInheritParentPermissions(filePlanService.getTransferContainer(filePlan))); - assertFalse(permissionService.getInheritParentPermissions(filePlanService.getHoldContainer(filePlan))); - assertFalse(permissionService.getInheritParentPermissions(unfiledContainer)); - assertFalse(permissionService.getInheritParentPermissions(rmContainer)); - assertTrue(permissionService.getInheritParentPermissions(recordFolderService.createRecordFolder(rmContainer, "subCategory"))); - assertTrue(permissionService.getInheritParentPermissions(rmFolder)); - assertTrue(permissionService.getInheritParentPermissions(recordOne)); - - return null; - } - }, ADMIN_USER); - } - - public void testRolesSetByDefault() - { - NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory1"); - NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder1"); - NodeRef record = utils.createRecord(folder, "record1.txt"); - - // Admin user has read/filing permissions on file plan, transfer, hold, unfiled records, root categories, sub categories, folders and records - assertPermissionsWithInheritance(ADMIN_USER, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.ALLOWED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.ALLOWED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.ALLOWED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.ALLOWED, // root category read - AccessStatus.ALLOWED, // root category file - AccessStatus.ALLOWED, // sub category read - AccessStatus.ALLOWED, // sub category file - AccessStatus.ALLOWED, // folder read - AccessStatus.ALLOWED, // folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - // Test user has read permissions on file plan, transfer, hold and unfiled records as the user will be added in the all records management roles - // which has read permissions on those nodes by default - assertPermissionsWithInheritance(createTestUser(), subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - } - - public void testAddUserToContainers() - { - NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory2"); - NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder2"); - NodeRef record = utils.createRecord(folder, "record2.txt"); - - // The user1 will have read permissions on the file plan - // and read permissions on transfer, hold and unfiled records as the user will be in the all records management users role - String user1 = createTestUser(); - setPermission(filePlan, user1, RMPermissionModel.READ_RECORDS); - assertPermissionsWithInheritance(user1, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - // The user2 will have read and filing permissions on the transfer container - // and read permissions on file plan, hold and unfiled records as the user will be in the all records management users role - String user2 = createTestUser(); - setPermission(transfersContainer, user2, RMPermissionModel.FILING); - assertPermissionsWithInheritance(user2, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.ALLOWED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - // The user3 will have read permissions on file plan, transfer, hold and unfiled records - String user3 = createTestUser(); - setPermission(holdsContainer, user3, RMPermissionModel.READ_RECORDS); - assertPermissionsWithInheritance(user3, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - // The user4 will have read permissions on file plan, transfer, hold - // and read and filing permissions on unfiled records container - String user4 = createTestUser(); - setPermission(unfiledContainer, user4, RMPermissionModel.FILING); - assertPermissionsWithInheritance(user4, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.DENIED, // record read - AccessStatus.DENIED); // record file - - // The user5 will read permissions on the root category - // as the inheritance is turned on for the sub category the user will have also read permissions on sub category, folder and record - // and also read permissions on file plan, transfer, hold and unfiled records - String user5 = createTestUser(); - setPermission(rmContainer, user5, RMPermissionModel.READ_RECORDS); - assertPermissionsWithInheritance(user5, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.ALLOWED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.ALLOWED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.ALLOWED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.ALLOWED, // record read - AccessStatus.DENIED); // record file - - // The user6 will read and filing permissions on the sub category - // as the inheritance is turned on the user will have also read and filing permissions on folder and record - // and also read permissions on file plan, transfer, hold and unfiled records - String user6 = createTestUser(); - setPermission(subCategory, user6, RMPermissionModel.FILING); - assertPermissionsWithInheritance(user6, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.ALLOWED, // sub category read - AccessStatus.ALLOWED, // sub category file - AccessStatus.ALLOWED, // folder read - AccessStatus.ALLOWED, // folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - - // The user7 will read permissions on the folder - // as the inheritance is turned on the user will have also read on record - // and also read permissions on file plan, transfer, hold and unfiled records - String user7 = createTestUser(); - setPermission(folder, user7, RMPermissionModel.READ_RECORDS); - assertPermissionsWithInheritance(user7, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.ALLOWED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.ALLOWED, // record read - AccessStatus.DENIED); // record file - - // The user8 will read and filing permissions on the record - // and also read permissions on file plan, transfer, hold and unfiled records - String user8 = createTestUser(); - setPermission(record, user8, RMPermissionModel.FILING); - assertPermissionsWithInheritance(user8, subCategory, folder, record, - AccessStatus.ALLOWED, // fileplan read - AccessStatus.DENIED, // fileplan file - AccessStatus.ALLOWED, // transfer read - AccessStatus.DENIED, // transfer file - AccessStatus.ALLOWED, // holds read - AccessStatus.DENIED, // holds file - AccessStatus.ALLOWED, // unfiled records file - AccessStatus.DENIED, // unfiled records file - AccessStatus.DENIED, // root category read - AccessStatus.DENIED, // root category file - AccessStatus.DENIED, // sub category read - AccessStatus.DENIED, // sub category file - AccessStatus.DENIED, // folder read - AccessStatus.DENIED, // folder file - AccessStatus.ALLOWED, // record read - AccessStatus.ALLOWED); // record file - } - - public void testAccessPermissionOnSingleRecordWithSeveralUsers() - { - final NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory3"); - final NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder3"); - final NodeRef record = utils.createRecord(folder, "record3.txt"); - - String user1 = createTestUser(); - String user2 = createTestUser(); - - setPermission(rmContainer, user1, RMPermissionModel.READ_RECORDS); - - // user1 will have access to file plan, root category and because of inheritance sub category, folder and record - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); - - return null; - } - }, user1); - - // user2 will have access to file plan - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); - - return null; - } - }, user2); - } - - public void testDenyPermissionsOnRecordsWithSeveralUsers() - { - final NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory4"); - final NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder4"); - final NodeRef record4 = utils.createRecord(folder, "record4.txt"); - final NodeRef record5 = utils.createRecord(folder, "record5.txt"); - - String user1 = createTestUser(); - String user2 = createTestUser(); - - setPermission(rmContainer, user1, RMPermissionModel.READ_RECORDS); - setPermission(rmContainer, user2, RMPermissionModel.READ_RECORDS); - - permissionService.setInheritParentPermissions(record4, false); - permissionService.setInheritParentPermissions(record5, false); - - setPermission(record4, user1, RMPermissionModel.READ_RECORDS); - setPermission(record5, user1, RMPermissionModel.READ_RECORDS); - - // user1 will have access to file plan, root category and because of inheritance sub category, folder, record4 and record5 - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record4, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record5, RMPermissionModel.READ_RECORDS)); - - return null; - } - }, user1); - - // user2 will have access to file plan, root category and because of inheritance sub category and folder - // user2 won't have access to the records as the inheritance is set to false - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record4, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record5, RMPermissionModel.READ_RECORDS)); - - return null; - } - }, user2); - } - - public void testMoveRootCategoryIntoAnotherRootCategory() - { - final NodeRef category5 = filePlanService.createRecordCategory(filePlan, "category5"); - final NodeRef category6 = filePlanService.createRecordCategory(filePlan, "category6"); - - assertFalse(permissionService.getInheritParentPermissions(category5)); - assertFalse(permissionService.getInheritParentPermissions(category6)); - - final String user1 = createTestUser(); - final String user2 = createTestUser(); - - setPermission(category5, user1, RMPermissionModel.READ_RECORDS); - setPermission(category6, user2, RMPermissionModel.FILING); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category5, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); - - return null; - } - }, user1); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); - - return null; - } - }, user2); - - final NodeRef movedCategory5 = doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return fileFolderService.move(category5, category6, null).getNodeRef(); - } - }); - - assertFalse(permissionService.getInheritParentPermissions(movedCategory5)); - assertFalse(permissionService.getInheritParentPermissions(category6)); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedCategory5, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); - - return null; - } - }, user1); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); - - return null; - } - }, user2); - } - - public void testPermissionsForMovedRecord() - { - final NodeRef category7 = filePlanService.createRecordCategory(filePlan, "category7"); - final NodeRef folder7 = recordFolderService.createRecordFolder(category7, "rmFolder7"); - final NodeRef record7 = utils.createRecord(folder7, "record7.txt"); - - final NodeRef category8 = filePlanService.createRecordCategory(filePlan, "category8"); - final NodeRef folder8 = recordFolderService.createRecordFolder(category8, "rmFolder8"); - final NodeRef record8 = utils.createRecord(folder8, "record8.txt"); - - final String user1 = createTestUser(); - final String user2 = createTestUser(); - final String user3 = createTestUser(); - - setPermission(folder7, user1, RMPermissionModel.FILING); - setPermission(record8, user2, RMPermissionModel.READ_RECORDS); - setPermission(category7, user3, RMPermissionModel.FILING); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); - - return null; - } - }, user1); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); - - return null; - } - }, user2); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); - - return null; - } - }, user3); - - final NodeRef movedRecord8 = doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return fileFolderService.move(record8, folder7, null).getNodeRef(); - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); - - return null; - } - }, user1); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); - - return null; - } - }, user2); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); - - return null; - } - }, user3); - } - - public void testSpecialRoles() - { - final NodeRef category9 = filePlanService.createRecordCategory(filePlan, "category9"); - final NodeRef subCategory9 = filePlanService.createRecordCategory(category9, "subCategory9"); - final NodeRef folder9 = recordFolderService.createRecordFolder(subCategory9, "rmFolder9"); - final NodeRef record9 = utils.createRecord(folder9, "record9.txt"); - - assertExistenceOfSpecialRolesAndPermissions(category9); - - assertExistenceOfSpecialRolesAndPermissions(subCategory9); - // After setting the permissions off the special roles should be still available as they will be added to the node automatically - permissionService.setInheritParentPermissions(subCategory9, false); - assertExistenceOfSpecialRolesAndPermissions(subCategory9); - permissionService.setInheritParentPermissions(subCategory9, true); - assertExistenceOfSpecialRolesAndPermissions(subCategory9); - - assertExistenceOfSpecialRolesAndPermissions(folder9); - permissionService.setInheritParentPermissions(folder9, false); - assertExistenceOfSpecialRolesAndPermissions(folder9); - permissionService.setInheritParentPermissions(folder9, true); - assertExistenceOfSpecialRolesAndPermissions(folder9); - - assertExistenceOfSpecialRolesAndPermissions(record9); - permissionService.setInheritParentPermissions(record9, false); - assertExistenceOfSpecialRolesAndPermissions(record9); - permissionService.setInheritParentPermissions(record9, true); - assertExistenceOfSpecialRolesAndPermissions(record9); - } - - private void assertExistenceOfSpecialRolesAndPermissions(NodeRef node) - { - Map accessPermissions = new HashMap(); - Set permissions = permissionService.getAllSetPermissions(node); - // FIXME!!! - //assertEquals(3, permissions.size()); - - for (AccessPermission permission : permissions) - { - accessPermissions.put(permission.getAuthority(), permission.getPermission()); - } - - String adminRole = authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); - assertTrue(accessPermissions.containsKey(adminRole)); - assertEquals(RMPermissionModel.FILING, accessPermissions.get(adminRole)); - } - - public void testMoveSubCategoryIntoFilePlan() - { - final NodeRef rootCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - final NodeRef subCategory = filePlanService.createRecordCategory(rootCategory, GUID.generate()); - - assertFalse(permissionService.getInheritParentPermissions(rootCategory)); - assertTrue(permissionService.getInheritParentPermissions(subCategory)); - - final NodeRef movedSubCategory = doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return fileFolderService.move(subCategory, filePlan, null).getNodeRef(); - } - }); - - assertFalse(permissionService.getInheritParentPermissions(rootCategory)); - assertFalse(permissionService.getInheritParentPermissions(movedSubCategory)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.AuthorityType; +import org.springframework.extensions.webscripts.GUID; + +/** + * File plan permission service unit test + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FilePlanPermissionServiceImplTest extends BaseRMTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() + */ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Helper to create test user + */ + private String createTestUser() + { + return doTestInTransaction(new Test() + { + @Override + public String run() + { + String userName = GUID.generate(); + createPerson(userName); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, userName); + return userName; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Helper to set permission + */ + private void setPermission(final NodeRef nodeRef, final String userName, final String permission) + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(nodeRef, userName, permission); + return null; + } + }); + } + + /** + * Helper to delete permission + */ + private void deletePermission(final NodeRef nodeRef, final String userName, final String permission) + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.deletePermission(nodeRef, userName, permission); + return null; + } + }); + } + + /** + * Test set/delete permissions on file plan + */ + public void testSetDeletePermissionFilePlan() throws Exception + { + String userName = createTestUser(); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + setPermission(filePlan, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.ALLOWED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + deletePermission(filePlan, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + //what happens if we try and remove READ for a normal user on the file plan ??? + deletePermission(filePlan, userName, RMPermissionModel.READ_RECORDS); + + // nothing .. user still has read on file plan .. only removing the user from all roles will remove read on file plan + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + } + + /** + * Test set/delete permission on record categorty + */ + public void testSetDeletePermissionRecordCategory() throws Exception + { + String userName = createTestUser(); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + setPermission(rmContainer, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // category read + AccessStatus.ALLOWED, // category file + AccessStatus.ALLOWED, // record folder read + AccessStatus.ALLOWED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + deletePermission(rmContainer, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + } + + /** + * Test set/delete permission on record folder + */ + public void testSetDeletePermissionRecordFolder() throws Exception + { + String userName = createTestUser(); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + setPermission(rmFolder, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.ALLOWED, // record folder read + AccessStatus.ALLOWED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + deletePermission(rmFolder, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + } + + /** + * Test set/delete permission on record + */ + public void testSetDeletePermissionRecord() throws Exception + { + String userName = createTestUser(); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + setPermission(recordOne, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + deletePermission(recordOne, userName, RMPermissionModel.FILING); + + assertPermissions(userName, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + } + + public void testMoveRecord() throws Exception + { + String userOne = createTestUser(); + String userTwo = createTestUser(); + String userThree = createTestUser(); + + final NodeRef otherFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + return recordFolderService.createRecordFolder(rmContainer, "otherFolder"); + } + }); + + assertPermissions(userOne, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userOne); + + assertPermissions(userTwo, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userTwo); + + assertPermissions(userThree, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userThree); + + setPermission(rmFolder, userOne, RMPermissionModel.FILING); + setPermission(otherFolder, userTwo, RMPermissionModel.FILING); + setPermission(recordOne, userThree, RMPermissionModel.FILING); + + assertPermissions(userOne, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.ALLOWED, // record folder read + AccessStatus.ALLOWED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userOne); + + assertPermissions(userTwo, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userTwo); + + assertPermissions(userThree, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userThree); + + // move the record! + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + fileFolderService.move(recordOne, otherFolder, "movedRecord.txt"); + return null; + } + }); + + assertPermissions(userOne, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.ALLOWED, // record folder read + AccessStatus.ALLOWED, // record folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userOne); + + assertPermissions(userTwo, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userTwo); + + assertPermissions(userThree, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.DENIED, // category read + AccessStatus.DENIED, // category file + AccessStatus.DENIED, // record folder read + AccessStatus.DENIED, // record folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(otherFolder, RMPermissionModel.FILING)); + return null; + } + }, userThree); + + } + + /** + * Helper to assert permissions for passed user + */ + private void assertPermissions(final String userName, final AccessStatus ... accessStatus) + { + assertEquals(8, accessStatus.length); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals("Everyone who has a role has read permissions on the file plan", + accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING)); + + assertEquals(accessStatus[2], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[3], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING)); + + assertEquals(accessStatus[4], permissionService.hasPermission(rmFolder, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[5], permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); + + assertEquals(accessStatus[6], permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[7], permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); + + return null; + } + }, userName); + } + + /** + * Helper to assert permissions for the passed user + */ + private void assertPermissionsWithInheritance( + final String userName, + final NodeRef subCategory, + final NodeRef folder, + final NodeRef record, + final AccessStatus ... accessStatus) + { + assertEquals(16, accessStatus.length); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING)); + + assertEquals(accessStatus[2], permissionService.hasPermission(transfersContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[3], permissionService.hasPermission(transfersContainer, RMPermissionModel.FILING)); + + assertEquals(accessStatus[4], permissionService.hasPermission(holdsContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[5], permissionService.hasPermission(holdsContainer, RMPermissionModel.FILING)); + + assertEquals(accessStatus[6], permissionService.hasPermission(unfiledContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[7], permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING)); + + assertEquals(accessStatus[8], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[9], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING)); + + assertEquals(accessStatus[10], permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[11], permissionService.hasPermission(subCategory, RMPermissionModel.FILING)); + + assertEquals(accessStatus[12], permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[13], permissionService.hasPermission(folder, RMPermissionModel.FILING)); + + assertEquals(accessStatus[14], permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); + assertEquals(accessStatus[15], permissionService.hasPermission(record, RMPermissionModel.FILING)); + + return null; + } + }, userName); + } + + public void testFilePlanComponentInheritance() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Inheritance is turned off for file plan, transfer, holds, unfiled records and root categories + // it is turned on for sub categories, record folders and records + assertFalse(permissionService.getInheritParentPermissions(filePlan)); + assertFalse(permissionService.getInheritParentPermissions(filePlanService.getTransferContainer(filePlan))); + assertFalse(permissionService.getInheritParentPermissions(filePlanService.getHoldContainer(filePlan))); + assertFalse(permissionService.getInheritParentPermissions(unfiledContainer)); + assertFalse(permissionService.getInheritParentPermissions(rmContainer)); + assertTrue(permissionService.getInheritParentPermissions(recordFolderService.createRecordFolder(rmContainer, "subCategory"))); + assertTrue(permissionService.getInheritParentPermissions(rmFolder)); + assertTrue(permissionService.getInheritParentPermissions(recordOne)); + + return null; + } + }, ADMIN_USER); + } + + public void testRolesSetByDefault() + { + NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory1"); + NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder1"); + NodeRef record = utils.createRecord(folder, "record1.txt"); + + // Admin user has read/filing permissions on file plan, transfer, hold, unfiled records, root categories, sub categories, folders and records + assertPermissionsWithInheritance(ADMIN_USER, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.ALLOWED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.ALLOWED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.ALLOWED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.ALLOWED, // root category read + AccessStatus.ALLOWED, // root category file + AccessStatus.ALLOWED, // sub category read + AccessStatus.ALLOWED, // sub category file + AccessStatus.ALLOWED, // folder read + AccessStatus.ALLOWED, // folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + // Test user has read permissions on file plan, transfer, hold and unfiled records as the user will be added in the all records management roles + // which has read permissions on those nodes by default + assertPermissionsWithInheritance(createTestUser(), subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + } + + public void testAddUserToContainers() + { + NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory2"); + NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder2"); + NodeRef record = utils.createRecord(folder, "record2.txt"); + + // The user1 will have read permissions on the file plan + // and read permissions on transfer, hold and unfiled records as the user will be in the all records management users role + String user1 = createTestUser(); + setPermission(filePlan, user1, RMPermissionModel.READ_RECORDS); + assertPermissionsWithInheritance(user1, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + // The user2 will have read and filing permissions on the transfer container + // and read permissions on file plan, hold and unfiled records as the user will be in the all records management users role + String user2 = createTestUser(); + setPermission(transfersContainer, user2, RMPermissionModel.FILING); + assertPermissionsWithInheritance(user2, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.ALLOWED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + // The user3 will have read permissions on file plan, transfer, hold and unfiled records + String user3 = createTestUser(); + setPermission(holdsContainer, user3, RMPermissionModel.READ_RECORDS); + assertPermissionsWithInheritance(user3, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + // The user4 will have read permissions on file plan, transfer, hold + // and read and filing permissions on unfiled records container + String user4 = createTestUser(); + setPermission(unfiledContainer, user4, RMPermissionModel.FILING); + assertPermissionsWithInheritance(user4, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.DENIED, // record read + AccessStatus.DENIED); // record file + + // The user5 will read permissions on the root category + // as the inheritance is turned on for the sub category the user will have also read permissions on sub category, folder and record + // and also read permissions on file plan, transfer, hold and unfiled records + String user5 = createTestUser(); + setPermission(rmContainer, user5, RMPermissionModel.READ_RECORDS); + assertPermissionsWithInheritance(user5, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.ALLOWED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.ALLOWED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.ALLOWED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.ALLOWED, // record read + AccessStatus.DENIED); // record file + + // The user6 will read and filing permissions on the sub category + // as the inheritance is turned on the user will have also read and filing permissions on folder and record + // and also read permissions on file plan, transfer, hold and unfiled records + String user6 = createTestUser(); + setPermission(subCategory, user6, RMPermissionModel.FILING); + assertPermissionsWithInheritance(user6, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.ALLOWED, // sub category read + AccessStatus.ALLOWED, // sub category file + AccessStatus.ALLOWED, // folder read + AccessStatus.ALLOWED, // folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + + // The user7 will read permissions on the folder + // as the inheritance is turned on the user will have also read on record + // and also read permissions on file plan, transfer, hold and unfiled records + String user7 = createTestUser(); + setPermission(folder, user7, RMPermissionModel.READ_RECORDS); + assertPermissionsWithInheritance(user7, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.ALLOWED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.ALLOWED, // record read + AccessStatus.DENIED); // record file + + // The user8 will read and filing permissions on the record + // and also read permissions on file plan, transfer, hold and unfiled records + String user8 = createTestUser(); + setPermission(record, user8, RMPermissionModel.FILING); + assertPermissionsWithInheritance(user8, subCategory, folder, record, + AccessStatus.ALLOWED, // fileplan read + AccessStatus.DENIED, // fileplan file + AccessStatus.ALLOWED, // transfer read + AccessStatus.DENIED, // transfer file + AccessStatus.ALLOWED, // holds read + AccessStatus.DENIED, // holds file + AccessStatus.ALLOWED, // unfiled records file + AccessStatus.DENIED, // unfiled records file + AccessStatus.DENIED, // root category read + AccessStatus.DENIED, // root category file + AccessStatus.DENIED, // sub category read + AccessStatus.DENIED, // sub category file + AccessStatus.DENIED, // folder read + AccessStatus.DENIED, // folder file + AccessStatus.ALLOWED, // record read + AccessStatus.ALLOWED); // record file + } + + public void testAccessPermissionOnSingleRecordWithSeveralUsers() + { + final NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory3"); + final NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder3"); + final NodeRef record = utils.createRecord(folder, "record3.txt"); + + String user1 = createTestUser(); + String user2 = createTestUser(); + + setPermission(rmContainer, user1, RMPermissionModel.READ_RECORDS); + + // user1 will have access to file plan, root category and because of inheritance sub category, folder and record + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); + + return null; + } + }, user1); + + // user2 will have access to file plan + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record, RMPermissionModel.READ_RECORDS)); + + return null; + } + }, user2); + } + + public void testDenyPermissionsOnRecordsWithSeveralUsers() + { + final NodeRef subCategory = filePlanService.createRecordCategory(rmContainer, "subCategory4"); + final NodeRef folder = recordFolderService.createRecordFolder(subCategory, "rmFolder4"); + final NodeRef record4 = utils.createRecord(folder, "record4.txt"); + final NodeRef record5 = utils.createRecord(folder, "record5.txt"); + + String user1 = createTestUser(); + String user2 = createTestUser(); + + setPermission(rmContainer, user1, RMPermissionModel.READ_RECORDS); + setPermission(rmContainer, user2, RMPermissionModel.READ_RECORDS); + + permissionService.setInheritParentPermissions(record4, false); + permissionService.setInheritParentPermissions(record5, false); + + setPermission(record4, user1, RMPermissionModel.READ_RECORDS); + setPermission(record5, user1, RMPermissionModel.READ_RECORDS); + + // user1 will have access to file plan, root category and because of inheritance sub category, folder, record4 and record5 + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record4, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record5, RMPermissionModel.READ_RECORDS)); + + return null; + } + }, user1); + + // user2 will have access to file plan, root category and because of inheritance sub category and folder + // user2 won't have access to the records as the inheritance is set to false + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(subCategory, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record4, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record5, RMPermissionModel.READ_RECORDS)); + + return null; + } + }, user2); + } + + public void testMoveRootCategoryIntoAnotherRootCategory() + { + final NodeRef category5 = filePlanService.createRecordCategory(filePlan, "category5"); + final NodeRef category6 = filePlanService.createRecordCategory(filePlan, "category6"); + + assertFalse(permissionService.getInheritParentPermissions(category5)); + assertFalse(permissionService.getInheritParentPermissions(category6)); + + final String user1 = createTestUser(); + final String user2 = createTestUser(); + + setPermission(category5, user1, RMPermissionModel.READ_RECORDS); + setPermission(category6, user2, RMPermissionModel.FILING); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category5, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); + + return null; + } + }, user1); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category5, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); + + return null; + } + }, user2); + + final NodeRef movedCategory5 = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return fileFolderService.move(category5, category6, null).getNodeRef(); + } + }); + + assertFalse(permissionService.getInheritParentPermissions(movedCategory5)); + assertFalse(permissionService.getInheritParentPermissions(category6)); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedCategory5, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); + + return null; + } + }, user1); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedCategory5, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category6, RMPermissionModel.FILING)); + + return null; + } + }, user2); + } + + public void testPermissionsForMovedRecord() + { + final NodeRef category7 = filePlanService.createRecordCategory(filePlan, "category7"); + final NodeRef folder7 = recordFolderService.createRecordFolder(category7, "rmFolder7"); + final NodeRef record7 = utils.createRecord(folder7, "record7.txt"); + + final NodeRef category8 = filePlanService.createRecordCategory(filePlan, "category8"); + final NodeRef folder8 = recordFolderService.createRecordFolder(category8, "rmFolder8"); + final NodeRef record8 = utils.createRecord(folder8, "record8.txt"); + + final String user1 = createTestUser(); + final String user2 = createTestUser(); + final String user3 = createTestUser(); + + setPermission(folder7, user1, RMPermissionModel.FILING); + setPermission(record8, user2, RMPermissionModel.READ_RECORDS); + setPermission(category7, user3, RMPermissionModel.FILING); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); + + return null; + } + }, user1); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); + + return null; + } + }, user2); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record8, RMPermissionModel.FILING)); + + return null; + } + }, user3); + + final NodeRef movedRecord8 = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return fileFolderService.move(record8, folder7, null).getNodeRef(); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); + + return null; + } + }, user1); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); + + return null; + } + }, user2); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(folder7, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(record7, RMPermissionModel.FILING)); + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(category8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(folder8, RMPermissionModel.FILING)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(movedRecord8, RMPermissionModel.FILING)); + + return null; + } + }, user3); + } + + public void testSpecialRoles() + { + final NodeRef category9 = filePlanService.createRecordCategory(filePlan, "category9"); + final NodeRef subCategory9 = filePlanService.createRecordCategory(category9, "subCategory9"); + final NodeRef folder9 = recordFolderService.createRecordFolder(subCategory9, "rmFolder9"); + final NodeRef record9 = utils.createRecord(folder9, "record9.txt"); + + assertExistenceOfSpecialRolesAndPermissions(category9); + + assertExistenceOfSpecialRolesAndPermissions(subCategory9); + // After setting the permissions off the special roles should be still available as they will be added to the node automatically + permissionService.setInheritParentPermissions(subCategory9, false); + assertExistenceOfSpecialRolesAndPermissions(subCategory9); + permissionService.setInheritParentPermissions(subCategory9, true); + assertExistenceOfSpecialRolesAndPermissions(subCategory9); + + assertExistenceOfSpecialRolesAndPermissions(folder9); + permissionService.setInheritParentPermissions(folder9, false); + assertExistenceOfSpecialRolesAndPermissions(folder9); + permissionService.setInheritParentPermissions(folder9, true); + assertExistenceOfSpecialRolesAndPermissions(folder9); + + assertExistenceOfSpecialRolesAndPermissions(record9); + permissionService.setInheritParentPermissions(record9, false); + assertExistenceOfSpecialRolesAndPermissions(record9); + permissionService.setInheritParentPermissions(record9, true); + assertExistenceOfSpecialRolesAndPermissions(record9); + } + + private void assertExistenceOfSpecialRolesAndPermissions(NodeRef node) + { + Map accessPermissions = new HashMap(); + Set permissions = permissionService.getAllSetPermissions(node); + // FIXME!!! + //assertEquals(3, permissions.size()); + + for (AccessPermission permission : permissions) + { + accessPermissions.put(permission.getAuthority(), permission.getPermission()); + } + + String adminRole = authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId()); + assertTrue(accessPermissions.containsKey(adminRole)); + assertEquals(RMPermissionModel.FILING, accessPermissions.get(adminRole)); + } + + public void testMoveSubCategoryIntoFilePlan() + { + final NodeRef rootCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + final NodeRef subCategory = filePlanService.createRecordCategory(rootCategory, GUID.generate()); + + assertFalse(permissionService.getInheritParentPermissions(rootCategory)); + assertTrue(permissionService.getInheritParentPermissions(subCategory)); + + final NodeRef movedSubCategory = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return fileFolderService.move(subCategory, filePlan, null).getNodeRef(); + } + }); + + assertFalse(permissionService.getInheritParentPermissions(rootCategory)); + assertFalse(permissionService.getInheritParentPermissions(movedSubCategory)); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanRoleServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanRoleServiceImplTest.java index 6a8cdaee53..96cbc907e8 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanRoleServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanRoleServiceImplTest.java @@ -1,222 +1,222 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * File plan role service unit test - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FilePlanRoleServiceImplTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - } - - public void testGetAllRolesContainerGroup() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - String allRolesGroup = filePlanRoleService.getAllRolesContainerGroup(filePlan); - assertNotNull(allRolesGroup); - - return null; - } - }); - } - - public void testGetRoles() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Set roles = filePlanRoleService.getRoles(filePlan); - assertNotNull(roles); - assertTrue(roles.size() != 0); - - Set rolesIncludingSystemRoles = filePlanRoleService.getRoles(filePlan, true); - assertNotNull(rolesIncludingSystemRoles); - assertTrue(roles.size() != 0); - assertTrue(roles.size() == rolesIncludingSystemRoles.size()); - - Set rolesWithoutSystemRoles = filePlanRoleService.getRoles(filePlan, false); - assertNotNull(rolesWithoutSystemRoles); - assertTrue(rolesWithoutSystemRoles.size() != 0); - assertTrue(rolesIncludingSystemRoles.size() > rolesWithoutSystemRoles.size()); - assertTrue(rolesIncludingSystemRoles.size() == rolesWithoutSystemRoles.size() + FilePlanRoleService.SYSTEM_ROLES.size()); - - return null; - } - }); - } - - public void testRolesByUser() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Set roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); - assertNotNull(roles); - assertEquals(1, roles.size()); - - Set rolesIncludingSystemRoles = filePlanRoleService.getRolesByUser(filePlan, rmUserName, true); - assertNotNull(rolesIncludingSystemRoles); - assertEquals(1, rolesIncludingSystemRoles.size()); - assertEquals(roles.size(), rolesIncludingSystemRoles.size()); - - return null; - } - }); - } - - public void testGetRole() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Role role = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_POWER_USER); - assertNotNull(role); - assertEquals(FilePlanRoleService.ROLE_POWER_USER, role.getName()); - - role = filePlanRoleService.getRole(filePlan, "donkey"); - assertNull(role); - - return null; - } - }); - } - - public void testExistsRole() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - assertTrue(filePlanRoleService.existsRole(filePlan, FilePlanRoleService.ROLE_POWER_USER)); - assertFalse(filePlanRoleService.existsRole(filePlan, "donkey")); - - return null; - } - }); - } - - public void testCreateUpdateDeleteRole() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - assertFalse(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); - - Set caps = new HashSet(2); - caps.add(capabilityService.getCapability(RMPermissionModel.ACCESS_AUDIT)); - caps.add(capabilityService.getCapability(RMPermissionModel.ADD_MODIFY_EVENT_DATES)); - - Role role = filePlanRoleService.createRole(filePlan, "Michelle Holt", "Michelle Holt", caps); - assertNotNull(role); - assertEquals("Michelle Holt", role.getName()); - assertEquals(2, role.getCapabilities().size()); - - assertTrue(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); - - caps.add(capabilityService.getCapability(RMPermissionModel.AUTHORIZE_ALL_TRANSFERS)); - - role = filePlanRoleService.updateRole(filePlan, "Michelle Holt", "Michelle Wetherall", caps); - assertNotNull(role); - assertEquals("Michelle Holt", role.getName()); - assertEquals(3, role.getCapabilities().size()); - - assertTrue(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); - - filePlanRoleService.deleteRole(filePlan, "Michelle Holt"); - - assertFalse(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); - - return null; - } - }); - } - - /** - * {@link FilePlanRoleService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, String, String)} - * {@link FilePlanRoleService#getAuthorities(org.alfresco.service.cmr.repository.NodeRef, String) - */ - public void testAuthorityAssignment() throws Exception - { - doTestInTransaction(new Test() - { - public Void run() - { - Set roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); - assertNotNull(roles); - assertEquals(1, roles.size()); - - Set authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(1, authorities.size()); - - authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(0, authorities.size()); - - authorities = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(1, authorities.size()); - - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, rmUserName); - - roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); - assertNotNull(roles); - assertEquals(2, roles.size()); - - authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(2, authorities.size()); - - authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(0, authorities.size()); - - authorities = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); - assertNotNull(authorities); - assertEquals(2, authorities.size()); - - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * File plan role service unit test + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FilePlanRoleServiceImplTest extends BaseRMTestCase +{ + @Override + protected boolean isUserTest() + { + return true; + } + + public void testGetAllRolesContainerGroup() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + String allRolesGroup = filePlanRoleService.getAllRolesContainerGroup(filePlan); + assertNotNull(allRolesGroup); + + return null; + } + }); + } + + public void testGetRoles() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Set roles = filePlanRoleService.getRoles(filePlan); + assertNotNull(roles); + assertTrue(roles.size() != 0); + + Set rolesIncludingSystemRoles = filePlanRoleService.getRoles(filePlan, true); + assertNotNull(rolesIncludingSystemRoles); + assertTrue(roles.size() != 0); + assertTrue(roles.size() == rolesIncludingSystemRoles.size()); + + Set rolesWithoutSystemRoles = filePlanRoleService.getRoles(filePlan, false); + assertNotNull(rolesWithoutSystemRoles); + assertTrue(rolesWithoutSystemRoles.size() != 0); + assertTrue(rolesIncludingSystemRoles.size() > rolesWithoutSystemRoles.size()); + assertTrue(rolesIncludingSystemRoles.size() == rolesWithoutSystemRoles.size() + FilePlanRoleService.SYSTEM_ROLES.size()); + + return null; + } + }); + } + + public void testRolesByUser() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Set roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); + assertNotNull(roles); + assertEquals(1, roles.size()); + + Set rolesIncludingSystemRoles = filePlanRoleService.getRolesByUser(filePlan, rmUserName, true); + assertNotNull(rolesIncludingSystemRoles); + assertEquals(1, rolesIncludingSystemRoles.size()); + assertEquals(roles.size(), rolesIncludingSystemRoles.size()); + + return null; + } + }); + } + + public void testGetRole() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Role role = filePlanRoleService.getRole(filePlan, FilePlanRoleService.ROLE_POWER_USER); + assertNotNull(role); + assertEquals(FilePlanRoleService.ROLE_POWER_USER, role.getName()); + + role = filePlanRoleService.getRole(filePlan, "donkey"); + assertNull(role); + + return null; + } + }); + } + + public void testExistsRole() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + assertTrue(filePlanRoleService.existsRole(filePlan, FilePlanRoleService.ROLE_POWER_USER)); + assertFalse(filePlanRoleService.existsRole(filePlan, "donkey")); + + return null; + } + }); + } + + public void testCreateUpdateDeleteRole() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + assertFalse(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); + + Set caps = new HashSet(2); + caps.add(capabilityService.getCapability(RMPermissionModel.ACCESS_AUDIT)); + caps.add(capabilityService.getCapability(RMPermissionModel.ADD_MODIFY_EVENT_DATES)); + + Role role = filePlanRoleService.createRole(filePlan, "Michelle Holt", "Michelle Holt", caps); + assertNotNull(role); + assertEquals("Michelle Holt", role.getName()); + assertEquals(2, role.getCapabilities().size()); + + assertTrue(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); + + caps.add(capabilityService.getCapability(RMPermissionModel.AUTHORIZE_ALL_TRANSFERS)); + + role = filePlanRoleService.updateRole(filePlan, "Michelle Holt", "Michelle Wetherall", caps); + assertNotNull(role); + assertEquals("Michelle Holt", role.getName()); + assertEquals(3, role.getCapabilities().size()); + + assertTrue(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); + + filePlanRoleService.deleteRole(filePlan, "Michelle Holt"); + + assertFalse(filePlanRoleService.existsRole(filePlan, "Michelle Holt")); + + return null; + } + }); + } + + /** + * {@link FilePlanRoleService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, String, String)} + * {@link FilePlanRoleService#getAuthorities(org.alfresco.service.cmr.repository.NodeRef, String) + */ + public void testAuthorityAssignment() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + Set roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); + assertNotNull(roles); + assertEquals(1, roles.size()); + + Set authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(1, authorities.size()); + + authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(0, authorities.size()); + + authorities = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(1, authorities.size()); + + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, rmUserName); + + roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName); + assertNotNull(roles); + assertEquals(2, roles.size()); + + authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(2, authorities.size()); + + authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(0, authorities.size()); + + authorities = filePlanRoleService.getAllAssignedToRole(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER); + assertNotNull(authorities); + assertEquals(2, authorities.size()); + + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanServiceImplTest.java index bbf38f7b38..cd95144906 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanServiceImplTest.java @@ -1,537 +1,537 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - -/** - * File plan service unit test - * - * @author Roy Wetherall - * @since 2.1 - */ -public class FilePlanServiceImplTest extends BaseRMTestCase -{ - /** - * Pull in collaboration test data - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * {@link FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)} - */ - public void testIsFilePlan() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - assertTrue(filePlanService.isFilePlan(filePlan)); - assertFalse(filePlanService.isFilePlan(rmContainer)); - assertFalse(filePlanService.isFilePlan(dmDocument)); - } - }); - } - - /** - * {@link FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)} - */ - public void testGetFilePlans() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); - assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); - assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); - assertNull(filePlanService.getFilePlan(dmDocument)); - } - }); - } - - /** - * {@link FilePlanService#getFilePlanBySiteId(String)} - */ - public void testGetFilePlanBySiteId() - { - doTestInTransaction(new VoidTest() - { - public void runImpl() throws Exception - { - assertEquals(filePlan, filePlanService.getFilePlanBySiteId(siteId)); - assertNull(filePlanService.getFilePlanBySiteId("rubbish")); - - String siteId = GUID.generate(); - siteService.createSite("anything", siteId, "title", "descrition", SiteVisibility.PUBLIC); - assertNull(filePlanService.getFilePlanBySiteId(siteId)); - } - }); - - } - - /** - * @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) - */ - public void testIsFilePlanComponent() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); - assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); - assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); - - return null; - } - }); - } - - /** - * @see FilePlanService#getFilePlanComponentKind(NodeRef) - */ - public void testGetFilePlanComponentKind() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return utils.createRecord(rmFolder, "testRecord.txt"); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); - assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); - assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); - assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); - // TODO HOLD and TRANSFER - assertNull(filePlanService.getFilePlanComponentKind(folder)); - } - }); - } - - /** - * @see FilePlanService#isRecordCategory(NodeRef) - */ - public void testIsRecordCategory() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); - assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); - assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); - - return null; - } - }); - } - - /** - * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String) - * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName) - */ - public void testCreateFilePlan() throws Exception - { - // Create default type of root - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createFilePlan(folder, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management root", result); - basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); - } - }); - - // Create specific type of root - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management root", result); - basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); - } - }); - - // Failure: creating root in existing hierarchy - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createFilePlan(rmContainer, GUID.generate()); - } - }); - - // Failure: type no extended from root container - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); - } - }); - } - - /** - * A basic test of a records management container - * - * @param nodeRef node reference - * @param name name of the container - * @param type the type of container - */ - private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) - { - // Check the basic details - assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); - assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); - assertEquals(type, nodeService.getType(nodeRef)); - } - - /** - * @see FilePlanService#createRecordCategory(NodeRef, String) - * @see FilePlanService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName) - */ - public void testCreateRecordCategory() throws Exception - { - // Create container (in root) - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createRecordCategory(filePlan, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management container", result); - basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); - } - }); - - // Create container (in container) - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createRecordCategory(rmContainer, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management container", result); - basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); - } - }); - - // TODO need a custom type of container! - // Create container of a given type -// doTestInTransaction(new Test() -// { -// @Override -// public NodeRef run() -// { -// String id = setString("id", GUID.generate()); -// return rmService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); -// } -// -// @Override -// public void test(NodeRef result) -// { -// assertNotNull("Unable to create records management container", result); -// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); -// } -// }); - - // Fail Test: parent is not a container - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createRecordCategory(folder, GUID.generate()); - } - }); - - // Fail Test: type is not a sub-type of rm:recordsManagementContainer - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); - } - }); - } - - /** - * @see FilePlanService#getAllContained(NodeRef) - * @see FilePlanService#getAllContained(NodeRef, boolean) - */ - public void testGetAllContained() throws Exception - { - // Get all contained test - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getAllContained(rmContainer); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getAllContained(rmContainer, false); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getAllContained(rmContainer, true); - assertNotNull(nodes); - assertEquals(4, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); - assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); - - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getAllContained(rmFolder); - } - }); - } - - /** - * @see FilePlanService#getContainedRecordCategories(NodeRef) - * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) - */ - public void testGetContainedRecordCategories() throws Exception - { - // Test getting all contained containers - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getContainedRecordCategories(rmContainer); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = filePlanService.getContainedRecordCategories(rmContainer, false); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = filePlanService.getContainedRecordCategories(rmContainer, true); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getContainedRecordCategories(rmFolder); - } - }); - } - - /** - * @see FilePlanService#getContainedRecordFolders(NodeRef) - * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) - */ - public void testGetContainedRecordFolders() throws Exception - { - // Test getting all contained record folders - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getContainedRecordFolders(rmContainer); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getContainedRecordFolders(rmContainer, false); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getContainedRecordFolders(rmContainer, true); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getContainedRecordFolders(rmFolder); - } - }); - } - - /** - * Test to create a simple multi-hierarchy record taxonomy - */ - public void testCreateSimpleHierarchy() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Create 3 level hierarchy - NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); - assertNotNull("Unable to create container", levelOne); - NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); - assertNotNull("Unable to create container", levelTwo); - NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); - assertNotNull("Unable to create container", levelThree); - NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); - assertNotNull("Unable to create record folder", levelThreeRecordFolder); - - return null; - } - - @Override - public void test(Void result) - { - // Test that the hierarchy has been created correctly - basicRMContainerCheck(getNodeRef("container1"), "container1", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); - - // TODO need to check that the parents and children can be retrieved correctly - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + +/** + * File plan service unit test + * + * @author Roy Wetherall + * @since 2.1 + */ +public class FilePlanServiceImplTest extends BaseRMTestCase +{ + /** + * Pull in collaboration test data + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * {@link FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)} + */ + public void testIsFilePlan() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + assertTrue(filePlanService.isFilePlan(filePlan)); + assertFalse(filePlanService.isFilePlan(rmContainer)); + assertFalse(filePlanService.isFilePlan(dmDocument)); + } + }); + } + + /** + * {@link FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)} + */ + public void testGetFilePlans() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); + assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); + assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); + assertNull(filePlanService.getFilePlan(dmDocument)); + } + }); + } + + /** + * {@link FilePlanService#getFilePlanBySiteId(String)} + */ + public void testGetFilePlanBySiteId() + { + doTestInTransaction(new VoidTest() + { + public void runImpl() throws Exception + { + assertEquals(filePlan, filePlanService.getFilePlanBySiteId(siteId)); + assertNull(filePlanService.getFilePlanBySiteId("rubbish")); + + String siteId = GUID.generate(); + siteService.createSite("anything", siteId, "title", "descrition", SiteVisibility.PUBLIC); + assertNull(filePlanService.getFilePlanBySiteId(siteId)); + } + }); + + } + + /** + * @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testIsFilePlanComponent() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); + assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); + assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); + + return null; + } + }); + } + + /** + * @see FilePlanService#getFilePlanComponentKind(NodeRef) + */ + public void testGetFilePlanComponentKind() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return utils.createRecord(rmFolder, "testRecord.txt"); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); + assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); + assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); + assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); + // TODO HOLD and TRANSFER + assertNull(filePlanService.getFilePlanComponentKind(folder)); + } + }); + } + + /** + * @see FilePlanService#isRecordCategory(NodeRef) + */ + public void testIsRecordCategory() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); + assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); + + return null; + } + }); + } + + /** + * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String) + * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName) + */ + public void testCreateFilePlan() throws Exception + { + // Create default type of root + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createFilePlan(folder, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management root", result); + basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); + } + }); + + // Create specific type of root + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management root", result); + basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); + } + }); + + // Failure: creating root in existing hierarchy + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createFilePlan(rmContainer, GUID.generate()); + } + }); + + // Failure: type no extended from root container + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); + } + }); + } + + /** + * A basic test of a records management container + * + * @param nodeRef node reference + * @param name name of the container + * @param type the type of container + */ + private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) + { + // Check the basic details + assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); + assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); + assertEquals(type, nodeService.getType(nodeRef)); + } + + /** + * @see FilePlanService#createRecordCategory(NodeRef, String) + * @see FilePlanService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName) + */ + public void testCreateRecordCategory() throws Exception + { + // Create container (in root) + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createRecordCategory(filePlan, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management container", result); + basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); + } + }); + + // Create container (in container) + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createRecordCategory(rmContainer, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management container", result); + basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); + } + }); + + // TODO need a custom type of container! + // Create container of a given type +// doTestInTransaction(new Test() +// { +// @Override +// public NodeRef run() +// { +// String id = setString("id", GUID.generate()); +// return rmService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); +// } +// +// @Override +// public void test(NodeRef result) +// { +// assertNotNull("Unable to create records management container", result); +// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); +// } +// }); + + // Fail Test: parent is not a container + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createRecordCategory(folder, GUID.generate()); + } + }); + + // Fail Test: type is not a sub-type of rm:recordsManagementContainer + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); + } + }); + } + + /** + * @see FilePlanService#getAllContained(NodeRef) + * @see FilePlanService#getAllContained(NodeRef, boolean) + */ + public void testGetAllContained() throws Exception + { + // Get all contained test + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getAllContained(rmContainer); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getAllContained(rmContainer, false); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getAllContained(rmContainer, true); + assertNotNull(nodes); + assertEquals(4, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); + assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); + + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getAllContained(rmFolder); + } + }); + } + + /** + * @see FilePlanService#getContainedRecordCategories(NodeRef) + * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) + */ + public void testGetContainedRecordCategories() throws Exception + { + // Test getting all contained containers + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getContainedRecordCategories(rmContainer); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, false); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, true); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getContainedRecordCategories(rmFolder); + } + }); + } + + /** + * @see FilePlanService#getContainedRecordFolders(NodeRef) + * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) + */ + public void testGetContainedRecordFolders() throws Exception + { + // Test getting all contained record folders + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getContainedRecordFolders(rmContainer); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, false); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, true); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getContainedRecordFolders(rmFolder); + } + }); + } + + /** + * Test to create a simple multi-hierarchy record taxonomy + */ + public void testCreateSimpleHierarchy() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Create 3 level hierarchy + NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); + assertNotNull("Unable to create container", levelOne); + NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); + assertNotNull("Unable to create container", levelTwo); + NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); + assertNotNull("Unable to create container", levelThree); + NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); + assertNotNull("Unable to create record folder", levelThreeRecordFolder); + + return null; + } + + @Override + public void test(Void result) + { + // Test that the hierarchy has been created correctly + basicRMContainerCheck(getNodeRef("container1"), "container1", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); + + // TODO need to check that the parents and children can be retrieved correctly + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FreezeServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FreezeServiceImplTest.java index 77b2cfa09c..6a149b8232 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FreezeServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FreezeServiceImplTest.java @@ -1,236 +1,236 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Freeze service implementation test. - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class FreezeServiceImplTest extends BaseRMTestCase -{ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * Test freeze service methods. - * - * @deprecated as of 2.2 - */ - public void testFreezeService() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - assertTrue(recordService.isRecord(recordOne)); - assertTrue(recordService.isRecord(recordTwo)); - assertTrue(recordService.isRecord(recordThree)); - assertTrue(recordService.isRecord(recordFour)); - assertTrue(filePlanService.isFilePlanComponent(recordOne)); - assertTrue(filePlanService.isFilePlanComponent(recordTwo)); - assertTrue(filePlanService.isFilePlanComponent(recordThree)); - assertTrue(filePlanService.isFilePlanComponent(recordFour)); - - // Freeze a record - NodeRef hold101 = holdService.createHold(filePlan, "freezename 101", "FreezeReason", null); - assertNotNull(hold101); - holdService.addToHold(hold101, recordOne); - //assertTrue(freezeService.hasFrozenChildren(rmFolder)); - - // Check the hold exists - List holdAssocs = holdService.getHolds(filePlan); - assertNotNull(holdAssocs); - assertEquals(1, holdAssocs.size()); - NodeRef holdNodeRef = holdAssocs.iterator().next(); - assertEquals(holdNodeRef, hold101); - assertTrue(holdService.isHold(holdNodeRef)); - assertEquals("FreezeReason", holdService.getHoldReason(holdNodeRef)); - List frozenNodes = holdService.getHeld(holdNodeRef); - assertNotNull(frozenNodes); - assertEquals(1, frozenNodes.size()); - - // Check the nodes are frozen - assertTrue(freezeService.isFrozen(recordOne)); - assertNotNull(freezeService.getFreezeDate(recordOne)); - assertNotNull(freezeService.getFreezeInitiator(recordOne)); - assertFalse(freezeService.isFrozen(recordTwo)); - assertFalse(freezeService.isFrozen(recordThree)); - - // Update the freeze reason - holdService.setHoldReason(holdNodeRef, "NewFreezeReason"); - - // Check the hold has been updated - assertEquals("NewFreezeReason", holdService.getHoldReason(holdNodeRef)); - - // Freeze a number of records - List records = new ArrayList(); - records.add(recordOne); - records.add(recordTwo); - records.add(recordThree); - NodeRef newHold = holdService.createHold(filePlan, "Hold 102", "Freeze a set of nodes", null); - holdService.addToHold(newHold, records); - assertNotNull(newHold); - assertTrue(holdService.isHold(newHold)); - - // Check the holds exist - holdAssocs = holdService.getHolds(filePlan); - assertNotNull(holdAssocs); - assertEquals(2, holdAssocs.size()); - for (NodeRef hold : holdAssocs) - { - String reason = holdService.getHoldReason(hold); - if (reason.equals("Freeze a set of nodes")) - { - assertEquals(newHold, hold); - frozenNodes = holdService.getHeld(hold); - assertNotNull(frozenNodes); - assertEquals(3, frozenNodes.size()); - } - else if (reason.equals("NewFreezeReason")) - { - frozenNodes = holdService.getHeld(hold); - assertNotNull(frozenNodes); - assertEquals(1, frozenNodes.size()); - } - else - { - throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds."); - } - } - - // Check the nodes are frozen - final List testRecords = Arrays.asList(new NodeRef[]{recordOne, recordTwo, recordThree}); - for (NodeRef nr : testRecords) - { - assertTrue(freezeService.isFrozen(nr)); - assertNotNull(freezeService.getFreezeDate(nr)); - assertNotNull(freezeService.getFreezeInitiator(nr)); - } - - // Unfreeze a node - holdService.removeFromAllHolds(recordThree); - - // Check the holds - holdAssocs = holdService.getHolds(filePlan); - assertNotNull(holdAssocs); - assertEquals(2, holdAssocs.size()); - for (NodeRef hold : holdAssocs) - { - String reason = holdService.getHoldReason(hold); - if (reason.equals("Freeze a set of nodes")) - { - frozenNodes = holdService.getHeld(hold); - assertNotNull(frozenNodes); - assertEquals(2, frozenNodes.size()); - } - else if (reason.equals("NewFreezeReason")) - { - frozenNodes = holdService.getHeld(hold); - assertNotNull(frozenNodes); - assertEquals(1, frozenNodes.size()); - } - else - { - throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds."); - } - } - - // Check the nodes are frozen - assertTrue(freezeService.isFrozen(recordOne)); - assertNotNull(freezeService.getFreezeDate(recordOne)); - assertNotNull(freezeService.getFreezeInitiator(recordOne)); - assertTrue(freezeService.isFrozen(recordTwo)); - assertNotNull(freezeService.getFreezeDate(recordTwo)); - assertNotNull(freezeService.getFreezeInitiator(recordTwo)); - assertFalse(freezeService.isFrozen(recordThree)); - assertFalse(freezeService.isFrozen(recordFour)); - - // Relinquish the first hold - holdNodeRef = holdAssocs.iterator().next(); - holdService.deleteHold(holdNodeRef); - - // Check the existing hold - holdAssocs = holdService.getHolds(filePlan); - assertNotNull(holdAssocs); - assertEquals(1, holdAssocs.size()); - - // Relinquish the second hold - holdNodeRef = holdAssocs.iterator().next(); - holdService.removeFromAllHolds(holdService.getHeld(holdNodeRef)); - - // hold is not automatically removed - holdAssocs = holdService.getHolds(filePlan); - assertEquals(1, holdAssocs.size()); - - // delete hold - holdService.deleteHold(holdNodeRef); - holdAssocs = holdService.getHolds(filePlan); - assertEquals(0, holdAssocs.size()); - - // Check the nodes are unfrozen - assertFalse(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(recordTwo)); - assertFalse(freezeService.isFrozen(recordThree)); - assertFalse(freezeService.isFrozen(recordFour)); - //assertFalse(freezeService.hasFrozenChildren(rmFolder)); - - // Test freezing nodes, adding them to an existing hold - NodeRef hold = holdService.createHold(filePlan, "hold 1", "AnotherFreezeReason", "description"); - holdService.addToHold(hold, recordFour); - holdService.addToHold(hold, recordOne); - List nodes = new ArrayList(); - nodes.add(recordTwo); - nodes.add(recordThree); - holdService.addToHold(hold, nodes); - //assertTrue(freezeService.hasFrozenChildren(rmFolder)); - - // Check the hold - holdAssocs = holdService.getHolds(filePlan); - assertNotNull(holdAssocs); - assertEquals(1, holdAssocs.size()); - - // Relinquish the first hold - holdService.deleteHold(holdAssocs.iterator().next()); - - // Check the nodes are unfrozen - assertFalse(freezeService.isFrozen(recordOne)); - assertFalse(freezeService.isFrozen(recordTwo)); - assertFalse(freezeService.isFrozen(recordThree)); - assertFalse(freezeService.isFrozen(recordFour)); - // assertFalse(freezeService.hasFrozenChildren(rmFolder)); - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Freeze service implementation test. + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class FreezeServiceImplTest extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Test freeze service methods. + * + * @deprecated as of 2.2 + */ + public void testFreezeService() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + assertTrue(recordService.isRecord(recordOne)); + assertTrue(recordService.isRecord(recordTwo)); + assertTrue(recordService.isRecord(recordThree)); + assertTrue(recordService.isRecord(recordFour)); + assertTrue(filePlanService.isFilePlanComponent(recordOne)); + assertTrue(filePlanService.isFilePlanComponent(recordTwo)); + assertTrue(filePlanService.isFilePlanComponent(recordThree)); + assertTrue(filePlanService.isFilePlanComponent(recordFour)); + + // Freeze a record + NodeRef hold101 = holdService.createHold(filePlan, "freezename 101", "FreezeReason", null); + assertNotNull(hold101); + holdService.addToHold(hold101, recordOne); + //assertTrue(freezeService.hasFrozenChildren(rmFolder)); + + // Check the hold exists + List holdAssocs = holdService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(1, holdAssocs.size()); + NodeRef holdNodeRef = holdAssocs.iterator().next(); + assertEquals(holdNodeRef, hold101); + assertTrue(holdService.isHold(holdNodeRef)); + assertEquals("FreezeReason", holdService.getHoldReason(holdNodeRef)); + List frozenNodes = holdService.getHeld(holdNodeRef); + assertNotNull(frozenNodes); + assertEquals(1, frozenNodes.size()); + + // Check the nodes are frozen + assertTrue(freezeService.isFrozen(recordOne)); + assertNotNull(freezeService.getFreezeDate(recordOne)); + assertNotNull(freezeService.getFreezeInitiator(recordOne)); + assertFalse(freezeService.isFrozen(recordTwo)); + assertFalse(freezeService.isFrozen(recordThree)); + + // Update the freeze reason + holdService.setHoldReason(holdNodeRef, "NewFreezeReason"); + + // Check the hold has been updated + assertEquals("NewFreezeReason", holdService.getHoldReason(holdNodeRef)); + + // Freeze a number of records + List records = new ArrayList(); + records.add(recordOne); + records.add(recordTwo); + records.add(recordThree); + NodeRef newHold = holdService.createHold(filePlan, "Hold 102", "Freeze a set of nodes", null); + holdService.addToHold(newHold, records); + assertNotNull(newHold); + assertTrue(holdService.isHold(newHold)); + + // Check the holds exist + holdAssocs = holdService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(2, holdAssocs.size()); + for (NodeRef hold : holdAssocs) + { + String reason = holdService.getHoldReason(hold); + if (reason.equals("Freeze a set of nodes")) + { + assertEquals(newHold, hold); + frozenNodes = holdService.getHeld(hold); + assertNotNull(frozenNodes); + assertEquals(3, frozenNodes.size()); + } + else if (reason.equals("NewFreezeReason")) + { + frozenNodes = holdService.getHeld(hold); + assertNotNull(frozenNodes); + assertEquals(1, frozenNodes.size()); + } + else + { + throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds."); + } + } + + // Check the nodes are frozen + final List testRecords = Arrays.asList(new NodeRef[]{recordOne, recordTwo, recordThree}); + for (NodeRef nr : testRecords) + { + assertTrue(freezeService.isFrozen(nr)); + assertNotNull(freezeService.getFreezeDate(nr)); + assertNotNull(freezeService.getFreezeInitiator(nr)); + } + + // Unfreeze a node + holdService.removeFromAllHolds(recordThree); + + // Check the holds + holdAssocs = holdService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(2, holdAssocs.size()); + for (NodeRef hold : holdAssocs) + { + String reason = holdService.getHoldReason(hold); + if (reason.equals("Freeze a set of nodes")) + { + frozenNodes = holdService.getHeld(hold); + assertNotNull(frozenNodes); + assertEquals(2, frozenNodes.size()); + } + else if (reason.equals("NewFreezeReason")) + { + frozenNodes = holdService.getHeld(hold); + assertNotNull(frozenNodes); + assertEquals(1, frozenNodes.size()); + } + else + { + throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds."); + } + } + + // Check the nodes are frozen + assertTrue(freezeService.isFrozen(recordOne)); + assertNotNull(freezeService.getFreezeDate(recordOne)); + assertNotNull(freezeService.getFreezeInitiator(recordOne)); + assertTrue(freezeService.isFrozen(recordTwo)); + assertNotNull(freezeService.getFreezeDate(recordTwo)); + assertNotNull(freezeService.getFreezeInitiator(recordTwo)); + assertFalse(freezeService.isFrozen(recordThree)); + assertFalse(freezeService.isFrozen(recordFour)); + + // Relinquish the first hold + holdNodeRef = holdAssocs.iterator().next(); + holdService.deleteHold(holdNodeRef); + + // Check the existing hold + holdAssocs = holdService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(1, holdAssocs.size()); + + // Relinquish the second hold + holdNodeRef = holdAssocs.iterator().next(); + holdService.removeFromAllHolds(holdService.getHeld(holdNodeRef)); + + // hold is not automatically removed + holdAssocs = holdService.getHolds(filePlan); + assertEquals(1, holdAssocs.size()); + + // delete hold + holdService.deleteHold(holdNodeRef); + holdAssocs = holdService.getHolds(filePlan); + assertEquals(0, holdAssocs.size()); + + // Check the nodes are unfrozen + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordTwo)); + assertFalse(freezeService.isFrozen(recordThree)); + assertFalse(freezeService.isFrozen(recordFour)); + //assertFalse(freezeService.hasFrozenChildren(rmFolder)); + + // Test freezing nodes, adding them to an existing hold + NodeRef hold = holdService.createHold(filePlan, "hold 1", "AnotherFreezeReason", "description"); + holdService.addToHold(hold, recordFour); + holdService.addToHold(hold, recordOne); + List nodes = new ArrayList(); + nodes.add(recordTwo); + nodes.add(recordThree); + holdService.addToHold(hold, nodes); + //assertTrue(freezeService.hasFrozenChildren(rmFolder)); + + // Check the hold + holdAssocs = holdService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(1, holdAssocs.size()); + + // Relinquish the first hold + holdService.deleteHold(holdAssocs.iterator().next()); + + // Check the nodes are unfrozen + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordTwo)); + assertFalse(freezeService.isFrozen(recordThree)); + assertFalse(freezeService.isFrozen(recordFour)); + // assertFalse(freezeService.hasFrozenChildren(rmFolder)); + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ModelSecurityServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ModelSecurityServiceImplTest.java index a4247c96e1..b85722c9a3 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ModelSecurityServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ModelSecurityServiceImplTest.java @@ -1,269 +1,269 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedAspect; -import org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedProperty; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.namespace.QName; - -/** - * Model security service test. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class ModelSecurityServiceImplTest extends BaseRMTestCase -{ - private static final QName CUSTOM_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customAspect"); - private static final QName CUSTOM_PROTECTED_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedAspect"); - - private static final QName CUSTOM_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProperty"); - private static final QName CUSTOM_PROTECTED_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedProperty"); - - - /** Model security service */ - private ModelSecurityService modelSecurityService; - - private boolean enabled; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - @Override - protected boolean isFillingForAllUsers() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService"); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestDataImpl() - */ - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - enabled = modelSecurityService.isEnabled(); - modelSecurityService.setEnabled(true); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() - */ - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - modelSecurityService.setEnabled(enabled); - } - - /** - * test - getProtectedAspects(), isProtectedAspect(), getProtectedAspect() - */ - public void testProtectedAspects() throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - Set protectedAspects = modelSecurityService.getProtectedAspects(); - - assertNotNull(protectedAspects); - assertFalse(protectedAspects.isEmpty()); - assertTrue(protectedAspects.contains(CUSTOM_PROTECTED_ASPECT)); - assertFalse(protectedAspects.contains(CUSTOM_ASPECT)); - - assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT)); - assertFalse(modelSecurityService.isProtectedAspect(CUSTOM_ASPECT)); - - ProtectedAspect protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_ASPECT); - assertNull(protectedAspect); - protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_PROTECTED_ASPECT); - assertNotNull(protectedAspect); - assertNotNull(protectedAspect.getQName()); - assertNotNull(protectedAspect.getCapabilities()); - } - }); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT)); - assertFalse(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); - } - }, powerUserName); - - doTestInTransaction(new FailureTest - ( - "Normal rm user should not have the permissions to add the protected aspect.", - ModelAccessDeniedException.class - ) - { - @Override - public void run() throws Exception - { - // try and add the aspect - nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null); - } - }, powerUserName); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); - - // try and add the aspect - nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null); - assertTrue(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); - } - }, ADMIN_USER); - - // check protected aspect via removeAspect - doTestInTransaction(new FailureTest - ( - "Normal rm user should not have the permissions to remove the custom aspect.", - ModelAccessDeniedException.class - ) - { - @Override - public void run() throws Exception - { - nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT); - } - }, powerUserName); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT); - assertFalse(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); - } - }, ADMIN_USER); - } - - /** - * test - getProtectedProperties(), isProtectedProperty(), getProtectedProperty() - */ - public void testProtectedProperties() throws Exception - { - doTestInTransaction(new VoidTest() - { - public void runImpl() - { - Set protectedProperties = modelSecurityService.getProtectedProperties(); - - assertNotNull(protectedProperties); - assertFalse(protectedProperties.isEmpty()); - assertTrue(protectedProperties.contains(CUSTOM_PROTECTED_PROPERTY)); - assertFalse(protectedProperties.contains(CUSTOM_PROPERTY)); - - assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY)); - assertFalse(modelSecurityService.isProtectedProperty(CUSTOM_PROPERTY)); - - ProtectedProperty protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROPERTY); - assertNull(protectedProperty); - protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROTECTED_PROPERTY); - assertNotNull(protectedProperty); - assertNotNull(protectedProperty.getQName()); - assertNotNull(protectedProperty.getCapabilities()); - } - }); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); - } - }, ADMIN_USER); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); - } - }, powerUserName); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY)); - assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); - } - }, powerUserName); - - doTestInTransaction(new FailureTest - ( - "Should not have the permissions to edit protected property.", - ModelAccessDeniedException.class - ) - { - @Override - public void run() throws Exception - { - nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello"); - } - }, powerUserName); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); - - nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello"); - assertEquals("hello", nodeService.getProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); - } - }, ADMIN_USER); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedAspect; +import org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedProperty; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.namespace.QName; + +/** + * Model security service test. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class ModelSecurityServiceImplTest extends BaseRMTestCase +{ + private static final QName CUSTOM_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customAspect"); + private static final QName CUSTOM_PROTECTED_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedAspect"); + + private static final QName CUSTOM_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProperty"); + private static final QName CUSTOM_PROTECTED_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedProperty"); + + + /** Model security service */ + private ModelSecurityService modelSecurityService; + + private boolean enabled; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected boolean isFillingForAllUsers() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService"); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestDataImpl() + */ + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + enabled = modelSecurityService.isEnabled(); + modelSecurityService.setEnabled(true); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() + */ + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + modelSecurityService.setEnabled(enabled); + } + + /** + * test - getProtectedAspects(), isProtectedAspect(), getProtectedAspect() + */ + public void testProtectedAspects() throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + Set protectedAspects = modelSecurityService.getProtectedAspects(); + + assertNotNull(protectedAspects); + assertFalse(protectedAspects.isEmpty()); + assertTrue(protectedAspects.contains(CUSTOM_PROTECTED_ASPECT)); + assertFalse(protectedAspects.contains(CUSTOM_ASPECT)); + + assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT)); + assertFalse(modelSecurityService.isProtectedAspect(CUSTOM_ASPECT)); + + ProtectedAspect protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_ASPECT); + assertNull(protectedAspect); + protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_PROTECTED_ASPECT); + assertNotNull(protectedAspect); + assertNotNull(protectedAspect.getQName()); + assertNotNull(protectedAspect.getCapabilities()); + } + }); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT)); + assertFalse(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); + } + }, powerUserName); + + doTestInTransaction(new FailureTest + ( + "Normal rm user should not have the permissions to add the protected aspect.", + ModelAccessDeniedException.class + ) + { + @Override + public void run() throws Exception + { + // try and add the aspect + nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null); + } + }, powerUserName); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); + + // try and add the aspect + nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null); + assertTrue(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); + } + }, ADMIN_USER); + + // check protected aspect via removeAspect + doTestInTransaction(new FailureTest + ( + "Normal rm user should not have the permissions to remove the custom aspect.", + ModelAccessDeniedException.class + ) + { + @Override + public void run() throws Exception + { + nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT); + } + }, powerUserName); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT); + assertFalse(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT)); + } + }, ADMIN_USER); + } + + /** + * test - getProtectedProperties(), isProtectedProperty(), getProtectedProperty() + */ + public void testProtectedProperties() throws Exception + { + doTestInTransaction(new VoidTest() + { + public void runImpl() + { + Set protectedProperties = modelSecurityService.getProtectedProperties(); + + assertNotNull(protectedProperties); + assertFalse(protectedProperties.isEmpty()); + assertTrue(protectedProperties.contains(CUSTOM_PROTECTED_PROPERTY)); + assertFalse(protectedProperties.contains(CUSTOM_PROPERTY)); + + assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY)); + assertFalse(modelSecurityService.isProtectedProperty(CUSTOM_PROPERTY)); + + ProtectedProperty protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROPERTY); + assertNull(protectedProperty); + protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROTECTED_PROPERTY); + assertNotNull(protectedProperty); + assertNotNull(protectedProperty.getQName()); + assertNotNull(protectedProperty.getCapabilities()); + } + }); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); + } + }, ADMIN_USER); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); + } + }, powerUserName); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY)); + assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); + } + }, powerUserName); + + doTestInTransaction(new FailureTest + ( + "Should not have the permissions to edit protected property.", + ModelAccessDeniedException.class + ) + { + @Override + public void run() throws Exception + { + nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello"); + } + }, powerUserName); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); + + nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello"); + assertEquals("hello", nodeService.getProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY)); + } + }, ADMIN_USER); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RMCaveatConfigServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RMCaveatConfigServiceImplTest.java index 1e95b97e55..693b0572e5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RMCaveatConfigServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RMCaveatConfigServiceImplTest.java @@ -1,19 +1,19 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java index a9061361bd..f85c28b17c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java @@ -1,764 +1,764 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - -/** - * Records Service Implementation Test - * - * @author Roy Wetherall - * @author Tuna Aksoy - * @since 2.1 - */ -public class RecordServiceImplTest extends BaseRMTestCase -{ - /** - * This is a user test - * - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * This is a record test - * - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() - */ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * This is a collaboration site test - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * @see RecordService#getRecordMetaDataAspects() - */ - public void testGetRecordMetaDataAspects() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Set aspects = recordService.getRecordMetadataAspects(filePlan); - assertNotNull(aspects); - assertEquals(2, aspects.size()); - assertTrue(aspects.containsAll(getAspectList())); - - return null; - } - - /** - * Helper method for getting a list of record meta data aspects - * - * @return Record meta data aspects as list - */ - private List getAspectList() - { - QName[] aspects = new QName[] - { - ASPECT_RECORD_META_DATA - }; - - return Arrays.asList(aspects); - } - }); - } - - /** - * @see RecordService#isRecord(org.alfresco.service.cmr.repository.NodeRef) - */ - public void testIsRecord() throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() - { - assertFalse(recordService.isRecord(filePlan)); - assertFalse(recordService.isRecord(rmContainer)); - assertFalse(recordService.isRecord(rmFolder)); - assertTrue(recordService.isRecord(recordOne)); - assertTrue(recordService.isRecord(recordDeclaredOne)); - } - }); - } - - /** - * @see RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) - */ - public void testIsDeclared() throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() - { - assertFalse(recordService.isRecord(filePlan)); - assertFalse(recordService.isRecord(rmContainer)); - assertFalse(recordService.isRecord(rmFolder)); - assertTrue(recordService.isRecord(recordOne)); - assertTrue(recordService.isRecord(recordDeclaredOne)); - } - }); - } - - public void testUnfiled() throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() - { - assertFalse(recordService.isFiled(filePlan)); - assertFalse(recordService.isFiled(rmContainer)); - assertFalse(recordService.isFiled(rmFolder)); - assertTrue(recordService.isFiled(recordOne)); - assertTrue(recordService.isFiled(recordDeclaredOne)); - } - }); - } - - public void testExtendedWriters() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertTrue(extendedSecurityService.getReaders(recordOne).isEmpty()); - assertTrue(extendedSecurityService.getWriters(recordOne).isEmpty()); - - return null; - } - }, dmCollaborator); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA)); - - return null; - } - }, dmCollaborator); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Set writers = new HashSet(1); - writers.add(dmCollaborator); - extendedSecurityService.set(recordOne, null, writers); - - assertTrue(extendedSecurityService.getReaders(recordOne).isEmpty()); - assertFalse(extendedSecurityService.getWriters(recordOne).isEmpty()); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); - - // ALLOWED, becuase users have been added to the in-place roles - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA)); - - return null; - } - }, dmCollaborator); - - } - - /** - * @see RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.service.cmr.repository.NodeRef) - */ - public void testCreateRecord() throws Exception - { - // show that users without WRITE can not create a record from a document - doTestInTransaction(new FailureTest( - "Can not create a record from a document if you do not have WRITE permissions.", - AccessDeniedException.class) - { - public void run() throws Exception - { - recordService.createRecord(filePlan, dmDocument); - } - }, dmConsumer); - - // create record from document - doTestInTransaction(new Test() - { - private NodeRef originalLocation; - - @Override - public Void run() - { - originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); - - assertFalse(recordService.isRecord(dmDocument)); - assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); - - checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - - checkPermissions(FILING, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - recordService.createRecord(filePlan, dmDocument); - - return null; - } - - public void test(Void result) - { - checkPermissions(READ_RECORDS, - AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.ALLOWED); // doc/record - - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - - checkPermissions(FILING, - AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.ALLOWED); // doc/record - - assertTrue(recordService.isRecord(dmDocument)); - assertTrue(extendedSecurityService.hasExtendedSecurity(dmDocument)); - assertFalse(recordService.isFiled(dmDocument)); - - // show that the record has meta-data about it's original - // location - assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS)); - assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); - assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); - - // show that the record is linked to it's original location - assertEquals(2, nodeService.getParentAssocs(dmDocument).size()); - - // **** - // Capability Tests - // **** - - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, - RMPermissionModel.EDIT_NON_RECORD_METADATA)); - - Capability filling = capabilityService.getCapability("FileRecords"); - assertEquals(AccessStatus.DENIED, filling.hasPermission(dmDocument)); - - Capability editRecordMetadata = capabilityService.getCapability("EditNonRecordMetadata"); - assertEquals(AccessStatus.ALLOWED, editRecordMetadata.hasPermission(dmDocument)); - - Capability updateProperties = capabilityService.getCapability("UpdateProperties"); - assertEquals(AccessStatus.ALLOWED, updateProperties.hasPermission(dmDocument)); - } - }, dmCollaborator); - - // check the consumer's permissions are correct for the newly created - // document - doTestInTransaction(new Test() - { - @Override - public Void run() - { - checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.ALLOWED); // doc/record - - checkPermissions(FILING, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, - RMPermissionModel.EDIT_NON_RECORD_METADATA)); - - Capability filling = capabilityService.getCapability("FileRecords"); - assertEquals(AccessStatus.DENIED, filling.hasPermission(dmDocument)); - - Capability editRecordMetadata = capabilityService.getCapability("EditNonRecordMetadata"); - assertEquals(AccessStatus.DENIED, editRecordMetadata.hasPermission(dmDocument)); - - Capability updateProperties = capabilityService.getCapability("UpdateProperties"); - assertEquals(AccessStatus.DENIED, updateProperties.hasPermission(dmDocument)); - - return null; - } - }, dmConsumer); - } - - public void testCreateRecordNoLink() throws Exception - { - // show that users without WRITE can not create a record from a document - doTestInTransaction(new FailureTest( - "Can not create a record from a document if you do not have WRITE permissions.", - AccessDeniedException.class) - { - public void run() throws Exception - { - recordService.createRecord(filePlan, dmDocument, false); - } - }, dmConsumer); - - // create record from document - final NodeRef originalLocation = doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); - - //assertFalse(recordService.isRecord(dmDocument)); - //assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); - - checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - - checkPermissions(FILING, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - recordService.createRecord(filePlan, dmDocument, false); - - checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, - RMPermissionModel.VIEW_RECORDS)); - - checkPermissions(FILING, AccessStatus.DENIED, // file plan - AccessStatus.DENIED, // unfiled container - AccessStatus.DENIED, // record category - AccessStatus.DENIED, // record folder - AccessStatus.DENIED); // doc/record - - return originalLocation; - } - }, dmCollaborator); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertTrue(recordService.isRecord(dmDocument)); - assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); - assertFalse(recordService.isFiled(dmDocument)); - - // show that the record has meta-data about it's original - // location - assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS)); - assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); - assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); - - // show that the record is linked to it's original location - assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); - - return null; - } - }, ADMIN_USER); - } - - public void testFileNewContent() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - NodeRef record = fileFolderService.create(rmFolder, "test101.txt", TYPE_CONTENT).getNodeRef(); - - ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent("hello world this is some test content"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertTrue(recordService.isRecord(record)); - assertTrue(recordService.isFiled(record)); - - assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); - } - }); - } - - public void xtestFileUnfiledrecord() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - recordService.createRecord(filePlan, dmDocument); - - assertTrue(recordService.isRecord(dmDocument)); - assertFalse(recordService.isFiled(dmDocument)); - - assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); - - fileFolderService.move(dmDocument, rmFolder, "record.txt"); - - return dmDocument; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertTrue(recordService.isRecord(record)); - assertTrue(recordService.isFiled(record)); - - assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); - } - }); - } - - public void testFileDirectlyFromCollab() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); - - fileFolderService.move(dmDocument, rmFolder, "record.txt"); - - return dmDocument; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertTrue(recordService.isRecord(record)); - assertTrue(recordService.isFiled(record)); - - assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); - } - }, AuthenticationUtil.getSystemUserName()); - } - - private void checkPermissions(String permission, AccessStatus filePlanExpected, AccessStatus unfiledExpected, - AccessStatus recordCatExpected, AccessStatus recordFolderExpected, AccessStatus recordExpected) - { - assertEquals(filePlanExpected, permissionService.hasPermission(filePlan, permission)); - assertEquals(unfiledExpected, permissionService.hasPermission(unfiledContainer, permission)); - assertEquals(recordCatExpected, permissionService.hasPermission(rmContainer, permission)); - assertEquals(recordFolderExpected, permissionService.hasPermission(rmFolder, permission)); - assertEquals(recordExpected, permissionService.hasPermission(dmDocument, permission)); - } - - private String createUserWithCapabilties(final String... capabiltyNames) - { - return doTestInTransaction(new Test() - { - @Override - public String run() throws Exception - { - Role role = utils.createRole(filePlan, GUID.generate(), capabiltyNames); - - String userName = GUID.generate(); - createPerson(userName); - filePlanRoleService.assignRoleToAuthority(filePlan, role.getName(), userName); - - return userName; - } - }, AuthenticationUtil.getSystemUserName()); - - } - - /** - * Test {@link RecordService#isPropertyEditable(NodeRef, QName)} - */ - public void testIsPropertyEditable() throws Exception - { - final String nonRecordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_NON_RECORD_METADATA); - final String recordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_RECORD_METADATA); - final String declaredRecordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - filePlanPermissionService.setPermission(rmFolder, rmUserName, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, nonRecordMetadata, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, recordMetadata, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, declaredRecordMetadata, RMPermissionModel.FILING); - } - }); - - // test rmadmin - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); - assertTrue(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); - assertTrue(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); - } - }); - - // test normal user - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); - - assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); - } - }, rmUserName); - - // test undeclared record with edit non-record metadata capability - // test declared record with edit non-record metadata capability - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); - assertTrue(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); - } - }, nonRecordMetadata); - - // test undeclared record with edit record metadata capability - // test declared record with edit record metadata capability - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertTrue(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); - } - }, recordMetadata); - - // test undeclared record with edit declared record metadata capability - // test declared record with edit declared record metadata capability - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); - assertTrue(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); - assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); - } - }, declaredRecordMetadata); - } - - public void testRecordPropertiesUpdate() throws Exception - { - final String nonRecordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_NON_RECORD_METADATA); - final String recordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_RECORD_METADATA); - final String declaredRecordMetadata = createUserWithCapabilties( - RMPermissionModel.VIEW_RECORDS, - RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - filePlanPermissionService.setPermission(rmFolder, rmUserName, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, nonRecordMetadata, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, recordMetadata, RMPermissionModel.FILING); - filePlanPermissionService.setPermission(rmFolder, declaredRecordMetadata, RMPermissionModel.FILING); - } - }); - - // test rmadmin - canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER); - canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER); - cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER); - canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER); - - // test normal user - cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, rmUserName); - cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, rmUserName); - cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, rmUserName); - cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, rmUserName); - - // test undeclared record with edit non-record metadata capability - canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, nonRecordMetadata); - cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, nonRecordMetadata); - // test declared record with edit non-record metadata capability - cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, nonRecordMetadata); - cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, nonRecordMetadata); - - // test undeclared record with edit record metadata capability - cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, recordMetadata); - canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, recordMetadata); - // test declared record with edit record metadata capability - cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, recordMetadata); - cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, recordMetadata); - - // test undeclared record with edit declared record metadata capability - cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, declaredRecordMetadata); - cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, declaredRecordMetadata); - // test declared record with edit declared record metadata capability - cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, declaredRecordMetadata); - canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, declaredRecordMetadata); - - } - - private void cantEditProperty(final NodeRef nodeRef, final QName property, String user) throws Exception - { - boolean failure = false; - try - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - nodeService.setProperty(nodeRef, property, GUID.generate()); - } - - }, user); - } - catch (Throwable exception) - { - // expected - failure = true; - } - - // assert fail not failure - if (!failure) - { - fail("Property should not have been editable."); - } - } - - private void canEditProperty(final NodeRef nodeRef, final QName property, String user) throws Exception - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - nodeService.setProperty(nodeRef, property, GUID.generate()); - } - }, user); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + +/** + * Records Service Implementation Test + * + * @author Roy Wetherall + * @author Tuna Aksoy + * @since 2.1 + */ +public class RecordServiceImplTest extends BaseRMTestCase +{ + /** + * This is a user test + * + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * This is a record test + * + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() + */ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * This is a collaboration site test + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** + * @see RecordService#getRecordMetaDataAspects() + */ + public void testGetRecordMetaDataAspects() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Set aspects = recordService.getRecordMetadataAspects(filePlan); + assertNotNull(aspects); + assertEquals(2, aspects.size()); + assertTrue(aspects.containsAll(getAspectList())); + + return null; + } + + /** + * Helper method for getting a list of record meta data aspects + * + * @return Record meta data aspects as list + */ + private List getAspectList() + { + QName[] aspects = new QName[] + { + ASPECT_RECORD_META_DATA + }; + + return Arrays.asList(aspects); + } + }); + } + + /** + * @see RecordService#isRecord(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testIsRecord() throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() + { + assertFalse(recordService.isRecord(filePlan)); + assertFalse(recordService.isRecord(rmContainer)); + assertFalse(recordService.isRecord(rmFolder)); + assertTrue(recordService.isRecord(recordOne)); + assertTrue(recordService.isRecord(recordDeclaredOne)); + } + }); + } + + /** + * @see RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testIsDeclared() throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() + { + assertFalse(recordService.isRecord(filePlan)); + assertFalse(recordService.isRecord(rmContainer)); + assertFalse(recordService.isRecord(rmFolder)); + assertTrue(recordService.isRecord(recordOne)); + assertTrue(recordService.isRecord(recordDeclaredOne)); + } + }); + } + + public void testUnfiled() throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() + { + assertFalse(recordService.isFiled(filePlan)); + assertFalse(recordService.isFiled(rmContainer)); + assertFalse(recordService.isFiled(rmFolder)); + assertTrue(recordService.isFiled(recordOne)); + assertTrue(recordService.isFiled(recordDeclaredOne)); + } + }); + } + + public void testExtendedWriters() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertTrue(extendedSecurityService.getReaders(recordOne).isEmpty()); + assertTrue(extendedSecurityService.getWriters(recordOne).isEmpty()); + + return null; + } + }, dmCollaborator); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA)); + + return null; + } + }, dmCollaborator); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Set writers = new HashSet(1); + writers.add(dmCollaborator); + extendedSecurityService.set(recordOne, null, writers); + + assertTrue(extendedSecurityService.getReaders(recordOne).isEmpty()); + assertFalse(extendedSecurityService.getWriters(recordOne).isEmpty()); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); + + // ALLOWED, becuase users have been added to the in-place roles + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA)); + + return null; + } + }, dmCollaborator); + + } + + /** + * @see RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, + * org.alfresco.service.cmr.repository.NodeRef) + */ + public void testCreateRecord() throws Exception + { + // show that users without WRITE can not create a record from a document + doTestInTransaction(new FailureTest( + "Can not create a record from a document if you do not have WRITE permissions.", + AccessDeniedException.class) + { + public void run() throws Exception + { + recordService.createRecord(filePlan, dmDocument); + } + }, dmConsumer); + + // create record from document + doTestInTransaction(new Test() + { + private NodeRef originalLocation; + + @Override + public Void run() + { + originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); + + assertFalse(recordService.isRecord(dmDocument)); + assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); + + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + + checkPermissions(FILING, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + recordService.createRecord(filePlan, dmDocument); + + return null; + } + + public void test(Void result) + { + checkPermissions(READ_RECORDS, + AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.ALLOWED); // doc/record + + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + + checkPermissions(FILING, + AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.ALLOWED); // doc/record + + assertTrue(recordService.isRecord(dmDocument)); + assertTrue(extendedSecurityService.hasExtendedSecurity(dmDocument)); + assertFalse(recordService.isFiled(dmDocument)); + + // show that the record has meta-data about it's original + // location + assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS)); + assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); + assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); + + // show that the record is linked to it's original location + assertEquals(2, nodeService.getParentAssocs(dmDocument).size()); + + // **** + // Capability Tests + // **** + + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, + RMPermissionModel.EDIT_NON_RECORD_METADATA)); + + Capability filling = capabilityService.getCapability("FileRecords"); + assertEquals(AccessStatus.DENIED, filling.hasPermission(dmDocument)); + + Capability editRecordMetadata = capabilityService.getCapability("EditNonRecordMetadata"); + assertEquals(AccessStatus.ALLOWED, editRecordMetadata.hasPermission(dmDocument)); + + Capability updateProperties = capabilityService.getCapability("UpdateProperties"); + assertEquals(AccessStatus.ALLOWED, updateProperties.hasPermission(dmDocument)); + } + }, dmCollaborator); + + // check the consumer's permissions are correct for the newly created + // document + doTestInTransaction(new Test() + { + @Override + public Void run() + { + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.ALLOWED); // doc/record + + checkPermissions(FILING, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, + RMPermissionModel.EDIT_NON_RECORD_METADATA)); + + Capability filling = capabilityService.getCapability("FileRecords"); + assertEquals(AccessStatus.DENIED, filling.hasPermission(dmDocument)); + + Capability editRecordMetadata = capabilityService.getCapability("EditNonRecordMetadata"); + assertEquals(AccessStatus.DENIED, editRecordMetadata.hasPermission(dmDocument)); + + Capability updateProperties = capabilityService.getCapability("UpdateProperties"); + assertEquals(AccessStatus.DENIED, updateProperties.hasPermission(dmDocument)); + + return null; + } + }, dmConsumer); + } + + public void testCreateRecordNoLink() throws Exception + { + // show that users without WRITE can not create a record from a document + doTestInTransaction(new FailureTest( + "Can not create a record from a document if you do not have WRITE permissions.", + AccessDeniedException.class) + { + public void run() throws Exception + { + recordService.createRecord(filePlan, dmDocument, false); + } + }, dmConsumer); + + // create record from document + final NodeRef originalLocation = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); + + //assertFalse(recordService.isRecord(dmDocument)); + //assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); + + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + + checkPermissions(FILING, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + recordService.createRecord(filePlan, dmDocument, false); + + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(filePlan, + RMPermissionModel.VIEW_RECORDS)); + + checkPermissions(FILING, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container + AccessStatus.DENIED, // record category + AccessStatus.DENIED, // record folder + AccessStatus.DENIED); // doc/record + + return originalLocation; + } + }, dmCollaborator); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertTrue(recordService.isRecord(dmDocument)); + assertFalse(extendedSecurityService.hasExtendedSecurity(dmDocument)); + assertFalse(recordService.isFiled(dmDocument)); + + // show that the record has meta-data about it's original + // location + assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS)); + assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION)); + assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); + + // show that the record is linked to it's original location + assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); + + return null; + } + }, ADMIN_USER); + } + + public void testFileNewContent() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + NodeRef record = fileFolderService.create(rmFolder, "test101.txt", TYPE_CONTENT).getNodeRef(); + + ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent("hello world this is some test content"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertTrue(recordService.isRecord(record)); + assertTrue(recordService.isFiled(record)); + + assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); + } + }); + } + + public void xtestFileUnfiledrecord() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + recordService.createRecord(filePlan, dmDocument); + + assertTrue(recordService.isRecord(dmDocument)); + assertFalse(recordService.isFiled(dmDocument)); + + assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); + + fileFolderService.move(dmDocument, rmFolder, "record.txt"); + + return dmDocument; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertTrue(recordService.isRecord(record)); + assertTrue(recordService.isFiled(record)); + + assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); + } + }); + } + + public void testFileDirectlyFromCollab() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); + + fileFolderService.move(dmDocument, rmFolder, "record.txt"); + + return dmDocument; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertTrue(recordService.isRecord(record)); + assertTrue(recordService.isFiled(record)); + + assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); + } + }, AuthenticationUtil.getSystemUserName()); + } + + private void checkPermissions(String permission, AccessStatus filePlanExpected, AccessStatus unfiledExpected, + AccessStatus recordCatExpected, AccessStatus recordFolderExpected, AccessStatus recordExpected) + { + assertEquals(filePlanExpected, permissionService.hasPermission(filePlan, permission)); + assertEquals(unfiledExpected, permissionService.hasPermission(unfiledContainer, permission)); + assertEquals(recordCatExpected, permissionService.hasPermission(rmContainer, permission)); + assertEquals(recordFolderExpected, permissionService.hasPermission(rmFolder, permission)); + assertEquals(recordExpected, permissionService.hasPermission(dmDocument, permission)); + } + + private String createUserWithCapabilties(final String... capabiltyNames) + { + return doTestInTransaction(new Test() + { + @Override + public String run() throws Exception + { + Role role = utils.createRole(filePlan, GUID.generate(), capabiltyNames); + + String userName = GUID.generate(); + createPerson(userName); + filePlanRoleService.assignRoleToAuthority(filePlan, role.getName(), userName); + + return userName; + } + }, AuthenticationUtil.getSystemUserName()); + + } + + /** + * Test {@link RecordService#isPropertyEditable(NodeRef, QName)} + */ + public void testIsPropertyEditable() throws Exception + { + final String nonRecordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_NON_RECORD_METADATA); + final String recordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_RECORD_METADATA); + final String declaredRecordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + filePlanPermissionService.setPermission(rmFolder, rmUserName, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, nonRecordMetadata, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, recordMetadata, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, declaredRecordMetadata, RMPermissionModel.FILING); + } + }); + + // test rmadmin + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); + assertTrue(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); + assertTrue(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); + } + }); + + // test normal user + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); + + assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); + } + }, rmUserName); + + // test undeclared record with edit non-record metadata capability + // test declared record with edit non-record metadata capability + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); + assertTrue(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); + } + }, nonRecordMetadata); + + // test undeclared record with edit record metadata capability + // test declared record with edit record metadata capability + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertTrue(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); + } + }, recordMetadata); + + // test undeclared record with edit declared record metadata capability + // test declared record with edit declared record metadata capability + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + assertFalse(recordService.isPropertyEditable(recordOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordOne, PROP_DESCRIPTION)); + assertTrue(recordService.isPropertyEditable(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION)); + assertFalse(recordService.isPropertyEditable(recordDeclaredOne, PROP_DESCRIPTION)); + } + }, declaredRecordMetadata); + } + + public void testRecordPropertiesUpdate() throws Exception + { + final String nonRecordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_NON_RECORD_METADATA); + final String recordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_RECORD_METADATA); + final String declaredRecordMetadata = createUserWithCapabilties( + RMPermissionModel.VIEW_RECORDS, + RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + filePlanPermissionService.setPermission(rmFolder, rmUserName, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, nonRecordMetadata, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, recordMetadata, RMPermissionModel.FILING); + filePlanPermissionService.setPermission(rmFolder, declaredRecordMetadata, RMPermissionModel.FILING); + } + }); + + // test rmadmin + canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER); + canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER); + cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER); + canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER); + + // test normal user + cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, rmUserName); + cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, rmUserName); + cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, rmUserName); + cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, rmUserName); + + // test undeclared record with edit non-record metadata capability + canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, nonRecordMetadata); + cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, nonRecordMetadata); + // test declared record with edit non-record metadata capability + cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, nonRecordMetadata); + cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, nonRecordMetadata); + + // test undeclared record with edit record metadata capability + cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, recordMetadata); + canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, recordMetadata); + // test declared record with edit record metadata capability + cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, recordMetadata); + cantEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, recordMetadata); + + // test undeclared record with edit declared record metadata capability + cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, declaredRecordMetadata); + cantEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, declaredRecordMetadata); + // test declared record with edit declared record metadata capability + cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, declaredRecordMetadata); + canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, declaredRecordMetadata); + + } + + private void cantEditProperty(final NodeRef nodeRef, final QName property, String user) throws Exception + { + boolean failure = false; + try + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + nodeService.setProperty(nodeRef, property, GUID.generate()); + } + + }, user); + } + catch (Throwable exception) + { + // expected + failure = true; + } + + // assert fail not failure + if (!failure) + { + fail("Property should not have been editable."); + } + } + + private void canEditProperty(final NodeRef nodeRef, final QName property, String user) throws Exception + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + nodeService.setProperty(nodeRef, property, GUID.generate()); + } + }, user); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementActionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementActionServiceImplTest.java index b87e6474ad..4482750f45 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementActionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementActionServiceImplTest.java @@ -1,289 +1,289 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - -/** - * Records management action service implementation test - * - * @author Roy Wetherall - */ -public class RecordsManagementActionServiceImplTest extends TestCase - implements RecordsManagementModel, - BeforeRMActionExecution, - OnRMActionExecution -{ - private static final String[] CONFIG_LOCATIONS = new String[] { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml"}; - - private ApplicationContext ctx; - - private ServiceRegistry serviceRegistry; - private TransactionService transactionService; - private RetryingTransactionHelper txnHelper; - private NodeService nodeService; - private RecordsManagementActionService rmActionService; - private PolicyComponent policyComponent; - - private NodeRef nodeRef; - private List nodeRefs; - - private boolean beforeMarker; - private boolean onMarker; - private boolean inTest; - - @Override - protected void setUp() throws Exception - { - ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); - - this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - this.transactionService = serviceRegistry.getTransactionService(); - this.txnHelper = transactionService.getRetryingTransactionHelper(); - this.nodeService = serviceRegistry.getNodeService(); - - this.rmActionService = (RecordsManagementActionService)ctx.getBean("RecordsManagementActionService"); - this.policyComponent = (PolicyComponent)ctx.getBean("policyComponent"); - - // Set the current security context as admin - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - RetryingTransactionCallback setUpCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Create a node we can use for the tests - NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); - nodeRef = nodeService.createNode( - rootNodeRef, - ContentModel.ASSOC_CHILDREN, - QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"), - ContentModel.TYPE_CONTENT).getChildRef(); - - // Create nodeRef list - nodeRefs = new ArrayList(5); - for (int i = 0; i < 5; i++) - { - nodeRefs.add( - nodeService.createNode( - rootNodeRef, - ContentModel.ASSOC_CHILDREN, - QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"), - ContentModel.TYPE_CONTENT).getChildRef()); - } - return null; - } - }; - txnHelper.doInTransaction(setUpCallback); - - beforeMarker = false; - onMarker = false; - inTest = false; - } - - @Override - protected void tearDown() - { - AuthenticationUtil.clearCurrentSecurityContext(); - } - - public void testGetActions() - { - RetryingTransactionCallback testCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - getActionsImpl(); - return null; - } - }; - txnHelper.doInTransaction(testCallback); - } - - private void getActionsImpl() - { - List result = this.rmActionService.getRecordsManagementActions(); - assertNotNull(result); - Map resultMap = new HashMap(8); - for (RecordsManagementAction action : result) - { - resultMap.put(action.getName(), action); - } - - assertTrue(resultMap.containsKey(TestAction.NAME)); - assertTrue(resultMap.containsKey(TestAction2.NAME)); - - result = this.rmActionService.getDispositionActions(); - resultMap = new HashMap(8); - for (RecordsManagementAction action : result) - { - resultMap.put(action.getName(), action); - } - assertTrue(resultMap.containsKey(TestAction.NAME)); - assertFalse(resultMap.containsKey(TestAction2.NAME)); - - // get some specific actions and check the label - RecordsManagementAction cutoff = this.rmActionService.getDispositionAction("cutoff"); - assertNotNull(cutoff); - assertEquals("Cut off", cutoff.getLabel()); - - RecordsManagementAction freeze = this.rmActionService.getRecordsManagementAction("freeze"); - assertNotNull(freeze); - assertEquals("Freeze", freeze.getLabel()); - assertEquals("Freeze", freeze.getLabel()); - - // test non-existent actions - assertNull(this.rmActionService.getDispositionAction("notThere")); - assertNull(this.rmActionService.getRecordsManagementAction("notThere")); - } - - public void testExecution() - { - RetryingTransactionCallback testCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - executionImpl(); - return null; - } - }; - txnHelper.doInTransaction(testCallback); - } - - public void beforeRMActionExecution(NodeRef nodeRef, String name, Map parameters) - { - if (inTest) - { - assertEquals(this.nodeRef, nodeRef); - assertEquals(TestAction.NAME, name); - assertEquals(1, parameters.size()); - assertTrue(parameters.containsKey(TestAction.PARAM)); - assertEquals(TestAction.PARAM_VALUE, parameters.get(TestAction.PARAM)); - beforeMarker = true; - } - } - - public void onRMActionExecution(NodeRef nodeRef, String name, Map parameters) - { - if (inTest) - { - assertEquals(this.nodeRef, nodeRef); - assertEquals(TestAction.NAME, name); - assertEquals(1, parameters.size()); - assertTrue(parameters.containsKey(TestAction.PARAM)); - assertEquals(TestAction.PARAM_VALUE, parameters.get(TestAction.PARAM)); - onMarker = true; - } - } - - private void executionImpl() - { - inTest = true; - try - { - policyComponent.bindClassBehaviour( - RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION, - this, - new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT)); - policyComponent.bindClassBehaviour( - RecordsManagementPolicies.ON_RM_ACTION_EXECUTION, - this, - new JavaBehaviour(this, "onRMActionExecution", NotificationFrequency.EVERY_EVENT)); - - assertFalse(beforeMarker); - assertFalse(onMarker); - assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD)); - - Map params = new HashMap(1); - params.put(TestAction.PARAM, TestAction.PARAM_VALUE); - this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params); - - assertTrue(beforeMarker); - assertTrue(onMarker); - assertTrue(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD)); - } - finally - { - inTest = false; - } - } - - public void testBulkExecution() - { - RetryingTransactionCallback testCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - bulkExecutionImpl(); - return null; - } - }; - txnHelper.doInTransaction(testCallback); - } - - private void bulkExecutionImpl() - { - for (NodeRef nodeRef : this.nodeRefs) - { - assertFalse(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD)); - } - - Map params = new HashMap(1); - params.put(TestAction.PARAM, TestAction.PARAM_VALUE); - this.rmActionService.executeRecordsManagementAction(this.nodeRefs, TestAction.NAME, params); - - for (NodeRef nodeRef : this.nodeRefs) - { - assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD)); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.springframework.context.ApplicationContext; + +/** + * Records management action service implementation test + * + * @author Roy Wetherall + */ +public class RecordsManagementActionServiceImplTest extends TestCase + implements RecordsManagementModel, + BeforeRMActionExecution, + OnRMActionExecution +{ + private static final String[] CONFIG_LOCATIONS = new String[] { + "classpath:alfresco/application-context.xml", + "classpath:test-context.xml"}; + + private ApplicationContext ctx; + + private ServiceRegistry serviceRegistry; + private TransactionService transactionService; + private RetryingTransactionHelper txnHelper; + private NodeService nodeService; + private RecordsManagementActionService rmActionService; + private PolicyComponent policyComponent; + + private NodeRef nodeRef; + private List nodeRefs; + + private boolean beforeMarker; + private boolean onMarker; + private boolean inTest; + + @Override + protected void setUp() throws Exception + { + ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); + + this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); + this.transactionService = serviceRegistry.getTransactionService(); + this.txnHelper = transactionService.getRetryingTransactionHelper(); + this.nodeService = serviceRegistry.getNodeService(); + + this.rmActionService = (RecordsManagementActionService)ctx.getBean("RecordsManagementActionService"); + this.policyComponent = (PolicyComponent)ctx.getBean("policyComponent"); + + // Set the current security context as admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + RetryingTransactionCallback setUpCallback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Create a node we can use for the tests + NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + nodeRef = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"), + ContentModel.TYPE_CONTENT).getChildRef(); + + // Create nodeRef list + nodeRefs = new ArrayList(5); + for (int i = 0; i < 5; i++) + { + nodeRefs.add( + nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"), + ContentModel.TYPE_CONTENT).getChildRef()); + } + return null; + } + }; + txnHelper.doInTransaction(setUpCallback); + + beforeMarker = false; + onMarker = false; + inTest = false; + } + + @Override + protected void tearDown() + { + AuthenticationUtil.clearCurrentSecurityContext(); + } + + public void testGetActions() + { + RetryingTransactionCallback testCallback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + getActionsImpl(); + return null; + } + }; + txnHelper.doInTransaction(testCallback); + } + + private void getActionsImpl() + { + List result = this.rmActionService.getRecordsManagementActions(); + assertNotNull(result); + Map resultMap = new HashMap(8); + for (RecordsManagementAction action : result) + { + resultMap.put(action.getName(), action); + } + + assertTrue(resultMap.containsKey(TestAction.NAME)); + assertTrue(resultMap.containsKey(TestAction2.NAME)); + + result = this.rmActionService.getDispositionActions(); + resultMap = new HashMap(8); + for (RecordsManagementAction action : result) + { + resultMap.put(action.getName(), action); + } + assertTrue(resultMap.containsKey(TestAction.NAME)); + assertFalse(resultMap.containsKey(TestAction2.NAME)); + + // get some specific actions and check the label + RecordsManagementAction cutoff = this.rmActionService.getDispositionAction("cutoff"); + assertNotNull(cutoff); + assertEquals("Cut off", cutoff.getLabel()); + + RecordsManagementAction freeze = this.rmActionService.getRecordsManagementAction("freeze"); + assertNotNull(freeze); + assertEquals("Freeze", freeze.getLabel()); + assertEquals("Freeze", freeze.getLabel()); + + // test non-existent actions + assertNull(this.rmActionService.getDispositionAction("notThere")); + assertNull(this.rmActionService.getRecordsManagementAction("notThere")); + } + + public void testExecution() + { + RetryingTransactionCallback testCallback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + executionImpl(); + return null; + } + }; + txnHelper.doInTransaction(testCallback); + } + + public void beforeRMActionExecution(NodeRef nodeRef, String name, Map parameters) + { + if (inTest) + { + assertEquals(this.nodeRef, nodeRef); + assertEquals(TestAction.NAME, name); + assertEquals(1, parameters.size()); + assertTrue(parameters.containsKey(TestAction.PARAM)); + assertEquals(TestAction.PARAM_VALUE, parameters.get(TestAction.PARAM)); + beforeMarker = true; + } + } + + public void onRMActionExecution(NodeRef nodeRef, String name, Map parameters) + { + if (inTest) + { + assertEquals(this.nodeRef, nodeRef); + assertEquals(TestAction.NAME, name); + assertEquals(1, parameters.size()); + assertTrue(parameters.containsKey(TestAction.PARAM)); + assertEquals(TestAction.PARAM_VALUE, parameters.get(TestAction.PARAM)); + onMarker = true; + } + } + + private void executionImpl() + { + inTest = true; + try + { + policyComponent.bindClassBehaviour( + RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION, + this, + new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT)); + policyComponent.bindClassBehaviour( + RecordsManagementPolicies.ON_RM_ACTION_EXECUTION, + this, + new JavaBehaviour(this, "onRMActionExecution", NotificationFrequency.EVERY_EVENT)); + + assertFalse(beforeMarker); + assertFalse(onMarker); + assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD)); + + Map params = new HashMap(1); + params.put(TestAction.PARAM, TestAction.PARAM_VALUE); + this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params); + + assertTrue(beforeMarker); + assertTrue(onMarker); + assertTrue(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD)); + } + finally + { + inTest = false; + } + } + + public void testBulkExecution() + { + RetryingTransactionCallback testCallback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + bulkExecutionImpl(); + return null; + } + }; + txnHelper.doInTransaction(testCallback); + } + + private void bulkExecutionImpl() + { + for (NodeRef nodeRef : this.nodeRefs) + { + assertFalse(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD)); + } + + Map params = new HashMap(1); + params.put(TestAction.PARAM, TestAction.PARAM_VALUE); + this.rmActionService.executeRecordsManagementAction(this.nodeRefs, TestAction.NAME, params); + + for (NodeRef nodeRef : this.nodeRefs) + { + assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD)); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAdminServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAdminServiceImplTest.java index a2790fac5b..c7b7d53f1d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAdminServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAdminServiceImplTest.java @@ -1,943 +1,943 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; -import org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.Constraint; -import org.alfresco.service.cmr.dictionary.ConstraintDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.Pair; -import org.springframework.util.CollectionUtils; - -/** - * This test class tests the definition and use of a custom RM elements at the Java services layer. - * - * @author Neil McErlean, janv, Roy Wetherall - */ -public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase - implements RecordsManagementModel, - BeforeCreateReference, - OnCreateReference -{ - - private final static long testRunID = System.currentTimeMillis(); - - private List createdCustomProperties; - private List madeCustomisable; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp() - */ - @Override - protected void setUp() throws Exception - { - createdCustomProperties = new ArrayList(); - madeCustomisable = new ArrayList(); - super.setUp(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData() - */ - @Override - protected void setupTestData() - { - super.setupTestData(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - // As system user - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - for (QName createdCustomProperty : createdCustomProperties) - { - rmAdminService.removeCustomPropertyDefinition(createdCustomProperty); - } - - for (QName customisable : madeCustomisable) - { - rmAdminService.unmakeCustomisable(customisable); - } - - return null; - } - }); - - super.tearDown(); - } - - /** - * @see RecordsManagementAdminService#getCustomisable() - */ - public void testGetCustomisable() throws Exception - { - // Get the customisable types - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Set list = rmAdminService.getCustomisable(); - assertNotNull(list); - assertTrue(list.containsAll( - CollectionUtils.arrayToList(new QName[] - { - ASPECT_RECORD, - TYPE_RECORD_FOLDER, - TYPE_NON_ELECTRONIC_DOCUMENT, - TYPE_RECORD_CATEGORY - }))); - - return null; - } - }); - } - - /** - * @see RecordsManagementAdminService#isCustomisable(QName) - */ - public void testIsCustomisable() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - assertFalse(rmAdminService.isCustomisable(TYPE_CONTENT)); - assertFalse(rmAdminService.isCustomisable(ASPECT_DUBLINCORE)); - assertTrue(rmAdminService.isCustomisable(TYPE_RECORD_FOLDER)); - assertTrue(rmAdminService.isCustomisable(ASPECT_RECORD)); - - return null; - } - }); - } - - /** - * @see RecordsManagementAdminService#existsCustomProperty(QName) - * @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String, String, boolean, boolean, boolean, QName) - * @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String) - */ - public void testAddCustomPropertyDefinition() throws Exception - { - // Add property to Record (id specified, short version) - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - // Check the property does not exist - assertFalse(rmAdminService.existsCustomProperty(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"))); - - return rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), - ASPECT_RECORD, - "Label1", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - - @Override - public void test(QName result) throws Exception - { - try - { - // Check the property QName is correct - assertNotNull(result); - assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), result); - assertTrue(rmAdminService.existsCustomProperty(result)); - - // Check that property is available as a custom property - Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); - assertNotNull(propDefs); - assertTrue(propDefs.containsKey(result)); - - // Check the property definition - PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); - assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription(dictionaryService)); - assertEquals("Label1", propDef.getTitle(dictionaryService)); - } - finally - { - // Store the created property for cleanup later - createdCustomProperties.add(result); - } - } - }); - - // Add property to record (no id, short version) - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - return rmAdminService.addCustomPropertyDefinition( - null, - ASPECT_RECORD, - "Label2", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - - @Override - public void test(QName result) throws Exception - { - try - { - // Check the property QName is correct - assertNotNull(result); - assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); - assertTrue(rmAdminService.existsCustomProperty(result)); - - // Check that property is available as a custom property - Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); - assertNotNull(propDefs); - assertTrue(propDefs.containsKey(result)); - - // Check the property definition - PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); - assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription(dictionaryService)); - assertEquals("Label2", propDef.getTitle(dictionaryService)); - } - finally - { - // Store the created property for cleanup later - createdCustomProperties.add(result); - } - } - }); - - // Add property to record (long version) - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - return rmAdminService.addCustomPropertyDefinition( - null, - ASPECT_RECORD, - "Label3", - DataTypeDefinition.TEXT, - "Title", - "Description", - "default", - false, - false, - false, - null); - } - - @Override - public void test(QName result) throws Exception - { - try - { - // Check the property QName is correct - assertNotNull(result); - assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); - assertTrue(rmAdminService.existsCustomProperty(result)); - - // Check that property is available as a custom property - Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); - assertNotNull(propDefs); - //assertEquals(3, propDefs.size()); - assertTrue(propDefs.containsKey(result)); - - // Check the property definition - PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); - assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription(dictionaryService)); - assertEquals("Label3", propDef.getTitle(dictionaryService)); - assertEquals("default", propDef.getDefaultValue()); - assertFalse(propDef.isMandatory()); - assertFalse(propDef.isMultiValued()); - assertFalse(propDef.isProtected()); - - } - finally - { - // Store the created property for cleanup later - createdCustomProperties.add(result); - } - } - }); - - // Failure: Add a property with the same name twice - doTestInTransaction(new FailureTest - ( - "Can not create a property with the same id twice", - CustomMetadataException.class - ) - { - @Override - public void run() throws Exception - { - rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), - ASPECT_RECORD, - "Label1", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - }); - - // Failure: Try and add a property to a type that isn't customisable - doTestInTransaction(new FailureTest - ( - "Can not add a custom property to a type that isn't registered as customisable", - CustomMetadataException.class - ) - { - @Override - public void run() throws Exception - { - rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"), - TYPE_CONTENT, - "Label1", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - }); - } - - /** - * @see RecordsManagementAdminService#makeCustomisable(QName) - */ - public void testMakeCustomisable() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - // Make a type customisable - assertFalse(rmAdminService.isCustomisable(TYPE_CUSTOM_TYPE)); - rmAdminService.makeCustomisable(TYPE_CUSTOM_TYPE); - madeCustomisable.add(TYPE_CUSTOM_TYPE); - assertTrue(rmAdminService.isCustomisable(TYPE_CUSTOM_TYPE)); - - // Add a custom property - return rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), - TYPE_CUSTOM_TYPE, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - - @Override - public void test(QName result) throws Exception - { - // Check the property QName is correct - assertNotNull(result); - assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), result); - assertTrue(rmAdminService.existsCustomProperty(result)); - - // Check that property is available as a custom property - Map propDefs = rmAdminService.getCustomPropertyDefinitions(TYPE_CUSTOM_TYPE); - assertNotNull(propDefs); - assertEquals(1, propDefs.size()); - assertTrue(propDefs.containsKey(result)); - - // Check the property definition - PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); - assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription(dictionaryService)); - assertEquals("Label", propDef.getTitle(dictionaryService)); - - } - }); - - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - // Make an aspect customisable - assertFalse(rmAdminService.isCustomisable(ASPECT_CUSTOM_ASPECT)); - rmAdminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); - madeCustomisable.add(ASPECT_CUSTOM_ASPECT); - assertTrue(rmAdminService.isCustomisable(ASPECT_CUSTOM_ASPECT)); - - // Add a custom property - return rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), - ASPECT_CUSTOM_ASPECT, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); - } - - @Override - public void test(QName result) throws Exception - { - // Check the property QName is correct - assertNotNull(result); - assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), result); - assertTrue(rmAdminService.existsCustomProperty(result)); - - // Check that property is available as a custom property - Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_CUSTOM_ASPECT); - assertNotNull(propDefs); - assertEquals(1, propDefs.size()); - assertTrue(propDefs.containsKey(result)); - - // Check the property definition - PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); - assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription(dictionaryService)); - assertEquals("Label", propDef.getTitle(dictionaryService)); - } - }); - } - - public void testUseCustomProperty() throws Exception - { - // Create custom property on type and aspect - doTestInTransaction(new Test() - { - @Override - public QName run() throws Exception - { - rmAdminService.makeCustomisable(TYPE_CUSTOM_TYPE); - madeCustomisable.add(TYPE_CUSTOM_TYPE); - rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), - TYPE_CUSTOM_TYPE, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); - rmAdminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); - madeCustomisable.add(ASPECT_CUSTOM_ASPECT); - rmAdminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), - ASPECT_CUSTOM_ASPECT, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - return null; - } +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; +import org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.Constraint; +import org.alfresco.service.cmr.dictionary.ConstraintDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.Pair; +import org.springframework.util.CollectionUtils; + +/** + * This test class tests the definition and use of a custom RM elements at the Java services layer. + * + * @author Neil McErlean, janv, Roy Wetherall + */ +public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase + implements RecordsManagementModel, + BeforeCreateReference, + OnCreateReference +{ + + private final static long testRunID = System.currentTimeMillis(); + + private List createdCustomProperties; + private List madeCustomisable; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + createdCustomProperties = new ArrayList(); + madeCustomisable = new ArrayList(); + super.setUp(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData() + */ + @Override + protected void setupTestData() + { + super.setupTestData(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + // As system user + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + for (QName createdCustomProperty : createdCustomProperties) + { + rmAdminService.removeCustomPropertyDefinition(createdCustomProperty); + } + + for (QName customisable : madeCustomisable) + { + rmAdminService.unmakeCustomisable(customisable); + } + + return null; + } }); - // Create nodes using custom type and aspect - doTestInTransaction(new Test() + super.tearDown(); + } + + /** + * @see RecordsManagementAdminService#getCustomisable() + */ + public void testGetCustomisable() throws Exception + { + // Get the customisable types + doTestInTransaction(new Test() { - @Override - public QName run() throws Exception + @Override + public Void run() throws Exception { - NodeRef customInstance1 = nodeService.createNode( - folder, - ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"), - TYPE_CUSTOM_TYPE).getChildRef(); - NodeRef customInstance2 = nodeService.createNode( - folder, - ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"), - TYPE_CONTENT).getChildRef(); - nodeService.addAspect(customInstance2, ASPECT_CUSTOM_ASPECT, null); - - // Assert that both instances have the custom aspects applied - assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); - assertTrue(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); - - // Remove the custom aspect - nodeService.removeAspect(customInstance2, ASPECT_CUSTOM_ASPECT); - - // Assert the custom property aspect is no longer applied applied - assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); - assertFalse(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); - + Set list = rmAdminService.getCustomisable(); + assertNotNull(list); + assertTrue(list.containsAll( + CollectionUtils.arrayToList(new QName[] + { + ASPECT_RECORD, + TYPE_RECORD_FOLDER, + TYPE_NON_ELECTRONIC_DOCUMENT, + TYPE_RECORD_CATEGORY + }))); + return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - - public void testCreateAndUseCustomChildReference() throws Exception - { - long now = System.currentTimeMillis(); - createAndUseCustomReference(RelationshipType.PARENTCHILD, null, "superseded" + now, "superseding" + now); - } - - public void testCreateAndUseCustomNonChildReference() throws Exception - { - long now = System.currentTimeMillis(); - createAndUseCustomReference(RelationshipType.BIDIRECTIONAL, "supporting" + now, null, null); - } - - private void createAndUseCustomReference(final RelationshipType refType, final String label, final String source, final String target) throws Exception - { - final NodeRef testRecord1 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - NodeRef result = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis()); - return result; - } - }); - final NodeRef testRecord2 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - NodeRef result = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); - return result; - } - }); - - final QName generatedQName = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public QName execute() throws Throwable - { - utils.completeRecord(testRecord1); - utils.completeRecord(testRecord2); - - Map params = new HashMap(); - params.put("referenceType", refType.toString()); - if (label != null) params.put("label", label); - if (source != null) params.put("source", source); - if (target != null) params.put("target", target); - - // Create the relationship display name - RelationshipDisplayName displayName; - if (label != null) - { - // A bidirectional reference - displayName = new RelationshipDisplayName(label, label); - } - else - { - // A parent/child reference - displayName = new RelationshipDisplayName(source, target); - } - - // Create the relationship definition - RelationshipDefinition relationshipDefinition = relationshipService.createRelationshipDefinition(displayName); - - // Get the qualified name - QName qNameResult = QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), namespaceService);; - - System.out.println("Creating new " + refType + " reference definition: " + qNameResult); - System.out.println(" params- label: '" + label + "' source: '" + source + "' target: '" + target + "'"); - - return qNameResult; - } - }); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - RelationshipDefinition relationshipDefinition = relationshipService.getRelationshipDefinition(generatedQName.getLocalName()); - assertNotNull("Relationship definition from relationshipService was null.", relationshipDefinition); - assertEquals(generatedQName.getLocalName(), relationshipDefinition.getUniqueName()); - assertTrue(refType.equals(relationshipDefinition.getType())); - - // Now we need to use the custom reference. - // So we apply the aspect containing it to our test records. - nodeService.addAspect(testRecord1, ASPECT_CUSTOM_ASSOCIATIONS, null); - - if (RelationshipType.PARENTCHILD.equals(refType)) - { - nodeService.addChild(testRecord1, testRecord2, generatedQName, generatedQName); - } - else - { - nodeService.createAssociation(testRecord1, testRecord2, generatedQName); - } - return null; - } - }); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Read back the reference value to make sure it was correctly applied. - List childAssocs = nodeService.getChildAssocs(testRecord1); - List retrievedAssocs = nodeService.getTargetAssocs(testRecord1, RegexQNamePattern.MATCH_ALL); - - Object newlyAddedRef = null; - if (RelationshipType.PARENTCHILD.equals(refType)) - { - for (ChildAssociationRef caRef : childAssocs) - { - QName refInstanceQName = caRef.getQName(); - if (generatedQName.equals(refInstanceQName)) newlyAddedRef = caRef; - } - } - else - { - for (AssociationRef aRef : retrievedAssocs) - { - QName refQName = aRef.getTypeQName(); - if (generatedQName.equals(refQName)) newlyAddedRef = aRef; - } - } - assertNotNull("newlyAddedRef was null.", newlyAddedRef); - - // Check that the reference has appeared in the data dictionary - AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); - assertNotNull(customAssocsAspect); - if (RelationshipType.PARENTCHILD.equals(refType)) - { - assertNotNull("The customReference is not returned from the dictionaryService.", - customAssocsAspect.getChildAssociations().get(generatedQName)); - } - else - { - assertNotNull("The customReference is not returned from the dictionaryService.", - customAssocsAspect.getAssociations().get(generatedQName)); - } - return null; - } - }); - } - - public void testGetAllProperties() - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Just dump them out for visual inspection - System.out.println("Available custom properties:"); - Map props = rmAdminService.getCustomPropertyDefinitions(); - for (QName prop : props.keySet()) - { - System.out.println(" - " + prop.toString()); - - String propId = props.get(prop).getTitle(dictionaryService); - assertNotNull("null client-id for " + prop, propId); - - System.out.println(" " + propId); - } - return null; - } - }); - } - - public void testGetAllReferences() - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Just dump them out for visual inspection - System.out.println("Available relationship definitions:"); - Set relationshipDefinitions = relationshipService.getRelationshipDefinitions(); - for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) - { - String uniqueName = relationshipDefinition.getUniqueName(); - RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); - - System.out.println(" - " + uniqueName); - System.out.println(" " + displayName.toString()); - } - - return null; - } - }); - } - - public void testGetAllConstraints() - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Just dump them out for visual inspection - System.out.println("Available custom constraints:"); + } + }); + } + + /** + * @see RecordsManagementAdminService#isCustomisable(QName) + */ + public void testIsCustomisable() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + assertFalse(rmAdminService.isCustomisable(TYPE_CONTENT)); + assertFalse(rmAdminService.isCustomisable(ASPECT_DUBLINCORE)); + assertTrue(rmAdminService.isCustomisable(TYPE_RECORD_FOLDER)); + assertTrue(rmAdminService.isCustomisable(ASPECT_RECORD)); + + return null; + } + }); + } + + /** + * @see RecordsManagementAdminService#existsCustomProperty(QName) + * @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String, String, boolean, boolean, boolean, QName) + * @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String) + */ + public void testAddCustomPropertyDefinition() throws Exception + { + // Add property to Record (id specified, short version) + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + // Check the property does not exist + assertFalse(rmAdminService.existsCustomProperty(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"))); + + return rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), + ASPECT_RECORD, + "Label1", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + + @Override + public void test(QName result) throws Exception + { + try + { + // Check the property QName is correct + assertNotNull(result); + assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), result); + assertTrue(rmAdminService.existsCustomProperty(result)); + + // Check that property is available as a custom property + Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); + assertNotNull(propDefs); + assertTrue(propDefs.containsKey(result)); + + // Check the property definition + PropertyDefinition propDef = propDefs.get(result); + assertNotNull(propDef); + assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label1", propDef.getTitle(dictionaryService)); + } + finally + { + // Store the created property for cleanup later + createdCustomProperties.add(result); + } + } + }); + + // Add property to record (no id, short version) + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + return rmAdminService.addCustomPropertyDefinition( + null, + ASPECT_RECORD, + "Label2", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + + @Override + public void test(QName result) throws Exception + { + try + { + // Check the property QName is correct + assertNotNull(result); + assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); + assertTrue(rmAdminService.existsCustomProperty(result)); + + // Check that property is available as a custom property + Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); + assertNotNull(propDefs); + assertTrue(propDefs.containsKey(result)); + + // Check the property definition + PropertyDefinition propDef = propDefs.get(result); + assertNotNull(propDef); + assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label2", propDef.getTitle(dictionaryService)); + } + finally + { + // Store the created property for cleanup later + createdCustomProperties.add(result); + } + } + }); + + // Add property to record (long version) + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + return rmAdminService.addCustomPropertyDefinition( + null, + ASPECT_RECORD, + "Label3", + DataTypeDefinition.TEXT, + "Title", + "Description", + "default", + false, + false, + false, + null); + } + + @Override + public void test(QName result) throws Exception + { + try + { + // Check the property QName is correct + assertNotNull(result); + assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); + assertTrue(rmAdminService.existsCustomProperty(result)); + + // Check that property is available as a custom property + Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_RECORD); + assertNotNull(propDefs); + //assertEquals(3, propDefs.size()); + assertTrue(propDefs.containsKey(result)); + + // Check the property definition + PropertyDefinition propDef = propDefs.get(result); + assertNotNull(propDef); + assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label3", propDef.getTitle(dictionaryService)); + assertEquals("default", propDef.getDefaultValue()); + assertFalse(propDef.isMandatory()); + assertFalse(propDef.isMultiValued()); + assertFalse(propDef.isProtected()); + + } + finally + { + // Store the created property for cleanup later + createdCustomProperties.add(result); + } + } + }); + + // Failure: Add a property with the same name twice + doTestInTransaction(new FailureTest + ( + "Can not create a property with the same id twice", + CustomMetadataException.class + ) + { + @Override + public void run() throws Exception + { + rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), + ASPECT_RECORD, + "Label1", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + }); + + // Failure: Try and add a property to a type that isn't customisable + doTestInTransaction(new FailureTest + ( + "Can not add a custom property to a type that isn't registered as customisable", + CustomMetadataException.class + ) + { + @Override + public void run() throws Exception + { + rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"), + TYPE_CONTENT, + "Label1", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + }); + } + + /** + * @see RecordsManagementAdminService#makeCustomisable(QName) + */ + public void testMakeCustomisable() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + // Make a type customisable + assertFalse(rmAdminService.isCustomisable(TYPE_CUSTOM_TYPE)); + rmAdminService.makeCustomisable(TYPE_CUSTOM_TYPE); + madeCustomisable.add(TYPE_CUSTOM_TYPE); + assertTrue(rmAdminService.isCustomisable(TYPE_CUSTOM_TYPE)); + + // Add a custom property + return rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), + TYPE_CUSTOM_TYPE, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + + @Override + public void test(QName result) throws Exception + { + // Check the property QName is correct + assertNotNull(result); + assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), result); + assertTrue(rmAdminService.existsCustomProperty(result)); + + // Check that property is available as a custom property + Map propDefs = rmAdminService.getCustomPropertyDefinitions(TYPE_CUSTOM_TYPE); + assertNotNull(propDefs); + assertEquals(1, propDefs.size()); + assertTrue(propDefs.containsKey(result)); + + // Check the property definition + PropertyDefinition propDef = propDefs.get(result); + assertNotNull(propDef); + assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label", propDef.getTitle(dictionaryService)); + + } + }); + + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + // Make an aspect customisable + assertFalse(rmAdminService.isCustomisable(ASPECT_CUSTOM_ASPECT)); + rmAdminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); + madeCustomisable.add(ASPECT_CUSTOM_ASPECT); + assertTrue(rmAdminService.isCustomisable(ASPECT_CUSTOM_ASPECT)); + + // Add a custom property + return rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), + ASPECT_CUSTOM_ASPECT, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); + } + + @Override + public void test(QName result) throws Exception + { + // Check the property QName is correct + assertNotNull(result); + assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), result); + assertTrue(rmAdminService.existsCustomProperty(result)); + + // Check that property is available as a custom property + Map propDefs = rmAdminService.getCustomPropertyDefinitions(ASPECT_CUSTOM_ASPECT); + assertNotNull(propDefs); + assertEquals(1, propDefs.size()); + assertTrue(propDefs.containsKey(result)); + + // Check the property definition + PropertyDefinition propDef = propDefs.get(result); + assertNotNull(propDef); + assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label", propDef.getTitle(dictionaryService)); + } + }); + } + + public void testUseCustomProperty() throws Exception + { + // Create custom property on type and aspect + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + rmAdminService.makeCustomisable(TYPE_CUSTOM_TYPE); + madeCustomisable.add(TYPE_CUSTOM_TYPE); + rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), + TYPE_CUSTOM_TYPE, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); + rmAdminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); + madeCustomisable.add(ASPECT_CUSTOM_ASPECT); + rmAdminService.addCustomPropertyDefinition( + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), + ASPECT_CUSTOM_ASPECT, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); + + return null; + } + }); + + // Create nodes using custom type and aspect + doTestInTransaction(new Test() + { + @Override + public QName run() throws Exception + { + NodeRef customInstance1 = nodeService.createNode( + folder, + ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"), + TYPE_CUSTOM_TYPE).getChildRef(); + NodeRef customInstance2 = nodeService.createNode( + folder, + ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"), + TYPE_CONTENT).getChildRef(); + nodeService.addAspect(customInstance2, ASPECT_CUSTOM_ASPECT, null); + + // Assert that both instances have the custom aspects applied + assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); + assertTrue(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); + + // Remove the custom aspect + nodeService.removeAspect(customInstance2, ASPECT_CUSTOM_ASPECT); + + // Assert the custom property aspect is no longer applied applied + assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); + assertFalse(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + + public void testCreateAndUseCustomChildReference() throws Exception + { + long now = System.currentTimeMillis(); + createAndUseCustomReference(RelationshipType.PARENTCHILD, null, "superseded" + now, "superseding" + now); + } + + public void testCreateAndUseCustomNonChildReference() throws Exception + { + long now = System.currentTimeMillis(); + createAndUseCustomReference(RelationshipType.BIDIRECTIONAL, "supporting" + now, null, null); + } + + private void createAndUseCustomReference(final RelationshipType refType, final String label, final String source, final String target) throws Exception + { + final NodeRef testRecord1 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef result = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis()); + return result; + } + }); + final NodeRef testRecord2 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef result = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); + return result; + } + }); + + final QName generatedQName = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public QName execute() throws Throwable + { + utils.completeRecord(testRecord1); + utils.completeRecord(testRecord2); + + Map params = new HashMap(); + params.put("referenceType", refType.toString()); + if (label != null) params.put("label", label); + if (source != null) params.put("source", source); + if (target != null) params.put("target", target); + + // Create the relationship display name + RelationshipDisplayName displayName; + if (label != null) + { + // A bidirectional reference + displayName = new RelationshipDisplayName(label, label); + } + else + { + // A parent/child reference + displayName = new RelationshipDisplayName(source, target); + } + + // Create the relationship definition + RelationshipDefinition relationshipDefinition = relationshipService.createRelationshipDefinition(displayName); + + // Get the qualified name + QName qNameResult = QName.createQName(RM_CUSTOM_PREFIX, relationshipDefinition.getUniqueName(), namespaceService);; + + System.out.println("Creating new " + refType + " reference definition: " + qNameResult); + System.out.println(" params- label: '" + label + "' source: '" + source + "' target: '" + target + "'"); + + return qNameResult; + } + }); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + RelationshipDefinition relationshipDefinition = relationshipService.getRelationshipDefinition(generatedQName.getLocalName()); + assertNotNull("Relationship definition from relationshipService was null.", relationshipDefinition); + assertEquals(generatedQName.getLocalName(), relationshipDefinition.getUniqueName()); + assertTrue(refType.equals(relationshipDefinition.getType())); + + // Now we need to use the custom reference. + // So we apply the aspect containing it to our test records. + nodeService.addAspect(testRecord1, ASPECT_CUSTOM_ASSOCIATIONS, null); + + if (RelationshipType.PARENTCHILD.equals(refType)) + { + nodeService.addChild(testRecord1, testRecord2, generatedQName, generatedQName); + } + else + { + nodeService.createAssociation(testRecord1, testRecord2, generatedQName); + } + return null; + } + }); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Read back the reference value to make sure it was correctly applied. + List childAssocs = nodeService.getChildAssocs(testRecord1); + List retrievedAssocs = nodeService.getTargetAssocs(testRecord1, RegexQNamePattern.MATCH_ALL); + + Object newlyAddedRef = null; + if (RelationshipType.PARENTCHILD.equals(refType)) + { + for (ChildAssociationRef caRef : childAssocs) + { + QName refInstanceQName = caRef.getQName(); + if (generatedQName.equals(refInstanceQName)) newlyAddedRef = caRef; + } + } + else + { + for (AssociationRef aRef : retrievedAssocs) + { + QName refQName = aRef.getTypeQName(); + if (generatedQName.equals(refQName)) newlyAddedRef = aRef; + } + } + assertNotNull("newlyAddedRef was null.", newlyAddedRef); + + // Check that the reference has appeared in the data dictionary + AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); + assertNotNull(customAssocsAspect); + if (RelationshipType.PARENTCHILD.equals(refType)) + { + assertNotNull("The customReference is not returned from the dictionaryService.", + customAssocsAspect.getChildAssociations().get(generatedQName)); + } + else + { + assertNotNull("The customReference is not returned from the dictionaryService.", + customAssocsAspect.getAssociations().get(generatedQName)); + } + return null; + } + }); + } + + public void testGetAllProperties() + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Just dump them out for visual inspection + System.out.println("Available custom properties:"); + Map props = rmAdminService.getCustomPropertyDefinitions(); + for (QName prop : props.keySet()) + { + System.out.println(" - " + prop.toString()); + + String propId = props.get(prop).getTitle(dictionaryService); + assertNotNull("null client-id for " + prop, propId); + + System.out.println(" " + propId); + } + return null; + } + }); + } + + public void testGetAllReferences() + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Just dump them out for visual inspection + System.out.println("Available relationship definitions:"); + Set relationshipDefinitions = relationshipService.getRelationshipDefinitions(); + for (RelationshipDefinition relationshipDefinition : relationshipDefinitions) + { + String uniqueName = relationshipDefinition.getUniqueName(); + RelationshipDisplayName displayName = relationshipDefinition.getDisplayName(); + + System.out.println(" - " + uniqueName); + System.out.println(" " + displayName.toString()); + } + + return null; + } + }); + } + + public void testGetAllConstraints() + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // Just dump them out for visual inspection + System.out.println("Available custom constraints:"); List constraints = rmAdminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); - for (ConstraintDefinition constraint : constraints) - { - System.out.println(" - " + constraint.getName()); - System.out.println(" " + constraint.getTitle(dictionaryService)); - } - return null; - } - }); - } - - private boolean beforeMarker = false; - private boolean onMarker = false; - @SuppressWarnings("unused") - private boolean inTest = false; - - public void testCreateReference() throws Exception - { - inTest = true; - try - { - // Create the necessary test objects in the db: two records. - final Pair testRecords = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback>() - { - public Pair execute() throws Throwable - { - NodeRef rec1 = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis()); - NodeRef rec2 = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); - Pair result = new Pair(rec1, rec2); - return result; - } - }); - final NodeRef testRecord1 = testRecords.getFirst(); - final NodeRef testRecord2 = testRecords.getSecond(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - utils.completeRecord(testRecord1); - utils.completeRecord(testRecord2); - - policyComponent.bindClassBehaviour( - RecordsManagementPolicies.BEFORE_CREATE_REFERENCE, - this, - new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "beforeCreateReference", NotificationFrequency.EVERY_EVENT)); - policyComponent.bindClassBehaviour( - RecordsManagementPolicies.ON_CREATE_REFERENCE, - this, - new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "onCreateReference", NotificationFrequency.EVERY_EVENT)); - - assertFalse(beforeMarker); - assertFalse(onMarker); - - relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), testRecord1, testRecord2); - - assertTrue(beforeMarker); - assertTrue(onMarker); - return null; - } - }); - } - finally - { - inTest = false; - } - } - - public void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) - { - beforeMarker = true; - } - - public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) - { - onMarker = true; - } - - public void testCreateCustomConstraints() throws Exception - { - final int beforeCnt = - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { + for (ConstraintDefinition constraint : constraints) + { + System.out.println(" - " + constraint.getName()); + System.out.println(" " + constraint.getTitle(dictionaryService)); + } + return null; + } + }); + } + + private boolean beforeMarker = false; + private boolean onMarker = false; + @SuppressWarnings("unused") + private boolean inTest = false; + + public void testCreateReference() throws Exception + { + inTest = true; + try + { + // Create the necessary test objects in the db: two records. + final Pair testRecords = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback>() + { + public Pair execute() throws Throwable + { + NodeRef rec1 = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis()); + NodeRef rec2 = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); + Pair result = new Pair(rec1, rec2); + return result; + } + }); + final NodeRef testRecord1 = testRecords.getFirst(); + final NodeRef testRecord2 = testRecords.getSecond(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + utils.completeRecord(testRecord1); + utils.completeRecord(testRecord2); + + policyComponent.bindClassBehaviour( + RecordsManagementPolicies.BEFORE_CREATE_REFERENCE, + this, + new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "beforeCreateReference", NotificationFrequency.EVERY_EVENT)); + policyComponent.bindClassBehaviour( + RecordsManagementPolicies.ON_CREATE_REFERENCE, + this, + new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "onCreateReference", NotificationFrequency.EVERY_EVENT)); + + assertFalse(beforeMarker); + assertFalse(onMarker); + + relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), testRecord1, testRecord2); + + assertTrue(beforeMarker); + assertTrue(onMarker); + return null; + } + }); + } + finally + { + inTest = false; + } + } + + public void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) + { + beforeMarker = true; + } + + public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) + { + onMarker = true; + } + + public void testCreateCustomConstraints() throws Exception + { + final int beforeCnt = + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Integer execute() throws Throwable + { List result = rmAdminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); - assertNotNull(result); - return result.size(); - } - }); - - final String conTitle = "test title - "+testRunID; - final List allowedValues = new ArrayList(3); - allowedValues.add("RED"); - allowedValues.add("AMBER"); - allowedValues.add("GREEN"); - - final QName testCon = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public QName execute() throws Throwable - { - String conLocalName = "test-"+testRunID; - - final QName result = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, conLocalName); - + assertNotNull(result); + return result.size(); + } + }); + + final String conTitle = "test title - "+testRunID; + final List allowedValues = new ArrayList(3); + allowedValues.add("RED"); + allowedValues.add("AMBER"); + allowedValues.add("GREEN"); + + final QName testCon = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public QName execute() throws Throwable + { + String conLocalName = "test-"+testRunID; + + final QName result = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, conLocalName); + rmAdminService.addCustomConstraintDefinition(result, conTitle, true, allowedValues, MatchLogic.AND); - return result; - } - }); - - - // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { + return result; + } + }); + + + // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { List customConstraintDefs = rmAdminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); - assertEquals(beforeCnt+1, customConstraintDefs.size()); - - boolean found = false; - for (ConstraintDefinition conDef : customConstraintDefs) - { - if (conDef.getName().equals(testCon)) - { - assertEquals(conTitle, conDef.getTitle(dictionaryService)); - - Constraint con = conDef.getConstraint(); - assertTrue(con instanceof RMListOfValuesConstraint); - - assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); - assertEquals(3, ((RMListOfValuesConstraint)con).getAllowedValues().size()); - - found = true; - break; - } - } - assertTrue(found); - return null; - } - }); - - - // Set the current security context as admin - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - allowedValues.clear(); - allowedValues.add("RED"); - allowedValues.add("YELLOW"); - - rmAdminService.changeCustomConstraintValues(testCon, allowedValues); - return null; - } - }); - - // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { + assertEquals(beforeCnt+1, customConstraintDefs.size()); + + boolean found = false; + for (ConstraintDefinition conDef : customConstraintDefs) + { + if (conDef.getName().equals(testCon)) + { + assertEquals(conTitle, conDef.getTitle(dictionaryService)); + + Constraint con = conDef.getConstraint(); + assertTrue(con instanceof RMListOfValuesConstraint); + + assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); + assertEquals(3, ((RMListOfValuesConstraint)con).getAllowedValues().size()); + + found = true; + break; + } + } + assertTrue(found); + return null; + } + }); + + + // Set the current security context as admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + allowedValues.clear(); + allowedValues.add("RED"); + allowedValues.add("YELLOW"); + + rmAdminService.changeCustomConstraintValues(testCon, allowedValues); + return null; + } + }); + + // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { List customConstraintDefs = rmAdminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); - assertEquals(beforeCnt+1, customConstraintDefs.size()); - - boolean found = false; - for (ConstraintDefinition conDef : customConstraintDefs) - { - if (conDef.getName().equals(testCon)) - { - assertEquals(conTitle, conDef.getTitle(dictionaryService)); - - Constraint con = conDef.getConstraint(); - assertTrue(con instanceof RMListOfValuesConstraint); - - assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); - assertEquals(2, ((RMListOfValuesConstraint)con).getAllowedValues().size()); - - found = true; - break; - } - } - assertTrue(found); - return null; - } - }); - - - // Set the current security context as admin - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - // Add custom property to record with test constraint - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - String propLocalName = "myProp-"+testRunID; - - QName dataType = DataTypeDefinition.TEXT; - String propTitle = "My property title"; - String description = "My property description"; - String defaultValue = null; - boolean multiValued = false; - boolean mandatory = false; - boolean isProtected = false; - - QName propName = rmAdminService.addCustomPropertyDefinition(null, ASPECT_RECORD, propLocalName, dataType, propTitle, description, defaultValue, multiValued, mandatory, isProtected, testCon); - createdCustomProperties.add(propName); - return null; - } - }); - } -} + assertEquals(beforeCnt+1, customConstraintDefs.size()); + + boolean found = false; + for (ConstraintDefinition conDef : customConstraintDefs) + { + if (conDef.getName().equals(testCon)) + { + assertEquals(conTitle, conDef.getTitle(dictionaryService)); + + Constraint con = conDef.getConstraint(); + assertTrue(con instanceof RMListOfValuesConstraint); + + assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); + assertEquals(2, ((RMListOfValuesConstraint)con).getAllowedValues().size()); + + found = true; + break; + } + } + assertTrue(found); + return null; + } + }); + + + // Set the current security context as admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + // Add custom property to record with test constraint + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + String propLocalName = "myProp-"+testRunID; + + QName dataType = DataTypeDefinition.TEXT; + String propTitle = "My property title"; + String description = "My property description"; + String defaultValue = null; + boolean multiValued = false; + boolean mandatory = false; + boolean isProtected = false; + + QName propName = rmAdminService.addCustomPropertyDefinition(null, ASPECT_RECORD, propLocalName, dataType, propTitle, description, defaultValue, multiValued, mandatory, isProtected, testCon); + createdCustomProperties.add(propName); + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java index 1a9d8f469c..3188b2cc65 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java @@ -1,500 +1,500 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditEntry; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationException; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.Pair; - -/** - * @see RecordsManagementAuditService - * - * @author Derek Hulley - * @author Roy Wetherall - * - * @since 3.2 - */ -public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase - implements RMPermissionModel -{ - /** Test record */ - private NodeRef record; - - /** Test start time */ - private Date testStartTime; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp() - */ - @Override - protected void setUp() throws Exception - { - super.setUp(); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // test start time recorded - testStartTime = new Date(); - - // Stop and clear the log - rmAuditService.stopAuditLog(filePlan); - rmAuditService.clearAuditLog(filePlan); - rmAuditService.startAuditLog(filePlan); - - // check that audit service is started - assertTrue(rmAuditService.isAuditLogEnabled(filePlan)); - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() - */ - @Override - protected boolean isUserTest() - { - return true; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestDataImpl() - */ - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - record = utils.createRecord(rmFolder, "AuditTest.txt"); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void setupTestUsersImpl(NodeRef filePlan) - { - super.setupTestUsersImpl(filePlan); - - // Give all the users file permission objects - for (String user : testUsers) - { - filePlanPermissionService.setPermission(filePlan, user, FILING); - filePlanPermissionService.setPermission(rmContainer, user, FILING); - } - } - - public void testGetAuditEvents() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - List events = rmAuditService.getAuditEvents(); - - System.out.println("Found audit events:"); - for (AuditEvent event : events) - { - System.out.println(" - " + event.getName() + " (" + event.getLabel() + ")"); - } - - return null; - } - }, ADMIN_USER); - } - - /** - * Test getAuditTrail method to check that deleted items always show in the audit. - * - * @see RM-2391 (last addressed isue) - */ - public void testGetAuditTrailForDeletedItem() - { - // We have only one entry for the event "audit.start": - List entries = getAuditTrail(1, ADMIN_USER); - - assertEquals(entries.get(0).getEvent(), "audit.start"); - - // Event "audit.view" was generated but will be visible on the next call to getAuditTrail(). - - // Make a change: - updateTitle(filePlan, ADMIN_USER); // event=Update RM Object - - // Show the audit has been updated; at this point we have three entries for the three events up to now: - // "audit.start", "audit.view" and "Update RM Object"; - entries = getAuditTrail(3, ADMIN_USER); - - assertEquals(entries.get(0).getEvent(), "audit.start"); - assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); - - // New "audit.view" event was generated - will be visible on next getAuditTrail(). - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - nodeService.deleteNode(record); - List entries = getAuditTrail(5, ADMIN_USER); - - assertEquals(entries.get(0).getEvent(), "audit.start"); - assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); - assertEquals(entries.get(3).getEvent(), "audit.view"); - - // Show the audit contains a reference to the deleted item: - assertEquals(entries.get(4).getEvent(), "Delete RM Object"); - assertEquals(entries.get(4).getNodeRef(), record); - - return null; - } - }); - } - - /** - * Test getAuditTrail method and parameter filters. - */ - public void testGetAuditTrail() - { - // show the audit is empty - getAuditTrail(1, ADMIN_USER); - - // make a change - final String updatedProperty = updateTitle(filePlan, ADMIN_USER); - - // show the audit has been updated - List entries = getAuditTrail(3, ADMIN_USER); - final RecordsManagementAuditEntry entry = entries.get(2); - assertNotNull(entry); - - // investigate the contents of the audit entry - doTestInTransaction(new Test() - { - @SuppressWarnings("unchecked") - @Override - public Void run() throws Exception - { - assertEquals(filePlan, entry.getNodeRef()); - - String id = (String)nodeService.getProperty(filePlan, PROP_IDENTIFIER); - assertEquals(id, entry.getIdentifier()); - - Map after = entry.getAfterProperties(); - Map> changed = entry.getChangedProperties(); - - assertTrue(after.containsKey(PROP_TITLE)); - assertTrue(changed.containsKey(PROP_TITLE)); - - Serializable value = ((Map)after.get(PROP_TITLE)).get(Locale.ENGLISH); - assertEquals(updatedProperty, value); - value = ((Map)changed.get(PROP_TITLE).getSecond()).get(Locale.ENGLISH); - assertEquals(updatedProperty, value); - - return null; - } - }, ADMIN_USER); - - // add some more title updates - updateTitle(rmContainer, ADMIN_USER); - updateTitle(rmFolder, ADMIN_USER); - updateTitle(record, ADMIN_USER); - - // show the audit has been updated - getAuditTrail(7, ADMIN_USER); - - // snap shot date - Date snapShot = new Date(); - - // show the audit results can be limited - RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); - params.setMaxEntries(2); - getAuditTrail(params, 2, ADMIN_USER); - - // test filter by user - updateTitle(rmContainer, recordsManagerName); - updateTitle(rmFolder, recordsManagerName); - updateTitle(record, recordsManagerName); - - params = new RecordsManagementAuditQueryParameters(); - params.setUser(recordsManagerName); - getAuditTrail(params, 3, ADMIN_USER); - - // test filter by date - params = new RecordsManagementAuditQueryParameters(); - params.setDateFrom(snapShot); - getAuditTrail(params, 13, ADMIN_USER); - params = new RecordsManagementAuditQueryParameters(); - params.setDateTo(snapShot); - getAuditTrail(params, 14, ADMIN_USER); - params.setDateFrom(testStartTime); - getAuditTrail(params, 15, ADMIN_USER); - - // test filter by object - updateTitle(record, ADMIN_USER); - updateTitle(record, ADMIN_USER); - updateTitle(record, ADMIN_USER); - params = new RecordsManagementAuditQueryParameters(); - params.setNodeRef(record); - getAuditTrail(params, 5, ADMIN_USER); - - // test filter by event - params = new RecordsManagementAuditQueryParameters(); - // params.setEvent("cutoff"); - // getAuditTrail(params, 0, ADMIN_USER); - params.setEvent("Update RM Object"); - getAuditTrail(params, 10, ADMIN_USER); - - // test filter by property - // params = new RecordsManagementAuditQueryParameters(); - //params.setProperty(PROP_ADDRESSEES); - //getAuditTrail(params, 0, ADMIN_USER); - // params.setProperty(PROP_TITLE); - // getAuditTrail(params, 10, ADMIN_USER); - } - - /** - * Tests the following methods: - * - start() - * - stop() - * - clear() - * - isEnabled() - * - getDateLastStopped() - * - getDateLastStarted() - * - * @throws InterruptedException - */ - public void testAdminMethods() throws InterruptedException - { - // Stop the audit - rmAuditService.stopAuditLog(filePlan); - - Thread.sleep(5000); - - List result1 = getAuditTrail(ADMIN_USER); - assertNotNull(result1); - - // Update the fileplan - updateTitle(filePlan, ADMIN_USER); - - Thread.sleep(5000); - - // There should be no new audit entries - List result2 = getAuditTrail(ADMIN_USER); - assertNotNull(result2); - assertEquals( - "Audit results should not have changed after auditing was disabled", - result1.size(), result2.size()); - - // repeat with a start - rmAuditService.startAuditLog(filePlan); - updateTitle(filePlan, ADMIN_USER); - - Thread.sleep(5000); - - List result3 = getAuditTrail(ADMIN_USER); - assertNotNull(result3); - assertTrue( - "Expected more results after enabling audit", - result3.size() > result1.size()); - - Thread.sleep(5000); - - // Stop and delete all entries - rmAuditService.stopAuditLog(filePlan); - rmAuditService.clearAuditLog(filePlan); - - // There should be no entries - List result4 = getAuditTrail(ADMIN_USER); - assertNotNull(result4); - assertEquals( - "Audit entries should have been cleared", - 0, result4.size()); - } - - // TODO testAuditRMAction - - // TODO testGetAuditTrailFile - - // TODO testFileAuditTrailAsRecord - - public void xtestAuditAuthentication() - { - rmAuditService.stopAuditLog(filePlan); - rmAuditService.clearAuditLog(filePlan); - rmAuditService.startAuditLog(filePlan); - - //MutableAuthenticationService authenticationService = serviceRegistry.getAuthenticationService(); - //PersonService personService = serviceRegistry.getPersonService(); - - try - { - personService.deletePerson("baboon"); - authenticationService.deleteAuthentication("baboon"); - } - catch (Throwable e) - { - // Not serious - } - - // Failed login attempt ... - try - { - AuthenticationUtil.pushAuthentication(); - authenticationService.authenticate("baboon", "lskdfj".toCharArray()); - fail("Expected authentication failure"); - } - catch (AuthenticationException e) - { - // Good - } - finally - { - AuthenticationUtil.popAuthentication(); - } - rmAuditService.stopAuditLog(filePlan); - List result1 = getAuditTrail(ADMIN_USER); - // Check that the username is reflected correctly in the results - assertFalse("No audit results were generated for the failed login.", result1.isEmpty()); - boolean found = false; - for (RecordsManagementAuditEntry entry : result1) - { - String userName = entry.getUserName(); - if (userName.equals("baboon")) - { - found = true; - break; - } - } - assertTrue("Expected to hit failed login attempt for user", found); - - // Test successful authentication - try - { - personService.deletePerson("cdickons"); - authenticationService.deleteAuthentication("cdickons"); - } - catch (Throwable e) - { - // Not serious - } - authenticationService.createAuthentication("cdickons", getName().toCharArray()); - Map personProperties = new HashMap(); - personProperties.put(ContentModel.PROP_USERNAME, "cdickons"); - personProperties.put(ContentModel.PROP_FIRSTNAME, "Charles"); - personProperties.put(ContentModel.PROP_LASTNAME, "Dickons"); - personService.createPerson(personProperties); - - rmAuditService.clearAuditLog(filePlan); - rmAuditService.startAuditLog(filePlan); - try - { - AuthenticationUtil.pushAuthentication(); - authenticationService.authenticate("cdickons", getName().toCharArray()); - } - finally - { - AuthenticationUtil.popAuthentication(); - } - rmAuditService.stopAuditLog(filePlan); - List result2 = getAuditTrail(ADMIN_USER); - found = false; - for (RecordsManagementAuditEntry entry : result2) - { - String userName = entry.getUserName(); - String fullName = entry.getFullName(); - if (userName.equals("cdickons") && EqualsHelper.nullSafeEquals(fullName, "Charles Dickons")) - { - found = true; - break; - } - } - assertTrue("Expected to hit successful login attempt for Charles Dickons (cdickons)", found); - } - - /** === Helper methods === */ - - private List getAuditTrail(String asUser) - { - return getAuditTrail(-1, asUser); - } - - private List getAuditTrail(final int expectedCount, String asUser) - { - return getAuditTrail(new RecordsManagementAuditQueryParameters(), expectedCount, asUser); - } - - private List getAuditTrail(final RecordsManagementAuditQueryParameters params, final int expectedCount, final String asUser) - { - return doTestInTransaction(new Test>() - { - @Override - public List run() throws Exception - { - return rmAuditService.getAuditTrail(params); - } - - @Override - public void test(List result) throws Exception - { - assertNotNull(result); - if (expectedCount != -1) - { - assertEquals(expectedCount, result.size()); - } - } - }, asUser); - } - - private String updateTitle(final NodeRef nodeRef, final String asUser) - { - return doTestInTransaction(new Test() - { - @Override - public String run() throws Exception - { - String updatedProperty = "Updated - " + System.currentTimeMillis(); - nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, updatedProperty); - return updatedProperty; - } - }, asUser); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditEntry; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditQueryParameters; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationException; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.EqualsHelper; +import org.alfresco.util.Pair; + +/** + * @see RecordsManagementAuditService + * + * @author Derek Hulley + * @author Roy Wetherall + * + * @since 3.2 + */ +public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase + implements RMPermissionModel +{ + /** Test record */ + private NodeRef record; + + /** Test start time */ + private Date testStartTime; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + super.setUp(); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // test start time recorded + testStartTime = new Date(); + + // Stop and clear the log + rmAuditService.stopAuditLog(filePlan); + rmAuditService.clearAuditLog(filePlan); + rmAuditService.startAuditLog(filePlan); + + // check that audit service is started + assertTrue(rmAuditService.isAuditLogEnabled(filePlan)); + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() + */ + @Override + protected boolean isUserTest() + { + return true; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestDataImpl() + */ + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + record = utils.createRecord(rmFolder, "AuditTest.txt"); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestUsersImpl(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + // Give all the users file permission objects + for (String user : testUsers) + { + filePlanPermissionService.setPermission(filePlan, user, FILING); + filePlanPermissionService.setPermission(rmContainer, user, FILING); + } + } + + public void testGetAuditEvents() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + List events = rmAuditService.getAuditEvents(); + + System.out.println("Found audit events:"); + for (AuditEvent event : events) + { + System.out.println(" - " + event.getName() + " (" + event.getLabel() + ")"); + } + + return null; + } + }, ADMIN_USER); + } + + /** + * Test getAuditTrail method to check that deleted items always show in the audit. + * + * @see RM-2391 (last addressed isue) + */ + public void testGetAuditTrailForDeletedItem() + { + // We have only one entry for the event "audit.start": + List entries = getAuditTrail(1, ADMIN_USER); + + assertEquals(entries.get(0).getEvent(), "audit.start"); + + // Event "audit.view" was generated but will be visible on the next call to getAuditTrail(). + + // Make a change: + updateTitle(filePlan, ADMIN_USER); // event=Update RM Object + + // Show the audit has been updated; at this point we have three entries for the three events up to now: + // "audit.start", "audit.view" and "Update RM Object"; + entries = getAuditTrail(3, ADMIN_USER); + + assertEquals(entries.get(0).getEvent(), "audit.start"); + assertEquals(entries.get(1).getEvent(), "audit.view"); + assertEquals(entries.get(2).getEvent(), "Update RM Object"); + + // New "audit.view" event was generated - will be visible on next getAuditTrail(). + + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + nodeService.deleteNode(record); + List entries = getAuditTrail(5, ADMIN_USER); + + assertEquals(entries.get(0).getEvent(), "audit.start"); + assertEquals(entries.get(1).getEvent(), "audit.view"); + assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(3).getEvent(), "audit.view"); + + // Show the audit contains a reference to the deleted item: + assertEquals(entries.get(4).getEvent(), "Delete RM Object"); + assertEquals(entries.get(4).getNodeRef(), record); + + return null; + } + }); + } + + /** + * Test getAuditTrail method and parameter filters. + */ + public void testGetAuditTrail() + { + // show the audit is empty + getAuditTrail(1, ADMIN_USER); + + // make a change + final String updatedProperty = updateTitle(filePlan, ADMIN_USER); + + // show the audit has been updated + List entries = getAuditTrail(3, ADMIN_USER); + final RecordsManagementAuditEntry entry = entries.get(2); + assertNotNull(entry); + + // investigate the contents of the audit entry + doTestInTransaction(new Test() + { + @SuppressWarnings("unchecked") + @Override + public Void run() throws Exception + { + assertEquals(filePlan, entry.getNodeRef()); + + String id = (String)nodeService.getProperty(filePlan, PROP_IDENTIFIER); + assertEquals(id, entry.getIdentifier()); + + Map after = entry.getAfterProperties(); + Map> changed = entry.getChangedProperties(); + + assertTrue(after.containsKey(PROP_TITLE)); + assertTrue(changed.containsKey(PROP_TITLE)); + + Serializable value = ((Map)after.get(PROP_TITLE)).get(Locale.ENGLISH); + assertEquals(updatedProperty, value); + value = ((Map)changed.get(PROP_TITLE).getSecond()).get(Locale.ENGLISH); + assertEquals(updatedProperty, value); + + return null; + } + }, ADMIN_USER); + + // add some more title updates + updateTitle(rmContainer, ADMIN_USER); + updateTitle(rmFolder, ADMIN_USER); + updateTitle(record, ADMIN_USER); + + // show the audit has been updated + getAuditTrail(7, ADMIN_USER); + + // snap shot date + Date snapShot = new Date(); + + // show the audit results can be limited + RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); + params.setMaxEntries(2); + getAuditTrail(params, 2, ADMIN_USER); + + // test filter by user + updateTitle(rmContainer, recordsManagerName); + updateTitle(rmFolder, recordsManagerName); + updateTitle(record, recordsManagerName); + + params = new RecordsManagementAuditQueryParameters(); + params.setUser(recordsManagerName); + getAuditTrail(params, 3, ADMIN_USER); + + // test filter by date + params = new RecordsManagementAuditQueryParameters(); + params.setDateFrom(snapShot); + getAuditTrail(params, 13, ADMIN_USER); + params = new RecordsManagementAuditQueryParameters(); + params.setDateTo(snapShot); + getAuditTrail(params, 14, ADMIN_USER); + params.setDateFrom(testStartTime); + getAuditTrail(params, 15, ADMIN_USER); + + // test filter by object + updateTitle(record, ADMIN_USER); + updateTitle(record, ADMIN_USER); + updateTitle(record, ADMIN_USER); + params = new RecordsManagementAuditQueryParameters(); + params.setNodeRef(record); + getAuditTrail(params, 5, ADMIN_USER); + + // test filter by event + params = new RecordsManagementAuditQueryParameters(); + // params.setEvent("cutoff"); + // getAuditTrail(params, 0, ADMIN_USER); + params.setEvent("Update RM Object"); + getAuditTrail(params, 10, ADMIN_USER); + + // test filter by property + // params = new RecordsManagementAuditQueryParameters(); + //params.setProperty(PROP_ADDRESSEES); + //getAuditTrail(params, 0, ADMIN_USER); + // params.setProperty(PROP_TITLE); + // getAuditTrail(params, 10, ADMIN_USER); + } + + /** + * Tests the following methods: + * - start() + * - stop() + * - clear() + * - isEnabled() + * - getDateLastStopped() + * - getDateLastStarted() + * + * @throws InterruptedException + */ + public void testAdminMethods() throws InterruptedException + { + // Stop the audit + rmAuditService.stopAuditLog(filePlan); + + Thread.sleep(5000); + + List result1 = getAuditTrail(ADMIN_USER); + assertNotNull(result1); + + // Update the fileplan + updateTitle(filePlan, ADMIN_USER); + + Thread.sleep(5000); + + // There should be no new audit entries + List result2 = getAuditTrail(ADMIN_USER); + assertNotNull(result2); + assertEquals( + "Audit results should not have changed after auditing was disabled", + result1.size(), result2.size()); + + // repeat with a start + rmAuditService.startAuditLog(filePlan); + updateTitle(filePlan, ADMIN_USER); + + Thread.sleep(5000); + + List result3 = getAuditTrail(ADMIN_USER); + assertNotNull(result3); + assertTrue( + "Expected more results after enabling audit", + result3.size() > result1.size()); + + Thread.sleep(5000); + + // Stop and delete all entries + rmAuditService.stopAuditLog(filePlan); + rmAuditService.clearAuditLog(filePlan); + + // There should be no entries + List result4 = getAuditTrail(ADMIN_USER); + assertNotNull(result4); + assertEquals( + "Audit entries should have been cleared", + 0, result4.size()); + } + + // TODO testAuditRMAction + + // TODO testGetAuditTrailFile + + // TODO testFileAuditTrailAsRecord + + public void xtestAuditAuthentication() + { + rmAuditService.stopAuditLog(filePlan); + rmAuditService.clearAuditLog(filePlan); + rmAuditService.startAuditLog(filePlan); + + //MutableAuthenticationService authenticationService = serviceRegistry.getAuthenticationService(); + //PersonService personService = serviceRegistry.getPersonService(); + + try + { + personService.deletePerson("baboon"); + authenticationService.deleteAuthentication("baboon"); + } + catch (Throwable e) + { + // Not serious + } + + // Failed login attempt ... + try + { + AuthenticationUtil.pushAuthentication(); + authenticationService.authenticate("baboon", "lskdfj".toCharArray()); + fail("Expected authentication failure"); + } + catch (AuthenticationException e) + { + // Good + } + finally + { + AuthenticationUtil.popAuthentication(); + } + rmAuditService.stopAuditLog(filePlan); + List result1 = getAuditTrail(ADMIN_USER); + // Check that the username is reflected correctly in the results + assertFalse("No audit results were generated for the failed login.", result1.isEmpty()); + boolean found = false; + for (RecordsManagementAuditEntry entry : result1) + { + String userName = entry.getUserName(); + if (userName.equals("baboon")) + { + found = true; + break; + } + } + assertTrue("Expected to hit failed login attempt for user", found); + + // Test successful authentication + try + { + personService.deletePerson("cdickons"); + authenticationService.deleteAuthentication("cdickons"); + } + catch (Throwable e) + { + // Not serious + } + authenticationService.createAuthentication("cdickons", getName().toCharArray()); + Map personProperties = new HashMap(); + personProperties.put(ContentModel.PROP_USERNAME, "cdickons"); + personProperties.put(ContentModel.PROP_FIRSTNAME, "Charles"); + personProperties.put(ContentModel.PROP_LASTNAME, "Dickons"); + personService.createPerson(personProperties); + + rmAuditService.clearAuditLog(filePlan); + rmAuditService.startAuditLog(filePlan); + try + { + AuthenticationUtil.pushAuthentication(); + authenticationService.authenticate("cdickons", getName().toCharArray()); + } + finally + { + AuthenticationUtil.popAuthentication(); + } + rmAuditService.stopAuditLog(filePlan); + List result2 = getAuditTrail(ADMIN_USER); + found = false; + for (RecordsManagementAuditEntry entry : result2) + { + String userName = entry.getUserName(); + String fullName = entry.getFullName(); + if (userName.equals("cdickons") && EqualsHelper.nullSafeEquals(fullName, "Charles Dickons")) + { + found = true; + break; + } + } + assertTrue("Expected to hit successful login attempt for Charles Dickons (cdickons)", found); + } + + /** === Helper methods === */ + + private List getAuditTrail(String asUser) + { + return getAuditTrail(-1, asUser); + } + + private List getAuditTrail(final int expectedCount, String asUser) + { + return getAuditTrail(new RecordsManagementAuditQueryParameters(), expectedCount, asUser); + } + + private List getAuditTrail(final RecordsManagementAuditQueryParameters params, final int expectedCount, final String asUser) + { + return doTestInTransaction(new Test>() + { + @Override + public List run() throws Exception + { + return rmAuditService.getAuditTrail(params); + } + + @Override + public void test(List result) throws Exception + { + assertNotNull(result); + if (expectedCount != -1) + { + assertEquals(expectedCount, result.size()); + } + } + }, asUser); + } + + private String updateTitle(final NodeRef nodeRef, final String asUser) + { + return doTestInTransaction(new Test() + { + @Override + public String run() throws Exception + { + String updatedProperty = "Updated - " + System.currentTimeMillis(); + nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, updatedProperty); + return updatedProperty; + } + }, asUser); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementEventServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementEventServiceImplTest.java index d466871ed2..cc0b414ece 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementEventServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementEventServiceImplTest.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.repository.StoreRef; - -/** - * Event service implementation unit test - * - * @author Roy Wetherall - */ -public class RecordsManagementEventServiceImplTest extends BaseRMTestCase implements RecordsManagementModel -{ - protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - - private RetryingTransactionHelper transactionHelper; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - // Get the service required in the tests - this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper"); - - // Set the current security context as admin - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - } - - public void testGetEventTypes() - { - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - List eventTypes = rmEventService.getEventTypes(); - assertNotNull(eventTypes); - for (RecordsManagementEventType eventType : eventTypes) - { - System.out.println(eventType.getName() + " - " + eventType.getDisplayLabel()); - } - return null; - } - }); - } - - public void testGetEvents() - { - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - List events = rmEventService.getEvents(); - assertNotNull(events); - for (RecordsManagementEvent event : events) - { - System.out.println(event.getName()); - } - return null; - } - }); - } - - public void testAddRemoveEvents() - { - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - List events = rmEventService.getEvents(); - assertNotNull(events); - assertFalse(containsEvent(events, "myEvent")); - - rmEventService.addEvent("rmEventType.simple", "myEvent", "My Event"); - - events = rmEventService.getEvents(); - assertNotNull(events); - assertTrue(containsEvent(events, "myEvent")); - - rmEventService.removeEvent("myEvent"); - - events = rmEventService.getEvents(); - assertNotNull(events); - assertFalse(containsEvent(events, "myEvent")); - return null; - } - }); - } - - private boolean containsEvent(List events, String eventName) - { - boolean result = false; - for (RecordsManagementEvent event : events) - { - if (eventName.equals(event.getName())) - { - result = true; - break; - } - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.repository.StoreRef; + +/** + * Event service implementation unit test + * + * @author Roy Wetherall + */ +public class RecordsManagementEventServiceImplTest extends BaseRMTestCase implements RecordsManagementModel +{ + protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); + + private RetryingTransactionHelper transactionHelper; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + // Get the service required in the tests + this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper"); + + // Set the current security context as admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + } + + public void testGetEventTypes() + { + transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + List eventTypes = rmEventService.getEventTypes(); + assertNotNull(eventTypes); + for (RecordsManagementEventType eventType : eventTypes) + { + System.out.println(eventType.getName() + " - " + eventType.getDisplayLabel()); + } + return null; + } + }); + } + + public void testGetEvents() + { + transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + List events = rmEventService.getEvents(); + assertNotNull(events); + for (RecordsManagementEvent event : events) + { + System.out.println(event.getName()); + } + return null; + } + }); + } + + public void testAddRemoveEvents() + { + transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + List events = rmEventService.getEvents(); + assertNotNull(events); + assertFalse(containsEvent(events, "myEvent")); + + rmEventService.addEvent("rmEventType.simple", "myEvent", "My Event"); + + events = rmEventService.getEvents(); + assertNotNull(events); + assertTrue(containsEvent(events, "myEvent")); + + rmEventService.removeEvent("myEvent"); + + events = rmEventService.getEvents(); + assertNotNull(events); + assertFalse(containsEvent(events, "myEvent")); + return null; + } + }); + } + + private boolean containsEvent(List events, String eventName) + { + boolean result = false; + for (RecordsManagementEvent event : events) + { + if (eventName.equals(event.getName())) + { + result = true; + break; + } + } + return result; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java index 2c9a53bad7..32c72a65a2 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java @@ -1,81 +1,81 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Records Management Query DAO - * - * @author Roy Wetherall - * @since 2.1 - */ -public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements RecordsManagementModel -{ - protected RecordsManagementQueryDAO queryDAO; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - - queryDAO = (RecordsManagementQueryDAO)applicationContext.getBean("recordsManagementQueryDAO"); - } - - /** - * This is a record test - * - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() - */ - @Override - protected boolean isRecordTest() - { - return true; - } - - /** - * @see RecordService#getRecordMetaDataAspects() - */ - public void testGetRecordMetaDataAspects() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - int count = queryDAO.getCountRmaIdentifier("abc-123"); - assertEquals(0, count); - - String existingID = (String)nodeService.getProperty(recordOne, PROP_IDENTIFIER); - count = queryDAO.getCountRmaIdentifier(existingID); - assertEquals(1, count); - - return null; - } - }); - } - - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Records Management Query DAO + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements RecordsManagementModel +{ + protected RecordsManagementQueryDAO queryDAO; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + + queryDAO = (RecordsManagementQueryDAO)applicationContext.getBean("recordsManagementQueryDAO"); + } + + /** + * This is a record test + * + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() + */ + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * @see RecordService#getRecordMetaDataAspects() + */ + public void testGetRecordMetaDataAspects() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + int count = queryDAO.getCountRmaIdentifier("abc-123"); + assertEquals(0, count); + + String existingID = (String)nodeService.getProperty(recordOne, PROP_IDENTIFIER); + count = queryDAO.getCountRmaIdentifier(existingID); + assertEquals(1, count); + + return null; + } + }); + } + + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementSearchServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementSearchServiceImplTest.java index 012db1a363..e534d322bb 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementSearchServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementSearchServiceImplTest.java @@ -1,309 +1,309 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; -import org.alfresco.util.TestWithUserUtils; - -/** - * Search service implementation unit test. - * - * @author Roy Wetherall - */ -@SuppressWarnings("unused") -public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase -{ - @Override - protected boolean isMultiHierarchyTest() - { - return true; - } - - private static final String SEARCH1 = "search1"; - private static final String SEARCH2 = "search2"; - private static final String SEARCH3 = "search3"; - private static final String SEARCH4 = "search4"; - - private static final String USER1 = "user1"; - private static final String USER2 = "user2"; - - private NodeRef folderLevelRecordFolder; - private NodeRef recordLevelRecordFolder; - - private NodeRef recordOne; - private NodeRef recordTwo; - private NodeRef recordThree; - private NodeRef recordFour; - private NodeRef recordFive; - private NodeRef recordSix; - - private int numberOfReports; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData() - */ - @Override - protected void setupTestData() - { - super.setupTestData(); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Create test users - TestWithUserUtils.createUser(USER1, USER1, rootNodeRef, nodeService, authenticationService); - TestWithUserUtils.createUser(USER2, USER2, rootNodeRef, nodeService, authenticationService); - - // Count the number of pre-defined reports - List searches = rmSearchService.getSavedSearches(siteId); - assertNotNull(searches); - numberOfReports = searches.size(); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupMultiHierarchyTestData() - */ - @Override - protected void setupMultiHierarchyTestData() - { - super.setupMultiHierarchyTestData(); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - folderLevelRecordFolder = mhRecordFolder42; - recordLevelRecordFolder = mhRecordFolder43; - - recordOne = utils.createRecord(folderLevelRecordFolder, "recordOne.txt", null, "record one - folder level - elephant"); - recordTwo = utils.createRecord(folderLevelRecordFolder, "recordTwo.txt", null, "record two - folder level - snake"); - recordThree = utils.createRecord(folderLevelRecordFolder, "recordThree.txt", null, "record three - folder level - monkey"); - recordFour = utils.createRecord(recordLevelRecordFolder, "recordFour.txt", null, "record four - record level - elephant"); - recordFive = utils.createRecord(recordLevelRecordFolder, "recordFive.txt", null, "record five - record level - snake"); - recordSix = utils.createRecord(recordLevelRecordFolder, "recordSix.txt", null, "record six - record level - monkey"); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - @Override - protected void tearDown() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Delete test users - TestWithUserUtils.deleteUser(USER1, USER1, rootNodeRef, nodeService, authenticationService); - TestWithUserUtils.deleteUser(USER2, USER2, rootNodeRef, nodeService, authenticationService); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - super.tearDown(); - } - - public void testSearch() - { - // Full text search - doTestInTransaction(new Test() - { - @Override - public Void run() - { - String query = "keywords:\"elephant\""; - RecordsManagementSearchParameters params = new RecordsManagementSearchParameters(); - params.setIncludeUndeclaredRecords(true); - List> results = rmSearchService.search(siteId, query, params); - assertNotNull(results); - assertEquals(2, results.size()); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - // Property search - - // - } - - public void testSaveSearch() - { - // Add some saved searches (as admin user) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - SavedSearchDetails details1 = rmSearchService.saveSearch(siteId, SEARCH1, "description1", "query1", new RecordsManagementSearchParameters(), true); - checkSearchDetails(details1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); - SavedSearchDetails details2 = rmSearchService.saveSearch(siteId, SEARCH2, "description2", "query2", new RecordsManagementSearchParameters(), false); - checkSearchDetails(details2, siteId, "search2", "description2", "query2", new RecordsManagementSearchParameters(), false); - - return null; - } - - }); - - // Add some saved searches (as user1) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - SavedSearchDetails details1 = rmSearchService.saveSearch(siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); - checkSearchDetails(details1, siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); - SavedSearchDetails details2 = rmSearchService.saveSearch(siteId, SEARCH4, "description4", "query4", new RecordsManagementSearchParameters(), false); - checkSearchDetails(details2, siteId, SEARCH4, "description4", "query4", new RecordsManagementSearchParameters(), false); - - return null; - } - - }, USER1); - - // Get searches (as admin user) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List searches = rmSearchService.getSavedSearches(siteId); - assertNotNull(searches); - assertEquals(numberOfReports + 2, searches.size()); - - SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); - assertNotNull(search1); - checkSearchDetails(search1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); - - SavedSearchDetails search2 = rmSearchService.getSavedSearch(siteId, SEARCH2); - assertNotNull(search2); - checkSearchDetails(search2, siteId, "search2", "description2", "query2", new RecordsManagementSearchParameters(), false); - - SavedSearchDetails search3 = rmSearchService.getSavedSearch(siteId, SEARCH3); - assertNull(search3); - - SavedSearchDetails search4 = rmSearchService.getSavedSearch(siteId, SEARCH4); - assertNull(search4); - - return null; - } - - }); - - // Get searches (as user1) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List searches = rmSearchService.getSavedSearches(siteId); - assertNotNull(searches); - assertEquals(numberOfReports + 3, searches.size()); - - SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); - assertNotNull(search1); - checkSearchDetails(search1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); - - SavedSearchDetails search2 = rmSearchService.getSavedSearch(siteId, SEARCH2); - assertNull(search2); - - SavedSearchDetails search3 = rmSearchService.getSavedSearch(siteId, SEARCH3); - assertNotNull(search3); - checkSearchDetails(search3, siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); - - SavedSearchDetails search4 = rmSearchService.getSavedSearch(siteId, SEARCH4); - assertNotNull(search4); - checkSearchDetails(search4, siteId, "search4", "description4", "query4", new RecordsManagementSearchParameters(), false); - - return null; - } - - }, USER1); - - // Update search (as admin user) - doTestInTransaction(new Test() - { - @Override - public Void run() - { - SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); - assertNotNull(search1); - checkSearchDetails(search1, siteId, SEARCH1, "description1", "query1", new RecordsManagementSearchParameters(), true); - - rmSearchService.saveSearch(siteId, SEARCH1, "change", "change", new RecordsManagementSearchParameters(), true); - - search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); - assertNotNull(search1); - checkSearchDetails(search1, siteId, SEARCH1, "change", "change", new RecordsManagementSearchParameters(), true); - - return null; - } - }); - - // Delete searches (as admin user) - // TODO - } - - /** - * Check the details of the saved search. - */ - private void checkSearchDetails( - SavedSearchDetails details, - String siteid, - String name, - String description, - String query, - RecordsManagementSearchParameters searchParameters, - boolean isPublic) - { - assertNotNull(details); - assertEquals(siteid, details.getSiteId()); - assertEquals(name, details.getName()); - assertEquals(description, details.getDescription()); - assertEquals(query, details.getSearch()); - assertEquals(isPublic, details.isPublic()); - - assertEquals(searchParameters.getMaxItems(), details.getSearchParameters().getMaxItems()); - assertEquals(searchParameters.isIncludeRecords(), details.getSearchParameters().isIncludeRecords()); - assertEquals(searchParameters.isIncludeUndeclaredRecords(), details.getSearchParameters().isIncludeUndeclaredRecords()); - assertEquals(searchParameters.isIncludeVitalRecords(), details.getSearchParameters().isIncludeVitalRecords()); - assertEquals(searchParameters.isIncludeRecordFolders(), details.getSearchParameters().isIncludeRecordFolders()); - assertEquals(searchParameters.isIncludeFrozen(), details.getSearchParameters().isIncludeFrozen()); - assertEquals(searchParameters.isIncludeCutoff(), details.getSearchParameters().isIncludeCutoff()); - - // Check the other stuff .... - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; +import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; +import org.alfresco.util.TestWithUserUtils; + +/** + * Search service implementation unit test. + * + * @author Roy Wetherall + */ +@SuppressWarnings("unused") +public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase +{ + @Override + protected boolean isMultiHierarchyTest() + { + return true; + } + + private static final String SEARCH1 = "search1"; + private static final String SEARCH2 = "search2"; + private static final String SEARCH3 = "search3"; + private static final String SEARCH4 = "search4"; + + private static final String USER1 = "user1"; + private static final String USER2 = "user2"; + + private NodeRef folderLevelRecordFolder; + private NodeRef recordLevelRecordFolder; + + private NodeRef recordOne; + private NodeRef recordTwo; + private NodeRef recordThree; + private NodeRef recordFour; + private NodeRef recordFive; + private NodeRef recordSix; + + private int numberOfReports; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData() + */ + @Override + protected void setupTestData() + { + super.setupTestData(); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Create test users + TestWithUserUtils.createUser(USER1, USER1, rootNodeRef, nodeService, authenticationService); + TestWithUserUtils.createUser(USER2, USER2, rootNodeRef, nodeService, authenticationService); + + // Count the number of pre-defined reports + List searches = rmSearchService.getSavedSearches(siteId); + assertNotNull(searches); + numberOfReports = searches.size(); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupMultiHierarchyTestData() + */ + @Override + protected void setupMultiHierarchyTestData() + { + super.setupMultiHierarchyTestData(); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + folderLevelRecordFolder = mhRecordFolder42; + recordLevelRecordFolder = mhRecordFolder43; + + recordOne = utils.createRecord(folderLevelRecordFolder, "recordOne.txt", null, "record one - folder level - elephant"); + recordTwo = utils.createRecord(folderLevelRecordFolder, "recordTwo.txt", null, "record two - folder level - snake"); + recordThree = utils.createRecord(folderLevelRecordFolder, "recordThree.txt", null, "record three - folder level - monkey"); + recordFour = utils.createRecord(recordLevelRecordFolder, "recordFour.txt", null, "record four - record level - elephant"); + recordFive = utils.createRecord(recordLevelRecordFolder, "recordFive.txt", null, "record five - record level - snake"); + recordSix = utils.createRecord(recordLevelRecordFolder, "recordSix.txt", null, "record six - record level - monkey"); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + } + + @Override + protected void tearDown() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Delete test users + TestWithUserUtils.deleteUser(USER1, USER1, rootNodeRef, nodeService, authenticationService); + TestWithUserUtils.deleteUser(USER2, USER2, rootNodeRef, nodeService, authenticationService); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + super.tearDown(); + } + + public void testSearch() + { + // Full text search + doTestInTransaction(new Test() + { + @Override + public Void run() + { + String query = "keywords:\"elephant\""; + RecordsManagementSearchParameters params = new RecordsManagementSearchParameters(); + params.setIncludeUndeclaredRecords(true); + List> results = rmSearchService.search(siteId, query, params); + assertNotNull(results); + assertEquals(2, results.size()); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); + + // Property search + + // + } + + public void testSaveSearch() + { + // Add some saved searches (as admin user) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + SavedSearchDetails details1 = rmSearchService.saveSearch(siteId, SEARCH1, "description1", "query1", new RecordsManagementSearchParameters(), true); + checkSearchDetails(details1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); + SavedSearchDetails details2 = rmSearchService.saveSearch(siteId, SEARCH2, "description2", "query2", new RecordsManagementSearchParameters(), false); + checkSearchDetails(details2, siteId, "search2", "description2", "query2", new RecordsManagementSearchParameters(), false); + + return null; + } + + }); + + // Add some saved searches (as user1) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + SavedSearchDetails details1 = rmSearchService.saveSearch(siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); + checkSearchDetails(details1, siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); + SavedSearchDetails details2 = rmSearchService.saveSearch(siteId, SEARCH4, "description4", "query4", new RecordsManagementSearchParameters(), false); + checkSearchDetails(details2, siteId, SEARCH4, "description4", "query4", new RecordsManagementSearchParameters(), false); + + return null; + } + + }, USER1); + + // Get searches (as admin user) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List searches = rmSearchService.getSavedSearches(siteId); + assertNotNull(searches); + assertEquals(numberOfReports + 2, searches.size()); + + SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); + assertNotNull(search1); + checkSearchDetails(search1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); + + SavedSearchDetails search2 = rmSearchService.getSavedSearch(siteId, SEARCH2); + assertNotNull(search2); + checkSearchDetails(search2, siteId, "search2", "description2", "query2", new RecordsManagementSearchParameters(), false); + + SavedSearchDetails search3 = rmSearchService.getSavedSearch(siteId, SEARCH3); + assertNull(search3); + + SavedSearchDetails search4 = rmSearchService.getSavedSearch(siteId, SEARCH4); + assertNull(search4); + + return null; + } + + }); + + // Get searches (as user1) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List searches = rmSearchService.getSavedSearches(siteId); + assertNotNull(searches); + assertEquals(numberOfReports + 3, searches.size()); + + SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); + assertNotNull(search1); + checkSearchDetails(search1, siteId, "search1", "description1", "query1", new RecordsManagementSearchParameters(), true); + + SavedSearchDetails search2 = rmSearchService.getSavedSearch(siteId, SEARCH2); + assertNull(search2); + + SavedSearchDetails search3 = rmSearchService.getSavedSearch(siteId, SEARCH3); + assertNotNull(search3); + checkSearchDetails(search3, siteId, SEARCH3, "description3", "query3", new RecordsManagementSearchParameters(), false); + + SavedSearchDetails search4 = rmSearchService.getSavedSearch(siteId, SEARCH4); + assertNotNull(search4); + checkSearchDetails(search4, siteId, "search4", "description4", "query4", new RecordsManagementSearchParameters(), false); + + return null; + } + + }, USER1); + + // Update search (as admin user) + doTestInTransaction(new Test() + { + @Override + public Void run() + { + SavedSearchDetails search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); + assertNotNull(search1); + checkSearchDetails(search1, siteId, SEARCH1, "description1", "query1", new RecordsManagementSearchParameters(), true); + + rmSearchService.saveSearch(siteId, SEARCH1, "change", "change", new RecordsManagementSearchParameters(), true); + + search1 = rmSearchService.getSavedSearch(siteId, SEARCH1); + assertNotNull(search1); + checkSearchDetails(search1, siteId, SEARCH1, "change", "change", new RecordsManagementSearchParameters(), true); + + return null; + } + }); + + // Delete searches (as admin user) + // TODO + } + + /** + * Check the details of the saved search. + */ + private void checkSearchDetails( + SavedSearchDetails details, + String siteid, + String name, + String description, + String query, + RecordsManagementSearchParameters searchParameters, + boolean isPublic) + { + assertNotNull(details); + assertEquals(siteid, details.getSiteId()); + assertEquals(name, details.getName()); + assertEquals(description, details.getDescription()); + assertEquals(query, details.getSearch()); + assertEquals(isPublic, details.isPublic()); + + assertEquals(searchParameters.getMaxItems(), details.getSearchParameters().getMaxItems()); + assertEquals(searchParameters.isIncludeRecords(), details.getSearchParameters().isIncludeRecords()); + assertEquals(searchParameters.isIncludeUndeclaredRecords(), details.getSearchParameters().isIncludeUndeclaredRecords()); + assertEquals(searchParameters.isIncludeVitalRecords(), details.getSearchParameters().isIncludeVitalRecords()); + assertEquals(searchParameters.isIncludeRecordFolders(), details.getSearchParameters().isIncludeRecordFolders()); + assertEquals(searchParameters.isIncludeFrozen(), details.getSearchParameters().isIncludeFrozen()); + assertEquals(searchParameters.isIncludeCutoff(), details.getSearchParameters().isIncludeCutoff()); + + // Check the other stuff .... + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementServiceImplTest.java index 0bee4f7467..5474d13992 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementServiceImplTest.java @@ -1,615 +1,615 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - - -/** - * Records management service test. - * - * @author Roy Wetherall - */ -public class RecordsManagementServiceImplTest extends BaseRMTestCase -{ - /********** RM Component methods **********/ - - /** - * @see FilePlanService#isFilePlanComponent(NodeRef) - */ - public void testIsFilePlanComponent() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); - assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); - assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); - - return null; - } - }); - } - - /** - * @see FilePlanService#getFilePlanComponentKind(NodeRef) - */ - public void testGetFilePlanComponentKind() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() throws Exception - { - return utils.createRecord(rmFolder, "testRecord.txt"); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); - assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); - assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); - assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); - // TODO HOLD and TRANSFER - assertNull(filePlanService.getFilePlanComponentKind(folder)); - } - }); - } - - /** - * @see FilePlanService#isFilePlan(NodeRef) - */ - public void testIsFilePlan() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertTrue("This is a records management root", filePlanService.isFilePlan(filePlan)); - assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmContainer)); - assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmFolder)); - - return null; - } - }); - } - - /** - * @see FilePlanService#isRecordCategory(NodeRef) - */ - public void testIsRecordCategory() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); - assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); - assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); - - return null; - } - }); - } - - /** - * @see RecordFolderService#isRecordFolder(NodeRef) - */ - public void testIsRecordFolder() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(filePlan)); - assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(rmContainer)); - assertTrue("This should be a record folder", recordFolderService.isRecordFolder(rmFolder)); - - return null; - } - }); - } - - public void testGetRecordsManagementRoot() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); - assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); - assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); - - return null; - } - }); - } - - /********** Record Management Root methods **********/ - - /** - * @see FilePlanService#getFilePlans() - */ - public void testGetRecordsManagementRoots() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - List roots = new ArrayList(filePlanService.getFilePlans()); - assertNotNull(roots); - assertTrue(roots.size() != 0); - assertTrue(roots.contains(filePlan)); - - return null; - } - }); - } - - /** - * @see FilePlanService#createFilePlan(NodeRef, String) - * @see FilePlanService#createFilePlan(NodeRef, String, QName) - */ - public void testCreateFilePlan() throws Exception - { - // Create default type of root - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createFilePlan(folder, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management root", result); - basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); - } - }); - - // Create specific type of root - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management root", result); - basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); - } - }); - - // Failure: creating root in existing hierarchy - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createFilePlan(rmContainer, GUID.generate()); - } - }); - - // Failure: type no extended from root container - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); - } - }); - } - - /********** Records Management Container methods **********/ - - /** - * @see FilePlanService#createRecordCategory(NodeRef, String) - * @see FilePlanService#createFilePlan(NodeRef, String, QName) - */ - public void testCreateRecordCategory() throws Exception - { - // Create container (in root) - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createRecordCategory(filePlan, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management container", result); - basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); - } - }); - - // Create container (in container) - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return filePlanService.createRecordCategory(rmContainer, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create records management container", result); - basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); - } - }); - - // TODO need a custom type of container! - // Create container of a given type -// doTestInTransaction(new Test() -// { -// @Override -// public NodeRef run() -// { -// String id = setString("id", GUID.generate()); -// return filePlanService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); -// } -// -// @Override -// public void test(NodeRef result) -// { -// assertNotNull("Unable to create records management container", result); -// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); -// } -// }); - - // Fail Test: parent is not a container - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createRecordCategory(folder, GUID.generate()); - } - }); - - // Fail Test: type is not a sub-type of rm:recordsManagementContainer - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); - } - }); - } - - /** - * @see FilePlanService#getAllContained(NodeRef) - * @see FilePlanService#getAllContained(NodeRef, boolean) - */ - public void testGetAllContained() throws Exception - { - // Get all contained test - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getAllContained(rmContainer); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getAllContained(rmContainer, false); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getAllContained(rmContainer, true); - assertNotNull(nodes); - assertEquals(4, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); - assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); - assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); - - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getAllContained(rmFolder); - } - }); - } - - /** - * @see FilePlanService#getContainedRecordCategories(NodeRef) - * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) - */ - public void testGetContainedRecordCategories() throws Exception - { - // Test getting all contained containers - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getContainedRecordCategories(rmContainer); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = filePlanService.getContainedRecordCategories(rmContainer, false); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = filePlanService.getContainedRecordCategories(rmContainer, true); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getContainedRecordCategories(rmFolder); - } - }); - } - - /** - * @see FilePlanService#getContainedRecordFolders(NodeRef) - * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) - */ - public void testGetContainedRecordFolders() throws Exception - { - // Test getting all contained record folders - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Add to the test data - NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - - // Put in model - setNodeRef("series", series); - setNodeRef("seriesChildFolder", seriesChildFolder); - setNodeRef("seriesChildContainer", seriesChildContainer); - - return null; - } - - @Override - public void test(Void result) throws Exception - { - List nodes = filePlanService.getContainedRecordFolders(rmContainer); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getContainedRecordFolders(rmContainer, false); - assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = filePlanService.getContainedRecordFolders(rmContainer, true); - assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); - } - }); - - // Failure: call on record folder - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - filePlanService.getContainedRecordFolders(rmFolder); - } - }); - } - - /********** Record Folder methods **********/ - - // TODO void testIsRecordFolderDeclared() - - // TODO void testIsRecordFolderClosed() - - // TODO void testGetRecords() - - /** - * @see RecordFolderService#createRecordFolder(NodeRef, String) - * @see RecordFolderService#createRecordFolder(NodeRef, String, QName) - */ - public void testCreateRecordFolder() throws Exception - { - // Create record - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - String id = setString("id", GUID.generate()); - return recordFolderService.createRecordFolder(rmContainer, id); - } - - @Override - public void test(NodeRef result) - { - assertNotNull("Unable to create record folder", result); - basicRMContainerCheck(result, getString("id"), TYPE_RECORD_FOLDER); - } - }); - - // TODO Create record of type - - // Failure: Create record with invalid type - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - recordFolderService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER); - } - }); - - // Failure: Create record folder in root - doTestInTransaction(new FailureTest() - { - @Override - public void run() - { - recordFolderService.createRecordFolder(filePlan, GUID.generate()); - } - }); - } - - - /********** RM2 - Multi-hierarchy record taxonomy's **********/ - - /** - * Test to create a simple multi-hierarchy record taxonomy - */ - public void testCreateSimpleHierarchy() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - // Create 3 level hierarchy - NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); - assertNotNull("Unable to create container", levelOne); - NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); - assertNotNull("Unable to create container", levelTwo); - NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); - assertNotNull("Unable to create container", levelThree); - NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); - assertNotNull("Unable to create record folder", levelThreeRecordFolder); - - return null; - } - - @Override - public void test(Void result) - { - // Test that the hierarchy has been created correctly - basicRMContainerCheck(getNodeRef("container1"), "container1", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); - basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); - - // TODO need to check that the parents and children can be retrieved correctly - } - }); - } - - /** - * A basic test of a records management container - * - * @param nodeRef node reference - * @param name name of the container - * @param type the type of container - */ - private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) - { - // Check the basic details - assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); - assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); - assertEquals(type, nodeService.getType(nodeRef)); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; + + +/** + * Records management service test. + * + * @author Roy Wetherall + */ +public class RecordsManagementServiceImplTest extends BaseRMTestCase +{ + /********** RM Component methods **********/ + + /** + * @see FilePlanService#isFilePlanComponent(NodeRef) + */ + public void testIsFilePlanComponent() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); + assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); + assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); + + return null; + } + }); + } + + /** + * @see FilePlanService#getFilePlanComponentKind(NodeRef) + */ + public void testGetFilePlanComponentKind() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return utils.createRecord(rmFolder, "testRecord.txt"); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); + assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); + assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); + assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); + // TODO HOLD and TRANSFER + assertNull(filePlanService.getFilePlanComponentKind(folder)); + } + }); + } + + /** + * @see FilePlanService#isFilePlan(NodeRef) + */ + public void testIsFilePlan() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertTrue("This is a records management root", filePlanService.isFilePlan(filePlan)); + assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmContainer)); + assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmFolder)); + + return null; + } + }); + } + + /** + * @see FilePlanService#isRecordCategory(NodeRef) + */ + public void testIsRecordCategory() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); + assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); + + return null; + } + }); + } + + /** + * @see RecordFolderService#isRecordFolder(NodeRef) + */ + public void testIsRecordFolder() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(filePlan)); + assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(rmContainer)); + assertTrue("This should be a record folder", recordFolderService.isRecordFolder(rmFolder)); + + return null; + } + }); + } + + public void testGetRecordsManagementRoot() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); + assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); + assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); + + return null; + } + }); + } + + /********** Record Management Root methods **********/ + + /** + * @see FilePlanService#getFilePlans() + */ + public void testGetRecordsManagementRoots() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + List roots = new ArrayList(filePlanService.getFilePlans()); + assertNotNull(roots); + assertTrue(roots.size() != 0); + assertTrue(roots.contains(filePlan)); + + return null; + } + }); + } + + /** + * @see FilePlanService#createFilePlan(NodeRef, String) + * @see FilePlanService#createFilePlan(NodeRef, String, QName) + */ + public void testCreateFilePlan() throws Exception + { + // Create default type of root + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createFilePlan(folder, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management root", result); + basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); + } + }); + + // Create specific type of root + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management root", result); + basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); + } + }); + + // Failure: creating root in existing hierarchy + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createFilePlan(rmContainer, GUID.generate()); + } + }); + + // Failure: type no extended from root container + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); + } + }); + } + + /********** Records Management Container methods **********/ + + /** + * @see FilePlanService#createRecordCategory(NodeRef, String) + * @see FilePlanService#createFilePlan(NodeRef, String, QName) + */ + public void testCreateRecordCategory() throws Exception + { + // Create container (in root) + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createRecordCategory(filePlan, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management container", result); + basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); + } + }); + + // Create container (in container) + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return filePlanService.createRecordCategory(rmContainer, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create records management container", result); + basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); + } + }); + + // TODO need a custom type of container! + // Create container of a given type +// doTestInTransaction(new Test() +// { +// @Override +// public NodeRef run() +// { +// String id = setString("id", GUID.generate()); +// return filePlanService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); +// } +// +// @Override +// public void test(NodeRef result) +// { +// assertNotNull("Unable to create records management container", result); +// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); +// } +// }); + + // Fail Test: parent is not a container + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createRecordCategory(folder, GUID.generate()); + } + }); + + // Fail Test: type is not a sub-type of rm:recordsManagementContainer + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); + } + }); + } + + /** + * @see FilePlanService#getAllContained(NodeRef) + * @see FilePlanService#getAllContained(NodeRef, boolean) + */ + public void testGetAllContained() throws Exception + { + // Get all contained test + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getAllContained(rmContainer); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getAllContained(rmContainer, false); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getAllContained(rmContainer, true); + assertNotNull(nodes); + assertEquals(4, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); + assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); + + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getAllContained(rmFolder); + } + }); + } + + /** + * @see FilePlanService#getContainedRecordCategories(NodeRef) + * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) + */ + public void testGetContainedRecordCategories() throws Exception + { + // Test getting all contained containers + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getContainedRecordCategories(rmContainer); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, false); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, true); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getContainedRecordCategories(rmFolder); + } + }); + } + + /** + * @see FilePlanService#getContainedRecordFolders(NodeRef) + * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) + */ + public void testGetContainedRecordFolders() throws Exception + { + // Test getting all contained record folders + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add to the test data + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + + // Put in model + setNodeRef("series", series); + setNodeRef("seriesChildFolder", seriesChildFolder); + setNodeRef("seriesChildContainer", seriesChildContainer); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + List nodes = filePlanService.getContainedRecordFolders(rmContainer); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, false); + assertNotNull(nodes); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, true); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); + } + }); + + // Failure: call on record folder + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + filePlanService.getContainedRecordFolders(rmFolder); + } + }); + } + + /********** Record Folder methods **********/ + + // TODO void testIsRecordFolderDeclared() + + // TODO void testIsRecordFolderClosed() + + // TODO void testGetRecords() + + /** + * @see RecordFolderService#createRecordFolder(NodeRef, String) + * @see RecordFolderService#createRecordFolder(NodeRef, String, QName) + */ + public void testCreateRecordFolder() throws Exception + { + // Create record + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + String id = setString("id", GUID.generate()); + return recordFolderService.createRecordFolder(rmContainer, id); + } + + @Override + public void test(NodeRef result) + { + assertNotNull("Unable to create record folder", result); + basicRMContainerCheck(result, getString("id"), TYPE_RECORD_FOLDER); + } + }); + + // TODO Create record of type + + // Failure: Create record with invalid type + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + recordFolderService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER); + } + }); + + // Failure: Create record folder in root + doTestInTransaction(new FailureTest() + { + @Override + public void run() + { + recordFolderService.createRecordFolder(filePlan, GUID.generate()); + } + }); + } + + + /********** RM2 - Multi-hierarchy record taxonomy's **********/ + + /** + * Test to create a simple multi-hierarchy record taxonomy + */ + public void testCreateSimpleHierarchy() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Create 3 level hierarchy + NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); + assertNotNull("Unable to create container", levelOne); + NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); + assertNotNull("Unable to create container", levelTwo); + NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); + assertNotNull("Unable to create container", levelThree); + NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); + assertNotNull("Unable to create record folder", levelThreeRecordFolder); + + return null; + } + + @Override + public void test(Void result) + { + // Test that the hierarchy has been created correctly + basicRMContainerCheck(getNodeRef("container1"), "container1", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); + basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); + + // TODO need to check that the parents and children can be retrieved correctly + } + }); + } + + /** + * A basic test of a records management container + * + * @param nodeRef node reference + * @param name name of the container + * @param type the type of container + */ + private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) + { + // Check the basic details + assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); + assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); + assertEquals(type, nodeService.getType(nodeRef)); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java index d7ffb4606a..6ccdcb272c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java @@ -1,231 +1,231 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.FileReportAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.report.Report; -import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; -import org.apache.commons.lang.StringUtils; - -/** - * Report service implementation unit test. - * - * @author Roy Wetherall - */ -public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel -{ - public void testGetReportTypes() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Set reportTypes = reportService.getReportTypes(); - - assertNotNull(reportTypes); - assertFalse(reportTypes.isEmpty()); - - for (QName reportType : reportTypes) - { - System.out.println(reportType.toString()); - } - - return null; - } - }); - } - - public void testGenerateReport() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Destruction Report - Report destructionReport = generateDestructionReport(); - System.out.println(destructionReport.getReportName()); - System.out.println(destructionReport.getReportContent().getContentString()); - - // Transfer Report - Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML); - System.out.println(transferReport.getReportName()); - System.out.println(transferReport.getReportContent().getContentString()); - - return null; - } - }); - } - - public void testFileReport() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Destruction Report - NodeRef destructionReportNodeRef = fileDestructionReport(); - assertNotNull(destructionReportNodeRef); - assertTrue(recordService.isRecord(destructionReportNodeRef)); - assertFalse(recordService.isFiled(destructionReportNodeRef)); - assertEquals(TYPE_DESTRUCTION_REPORT, nodeService.getType(destructionReportNodeRef)); - - // Transfer Report - NodeRef transferReportNodeRef = fileTransferReport(); - assertNotNull(transferReportNodeRef); - assertTrue(recordService.isRecord(transferReportNodeRef)); - assertFalse(recordService.isFiled(transferReportNodeRef)); - assertEquals(TYPE_TRANSFER_REPORT, nodeService.getType(transferReportNodeRef)); - - return null; - } - }); - } - - /** - * Helper method to generate a destruction report - * - * @return Destruction report - */ - private Report generateDestructionReport() - { - return reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder); - } - - /** - * Helper method to file a destruction report - * - * @return Node reference of the destruction report - */ - private NodeRef fileDestructionReport() - { - Report destructionReport = generateDestructionReport(); - return reportService.fileReport(filePlan, destructionReport); - } - - /** - * Helper method to file a transfer report - * - * @return Node reference of the transfer report - */ - private NodeRef fileTransferReport() - { - Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML); - return reportService.fileReport(filePlan, transferReport); - } - - public void testFileDestructionReportAction() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(rmFolder, CompleteEventAction.NAME, params); - - rmActionService.executeRecordsManagementAction(rmFolder, CutOffAction.NAME); - rmActionService.executeRecordsManagementAction(rmFolder, DestroyAction.NAME); - - Map fileReportParams = new HashMap(2); - fileReportParams.put(FileReportAction.REPORT_TYPE, "rmr:destructionReport"); - fileReportParams.put(FileReportAction.DESTINATION, filePlan.toString()); - rmActionService.executeRecordsManagementAction(rmFolder, FileReportAction.NAME, fileReportParams); - return null; - } - }); - } - - public void testFileTransferReportAction() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Create transfer report for the transfer object - Map params = new HashMap(2); - params.put(FileReportAction.REPORT_TYPE, "rmr:transferReport"); - params.put(FileReportAction.DESTINATION, filePlan.toString()); - RecordsManagementActionResult transferReportAction = rmActionService.executeRecordsManagementAction(getTransferObject(), FileReportAction.NAME, params); - // Check transfer report result - String transferReportName = (String) transferReportAction.getValue(); - assertFalse(StringUtils.isBlank(transferReportName)); - return null; - } - }); - } - - /** - * Helper method for creating a transfer object - * - * @return Node reference of the transfer object - */ - private NodeRef getTransferObject() - { - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); - utils.createDispositionSchedule( - recordCategory, - CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, - CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, - false, // record level - true, // set the default actions - true); // extended disposition schedule - - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); - - // Set the record folder identifier - String identifier = identifierService.generateIdentifier(TYPE_RECORD_FOLDER, recordCategory); - nodeService.setProperty(recordFolder, PROP_IDENTIFIER, identifier); - - // Complete event - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); - rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); - - // Cut off folder - rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME); - - // Transfer folder - RecordsManagementActionResult transferAction = rmActionService.executeRecordsManagementAction(recordFolder, TransferAction.NAME); - NodeRef transferObject = (NodeRef) transferAction.getValue(); - assertTrue(transferObject != null); - - return transferObject; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileReportAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.report.Report; +import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; +import org.apache.commons.lang.StringUtils; + +/** + * Report service implementation unit test. + * + * @author Roy Wetherall + */ +public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel +{ + public void testGetReportTypes() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Set reportTypes = reportService.getReportTypes(); + + assertNotNull(reportTypes); + assertFalse(reportTypes.isEmpty()); + + for (QName reportType : reportTypes) + { + System.out.println(reportType.toString()); + } + + return null; + } + }); + } + + public void testGenerateReport() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Destruction Report + Report destructionReport = generateDestructionReport(); + System.out.println(destructionReport.getReportName()); + System.out.println(destructionReport.getReportContent().getContentString()); + + // Transfer Report + Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML); + System.out.println(transferReport.getReportName()); + System.out.println(transferReport.getReportContent().getContentString()); + + return null; + } + }); + } + + public void testFileReport() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Destruction Report + NodeRef destructionReportNodeRef = fileDestructionReport(); + assertNotNull(destructionReportNodeRef); + assertTrue(recordService.isRecord(destructionReportNodeRef)); + assertFalse(recordService.isFiled(destructionReportNodeRef)); + assertEquals(TYPE_DESTRUCTION_REPORT, nodeService.getType(destructionReportNodeRef)); + + // Transfer Report + NodeRef transferReportNodeRef = fileTransferReport(); + assertNotNull(transferReportNodeRef); + assertTrue(recordService.isRecord(transferReportNodeRef)); + assertFalse(recordService.isFiled(transferReportNodeRef)); + assertEquals(TYPE_TRANSFER_REPORT, nodeService.getType(transferReportNodeRef)); + + return null; + } + }); + } + + /** + * Helper method to generate a destruction report + * + * @return Destruction report + */ + private Report generateDestructionReport() + { + return reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder); + } + + /** + * Helper method to file a destruction report + * + * @return Node reference of the destruction report + */ + private NodeRef fileDestructionReport() + { + Report destructionReport = generateDestructionReport(); + return reportService.fileReport(filePlan, destructionReport); + } + + /** + * Helper method to file a transfer report + * + * @return Node reference of the transfer report + */ + private NodeRef fileTransferReport() + { + Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML); + return reportService.fileReport(filePlan, transferReport); + } + + public void testFileDestructionReportAction() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(rmFolder, CompleteEventAction.NAME, params); + + rmActionService.executeRecordsManagementAction(rmFolder, CutOffAction.NAME); + rmActionService.executeRecordsManagementAction(rmFolder, DestroyAction.NAME); + + Map fileReportParams = new HashMap(2); + fileReportParams.put(FileReportAction.REPORT_TYPE, "rmr:destructionReport"); + fileReportParams.put(FileReportAction.DESTINATION, filePlan.toString()); + rmActionService.executeRecordsManagementAction(rmFolder, FileReportAction.NAME, fileReportParams); + return null; + } + }); + } + + public void testFileTransferReportAction() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + // Create transfer report for the transfer object + Map params = new HashMap(2); + params.put(FileReportAction.REPORT_TYPE, "rmr:transferReport"); + params.put(FileReportAction.DESTINATION, filePlan.toString()); + RecordsManagementActionResult transferReportAction = rmActionService.executeRecordsManagementAction(getTransferObject(), FileReportAction.NAME, params); + // Check transfer report result + String transferReportName = (String) transferReportAction.getValue(); + assertFalse(StringUtils.isBlank(transferReportName)); + return null; + } + }); + } + + /** + * Helper method for creating a transfer object + * + * @return Node reference of the transfer object + */ + private NodeRef getTransferObject() + { + NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + utils.createDispositionSchedule( + recordCategory, + CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, + CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, + false, // record level + true, // set the default actions + true); // extended disposition schedule + + NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate()); + + // Set the record folder identifier + String identifier = identifierService.generateIdentifier(TYPE_RECORD_FOLDER, recordCategory); + nodeService.setProperty(recordFolder, PROP_IDENTIFIER, identifier); + + // Complete event + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); + rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params); + + // Cut off folder + rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME); + + // Transfer folder + RecordsManagementActionResult transferAction = rmActionService.executeRecordsManagementAction(recordFolder, TransferAction.NAME); + NodeRef transferObject = (NodeRef) transferAction.getValue(); + assertTrue(transferObject != null); + + return transferObject; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServiceBaseImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServiceBaseImplTest.java index 5a973c43db..a8aa50fb41 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServiceBaseImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServiceBaseImplTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestServiceImpl; -import org.alfresco.service.namespace.QName; - -/** - * Unit test for service base implementation. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class ServiceBaseImplTest extends BaseRMTestCase -{ - /** test service */ - private TestServiceImpl testService; - - /** - * Init services - */ - @Override - protected void initServices() - { - super.initServices(); - - testService = (TestServiceImpl)applicationContext.getBean("testService"); - } - - /** - * test instanceOf() - */ - public void testInstanceOf() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - assertTrue(testService.doInstanceOf(rmFolder, ContentModel.TYPE_FOLDER)); - assertTrue(testService.doInstanceOf(rmFolder, TYPE_RECORD_FOLDER)); - assertFalse(testService.doInstanceOf(rmFolder, TYPE_RECORD_CATEGORY)); - - return null; - } - }); - - } - - /** - * test getNextCounter() - */ - public void testGetNextCounter() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - assertNull(nodeService.getProperty(rmFolder, PROP_COUNT)); - assertEquals(1, testService.doGetNextCount(rmFolder)); - assertEquals(2, testService.doGetNextCount(rmFolder)); - assertEquals(3, testService.doGetNextCount(rmFolder)); - - return null; - } - }); - - } - - /** - * test getTypeAndAspects() - */ - public void testGetTypeAndAspects() - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - Set result = testService.doGetTypeAndApsects(rmFolder); - assertTrue(result.contains(TYPE_RECORD_FOLDER)); - - return null; - } - }); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestServiceImpl; +import org.alfresco.service.namespace.QName; + +/** + * Unit test for service base implementation. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class ServiceBaseImplTest extends BaseRMTestCase +{ + /** test service */ + private TestServiceImpl testService; + + /** + * Init services + */ + @Override + protected void initServices() + { + super.initServices(); + + testService = (TestServiceImpl)applicationContext.getBean("testService"); + } + + /** + * test instanceOf() + */ + public void testInstanceOf() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + assertTrue(testService.doInstanceOf(rmFolder, ContentModel.TYPE_FOLDER)); + assertTrue(testService.doInstanceOf(rmFolder, TYPE_RECORD_FOLDER)); + assertFalse(testService.doInstanceOf(rmFolder, TYPE_RECORD_CATEGORY)); + + return null; + } + }); + + } + + /** + * test getNextCounter() + */ + public void testGetNextCounter() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + assertNull(nodeService.getProperty(rmFolder, PROP_COUNT)); + assertEquals(1, testService.doGetNextCount(rmFolder)); + assertEquals(2, testService.doGetNextCount(rmFolder)); + assertEquals(3, testService.doGetNextCount(rmFolder)); + + return null; + } + }); + + } + + /** + * test getTypeAndAspects() + */ + public void testGetTypeAndAspects() + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + Set result = testService.doGetTypeAndApsects(rmFolder); + assertTrue(result.contains(TYPE_RECORD_FOLDER)); + + return null; + } + }); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServicesTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServicesTestSuite.java index b981f08c25..4ae0a81e2e 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServicesTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ServicesTestSuite.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - - -/** - * RM test suite - * - * @author Roy Wetherall - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - ServiceBaseImplTest.class, - ExtendedSecurityServiceImplTest.class, - ModelSecurityServiceImplTest.class, - RecordsManagementActionServiceImplTest.class, - ExtendedActionServiceTest.class, - DispositionServiceImplTest.class, - RecordsManagementActionServiceImplTest.class, - RecordsManagementAdminServiceImplTest.class, - RecordsManagementAuditServiceImplTest.class, - //RecordsManagementEventServiceImplTest.class, - RecordsManagementSearchServiceImplTest.class, - VitalRecordServiceImplTest.class, - DataSetServiceImplTest.class, - FreezeServiceImplTest.class, - RecordServiceImplTest.class, - CapabilityServiceImplTest.class, - FilePlanRoleServiceImplTest.class, - FilePlanServiceImplTest.class, - FilePlanPermissionServiceImplTest.class, - ReportServiceImplTest.class, - RecordsManagementQueryDAOImplTest.class, - DeleteHoldTest.class -}) -public class ServicesTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import org.alfresco.module.org_alfresco_module_rm.test.integration.hold.DeleteHoldTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * RM test suite + * + * @author Roy Wetherall + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + ServiceBaseImplTest.class, + ExtendedSecurityServiceImplTest.class, + ModelSecurityServiceImplTest.class, + RecordsManagementActionServiceImplTest.class, + ExtendedActionServiceTest.class, + DispositionServiceImplTest.class, + RecordsManagementActionServiceImplTest.class, + RecordsManagementAdminServiceImplTest.class, + RecordsManagementAuditServiceImplTest.class, + //RecordsManagementEventServiceImplTest.class, + RecordsManagementSearchServiceImplTest.class, + VitalRecordServiceImplTest.class, + DataSetServiceImplTest.class, + FreezeServiceImplTest.class, + RecordServiceImplTest.class, + CapabilityServiceImplTest.class, + FilePlanRoleServiceImplTest.class, + FilePlanServiceImplTest.class, + FilePlanPermissionServiceImplTest.class, + ReportServiceImplTest.class, + RecordsManagementQueryDAOImplTest.class, + DeleteHoldTest.class +}) +public class ServicesTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/VitalRecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/VitalRecordServiceImplTest.java index 259066ebee..08735427e4 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/VitalRecordServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/VitalRecordServiceImplTest.java @@ -1,461 +1,461 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; - -import java.util.Date; - -import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.util.GUID; - -/** - * Vital record service implementation unit test. - * - * @author Roy Wetherall - */ -public class VitalRecordServiceImplTest extends BaseRMTestCase -{ - /** Test periods */ - protected static final Period PERIOD_NONE = new Period("none|0"); - protected static final Period PERIOD_WEEK = new Period("week|1"); - protected static final Period PERIOD_MONTH = new Period("month|1"); - - /** Test records */ - private NodeRef mhRecord51; - private NodeRef mhRecord52; - private NodeRef mhRecord53; - private NodeRef mhRecord54; - private NodeRef mhRecord55; - - /** - * Indicate this test uses the collaboration site test data - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** Indicate this is a multi hierarchy test */ - @Override - protected boolean isMultiHierarchyTest() - { - return true; - } - - /** vital record multi-hierarchy test data - * - * |--rmRootContainer (no vr def) - * | - * |--mhContainer (no vr def) - * | - * |--mhContainer-1-1 (has schedule - folder level) (no vr def) - * | | - * | |--mhContainer-2-1 (vr def) - * | | - * | |--mhContainer-3-1 (no vr def) - * | - * |--mhContainer-1-2 (has schedule - folder level) (no vr def) - * | - * |--mhContainer-2-2 (no vr def) - * | | - * | |--mhContainer-3-2 (vr def disabled) - * | | - * | |--mhContainer-3-3 (has schedule - record level) (vr def) - * | - * |--mhContainer-2-3 (has schedule - folder level) (vr def) - * | - * |--mhContainer-3-4 (no vr def) - * | - * |--mhContainer-3-5 (has schedule- record level) (vr def) - */ - @Override - protected void setupMultiHierarchyTestData() - { - // Load core test data - super.setupMultiHierarchyTestData(); - - // Setup vital record definitions - setupVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); - setupVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); - setupVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); - setupVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); - setupVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - - // Create records - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - mhRecord51 = utils.createRecord(mhRecordFolder41, "record51.txt"); - mhRecord52 = utils.createRecord(mhRecordFolder42, "record52.txt"); - mhRecord53 = utils.createRecord(mhRecordFolder43, "record53.txt"); - mhRecord54 = utils.createRecord(mhRecordFolder44, "record54.txt"); - mhRecord55 = utils.createRecord(mhRecordFolder45, "record55.txt"); - - return null; - } - }); - } - - /** - * Helper to set up the vital record definition data in a transactional manner. - * - * @param nodeRef - * @param enabled - * @param period - */ - private void setupVitalRecordDefinition(final NodeRef nodeRef, final boolean enabled, final Period period) - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - vitalRecordService.setVitalRecordDefintion(nodeRef, enabled, period); - return null; - } - }); - } - - /** - * Based on the initial data: - * - check category, folder and record raw values. - * - check search aspect values. - */ - public void testInit() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertHasVitalRecordDefinition(mhContainer, false, null); - assertHasVitalRecordDefinition(mhContainer11, false, null); - assertHasVitalRecordDefinition(mhContainer12, false, null); - assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer22, false, null); - assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer31, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - - assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder42, false, null); - assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - - assertVitalRecord(mhRecord51, true, PERIOD_WEEK); - assertVitalRecord(mhRecord52, false, null); - assertVitalRecord(mhRecord53, true, PERIOD_WEEK); - assertVitalRecord(mhRecord54, true, PERIOD_WEEK); - assertVitalRecord(mhRecord55, true, PERIOD_MONTH); - - return null; - } - }); - } - - /** - * Test that when new record categories and record folders are created in an existing file plan - * structure that they correctly inherit the correct vital record property values - */ - public void testValueInheritance() throws Exception - { - // Test record category value inheritance - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - return filePlanService.createRecordCategory(mhContainer35, GUID.generate()); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertHasVitalRecordDefinition(result, true, PERIOD_MONTH); - } - }); - - // Test record folder value inheritance - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - return recordFolderService.createRecordFolder(mhContainer32, GUID.generate()); - } - - @Override - public void test(NodeRef result) throws Exception - { - assertHasVitalRecordDefinition(result, false, PERIOD_WEEK); - } - }); - } - - /** Filling tests */ - - public void testFileNewContent() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public NodeRef run() - { - NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef(); - - ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent("hello world this is some test content"); - - return record; - } - - @Override - public void test(NodeRef record) throws Exception - { - assertVitalRecord(record, true, PERIOD_WEEK); - } - }); - } - -// public void testFileUnfiledrecord() throws Exception -// { -// doTestInTransaction(new Test() -// { -// @Override -// public NodeRef run() throws Exception -// { -// recordService.createRecord(filePlan, dmDocument); -// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); -// -// return dmDocument; -// } -// -// @Override -// public void test(NodeRef record) throws Exception -// { -// assertVitalRecord(record, true, PERIOD_WEEK); -// } -// }); -// } -// -// public void testFileDirectlyFromCollab() throws Exception -// { -// doTestInTransaction(new Test() -// { -// @Override -// public NodeRef run() throws Exception -// { -// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); -// return dmDocument; -// } -// -// @Override -// public void test(NodeRef record) throws Exception -// { -// assertVitalRecord(record, true, PERIOD_WEEK); -// } -// }); -// } - - /** Helper Methods */ - - /** - * Test to ensure that changes made to vital record definitions are reflected down the hierarchy. - */ - public void testChangesToVitalRecordDefinitions() throws Exception - { - // Override vital record definition - doTestInTransaction(new Test() - { - @Override - public Void run() - { - setupVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH); - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertHasVitalRecordDefinition(mhContainer, false, null); - assertHasVitalRecordDefinition(mhContainer11, false, null); - assertHasVitalRecordDefinition(mhContainer12, false, null); - assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer22, false, null); - assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - - assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhRecordFolder42, false, null); - assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - - assertVitalRecord(mhRecord51, true, PERIOD_MONTH); - assertVitalRecord(mhRecord52, false, null); - assertVitalRecord(mhRecord53, true, PERIOD_WEEK); - assertVitalRecord(mhRecord54, true, PERIOD_WEEK); - assertVitalRecord(mhRecord55, true, PERIOD_MONTH); - } - }); - - // 'turn off' vital record def - doTestInTransaction(new Test() - { - @Override - public Void run() - { - setupVitalRecordDefinition(mhContainer31, false, PERIOD_NONE); - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertHasVitalRecordDefinition(mhContainer, false, null); - assertHasVitalRecordDefinition(mhContainer11, false, null); - assertHasVitalRecordDefinition(mhContainer12, false, null); - assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer22, false, null); - assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer31, false, null); - assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - - assertHasVitalRecordDefinition(mhRecordFolder41, false, null); - assertHasVitalRecordDefinition(mhRecordFolder42, false, null); - assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - - assertVitalRecord(mhRecord51, false, null); - assertVitalRecord(mhRecord52, false, null); - assertVitalRecord(mhRecord53, true, PERIOD_WEEK); - assertVitalRecord(mhRecord54, true, PERIOD_WEEK); - assertVitalRecord(mhRecord55, true, PERIOD_MONTH); - } - }); - - // Test parent change overrites existing - doTestInTransaction(new Test() - { - @Override - public Void run() - { - setupVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); - return null; - } - - @Override - public void test(Void result) throws Exception - { - assertHasVitalRecordDefinition(mhContainer, false, null); - assertHasVitalRecordDefinition(mhContainer11, false, null); - assertHasVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); - assertHasVitalRecordDefinition(mhContainer22, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer31, false, null); - assertHasVitalRecordDefinition(mhContainer32, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - - assertHasVitalRecordDefinition(mhRecordFolder41, false, null); - assertHasVitalRecordDefinition(mhRecordFolder42, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_MONTH); - assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - - assertVitalRecord(mhRecord51, false, null); - assertVitalRecord(mhRecord52, true, PERIOD_MONTH); - assertVitalRecord(mhRecord53, true, PERIOD_MONTH); - assertVitalRecord(mhRecord54, true, PERIOD_MONTH); - assertVitalRecord(mhRecord55, true, PERIOD_MONTH); - } - }); - - } - - @SuppressWarnings("deprecation") - private void assertHasVitalRecordDefinition(NodeRef nodeRef, boolean enabled, Period period) - { - assertTrue(nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION)); - - VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef); - assertNotNull(def); - - Boolean vitalRecordIndicator = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); - assertNotNull(vitalRecordIndicator); - assertEquals(enabled, vitalRecordIndicator.booleanValue()); - assertEquals(enabled, def.isEnabled()); - - if (enabled) - { - Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); - assertNotNull(reviewPeriod); - assertEquals(period, reviewPeriod); - assertEquals(period, def.getReviewPeriod()); - assertEquals(period.getNextDate(new Date()).getDate(), def.getNextReviewDate().getDate()); - } - } - - @SuppressWarnings("deprecation") - private void assertVitalRecord(NodeRef nodeRef, boolean enabled, Period period) - { - assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)); - if (enabled) - { - Date reviewAsOf = (Date)nodeService.getProperty(nodeRef, PROP_REVIEW_AS_OF); - assertNotNull(reviewAsOf); - assertEquals(period.getNextDate(new Date()).getDate(), reviewAsOf.getDate()); - - assertEquals(period.getPeriodType(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD)); - assertEquals(period.getExpression(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)); - } - else - { - assertNull(nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD)); - assertNull(nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.service; + +import java.util.Date; + +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.util.GUID; + +/** + * Vital record service implementation unit test. + * + * @author Roy Wetherall + */ +public class VitalRecordServiceImplTest extends BaseRMTestCase +{ + /** Test periods */ + protected static final Period PERIOD_NONE = new Period("none|0"); + protected static final Period PERIOD_WEEK = new Period("week|1"); + protected static final Period PERIOD_MONTH = new Period("month|1"); + + /** Test records */ + private NodeRef mhRecord51; + private NodeRef mhRecord52; + private NodeRef mhRecord53; + private NodeRef mhRecord54; + private NodeRef mhRecord55; + + /** + * Indicate this test uses the collaboration site test data + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** Indicate this is a multi hierarchy test */ + @Override + protected boolean isMultiHierarchyTest() + { + return true; + } + + /** vital record multi-hierarchy test data + * + * |--rmRootContainer (no vr def) + * | + * |--mhContainer (no vr def) + * | + * |--mhContainer-1-1 (has schedule - folder level) (no vr def) + * | | + * | |--mhContainer-2-1 (vr def) + * | | + * | |--mhContainer-3-1 (no vr def) + * | + * |--mhContainer-1-2 (has schedule - folder level) (no vr def) + * | + * |--mhContainer-2-2 (no vr def) + * | | + * | |--mhContainer-3-2 (vr def disabled) + * | | + * | |--mhContainer-3-3 (has schedule - record level) (vr def) + * | + * |--mhContainer-2-3 (has schedule - folder level) (vr def) + * | + * |--mhContainer-3-4 (no vr def) + * | + * |--mhContainer-3-5 (has schedule- record level) (vr def) + */ + @Override + protected void setupMultiHierarchyTestData() + { + // Load core test data + super.setupMultiHierarchyTestData(); + + // Setup vital record definitions + setupVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); + setupVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); + setupVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); + setupVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); + setupVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); + + // Create records + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + mhRecord51 = utils.createRecord(mhRecordFolder41, "record51.txt"); + mhRecord52 = utils.createRecord(mhRecordFolder42, "record52.txt"); + mhRecord53 = utils.createRecord(mhRecordFolder43, "record53.txt"); + mhRecord54 = utils.createRecord(mhRecordFolder44, "record54.txt"); + mhRecord55 = utils.createRecord(mhRecordFolder45, "record55.txt"); + + return null; + } + }); + } + + /** + * Helper to set up the vital record definition data in a transactional manner. + * + * @param nodeRef + * @param enabled + * @param period + */ + private void setupVitalRecordDefinition(final NodeRef nodeRef, final boolean enabled, final Period period) + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + vitalRecordService.setVitalRecordDefintion(nodeRef, enabled, period); + return null; + } + }); + } + + /** + * Based on the initial data: + * - check category, folder and record raw values. + * - check search aspect values. + */ + public void testInit() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertHasVitalRecordDefinition(mhContainer, false, null); + assertHasVitalRecordDefinition(mhContainer11, false, null); + assertHasVitalRecordDefinition(mhContainer12, false, null); + assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer22, false, null); + assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer31, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); + + assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder42, false, null); + assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); + + assertVitalRecord(mhRecord51, true, PERIOD_WEEK); + assertVitalRecord(mhRecord52, false, null); + assertVitalRecord(mhRecord53, true, PERIOD_WEEK); + assertVitalRecord(mhRecord54, true, PERIOD_WEEK); + assertVitalRecord(mhRecord55, true, PERIOD_MONTH); + + return null; + } + }); + } + + /** + * Test that when new record categories and record folders are created in an existing file plan + * structure that they correctly inherit the correct vital record property values + */ + public void testValueInheritance() throws Exception + { + // Test record category value inheritance + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + return filePlanService.createRecordCategory(mhContainer35, GUID.generate()); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertHasVitalRecordDefinition(result, true, PERIOD_MONTH); + } + }); + + // Test record folder value inheritance + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + return recordFolderService.createRecordFolder(mhContainer32, GUID.generate()); + } + + @Override + public void test(NodeRef result) throws Exception + { + assertHasVitalRecordDefinition(result, false, PERIOD_WEEK); + } + }); + } + + /** Filling tests */ + + public void testFileNewContent() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef(); + + ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); + writer.setEncoding("UTF-8"); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent("hello world this is some test content"); + + return record; + } + + @Override + public void test(NodeRef record) throws Exception + { + assertVitalRecord(record, true, PERIOD_WEEK); + } + }); + } + +// public void testFileUnfiledrecord() throws Exception +// { +// doTestInTransaction(new Test() +// { +// @Override +// public NodeRef run() throws Exception +// { +// recordService.createRecord(filePlan, dmDocument); +// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); +// +// return dmDocument; +// } +// +// @Override +// public void test(NodeRef record) throws Exception +// { +// assertVitalRecord(record, true, PERIOD_WEEK); +// } +// }); +// } +// +// public void testFileDirectlyFromCollab() throws Exception +// { +// doTestInTransaction(new Test() +// { +// @Override +// public NodeRef run() throws Exception +// { +// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); +// return dmDocument; +// } +// +// @Override +// public void test(NodeRef record) throws Exception +// { +// assertVitalRecord(record, true, PERIOD_WEEK); +// } +// }); +// } + + /** Helper Methods */ + + /** + * Test to ensure that changes made to vital record definitions are reflected down the hierarchy. + */ + public void testChangesToVitalRecordDefinitions() throws Exception + { + // Override vital record definition + doTestInTransaction(new Test() + { + @Override + public Void run() + { + setupVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertHasVitalRecordDefinition(mhContainer, false, null); + assertHasVitalRecordDefinition(mhContainer11, false, null); + assertHasVitalRecordDefinition(mhContainer12, false, null); + assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer22, false, null); + assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); + + assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhRecordFolder42, false, null); + assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); + + assertVitalRecord(mhRecord51, true, PERIOD_MONTH); + assertVitalRecord(mhRecord52, false, null); + assertVitalRecord(mhRecord53, true, PERIOD_WEEK); + assertVitalRecord(mhRecord54, true, PERIOD_WEEK); + assertVitalRecord(mhRecord55, true, PERIOD_MONTH); + } + }); + + // 'turn off' vital record def + doTestInTransaction(new Test() + { + @Override + public Void run() + { + setupVitalRecordDefinition(mhContainer31, false, PERIOD_NONE); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertHasVitalRecordDefinition(mhContainer, false, null); + assertHasVitalRecordDefinition(mhContainer11, false, null); + assertHasVitalRecordDefinition(mhContainer12, false, null); + assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer22, false, null); + assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer31, false, null); + assertHasVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); + + assertHasVitalRecordDefinition(mhRecordFolder41, false, null); + assertHasVitalRecordDefinition(mhRecordFolder42, false, null); + assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); + + assertVitalRecord(mhRecord51, false, null); + assertVitalRecord(mhRecord52, false, null); + assertVitalRecord(mhRecord53, true, PERIOD_WEEK); + assertVitalRecord(mhRecord54, true, PERIOD_WEEK); + assertVitalRecord(mhRecord55, true, PERIOD_MONTH); + } + }); + + // Test parent change overrites existing + doTestInTransaction(new Test() + { + @Override + public Void run() + { + setupVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertHasVitalRecordDefinition(mhContainer, false, null); + assertHasVitalRecordDefinition(mhContainer11, false, null); + assertHasVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); + assertHasVitalRecordDefinition(mhContainer22, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer23, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer31, false, null); + assertHasVitalRecordDefinition(mhContainer32, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); + + assertHasVitalRecordDefinition(mhRecordFolder41, false, null); + assertHasVitalRecordDefinition(mhRecordFolder42, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_MONTH); + assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); + + assertVitalRecord(mhRecord51, false, null); + assertVitalRecord(mhRecord52, true, PERIOD_MONTH); + assertVitalRecord(mhRecord53, true, PERIOD_MONTH); + assertVitalRecord(mhRecord54, true, PERIOD_MONTH); + assertVitalRecord(mhRecord55, true, PERIOD_MONTH); + } + }); + + } + + @SuppressWarnings("deprecation") + private void assertHasVitalRecordDefinition(NodeRef nodeRef, boolean enabled, Period period) + { + assertTrue(nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION)); + + VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef); + assertNotNull(def); + + Boolean vitalRecordIndicator = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); + assertNotNull(vitalRecordIndicator); + assertEquals(enabled, vitalRecordIndicator.booleanValue()); + assertEquals(enabled, def.isEnabled()); + + if (enabled) + { + Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); + assertNotNull(reviewPeriod); + assertEquals(period, reviewPeriod); + assertEquals(period, def.getReviewPeriod()); + assertEquals(period.getNextDate(new Date()).getDate(), def.getNextReviewDate().getDate()); + } + } + + @SuppressWarnings("deprecation") + private void assertVitalRecord(NodeRef nodeRef, boolean enabled, Period period) + { + assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)); + if (enabled) + { + Date reviewAsOf = (Date)nodeService.getProperty(nodeRef, PROP_REVIEW_AS_OF); + assertNotNull(reviewAsOf); + assertEquals(period.getNextDate(new Date()).getDate(), reviewAsOf.getDate()); + + assertEquals(period.getPeriodType(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD)); + assertEquals(period.getExpression(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)); + } + else + { + assertNull(nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD)); + assertNull(nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ActionDefinitionsRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ActionDefinitionsRestApiTest.java index 90c27626b2..f69a1f4cd6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ActionDefinitionsRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ActionDefinitionsRestApiTest.java @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Tests for Action Definitions - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class ActionDefinitionsRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST APIs */ - private static final String RM_ACTIONDEFINITIONS_URL = "/api/rm/rm-actiondefinitions"; - - /** - * Test the REST API to retrieve the list of rm action definitions - * - * @throws IOException - * @throws JSONException - */ - public void testRmGetActionDefinitions() throws IOException, JSONException - { - // Send request - Response response = sendRequest(new GetRequest(RM_ACTIONDEFINITIONS_URL), Status.STATUS_OK); - - // Check the content from the response - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json and check the data - JSONObject contentAsJson = new JSONObject(contentAsString); - JSONArray data = contentAsJson.getJSONArray("data"); - assertNotNull(data); - - // Get a (sub)list of available dm action definitions - List dmActionDefinitions = getDmActionDefinitions(); - - // Get the list of rm action definitions from the response and check it - List rmActionDefinitions = new ArrayList(); - for (int i = 0; i < data.length(); i++) - { - String name = data.getJSONObject(i).getString("name"); - assertNotNull(name); - rmActionDefinitions.add(name); - assertFalse(dmActionDefinitions.contains(name)); - } - assertTrue(rmActionDefinitions.containsAll(getRmActionDefinitions())); - } - - /** - * Returns a (sub)list of rm action definitions - * - * @return A (sub)list of rm action definitions - */ - private List getRmActionDefinitions() - { - return Arrays.asList(new String[] - { - "reject", - "fileTo", - "declareRecord" - }); - } - - /** - * Returns a (sub)list of dm action definitions - * - * @return A (sub)list of dm action definitions - */ - private List getDmActionDefinitions() - { - return Arrays.asList(new String[] - { - "check-in", - "check-out", - "mail", - "move", - "transform" - }); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Tests for Action Definitions + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class ActionDefinitionsRestApiTest extends BaseRMWebScriptTestCase +{ + /** URL for the REST APIs */ + private static final String RM_ACTIONDEFINITIONS_URL = "/api/rm/rm-actiondefinitions"; + + /** + * Test the REST API to retrieve the list of rm action definitions + * + * @throws IOException + * @throws JSONException + */ + public void testRmGetActionDefinitions() throws IOException, JSONException + { + // Send request + Response response = sendRequest(new GetRequest(RM_ACTIONDEFINITIONS_URL), Status.STATUS_OK); + + // Check the content from the response + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json and check the data + JSONObject contentAsJson = new JSONObject(contentAsString); + JSONArray data = contentAsJson.getJSONArray("data"); + assertNotNull(data); + + // Get a (sub)list of available dm action definitions + List dmActionDefinitions = getDmActionDefinitions(); + + // Get the list of rm action definitions from the response and check it + List rmActionDefinitions = new ArrayList(); + for (int i = 0; i < data.length(); i++) + { + String name = data.getJSONObject(i).getString("name"); + assertNotNull(name); + rmActionDefinitions.add(name); + assertFalse(dmActionDefinitions.contains(name)); + } + assertTrue(rmActionDefinitions.containsAll(getRmActionDefinitions())); + } + + /** + * Returns a (sub)list of rm action definitions + * + * @return A (sub)list of rm action definitions + */ + private List getRmActionDefinitions() + { + return Arrays.asList(new String[] + { + "reject", + "fileTo", + "declareRecord" + }); + } + + /** + * Returns a (sub)list of dm action definitions + * + * @return A (sub)list of dm action definitions + */ + private List getDmActionDefinitions() + { + return Arrays.asList(new String[] + { + "check-in", + "check-out", + "mail", + "move", + "transform" + }); + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/AuditRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/AuditRestApiTest.java index d28c62d790..efda6023e5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/AuditRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/AuditRestApiTest.java @@ -1,72 +1,72 @@ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.text.MessageFormat; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; - - -public class AuditRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST APIs */ - protected static final String GET_NODE_AUDITLOG_URL_FORMAT = "/api/node/{0}/rmauditlog"; - - private static final String USER_WITHOUT_AUDIT_CAPABILITY = GUID.generate(); - - private NodeRef record; - - public void testAuditAccessCapability() throws IOException - { - - String recordAuditUrl = MessageFormat.format(GET_NODE_AUDITLOG_URL_FORMAT,record.toString().replace("://", "/")); - - sendRequest(new GetRequest(recordAuditUrl), Status.STATUS_OK, AuthenticationUtil.getAdminUserName() ); - - sendRequest(new GetRequest(recordAuditUrl), Status.STATUS_FORBIDDEN, USER_WITHOUT_AUDIT_CAPABILITY ); - } - - @Override - protected void setupTestData() - { - super.setupTestData(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil - .getSystemUserName()); - - createUser(USER_WITHOUT_AUDIT_CAPABILITY); - - record = utils.createRecord(recordFolder, GUID.generate()); - - - return null; - } - }); - } - - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - - deleteUser(USER_WITHOUT_AUDIT_CAPABILITY); - } - - protected String getRMSiteId() - { - return filePlanService.DEFAULT_RM_SITE_ID; - } - - -} +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.text.MessageFormat; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; + + +public class AuditRestApiTest extends BaseRMWebScriptTestCase +{ + /** URL for the REST APIs */ + protected static final String GET_NODE_AUDITLOG_URL_FORMAT = "/api/node/{0}/rmauditlog"; + + private static final String USER_WITHOUT_AUDIT_CAPABILITY = GUID.generate(); + + private NodeRef record; + + public void testAuditAccessCapability() throws IOException + { + + String recordAuditUrl = MessageFormat.format(GET_NODE_AUDITLOG_URL_FORMAT,record.toString().replace("://", "/")); + + sendRequest(new GetRequest(recordAuditUrl), Status.STATUS_OK, AuthenticationUtil.getAdminUserName() ); + + sendRequest(new GetRequest(recordAuditUrl), Status.STATUS_FORBIDDEN, USER_WITHOUT_AUDIT_CAPABILITY ); + } + + @Override + protected void setupTestData() + { + super.setupTestData(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil + .getSystemUserName()); + + createUser(USER_WITHOUT_AUDIT_CAPABILITY); + + record = utils.createRecord(recordFolder, GUID.generate()); + + + return null; + } + }); + } + + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + deleteUser(USER_WITHOUT_AUDIT_CAPABILITY); + } + + protected String getRMSiteId() + { + return filePlanService.DEFAULT_RM_SITE_ID; + } + + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/CapabilitiesRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/CapabilitiesRestApiTest.java index 99f2ac57bc..9e56a11f4c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/CapabilitiesRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/CapabilitiesRestApiTest.java @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.text.MessageFormat; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Test for Capabilities - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class CapabilitiesRestApiTest extends BaseRMWebScriptTestCase -{ - /** URLs for the REST API */ - private static final String GET_CAPABILITIES_URL = "/api/node/{0}/{1}/{2}/capabilities?"; - - /** - * Tests the REST API to get the list of capabilities - * - * @throws IOException - * @throws JSONException - */ - public void testGetCapabilitiesAction() throws IOException, JSONException - { - String baseURL = MessageFormat.format(GET_CAPABILITIES_URL, - filePlan.getStoreRef().getProtocol(), - filePlan.getStoreRef().getIdentifier(), - filePlan.getId()); - - // Format url and send request - String getUrl = String.format(baseURL + "includeAll=%s", true); - Response getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); - - // Check the content from the response - String getContentAsString = getResponse.getContentAsString(); - assertNotNull(getContentAsString); - - System.out.println(getContentAsString); - - // Convert the response to json and check the data - JSONObject getContentAsJson = new JSONObject(getContentAsString); - JSONObject getData = getContentAsJson.getJSONObject("data"); - assertNotNull(getData); - - // Get the capabilities and check them - JSONArray getDataSets = getData.getJSONArray("capabilities"); - assertNotNull(getDataSets); - - // Format url and send another request with different parameter - getUrl = String.format(baseURL + "grouped=%s", true); - getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); - - // Check the content from the response - getContentAsString = getResponse.getContentAsString(); - assertNotNull(getContentAsString); - - // If both parameters are specified the result should be the same with only specifying the "grouped" parameter - getUrl = String.format(baseURL + "includeAll=%s&grouped=%s", true, true); - getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); - getContentAsString.equalsIgnoreCase(getResponse.getContentAsString()); - - // Convert the response to json and check the data - getContentAsJson = new JSONObject(getContentAsString); - getData = getContentAsJson.getJSONObject("data"); - assertNotNull(getData); - - // Get the grouped capabilities and check them - getDataSets = getData.getJSONArray("groupedCapabilities"); - assertNotNull(getDataSets); - - // Check the JSON structure - int length = getDataSets.length(); - if (length > 0) - { - for (int i = 0; i < length; i++) - { - JSONObject jsonObject = getDataSets.getJSONObject(i); - String key = (String) jsonObject.keys().next(); - JSONObject value = jsonObject.getJSONObject(key); - assertNotNull(value.getString("groupTitle")); - assertNotNull(value.getJSONObject("capabilities")); - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.text.MessageFormat; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Test for Capabilities + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class CapabilitiesRestApiTest extends BaseRMWebScriptTestCase +{ + /** URLs for the REST API */ + private static final String GET_CAPABILITIES_URL = "/api/node/{0}/{1}/{2}/capabilities?"; + + /** + * Tests the REST API to get the list of capabilities + * + * @throws IOException + * @throws JSONException + */ + public void testGetCapabilitiesAction() throws IOException, JSONException + { + String baseURL = MessageFormat.format(GET_CAPABILITIES_URL, + filePlan.getStoreRef().getProtocol(), + filePlan.getStoreRef().getIdentifier(), + filePlan.getId()); + + // Format url and send request + String getUrl = String.format(baseURL + "includeAll=%s", true); + Response getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); + + // Check the content from the response + String getContentAsString = getResponse.getContentAsString(); + assertNotNull(getContentAsString); + + System.out.println(getContentAsString); + + // Convert the response to json and check the data + JSONObject getContentAsJson = new JSONObject(getContentAsString); + JSONObject getData = getContentAsJson.getJSONObject("data"); + assertNotNull(getData); + + // Get the capabilities and check them + JSONArray getDataSets = getData.getJSONArray("capabilities"); + assertNotNull(getDataSets); + + // Format url and send another request with different parameter + getUrl = String.format(baseURL + "grouped=%s", true); + getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); + + // Check the content from the response + getContentAsString = getResponse.getContentAsString(); + assertNotNull(getContentAsString); + + // If both parameters are specified the result should be the same with only specifying the "grouped" parameter + getUrl = String.format(baseURL + "includeAll=%s&grouped=%s", true, true); + getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); + getContentAsString.equalsIgnoreCase(getResponse.getContentAsString()); + + // Convert the response to json and check the data + getContentAsJson = new JSONObject(getContentAsString); + getData = getContentAsJson.getJSONObject("data"); + assertNotNull(getData); + + // Get the grouped capabilities and check them + getDataSets = getData.getJSONArray("groupedCapabilities"); + assertNotNull(getDataSets); + + // Check the JSON structure + int length = getDataSets.length(); + if (length > 0) + { + for (int i = 0; i < length; i++) + { + JSONObject jsonObject = getDataSets.getJSONObject(i); + String key = (String) jsonObject.keys().next(); + JSONObject value = jsonObject.getJSONObject(key); + assertNotNull(value.getString("groupTitle")); + assertNotNull(value.getJSONObject("capabilities")); + } + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DataSetRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DataSetRestApiTest.java index 2d9a8a29c6..5b28b08b02 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DataSetRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DataSetRestApiTest.java @@ -1,93 +1,93 @@ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -public class DataSetRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST APIs */ - private static final String GET_DATASETS_URL = "/api/rma/datasets?site=%s"; - //private static final String POST_DATASET_URL = "/api/rma/datasets/%s?site=%s"; - - /** Constant for the content type */ - //private static final String APPLICATION_JSON = "application/json"; - - /** - * Test the REST API to retrieve details of available RM data sets - * and to import an RM data set into a file plan - * - * @throws IOException - * @throws JSONException - */ - public void testGetPostDataSetAction() throws IOException, JSONException - { - /** Test GET */ - - // Format url and send request - String getUrl = String.format(GET_DATASETS_URL, siteId); - Response getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); - - // Check the content from the response - String getContentAsString = getResponse.getContentAsString(); - assertNotNull(getContentAsString); - - // Convert the response to json and check the data - JSONObject getContentAsJson = new JSONObject(getContentAsString); - JSONObject getData = getContentAsJson.getJSONObject("data"); - assertNotNull(getData); - - // Get the data sets and check them - JSONArray getDataSets = getData.getJSONArray("datasets"); - assertNotNull(getDataSets); - - // Check the label and the id of the data sets - for (int i = 0; i < getDataSets.length(); i++) - { - JSONObject dataSet = (JSONObject) getDataSets.get(i); - assertTrue(dataSet.length() == 3); - assertNotNull(dataSet.get("label")); - assertNotNull(dataSet.get("id")); - assertNotNull(dataSet.get("isLoaded")); - } - - /** Test POST */ -// String dataSetId = getDataSets.getJSONObject(0).getString("id"); -// if (StringUtils.isNotBlank(dataSetId)) -// { -// // Format url and send request -// String url = String.format(POST_DATASET_URL, dataSetId, SITE_ID); -// Response response = sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); -// -// // Check the content from the response -// String contentAsString = response.getContentAsString(); -// assertNotNull(contentAsString); -// -// // Convert the response to json and check the result -// JSONObject contentAsJson = new JSONObject(contentAsString); -// String success = contentAsJson.getString("success"); -// assertNotNull(success); -// assertTrue(success.equals("true")); -// -// // It is not possible to import the same data set into the same file plan -// response = sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); -// -// // Check the content from the response -// contentAsString = response.getContentAsString(); -// assertNotNull(contentAsString); -// -// // Convert the response to json and check the result -// contentAsJson = new JSONObject(contentAsString); -// success = contentAsJson.getString("success"); -// assertNotNull(success); -// assertTrue(success.equals("false")); -// assertNotNull(contentAsJson.getString("message")); -// } - } +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +public class DataSetRestApiTest extends BaseRMWebScriptTestCase +{ + /** URL for the REST APIs */ + private static final String GET_DATASETS_URL = "/api/rma/datasets?site=%s"; + //private static final String POST_DATASET_URL = "/api/rma/datasets/%s?site=%s"; + + /** Constant for the content type */ + //private static final String APPLICATION_JSON = "application/json"; + + /** + * Test the REST API to retrieve details of available RM data sets + * and to import an RM data set into a file plan + * + * @throws IOException + * @throws JSONException + */ + public void testGetPostDataSetAction() throws IOException, JSONException + { + /** Test GET */ + + // Format url and send request + String getUrl = String.format(GET_DATASETS_URL, siteId); + Response getResponse = sendRequest(new GetRequest(getUrl), Status.STATUS_OK); + + // Check the content from the response + String getContentAsString = getResponse.getContentAsString(); + assertNotNull(getContentAsString); + + // Convert the response to json and check the data + JSONObject getContentAsJson = new JSONObject(getContentAsString); + JSONObject getData = getContentAsJson.getJSONObject("data"); + assertNotNull(getData); + + // Get the data sets and check them + JSONArray getDataSets = getData.getJSONArray("datasets"); + assertNotNull(getDataSets); + + // Check the label and the id of the data sets + for (int i = 0; i < getDataSets.length(); i++) + { + JSONObject dataSet = (JSONObject) getDataSets.get(i); + assertTrue(dataSet.length() == 3); + assertNotNull(dataSet.get("label")); + assertNotNull(dataSet.get("id")); + assertNotNull(dataSet.get("isLoaded")); + } + + /** Test POST */ +// String dataSetId = getDataSets.getJSONObject(0).getString("id"); +// if (StringUtils.isNotBlank(dataSetId)) +// { +// // Format url and send request +// String url = String.format(POST_DATASET_URL, dataSetId, SITE_ID); +// Response response = sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); +// +// // Check the content from the response +// String contentAsString = response.getContentAsString(); +// assertNotNull(contentAsString); +// +// // Convert the response to json and check the result +// JSONObject contentAsJson = new JSONObject(contentAsString); +// String success = contentAsJson.getString("success"); +// assertNotNull(success); +// assertTrue(success.equals("true")); +// +// // It is not possible to import the same data set into the same file plan +// response = sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); +// +// // Check the content from the response +// contentAsString = response.getContentAsString(); +// assertNotNull(contentAsString); +// +// // Convert the response to json and check the result +// contentAsJson = new JSONObject(contentAsString); +// success = contentAsJson.getString("success"); +// assertNotNull(success); +// assertTrue(success.equals("false")); +// assertNotNull(contentAsJson.getString("message")); +// } + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DispositionRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DispositionRestApiTest.java index 4667247f39..28c590db0e 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DispositionRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/DispositionRestApiTest.java @@ -1,438 +1,438 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.text.MessageFormat; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.util.GUID; -import org.json.JSONArray; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * This class tests the Rest API for disposition related operations - * - * @author Gavin Cornwell - */ -public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel -{ - protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - protected static final String GET_SCHEDULE_URL_FORMAT = "/api/node/{0}/dispositionschedule"; - protected static final String GET_LIFECYCLE_URL_FORMAT = "/api/node/{0}/nextdispositionaction"; - protected static final String POST_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions"; - protected static final String DELETE_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions/{1}"; - protected static final String PUT_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions/{1}"; - protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues"; - protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; - protected static final String APPLICATION_JSON = "application/json"; - - - public void testGetDispositionSchedule() throws Exception - { - // Test 404 status for non existent node - int expectedStatus = 404; - String nonExistentNode = "workspace/SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"; - String nonExistentUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, nonExistentNode); - Response rsp = sendRequest(new GetRequest(nonExistentUrl), expectedStatus); - - // Test 404 status for node that doesn't have dispostion schedule i.e. a record series - String seriesNodeUrl = recordSeries.toString().replace("://", "/"); - String wrongNodeUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, seriesNodeUrl); - rsp = sendRequest(new GetRequest(wrongNodeUrl), expectedStatus); - - // Test data structure returned from "AIS Audit Records" - expectedStatus = 200; - - String categoryNodeUrl = recordCategory.toString().replace("://", "/"); - String requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); - rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); - assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - - // get response as JSON - JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertNotNull(jsonParsedObject); - - // check JSON data - JSONObject dataObj = jsonParsedObject.getJSONObject("data"); - assertNotNull(dataObj); - JSONObject rootDataObject = (JSONObject)dataObj; - assertEquals(10, rootDataObject.length()); - - // check individual data items - String serviceUrl = SERVICE_URL_PREFIX + requestUrl; - String url = rootDataObject.getString("url"); - assertEquals(serviceUrl, url); - - String authority = rootDataObject.getString("authority"); - - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, authority); - - String instructions = rootDataObject.getString("instructions"); - assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, instructions); - - String actionsUrl = rootDataObject.getString("actionsUrl"); - assertEquals(serviceUrl + "/dispositionactiondefinitions", actionsUrl); - - boolean recordLevel = rootDataObject.getBoolean("recordLevelDisposition"); - assertFalse(recordLevel); - - assertFalse(rootDataObject.getBoolean("canStepsBeRemoved")); - - JSONArray actions = rootDataObject.getJSONArray("actions"); - assertNotNull(actions); - assertEquals(2, actions.length()); - JSONObject action1 = (JSONObject)actions.get(0); - assertEquals(9, action1.length()); - assertNotNull(action1.get("id")); - assertNotNull(action1.get("url")); - assertEquals(0, action1.getInt("index")); - assertEquals("cutoff", action1.getString("name")); - assertTrue(action1.getBoolean("eligibleOnFirstCompleteEvent")); - - JSONObject action2 = (JSONObject)actions.get(1); - assertEquals(8, action2.length()); - - // make sure the disposition schedule node ref is present and valid - String scheduleNodeRefJSON = rootDataObject.getString("nodeRef"); - NodeRef scheduleNodeRef = new NodeRef(scheduleNodeRefJSON); - assertTrue(this.nodeService.exists(scheduleNodeRef)); - - // create a new recordCategory node in the recordSeries and then get - // the disposition schedule - NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); - dispositionService.createDispositionSchedule(newRecordCategory, null); - - categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); - requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); - //System.out.println("GET response: " + rsp.getContentAsString()); - rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); - - // get response as JSON - jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); - System.out.println(rsp.getContentAsString()); - assertNotNull(jsonParsedObject); - - // check JSON data - dataObj = jsonParsedObject.getJSONObject("data"); - assertNotNull(dataObj); - rootDataObject = (JSONObject)dataObj; - assertEquals(8, rootDataObject.length()); - actions = rootDataObject.getJSONArray("actions"); - assertNotNull(actions); - assertEquals(0, actions.length()); - } - - public void testPostDispositionAction() throws Exception - { - // create a new recordCategory node in the recordSeries and then get - // the disposition schedule - NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); - dispositionService.createDispositionSchedule(newRecordCategory, null); - - String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); - String requestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); - - // Construct the JSON request. - String name = "destroy"; - String desc = "Destroy this record after 5 years"; - String period = "year|5"; - String periodProperty = "rma:cutOffDate"; - boolean eligibleOnFirstCompleteEvent = true; - - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("name", name); - jsonPostData.put("description", desc); - jsonPostData.put("period", period); - jsonPostData.put("location", "my location"); - jsonPostData.put("periodProperty", periodProperty); - jsonPostData.put("eligibleOnFirstCompleteEvent", eligibleOnFirstCompleteEvent); - JSONArray events = new JSONArray(); - events.put("superseded"); - events.put("no_longer_needed"); - jsonPostData.put("events", events); - - // Submit the JSON request. - String jsonPostString = jsonPostData.toString(); - Response rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); - - // check the returned data is what was expected - JSONObject jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); - JSONObject dataObj = jsonResponse.getJSONObject("data"); - JSONObject rootDataObject = (JSONObject)dataObj; - assertNotNull(rootDataObject.getString("id")); - assertNotNull(rootDataObject.getString("url")); - assertEquals(0, rootDataObject.getInt("index")); - assertEquals(name, rootDataObject.getString("name")); - assertEquals("Destroy", rootDataObject.getString("label")); - assertEquals(desc, rootDataObject.getString("description")); - assertEquals(period, rootDataObject.getString("period")); - assertEquals("my location", rootDataObject.getString("location")); - assertEquals(periodProperty, rootDataObject.getString("periodProperty")); - assertTrue(rootDataObject.getBoolean("eligibleOnFirstCompleteEvent")); - events = rootDataObject.getJSONArray("events"); - assertNotNull(events); - assertEquals(2, events.length()); - assertEquals("superseded", events.get(0)); - assertEquals("no_longer_needed", events.get(1)); - - // test the minimum amount of data required to create an action definition - jsonPostData = new JSONObject(); - jsonPostData.put("name", name); - jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); - - // check the returned data is what was expected - jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); - dataObj = jsonResponse.getJSONObject("data"); - assertNotNull(rootDataObject.getString("id")); - assertNotNull(rootDataObject.getString("url")); - assertEquals(0, rootDataObject.getInt("index")); - assertEquals(name, dataObj.getString("name")); - assertEquals("none|0", dataObj.getString("period")); - assertFalse(dataObj.has("description")); - assertFalse(dataObj.has("periodProperty")); - assertFalse(dataObj.has("events")); - assertTrue(dataObj.getBoolean("eligibleOnFirstCompleteEvent")); - - // negative test to ensure not supplying mandatory data results in an error - jsonPostData = new JSONObject(); - jsonPostData.put("description", desc); - jsonPostData.put("period", period); - jsonPostString = jsonPostData.toString(); - sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 400); - } - - public void testPutDispositionAction() throws Exception - { - NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); - dispositionService.createDispositionSchedule(newRecordCategory, null); - - // create an action definition to then update - String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); - String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("name", "cutoff"); - String jsonPostString = jsonPostData.toString(); - sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); - - // verify the action definition is present and retrieve it's id - String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); - Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); - JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString())); - JSONObject actionDef = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0); - String actionDefId = actionDef.getString("id"); - assertEquals("cutoff", actionDef.getString("name")); - assertEquals("none|0", actionDef.getString("period")); - assertFalse(actionDef.has("description")); - assertFalse(actionDef.has("events")); - - // define body for PUT request - String name = "destroy"; - String desc = "Destroy this record after 5 years"; - String period = "year|5"; - String location = "my location"; - String periodProperty = "rma:cutOffDate"; - boolean eligibleOnFirstCompleteEvent = false; - - jsonPostData = new JSONObject(); - jsonPostData.put("name", name); - jsonPostData.put("description", desc); - jsonPostData.put("period", period); - jsonPostData.put("location", location); - jsonPostData.put("periodProperty", periodProperty); - jsonPostData.put("eligibleOnFirstCompleteEvent", eligibleOnFirstCompleteEvent); - JSONArray events = new JSONArray(); - events.put("superseded"); - events.put("no_longer_needed"); - jsonPostData.put("events", events); - jsonPostString = jsonPostData.toString(); - - // try and update a non existent action definition to check for 404 - String putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); - rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 404); - - // update the action definition - putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); - rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 200); - - // check the update happened correctly - json = new JSONObject(new JSONTokener(rsp.getContentAsString())); - actionDef = json.getJSONObject("data"); - assertEquals(name, actionDef.getString("name")); - assertEquals("Destroy", actionDef.getString("label")); - assertEquals(desc, actionDef.getString("description")); - assertEquals(period, actionDef.getString("period")); - assertEquals(location, actionDef.getString("location")); - assertEquals(periodProperty, actionDef.getString("periodProperty")); - assertFalse(actionDef.getBoolean("eligibleOnFirstCompleteEvent")); - assertEquals(2, actionDef.getJSONArray("events").length()); - assertEquals("superseded", actionDef.getJSONArray("events").getString(0)); - assertEquals("no_longer_needed", actionDef.getJSONArray("events").getString(1)); - } - - public void testDeleteDispositionAction() throws Exception - { - NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); - dispositionService.createDispositionSchedule(newRecordCategory, null); - - // create an action definition to then delete - String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); - String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("name", "cutoff"); - String jsonPostString = jsonPostData.toString(); - sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); - - // verify the action definition is present and retrieve it's id - String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); - Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); - JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString())); - String actionDefId = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0).getString("id"); - - // try and delete a non existent action definition to check for 404 - String deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); - rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 404); - - // now delete the action defintion created above - deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); - rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 200); - - // verify it got deleted - getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); - rsp = sendRequest(new GetRequest(getRequestUrl), 200); - json = new JSONObject(new JSONTokener(rsp.getContentAsString())); - JSONArray actions = json.getJSONObject("data").getJSONArray("actions"); - assertEquals(0, actions.length()); - } - - public void testGetDispositionLifecycle() throws Exception - { - // Test 404 for disposition lifecycle request on incorrect node - String categoryUrl = recordCategory.toString().replace("://", "/"); - String requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, categoryUrl); - Response rsp = sendRequest(new GetRequest(requestUrl), 200); - - JSONObject notFound = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertEquals(true, notFound.getJSONObject("data").getBoolean("notFound")); - - NodeRef newRecordFolder = recordFolderService.createRecordFolder(recordCategory, "recordFolder"); - - - // there should now be a disposition lifecycle for the record - requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, newRecordFolder.toString().replace("://", "/")); - rsp = sendRequest(new GetRequest(requestUrl), 200); - System.out.println("GET : " + rsp.getContentAsString()); - assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - - // get response as JSON - JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertNotNull(jsonParsedObject); - - // check mandatory stuff is present - JSONObject dataObj = jsonParsedObject.getJSONObject("data"); - assertEquals(SERVICE_URL_PREFIX + requestUrl, dataObj.getString("url")); - assertEquals("cutoff", dataObj.getString("name")); - assertFalse(dataObj.getBoolean("eventsEligible")); - assertTrue(dataObj.has("events")); - JSONArray events = dataObj.getJSONArray("events"); - assertEquals(1, events.length()); - JSONObject event1 = events.getJSONObject(0); - assertEquals("case_closed", event1.get("name")); - assertEquals("Case Closed", event1.get("label")); - assertFalse(event1.getBoolean("complete")); - assertFalse(event1.getBoolean("automatic")); - - // check stuff expected to be missing is missing - assertFalse(dataObj.has("asOf")); - assertFalse(dataObj.has("startedAt")); - assertFalse(dataObj.has("startedBy")); - assertFalse(dataObj.has("completedAt")); - assertFalse(dataObj.has("completedBy")); - assertFalse(event1.has("completedAt")); - assertFalse(event1.has("completedBy")); - } - - public void testGetListOfValues() throws Exception - { - // call the list service - Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); - assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - - // get response as JSON - JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertNotNull(jsonParsedObject); - JSONObject data = jsonParsedObject.getJSONObject("data"); - - // check dispostion actions - JSONObject actions = data.getJSONObject("dispositionActions"); - assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/dispositionactions", actions.getString("url")); - JSONArray items = actions.getJSONArray("items"); - assertEquals(actionService.getDispositionActions().size(), items.length()); - assertTrue(items.length() > 0); - JSONObject item = items.getJSONObject(0); - assertTrue(item.length() == 2); - assertTrue(item.has("label")); - assertTrue(item.has("value")); - - // check events - JSONObject events = data.getJSONObject("events"); - assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/events", events.getString("url")); - items = events.getJSONArray("items"); - assertEquals(eventService.getEvents().size(), items.length()); - assertTrue(items.length() > 0); - item = items.getJSONObject(0); - assertTrue(item.length() == 3); - assertTrue(item.has("label")); - assertTrue(item.has("value")); - assertTrue(item.has("automatic")); - - // check period types - JSONObject periodTypes = data.getJSONObject("periodTypes"); - assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodtypes", periodTypes.getString("url")); - items = periodTypes.getJSONArray("items"); - assertEquals(Period.getProviderNames().size()-1, items.length()); - assertTrue(items.length() > 0); - item = items.getJSONObject(0); - assertTrue(item.length() == 2); - assertTrue(item.has("label")); - assertTrue(item.has("value")); - - // check period properties - JSONObject periodProperties = data.getJSONObject("periodProperties"); - assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodproperties", periodProperties.getString("url")); - items = periodProperties.getJSONArray("items"); - assertEquals(5, items.length()); - assertTrue(items.length() > 0); - item = items.getJSONObject(0); - assertTrue(item.length() == 2); - assertTrue(item.has("label")); - assertTrue(item.has("value")); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.text.MessageFormat; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.util.GUID; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * This class tests the Rest API for disposition related operations + * + * @author Gavin Cornwell + */ +public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel +{ + protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); + protected static final String GET_SCHEDULE_URL_FORMAT = "/api/node/{0}/dispositionschedule"; + protected static final String GET_LIFECYCLE_URL_FORMAT = "/api/node/{0}/nextdispositionaction"; + protected static final String POST_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions"; + protected static final String DELETE_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions/{1}"; + protected static final String PUT_ACTIONDEF_URL_FORMAT = "/api/node/{0}/dispositionschedule/dispositionactiondefinitions/{1}"; + protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues"; + protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; + protected static final String APPLICATION_JSON = "application/json"; + + + public void testGetDispositionSchedule() throws Exception + { + // Test 404 status for non existent node + int expectedStatus = 404; + String nonExistentNode = "workspace/SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"; + String nonExistentUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, nonExistentNode); + Response rsp = sendRequest(new GetRequest(nonExistentUrl), expectedStatus); + + // Test 404 status for node that doesn't have dispostion schedule i.e. a record series + String seriesNodeUrl = recordSeries.toString().replace("://", "/"); + String wrongNodeUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, seriesNodeUrl); + rsp = sendRequest(new GetRequest(wrongNodeUrl), expectedStatus); + + // Test data structure returned from "AIS Audit Records" + expectedStatus = 200; + + String categoryNodeUrl = recordCategory.toString().replace("://", "/"); + String requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); + rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); + assertEquals("application/json;charset=UTF-8", rsp.getContentType()); + + // get response as JSON + JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertNotNull(jsonParsedObject); + + // check JSON data + JSONObject dataObj = jsonParsedObject.getJSONObject("data"); + assertNotNull(dataObj); + JSONObject rootDataObject = (JSONObject)dataObj; + assertEquals(10, rootDataObject.length()); + + // check individual data items + String serviceUrl = SERVICE_URL_PREFIX + requestUrl; + String url = rootDataObject.getString("url"); + assertEquals(serviceUrl, url); + + String authority = rootDataObject.getString("authority"); + + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, authority); + + String instructions = rootDataObject.getString("instructions"); + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, instructions); + + String actionsUrl = rootDataObject.getString("actionsUrl"); + assertEquals(serviceUrl + "/dispositionactiondefinitions", actionsUrl); + + boolean recordLevel = rootDataObject.getBoolean("recordLevelDisposition"); + assertFalse(recordLevel); + + assertFalse(rootDataObject.getBoolean("canStepsBeRemoved")); + + JSONArray actions = rootDataObject.getJSONArray("actions"); + assertNotNull(actions); + assertEquals(2, actions.length()); + JSONObject action1 = (JSONObject)actions.get(0); + assertEquals(9, action1.length()); + assertNotNull(action1.get("id")); + assertNotNull(action1.get("url")); + assertEquals(0, action1.getInt("index")); + assertEquals("cutoff", action1.getString("name")); + assertTrue(action1.getBoolean("eligibleOnFirstCompleteEvent")); + + JSONObject action2 = (JSONObject)actions.get(1); + assertEquals(8, action2.length()); + + // make sure the disposition schedule node ref is present and valid + String scheduleNodeRefJSON = rootDataObject.getString("nodeRef"); + NodeRef scheduleNodeRef = new NodeRef(scheduleNodeRefJSON); + assertTrue(this.nodeService.exists(scheduleNodeRef)); + + // create a new recordCategory node in the recordSeries and then get + // the disposition schedule + NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); + dispositionService.createDispositionSchedule(newRecordCategory, null); + + categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); + requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); + //System.out.println("GET response: " + rsp.getContentAsString()); + rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); + + // get response as JSON + jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); + System.out.println(rsp.getContentAsString()); + assertNotNull(jsonParsedObject); + + // check JSON data + dataObj = jsonParsedObject.getJSONObject("data"); + assertNotNull(dataObj); + rootDataObject = (JSONObject)dataObj; + assertEquals(8, rootDataObject.length()); + actions = rootDataObject.getJSONArray("actions"); + assertNotNull(actions); + assertEquals(0, actions.length()); + } + + public void testPostDispositionAction() throws Exception + { + // create a new recordCategory node in the recordSeries and then get + // the disposition schedule + NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); + dispositionService.createDispositionSchedule(newRecordCategory, null); + + String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); + String requestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); + + // Construct the JSON request. + String name = "destroy"; + String desc = "Destroy this record after 5 years"; + String period = "year|5"; + String periodProperty = "rma:cutOffDate"; + boolean eligibleOnFirstCompleteEvent = true; + + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("name", name); + jsonPostData.put("description", desc); + jsonPostData.put("period", period); + jsonPostData.put("location", "my location"); + jsonPostData.put("periodProperty", periodProperty); + jsonPostData.put("eligibleOnFirstCompleteEvent", eligibleOnFirstCompleteEvent); + JSONArray events = new JSONArray(); + events.put("superseded"); + events.put("no_longer_needed"); + jsonPostData.put("events", events); + + // Submit the JSON request. + String jsonPostString = jsonPostData.toString(); + Response rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); + + // check the returned data is what was expected + JSONObject jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); + JSONObject dataObj = jsonResponse.getJSONObject("data"); + JSONObject rootDataObject = (JSONObject)dataObj; + assertNotNull(rootDataObject.getString("id")); + assertNotNull(rootDataObject.getString("url")); + assertEquals(0, rootDataObject.getInt("index")); + assertEquals(name, rootDataObject.getString("name")); + assertEquals("Destroy", rootDataObject.getString("label")); + assertEquals(desc, rootDataObject.getString("description")); + assertEquals(period, rootDataObject.getString("period")); + assertEquals("my location", rootDataObject.getString("location")); + assertEquals(periodProperty, rootDataObject.getString("periodProperty")); + assertTrue(rootDataObject.getBoolean("eligibleOnFirstCompleteEvent")); + events = rootDataObject.getJSONArray("events"); + assertNotNull(events); + assertEquals(2, events.length()); + assertEquals("superseded", events.get(0)); + assertEquals("no_longer_needed", events.get(1)); + + // test the minimum amount of data required to create an action definition + jsonPostData = new JSONObject(); + jsonPostData.put("name", name); + jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); + + // check the returned data is what was expected + jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); + dataObj = jsonResponse.getJSONObject("data"); + assertNotNull(rootDataObject.getString("id")); + assertNotNull(rootDataObject.getString("url")); + assertEquals(0, rootDataObject.getInt("index")); + assertEquals(name, dataObj.getString("name")); + assertEquals("none|0", dataObj.getString("period")); + assertFalse(dataObj.has("description")); + assertFalse(dataObj.has("periodProperty")); + assertFalse(dataObj.has("events")); + assertTrue(dataObj.getBoolean("eligibleOnFirstCompleteEvent")); + + // negative test to ensure not supplying mandatory data results in an error + jsonPostData = new JSONObject(); + jsonPostData.put("description", desc); + jsonPostData.put("period", period); + jsonPostString = jsonPostData.toString(); + sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 400); + } + + public void testPutDispositionAction() throws Exception + { + NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); + dispositionService.createDispositionSchedule(newRecordCategory, null); + + // create an action definition to then update + String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); + String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("name", "cutoff"); + String jsonPostString = jsonPostData.toString(); + sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); + + // verify the action definition is present and retrieve it's id + String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); + Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); + JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString())); + JSONObject actionDef = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0); + String actionDefId = actionDef.getString("id"); + assertEquals("cutoff", actionDef.getString("name")); + assertEquals("none|0", actionDef.getString("period")); + assertFalse(actionDef.has("description")); + assertFalse(actionDef.has("events")); + + // define body for PUT request + String name = "destroy"; + String desc = "Destroy this record after 5 years"; + String period = "year|5"; + String location = "my location"; + String periodProperty = "rma:cutOffDate"; + boolean eligibleOnFirstCompleteEvent = false; + + jsonPostData = new JSONObject(); + jsonPostData.put("name", name); + jsonPostData.put("description", desc); + jsonPostData.put("period", period); + jsonPostData.put("location", location); + jsonPostData.put("periodProperty", periodProperty); + jsonPostData.put("eligibleOnFirstCompleteEvent", eligibleOnFirstCompleteEvent); + JSONArray events = new JSONArray(); + events.put("superseded"); + events.put("no_longer_needed"); + jsonPostData.put("events", events); + jsonPostString = jsonPostData.toString(); + + // try and update a non existent action definition to check for 404 + String putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); + rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 404); + + // update the action definition + putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); + rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 200); + + // check the update happened correctly + json = new JSONObject(new JSONTokener(rsp.getContentAsString())); + actionDef = json.getJSONObject("data"); + assertEquals(name, actionDef.getString("name")); + assertEquals("Destroy", actionDef.getString("label")); + assertEquals(desc, actionDef.getString("description")); + assertEquals(period, actionDef.getString("period")); + assertEquals(location, actionDef.getString("location")); + assertEquals(periodProperty, actionDef.getString("periodProperty")); + assertFalse(actionDef.getBoolean("eligibleOnFirstCompleteEvent")); + assertEquals(2, actionDef.getJSONArray("events").length()); + assertEquals("superseded", actionDef.getJSONArray("events").getString(0)); + assertEquals("no_longer_needed", actionDef.getJSONArray("events").getString(1)); + } + + public void testDeleteDispositionAction() throws Exception + { + NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); + dispositionService.createDispositionSchedule(newRecordCategory, null); + + // create an action definition to then delete + String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); + String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("name", "cutoff"); + String jsonPostString = jsonPostData.toString(); + sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); + + // verify the action definition is present and retrieve it's id + String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); + Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); + JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString())); + String actionDefId = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0).getString("id"); + + // try and delete a non existent action definition to check for 404 + String deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); + rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 404); + + // now delete the action defintion created above + deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); + rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 200); + + // verify it got deleted + getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); + rsp = sendRequest(new GetRequest(getRequestUrl), 200); + json = new JSONObject(new JSONTokener(rsp.getContentAsString())); + JSONArray actions = json.getJSONObject("data").getJSONArray("actions"); + assertEquals(0, actions.length()); + } + + public void testGetDispositionLifecycle() throws Exception + { + // Test 404 for disposition lifecycle request on incorrect node + String categoryUrl = recordCategory.toString().replace("://", "/"); + String requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, categoryUrl); + Response rsp = sendRequest(new GetRequest(requestUrl), 200); + + JSONObject notFound = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertEquals(true, notFound.getJSONObject("data").getBoolean("notFound")); + + NodeRef newRecordFolder = recordFolderService.createRecordFolder(recordCategory, "recordFolder"); + + + // there should now be a disposition lifecycle for the record + requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, newRecordFolder.toString().replace("://", "/")); + rsp = sendRequest(new GetRequest(requestUrl), 200); + System.out.println("GET : " + rsp.getContentAsString()); + assertEquals("application/json;charset=UTF-8", rsp.getContentType()); + + // get response as JSON + JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertNotNull(jsonParsedObject); + + // check mandatory stuff is present + JSONObject dataObj = jsonParsedObject.getJSONObject("data"); + assertEquals(SERVICE_URL_PREFIX + requestUrl, dataObj.getString("url")); + assertEquals("cutoff", dataObj.getString("name")); + assertFalse(dataObj.getBoolean("eventsEligible")); + assertTrue(dataObj.has("events")); + JSONArray events = dataObj.getJSONArray("events"); + assertEquals(1, events.length()); + JSONObject event1 = events.getJSONObject(0); + assertEquals("case_closed", event1.get("name")); + assertEquals("Case Closed", event1.get("label")); + assertFalse(event1.getBoolean("complete")); + assertFalse(event1.getBoolean("automatic")); + + // check stuff expected to be missing is missing + assertFalse(dataObj.has("asOf")); + assertFalse(dataObj.has("startedAt")); + assertFalse(dataObj.has("startedBy")); + assertFalse(dataObj.has("completedAt")); + assertFalse(dataObj.has("completedBy")); + assertFalse(event1.has("completedAt")); + assertFalse(event1.has("completedBy")); + } + + public void testGetListOfValues() throws Exception + { + // call the list service + Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); + assertEquals("application/json;charset=UTF-8", rsp.getContentType()); + + // get response as JSON + JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertNotNull(jsonParsedObject); + JSONObject data = jsonParsedObject.getJSONObject("data"); + + // check dispostion actions + JSONObject actions = data.getJSONObject("dispositionActions"); + assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/dispositionactions", actions.getString("url")); + JSONArray items = actions.getJSONArray("items"); + assertEquals(actionService.getDispositionActions().size(), items.length()); + assertTrue(items.length() > 0); + JSONObject item = items.getJSONObject(0); + assertTrue(item.length() == 2); + assertTrue(item.has("label")); + assertTrue(item.has("value")); + + // check events + JSONObject events = data.getJSONObject("events"); + assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/events", events.getString("url")); + items = events.getJSONArray("items"); + assertEquals(eventService.getEvents().size(), items.length()); + assertTrue(items.length() > 0); + item = items.getJSONObject(0); + assertTrue(item.length() == 3); + assertTrue(item.has("label")); + assertTrue(item.has("value")); + assertTrue(item.has("automatic")); + + // check period types + JSONObject periodTypes = data.getJSONObject("periodTypes"); + assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodtypes", periodTypes.getString("url")); + items = periodTypes.getJSONArray("items"); + assertEquals(Period.getProviderNames().size()-1, items.length()); + assertTrue(items.length() > 0); + item = items.getJSONObject(0); + assertTrue(item.length() == 2); + assertTrue(item.has("label")); + assertTrue(item.has("value")); + + // check period properties + JSONObject periodProperties = data.getJSONObject("periodProperties"); + assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodproperties", periodProperties.getString("url")); + items = periodProperties.getJSONArray("items"); + assertEquals(5, items.length()); + assertTrue(items.length() > 0); + item = items.getJSONObject(0); + assertTrue(item.length() == 2); + assertTrue(item.has("label")); + assertTrue(item.has("value")); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapKeysRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapKeysRestApiTest.java index e377524c32..1aaba9bf92 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapKeysRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapKeysRestApiTest.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Test for Email mapping keys - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class EmailMapKeysRestApiTest extends BaseRMWebScriptTestCase -{ - /** URLs for the REST API */ - private static final String GET_EMAIL_MAP_KEYS_URL = "/api/rma/admin/emailmapkeys"; - - /** - * Tests the REST API to get the list of email mapping keys - * - * @throws IOException - * @throws JSONException - */ - public void testGetCapabilitiesAction() throws IOException, JSONException - { - // Send request - Response response = sendRequest(new GetRequest(GET_EMAIL_MAP_KEYS_URL), Status.STATUS_OK); - - // Check the content from the response - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json and check the data - JSONObject contentAsJson = new JSONObject(contentAsString); - JSONObject data = contentAsJson.getJSONObject("data"); - assertNotNull(data); - - // Get the email mapping keys and check them - JSONArray dataSets = data.getJSONArray("emailmapkeys"); - assertNotNull(dataSets); - - // Check the number of email mapping keys - assertTrue(dataSets.length() == 6); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Test for Email mapping keys + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class EmailMapKeysRestApiTest extends BaseRMWebScriptTestCase +{ + /** URLs for the REST API */ + private static final String GET_EMAIL_MAP_KEYS_URL = "/api/rma/admin/emailmapkeys"; + + /** + * Tests the REST API to get the list of email mapping keys + * + * @throws IOException + * @throws JSONException + */ + public void testGetCapabilitiesAction() throws IOException, JSONException + { + // Send request + Response response = sendRequest(new GetRequest(GET_EMAIL_MAP_KEYS_URL), Status.STATUS_OK); + + // Check the content from the response + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json and check the data + JSONObject contentAsJson = new JSONObject(contentAsString); + JSONObject data = contentAsJson.getJSONObject("data"); + assertNotNull(data); + + // Get the email mapping keys and check them + JSONArray dataSets = data.getJSONArray("emailmapkeys"); + assertNotNull(dataSets); + + // Check the number of email mapping keys + assertTrue(dataSets.length() == 6); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapScriptTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapScriptTest.java index 3bb58ad5d7..147d66ca85 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapScriptTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EmailMapScriptTest.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -public class EmailMapScriptTest extends BaseRMWebScriptTestCase -{ - /** URLs for the REST APIs */ - public final static String URL_RM_EMAILMAP = "/api/rma/admin/emailmap"; - public final static String URL_RM_EMAILMAP_DELETE = "/api/rma/admin/emailmap/%s/%s"; - - /** Constant for the content type */ - private static final String APPLICATION_JSON = "application/json"; - - /** - * Tests the REST APIs for a custom mapping - * - * @throws IOException - * @throws JSONException - */ - public void testEmailMap() throws IOException, JSONException - { - /** Test GET */ - Response getResponse = sendRequest(new GetRequest(URL_RM_EMAILMAP), Status.STATUS_OK); - - JSONObject getResponseContent = new JSONObject(getResponse.getContentAsString()); - JSONObject getData = getResponseContent.getJSONObject("data"); - JSONArray getMappings = getData.getJSONArray("mappings"); - assertTrue(getMappings.length() == 20); - - /** Test POST */ - JSONObject newMapping = new JSONObject(); - newMapping.put("from", "messageTo"); - newMapping.put("to", "rmc:Wibble"); - - Response postResponse = sendRequest(new PostRequest(URL_RM_EMAILMAP, newMapping.toString(), APPLICATION_JSON), Status.STATUS_OK); - JSONObject postResponseContent = new JSONObject(postResponse.getContentAsString()); - JSONObject postData = postResponseContent.getJSONObject("data"); - JSONArray postMappings = postData.getJSONArray("mappings"); - - assertTrue(postMappings.length() == 21); - assertTrue(existsMapping(postMappings)); - - /** Test DELETE */ - Response deleteResponse = sendRequest(new DeleteRequest(String.format(URL_RM_EMAILMAP_DELETE, "messageTo", "rmc:Wibble")), Status.STATUS_OK); - JSONObject deleteResponseContent = new JSONObject(deleteResponse.getContentAsString()); - JSONObject deleteData = deleteResponseContent.getJSONObject("data"); - JSONArray deleteMappings = deleteData.getJSONArray("mappings"); - - assertTrue(deleteMappings.length() == 20); - assertFalse(existsMapping(deleteMappings)); - } - - /** - * Helper method for checking if a custom mapping exists - * - * @param mappings The list of available mappings - * @return true if the custom mapping exists in the list of available mappings, false otherwise - * @throws JSONException - */ - private boolean existsMapping(JSONArray mappings) throws JSONException - { - boolean result = false; - for (int i = 0; i < mappings.length(); i++) - { - String from = mappings.getJSONObject(i).getString("from"); - String to = mappings.getJSONObject(i).getString("to"); - if (from.equalsIgnoreCase("messageTo") && to.equalsIgnoreCase("rmc:Wibble")) - { - result = true; - break; - } - } - return result; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +public class EmailMapScriptTest extends BaseRMWebScriptTestCase +{ + /** URLs for the REST APIs */ + public final static String URL_RM_EMAILMAP = "/api/rma/admin/emailmap"; + public final static String URL_RM_EMAILMAP_DELETE = "/api/rma/admin/emailmap/%s/%s"; + + /** Constant for the content type */ + private static final String APPLICATION_JSON = "application/json"; + + /** + * Tests the REST APIs for a custom mapping + * + * @throws IOException + * @throws JSONException + */ + public void testEmailMap() throws IOException, JSONException + { + /** Test GET */ + Response getResponse = sendRequest(new GetRequest(URL_RM_EMAILMAP), Status.STATUS_OK); + + JSONObject getResponseContent = new JSONObject(getResponse.getContentAsString()); + JSONObject getData = getResponseContent.getJSONObject("data"); + JSONArray getMappings = getData.getJSONArray("mappings"); + assertTrue(getMappings.length() == 20); + + /** Test POST */ + JSONObject newMapping = new JSONObject(); + newMapping.put("from", "messageTo"); + newMapping.put("to", "rmc:Wibble"); + + Response postResponse = sendRequest(new PostRequest(URL_RM_EMAILMAP, newMapping.toString(), APPLICATION_JSON), Status.STATUS_OK); + JSONObject postResponseContent = new JSONObject(postResponse.getContentAsString()); + JSONObject postData = postResponseContent.getJSONObject("data"); + JSONArray postMappings = postData.getJSONArray("mappings"); + + assertTrue(postMappings.length() == 21); + assertTrue(existsMapping(postMappings)); + + /** Test DELETE */ + Response deleteResponse = sendRequest(new DeleteRequest(String.format(URL_RM_EMAILMAP_DELETE, "messageTo", "rmc:Wibble")), Status.STATUS_OK); + JSONObject deleteResponseContent = new JSONObject(deleteResponse.getContentAsString()); + JSONObject deleteData = deleteResponseContent.getJSONObject("data"); + JSONArray deleteMappings = deleteData.getJSONArray("mappings"); + + assertTrue(deleteMappings.length() == 20); + assertFalse(existsMapping(deleteMappings)); + } + + /** + * Helper method for checking if a custom mapping exists + * + * @param mappings The list of available mappings + * @return true if the custom mapping exists in the list of available mappings, false otherwise + * @throws JSONException + */ + private boolean existsMapping(JSONArray mappings) throws JSONException + { + boolean result = false; + for (int i = 0; i < mappings.length(); i++) + { + String from = mappings.getJSONObject(i).getString("from"); + String to = mappings.getJSONObject(i).getString("to"); + if (from.equalsIgnoreCase("messageTo") && to.equalsIgnoreCase("rmc:Wibble")) + { + result = true; + break; + } + } + return result; + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EventRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EventRestApiTest.java index 9dff3ed122..bf382f603d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EventRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/EventRestApiTest.java @@ -1,242 +1,242 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.util.GUID; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * RM event REST API test - * - * @author Roy Wetherall - */ -public class EventRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel -{ - protected static final String GET_EVENTS_URL = "/api/rma/admin/rmevents"; - protected static final String GET_EVENTTYPES_URL = "/api/rma/admin/rmeventtypes"; - protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; - protected static final String APPLICATION_JSON = "application/json"; - - protected static final String DISPLAY_LABEL = "display label"; - protected static final String EVENT_TYPE = "rmEventType.simple"; - protected static final String KEY_EVENT_NAME = "eventName"; - protected static final String KEY_EVENT_TYPE = "eventType"; - protected static final String KEY_EVENT_DISPLAY_LABEL = "eventDisplayLabel"; - - public void testGetEventTypes() throws Exception - { - Response rsp = sendRequest(new GetRequest(GET_EVENTTYPES_URL),200); - String rspContent = rsp.getContentAsString(); - - JSONObject obj = new JSONObject(rspContent); - JSONObject types = obj.getJSONObject("data"); - assertNotNull(types); - - JSONObject type = types.getJSONObject("rmEventType.simple"); - assertNotNull(type); - assertEquals("rmEventType.simple", type.getString("eventTypeName")); - assertNotNull(type.getString("eventTypeDisplayLabel")); - - System.out.println(rspContent); - } - - public void testGetEvents() throws Exception - { - String event1 = GUID.generate(); - String event2 = GUID.generate(); - - // Create a couple or events by hand - eventService.addEvent(EVENT_TYPE, event1, DISPLAY_LABEL); - eventService.addEvent(EVENT_TYPE, event2, DISPLAY_LABEL); - - try - { - // Get the events - Response rsp = sendRequest(new GetRequest(GET_EVENTS_URL),200); - String rspContent = rsp.getContentAsString(); - - JSONObject obj = new JSONObject(rspContent); - JSONObject roles = obj.getJSONObject("data"); - assertNotNull(roles); - - JSONObject eventObj = roles.getJSONObject(event1); - assertNotNull(eventObj); - assertEquals(event1, eventObj.get(KEY_EVENT_NAME)); - assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - - eventObj = roles.getJSONObject(event2); - assertNotNull(eventObj); - assertEquals(event2, eventObj.get(KEY_EVENT_NAME)); - assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - } - finally - { - // Clean up - eventService.removeEvent(event1); - eventService.removeEvent(event2); - } - - } - - public void testPostEvents() throws Exception - { - String eventName= GUID.generate(); - - JSONObject obj = new JSONObject(); - obj.put(KEY_EVENT_NAME, eventName); - obj.put(KEY_EVENT_DISPLAY_LABEL, DISPLAY_LABEL); - obj.put(KEY_EVENT_TYPE, EVENT_TYPE); - - Response rsp = sendRequest(new PostRequest(GET_EVENTS_URL, obj.toString(), APPLICATION_JSON),200); - try - { - String rspContent = rsp.getContentAsString(); - - JSONObject resultObj = new JSONObject(rspContent); - JSONObject eventObj = resultObj.getJSONObject("data"); - assertNotNull(eventObj); - - assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); - assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - - } - finally - { - eventService.removeEvent(eventName); - } - - // Test with no event name set - obj = new JSONObject(); - obj.put(KEY_EVENT_DISPLAY_LABEL, DISPLAY_LABEL); - obj.put(KEY_EVENT_TYPE, EVENT_TYPE); - rsp = sendRequest(new PostRequest(GET_EVENTS_URL, obj.toString(), APPLICATION_JSON),200); - try - { - String rspContent = rsp.getContentAsString(); - - JSONObject resultObj = new JSONObject(rspContent); - JSONObject eventObj = resultObj.getJSONObject("data"); - assertNotNull(eventObj); - - assertNotNull(eventObj.get(KEY_EVENT_NAME)); - assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - - eventName = eventObj.getString(KEY_EVENT_NAME); - } - finally - { - eventService.removeEvent(eventName); - } - } - - public void testPutRole() throws Exception - { - String eventName = GUID.generate(); - eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); - - try - { - JSONObject obj = new JSONObject(); - obj.put(KEY_EVENT_NAME, eventName); - obj.put(KEY_EVENT_DISPLAY_LABEL, "changed"); - obj.put(KEY_EVENT_TYPE, EVENT_TYPE); - - // Get the roles - Response rsp = sendRequest(new PutRequest(GET_EVENTS_URL + "/" + eventName, obj.toString(), APPLICATION_JSON),200); - String rspContent = rsp.getContentAsString(); - - JSONObject result = new JSONObject(rspContent); - JSONObject eventObj = result.getJSONObject("data"); - assertNotNull(eventObj); - - assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); - assertEquals("changed", eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - - // Bad requests - obj = new JSONObject(); - obj.put(KEY_EVENT_NAME, "cheese"); - obj.put(KEY_EVENT_DISPLAY_LABEL, "whatever"); - obj.put(KEY_EVENT_TYPE, EVENT_TYPE); - - sendRequest(new PutRequest(GET_EVENTS_URL + "/cheese", obj.toString(), APPLICATION_JSON), 404); - } - finally - { - // Clean up - eventService.removeEvent(eventName); - } - - } - - public void testGetRole() throws Exception - { - String eventName = GUID.generate(); - eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); - - try - { - // Get the roles - Response rsp = sendRequest(new GetRequest(GET_EVENTS_URL + "/" + eventName),200); - String rspContent = rsp.getContentAsString(); - - JSONObject obj = new JSONObject(rspContent); - JSONObject eventObj = obj.getJSONObject("data"); - assertNotNull(eventObj); - - assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); - assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); - assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); - - // Bad requests - sendRequest(new GetRequest(GET_EVENTS_URL + "/cheese"), 404); - } - finally - { - // Clean up - eventService.removeEvent(eventName); - } - - } - - public void testDeleteRole() throws Exception - { - String eventName = GUID.generate(); - assertFalse(eventService.existsEvent(eventName)); - eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); - assertTrue(eventService.existsEvent(eventName)); - sendRequest(new DeleteRequest(GET_EVENTS_URL + "/" + eventName),200); - assertFalse(eventService.existsEvent(eventName)); - - // Bad request - sendRequest(new DeleteRequest(GET_EVENTS_URL + "/cheese"), 404); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.util.GUID; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * RM event REST API test + * + * @author Roy Wetherall + */ +public class EventRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel +{ + protected static final String GET_EVENTS_URL = "/api/rma/admin/rmevents"; + protected static final String GET_EVENTTYPES_URL = "/api/rma/admin/rmeventtypes"; + protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; + protected static final String APPLICATION_JSON = "application/json"; + + protected static final String DISPLAY_LABEL = "display label"; + protected static final String EVENT_TYPE = "rmEventType.simple"; + protected static final String KEY_EVENT_NAME = "eventName"; + protected static final String KEY_EVENT_TYPE = "eventType"; + protected static final String KEY_EVENT_DISPLAY_LABEL = "eventDisplayLabel"; + + public void testGetEventTypes() throws Exception + { + Response rsp = sendRequest(new GetRequest(GET_EVENTTYPES_URL),200); + String rspContent = rsp.getContentAsString(); + + JSONObject obj = new JSONObject(rspContent); + JSONObject types = obj.getJSONObject("data"); + assertNotNull(types); + + JSONObject type = types.getJSONObject("rmEventType.simple"); + assertNotNull(type); + assertEquals("rmEventType.simple", type.getString("eventTypeName")); + assertNotNull(type.getString("eventTypeDisplayLabel")); + + System.out.println(rspContent); + } + + public void testGetEvents() throws Exception + { + String event1 = GUID.generate(); + String event2 = GUID.generate(); + + // Create a couple or events by hand + eventService.addEvent(EVENT_TYPE, event1, DISPLAY_LABEL); + eventService.addEvent(EVENT_TYPE, event2, DISPLAY_LABEL); + + try + { + // Get the events + Response rsp = sendRequest(new GetRequest(GET_EVENTS_URL),200); + String rspContent = rsp.getContentAsString(); + + JSONObject obj = new JSONObject(rspContent); + JSONObject roles = obj.getJSONObject("data"); + assertNotNull(roles); + + JSONObject eventObj = roles.getJSONObject(event1); + assertNotNull(eventObj); + assertEquals(event1, eventObj.get(KEY_EVENT_NAME)); + assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + + eventObj = roles.getJSONObject(event2); + assertNotNull(eventObj); + assertEquals(event2, eventObj.get(KEY_EVENT_NAME)); + assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + } + finally + { + // Clean up + eventService.removeEvent(event1); + eventService.removeEvent(event2); + } + + } + + public void testPostEvents() throws Exception + { + String eventName= GUID.generate(); + + JSONObject obj = new JSONObject(); + obj.put(KEY_EVENT_NAME, eventName); + obj.put(KEY_EVENT_DISPLAY_LABEL, DISPLAY_LABEL); + obj.put(KEY_EVENT_TYPE, EVENT_TYPE); + + Response rsp = sendRequest(new PostRequest(GET_EVENTS_URL, obj.toString(), APPLICATION_JSON),200); + try + { + String rspContent = rsp.getContentAsString(); + + JSONObject resultObj = new JSONObject(rspContent); + JSONObject eventObj = resultObj.getJSONObject("data"); + assertNotNull(eventObj); + + assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); + assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + + } + finally + { + eventService.removeEvent(eventName); + } + + // Test with no event name set + obj = new JSONObject(); + obj.put(KEY_EVENT_DISPLAY_LABEL, DISPLAY_LABEL); + obj.put(KEY_EVENT_TYPE, EVENT_TYPE); + rsp = sendRequest(new PostRequest(GET_EVENTS_URL, obj.toString(), APPLICATION_JSON),200); + try + { + String rspContent = rsp.getContentAsString(); + + JSONObject resultObj = new JSONObject(rspContent); + JSONObject eventObj = resultObj.getJSONObject("data"); + assertNotNull(eventObj); + + assertNotNull(eventObj.get(KEY_EVENT_NAME)); + assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + + eventName = eventObj.getString(KEY_EVENT_NAME); + } + finally + { + eventService.removeEvent(eventName); + } + } + + public void testPutRole() throws Exception + { + String eventName = GUID.generate(); + eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); + + try + { + JSONObject obj = new JSONObject(); + obj.put(KEY_EVENT_NAME, eventName); + obj.put(KEY_EVENT_DISPLAY_LABEL, "changed"); + obj.put(KEY_EVENT_TYPE, EVENT_TYPE); + + // Get the roles + Response rsp = sendRequest(new PutRequest(GET_EVENTS_URL + "/" + eventName, obj.toString(), APPLICATION_JSON),200); + String rspContent = rsp.getContentAsString(); + + JSONObject result = new JSONObject(rspContent); + JSONObject eventObj = result.getJSONObject("data"); + assertNotNull(eventObj); + + assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); + assertEquals("changed", eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + + // Bad requests + obj = new JSONObject(); + obj.put(KEY_EVENT_NAME, "cheese"); + obj.put(KEY_EVENT_DISPLAY_LABEL, "whatever"); + obj.put(KEY_EVENT_TYPE, EVENT_TYPE); + + sendRequest(new PutRequest(GET_EVENTS_URL + "/cheese", obj.toString(), APPLICATION_JSON), 404); + } + finally + { + // Clean up + eventService.removeEvent(eventName); + } + + } + + public void testGetRole() throws Exception + { + String eventName = GUID.generate(); + eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); + + try + { + // Get the roles + Response rsp = sendRequest(new GetRequest(GET_EVENTS_URL + "/" + eventName),200); + String rspContent = rsp.getContentAsString(); + + JSONObject obj = new JSONObject(rspContent); + JSONObject eventObj = obj.getJSONObject("data"); + assertNotNull(eventObj); + + assertEquals(eventName, eventObj.get(KEY_EVENT_NAME)); + assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL)); + assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE)); + + // Bad requests + sendRequest(new GetRequest(GET_EVENTS_URL + "/cheese"), 404); + } + finally + { + // Clean up + eventService.removeEvent(eventName); + } + + } + + public void testDeleteRole() throws Exception + { + String eventName = GUID.generate(); + assertFalse(eventService.existsEvent(eventName)); + eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL); + assertTrue(eventService.existsEvent(eventName)); + sendRequest(new DeleteRequest(GET_EVENTS_URL + "/" + eventName),200); + assertFalse(eventService.existsEvent(eventName)); + + // Bad request + sendRequest(new DeleteRequest(GET_EVENTS_URL + "/cheese"), 404); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMCaveatConfigScriptTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMCaveatConfigScriptTest.java index c2ff562afb..52e26685d6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMCaveatConfigScriptTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMCaveatConfigScriptTest.java @@ -1,925 +1,925 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; -import org.json.JSONArray; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * - * - * @author Mark Rogers - */ -@SuppressWarnings("unused") -public class RMCaveatConfigScriptTest extends BaseRMWebScriptTestCase -{ - protected final static String RM_LIST = "rmc:smListTest"; - protected final static String RM_LIST_URI_ELEM = "rmc_smListTest"; - - private static final String URL_RM_CONSTRAINTS = "/api/rma/admin/rmconstraints"; - - public void testGetRMConstraints() throws Exception - { - { - Response response = sendRequest(new GetRequest(URL_RM_CONSTRAINTS), Status.STATUS_OK); - - JSONObject top = new JSONObject(response.getContentAsString()); - System.out.println(response.getContentAsString()); - assertNotNull(top.getJSONArray("data")); - } - - /** - * Add a list, then get it back via the list rest script - */ - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - { - Response response = sendRequest(new GetRequest(URL_RM_CONSTRAINTS), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - System.out.println(response.getContentAsString()); - JSONArray data = top.getJSONArray("data"); - - boolean found = false; - assertTrue("no data returned", data.length() > 0); - for(int i = 0; i < data.length(); i++) - { - JSONObject obj = data.getJSONObject(i); - String name = (String)obj.getString("constraintName"); - assertNotNull("constraintName is null", name); - String url = (String)obj.getString("url"); - assertNotNull("detail url is null", name); - if(name.equalsIgnoreCase(RM_LIST)) - { - found = true; - } - - /** - * vallidate the detail URL returned - */ - sendRequest(new GetRequest(url), Status.STATUS_OK); - } - } - } - - /** - * - * @throws Exception - */ - public void testGetRMConstraint() throws Exception - { - /** - * Delete the list to remove any junk then recreate it. - */ - if (caveatConfigService.getRMConstraint(RM_LIST) != null) - { - caveatConfigService.deleteRMConstraint(RM_LIST); - } - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - - createUser("fbloggs"); - createUser("jrogers"); - createUser("jdoe"); - - - List values = new ArrayList(); - values.add("NOFORN"); - values.add("FGI"); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); - - /** - * Positive test Get the constraint - */ - { - String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - String constraintName = data.getString("constraintName"); - assertNotNull("constraintName is null", constraintName); -// JSONArray allowedValues = data.getJSONArray("allowedValues"); - -// assertTrue("values not correct", compare(array, allowedValues)); - -// JSONArray constraintDetails = data.getJSONArray("constraintDetails"); -// -// assertTrue("details array does not contain 3 elements", constraintDetails.length() == 3); -// for(int i =0; i < constraintDetails.length(); i++) -// { -// JSONObject detail = constraintDetails.getJSONObject(i); -// } - } - - /** - * - * @throws Exception - */ - - /** - * Negative test - Attempt to get a constraint that does exist - */ - { - String url = URL_RM_CONSTRAINTS + "/" + "rmc_wibble"; - sendRequest(new GetRequest(url), Status.STATUS_NOT_FOUND); - } - - deleteUser("fbloggs"); - deleteUser("jrogers"); - deleteUser("jdoe"); - - - - - } - - /** - * Create an RM Constraint - * @throws Exception - */ - public void testUpdateRMConstraint() throws Exception - { - - String constraintName = null; - /* - * Create a new list - */ - { - String title = "test Update RM Constraint title"; - JSONArray array = new JSONArray(); - array.put("LEMON"); - array.put("BANANA"); - array.put("PEACH"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintTitle", title); - /** - * Now do a post to create a new list - */ - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - constraintName = data.getString("constraintName"); - JSONArray allowedValues = data.getJSONArray("allowedValues"); - assertTrue("values not correct", compare(array, allowedValues)); - - } - - /** - * Now update both values and title - remove BANANA, PEACH, Add APPLE. - */ - - { - String newTitle = "this is the new title"; - JSONArray array = new JSONArray(); - array.put("LEMON"); - array.put("APPLE"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintName", constraintName); - obj.put("constraintTitle", newTitle); - - System.out.println(obj.toString()); - - /** - * Now do a post to update list - */ - Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - JSONObject top = new JSONObject(response.getContentAsString()); - JSONObject data = top.getJSONObject("data"); - - System.out.println(response.getContentAsString()); - - String url = data.getString("url"); - String constraintName2 = data.getString("constraintName"); - String constraintTitle = data.getString("constraintTitle"); - JSONArray allowedValues = data.getJSONArray("allowedValues"); - - assertTrue(allowedValues.length() == 2); - assertTrue("values not correct", compare(array, allowedValues)); - assertNotNull(url); - assertEquals(constraintName2, constraintName); - assertNotNull(constraintTitle); - assertEquals("title not as expected", constraintTitle, newTitle); - - // Check that data has been persisted. - Response resp2 = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top2 = new JSONObject(resp2.getContentAsString()); - System.out.println("Problem here"); - System.out.println(resp2.getContentAsString()); - JSONObject data2 = top2.getJSONObject("data"); - String constraintTitle2 = data2.getString("constraintTitle"); - JSONArray allowedValues2 = data2.getJSONArray("allowedValues"); - assertTrue("values not correct", compare(array, allowedValues2)); - assertTrue("allowedValues is not 2", allowedValues2.length() == 2); - assertEquals(constraintName2, constraintName); - assertNotNull(constraintTitle2); - assertEquals("title not as expected", constraintTitle2, newTitle); - - } - - /** - * Now put without allowed values - */ - { - String newTitle = "update with no values"; - - JSONObject obj = new JSONObject(); - - obj.put("constraintName", RM_LIST); - obj.put("constraintTitle", newTitle); - - /** - * Now do a put to update a new list - */ - - Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - String url = data.getString("url"); - String constraintName2 = data.getString("constraintName"); - String constraintTitle = data.getString("constraintTitle"); - JSONArray allowedValues = data.getJSONArray("allowedValues"); - - assertTrue(allowedValues.length() == 2); - - assertNotNull(url); - assertEquals(constraintName2, constraintName); - assertNotNull(constraintTitle); - assertEquals("title not as expected", constraintTitle, newTitle); - } - - /** - * Now post without constraint Title - */ - { - JSONArray array = new JSONArray(); - array.put("LEMON"); - array.put("APPLE"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - - System.out.println(obj.toString()); - - /** - * Now do a Put to update the list - title should remain - */ - - Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - } - - /** - * Add a new value (PEAR) to the list - */ - { - JSONArray array = new JSONArray(); - array.put("PEAR"); - array.put("LEMON"); - array.put("APPLE"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - - System.out.println(obj.toString()); - - Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - } - - /** - * Remove a value (PEAR) from the list - */ - { - JSONArray array = new JSONArray(); - array.put("APPLE"); - array.put("LEMON"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - - System.out.println(obj.toString()); - - Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - } - - } - - - /** - * Create an RM Constraint - * @throws Exception - */ - public void testCreateRMConstraint() throws Exception - { - /** - * Delete the list to remove any junk then recreate it. - */ - //caveatConfigService.deleteRMConstraint(RM_LIST); - - /** - * create a new list - */ - { - JSONArray array = new JSONArray(); - array.put("NOFORN"); - array.put("FGI"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintName", RM_LIST); - obj.put("constraintTitle", GUID.generate()); - - System.out.println(obj.toString()); - - /** - * Now do a post to create a new list - */ - - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); - // Check the response - } - - /** - * Now go and get the constraint - */ - { - String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - String constraintName = data.getString("constraintName"); - assertNotNull("constraintName is null", constraintName); - -// JSONArray constraintDetails = data.getJSONArray("constraintDetails"); -// -// assertTrue("details array does not contain 3 elements", constraintDetails.length() == 3); -// for(int i =0; i < constraintDetails.length(); i++) -// { -// JSONObject detail = constraintDetails.getJSONObject(i); -// } - } - - /** - * Now a constraint with a generated name - */ - { - String title = GUID.generate(); - JSONArray array = new JSONArray(); - array.put("Red"); - array.put("Blue"); - array.put("Green"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintTitle", title); - - System.out.println(obj.toString()); - - /** - * Now do a post to create a new list - */ - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - // Check the response - - String url = data.getString("url"); - String constraintName = data.getString("constraintName"); - String constraintTitle = data.getString("constraintTitle"); - JSONArray allowedValues = data.getJSONArray("allowedValues"); - - assertTrue(allowedValues.length() == 3); - assertNotNull(url); - assertNotNull(constraintName); - assertNotNull(constraintTitle); - assertEquals("title not as expected", constraintTitle, title); - sendRequest(new GetRequest(url), Status.STATUS_OK); - - - } - - - /** - * Now a constraint with an empty list of values. - */ - { - JSONArray array = new JSONArray(); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintName", "rmc_whazoo"); - obj.put("constraintTitle", GUID.generate()); - - System.out.println(obj.toString()); - - /** - * Now do a post to create a new list - */ - - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - // Check the response - } - - -// /** -// * Negative tests - duplicate list -// */ -// { -// JSONArray array = new JSONArray(); -// array.put("NOFORN"); -// array.put("FGI"); -// -// JSONObject obj = new JSONObject(); -// obj.put("allowedValues", array); -// obj.put("constraintName", RM_LIST); -// obj.put("constraintTitle", "this is the title"); -// -// System.out.println(obj.toString()); -// -// /** -// * Now do a post to create a new list -// */ -// Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_CREATED); -// JSONObject top = new JSONObject(response.getContentAsString()); -// -// JSONObject data = top.getJSONObject("data"); -// System.out.println(response.getContentAsString()); -// -// // Check the response -// } - - - } - - - public void testGetRMConstraintValues() throws Exception - { - createUser("fbloggs"); - createUser("jrogers"); - createUser("jdoe"); - - /** - * Delete the list to remove any junk then recreate it. - */ - { - if (caveatConfigService.getRMConstraint(RM_LIST) != null) - { - caveatConfigService.deleteRMConstraint(RM_LIST); - } - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - List values = new ArrayList(); - values.add("NOFORN"); - values.add("FGI"); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); - } - - /** - * Positive test Get the constraint - */ - { - String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM + "/values"; - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - String constraintName = data.getString("constraintName"); - assertNotNull("constraintName is null", constraintName); - String constraintTitle = data.getString("constraintTitle"); - assertNotNull("constraintTitle is null", constraintTitle); - - JSONArray values = data.getJSONArray("values"); - - assertTrue("details array does not contain 2 elements", values.length() == 2); - boolean fgiFound = false; - boolean nofornFound = false; - - for(int i =0; i < values.length(); i++) - { - JSONObject value = values.getJSONObject(i); - - if(value.getString("valueName").equalsIgnoreCase("FGI")) - { - fgiFound = true; - - } - - if(value.getString("valueName").equalsIgnoreCase("NOFORN")) - { - nofornFound = true; - } - - - } - assertTrue("fgi not found", fgiFound); - assertTrue("noforn not found", nofornFound); - } - - deleteUser("fbloggs"); - deleteUser("jrogers"); - deleteUser("jdoe"); - } - - - - /** - * Update a value in a constraint - * @throws Exception - */ - public void testUpdateRMConstraintValue() throws Exception - { - if (caveatConfigService.getRMConstraint(RM_LIST) != null) - { - caveatConfigService.deleteRMConstraint(RM_LIST); - } - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - /** - * Add some data to an empty list - */ - { - JSONArray values = new JSONArray(); - - JSONArray authorities = new JSONArray(); - authorities.put("fbloggs"); - authorities.put("jdoe"); - - JSONObject valueA = new JSONObject(); - valueA.put("value", "NOFORN"); - valueA.put("authorities", authorities); - - values.put(valueA); - - JSONObject valueB = new JSONObject(); - valueB.put("value", "FGI"); - valueB.put("authorities", authorities); - - values.put(valueB); - - JSONObject obj = new JSONObject(); - obj.put("values", values); - - - /** - * Do the first update - should get back - * NOFORN - fbloggs, jdoe - * FGI - fbloggs, jdoe - */ - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - assertNotNull("data is null", data); - - JSONArray myValues = data.getJSONArray("values"); - assertTrue("two values not found", myValues.length() == 2); - for(int i = 0; i < myValues.length(); i++) - { - JSONObject myObj = myValues.getJSONObject(i); - } - } - - /** - * Add to a new value, NOCON, fbloggs, jrogers - */ - { - JSONArray values = new JSONArray(); - - JSONArray authorities = new JSONArray(); - authorities.put("fbloggs"); - authorities.put("jrogers"); - - JSONObject valueA = new JSONObject(); - valueA.put("value", "NOCON"); - valueA.put("authorities", authorities); - - values.put(valueA); - - - JSONObject obj = new JSONObject(); - obj.put("values", values); - - - /** - * Add a new value - should get back - * NOFORN - fbloggs, jdoe - * FGI - fbloggs, jdoe - * NOCON - fbloggs, jrogers - */ - System.out.println(obj.toString()); - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - assertNotNull("data is null", data); - - JSONArray myValues = data.getJSONArray("values"); - assertTrue("three values not found", myValues.length() == 3); - for(int i = 0; i < myValues.length(); i++) - { - JSONObject myObj = myValues.getJSONObject(i); - } - } - - /** - * Add to an existing value (NOFORN, jrogers) - * should get back - * NOFORN - fbloggs, jdoe, jrogers - * FGI - fbloggs, jdoe - * NOCON - fbloggs, jrogers - */ - { - JSONArray values = new JSONArray(); - - JSONArray authorities = new JSONArray(); - authorities.put("fbloggs"); - authorities.put("jrogers"); - authorities.put("jdoe"); - - JSONObject valueA = new JSONObject(); - valueA.put("value", "NOFORN"); - valueA.put("authorities", authorities); - - values.put(valueA); - - - JSONObject obj = new JSONObject(); - obj.put("values", values); - - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - assertNotNull("data is null", data); - - JSONArray myValues = data.getJSONArray("values"); - assertTrue("three values not found", myValues.length() == 3); - for(int i = 0; i < myValues.length(); i++) - { - JSONObject myObj = myValues.getJSONObject(i); - } - } - - - /** - * Remove from existing value (NOCON, fbloggs) - */ - { - JSONArray values = new JSONArray(); - - JSONArray authorities = new JSONArray(); - authorities.put("jrogers"); - - JSONObject valueA = new JSONObject(); - valueA.put("value", "NOCON"); - valueA.put("authorities", authorities); - - values.put(valueA); - - - JSONObject obj = new JSONObject(); - obj.put("values", values); - - - /** - * should get back - * NOFORN - fbloggs, jdoe - * FGI - fbloggs, jdoe - * NOCON - jrogers - */ - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - assertNotNull("data is null", data); - - JSONArray myValues = data.getJSONArray("values"); - assertTrue("three values not found", myValues.length() == 3); - boolean foundNOCON = false; - boolean foundNOFORN = false; - boolean foundFGI = false; - - for(int i = 0; i < myValues.length(); i++) - { - JSONObject myObj = myValues.getJSONObject(i); - - if(myObj.getString("valueName").equalsIgnoreCase("NOCON")) - { - foundNOCON = true; - } - if(myObj.getString("valueName").equalsIgnoreCase("NOFORN")) - { - foundNOFORN = true; - } - if(myObj.getString("valueName").equalsIgnoreCase("FGI")) - { - foundFGI = true; - } - } - - assertTrue("not found NOCON", foundNOCON); - assertTrue("not found NOFORN", foundNOFORN); - assertTrue("not found FGI", foundFGI); - } - } - - - /** - * Delete the entire constraint - * - * @throws Exception - */ - public void testDeleteRMConstraint() throws Exception - { - /** - * Delete the list to remove any junk then recreate it. - */ - if (caveatConfigService.getRMConstraint(RM_LIST) != null) - { - caveatConfigService.deleteRMConstraint(RM_LIST); - } - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - /** - * Now do a delete - */ - Response response = sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_OK); - - /** - * Now delete the list that should have been deleted - */ - // TODO NEED TO THINK ABOUT THIS BEHAVIOUR - //{ - // sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_NOT_FOUND); - //} - - /** - * Negative test - delete list that does not exist - */ - { - sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + "rmc_wibble"), Status.STATUS_NOT_FOUND); - } - } - - private boolean compare(JSONArray from, JSONArray to) throws Exception - { - List ret = new ArrayList(); - - if(from.length() != to.length()) - { - fail("arrays are different lengths" + from.length() +", " + to.length()); - return false; - } - - for(int i = 0 ; i < to.length(); i++) - { - ret.add(to.getString(i)); - } - - for(int i = 0 ; i < from.length(); i++) - { - String val = from.getString(i); - - if(ret.contains(val)) - { - - } - else - { - fail("Value not contained in list:" + val); - return false; - } - } - - return true; - } - - - /** - * Create an RM Constraint value - * @throws Exception - */ - public void testGetRMConstraintValue() throws Exception - { - - String constraintName = null; - - /* - * Create a new list - */ - { - String title = "Get Constraint Value"; - JSONArray array = new JSONArray(); - array.put("POTATO"); - array.put("CARROT"); - array.put("TURNIP"); - - JSONObject obj = new JSONObject(); - obj.put("allowedValues", array); - obj.put("constraintTitle", title); - /** - * Now do a post to create a new list - */ - Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - constraintName = data.getString("constraintName"); - JSONArray allowedValues = data.getJSONArray("allowedValues"); - assertTrue("values not correct", compare(array, allowedValues)); - } - - /** - * Get the CARROT value - */ - { - String url = URL_RM_CONSTRAINTS + "/" + constraintName + "/values/" + "CARROT"; - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - } - - { - String url = URL_RM_CONSTRAINTS + "/" + constraintName + "/values/" + "ONION"; - sendRequest(new GetRequest(url), Status.STATUS_NOT_FOUND); - } - } -} - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.service.cmr.security.MutableAuthenticationService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.util.GUID; +import org.alfresco.util.PropertyMap; +import org.json.JSONArray; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * + * + * @author Mark Rogers + */ +@SuppressWarnings("unused") +public class RMCaveatConfigScriptTest extends BaseRMWebScriptTestCase +{ + protected final static String RM_LIST = "rmc:smListTest"; + protected final static String RM_LIST_URI_ELEM = "rmc_smListTest"; + + private static final String URL_RM_CONSTRAINTS = "/api/rma/admin/rmconstraints"; + + public void testGetRMConstraints() throws Exception + { + { + Response response = sendRequest(new GetRequest(URL_RM_CONSTRAINTS), Status.STATUS_OK); + + JSONObject top = new JSONObject(response.getContentAsString()); + System.out.println(response.getContentAsString()); + assertNotNull(top.getJSONArray("data")); + } + + /** + * Add a list, then get it back via the list rest script + */ + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + { + Response response = sendRequest(new GetRequest(URL_RM_CONSTRAINTS), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + System.out.println(response.getContentAsString()); + JSONArray data = top.getJSONArray("data"); + + boolean found = false; + assertTrue("no data returned", data.length() > 0); + for(int i = 0; i < data.length(); i++) + { + JSONObject obj = data.getJSONObject(i); + String name = (String)obj.getString("constraintName"); + assertNotNull("constraintName is null", name); + String url = (String)obj.getString("url"); + assertNotNull("detail url is null", name); + if(name.equalsIgnoreCase(RM_LIST)) + { + found = true; + } + + /** + * vallidate the detail URL returned + */ + sendRequest(new GetRequest(url), Status.STATUS_OK); + } + } + } + + /** + * + * @throws Exception + */ + public void testGetRMConstraint() throws Exception + { + /** + * Delete the list to remove any junk then recreate it. + */ + if (caveatConfigService.getRMConstraint(RM_LIST) != null) + { + caveatConfigService.deleteRMConstraint(RM_LIST); + } + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + + createUser("fbloggs"); + createUser("jrogers"); + createUser("jdoe"); + + + List values = new ArrayList(); + values.add("NOFORN"); + values.add("FGI"); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); + + /** + * Positive test Get the constraint + */ + { + String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + String constraintName = data.getString("constraintName"); + assertNotNull("constraintName is null", constraintName); +// JSONArray allowedValues = data.getJSONArray("allowedValues"); + +// assertTrue("values not correct", compare(array, allowedValues)); + +// JSONArray constraintDetails = data.getJSONArray("constraintDetails"); +// +// assertTrue("details array does not contain 3 elements", constraintDetails.length() == 3); +// for(int i =0; i < constraintDetails.length(); i++) +// { +// JSONObject detail = constraintDetails.getJSONObject(i); +// } + } + + /** + * + * @throws Exception + */ + + /** + * Negative test - Attempt to get a constraint that does exist + */ + { + String url = URL_RM_CONSTRAINTS + "/" + "rmc_wibble"; + sendRequest(new GetRequest(url), Status.STATUS_NOT_FOUND); + } + + deleteUser("fbloggs"); + deleteUser("jrogers"); + deleteUser("jdoe"); + + + + + } + + /** + * Create an RM Constraint + * @throws Exception + */ + public void testUpdateRMConstraint() throws Exception + { + + String constraintName = null; + /* + * Create a new list + */ + { + String title = "test Update RM Constraint title"; + JSONArray array = new JSONArray(); + array.put("LEMON"); + array.put("BANANA"); + array.put("PEACH"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintTitle", title); + /** + * Now do a post to create a new list + */ + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + constraintName = data.getString("constraintName"); + JSONArray allowedValues = data.getJSONArray("allowedValues"); + assertTrue("values not correct", compare(array, allowedValues)); + + } + + /** + * Now update both values and title - remove BANANA, PEACH, Add APPLE. + */ + + { + String newTitle = "this is the new title"; + JSONArray array = new JSONArray(); + array.put("LEMON"); + array.put("APPLE"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintName", constraintName); + obj.put("constraintTitle", newTitle); + + System.out.println(obj.toString()); + + /** + * Now do a post to update list + */ + Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + JSONObject top = new JSONObject(response.getContentAsString()); + JSONObject data = top.getJSONObject("data"); + + System.out.println(response.getContentAsString()); + + String url = data.getString("url"); + String constraintName2 = data.getString("constraintName"); + String constraintTitle = data.getString("constraintTitle"); + JSONArray allowedValues = data.getJSONArray("allowedValues"); + + assertTrue(allowedValues.length() == 2); + assertTrue("values not correct", compare(array, allowedValues)); + assertNotNull(url); + assertEquals(constraintName2, constraintName); + assertNotNull(constraintTitle); + assertEquals("title not as expected", constraintTitle, newTitle); + + // Check that data has been persisted. + Response resp2 = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top2 = new JSONObject(resp2.getContentAsString()); + System.out.println("Problem here"); + System.out.println(resp2.getContentAsString()); + JSONObject data2 = top2.getJSONObject("data"); + String constraintTitle2 = data2.getString("constraintTitle"); + JSONArray allowedValues2 = data2.getJSONArray("allowedValues"); + assertTrue("values not correct", compare(array, allowedValues2)); + assertTrue("allowedValues is not 2", allowedValues2.length() == 2); + assertEquals(constraintName2, constraintName); + assertNotNull(constraintTitle2); + assertEquals("title not as expected", constraintTitle2, newTitle); + + } + + /** + * Now put without allowed values + */ + { + String newTitle = "update with no values"; + + JSONObject obj = new JSONObject(); + + obj.put("constraintName", RM_LIST); + obj.put("constraintTitle", newTitle); + + /** + * Now do a put to update a new list + */ + + Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + String url = data.getString("url"); + String constraintName2 = data.getString("constraintName"); + String constraintTitle = data.getString("constraintTitle"); + JSONArray allowedValues = data.getJSONArray("allowedValues"); + + assertTrue(allowedValues.length() == 2); + + assertNotNull(url); + assertEquals(constraintName2, constraintName); + assertNotNull(constraintTitle); + assertEquals("title not as expected", constraintTitle, newTitle); + } + + /** + * Now post without constraint Title + */ + { + JSONArray array = new JSONArray(); + array.put("LEMON"); + array.put("APPLE"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + + System.out.println(obj.toString()); + + /** + * Now do a Put to update the list - title should remain + */ + + Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + } + + /** + * Add a new value (PEAR) to the list + */ + { + JSONArray array = new JSONArray(); + array.put("PEAR"); + array.put("LEMON"); + array.put("APPLE"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + + System.out.println(obj.toString()); + + Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + } + + /** + * Remove a value (PEAR) from the list + */ + { + JSONArray array = new JSONArray(); + array.put("APPLE"); + array.put("LEMON"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + + System.out.println(obj.toString()); + + Response response = sendRequest(new PutRequest(URL_RM_CONSTRAINTS + "/" + constraintName, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + } + + } + + + /** + * Create an RM Constraint + * @throws Exception + */ + public void testCreateRMConstraint() throws Exception + { + /** + * Delete the list to remove any junk then recreate it. + */ + //caveatConfigService.deleteRMConstraint(RM_LIST); + + /** + * create a new list + */ + { + JSONArray array = new JSONArray(); + array.put("NOFORN"); + array.put("FGI"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintName", RM_LIST); + obj.put("constraintTitle", GUID.generate()); + + System.out.println(obj.toString()); + + /** + * Now do a post to create a new list + */ + + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); + // Check the response + } + + /** + * Now go and get the constraint + */ + { + String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + String constraintName = data.getString("constraintName"); + assertNotNull("constraintName is null", constraintName); + +// JSONArray constraintDetails = data.getJSONArray("constraintDetails"); +// +// assertTrue("details array does not contain 3 elements", constraintDetails.length() == 3); +// for(int i =0; i < constraintDetails.length(); i++) +// { +// JSONObject detail = constraintDetails.getJSONObject(i); +// } + } + + /** + * Now a constraint with a generated name + */ + { + String title = GUID.generate(); + JSONArray array = new JSONArray(); + array.put("Red"); + array.put("Blue"); + array.put("Green"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintTitle", title); + + System.out.println(obj.toString()); + + /** + * Now do a post to create a new list + */ + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + // Check the response + + String url = data.getString("url"); + String constraintName = data.getString("constraintName"); + String constraintTitle = data.getString("constraintTitle"); + JSONArray allowedValues = data.getJSONArray("allowedValues"); + + assertTrue(allowedValues.length() == 3); + assertNotNull(url); + assertNotNull(constraintName); + assertNotNull(constraintTitle); + assertEquals("title not as expected", constraintTitle, title); + sendRequest(new GetRequest(url), Status.STATUS_OK); + + + } + + + /** + * Now a constraint with an empty list of values. + */ + { + JSONArray array = new JSONArray(); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintName", "rmc_whazoo"); + obj.put("constraintTitle", GUID.generate()); + + System.out.println(obj.toString()); + + /** + * Now do a post to create a new list + */ + + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + // Check the response + } + + +// /** +// * Negative tests - duplicate list +// */ +// { +// JSONArray array = new JSONArray(); +// array.put("NOFORN"); +// array.put("FGI"); +// +// JSONObject obj = new JSONObject(); +// obj.put("allowedValues", array); +// obj.put("constraintName", RM_LIST); +// obj.put("constraintTitle", "this is the title"); +// +// System.out.println(obj.toString()); +// +// /** +// * Now do a post to create a new list +// */ +// Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_CREATED); +// JSONObject top = new JSONObject(response.getContentAsString()); +// +// JSONObject data = top.getJSONObject("data"); +// System.out.println(response.getContentAsString()); +// +// // Check the response +// } + + + } + + + public void testGetRMConstraintValues() throws Exception + { + createUser("fbloggs"); + createUser("jrogers"); + createUser("jdoe"); + + /** + * Delete the list to remove any junk then recreate it. + */ + { + if (caveatConfigService.getRMConstraint(RM_LIST) != null) + { + caveatConfigService.deleteRMConstraint(RM_LIST); + } + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + List values = new ArrayList(); + values.add("NOFORN"); + values.add("FGI"); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); + } + + /** + * Positive test Get the constraint + */ + { + String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM + "/values"; + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + String constraintName = data.getString("constraintName"); + assertNotNull("constraintName is null", constraintName); + String constraintTitle = data.getString("constraintTitle"); + assertNotNull("constraintTitle is null", constraintTitle); + + JSONArray values = data.getJSONArray("values"); + + assertTrue("details array does not contain 2 elements", values.length() == 2); + boolean fgiFound = false; + boolean nofornFound = false; + + for(int i =0; i < values.length(); i++) + { + JSONObject value = values.getJSONObject(i); + + if(value.getString("valueName").equalsIgnoreCase("FGI")) + { + fgiFound = true; + + } + + if(value.getString("valueName").equalsIgnoreCase("NOFORN")) + { + nofornFound = true; + } + + + } + assertTrue("fgi not found", fgiFound); + assertTrue("noforn not found", nofornFound); + } + + deleteUser("fbloggs"); + deleteUser("jrogers"); + deleteUser("jdoe"); + } + + + + /** + * Update a value in a constraint + * @throws Exception + */ + public void testUpdateRMConstraintValue() throws Exception + { + if (caveatConfigService.getRMConstraint(RM_LIST) != null) + { + caveatConfigService.deleteRMConstraint(RM_LIST); + } + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + /** + * Add some data to an empty list + */ + { + JSONArray values = new JSONArray(); + + JSONArray authorities = new JSONArray(); + authorities.put("fbloggs"); + authorities.put("jdoe"); + + JSONObject valueA = new JSONObject(); + valueA.put("value", "NOFORN"); + valueA.put("authorities", authorities); + + values.put(valueA); + + JSONObject valueB = new JSONObject(); + valueB.put("value", "FGI"); + valueB.put("authorities", authorities); + + values.put(valueB); + + JSONObject obj = new JSONObject(); + obj.put("values", values); + + + /** + * Do the first update - should get back + * NOFORN - fbloggs, jdoe + * FGI - fbloggs, jdoe + */ + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + assertNotNull("data is null", data); + + JSONArray myValues = data.getJSONArray("values"); + assertTrue("two values not found", myValues.length() == 2); + for(int i = 0; i < myValues.length(); i++) + { + JSONObject myObj = myValues.getJSONObject(i); + } + } + + /** + * Add to a new value, NOCON, fbloggs, jrogers + */ + { + JSONArray values = new JSONArray(); + + JSONArray authorities = new JSONArray(); + authorities.put("fbloggs"); + authorities.put("jrogers"); + + JSONObject valueA = new JSONObject(); + valueA.put("value", "NOCON"); + valueA.put("authorities", authorities); + + values.put(valueA); + + + JSONObject obj = new JSONObject(); + obj.put("values", values); + + + /** + * Add a new value - should get back + * NOFORN - fbloggs, jdoe + * FGI - fbloggs, jdoe + * NOCON - fbloggs, jrogers + */ + System.out.println(obj.toString()); + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + assertNotNull("data is null", data); + + JSONArray myValues = data.getJSONArray("values"); + assertTrue("three values not found", myValues.length() == 3); + for(int i = 0; i < myValues.length(); i++) + { + JSONObject myObj = myValues.getJSONObject(i); + } + } + + /** + * Add to an existing value (NOFORN, jrogers) + * should get back + * NOFORN - fbloggs, jdoe, jrogers + * FGI - fbloggs, jdoe + * NOCON - fbloggs, jrogers + */ + { + JSONArray values = new JSONArray(); + + JSONArray authorities = new JSONArray(); + authorities.put("fbloggs"); + authorities.put("jrogers"); + authorities.put("jdoe"); + + JSONObject valueA = new JSONObject(); + valueA.put("value", "NOFORN"); + valueA.put("authorities", authorities); + + values.put(valueA); + + + JSONObject obj = new JSONObject(); + obj.put("values", values); + + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + assertNotNull("data is null", data); + + JSONArray myValues = data.getJSONArray("values"); + assertTrue("three values not found", myValues.length() == 3); + for(int i = 0; i < myValues.length(); i++) + { + JSONObject myObj = myValues.getJSONObject(i); + } + } + + + /** + * Remove from existing value (NOCON, fbloggs) + */ + { + JSONArray values = new JSONArray(); + + JSONArray authorities = new JSONArray(); + authorities.put("jrogers"); + + JSONObject valueA = new JSONObject(); + valueA.put("value", "NOCON"); + valueA.put("authorities", authorities); + + values.put(valueA); + + + JSONObject obj = new JSONObject(); + obj.put("values", values); + + + /** + * should get back + * NOFORN - fbloggs, jdoe + * FGI - fbloggs, jdoe + * NOCON - jrogers + */ + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST + "/values" , obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + assertNotNull("data is null", data); + + JSONArray myValues = data.getJSONArray("values"); + assertTrue("three values not found", myValues.length() == 3); + boolean foundNOCON = false; + boolean foundNOFORN = false; + boolean foundFGI = false; + + for(int i = 0; i < myValues.length(); i++) + { + JSONObject myObj = myValues.getJSONObject(i); + + if(myObj.getString("valueName").equalsIgnoreCase("NOCON")) + { + foundNOCON = true; + } + if(myObj.getString("valueName").equalsIgnoreCase("NOFORN")) + { + foundNOFORN = true; + } + if(myObj.getString("valueName").equalsIgnoreCase("FGI")) + { + foundFGI = true; + } + } + + assertTrue("not found NOCON", foundNOCON); + assertTrue("not found NOFORN", foundNOFORN); + assertTrue("not found FGI", foundFGI); + } + } + + + /** + * Delete the entire constraint + * + * @throws Exception + */ + public void testDeleteRMConstraint() throws Exception + { + /** + * Delete the list to remove any junk then recreate it. + */ + if (caveatConfigService.getRMConstraint(RM_LIST) != null) + { + caveatConfigService.deleteRMConstraint(RM_LIST); + } + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + /** + * Now do a delete + */ + Response response = sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_OK); + + /** + * Now delete the list that should have been deleted + */ + // TODO NEED TO THINK ABOUT THIS BEHAVIOUR + //{ + // sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_NOT_FOUND); + //} + + /** + * Negative test - delete list that does not exist + */ + { + sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + "rmc_wibble"), Status.STATUS_NOT_FOUND); + } + } + + private boolean compare(JSONArray from, JSONArray to) throws Exception + { + List ret = new ArrayList(); + + if(from.length() != to.length()) + { + fail("arrays are different lengths" + from.length() +", " + to.length()); + return false; + } + + for(int i = 0 ; i < to.length(); i++) + { + ret.add(to.getString(i)); + } + + for(int i = 0 ; i < from.length(); i++) + { + String val = from.getString(i); + + if(ret.contains(val)) + { + + } + else + { + fail("Value not contained in list:" + val); + return false; + } + } + + return true; + } + + + /** + * Create an RM Constraint value + * @throws Exception + */ + public void testGetRMConstraintValue() throws Exception + { + + String constraintName = null; + + /* + * Create a new list + */ + { + String title = "Get Constraint Value"; + JSONArray array = new JSONArray(); + array.put("POTATO"); + array.put("CARROT"); + array.put("TURNIP"); + + JSONObject obj = new JSONObject(); + obj.put("allowedValues", array); + obj.put("constraintTitle", title); + /** + * Now do a post to create a new list + */ + Response response = sendRequest(new PostRequest(URL_RM_CONSTRAINTS, obj.toString(), "application/json"), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + constraintName = data.getString("constraintName"); + JSONArray allowedValues = data.getJSONArray("allowedValues"); + assertTrue("values not correct", compare(array, allowedValues)); + } + + /** + * Get the CARROT value + */ + { + String url = URL_RM_CONSTRAINTS + "/" + constraintName + "/values/" + "CARROT"; + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + } + + { + String url = URL_RM_CONSTRAINTS + "/" + constraintName + "/values/" + "ONION"; + sendRequest(new GetRequest(url), Status.STATUS_NOT_FOUND); + } + } +} + diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMConstraintScriptTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMConstraintScriptTest.java index 78b35e78d3..7dff9bb532 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMConstraintScriptTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RMConstraintScriptTest.java @@ -1,100 +1,100 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * Test of GET RM Constraint (User facing scripts) - * - * @author Mark Rogers - */ -public class RMConstraintScriptTest extends BaseRMWebScriptTestCase -{ - protected final static String RM_LIST = "rmc:smListTest"; - protected final static String RM_LIST_URI_ELEM = "rmc_smListTest"; - - private static final String URL_RM_CONSTRAINTS = "/api/rma/rmconstraints"; - - /** - * - * @throws Exception - */ - public void testGetRMConstraint() throws Exception - { - // Set the current security context as admin - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - /** - * Delete the list to remove any junk then recreate it. - */ - if (caveatConfigService.getRMConstraint(RM_LIST) != null) - { - caveatConfigService.deleteRMConstraint(RM_LIST); - } - caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); - - - createUser("fbloggs"); - createUser("jrogers"); - createUser("jdoe"); - - - List values = new ArrayList(); - values.add("NOFORN"); - values.add("FGI"); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); - caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); - - AuthenticationUtil.setFullyAuthenticatedUser("jdoe"); - /** - * Positive test Get the constraint - */ - { - String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - JSONObject top = new JSONObject(response.getContentAsString()); - - JSONObject data = top.getJSONObject("data"); - System.out.println(response.getContentAsString()); - - data.getJSONArray("allowedValuesForCurrentUser"); - - } - - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - deleteUser("fbloggs"); - deleteUser("jrogers"); - deleteUser("jdoe"); - - } - -} - - +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * Test of GET RM Constraint (User facing scripts) + * + * @author Mark Rogers + */ +public class RMConstraintScriptTest extends BaseRMWebScriptTestCase +{ + protected final static String RM_LIST = "rmc:smListTest"; + protected final static String RM_LIST_URI_ELEM = "rmc_smListTest"; + + private static final String URL_RM_CONSTRAINTS = "/api/rma/rmconstraints"; + + /** + * + * @throws Exception + */ + public void testGetRMConstraint() throws Exception + { + // Set the current security context as admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + /** + * Delete the list to remove any junk then recreate it. + */ + if (caveatConfigService.getRMConstraint(RM_LIST) != null) + { + caveatConfigService.deleteRMConstraint(RM_LIST); + } + caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]); + + + createUser("fbloggs"); + createUser("jrogers"); + createUser("jdoe"); + + + List values = new ArrayList(); + values.add("NOFORN"); + values.add("FGI"); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "fbloggs", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values); + caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jdoe", values); + + AuthenticationUtil.setFullyAuthenticatedUser("jdoe"); + /** + * Positive test Get the constraint + */ + { + String url = URL_RM_CONSTRAINTS + "/" + RM_LIST_URI_ELEM; + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + + JSONObject data = top.getJSONObject("data"); + System.out.println(response.getContentAsString()); + + data.getJSONArray("allowedValuesForCurrentUser"); + + } + + + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + deleteUser("fbloggs"); + deleteUser("jrogers"); + deleteUser("jdoe"); + + } + +} + + diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java index 64c4b968f5..31e70a8b33 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java @@ -1,341 +1,341 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.util.GUID; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Tests for adding/removing users/groups to/from a role - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmAuthoritiesRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST APIs */ - private static final String RM_CHILDREN_URL = "/api/rm/%s/roles/%s/authorities/%s"; - - /** Constant for the content type */ - private static final String APPLICATION_JSON = "application/json"; - - /** Constant for users and groups */ - private static final String USER_WITH_CAPABILITY = GUID.generate(); - private static final String USER_WITHOUT_CAPABILITY = GUID.generate(); - private static final String ROLE_INCLUDING_CAPABILITY = GUID.generate(); - private static final String ROLE_NOT_INCLUDING_CAPABILITY = GUID.generate(); - private static final String USER_TO_ADD_TO_ROLE = GUID.generate(); - private static final String GROUP_TO_ADD_TO_ROLE = GUID.generate(); - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#setupTestData() - */ - @Override - protected void setupTestData() - { - super.setupTestData(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - // Create test user WITH required capability - createUser(USER_WITH_CAPABILITY); - // Create test role - Set capabilities = new HashSet(2); - capabilities.add(capabilityService.getCapability(RMPermissionModel.VIEW_RECORDS)); - capabilities.add(capabilityService.getCapability(RMPermissionModel.MANAGE_ACCESS_CONTROLS)); - filePlanRoleService.createRole(filePlan, ROLE_INCLUDING_CAPABILITY, ROLE_INCLUDING_CAPABILITY, capabilities); - // Add user to the role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_INCLUDING_CAPABILITY, USER_WITH_CAPABILITY); - - // Create test user WITHOUT required capability - createUser(USER_WITHOUT_CAPABILITY); - // Create test role - filePlanRoleService.createRole(filePlan, ROLE_NOT_INCLUDING_CAPABILITY, ROLE_NOT_INCLUDING_CAPABILITY, new HashSet(1)); - // Add user to the role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NOT_INCLUDING_CAPABILITY, USER_WITHOUT_CAPABILITY); - - // Create a test user to add to role - createUser(USER_TO_ADD_TO_ROLE); - - // Create a group to add to role - createGroup(GROUP_TO_ADD_TO_ROLE); - - return null; - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#tearDownImpl() - */ - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - - // Delete test user WITH required capability - deleteUser(USER_WITH_CAPABILITY); - // Delete test role - filePlanRoleService.deleteRole(filePlan, ROLE_INCLUDING_CAPABILITY); - - // Delete test user WITHOUT required capability - deleteUser(USER_WITHOUT_CAPABILITY); - // Add user to the role - filePlanRoleService.deleteRole(filePlan, ROLE_NOT_INCLUDING_CAPABILITY); - - // Delete the user which was added to the role - deleteUser(getTestUserName()); - - // Delete the group which was added to the role - deleteGroup(getTestGroupName()); - } - - /** - * Test the REST API to add/remove a user to/from a role - * - * @throws IOException - * @throws JSONException - */ - public void testRmAddRemoveUser() throws IOException, JSONException - { - // Do the positive test with a user with the needed capabilities - AuthenticationUtil.setFullyAuthenticatedUser(USER_WITH_CAPABILITY); - - // Get the user name - String userName = getTestUserName(); - - // Check if the user is already assigned to the role - assertFalse(getUsersAssignedToRole().contains(userName)); - - // Format url, send the request and check the content - String url = getFormattedUrlString(userName); - checkContent(postRequestSuccess(url)); - - // The user should be added to the role - assertTrue(getUsersAssignedToRole().contains(userName)); - - // Remove the user from the role and check the content - checkContent(deleteRequestSuccess(url)); - - // The user should be removed from the role - assertFalse(getUsersAssignedToRole().contains(userName)); - - // Do the negative test with a user without any capabilities - AuthenticationUtil.setFullyAuthenticatedUser(USER_WITHOUT_CAPABILITY); - - // Send a request. The expectation is an internal server error - postRequestFailure(url); - } - - /** - * Test the REST API to add/remove a group to/from a role - * - * @throws IOException - * @throws JSONException - */ - public void testRmAddRemoveGroup() throws IOException, JSONException - { - // Do the positive test with a user with the needed capabilities - AuthenticationUtil.setFullyAuthenticatedUser(USER_WITH_CAPABILITY); - - // Get the group name - String groupName = getTestGroupName(); - - // Check if the group is already assigned to the role - assertFalse(getGroupsAssignedToRole().contains(groupName)); - - // Format url, send the request and check the content - String url = getFormattedUrlString(groupName); - checkContent(postRequestSuccess(url)); - - // The group should be added to the role - assertTrue(getGroupsAssignedToRole().contains(groupName)); - - // Remove the group from the role and check the content - checkContent(deleteRequestSuccess(url)); - - // The user should be removed from the role - assertFalse(getGroupsAssignedToRole().contains(groupName)); - - // Do the negative test with a user without any capabilities - AuthenticationUtil.setFullyAuthenticatedUser(USER_WITHOUT_CAPABILITY); - - // Send a request. The expectation is an internal server error - deleteRequestFailure(url); - } - - /** - * Util method to get the user name which will be added/removed to/from the role - * - * @return Returns the user name which will be added/removed to/from the role - */ - private String getTestUserName() - { - return authorityService.getName(AuthorityType.USER, USER_TO_ADD_TO_ROLE); - } - - /** - * Util method to get the group name which will be added/removed to/from the role - * - * @return Returns the user group which will be added/removed to/from the role - */ - private String getTestGroupName() - { - return authorityService.getName(AuthorityType.GROUP, GROUP_TO_ADD_TO_ROLE); - } - - /** - * Util method to get a set of groups assigned to a role - * - * @return Returns a set of groups assigned to a role - */ - private Set getGroupsAssignedToRole() - { - return filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER); - } - - /** - * Util method to get a set of users assigned to a role - * - * @return Returns a set of users assigned to a role - */ - private Set getUsersAssignedToRole() - { - return filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER); - } - - /** - * Util method to get a formatted nodeRef string - * - * @return Returns a formatted nodeRef string - */ - private String getFormattedFilePlanString() - { - StoreRef storeRef = filePlan.getStoreRef(); - String storeType = storeRef.getProtocol(); - String storeId = storeRef.getIdentifier(); - String id = filePlan.getId(); - - StringBuffer sb = new StringBuffer(32); - sb.append(storeType); - sb.append("/"); - sb.append(storeId); - sb.append("/"); - sb.append(id); - - return sb.toString(); - } - - /** - * Util method to get a formatted url string - * - * @param authorityName The name of the authority which should be added/removed to/from a role - * @return Returns a formatted url string - */ - private String getFormattedUrlString(String authorityName) - { - return String.format(RM_CHILDREN_URL, getFormattedFilePlanString(), FilePlanRoleService.ROLE_SECURITY_OFFICER, authorityName); - } - - /** - * Util method to send a post request. The expected status is success. - * - * @param url The url which should be used to make the post request - * @return Returns the response from the server - * @throws UnsupportedEncodingException - * @throws IOException - */ - private Response postRequestSuccess(String url) throws UnsupportedEncodingException, IOException - { - return sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); - } - - /** - * Util method to send a post request. The expected status is an internal server error. - * - * @param url The url which should be used to make the post request - * @return Returns the response from the server - * @throws UnsupportedEncodingException - * @throws IOException - */ - private Response postRequestFailure(String url) throws UnsupportedEncodingException, IOException - { - return sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_INTERNAL_SERVER_ERROR); - } - - /** - * Util method to send a delete request. The expected status is success. - * - * @param url The url which should be used to make the delete request - * @return Returns the response from the server - * @throws IOException - */ - private Response deleteRequestSuccess(String url) throws IOException - { - return sendRequest(new DeleteRequest(url), Status.STATUS_OK); - } - - /** - * Util method to send a delete request. The expected status is an internal server error. - * - * @param url The url which should be used to make the delete request - * @return Returns the response from the server - * @throws IOException - */ - private Response deleteRequestFailure(String url) throws IOException - { - return sendRequest(new DeleteRequest(url), Status.STATUS_INTERNAL_SERVER_ERROR); - } - - /** - * Util method to check the server response - * - * @param response The server response - * @throws UnsupportedEncodingException - */ - private void checkContent(Response response) throws UnsupportedEncodingException - { - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - assertTrue(contentAsString.equals("{}")); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.util.GUID; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Tests for adding/removing users/groups to/from a role + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmAuthoritiesRestApiTest extends BaseRMWebScriptTestCase +{ + /** URL for the REST APIs */ + private static final String RM_CHILDREN_URL = "/api/rm/%s/roles/%s/authorities/%s"; + + /** Constant for the content type */ + private static final String APPLICATION_JSON = "application/json"; + + /** Constant for users and groups */ + private static final String USER_WITH_CAPABILITY = GUID.generate(); + private static final String USER_WITHOUT_CAPABILITY = GUID.generate(); + private static final String ROLE_INCLUDING_CAPABILITY = GUID.generate(); + private static final String ROLE_NOT_INCLUDING_CAPABILITY = GUID.generate(); + private static final String USER_TO_ADD_TO_ROLE = GUID.generate(); + private static final String GROUP_TO_ADD_TO_ROLE = GUID.generate(); + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#setupTestData() + */ + @Override + protected void setupTestData() + { + super.setupTestData(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + // Create test user WITH required capability + createUser(USER_WITH_CAPABILITY); + // Create test role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability(RMPermissionModel.VIEW_RECORDS)); + capabilities.add(capabilityService.getCapability(RMPermissionModel.MANAGE_ACCESS_CONTROLS)); + filePlanRoleService.createRole(filePlan, ROLE_INCLUDING_CAPABILITY, ROLE_INCLUDING_CAPABILITY, capabilities); + // Add user to the role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_INCLUDING_CAPABILITY, USER_WITH_CAPABILITY); + + // Create test user WITHOUT required capability + createUser(USER_WITHOUT_CAPABILITY); + // Create test role + filePlanRoleService.createRole(filePlan, ROLE_NOT_INCLUDING_CAPABILITY, ROLE_NOT_INCLUDING_CAPABILITY, new HashSet(1)); + // Add user to the role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NOT_INCLUDING_CAPABILITY, USER_WITHOUT_CAPABILITY); + + // Create a test user to add to role + createUser(USER_TO_ADD_TO_ROLE); + + // Create a group to add to role + createGroup(GROUP_TO_ADD_TO_ROLE); + + return null; + } + }); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#tearDownImpl() + */ + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + // Delete test user WITH required capability + deleteUser(USER_WITH_CAPABILITY); + // Delete test role + filePlanRoleService.deleteRole(filePlan, ROLE_INCLUDING_CAPABILITY); + + // Delete test user WITHOUT required capability + deleteUser(USER_WITHOUT_CAPABILITY); + // Add user to the role + filePlanRoleService.deleteRole(filePlan, ROLE_NOT_INCLUDING_CAPABILITY); + + // Delete the user which was added to the role + deleteUser(getTestUserName()); + + // Delete the group which was added to the role + deleteGroup(getTestGroupName()); + } + + /** + * Test the REST API to add/remove a user to/from a role + * + * @throws IOException + * @throws JSONException + */ + public void testRmAddRemoveUser() throws IOException, JSONException + { + // Do the positive test with a user with the needed capabilities + AuthenticationUtil.setFullyAuthenticatedUser(USER_WITH_CAPABILITY); + + // Get the user name + String userName = getTestUserName(); + + // Check if the user is already assigned to the role + assertFalse(getUsersAssignedToRole().contains(userName)); + + // Format url, send the request and check the content + String url = getFormattedUrlString(userName); + checkContent(postRequestSuccess(url)); + + // The user should be added to the role + assertTrue(getUsersAssignedToRole().contains(userName)); + + // Remove the user from the role and check the content + checkContent(deleteRequestSuccess(url)); + + // The user should be removed from the role + assertFalse(getUsersAssignedToRole().contains(userName)); + + // Do the negative test with a user without any capabilities + AuthenticationUtil.setFullyAuthenticatedUser(USER_WITHOUT_CAPABILITY); + + // Send a request. The expectation is an internal server error + postRequestFailure(url); + } + + /** + * Test the REST API to add/remove a group to/from a role + * + * @throws IOException + * @throws JSONException + */ + public void testRmAddRemoveGroup() throws IOException, JSONException + { + // Do the positive test with a user with the needed capabilities + AuthenticationUtil.setFullyAuthenticatedUser(USER_WITH_CAPABILITY); + + // Get the group name + String groupName = getTestGroupName(); + + // Check if the group is already assigned to the role + assertFalse(getGroupsAssignedToRole().contains(groupName)); + + // Format url, send the request and check the content + String url = getFormattedUrlString(groupName); + checkContent(postRequestSuccess(url)); + + // The group should be added to the role + assertTrue(getGroupsAssignedToRole().contains(groupName)); + + // Remove the group from the role and check the content + checkContent(deleteRequestSuccess(url)); + + // The user should be removed from the role + assertFalse(getGroupsAssignedToRole().contains(groupName)); + + // Do the negative test with a user without any capabilities + AuthenticationUtil.setFullyAuthenticatedUser(USER_WITHOUT_CAPABILITY); + + // Send a request. The expectation is an internal server error + deleteRequestFailure(url); + } + + /** + * Util method to get the user name which will be added/removed to/from the role + * + * @return Returns the user name which will be added/removed to/from the role + */ + private String getTestUserName() + { + return authorityService.getName(AuthorityType.USER, USER_TO_ADD_TO_ROLE); + } + + /** + * Util method to get the group name which will be added/removed to/from the role + * + * @return Returns the user group which will be added/removed to/from the role + */ + private String getTestGroupName() + { + return authorityService.getName(AuthorityType.GROUP, GROUP_TO_ADD_TO_ROLE); + } + + /** + * Util method to get a set of groups assigned to a role + * + * @return Returns a set of groups assigned to a role + */ + private Set getGroupsAssignedToRole() + { + return filePlanRoleService.getGroupsAssignedToRole(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER); + } + + /** + * Util method to get a set of users assigned to a role + * + * @return Returns a set of users assigned to a role + */ + private Set getUsersAssignedToRole() + { + return filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER); + } + + /** + * Util method to get a formatted nodeRef string + * + * @return Returns a formatted nodeRef string + */ + private String getFormattedFilePlanString() + { + StoreRef storeRef = filePlan.getStoreRef(); + String storeType = storeRef.getProtocol(); + String storeId = storeRef.getIdentifier(); + String id = filePlan.getId(); + + StringBuffer sb = new StringBuffer(32); + sb.append(storeType); + sb.append("/"); + sb.append(storeId); + sb.append("/"); + sb.append(id); + + return sb.toString(); + } + + /** + * Util method to get a formatted url string + * + * @param authorityName The name of the authority which should be added/removed to/from a role + * @return Returns a formatted url string + */ + private String getFormattedUrlString(String authorityName) + { + return String.format(RM_CHILDREN_URL, getFormattedFilePlanString(), FilePlanRoleService.ROLE_SECURITY_OFFICER, authorityName); + } + + /** + * Util method to send a post request. The expected status is success. + * + * @param url The url which should be used to make the post request + * @return Returns the response from the server + * @throws UnsupportedEncodingException + * @throws IOException + */ + private Response postRequestSuccess(String url) throws UnsupportedEncodingException, IOException + { + return sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_OK); + } + + /** + * Util method to send a post request. The expected status is an internal server error. + * + * @param url The url which should be used to make the post request + * @return Returns the response from the server + * @throws UnsupportedEncodingException + * @throws IOException + */ + private Response postRequestFailure(String url) throws UnsupportedEncodingException, IOException + { + return sendRequest(new PostRequest(url, new JSONObject().toString(), APPLICATION_JSON), Status.STATUS_INTERNAL_SERVER_ERROR); + } + + /** + * Util method to send a delete request. The expected status is success. + * + * @param url The url which should be used to make the delete request + * @return Returns the response from the server + * @throws IOException + */ + private Response deleteRequestSuccess(String url) throws IOException + { + return sendRequest(new DeleteRequest(url), Status.STATUS_OK); + } + + /** + * Util method to send a delete request. The expected status is an internal server error. + * + * @param url The url which should be used to make the delete request + * @return Returns the response from the server + * @throws IOException + */ + private Response deleteRequestFailure(String url) throws IOException + { + return sendRequest(new DeleteRequest(url), Status.STATUS_INTERNAL_SERVER_ERROR); + } + + /** + * Util method to check the server response + * + * @param response The server response + * @throws UnsupportedEncodingException + */ + private void checkContent(Response response) throws UnsupportedEncodingException + { + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + assertTrue(contentAsString.equals("{}")); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmClassesRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmClassesRestApiTest.java index 40e9faac02..149a9e5828 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmClassesRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmClassesRestApiTest.java @@ -1,146 +1,146 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Tests for Class Definitions - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmClassesRestApiTest extends BaseRMWebScriptTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** URL for the REST APIs */ - private static final String RM_ASPECTS_URL = "/api/rm/classes?cf=%s&siteId=%s"; - - /** - * Test the REST API to retrieve the list of rm aspects - * - * @throws IOException - * @throws JSONException - */ - public void testRmGetAspectDefinitions() throws IOException, JSONException - { - // Format url and send request - String url = String.format(RM_ASPECTS_URL, "aspect", siteId); - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - - // Check the content from the response - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json array - JSONArray contentAsJson = new JSONArray(contentAsString); - assertNotNull(contentAsJson); - - // Get a (sub)list of available dm/rm aspects - List dmAspects = getDmAspects(); - List rmAspects = getRmAspects(); - - // Get the list of rm aspects from the response and check it - List rmAspectList = new ArrayList(); - for (int i = 0; i < contentAsJson.length(); i++) - { - String name = contentAsJson.getJSONObject(i).getString("name"); - assertNotNull(name); - rmAspectList.add(name); - assertFalse(dmAspects.contains(name)); - } - assertTrue(rmAspectList.containsAll(rmAspects)); - - // Get the list of dm aspects and check them. It also contains rm related aspects. - - // Format url and send request - url = String.format(RM_ASPECTS_URL, "aspect", collabSiteId); - response = sendRequest(new GetRequest(url), Status.STATUS_OK); - - // Check the content from the response - contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json array - contentAsJson = new JSONArray(contentAsString); - assertNotNull(contentAsJson); - - // Get the list of dm aspects from the response and check it - List dmAspectList = new ArrayList(); - for (int i = 0; i < contentAsJson.length(); i++) - { - String name = contentAsJson.getJSONObject(i).getString("name"); - assertNotNull(name); - dmAspectList.add(name); - } - assertTrue(dmAspectList.containsAll(dmAspects)); - // the list of dm aspescts contains also rm aspects - assertTrue(dmAspectList.containsAll(rmAspects)); - } - - /** - * Returns a (sub)list of rm aspects - * - * @return A (sub)list of rm aspects - */ - private List getRmAspects() - { - return Arrays.asList(new String[] - { - "rma:ascended", - "rma:recordMetaData", - "rma:vitalRecordDefinition" - }); - } - - /** - * Returns a (sub)list of dm aspects - * - * @return A (sub)list of dm aspects - */ - private List getDmAspects() - { - return Arrays.asList(new String[] - { - "emailserver:attached", - "bpm:assignees", - "cm:likesRatingSchemeRollups", - "wf:parallelReviewStats", - "sys:localized" - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Tests for Class Definitions + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmClassesRestApiTest extends BaseRMWebScriptTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** URL for the REST APIs */ + private static final String RM_ASPECTS_URL = "/api/rm/classes?cf=%s&siteId=%s"; + + /** + * Test the REST API to retrieve the list of rm aspects + * + * @throws IOException + * @throws JSONException + */ + public void testRmGetAspectDefinitions() throws IOException, JSONException + { + // Format url and send request + String url = String.format(RM_ASPECTS_URL, "aspect", siteId); + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + + // Check the content from the response + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json array + JSONArray contentAsJson = new JSONArray(contentAsString); + assertNotNull(contentAsJson); + + // Get a (sub)list of available dm/rm aspects + List dmAspects = getDmAspects(); + List rmAspects = getRmAspects(); + + // Get the list of rm aspects from the response and check it + List rmAspectList = new ArrayList(); + for (int i = 0; i < contentAsJson.length(); i++) + { + String name = contentAsJson.getJSONObject(i).getString("name"); + assertNotNull(name); + rmAspectList.add(name); + assertFalse(dmAspects.contains(name)); + } + assertTrue(rmAspectList.containsAll(rmAspects)); + + // Get the list of dm aspects and check them. It also contains rm related aspects. + + // Format url and send request + url = String.format(RM_ASPECTS_URL, "aspect", collabSiteId); + response = sendRequest(new GetRequest(url), Status.STATUS_OK); + + // Check the content from the response + contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json array + contentAsJson = new JSONArray(contentAsString); + assertNotNull(contentAsJson); + + // Get the list of dm aspects from the response and check it + List dmAspectList = new ArrayList(); + for (int i = 0; i < contentAsJson.length(); i++) + { + String name = contentAsJson.getJSONObject(i).getString("name"); + assertNotNull(name); + dmAspectList.add(name); + } + assertTrue(dmAspectList.containsAll(dmAspects)); + // the list of dm aspescts contains also rm aspects + assertTrue(dmAspectList.containsAll(rmAspects)); + } + + /** + * Returns a (sub)list of rm aspects + * + * @return A (sub)list of rm aspects + */ + private List getRmAspects() + { + return Arrays.asList(new String[] + { + "rma:ascended", + "rma:recordMetaData", + "rma:vitalRecordDefinition" + }); + } + + /** + * Returns a (sub)list of dm aspects + * + * @return A (sub)list of dm aspects + */ + private List getDmAspects() + { + return Arrays.asList(new String[] + { + "emailserver:attached", + "bpm:assignees", + "cm:likesRatingSchemeRollups", + "wf:parallelReviewStats", + "sys:localized" + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmPropertiesRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmPropertiesRestApiTest.java index 820e28aa6d..24daeb2602 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmPropertiesRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmPropertiesRestApiTest.java @@ -1,146 +1,146 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Tests for Properties Definitions - * - * @author Tuna Aksoy - * @since 2.1 - */ -public class RmPropertiesRestApiTest extends BaseRMWebScriptTestCase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** URL for the REST APIs */ - private static final String RM_TYPES_URL = "/api/rm/classes?cf=%s&siteId=%s"; - - /** - * Test the REST API to retrieve the list of rm types - * - * @throws IOException - * @throws JSONException - */ - public void testRmGetTypeDefinitions() throws IOException, JSONException - { - // Format url and send request - String url = String.format(RM_TYPES_URL, "type", siteId); - Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); - - // Check the content from the response - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json array - JSONArray contentAsJson = new JSONArray(contentAsString); - assertNotNull(contentAsJson); - - // Get a (sub)list of available dm/rm types - List dmTypes = getDmTypes(); - List rmTypes = getRmTypes(); - - // Get the list of rm types from the response and check it - List rmTypeList = new ArrayList(); - for (int i = 0; i < contentAsJson.length(); i++) - { - String name = contentAsJson.getJSONObject(i).getString("name"); - assertNotNull(name); - rmTypeList.add(name); - assertFalse(dmTypes.contains(name)); - } - assertTrue(rmTypeList.containsAll(rmTypes)); - - // Get the list of dm types and check them. It also contains rm related types. - - // Format url and send request - url = String.format(RM_TYPES_URL, "type", collabSiteId); - response = sendRequest(new GetRequest(url), Status.STATUS_OK); - - // Check the content from the response - contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json array - contentAsJson = new JSONArray(contentAsString); - assertNotNull(contentAsJson); - - // Get the list of dm types from the response and check it - List dmTypeList = new ArrayList(); - for (int i = 0; i < contentAsJson.length(); i++) - { - String name = contentAsJson.getJSONObject(i).getString("name"); - assertNotNull(name); - dmTypeList.add(name); - } - assertTrue(dmTypeList.containsAll(dmTypes)); - // the list of dm type contains also rm types - assertTrue(dmTypeList.containsAll(rmTypes)); - } - - /** - * Returns a (sub)list of rm types - * - * @return A (sub)list of rm types - */ - private List getRmTypes() - { - return Arrays.asList(new String[] - { - "rma:eventExecution", - "rma:nonElectronicDocument", - "rma:transfer" - }); - } - - /** - * Returns a (sub)list of dm types - * - * @return A (sub)list of dm types - */ - private List getDmTypes() - { - return Arrays.asList(new String[] - { - "cm:authority", - "sys:descriptor", - "app:folderlink", - "wf:submitGroupReviewTask", - "cmis:policy" - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Tests for Properties Definitions + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RmPropertiesRestApiTest extends BaseRMWebScriptTestCase +{ + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase#isCollaborationSiteTest() + */ + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + /** URL for the REST APIs */ + private static final String RM_TYPES_URL = "/api/rm/classes?cf=%s&siteId=%s"; + + /** + * Test the REST API to retrieve the list of rm types + * + * @throws IOException + * @throws JSONException + */ + public void testRmGetTypeDefinitions() throws IOException, JSONException + { + // Format url and send request + String url = String.format(RM_TYPES_URL, "type", siteId); + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + + // Check the content from the response + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json array + JSONArray contentAsJson = new JSONArray(contentAsString); + assertNotNull(contentAsJson); + + // Get a (sub)list of available dm/rm types + List dmTypes = getDmTypes(); + List rmTypes = getRmTypes(); + + // Get the list of rm types from the response and check it + List rmTypeList = new ArrayList(); + for (int i = 0; i < contentAsJson.length(); i++) + { + String name = contentAsJson.getJSONObject(i).getString("name"); + assertNotNull(name); + rmTypeList.add(name); + assertFalse(dmTypes.contains(name)); + } + assertTrue(rmTypeList.containsAll(rmTypes)); + + // Get the list of dm types and check them. It also contains rm related types. + + // Format url and send request + url = String.format(RM_TYPES_URL, "type", collabSiteId); + response = sendRequest(new GetRequest(url), Status.STATUS_OK); + + // Check the content from the response + contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json array + contentAsJson = new JSONArray(contentAsString); + assertNotNull(contentAsJson); + + // Get the list of dm types from the response and check it + List dmTypeList = new ArrayList(); + for (int i = 0; i < contentAsJson.length(); i++) + { + String name = contentAsJson.getJSONObject(i).getString("name"); + assertNotNull(name); + dmTypeList.add(name); + } + assertTrue(dmTypeList.containsAll(dmTypes)); + // the list of dm type contains also rm types + assertTrue(dmTypeList.containsAll(rmTypes)); + } + + /** + * Returns a (sub)list of rm types + * + * @return A (sub)list of rm types + */ + private List getRmTypes() + { + return Arrays.asList(new String[] + { + "rma:eventExecution", + "rma:nonElectronicDocument", + "rma:transfer" + }); + } + + /** + * Returns a (sub)list of dm types + * + * @return A (sub)list of dm types + */ + private List getDmTypes() + { + return Arrays.asList(new String[] + { + "cm:authority", + "sys:descriptor", + "app:folderlink", + "wf:submitGroupReviewTask", + "cmis:policy" + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmRestApiTest.java index f4d3eb5bc0..a12cf5ec39 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmRestApiTest.java @@ -1,1163 +1,1163 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.Date; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.module.org_alfresco_module_rm.test.util.TestActionParams; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONStringer; -import org.json.JSONTokener; -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * This class tests the Rest API for RM. - * - * @author Neil McErlean - */ -public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel -{ - protected static final String GET_NODE_AUDITLOG_URL_FORMAT = "/api/node/{0}/rmauditlog"; - protected static final String GET_TRANSFER_URL_FORMAT = "/api/node/{0}/transfers/{1}"; - protected static final String TRANSFER_REPORT_URL_FORMAT = "/api/node/{0}/transfers/{1}/report"; - protected static final String REF_INSTANCES_URL_FORMAT = "/api/node/{0}/customreferences"; - protected static final String RMA_AUDITLOG_URL = "/api/rma/admin/rmauditlog"; - protected static final String RMA_AUDITLOG_STATUS_URL = "/api/rma/admin/rmauditlog/status"; - protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues"; - protected static final String RMA_ACTIONS_URL = "/api/rma/actions/ExecutionQueue"; - protected static final String APPLICATION_JSON = "application/json"; - protected static final String RMA_CUSTOM_PROPS_DEFINITIONS_URL = "/api/rma/admin/custompropertydefinitions"; - protected static final String RMA_CUSTOM_REFS_DEFINITIONS_URL = "/api/rma/admin/customreferencedefinitions"; - - private static final String BI_DI = "BiDi"; - private static final String CHILD_SRC = "childSrc"; - private static final String CHILD_TGT = "childTgt"; - - /** - * This test method ensures that a POST of an RM action to a non-existent node - * will result in a 404 status. - * - * @throws Exception - */ - public void testPostActionToNonExistentNode() throws Exception - { - NodeRef nonExistentNode = new NodeRef("workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); - - // Construct the JSON request. - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("nodeRef", nonExistentNode.toString()); - // Although the request specifies a 'reviewed' action, it does not matter what - // action is specified here, as the non-existent Node should trigger a 404 - // before the action is executed. - jsonPostData.put("name", "reviewed"); - - // Submit the JSON request. - String jsonPostString = jsonPostData.toString(); - - final int expectedStatus = 404; - sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonPostString, APPLICATION_JSON), expectedStatus); - } - - public void testPostReviewedAction() throws IOException, JSONException - { - NodeRef testRecord = utils.createRecord(recordFolder, "test.txt"); - - // In this test, this property has a date-value equal to the model import time. - Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); - - // Construct the JSON request for 'reviewed'. - String jsonString = new JSONStringer().object() - .key("name").value("reviewed") - .key("nodeRef").value(testRecord.toString()) - // These JSON params are just to test the submission of params. They'll be ignored. - .key("params").object() - .key("param1").value("one") - .key("param2").value("two") - .endObject() - .endObject() - .toString(); - - // Submit the JSON request. - final int expectedStatus = 200; - Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, - jsonString, APPLICATION_JSON), expectedStatus); - - String rspContent = rsp.getContentAsString(); - assertTrue(rspContent.contains("Successfully queued action [reviewed]")); - - Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); - assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, - pristineReviewAsOf.equals(newReviewAsOfDate)); - } - - public void testPostMultiReviewedAction() throws IOException, JSONException - { - NodeRef testRecord = utils.createRecord(recordFolder, "test1.txt"); - NodeRef testRecord2 = utils.createRecord(recordFolder, "test2.txt"); - NodeRef testRecord3 = utils.createRecord(recordFolder, "test3.txt"); - - // In this test, this property has a date-value equal to the model import time. - Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); - Serializable pristineReviewAsOf2 = this.nodeService.getProperty(testRecord2, PROP_REVIEW_AS_OF); - Serializable pristineReviewAsOf3 = this.nodeService.getProperty(testRecord3, PROP_REVIEW_AS_OF); - - // Construct the JSON request for 'reviewed'. - String jsonString = new JSONStringer().object() - .key("name").value("reviewed") - .key("nodeRefs").array() - .value(testRecord.toString()) - .value(testRecord2.toString()) - .value(testRecord3.toString()) - .endArray() - // These JSON params are just to test the submission of params. They'll be ignored. - .key("params").object() - .key("param1").value("one") - .key("param2").value("two") - .endObject() - .endObject() - .toString(); - - // Submit the JSON request. - final int expectedStatus = 200; - Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, - jsonString, APPLICATION_JSON), expectedStatus); - - String rspContent = rsp.getContentAsString(); - assertTrue(rspContent.contains("Successfully queued action [reviewed]")); - - Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); - assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, - pristineReviewAsOf.equals(newReviewAsOfDate)); - Serializable newReviewAsOfDate2 = this.nodeService.getProperty(testRecord2, PROP_REVIEW_AS_OF); - assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf2, - pristineReviewAsOf2.equals(newReviewAsOfDate2)); - Serializable newReviewAsOfDate3 = this.nodeService.getProperty(testRecord3, PROP_REVIEW_AS_OF); - assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf3, - pristineReviewAsOf3.equals(newReviewAsOfDate3)); - } - - public void testActionParams() throws Exception - { - // Construct the JSON request for 'reviewed'. - String jsonString = new JSONStringer().object() - .key("name").value("testActionParams") - .key("nodeRef").array() - .value("nothing://nothing/nothing") - .endArray() - // These JSON params are just to test the submission of params. They'll be ignored. - .key("params").object() - .key(TestActionParams.PARAM_DATE).object() - .key("iso8601") - .value(ISO8601DateFormat.format(new Date())) - .endObject() - .endObject() - .endObject() - .toString(); - - // Submit the JSON request. - final int expectedStatus = 200; - //TODO Currently failing unit test. - sendRequest(new PostRequest(RMA_ACTIONS_URL, - jsonString, APPLICATION_JSON), expectedStatus); - } - - public void testPostCustomReferenceDefinitions() throws IOException, JSONException - { - postCustomReferenceDefinitions(); - } - - /** - * This method creates a child and a non-child reference and returns their generated ids. - * - * - * @return String[] with element 0 = refId of p/c ref, 1 = refId pf bidi. - */ - private String[] postCustomReferenceDefinitions() throws JSONException, IOException, - UnsupportedEncodingException { - String[] result = new String[2]; - - // 1. Child association. - String jsonString = new JSONStringer().object() - .key("referenceType").value(RelationshipType.PARENTCHILD) - .key("source").value(CHILD_SRC) - .key("target").value(CHILD_TGT) - .endObject() - .toString(); - -// System.out.println(jsonString); - - // Submit the JSON request. - final int expectedStatus = 200; - Response rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, - jsonString, APPLICATION_JSON), expectedStatus); - - String rspContent = rsp.getContentAsString(); - assertTrue(rspContent.contains("success")); - -// System.out.println(rspContent); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String generatedChildRefId = jsonRsp.getJSONObject("data").getString("refId"); - result[0] = generatedChildRefId; - - // 2. Non-child or standard association. - jsonString = new JSONStringer().object() - .key("referenceType").value(RelationshipType.BIDIRECTIONAL) - .key("label").value(BI_DI) - .endObject() - .toString(); - -// System.out.println(jsonString); - - // Submit the JSON request. - rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, - jsonString, APPLICATION_JSON), expectedStatus); - - rspContent = rsp.getContentAsString(); - assertTrue(rspContent.contains("success")); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String generatedBidiRefId = jsonRsp.getJSONObject("data").getString("refId"); - result[1] = generatedBidiRefId; - - // Now assert that both have appeared in the data dictionary. - AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); - assertNotNull("Missing customAssocs aspect", customAssocsAspect); - - QName newRefQname = adminService.getQNameForClientId(generatedChildRefId); - Map associations = customAssocsAspect.getAssociations(); - assertTrue("Custom child assoc not returned by dataDictionary.", associations.containsKey(newRefQname)); - - newRefQname = adminService.getQNameForClientId(generatedBidiRefId); - assertTrue("Custom std assoc not returned by dataDictionary.", customAssocsAspect.getAssociations().containsKey(newRefQname)); - - return result; - } - - public void testPutCustomPropertyDefinition() throws Exception - { - // POST to create a property definition with a known propId - final String propertyLabel = "Original label åçîéøü"; - String propId = postCustomPropertyDefinition(propertyLabel, null); - - // PUT an updated label. - final String updatedLabel = "Updated label πø^¨¥†®"; - String jsonString = new JSONStringer().object() - .key("label").value(updatedLabel) - .endObject() - .toString(); - - String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; - Response rsp = sendRequest(new PutRequest(propDefnUrl, - jsonString, APPLICATION_JSON), 200); - - // GET from the URL again to ensure it's valid - rsp = sendRequest(new GetRequest(propDefnUrl), 200); - String rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - // PUT an updated constraint ref. - final String updatedConstraint = "rmc:tlList"; - jsonString = new JSONStringer().object() - .key("constraintRef").value(updatedConstraint) - .endObject() - .toString(); - - propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; - rsp = sendRequest(new PutRequest(propDefnUrl, - jsonString, APPLICATION_JSON), 200); - - rspContent = rsp.getContentAsString(); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String urlOfNewPropDef = jsonRsp.getString("url"); - assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); - - // GET from the URL again to ensure it's valid - rsp = sendRequest(new GetRequest(propDefnUrl), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - JSONObject customPropsObject = dataObject.getJSONObject("customProperties"); - assertNotNull("JSON customProperties object was null", customPropsObject); - assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); - - Object keyToSoleProp = customPropsObject.keys().next(); - - JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); - assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); - JSONArray constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); - assertEquals("ConstraintRefsArray wrong length.", 1, constraintRefsArray.length()); - String retrievedUpdatedTitle = constraintRefsArray.getJSONObject(0).getString("name"); - assertEquals("Constraints had wrong name.", "rmc:tlList", retrievedUpdatedTitle); - - // PUT again to remove all constraints - jsonString = new JSONStringer().object() - .key("constraintRef").value(null) - .endObject() - .toString(); - - rsp = sendRequest(new PutRequest(propDefnUrl, - jsonString, APPLICATION_JSON), 200); - - rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - - // GET from the URL again to ensure it's valid - rsp = sendRequest(new GetRequest(propDefnUrl), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - customPropsObject = dataObject.getJSONObject("customProperties"); - assertNotNull("JSON customProperties object was null", customPropsObject); - assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); - - keyToSoleProp = customPropsObject.keys().next(); - - newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); - assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); - constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); - assertEquals("ConstraintRefsArray wrong length.", 0, constraintRefsArray.length()); - - // Finally PUT a constraint on a PropertyDefn that has been cleared of constraints. - // This was raised as an issue - final String readdedConstraint = "rmc:tlList"; - jsonString = new JSONStringer().object() - .key("constraintRef").value(readdedConstraint) - .endObject() - .toString(); - - propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; - rsp = sendRequest(new PutRequest(propDefnUrl, - jsonString, APPLICATION_JSON), 200); - - rspContent = rsp.getContentAsString(); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); -// System.out.println("PUTting a constraint back again."); -// System.out.println(rspContent); - - // And GET from the URL again - rsp = sendRequest(new GetRequest(propDefnUrl), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - customPropsObject = dataObject.getJSONObject("customProperties"); - assertNotNull("JSON customProperties object was null", customPropsObject); - assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); - - keyToSoleProp = customPropsObject.keys().next(); - - newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); - assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); - constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); - assertEquals("ConstraintRefsArray wrong length.", 1, constraintRefsArray.length()); - String readdedUpdatedTitle = constraintRefsArray.getJSONObject(0).getString("name"); - assertEquals("Constraints had wrong name.", "rmc:tlList", readdedUpdatedTitle); - } - - public void testGetCustomReferences() throws IOException, JSONException - { - // Ensure that there is at least one custom reference. - postCustomReferenceDefinitions(); - - // GET all custom reference definitions - final int expectedStatus = 200; - Response rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL), expectedStatus); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - JSONArray customRefsObj = (JSONArray)dataObj.get("customReferences"); - assertNotNull("JSON 'customReferences' object was null", customRefsObj); - - assertTrue("There should be at least two custom references. Found " + customRefsObj, customRefsObj.length() >= 2); - - // GET a specific custom reference definition. - // Here, we're using one of the built-in references - // qname = rmc:versions - rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL + "/" + CUSTOM_REF_VERSIONS.getLocalName()), expectedStatus); - - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - customRefsObj = (JSONArray)dataObj.get("customReferences"); - assertNotNull("JSON 'customProperties' object was null", customRefsObj); - - assertTrue("There should be exactly 1 custom references. Found " + customRefsObj.length(), customRefsObj.length() == 1); - } - - public void testGetDodCustomTypes() throws IOException, JSONException - { - final int expectedStatus = 200; - Response rsp = sendRequest(new GetRequest("/api/rma/admin/dodcustomtypes"), expectedStatus); - - String rspContent = rsp.getContentAsString(); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - - // System.out.println(rspContent); - - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - JSONArray customTypesObj = (JSONArray)dataObj.get("dodCustomTypes"); - assertNotNull("JSON 'dodCustomTypes' object was null", customTypesObj); - - assertEquals("Wrong DOD custom types count.", 4, customTypesObj.length()); - } - - public void testGetPostAndRemoveCustomReferenceInstances() throws Exception - { - NodeRef testRecord1 = utils.createRecord(recordFolder, "testRecord1" + System.currentTimeMillis(), "The from recørd"); - NodeRef testRecord2 = utils.createRecord(recordFolder, "testRecord2" + System.currentTimeMillis(), "The to récord"); - - String node1Url = testRecord1.toString().replace("://", "/"); - String refInstancesRecord1Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node1Url); - - // Create reference types. - String[] generatedRefIds = postCustomReferenceDefinitions(); - - // Add a standard ref - String jsonString = new JSONStringer().object() - .key("toNode").value(testRecord2.toString()) - .key("refId").value(generatedRefIds[1]) - .endObject() - .toString(); - - Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, - jsonString, APPLICATION_JSON), 200); - - // Add a child ref - jsonString = new JSONStringer().object() - .key("toNode").value(testRecord2.toString()) - .key("refId").value(generatedRefIds[0]) - .endObject() - .toString(); - -// System.out.println(jsonString); - - rsp = sendRequest(new PostRequest(refInstancesRecord1Url, - jsonString, APPLICATION_JSON), 200); - -// System.out.println(rsp.getContentAsString()); - - // Now retrieve the applied references from the REST API - // 1. references on the 'from' record. - rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - - String contentAsString = rsp.getContentAsString(); -// System.out.println(contentAsString); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); - - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - JSONArray customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); - assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); - - int customRefsCount = customRefsFromArray.length(); - assertTrue("There should be at least one custom reference. Found " + customRefsFromArray, customRefsCount > 0); - - JSONArray customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); - assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); - assertEquals("customReferencesTo wrong length.", 0, customRefsToArray.length()); - - // 2. Back-references on the 'to' record - String node2Url = testRecord2.toString().replace("://", "/"); - String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); - - rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); - - contentAsString = rsp.getContentAsString(); - - jsonRsp = new JSONObject(new JSONTokener(contentAsString)); - - dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); - assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); - - customRefsCount = customRefsToArray.length(); - assertTrue("There should be at least one custom reference. Found " + customRefsToArray, customRefsCount > 0); - - customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); - assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); - assertEquals("customReferencesFrom wrong length.", 0, customRefsFromArray.length()); - - - - // Now to delete a reference instance of each type - String protocol = testRecord2.getStoreRef().getProtocol(); - String identifier = testRecord2.getStoreRef().getIdentifier(); - String recId = testRecord2.getId(); - final String queryFormat = "?st={0}&si={1}&id={2}"; - String urlQueryString = MessageFormat.format(queryFormat, protocol, identifier, recId); - - rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" + generatedRefIds[1] + urlQueryString), 200); - assertTrue(rsp.getContentAsString().contains("success")); - - rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" - + generatedRefIds[0] - + urlQueryString), 200); - assertTrue(rsp.getContentAsString().contains("success")); - - // Get the reference instances back and confirm they've been removed. - rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); - assertNotNull("JSON 'customReferences' object was null", customRefsFromArray); - assertTrue("customRefsArray was unexpectedly not empty.", customRefsFromArray.length() == 0); - } - - public void testMob1630ShouldNotBeAbleToCreateTwoSupersedesReferencesOnOneRecordPair() throws Exception - { - // Create 2 test records. - NodeRef testRecord1 = utils.createRecord(recordFolder, "testRecord1" + System.currentTimeMillis(), "The from recørd"); - NodeRef testRecord2 = utils.createRecord(recordFolder, "testRecord2" + System.currentTimeMillis(), "The to récord"); - - String node1Url = testRecord1.toString().replace("://", "/"); - String node2Url = testRecord2.toString().replace("://", "/"); - String refInstancesRecord1Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node1Url); - String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); - - {// Sanity check. There should be no references defined on these new records. - Response rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - - String rspContent = rsp.getContentAsString(); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObj = jsonRsp.getJSONObject("data"); - JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); - JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); - assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); - assertEquals("Incorrect to-refs count.", 0, refsTo.length()); - } - - // Add a supersedes ref instance between them - final String supersedesRefLocalName = CUSTOM_REF_SUPERSEDES.getLocalName(); - String jsonString = new JSONStringer().object() - .key("toNode").value(testRecord2.toString()) - .key("refId").value(supersedesRefLocalName) - .endObject() - .toString(); - - Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, - jsonString, APPLICATION_JSON), 200); - - // The bug is that we can apply two such references which should not be allowed - rsp = sendRequest(new PostRequest(refInstancesRecord1Url, - jsonString, APPLICATION_JSON), 500); - - {// Retrieve reference instances on this pair of records. - // The first record - rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - - String rspContent = rsp.getContentAsString(); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObj = jsonRsp.getJSONObject("data"); - JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); - JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); - assertEquals("Incorrect from-refs count.", 1, refsFrom.length()); - assertEquals("Incorrect to-refs count.", 0, refsTo.length()); - - // The second record - the back-reference - rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); - - rspContent = rsp.getContentAsString(); - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - dataObj = jsonRsp.getJSONObject("data"); - refsFrom = dataObj.getJSONArray("customReferencesFrom"); - refsTo = dataObj.getJSONArray("customReferencesTo"); - assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); - assertEquals("Incorrect to-refs count.", 1, refsTo.length()); - } - - // Delete the reference instance - String protocol = testRecord2.getStoreRef().getProtocol(); - String identifier = testRecord2.getStoreRef().getIdentifier(); - String recId = testRecord2.getId(); - final String queryFormat = "?st={0}&si={1}&id={2}"; - String urlQueryString = MessageFormat.format(queryFormat, protocol, identifier, recId); - - rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" + supersedesRefLocalName + urlQueryString), 200); - assertTrue(rsp.getContentAsString().contains("success")); - - {// Retrieve reference instances on this pair of records. - // The first record - rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - - String rspContent = rsp.getContentAsString(); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObj = jsonRsp.getJSONObject("data"); - JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); - JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); - assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); - assertEquals("Incorrect to-refs count.", 0, refsTo.length()); - - // The second record - the back-reference - rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); - - rspContent = rsp.getContentAsString(); - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - dataObj = jsonRsp.getJSONObject("data"); - refsFrom = dataObj.getJSONArray("customReferencesFrom"); - refsTo = dataObj.getJSONArray("customReferencesTo"); - assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); - assertEquals("Incorrect to-refs count.", 0, refsTo.length()); - } - } - - public void testPostCustomPropertyDefinition() throws Exception - { - long currentTimeMillis = System.currentTimeMillis(); - - // Create one with no propId - it'll get generated. - postCustomPropertyDefinition("customProperty" + currentTimeMillis, null); - - // Create another with an explicit propId. - postCustomPropertyDefinition("customProperty" + currentTimeMillis, "prop" + currentTimeMillis); - } - - /** - * Creates a new property definition using a POST call. - * GETs the resultant property definition. - * - * @param propertyLabel the label to use - * @param propId the propId to use - null to have one generated. - * @return the propId of the new property definition - */ - private String postCustomPropertyDefinition(String propertyLabel, String propId) throws JSONException, - IOException, UnsupportedEncodingException - { - String jsonString; - if (propId == null) - { - jsonString = new JSONStringer().object() - .key("label").value(propertyLabel) - .key("description").value("Dynamically defined test property") - .key("mandatory").value(false) - .key("dataType").value("d:text") - .key("element").value("record") - .key("constraintRef").value("rmc:smList") - // Note no propId - .endObject() - .toString(); - } - else - { - jsonString = new JSONStringer().object() - .key("label").value(propertyLabel) - .key("description").value("Dynamically defined test property") - .key("mandatory").value(false) - .key("dataType").value("d:text") - .key("element").value("record") - .key("constraintRef").value("rmc:smList") - .key("propId").value(propId) - .endObject() - .toString(); - } - - // Submit the JSON request. - final int expectedStatus = 200; - Response rsp = sendRequest(new PostRequest("/api/rma/admin/custompropertydefinitions?element=record", - jsonString, APPLICATION_JSON), expectedStatus); - - String rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String urlOfNewPropDef = jsonRsp.getString("url"); - String newPropId = jsonRsp.getString("propId"); - - assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); - - // GET from the URL we're given to ensure it's valid - rsp = sendRequest(new GetRequest(urlOfNewPropDef), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - JSONObject customPropsObject = dataObject.getJSONObject("customProperties"); - assertNotNull("JSON customProperties object was null", customPropsObject); - assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); - - Object keyToSoleProp = customPropsObject.keys().next(); - -// System.out.println("New property defn: " + keyToSoleProp); - - JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); - assertEquals("Wrong property label.", propertyLabel, newPropObject.getString("label")); - - return newPropId; - } - - public void testPutCustomReferenceDefinition() throws Exception - { - String[] generatedRefIds = postCustomReferenceDefinitions(); - final String pcRefId = generatedRefIds[0]; - final String bidiRefId = generatedRefIds[1]; - - // GET the custom refs in order to retrieve the label/source/target - String refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; - Response rsp = sendRequest(new GetRequest(refDefnUrl), 200); - - String rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - - refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; - rsp = sendRequest(new GetRequest(refDefnUrl), 200); - - rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - - // Update the bidirectional reference. - final String updatedBiDiLabel = "Updated label üøéîçå"; - String jsonString = new JSONStringer().object() - .key("label").value(updatedBiDiLabel) - .endObject() - .toString(); - - refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; - rsp = sendRequest(new PutRequest(refDefnUrl, - jsonString, APPLICATION_JSON), 200); - - rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String urlOfNewRefDef = jsonRsp.getString("url"); - assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); - - // GET the bidi reference to ensure it's valid - rsp = sendRequest(new GetRequest(refDefnUrl), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - JSONArray customRefsObject = dataObject.getJSONArray("customReferences"); - assertNotNull("JSON customReferences object was null", customRefsObject); - assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); - - JSONObject newRefObject = customRefsObject.getJSONObject(0); - assertEquals("Wrong property label.", updatedBiDiLabel, newRefObject.getString("label")); - - // Update the parent/child reference. - final String updatedPcSource = "Updated source ∆Ωç√∫"; - final String updatedPcTarget = "Updated target ∆Ωç√∫"; - jsonString = new JSONStringer().object() - .key("source").value(updatedPcSource) - .key("target").value(updatedPcTarget) - .endObject() - .toString(); - - refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; - rsp = sendRequest(new PutRequest(refDefnUrl, - jsonString, APPLICATION_JSON), 200); - - rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - urlOfNewRefDef = jsonRsp.getString("url"); - assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); - - // GET the parent/child reference to ensure it's valid - refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; - - rsp = sendRequest(new GetRequest(refDefnUrl), 200); - rspContent = rsp.getContentAsString(); - -// System.out.println(rspContent); - - jsonRsp = new JSONObject(new JSONTokener(rspContent)); - dataObject = jsonRsp.getJSONObject("data"); - assertNotNull("JSON data object was null", dataObject); - customRefsObject = dataObject.getJSONArray("customReferences"); - assertNotNull("JSON customReferences object was null", customRefsObject); - assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); - - newRefObject = customRefsObject.getJSONObject(0); - assertEquals("Wrong reference source.", updatedPcSource, newRefObject.getString("source")); - assertEquals("Wrong reference target.", updatedPcTarget, newRefObject.getString("target")); - } - - public void testGetCustomProperties() throws Exception - { - getCustomProperties(); - } - - private String getCustomProperties() throws Exception, IOException, - UnsupportedEncodingException, JSONException - { - // Ensure that there is at least one custom property. - this.testPostCustomPropertyDefinition(); - - final int expectedStatus = 200; - Response rsp = sendRequest(new GetRequest("/api/rma/admin/custompropertydefinitions?element=record"), expectedStatus); - - String contentAsString = rsp.getContentAsString(); -// System.out.println(contentAsString); - JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); - - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - JSONObject customPropsObj = (JSONObject)dataObj.get("customProperties"); - assertNotNull("JSON 'customProperties' object was null", customPropsObj); - - final int customPropsCount = customPropsObj.length(); - assertTrue("There should be at least one custom property. Found " + customPropsObj, customPropsCount > 0); - - return contentAsString; - } - - public void testGetRecordMetaDataAspects() throws Exception - { - Response rsp = sendRequest(new GetRequest("/api/rma/recordmetadataaspects"), 200); - String contentAsString = rsp.getContentAsString(); - System.out.println(contentAsString); - JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); - - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - - JSONArray aspects = dataObj.getJSONArray("recordMetaDataAspects"); - assertNotNull(aspects); - assertEquals(4, aspects.length()); - - // TODO test the items themselves - } - - public void testExport() throws Exception - { - String exportUrl = "/api/rma/admin/export"; - - // define JSON POST body - JSONObject jsonPostData = new JSONObject(); - JSONArray nodeRefs = new JSONArray(); - nodeRefs.put(recordFolder.toString()); - nodeRefs.put(recordFolder2.toString()); - jsonPostData.put("nodeRefs", nodeRefs); - String jsonPostString = jsonPostData.toString(); - - // make the export request - Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); - assertEquals("application/acp", rsp.getContentType()); - } - - public void testExportInTransferFormat() throws Exception - { - String exportUrl = "/api/rma/admin/export"; - - // define JSON POST body - JSONObject jsonPostData = new JSONObject(); - JSONArray nodeRefs = new JSONArray(); - nodeRefs.put(recordFolder.toString()); - nodeRefs.put(recordFolder2.toString()); - jsonPostData.put("nodeRefs", nodeRefs); - jsonPostData.put("transferFormat", true); - String jsonPostString = jsonPostData.toString(); - - // make the export request - Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); - assertEquals("application/zip", rsp.getContentType()); - } - - public void testAudit() throws Exception - { - // call the list service to get audit events - Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); - //System.out.println("GET : " + rsp.getContentAsString()); - assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - - // get response as JSON and check - JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertNotNull(jsonParsedObject); - JSONObject data = jsonParsedObject.getJSONObject("data"); - JSONObject events = data.getJSONObject("auditEvents"); - JSONArray items = events.getJSONArray("items"); - assertEquals(auditService.getAuditEvents().size(), items.length()); - assertTrue(items.length() > 0); - JSONObject item = items.getJSONObject(0); - assertTrue(item.length() == 2); - assertTrue(item.has("label")); - assertTrue(item.has("value")); - - // get the full RM audit log and check response - rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL), 200); - assertEquals("application/json", rsp.getContentType()); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - // get the full RM audit log as an HTML report and check response - rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?format=html"), 200); - assertEquals("text/html", rsp.getContentType()); - - // export the full RM audit log and check response - rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?export=true"), 200); - assertEquals("application/json", rsp.getContentType()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - // construct the URL - String nodeUrl = recordCategory.toString().replace("://", "/"); - String auditUrl = MessageFormat.format(GET_NODE_AUDITLOG_URL_FORMAT, nodeUrl); - - // send request - rsp = sendRequest(new GetRequest(auditUrl), 200); - // check response - assertEquals("application/json", rsp.getContentType()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - // get the audit log with all restrictions in place - String filteredAuditUrl = auditUrl + "?user=gavinc&size=5&from=2009-01-01&to=2009-12-31&event=Login"; - rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); - // check response - assertEquals("application/json", rsp.getContentType()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - // attempt to get the audit log with invalid restrictions in place - filteredAuditUrl = auditUrl + "?user=fred&size=abc&from=2009&to=2010&property=wrong"; - rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); - assertEquals("application/json", rsp.getContentType()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - - checkAuditStatus(true); - - // start the RM audit log - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("enabled", true); - String jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - - checkAuditStatus(true); - - // check the response - //System.out.println(rsp.getContentAsString()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - JSONObject dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - assertTrue(dataObj.getBoolean("enabled")); - assertTrue(dataObj.has("started")); - assertTrue(dataObj.has("stopped")); - - // stop the RM audit log - jsonPostData = new JSONObject(); - jsonPostData.put("enabled", false); - jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - - checkAuditStatus(false); - - // check the response - //System.out.println(rsp.getContentAsString()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - assertFalse(dataObj.getBoolean("enabled")); - - // clear the RM audit log - rsp = sendRequest(new DeleteRequest(RMA_AUDITLOG_URL), 200); - //System.out.println(rsp.getContentAsString()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - dataObj = (JSONObject)jsonRsp.get("data"); - assertNotNull("JSON 'data' object was null", dataObj); - assertFalse(dataObj.getBoolean("enabled")); - } - - private void checkAuditStatus(boolean expected) throws Exception - { - Response rsp = sendRequest(new GetRequest(RMA_AUDITLOG_STATUS_URL), 200); - JSONObject rspObj = new JSONObject(rsp.getContentAsString()); - JSONObject data = rspObj.getJSONObject("data"); - boolean enabled = data.getBoolean("enabled"); - assertEquals("Audit log status does not match expected status.", expected, enabled); - - } - - public void testFileAuditLogAsRecord() throws Exception - { - // Attempt to store audit log at non existent destination, make sure we get 404 - JSONObject jsonPostData = new JSONObject(); - jsonPostData.put("destination", "workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); - String jsonPostString = jsonPostData.toString(); - Response rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 404); - - // Attempt to store audit log at wrong type of destination, make sure we get 400 - jsonPostData = new JSONObject(); - jsonPostData.put("destination", recordCategory.toString()); - jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 400); - - - // Store the full audit log as a record - jsonPostData = new JSONObject(); - jsonPostData.put("destination", recordFolder2); - jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - - // check the response - System.out.println(rsp.getContentAsString()); - JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertTrue(jsonRsp.has("success")); - assertTrue(jsonRsp.getBoolean("success")); - assertTrue(jsonRsp.has("record")); - assertNotNull(jsonRsp.get("record")); - assertTrue(nodeService.exists(new NodeRef(jsonRsp.getString("record")))); - assertTrue(jsonRsp.has("recordName")); - assertNotNull(jsonRsp.get("recordName")); - assertTrue(jsonRsp.getString("recordName").startsWith("audit_")); - - // Store a filtered audit log as a record - jsonPostData = new JSONObject(); - jsonPostData.put("destination", recordFolder2); - jsonPostData.put("size", "50"); - jsonPostData.put("user", "gavinc"); - jsonPostData.put("event", "Update Metadata"); - jsonPostData.put("property", "{http://www.alfresco.org/model/content/1.0}modified"); - jsonPostString = jsonPostData.toString(); - rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - - // check the response - System.out.println(rsp.getContentAsString()); - jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - assertTrue(jsonRsp.has("success")); - assertTrue(jsonRsp.getBoolean("success")); - assertTrue(jsonRsp.has("record")); - assertNotNull(jsonRsp.get("record")); - assertTrue(nodeService.exists(new NodeRef(jsonRsp.getString("record")))); - assertTrue(jsonRsp.has("recordName")); - assertNotNull(jsonRsp.get("recordName")); - assertTrue(jsonRsp.getString("recordName").startsWith("audit_")); - } - - public void testPropertyLabelWithAccentedChars() throws Exception - { - final long number = System.currentTimeMillis(); - - // Create a property with a simple name - final String simplePropId = "simpleId" + number; - postCustomPropertyDefinition("simple", simplePropId); - - // Create a property whose name has accented chars - final String originalAccentedLabel = "øoê≈çœ"; - final String accentedPropId = "accentedId" + number; - postCustomPropertyDefinition(originalAccentedLabel, accentedPropId); - - // We'll update the label on the simple-name property a few times. - // This will cause the repeated read and write of the entire RM custom model xml file - // This should also leave the accented-char property unchanged. - putCustomPropDefinition("one", simplePropId); - putCustomPropDefinition("two", simplePropId); - putCustomPropDefinition("three", simplePropId); - putCustomPropDefinition("four", simplePropId); - putCustomPropDefinition("five", simplePropId); - - // Now get all the custom properties back. - String rspContent = getCustomProperties(); - - JSONObject rspObject = new JSONObject(new JSONTokener(rspContent)); - JSONObject dataObj = rspObject.getJSONObject("data"); - assertNotNull("jsonObject was null", dataObj); - - JSONObject customPropertiesObj = dataObj.getJSONObject("customProperties"); - assertNotNull("customPropertiesObj was null", customPropertiesObj); - - JSONObject accentedPropertyObj = customPropertiesObj.getJSONObject(RecordsManagementCustomModel.RM_CUSTOM_PREFIX - + ":" + accentedPropId); - assertNotNull("accentedPropertyObj was null", accentedPropertyObj); - - String labelObj = accentedPropertyObj.getString("label"); - assertEquals("labelObj was changed.", originalAccentedLabel, labelObj); - } - - private void putCustomPropDefinition(String label, String id) throws JSONException, IOException, - UnsupportedEncodingException - { - String jsonString = new JSONStringer().object() - .key("label").value(label) - .endObject() - .toString(); - - String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + id; - Response rsp = sendRequest(new PutRequest(propDefnUrl, - jsonString, APPLICATION_JSON), 200); - - String rspContent = rsp.getContentAsString(); -// System.out.println(rspContent); - - JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); - String urlOfNewPropDef = jsonRsp.getString("url"); - assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.text.MessageFormat; +import java.util.Date; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.TestActionParams; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONStringer; +import org.json.JSONTokener; +import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * This class tests the Rest API for RM. + * + * @author Neil McErlean + */ +public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel +{ + protected static final String GET_NODE_AUDITLOG_URL_FORMAT = "/api/node/{0}/rmauditlog"; + protected static final String GET_TRANSFER_URL_FORMAT = "/api/node/{0}/transfers/{1}"; + protected static final String TRANSFER_REPORT_URL_FORMAT = "/api/node/{0}/transfers/{1}/report"; + protected static final String REF_INSTANCES_URL_FORMAT = "/api/node/{0}/customreferences"; + protected static final String RMA_AUDITLOG_URL = "/api/rma/admin/rmauditlog"; + protected static final String RMA_AUDITLOG_STATUS_URL = "/api/rma/admin/rmauditlog/status"; + protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues"; + protected static final String RMA_ACTIONS_URL = "/api/rma/actions/ExecutionQueue"; + protected static final String APPLICATION_JSON = "application/json"; + protected static final String RMA_CUSTOM_PROPS_DEFINITIONS_URL = "/api/rma/admin/custompropertydefinitions"; + protected static final String RMA_CUSTOM_REFS_DEFINITIONS_URL = "/api/rma/admin/customreferencedefinitions"; + + private static final String BI_DI = "BiDi"; + private static final String CHILD_SRC = "childSrc"; + private static final String CHILD_TGT = "childTgt"; + + /** + * This test method ensures that a POST of an RM action to a non-existent node + * will result in a 404 status. + * + * @throws Exception + */ + public void testPostActionToNonExistentNode() throws Exception + { + NodeRef nonExistentNode = new NodeRef("workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); + + // Construct the JSON request. + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("nodeRef", nonExistentNode.toString()); + // Although the request specifies a 'reviewed' action, it does not matter what + // action is specified here, as the non-existent Node should trigger a 404 + // before the action is executed. + jsonPostData.put("name", "reviewed"); + + // Submit the JSON request. + String jsonPostString = jsonPostData.toString(); + + final int expectedStatus = 404; + sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonPostString, APPLICATION_JSON), expectedStatus); + } + + public void testPostReviewedAction() throws IOException, JSONException + { + NodeRef testRecord = utils.createRecord(recordFolder, "test.txt"); + + // In this test, this property has a date-value equal to the model import time. + Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); + + // Construct the JSON request for 'reviewed'. + String jsonString = new JSONStringer().object() + .key("name").value("reviewed") + .key("nodeRef").value(testRecord.toString()) + // These JSON params are just to test the submission of params. They'll be ignored. + .key("params").object() + .key("param1").value("one") + .key("param2").value("two") + .endObject() + .endObject() + .toString(); + + // Submit the JSON request. + final int expectedStatus = 200; + Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, + jsonString, APPLICATION_JSON), expectedStatus); + + String rspContent = rsp.getContentAsString(); + assertTrue(rspContent.contains("Successfully queued action [reviewed]")); + + Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); + assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, + pristineReviewAsOf.equals(newReviewAsOfDate)); + } + + public void testPostMultiReviewedAction() throws IOException, JSONException + { + NodeRef testRecord = utils.createRecord(recordFolder, "test1.txt"); + NodeRef testRecord2 = utils.createRecord(recordFolder, "test2.txt"); + NodeRef testRecord3 = utils.createRecord(recordFolder, "test3.txt"); + + // In this test, this property has a date-value equal to the model import time. + Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); + Serializable pristineReviewAsOf2 = this.nodeService.getProperty(testRecord2, PROP_REVIEW_AS_OF); + Serializable pristineReviewAsOf3 = this.nodeService.getProperty(testRecord3, PROP_REVIEW_AS_OF); + + // Construct the JSON request for 'reviewed'. + String jsonString = new JSONStringer().object() + .key("name").value("reviewed") + .key("nodeRefs").array() + .value(testRecord.toString()) + .value(testRecord2.toString()) + .value(testRecord3.toString()) + .endArray() + // These JSON params are just to test the submission of params. They'll be ignored. + .key("params").object() + .key("param1").value("one") + .key("param2").value("two") + .endObject() + .endObject() + .toString(); + + // Submit the JSON request. + final int expectedStatus = 200; + Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, + jsonString, APPLICATION_JSON), expectedStatus); + + String rspContent = rsp.getContentAsString(); + assertTrue(rspContent.contains("Successfully queued action [reviewed]")); + + Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); + assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, + pristineReviewAsOf.equals(newReviewAsOfDate)); + Serializable newReviewAsOfDate2 = this.nodeService.getProperty(testRecord2, PROP_REVIEW_AS_OF); + assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf2, + pristineReviewAsOf2.equals(newReviewAsOfDate2)); + Serializable newReviewAsOfDate3 = this.nodeService.getProperty(testRecord3, PROP_REVIEW_AS_OF); + assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf3, + pristineReviewAsOf3.equals(newReviewAsOfDate3)); + } + + public void testActionParams() throws Exception + { + // Construct the JSON request for 'reviewed'. + String jsonString = new JSONStringer().object() + .key("name").value("testActionParams") + .key("nodeRef").array() + .value("nothing://nothing/nothing") + .endArray() + // These JSON params are just to test the submission of params. They'll be ignored. + .key("params").object() + .key(TestActionParams.PARAM_DATE).object() + .key("iso8601") + .value(ISO8601DateFormat.format(new Date())) + .endObject() + .endObject() + .endObject() + .toString(); + + // Submit the JSON request. + final int expectedStatus = 200; + //TODO Currently failing unit test. + sendRequest(new PostRequest(RMA_ACTIONS_URL, + jsonString, APPLICATION_JSON), expectedStatus); + } + + public void testPostCustomReferenceDefinitions() throws IOException, JSONException + { + postCustomReferenceDefinitions(); + } + + /** + * This method creates a child and a non-child reference and returns their generated ids. + * + * + * @return String[] with element 0 = refId of p/c ref, 1 = refId pf bidi. + */ + private String[] postCustomReferenceDefinitions() throws JSONException, IOException, + UnsupportedEncodingException { + String[] result = new String[2]; + + // 1. Child association. + String jsonString = new JSONStringer().object() + .key("referenceType").value(RelationshipType.PARENTCHILD) + .key("source").value(CHILD_SRC) + .key("target").value(CHILD_TGT) + .endObject() + .toString(); + +// System.out.println(jsonString); + + // Submit the JSON request. + final int expectedStatus = 200; + Response rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, + jsonString, APPLICATION_JSON), expectedStatus); + + String rspContent = rsp.getContentAsString(); + assertTrue(rspContent.contains("success")); + +// System.out.println(rspContent); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String generatedChildRefId = jsonRsp.getJSONObject("data").getString("refId"); + result[0] = generatedChildRefId; + + // 2. Non-child or standard association. + jsonString = new JSONStringer().object() + .key("referenceType").value(RelationshipType.BIDIRECTIONAL) + .key("label").value(BI_DI) + .endObject() + .toString(); + +// System.out.println(jsonString); + + // Submit the JSON request. + rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, + jsonString, APPLICATION_JSON), expectedStatus); + + rspContent = rsp.getContentAsString(); + assertTrue(rspContent.contains("success")); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String generatedBidiRefId = jsonRsp.getJSONObject("data").getString("refId"); + result[1] = generatedBidiRefId; + + // Now assert that both have appeared in the data dictionary. + AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); + assertNotNull("Missing customAssocs aspect", customAssocsAspect); + + QName newRefQname = adminService.getQNameForClientId(generatedChildRefId); + Map associations = customAssocsAspect.getAssociations(); + assertTrue("Custom child assoc not returned by dataDictionary.", associations.containsKey(newRefQname)); + + newRefQname = adminService.getQNameForClientId(generatedBidiRefId); + assertTrue("Custom std assoc not returned by dataDictionary.", customAssocsAspect.getAssociations().containsKey(newRefQname)); + + return result; + } + + public void testPutCustomPropertyDefinition() throws Exception + { + // POST to create a property definition with a known propId + final String propertyLabel = "Original label åçîéøü"; + String propId = postCustomPropertyDefinition(propertyLabel, null); + + // PUT an updated label. + final String updatedLabel = "Updated label πø^¨¥†®"; + String jsonString = new JSONStringer().object() + .key("label").value(updatedLabel) + .endObject() + .toString(); + + String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; + Response rsp = sendRequest(new PutRequest(propDefnUrl, + jsonString, APPLICATION_JSON), 200); + + // GET from the URL again to ensure it's valid + rsp = sendRequest(new GetRequest(propDefnUrl), 200); + String rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + // PUT an updated constraint ref. + final String updatedConstraint = "rmc:tlList"; + jsonString = new JSONStringer().object() + .key("constraintRef").value(updatedConstraint) + .endObject() + .toString(); + + propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; + rsp = sendRequest(new PutRequest(propDefnUrl, + jsonString, APPLICATION_JSON), 200); + + rspContent = rsp.getContentAsString(); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String urlOfNewPropDef = jsonRsp.getString("url"); + assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); + + // GET from the URL again to ensure it's valid + rsp = sendRequest(new GetRequest(propDefnUrl), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + JSONObject customPropsObject = dataObject.getJSONObject("customProperties"); + assertNotNull("JSON customProperties object was null", customPropsObject); + assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); + + Object keyToSoleProp = customPropsObject.keys().next(); + + JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); + assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); + JSONArray constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); + assertEquals("ConstraintRefsArray wrong length.", 1, constraintRefsArray.length()); + String retrievedUpdatedTitle = constraintRefsArray.getJSONObject(0).getString("name"); + assertEquals("Constraints had wrong name.", "rmc:tlList", retrievedUpdatedTitle); + + // PUT again to remove all constraints + jsonString = new JSONStringer().object() + .key("constraintRef").value(null) + .endObject() + .toString(); + + rsp = sendRequest(new PutRequest(propDefnUrl, + jsonString, APPLICATION_JSON), 200); + + rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + + // GET from the URL again to ensure it's valid + rsp = sendRequest(new GetRequest(propDefnUrl), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + customPropsObject = dataObject.getJSONObject("customProperties"); + assertNotNull("JSON customProperties object was null", customPropsObject); + assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); + + keyToSoleProp = customPropsObject.keys().next(); + + newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); + assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); + constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); + assertEquals("ConstraintRefsArray wrong length.", 0, constraintRefsArray.length()); + + // Finally PUT a constraint on a PropertyDefn that has been cleared of constraints. + // This was raised as an issue + final String readdedConstraint = "rmc:tlList"; + jsonString = new JSONStringer().object() + .key("constraintRef").value(readdedConstraint) + .endObject() + .toString(); + + propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; + rsp = sendRequest(new PutRequest(propDefnUrl, + jsonString, APPLICATION_JSON), 200); + + rspContent = rsp.getContentAsString(); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); +// System.out.println("PUTting a constraint back again."); +// System.out.println(rspContent); + + // And GET from the URL again + rsp = sendRequest(new GetRequest(propDefnUrl), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + customPropsObject = dataObject.getJSONObject("customProperties"); + assertNotNull("JSON customProperties object was null", customPropsObject); + assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); + + keyToSoleProp = customPropsObject.keys().next(); + + newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); + assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); + constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); + assertEquals("ConstraintRefsArray wrong length.", 1, constraintRefsArray.length()); + String readdedUpdatedTitle = constraintRefsArray.getJSONObject(0).getString("name"); + assertEquals("Constraints had wrong name.", "rmc:tlList", readdedUpdatedTitle); + } + + public void testGetCustomReferences() throws IOException, JSONException + { + // Ensure that there is at least one custom reference. + postCustomReferenceDefinitions(); + + // GET all custom reference definitions + final int expectedStatus = 200; + Response rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL), expectedStatus); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + JSONArray customRefsObj = (JSONArray)dataObj.get("customReferences"); + assertNotNull("JSON 'customReferences' object was null", customRefsObj); + + assertTrue("There should be at least two custom references. Found " + customRefsObj, customRefsObj.length() >= 2); + + // GET a specific custom reference definition. + // Here, we're using one of the built-in references + // qname = rmc:versions + rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL + "/" + CUSTOM_REF_VERSIONS.getLocalName()), expectedStatus); + + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + customRefsObj = (JSONArray)dataObj.get("customReferences"); + assertNotNull("JSON 'customProperties' object was null", customRefsObj); + + assertTrue("There should be exactly 1 custom references. Found " + customRefsObj.length(), customRefsObj.length() == 1); + } + + public void testGetDodCustomTypes() throws IOException, JSONException + { + final int expectedStatus = 200; + Response rsp = sendRequest(new GetRequest("/api/rma/admin/dodcustomtypes"), expectedStatus); + + String rspContent = rsp.getContentAsString(); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + + // System.out.println(rspContent); + + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + JSONArray customTypesObj = (JSONArray)dataObj.get("dodCustomTypes"); + assertNotNull("JSON 'dodCustomTypes' object was null", customTypesObj); + + assertEquals("Wrong DOD custom types count.", 4, customTypesObj.length()); + } + + public void testGetPostAndRemoveCustomReferenceInstances() throws Exception + { + NodeRef testRecord1 = utils.createRecord(recordFolder, "testRecord1" + System.currentTimeMillis(), "The from recørd"); + NodeRef testRecord2 = utils.createRecord(recordFolder, "testRecord2" + System.currentTimeMillis(), "The to récord"); + + String node1Url = testRecord1.toString().replace("://", "/"); + String refInstancesRecord1Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node1Url); + + // Create reference types. + String[] generatedRefIds = postCustomReferenceDefinitions(); + + // Add a standard ref + String jsonString = new JSONStringer().object() + .key("toNode").value(testRecord2.toString()) + .key("refId").value(generatedRefIds[1]) + .endObject() + .toString(); + + Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, + jsonString, APPLICATION_JSON), 200); + + // Add a child ref + jsonString = new JSONStringer().object() + .key("toNode").value(testRecord2.toString()) + .key("refId").value(generatedRefIds[0]) + .endObject() + .toString(); + +// System.out.println(jsonString); + + rsp = sendRequest(new PostRequest(refInstancesRecord1Url, + jsonString, APPLICATION_JSON), 200); + +// System.out.println(rsp.getContentAsString()); + + // Now retrieve the applied references from the REST API + // 1. references on the 'from' record. + rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); + + String contentAsString = rsp.getContentAsString(); +// System.out.println(contentAsString); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); + + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + JSONArray customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); + assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); + + int customRefsCount = customRefsFromArray.length(); + assertTrue("There should be at least one custom reference. Found " + customRefsFromArray, customRefsCount > 0); + + JSONArray customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); + assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); + assertEquals("customReferencesTo wrong length.", 0, customRefsToArray.length()); + + // 2. Back-references on the 'to' record + String node2Url = testRecord2.toString().replace("://", "/"); + String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); + + rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); + + contentAsString = rsp.getContentAsString(); + + jsonRsp = new JSONObject(new JSONTokener(contentAsString)); + + dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); + assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); + + customRefsCount = customRefsToArray.length(); + assertTrue("There should be at least one custom reference. Found " + customRefsToArray, customRefsCount > 0); + + customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); + assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); + assertEquals("customReferencesFrom wrong length.", 0, customRefsFromArray.length()); + + + + // Now to delete a reference instance of each type + String protocol = testRecord2.getStoreRef().getProtocol(); + String identifier = testRecord2.getStoreRef().getIdentifier(); + String recId = testRecord2.getId(); + final String queryFormat = "?st={0}&si={1}&id={2}"; + String urlQueryString = MessageFormat.format(queryFormat, protocol, identifier, recId); + + rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" + generatedRefIds[1] + urlQueryString), 200); + assertTrue(rsp.getContentAsString().contains("success")); + + rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" + + generatedRefIds[0] + + urlQueryString), 200); + assertTrue(rsp.getContentAsString().contains("success")); + + // Get the reference instances back and confirm they've been removed. + rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); + + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); + assertNotNull("JSON 'customReferences' object was null", customRefsFromArray); + assertTrue("customRefsArray was unexpectedly not empty.", customRefsFromArray.length() == 0); + } + + public void testMob1630ShouldNotBeAbleToCreateTwoSupersedesReferencesOnOneRecordPair() throws Exception + { + // Create 2 test records. + NodeRef testRecord1 = utils.createRecord(recordFolder, "testRecord1" + System.currentTimeMillis(), "The from recørd"); + NodeRef testRecord2 = utils.createRecord(recordFolder, "testRecord2" + System.currentTimeMillis(), "The to récord"); + + String node1Url = testRecord1.toString().replace("://", "/"); + String node2Url = testRecord2.toString().replace("://", "/"); + String refInstancesRecord1Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node1Url); + String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); + + {// Sanity check. There should be no references defined on these new records. + Response rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); + + String rspContent = rsp.getContentAsString(); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObj = jsonRsp.getJSONObject("data"); + JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); + JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); + assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); + assertEquals("Incorrect to-refs count.", 0, refsTo.length()); + } + + // Add a supersedes ref instance between them + final String supersedesRefLocalName = CUSTOM_REF_SUPERSEDES.getLocalName(); + String jsonString = new JSONStringer().object() + .key("toNode").value(testRecord2.toString()) + .key("refId").value(supersedesRefLocalName) + .endObject() + .toString(); + + Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, + jsonString, APPLICATION_JSON), 200); + + // The bug is that we can apply two such references which should not be allowed + rsp = sendRequest(new PostRequest(refInstancesRecord1Url, + jsonString, APPLICATION_JSON), 500); + + {// Retrieve reference instances on this pair of records. + // The first record + rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); + + String rspContent = rsp.getContentAsString(); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObj = jsonRsp.getJSONObject("data"); + JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); + JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); + assertEquals("Incorrect from-refs count.", 1, refsFrom.length()); + assertEquals("Incorrect to-refs count.", 0, refsTo.length()); + + // The second record - the back-reference + rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); + + rspContent = rsp.getContentAsString(); + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + dataObj = jsonRsp.getJSONObject("data"); + refsFrom = dataObj.getJSONArray("customReferencesFrom"); + refsTo = dataObj.getJSONArray("customReferencesTo"); + assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); + assertEquals("Incorrect to-refs count.", 1, refsTo.length()); + } + + // Delete the reference instance + String protocol = testRecord2.getStoreRef().getProtocol(); + String identifier = testRecord2.getStoreRef().getIdentifier(); + String recId = testRecord2.getId(); + final String queryFormat = "?st={0}&si={1}&id={2}"; + String urlQueryString = MessageFormat.format(queryFormat, protocol, identifier, recId); + + rsp = sendRequest(new DeleteRequest(refInstancesRecord1Url + "/" + supersedesRefLocalName + urlQueryString), 200); + assertTrue(rsp.getContentAsString().contains("success")); + + {// Retrieve reference instances on this pair of records. + // The first record + rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); + + String rspContent = rsp.getContentAsString(); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObj = jsonRsp.getJSONObject("data"); + JSONArray refsFrom = dataObj.getJSONArray("customReferencesFrom"); + JSONArray refsTo = dataObj.getJSONArray("customReferencesTo"); + assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); + assertEquals("Incorrect to-refs count.", 0, refsTo.length()); + + // The second record - the back-reference + rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); + + rspContent = rsp.getContentAsString(); + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + dataObj = jsonRsp.getJSONObject("data"); + refsFrom = dataObj.getJSONArray("customReferencesFrom"); + refsTo = dataObj.getJSONArray("customReferencesTo"); + assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); + assertEquals("Incorrect to-refs count.", 0, refsTo.length()); + } + } + + public void testPostCustomPropertyDefinition() throws Exception + { + long currentTimeMillis = System.currentTimeMillis(); + + // Create one with no propId - it'll get generated. + postCustomPropertyDefinition("customProperty" + currentTimeMillis, null); + + // Create another with an explicit propId. + postCustomPropertyDefinition("customProperty" + currentTimeMillis, "prop" + currentTimeMillis); + } + + /** + * Creates a new property definition using a POST call. + * GETs the resultant property definition. + * + * @param propertyLabel the label to use + * @param propId the propId to use - null to have one generated. + * @return the propId of the new property definition + */ + private String postCustomPropertyDefinition(String propertyLabel, String propId) throws JSONException, + IOException, UnsupportedEncodingException + { + String jsonString; + if (propId == null) + { + jsonString = new JSONStringer().object() + .key("label").value(propertyLabel) + .key("description").value("Dynamically defined test property") + .key("mandatory").value(false) + .key("dataType").value("d:text") + .key("element").value("record") + .key("constraintRef").value("rmc:smList") + // Note no propId + .endObject() + .toString(); + } + else + { + jsonString = new JSONStringer().object() + .key("label").value(propertyLabel) + .key("description").value("Dynamically defined test property") + .key("mandatory").value(false) + .key("dataType").value("d:text") + .key("element").value("record") + .key("constraintRef").value("rmc:smList") + .key("propId").value(propId) + .endObject() + .toString(); + } + + // Submit the JSON request. + final int expectedStatus = 200; + Response rsp = sendRequest(new PostRequest("/api/rma/admin/custompropertydefinitions?element=record", + jsonString, APPLICATION_JSON), expectedStatus); + + String rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String urlOfNewPropDef = jsonRsp.getString("url"); + String newPropId = jsonRsp.getString("propId"); + + assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); + + // GET from the URL we're given to ensure it's valid + rsp = sendRequest(new GetRequest(urlOfNewPropDef), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + JSONObject customPropsObject = dataObject.getJSONObject("customProperties"); + assertNotNull("JSON customProperties object was null", customPropsObject); + assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); + + Object keyToSoleProp = customPropsObject.keys().next(); + +// System.out.println("New property defn: " + keyToSoleProp); + + JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); + assertEquals("Wrong property label.", propertyLabel, newPropObject.getString("label")); + + return newPropId; + } + + public void testPutCustomReferenceDefinition() throws Exception + { + String[] generatedRefIds = postCustomReferenceDefinitions(); + final String pcRefId = generatedRefIds[0]; + final String bidiRefId = generatedRefIds[1]; + + // GET the custom refs in order to retrieve the label/source/target + String refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; + Response rsp = sendRequest(new GetRequest(refDefnUrl), 200); + + String rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; + rsp = sendRequest(new GetRequest(refDefnUrl), 200); + + rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + + // Update the bidirectional reference. + final String updatedBiDiLabel = "Updated label üøéîçå"; + String jsonString = new JSONStringer().object() + .key("label").value(updatedBiDiLabel) + .endObject() + .toString(); + + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; + rsp = sendRequest(new PutRequest(refDefnUrl, + jsonString, APPLICATION_JSON), 200); + + rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String urlOfNewRefDef = jsonRsp.getString("url"); + assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); + + // GET the bidi reference to ensure it's valid + rsp = sendRequest(new GetRequest(refDefnUrl), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + JSONArray customRefsObject = dataObject.getJSONArray("customReferences"); + assertNotNull("JSON customReferences object was null", customRefsObject); + assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); + + JSONObject newRefObject = customRefsObject.getJSONObject(0); + assertEquals("Wrong property label.", updatedBiDiLabel, newRefObject.getString("label")); + + // Update the parent/child reference. + final String updatedPcSource = "Updated source ∆Ωç√∫"; + final String updatedPcTarget = "Updated target ∆Ωç√∫"; + jsonString = new JSONStringer().object() + .key("source").value(updatedPcSource) + .key("target").value(updatedPcTarget) + .endObject() + .toString(); + + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; + rsp = sendRequest(new PutRequest(refDefnUrl, + jsonString, APPLICATION_JSON), 200); + + rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + urlOfNewRefDef = jsonRsp.getString("url"); + assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); + + // GET the parent/child reference to ensure it's valid + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; + + rsp = sendRequest(new GetRequest(refDefnUrl), 200); + rspContent = rsp.getContentAsString(); + +// System.out.println(rspContent); + + jsonRsp = new JSONObject(new JSONTokener(rspContent)); + dataObject = jsonRsp.getJSONObject("data"); + assertNotNull("JSON data object was null", dataObject); + customRefsObject = dataObject.getJSONArray("customReferences"); + assertNotNull("JSON customReferences object was null", customRefsObject); + assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); + + newRefObject = customRefsObject.getJSONObject(0); + assertEquals("Wrong reference source.", updatedPcSource, newRefObject.getString("source")); + assertEquals("Wrong reference target.", updatedPcTarget, newRefObject.getString("target")); + } + + public void testGetCustomProperties() throws Exception + { + getCustomProperties(); + } + + private String getCustomProperties() throws Exception, IOException, + UnsupportedEncodingException, JSONException + { + // Ensure that there is at least one custom property. + this.testPostCustomPropertyDefinition(); + + final int expectedStatus = 200; + Response rsp = sendRequest(new GetRequest("/api/rma/admin/custompropertydefinitions?element=record"), expectedStatus); + + String contentAsString = rsp.getContentAsString(); +// System.out.println(contentAsString); + JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); + + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + JSONObject customPropsObj = (JSONObject)dataObj.get("customProperties"); + assertNotNull("JSON 'customProperties' object was null", customPropsObj); + + final int customPropsCount = customPropsObj.length(); + assertTrue("There should be at least one custom property. Found " + customPropsObj, customPropsCount > 0); + + return contentAsString; + } + + public void testGetRecordMetaDataAspects() throws Exception + { + Response rsp = sendRequest(new GetRequest("/api/rma/recordmetadataaspects"), 200); + String contentAsString = rsp.getContentAsString(); + System.out.println(contentAsString); + JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); + + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + + JSONArray aspects = dataObj.getJSONArray("recordMetaDataAspects"); + assertNotNull(aspects); + assertEquals(4, aspects.length()); + + // TODO test the items themselves + } + + public void testExport() throws Exception + { + String exportUrl = "/api/rma/admin/export"; + + // define JSON POST body + JSONObject jsonPostData = new JSONObject(); + JSONArray nodeRefs = new JSONArray(); + nodeRefs.put(recordFolder.toString()); + nodeRefs.put(recordFolder2.toString()); + jsonPostData.put("nodeRefs", nodeRefs); + String jsonPostString = jsonPostData.toString(); + + // make the export request + Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); + assertEquals("application/acp", rsp.getContentType()); + } + + public void testExportInTransferFormat() throws Exception + { + String exportUrl = "/api/rma/admin/export"; + + // define JSON POST body + JSONObject jsonPostData = new JSONObject(); + JSONArray nodeRefs = new JSONArray(); + nodeRefs.put(recordFolder.toString()); + nodeRefs.put(recordFolder2.toString()); + jsonPostData.put("nodeRefs", nodeRefs); + jsonPostData.put("transferFormat", true); + String jsonPostString = jsonPostData.toString(); + + // make the export request + Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); + assertEquals("application/zip", rsp.getContentType()); + } + + public void testAudit() throws Exception + { + // call the list service to get audit events + Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); + //System.out.println("GET : " + rsp.getContentAsString()); + assertEquals("application/json;charset=UTF-8", rsp.getContentType()); + + // get response as JSON and check + JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertNotNull(jsonParsedObject); + JSONObject data = jsonParsedObject.getJSONObject("data"); + JSONObject events = data.getJSONObject("auditEvents"); + JSONArray items = events.getJSONArray("items"); + assertEquals(auditService.getAuditEvents().size(), items.length()); + assertTrue(items.length() > 0); + JSONObject item = items.getJSONObject(0); + assertTrue(item.length() == 2); + assertTrue(item.has("label")); + assertTrue(item.has("value")); + + // get the full RM audit log and check response + rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL), 200); + assertEquals("application/json", rsp.getContentType()); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + // get the full RM audit log as an HTML report and check response + rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?format=html"), 200); + assertEquals("text/html", rsp.getContentType()); + + // export the full RM audit log and check response + rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?export=true"), 200); + assertEquals("application/json", rsp.getContentType()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + // construct the URL + String nodeUrl = recordCategory.toString().replace("://", "/"); + String auditUrl = MessageFormat.format(GET_NODE_AUDITLOG_URL_FORMAT, nodeUrl); + + // send request + rsp = sendRequest(new GetRequest(auditUrl), 200); + // check response + assertEquals("application/json", rsp.getContentType()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + // get the audit log with all restrictions in place + String filteredAuditUrl = auditUrl + "?user=gavinc&size=5&from=2009-01-01&to=2009-12-31&event=Login"; + rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); + // check response + assertEquals("application/json", rsp.getContentType()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + // attempt to get the audit log with invalid restrictions in place + filteredAuditUrl = auditUrl + "?user=fred&size=abc&from=2009&to=2010&property=wrong"; + rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); + assertEquals("application/json", rsp.getContentType()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + + checkAuditStatus(true); + + // start the RM audit log + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("enabled", true); + String jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); + + checkAuditStatus(true); + + // check the response + //System.out.println(rsp.getContentAsString()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + assertTrue(dataObj.getBoolean("enabled")); + assertTrue(dataObj.has("started")); + assertTrue(dataObj.has("stopped")); + + // stop the RM audit log + jsonPostData = new JSONObject(); + jsonPostData.put("enabled", false); + jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); + + checkAuditStatus(false); + + // check the response + //System.out.println(rsp.getContentAsString()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + assertFalse(dataObj.getBoolean("enabled")); + + // clear the RM audit log + rsp = sendRequest(new DeleteRequest(RMA_AUDITLOG_URL), 200); + //System.out.println(rsp.getContentAsString()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + dataObj = (JSONObject)jsonRsp.get("data"); + assertNotNull("JSON 'data' object was null", dataObj); + assertFalse(dataObj.getBoolean("enabled")); + } + + private void checkAuditStatus(boolean expected) throws Exception + { + Response rsp = sendRequest(new GetRequest(RMA_AUDITLOG_STATUS_URL), 200); + JSONObject rspObj = new JSONObject(rsp.getContentAsString()); + JSONObject data = rspObj.getJSONObject("data"); + boolean enabled = data.getBoolean("enabled"); + assertEquals("Audit log status does not match expected status.", expected, enabled); + + } + + public void testFileAuditLogAsRecord() throws Exception + { + // Attempt to store audit log at non existent destination, make sure we get 404 + JSONObject jsonPostData = new JSONObject(); + jsonPostData.put("destination", "workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); + String jsonPostString = jsonPostData.toString(); + Response rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 404); + + // Attempt to store audit log at wrong type of destination, make sure we get 400 + jsonPostData = new JSONObject(); + jsonPostData.put("destination", recordCategory.toString()); + jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 400); + + + // Store the full audit log as a record + jsonPostData = new JSONObject(); + jsonPostData.put("destination", recordFolder2); + jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); + + // check the response + System.out.println(rsp.getContentAsString()); + JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertTrue(jsonRsp.has("success")); + assertTrue(jsonRsp.getBoolean("success")); + assertTrue(jsonRsp.has("record")); + assertNotNull(jsonRsp.get("record")); + assertTrue(nodeService.exists(new NodeRef(jsonRsp.getString("record")))); + assertTrue(jsonRsp.has("recordName")); + assertNotNull(jsonRsp.get("recordName")); + assertTrue(jsonRsp.getString("recordName").startsWith("audit_")); + + // Store a filtered audit log as a record + jsonPostData = new JSONObject(); + jsonPostData.put("destination", recordFolder2); + jsonPostData.put("size", "50"); + jsonPostData.put("user", "gavinc"); + jsonPostData.put("event", "Update Metadata"); + jsonPostData.put("property", "{http://www.alfresco.org/model/content/1.0}modified"); + jsonPostString = jsonPostData.toString(); + rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); + + // check the response + System.out.println(rsp.getContentAsString()); + jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); + assertTrue(jsonRsp.has("success")); + assertTrue(jsonRsp.getBoolean("success")); + assertTrue(jsonRsp.has("record")); + assertNotNull(jsonRsp.get("record")); + assertTrue(nodeService.exists(new NodeRef(jsonRsp.getString("record")))); + assertTrue(jsonRsp.has("recordName")); + assertNotNull(jsonRsp.get("recordName")); + assertTrue(jsonRsp.getString("recordName").startsWith("audit_")); + } + + public void testPropertyLabelWithAccentedChars() throws Exception + { + final long number = System.currentTimeMillis(); + + // Create a property with a simple name + final String simplePropId = "simpleId" + number; + postCustomPropertyDefinition("simple", simplePropId); + + // Create a property whose name has accented chars + final String originalAccentedLabel = "øoê≈çœ"; + final String accentedPropId = "accentedId" + number; + postCustomPropertyDefinition(originalAccentedLabel, accentedPropId); + + // We'll update the label on the simple-name property a few times. + // This will cause the repeated read and write of the entire RM custom model xml file + // This should also leave the accented-char property unchanged. + putCustomPropDefinition("one", simplePropId); + putCustomPropDefinition("two", simplePropId); + putCustomPropDefinition("three", simplePropId); + putCustomPropDefinition("four", simplePropId); + putCustomPropDefinition("five", simplePropId); + + // Now get all the custom properties back. + String rspContent = getCustomProperties(); + + JSONObject rspObject = new JSONObject(new JSONTokener(rspContent)); + JSONObject dataObj = rspObject.getJSONObject("data"); + assertNotNull("jsonObject was null", dataObj); + + JSONObject customPropertiesObj = dataObj.getJSONObject("customProperties"); + assertNotNull("customPropertiesObj was null", customPropertiesObj); + + JSONObject accentedPropertyObj = customPropertiesObj.getJSONObject(RecordsManagementCustomModel.RM_CUSTOM_PREFIX + + ":" + accentedPropId); + assertNotNull("accentedPropertyObj was null", accentedPropertyObj); + + String labelObj = accentedPropertyObj.getString("label"); + assertEquals("labelObj was changed.", originalAccentedLabel, labelObj); + } + + private void putCustomPropDefinition(String label, String id) throws JSONException, IOException, + UnsupportedEncodingException + { + String jsonString = new JSONStringer().object() + .key("label").value(label) + .endObject() + .toString(); + + String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + id; + Response rsp = sendRequest(new PutRequest(propDefnUrl, + jsonString, APPLICATION_JSON), 200); + + String rspContent = rsp.getContentAsString(); +// System.out.println(rspContent); + + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); + String urlOfNewPropDef = jsonRsp.getString("url"); + assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RoleRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RoleRestApiTest.java index 95a985998c..9b07611008 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RoleRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RoleRestApiTest.java @@ -1,367 +1,367 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.util.GUID; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * This class tests the Rest API for disposition related operations - * - * @author Roy Wetherall - */ -public class RoleRestApiTest extends BaseRMWebScriptTestCase - implements RecordsManagementModel -{ - protected static final String GET_ROLES_URL_BY_SITE = "/api/rma/admin/{0}/rmroles"; - protected static final String GET_ROLES_URL_BY_FILEPLAN = "/api/rma/admin/{0}/{1}/{2}/rmroles"; - protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; - protected static final String APPLICATION_JSON = "application/json"; - - private String getRolesUrlBySite() - { - return MessageFormat.format(GET_ROLES_URL_BY_SITE, siteId); - } - - private String getRoleUrlByFilePlan() - { - return MessageFormat.format(GET_ROLES_URL_BY_FILEPLAN, filePlan.getStoreRef().getProtocol(), filePlan.getStoreRef().getIdentifier(), filePlan.getId()); - } - - public void testGetRoles() throws Exception - { - String role1 = GUID.generate(); - String role2 = GUID.generate(); - String role3 = GUID.generate(); - - // Create a couple or roles by hand - filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); - filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5)); - - //The user can either enter a plain text label or a key to look up in a property file. - filePlanRoleService.createRole(filePlan, role3, "System Administrator", getListOfCapabilities(5)); - - // create test group - String groupName = GUID.generate(); - String group = authorityService.createAuthority(AuthorityType.GROUP, groupName, "monkey", null); - - // Add the admin user to one of the roles - filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin"); - filePlanRoleService.assignRoleToAuthority(filePlan, role1, group); - - try - { - // Get the roles (for the default file plan) - Response rsp = sendRequest(new GetRequest(getRolesUrlBySite()),200); - String rspContent = rsp.getContentAsString(); - - JSONObject obj = new JSONObject(rspContent); - JSONObject roles = obj.getJSONObject("data"); - assertNotNull(roles); - - JSONObject roleObj = roles.getJSONObject(role1); - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("My Test Role", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - roleObj = roles.getJSONObject(role2); - assertNotNull(roleObj); - assertEquals(role2, roleObj.get("name")); - assertEquals("My Test Role Too", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - //Custom role with a user entered message key - roleObj = roles.getJSONObject(role3); - assertNotNull(roleObj); - assertEquals(role3, roleObj.get("name")); - assertEquals("System Administrator", roleObj.get("displayLabel")); - - // Get the roles, specifying the file plan - rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan()),200); - rspContent = rsp.getContentAsString(); - - obj = new JSONObject(rspContent); - roles = obj.getJSONObject("data"); - assertNotNull(roles); - - roleObj = roles.getJSONObject(role1); - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("My Test Role", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - roleObj = roles.getJSONObject(role2); - assertNotNull(roleObj); - assertEquals(role2, roleObj.get("name")); - assertEquals("My Test Role Too", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - // Get the roles for "admin" - rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "?user=admin"),200); - rspContent = rsp.getContentAsString(); - - obj = new JSONObject(rspContent); - roles = obj.getJSONObject("data"); - assertNotNull(roles); - - roleObj = roles.getJSONObject(role1); - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("My Test Role", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - assertFalse(roles.has(role2)); - - // Get the roles including assigned authorities - rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan() + "?auths=true"),200); - rspContent = rsp.getContentAsString(); - - System.out.println(rspContent); - - obj = new JSONObject(rspContent); - roles = obj.getJSONObject("data"); - assertNotNull(roles); - - roleObj = roles.getJSONObject(role1); - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("My Test Role", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - JSONArray users = roleObj.getJSONArray("assignedUsers"); - assertNotNull(users); - assertEquals(1, users.length()); - - JSONArray groups = roleObj.getJSONArray("assignedGroups"); - assertNotNull(groups); - assertEquals(1, groups.length()); - - roleObj = roles.getJSONObject(role2); - assertNotNull(roleObj); - assertEquals(role2, roleObj.get("name")); - assertEquals("My Test Role Too", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - users = roleObj.getJSONArray("assignedUsers"); - assertNotNull(users); - assertEquals(0, users.length()); - - groups = roleObj.getJSONArray("assignedGroups"); - assertNotNull(groups); - assertEquals(0, groups.length()); - } - finally - { - // Clean up - filePlanRoleService.deleteRole(filePlan, role1); - filePlanRoleService.deleteRole(filePlan, role2); - } - - } - - @SuppressWarnings("unchecked") - private void checkCapabilities(JSONObject role, int expectedCount) throws JSONException - { - JSONObject capabilities = role.getJSONObject("capabilities"); - assertNotNull(capabilities); - - int count = 0; - Iterator it = capabilities.keys(); - while (it.hasNext()) - { - String key = it.next(); - assertNotNull(key); - assertNotNull(capabilities.getString(key)); - count ++; - } - - assertEquals(expectedCount, count); - } - - public void testPostRoles() throws Exception - { - Set caps = getListOfCapabilities(5); - JSONArray arrCaps = new JSONArray(); - for (Capability cap : caps) - { - arrCaps.put(cap.getName()); - } - - String roleName = GUID.generate(); - - JSONObject obj = new JSONObject(); - obj.put("name", roleName); - obj.put("displayLabel", "Display Label"); - obj.put("capabilities", arrCaps); - - Response rsp = sendRequest(new PostRequest(getRolesUrlBySite(), obj.toString(), APPLICATION_JSON),200); - try - { - String rspContent = rsp.getContentAsString(); - - JSONObject resultObj = new JSONObject(rspContent); - JSONObject roleObj = resultObj.getJSONObject("data"); - assertNotNull(roleObj); - - assertNotNull(roleObj); - assertEquals(roleName, roleObj.get("name")); - assertEquals("Display Label", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - } - finally - { - filePlanRoleService.deleteRole(filePlan, roleName); - } - - } - - public void testPutRole() throws Exception - { - String role1 = GUID.generate(); - filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); - - try - { - Set caps = getListOfCapabilities(4,8); - JSONArray arrCaps = new JSONArray(); - for (Capability cap : caps) - { - System.out.println(cap.getName()); - arrCaps.put(cap.getName()); - } - - JSONObject obj = new JSONObject(); - obj.put("name", role1); - obj.put("displayLabel", "Changed"); - obj.put("capabilities", arrCaps); - - // Get the roles - Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON),200); - String rspContent = rsp.getContentAsString(); - - JSONObject result = new JSONObject(rspContent); - JSONObject roleObj = result.getJSONObject("data"); - assertNotNull(roleObj); - - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("Changed", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 4); - - // Bad requests - sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404); - } - finally - { - // Clean up - filePlanRoleService.deleteRole(filePlan, role1); - } - - } - - public void testGetRole() throws Exception - { - String role1 = GUID.generate(); - filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); - - try - { - // Get the roles - Response rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "/" + role1),200); - String rspContent = rsp.getContentAsString(); - - JSONObject obj = new JSONObject(rspContent); - JSONObject roleObj = obj.getJSONObject("data"); - assertNotNull(roleObj); - - assertNotNull(roleObj); - assertEquals(role1, roleObj.get("name")); - assertEquals("My Test Role", roleObj.get("displayLabel")); - checkCapabilities(roleObj, 5); - - // Bad requests - sendRequest(new GetRequest(getRolesUrlBySite() + "/cheese"), 404); - } - finally - { - // Clean up - filePlanRoleService.deleteRole(filePlan, role1); - } - - } - - public void testDeleteRole() throws Exception - { - String role1 = GUID.generate(); - assertFalse(filePlanRoleService.existsRole(filePlan, role1)); - filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); - assertTrue(filePlanRoleService.existsRole(filePlan, role1)); - sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1),200); - assertFalse(filePlanRoleService.existsRole(filePlan, role1)); - - // Bad request - sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404); - } - - private Set getListOfCapabilities(int size) - { - return getListOfCapabilities(size, 0); - } - - private Set getListOfCapabilities(int size, int offset) - { - Set result = new HashSet(size); - Set caps = capabilityService.getCapabilities(false); - int count = 0; - for (Capability cap : caps) - { - if (count < size+offset) - { - if (count >= offset) - { - result.add(cap); - } - } - else - { - break; - } - count ++; - } - return result; - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.text.MessageFormat; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.util.GUID; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * This class tests the Rest API for disposition related operations + * + * @author Roy Wetherall + */ +public class RoleRestApiTest extends BaseRMWebScriptTestCase + implements RecordsManagementModel +{ + protected static final String GET_ROLES_URL_BY_SITE = "/api/rma/admin/{0}/rmroles"; + protected static final String GET_ROLES_URL_BY_FILEPLAN = "/api/rma/admin/{0}/{1}/{2}/rmroles"; + protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; + protected static final String APPLICATION_JSON = "application/json"; + + private String getRolesUrlBySite() + { + return MessageFormat.format(GET_ROLES_URL_BY_SITE, siteId); + } + + private String getRoleUrlByFilePlan() + { + return MessageFormat.format(GET_ROLES_URL_BY_FILEPLAN, filePlan.getStoreRef().getProtocol(), filePlan.getStoreRef().getIdentifier(), filePlan.getId()); + } + + public void testGetRoles() throws Exception + { + String role1 = GUID.generate(); + String role2 = GUID.generate(); + String role3 = GUID.generate(); + + // Create a couple or roles by hand + filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); + filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5)); + + //The user can either enter a plain text label or a key to look up in a property file. + filePlanRoleService.createRole(filePlan, role3, "System Administrator", getListOfCapabilities(5)); + + // create test group + String groupName = GUID.generate(); + String group = authorityService.createAuthority(AuthorityType.GROUP, groupName, "monkey", null); + + // Add the admin user to one of the roles + filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin"); + filePlanRoleService.assignRoleToAuthority(filePlan, role1, group); + + try + { + // Get the roles (for the default file plan) + Response rsp = sendRequest(new GetRequest(getRolesUrlBySite()),200); + String rspContent = rsp.getContentAsString(); + + JSONObject obj = new JSONObject(rspContent); + JSONObject roles = obj.getJSONObject("data"); + assertNotNull(roles); + + JSONObject roleObj = roles.getJSONObject(role1); + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("My Test Role", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + roleObj = roles.getJSONObject(role2); + assertNotNull(roleObj); + assertEquals(role2, roleObj.get("name")); + assertEquals("My Test Role Too", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + //Custom role with a user entered message key + roleObj = roles.getJSONObject(role3); + assertNotNull(roleObj); + assertEquals(role3, roleObj.get("name")); + assertEquals("System Administrator", roleObj.get("displayLabel")); + + // Get the roles, specifying the file plan + rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan()),200); + rspContent = rsp.getContentAsString(); + + obj = new JSONObject(rspContent); + roles = obj.getJSONObject("data"); + assertNotNull(roles); + + roleObj = roles.getJSONObject(role1); + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("My Test Role", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + roleObj = roles.getJSONObject(role2); + assertNotNull(roleObj); + assertEquals(role2, roleObj.get("name")); + assertEquals("My Test Role Too", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + // Get the roles for "admin" + rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "?user=admin"),200); + rspContent = rsp.getContentAsString(); + + obj = new JSONObject(rspContent); + roles = obj.getJSONObject("data"); + assertNotNull(roles); + + roleObj = roles.getJSONObject(role1); + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("My Test Role", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + assertFalse(roles.has(role2)); + + // Get the roles including assigned authorities + rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan() + "?auths=true"),200); + rspContent = rsp.getContentAsString(); + + System.out.println(rspContent); + + obj = new JSONObject(rspContent); + roles = obj.getJSONObject("data"); + assertNotNull(roles); + + roleObj = roles.getJSONObject(role1); + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("My Test Role", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + JSONArray users = roleObj.getJSONArray("assignedUsers"); + assertNotNull(users); + assertEquals(1, users.length()); + + JSONArray groups = roleObj.getJSONArray("assignedGroups"); + assertNotNull(groups); + assertEquals(1, groups.length()); + + roleObj = roles.getJSONObject(role2); + assertNotNull(roleObj); + assertEquals(role2, roleObj.get("name")); + assertEquals("My Test Role Too", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + users = roleObj.getJSONArray("assignedUsers"); + assertNotNull(users); + assertEquals(0, users.length()); + + groups = roleObj.getJSONArray("assignedGroups"); + assertNotNull(groups); + assertEquals(0, groups.length()); + } + finally + { + // Clean up + filePlanRoleService.deleteRole(filePlan, role1); + filePlanRoleService.deleteRole(filePlan, role2); + } + + } + + @SuppressWarnings("unchecked") + private void checkCapabilities(JSONObject role, int expectedCount) throws JSONException + { + JSONObject capabilities = role.getJSONObject("capabilities"); + assertNotNull(capabilities); + + int count = 0; + Iterator it = capabilities.keys(); + while (it.hasNext()) + { + String key = it.next(); + assertNotNull(key); + assertNotNull(capabilities.getString(key)); + count ++; + } + + assertEquals(expectedCount, count); + } + + public void testPostRoles() throws Exception + { + Set caps = getListOfCapabilities(5); + JSONArray arrCaps = new JSONArray(); + for (Capability cap : caps) + { + arrCaps.put(cap.getName()); + } + + String roleName = GUID.generate(); + + JSONObject obj = new JSONObject(); + obj.put("name", roleName); + obj.put("displayLabel", "Display Label"); + obj.put("capabilities", arrCaps); + + Response rsp = sendRequest(new PostRequest(getRolesUrlBySite(), obj.toString(), APPLICATION_JSON),200); + try + { + String rspContent = rsp.getContentAsString(); + + JSONObject resultObj = new JSONObject(rspContent); + JSONObject roleObj = resultObj.getJSONObject("data"); + assertNotNull(roleObj); + + assertNotNull(roleObj); + assertEquals(roleName, roleObj.get("name")); + assertEquals("Display Label", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + } + finally + { + filePlanRoleService.deleteRole(filePlan, roleName); + } + + } + + public void testPutRole() throws Exception + { + String role1 = GUID.generate(); + filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); + + try + { + Set caps = getListOfCapabilities(4,8); + JSONArray arrCaps = new JSONArray(); + for (Capability cap : caps) + { + System.out.println(cap.getName()); + arrCaps.put(cap.getName()); + } + + JSONObject obj = new JSONObject(); + obj.put("name", role1); + obj.put("displayLabel", "Changed"); + obj.put("capabilities", arrCaps); + + // Get the roles + Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON),200); + String rspContent = rsp.getContentAsString(); + + JSONObject result = new JSONObject(rspContent); + JSONObject roleObj = result.getJSONObject("data"); + assertNotNull(roleObj); + + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("Changed", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 4); + + // Bad requests + sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404); + } + finally + { + // Clean up + filePlanRoleService.deleteRole(filePlan, role1); + } + + } + + public void testGetRole() throws Exception + { + String role1 = GUID.generate(); + filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); + + try + { + // Get the roles + Response rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "/" + role1),200); + String rspContent = rsp.getContentAsString(); + + JSONObject obj = new JSONObject(rspContent); + JSONObject roleObj = obj.getJSONObject("data"); + assertNotNull(roleObj); + + assertNotNull(roleObj); + assertEquals(role1, roleObj.get("name")); + assertEquals("My Test Role", roleObj.get("displayLabel")); + checkCapabilities(roleObj, 5); + + // Bad requests + sendRequest(new GetRequest(getRolesUrlBySite() + "/cheese"), 404); + } + finally + { + // Clean up + filePlanRoleService.deleteRole(filePlan, role1); + } + + } + + public void testDeleteRole() throws Exception + { + String role1 = GUID.generate(); + assertFalse(filePlanRoleService.existsRole(filePlan, role1)); + filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5)); + assertTrue(filePlanRoleService.existsRole(filePlan, role1)); + sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1),200); + assertFalse(filePlanRoleService.existsRole(filePlan, role1)); + + // Bad request + sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404); + } + + private Set getListOfCapabilities(int size) + { + return getListOfCapabilities(size, 0); + } + + private Set getListOfCapabilities(int size, int offset) + { + Set result = new HashSet(size); + Set caps = capabilityService.getCapabilities(false); + int count = 0; + for (Capability cap : caps) + { + if (count < size+offset) + { + if (count >= offset) + { + result.add(cap); + } + } + else + { + break; + } + count ++; + } + return result; + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/SubstitutionSuggestionsRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/SubstitutionSuggestionsRestApiTest.java index b83713bed9..9819ecc9f8 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/SubstitutionSuggestionsRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/SubstitutionSuggestionsRestApiTest.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API Tests for Action Definitions - * - * @author Mark Hibbins - * @since 2.2 - */ -public class SubstitutionSuggestionsRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST APIs */ - private static final String RM_SUBSTITUTIONSUGGESTIONS_URL = "/api/rm/rm-substitutionsuggestions?fragment=month"; - - /** - * Test the REST API to retrieve the list of rm substitution suggestions - * - * @throws IOException - * @throws JSONException - */ - public void testRmGetSubstitutionSuggestions() throws IOException, JSONException - { - // Send request - Response response = sendRequest(new GetRequest(RM_SUBSTITUTIONSUGGESTIONS_URL), Status.STATUS_OK); - - // Check the content from the response - String contentAsString = response.getContentAsString(); - assertNotNull(contentAsString); - - // Convert the response to json and check the data - JSONObject contentAsJson = new JSONObject(contentAsString); - JSONArray data = contentAsJson.getJSONArray("substitutions"); - assertNotNull(data); - - // Get the list of rm action definitions from the response and check it - List substitutionDefinitions = getSubstitutionDefinitions(); - List rmSubstitutionDefinitions = new ArrayList(); - for (int i = 0; i < data.length(); i++) - { - String value = data.getString(i); - assertNotNull(value); - rmSubstitutionDefinitions.add(value); - } - assertTrue(rmSubstitutionDefinitions.containsAll(substitutionDefinitions)); - assertTrue(substitutionDefinitions.containsAll(rmSubstitutionDefinitions)); - } - - /** - * Returns a (sub)list of dm action definitions - * - * @return A (sub)list of dm action definitions - */ - private List getSubstitutionDefinitions() - { - return Arrays.asList(new String[] - { - "date.month.number", - "date.month.long", - "date.month.short", - "date.month", - "date.day.month", - }); - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +/** + * REST API Tests for Action Definitions + * + * @author Mark Hibbins + * @since 2.2 + */ +public class SubstitutionSuggestionsRestApiTest extends BaseRMWebScriptTestCase +{ + /** URL for the REST APIs */ + private static final String RM_SUBSTITUTIONSUGGESTIONS_URL = "/api/rm/rm-substitutionsuggestions?fragment=month"; + + /** + * Test the REST API to retrieve the list of rm substitution suggestions + * + * @throws IOException + * @throws JSONException + */ + public void testRmGetSubstitutionSuggestions() throws IOException, JSONException + { + // Send request + Response response = sendRequest(new GetRequest(RM_SUBSTITUTIONSUGGESTIONS_URL), Status.STATUS_OK); + + // Check the content from the response + String contentAsString = response.getContentAsString(); + assertNotNull(contentAsString); + + // Convert the response to json and check the data + JSONObject contentAsJson = new JSONObject(contentAsString); + JSONArray data = contentAsJson.getJSONArray("substitutions"); + assertNotNull(data); + + // Get the list of rm action definitions from the response and check it + List substitutionDefinitions = getSubstitutionDefinitions(); + List rmSubstitutionDefinitions = new ArrayList(); + for (int i = 0; i < data.length(); i++) + { + String value = data.getString(i); + assertNotNull(value); + rmSubstitutionDefinitions.add(value); + } + assertTrue(rmSubstitutionDefinitions.containsAll(substitutionDefinitions)); + assertTrue(substitutionDefinitions.containsAll(rmSubstitutionDefinitions)); + } + + /** + * Returns a (sub)list of dm action definitions + * + * @return A (sub)list of dm action definitions + */ + private List getSubstitutionDefinitions() + { + return Arrays.asList(new String[] + { + "date.month.number", + "date.month.long", + "date.month.short", + "date.month", + "date.day.month", + }); + } } \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/WebScriptTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/WebScriptTestSuite.java index d1581e74d5..9567fa87c1 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/WebScriptTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/WebScriptTestSuite.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * RM WebScript test suite - * - * @author Roy Wetherall - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - DispositionRestApiTest.class, - EventRestApiTest.class, - RMCaveatConfigScriptTest.class, - RMConstraintScriptTest.class, - //RmRestApiTest.class, - RoleRestApiTest.class, - DataSetRestApiTest.class, - EmailMapScriptTest.class, - EmailMapKeysRestApiTest.class, - CapabilitiesRestApiTest.class, - ActionDefinitionsRestApiTest.class, - RmClassesRestApiTest.class, - RmPropertiesRestApiTest.class, - RmAuthoritiesRestApiTest.class, - SubstitutionSuggestionsRestApiTest.class -}) -public class WebScriptTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * RM WebScript test suite + * + * @author Roy Wetherall + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + DispositionRestApiTest.class, + EventRestApiTest.class, + RMCaveatConfigScriptTest.class, + RMConstraintScriptTest.class, + //RmRestApiTest.class, + RoleRestApiTest.class, + DataSetRestApiTest.class, + EmailMapScriptTest.class, + EmailMapKeysRestApiTest.class, + CapabilitiesRestApiTest.class, + ActionDefinitionsRestApiTest.class, + RmClassesRestApiTest.class, + RmPropertiesRestApiTest.class, + RmAuthoritiesRestApiTest.class, + SubstitutionSuggestionsRestApiTest.class +}) +public class WebScriptTestSuite +{ +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/DataLoadSystemTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/DataLoadSystemTest.java index a16befc493..dc877cabd5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/DataLoadSystemTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/DataLoadSystemTest.java @@ -1,311 +1,311 @@ -package org.alfresco.module.org_alfresco_module_rm.test.system; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteRole; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.extensions.webscripts.GUID; - -public class DataLoadSystemTest -{ - /** services */ - protected FilePlanService filePlanService; - protected RecordFolderService recordFolderService; - protected RecordService recordService; - protected TransactionService transactionService; - protected AuthorityService authorityService; - protected MutableAuthenticationService authenticationService; - protected PersonService personService; - protected FilePlanRoleService filePlanRoleService; - protected SiteService siteService; - protected FileFolderService fileFolderService; - - /** config locations */ - protected String[] getConfigLocations() - { - return new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml" - }; - } - - /** transaction batch size */ - private static final int BATCH_SIZE = 100; - - /** file plan sizing */ - private static final int ROOT_CATEGORY_COUNT = 0; - private static final int RECORD_FOLDER_COUNT = 0; - private static final int RECORD_COUNT = 0; - - /** rm user sizing */ - private static final int RM_GROUP_COUNT = 0; - private static final int RM_USER_COUNT = 0; - - /** inplace sizing */ - private static final int USER_COUNT = 0; - private static final int INPLACE_RECORD_COUNT = 5000; - - /** application context */ - private ApplicationContext applicationContext; - CommonRMTestUtils utils; - - private int totalCount; - private List recordCategories; - private List recordFolders; - private List groups; - - @Before - public void before() - { - applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations()); - utils = new CommonRMTestUtils(applicationContext); - - filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService"); - recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); - recordService = (RecordService)applicationContext.getBean("RecordService"); - transactionService = (TransactionService)applicationContext.getBean("transactionService"); - authorityService = (AuthorityService)applicationContext.getBean("authorityService"); - authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService"); - personService = (PersonService)applicationContext.getBean("personService"); - filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("filePlanRoleService"); - siteService = (SiteService)applicationContext.getBean("siteService"); - fileFolderService = (FileFolderService)applicationContext.getBean("fileFolderService"); - } - - @Test - public void loadAllData() - { - loadFilePlanData(); - loadRMUsersAndGroups(); - loadInPlace(); - } - - private void loadInPlace() - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - final SiteInfo site = siteService.getSite("test"); - if (site == null) - { - throw new AlfrescoRuntimeException("The collab site test is not present."); - } - - final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - Assert.fail("The default RM site is not present."); - } - - // create users and add to site - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - // create user - String userName = GUID.generate(); - System.out.println("Creating user " + userName); - createPerson(userName, true); - - // add to collab site - siteService.setMembership("test", userName, SiteRole.SiteCollaborator.toString()); - - return null; - } - }, USER_COUNT); - - // create content and declare as record - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - // create document - NodeRef docLib = siteService.getContainer(site.getShortName(), SiteService.DOCUMENT_LIBRARY); - NodeRef document = fileFolderService.create(docLib, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - - recordService.createRecord(filePlan, document); - - return null; - } - }, INPLACE_RECORD_COUNT); - - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - - private void loadRMUsersAndGroups() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - Assert.fail("The default RM site is not present."); - } - - groups = new ArrayList(); - - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - String groupName = GUID.generate(); - System.out.println("Creating group " + groupName); - groups.add("GROUP_" + authorityService.createAuthority(AuthorityType.GROUP, groupName)); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, groupName); - return null; - } - }, RM_GROUP_COUNT); - - for (final String group : groups) - { - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - String userName = GUID.generate(); - System.out.println("Creating user " + userName + " and adding to group " + group); - createPerson(userName, true); - authorityService.addAuthority(group, userName); - return null; - } - }, RM_USER_COUNT); - } - - return null; - } - }); - } - - private void loadFilePlanData() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - if (filePlan == null) - { - Assert.fail("The default RM site is not present."); - } - - // create root categories - recordCategories = new ArrayList(ROOT_CATEGORY_COUNT); - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - recordCategories.add(filePlanService.createRecordCategory(filePlan, GUID.generate())); - return null; - } - }, ROOT_CATEGORY_COUNT); - - // create record folders - recordFolders = new ArrayList(RECORD_FOLDER_COUNT); - for (final NodeRef recordCategory : recordCategories) - { - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - recordFolders.add(recordFolderService.createRecordFolder(recordCategory, GUID.generate())); - return null; - } - }, RECORD_FOLDER_COUNT); - } - - // create records - for (final NodeRef recordFolder : recordFolders) - { - repeatInTransactionBatches(new RunAsWork() - { - public Void doWork() throws Exception - { - recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null); - return null; - } - }, RECORD_COUNT); - } - - - return null; - } - }); - } - - private NodeRef createPerson(String userName, boolean createAuth) - { - if (createAuth) - { - authenticationService.createAuthentication(userName, "password".toCharArray()); - } - Map properties = new HashMap(); - properties.put(ContentModel.PROP_USERNAME, userName); - return personService.createPerson(properties); - } - - private void repeatInTransactionBatches(final RunAsWork work, final int count) throws Exception - { - totalCount = 0; - while (totalCount < count) - { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - int batchSize = count - totalCount; - if (batchSize >= BATCH_SIZE) - { - batchSize = BATCH_SIZE; - } - - for (int i = 0; i < batchSize; i++) - { - // do it - work.doWork(); - totalCount++; - } - - System.out.println("Created " + totalCount + " of " + count); - - return null; - } - }, - false, true); - } - } -} +package org.alfresco.module.org_alfresco_module_rm.test.system; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.MutableAuthenticationService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteRole; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.extensions.webscripts.GUID; + +public class DataLoadSystemTest +{ + /** services */ + protected FilePlanService filePlanService; + protected RecordFolderService recordFolderService; + protected RecordService recordService; + protected TransactionService transactionService; + protected AuthorityService authorityService; + protected MutableAuthenticationService authenticationService; + protected PersonService personService; + protected FilePlanRoleService filePlanRoleService; + protected SiteService siteService; + protected FileFolderService fileFolderService; + + /** config locations */ + protected String[] getConfigLocations() + { + return new String[] + { + "classpath:alfresco/application-context.xml", + "classpath:test-context.xml" + }; + } + + /** transaction batch size */ + private static final int BATCH_SIZE = 100; + + /** file plan sizing */ + private static final int ROOT_CATEGORY_COUNT = 0; + private static final int RECORD_FOLDER_COUNT = 0; + private static final int RECORD_COUNT = 0; + + /** rm user sizing */ + private static final int RM_GROUP_COUNT = 0; + private static final int RM_USER_COUNT = 0; + + /** inplace sizing */ + private static final int USER_COUNT = 0; + private static final int INPLACE_RECORD_COUNT = 5000; + + /** application context */ + private ApplicationContext applicationContext; + CommonRMTestUtils utils; + + private int totalCount; + private List recordCategories; + private List recordFolders; + private List groups; + + @Before + public void before() + { + applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations()); + utils = new CommonRMTestUtils(applicationContext); + + filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService"); + recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); + recordService = (RecordService)applicationContext.getBean("RecordService"); + transactionService = (TransactionService)applicationContext.getBean("transactionService"); + authorityService = (AuthorityService)applicationContext.getBean("authorityService"); + authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService"); + personService = (PersonService)applicationContext.getBean("personService"); + filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("filePlanRoleService"); + siteService = (SiteService)applicationContext.getBean("siteService"); + fileFolderService = (FileFolderService)applicationContext.getBean("fileFolderService"); + } + + @Test + public void loadAllData() + { + loadFilePlanData(); + loadRMUsersAndGroups(); + loadInPlace(); + } + + private void loadInPlace() + { + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + final SiteInfo site = siteService.getSite("test"); + if (site == null) + { + throw new AlfrescoRuntimeException("The collab site test is not present."); + } + + final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + Assert.fail("The default RM site is not present."); + } + + // create users and add to site + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + // create user + String userName = GUID.generate(); + System.out.println("Creating user " + userName); + createPerson(userName, true); + + // add to collab site + siteService.setMembership("test", userName, SiteRole.SiteCollaborator.toString()); + + return null; + } + }, USER_COUNT); + + // create content and declare as record + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + // create document + NodeRef docLib = siteService.getContainer(site.getShortName(), SiteService.DOCUMENT_LIBRARY); + NodeRef document = fileFolderService.create(docLib, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); + + recordService.createRecord(filePlan, document); + + return null; + } + }, INPLACE_RECORD_COUNT); + + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + + private void loadRMUsersAndGroups() + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() throws Exception + { + final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + Assert.fail("The default RM site is not present."); + } + + groups = new ArrayList(); + + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + String groupName = GUID.generate(); + System.out.println("Creating group " + groupName); + groups.add("GROUP_" + authorityService.createAuthority(AuthorityType.GROUP, groupName)); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, groupName); + return null; + } + }, RM_GROUP_COUNT); + + for (final String group : groups) + { + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + String userName = GUID.generate(); + System.out.println("Creating user " + userName + " and adding to group " + group); + createPerson(userName, true); + authorityService.addAuthority(group, userName); + return null; + } + }, RM_USER_COUNT); + } + + return null; + } + }); + } + + private void loadFilePlanData() + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Void doWork() throws Exception + { + final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + if (filePlan == null) + { + Assert.fail("The default RM site is not present."); + } + + // create root categories + recordCategories = new ArrayList(ROOT_CATEGORY_COUNT); + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + recordCategories.add(filePlanService.createRecordCategory(filePlan, GUID.generate())); + return null; + } + }, ROOT_CATEGORY_COUNT); + + // create record folders + recordFolders = new ArrayList(RECORD_FOLDER_COUNT); + for (final NodeRef recordCategory : recordCategories) + { + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + recordFolders.add(recordFolderService.createRecordFolder(recordCategory, GUID.generate())); + return null; + } + }, RECORD_FOLDER_COUNT); + } + + // create records + for (final NodeRef recordFolder : recordFolders) + { + repeatInTransactionBatches(new RunAsWork() + { + public Void doWork() throws Exception + { + recordService.createRecordFromContent(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT, null, null); + return null; + } + }, RECORD_COUNT); + } + + + return null; + } + }); + } + + private NodeRef createPerson(String userName, boolean createAuth) + { + if (createAuth) + { + authenticationService.createAuthentication(userName, "password".toCharArray()); + } + Map properties = new HashMap(); + properties.put(ContentModel.PROP_USERNAME, userName); + return personService.createPerson(properties); + } + + private void repeatInTransactionBatches(final RunAsWork work, final int count) throws Exception + { + totalCount = 0; + while (totalCount < count) + { + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + int batchSize = count - totalCount; + if (batchSize >= BATCH_SIZE) + { + batchSize = BATCH_SIZE; + } + + for (int i = 0; i < batchSize; i++) + { + // do it + work.doWork(); + totalCount++; + } + + System.out.println("Created " + totalCount + " of " + count); + + return null; + } + }, + false, true); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/NotificationServiceHelperSystemTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/NotificationServiceHelperSystemTest.java index e6dcb49416..c4f9d1d9fb 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/NotificationServiceHelperSystemTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/system/NotificationServiceHelperSystemTest.java @@ -1,149 +1,149 @@ -/* - * Copyright (C) 2009-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.test.system; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; - - -/** - * Notification helper (system) test - * - * @author Roy Wetherall - */ -public class NotificationServiceHelperSystemTest extends BaseRMTestCase -{ - private static final String NOTIFICATION_ROLE = "RecordsManager"; - private static final String EMAIL_ADDRESS = "roy.wetherall@alfreso.com"; - - /** Services */ - private RecordsManagementNotificationHelper notificationHelper; - - /** Test data */ - private NodeRef record; - private List records; - private String userName; - private NodeRef person; - - @Override - protected void initServices() - { - super.initServices(); - - // Get the notification helper - notificationHelper = (RecordsManagementNotificationHelper)applicationContext.getBean("recordsManagementNotificationHelper"); - } - - @Override - protected void setupTestData() - { - super.setupTestData(); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - // Create a user - userName = GUID.generate(); - authenticationService.createAuthentication(userName, "".toCharArray()); - PropertyMap props = new PropertyMap(); - props.put(PROP_USERNAME, userName); - props.put(PROP_FIRSTNAME, "Test"); - props.put(PROP_LASTNAME, "User"); - props.put(PROP_EMAIL, EMAIL_ADDRESS); - person = personService.createPerson(props); - - // Find the authority for the given role - Role role = filePlanRoleService.getRole(filePlan, NOTIFICATION_ROLE); - assertNotNull("Notification role could not be retrieved", role); - String roleGroup = role.getRoleGroupName(); - assertNotNull("Notification role group can not be null.", roleGroup); - - // Add user to notification role group - authorityService.addAuthority(roleGroup, userName); - - return null; - } - }); - } - - @Override - protected void setupTestDataImpl() - { - super.setupTestDataImpl(); - - // Create a few test records - record = utils.createRecord(rmFolder, "recordOne"); - NodeRef record2 = utils.createRecord(rmFolder, "recordTwo"); - NodeRef record3 = utils.createRecord(rmFolder, "recordThree"); - - records = new ArrayList(3); - records.add(record); - records.add(record2); - records.add(record3); - } - - @Override - protected void tearDownImpl() - { - super.tearDownImpl(); - - // Delete the person and user - personService.deletePerson(person); - } - - public void testSendDueForReviewNotification() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - notificationHelper.recordsDueForReviewEmailNotification(records); - return null; - } - }); - } - - public void testSendSupersededNotification() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - notificationHelper.recordSupersededEmailNotification(record); - return null; - } - }); - } -} +/* + * Copyright (C) 2009-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.test.system; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; +import org.alfresco.util.PropertyMap; + + +/** + * Notification helper (system) test + * + * @author Roy Wetherall + */ +public class NotificationServiceHelperSystemTest extends BaseRMTestCase +{ + private static final String NOTIFICATION_ROLE = "RecordsManager"; + private static final String EMAIL_ADDRESS = "roy.wetherall@alfreso.com"; + + /** Services */ + private RecordsManagementNotificationHelper notificationHelper; + + /** Test data */ + private NodeRef record; + private List records; + private String userName; + private NodeRef person; + + @Override + protected void initServices() + { + super.initServices(); + + // Get the notification helper + notificationHelper = (RecordsManagementNotificationHelper)applicationContext.getBean("recordsManagementNotificationHelper"); + } + + @Override + protected void setupTestData() + { + super.setupTestData(); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + // Create a user + userName = GUID.generate(); + authenticationService.createAuthentication(userName, "".toCharArray()); + PropertyMap props = new PropertyMap(); + props.put(PROP_USERNAME, userName); + props.put(PROP_FIRSTNAME, "Test"); + props.put(PROP_LASTNAME, "User"); + props.put(PROP_EMAIL, EMAIL_ADDRESS); + person = personService.createPerson(props); + + // Find the authority for the given role + Role role = filePlanRoleService.getRole(filePlan, NOTIFICATION_ROLE); + assertNotNull("Notification role could not be retrieved", role); + String roleGroup = role.getRoleGroupName(); + assertNotNull("Notification role group can not be null.", roleGroup); + + // Add user to notification role group + authorityService.addAuthority(roleGroup, userName); + + return null; + } + }); + } + + @Override + protected void setupTestDataImpl() + { + super.setupTestDataImpl(); + + // Create a few test records + record = utils.createRecord(rmFolder, "recordOne"); + NodeRef record2 = utils.createRecord(rmFolder, "recordTwo"); + NodeRef record3 = utils.createRecord(rmFolder, "recordThree"); + + records = new ArrayList(3); + records.add(record); + records.add(record2); + records.add(record3); + } + + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + // Delete the person and user + personService.deletePerson(person); + } + + public void testSendDueForReviewNotification() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + notificationHelper.recordsDueForReviewEmailNotification(records); + return null; + } + }); + } + + public void testSendSupersededNotification() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + notificationHelper.recordSupersededEmailNotification(record); + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index d549b1ffa6..1444dd5f86 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -1,979 +1,979 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.report.ReportService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authority.AuthorityDAO; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.repo.site.SiteServiceImpl; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.GUID; -import org.alfresco.util.RetryingTransactionHelperTestCase; -import org.springframework.context.ApplicationContext; - -/** - * Base test case class to use for RM unit tests. - * - * @author Roy Wetherall - */ -public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase - implements RecordsManagementModel, ContentModel, RMPermissionModel -{ - /** Application context */ - protected String[] getConfigLocations() - { - return new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml" - }; - } - protected ApplicationContext applicationContext; - - /** test model constants */ - protected String URI = "http://www.alfresco.org/model/rmtest/1.0"; - protected String PREFIX = "rmt"; - protected QName TYPE_CUSTOM_TYPE = QName.createQName(URI, "customType"); - protected QName ASPECT_CUSTOM_ASPECT = QName.createQName(URI, "customAspect"); - protected QName ASPECT_RECORD_META_DATA = QName.createQName(URI, "recordMetaData"); - - /** test data */ - protected String NAME_DM_DOCUMENT = "collabDocument.txt"; - - /** admin user */ - protected static final String ADMIN_USER = "admin"; - - /** Common test utils */ - protected CommonRMTestUtils utils; - - /** Services */ - protected NodeService nodeService; - protected ContentService contentService; - protected DictionaryService dictionaryService; - protected RetryingTransactionHelper retryingTransactionHelper; - protected PolicyComponent policyComponent; - protected NamespaceService namespaceService; - protected SearchService searchService; - protected SiteService siteService; - protected MutableAuthenticationService authenticationService; - protected AuthorityService authorityService; - protected PersonService personService; - protected TransactionService transactionService; - protected FileFolderService fileFolderService; - protected PermissionService permissionService; - protected TaggingService taggingService; - protected ActionService actionService; - protected OwnableService ownableService; - protected VersionService versionService; - - /** RM Services */ - protected DispositionService dispositionService; - protected RecordsManagementEventService rmEventService; - protected RecordsManagementAdminService rmAdminService; - protected RecordsManagementActionService rmActionService; - protected RecordsManagementSearchService rmSearchService; - protected FilePlanRoleService filePlanRoleService; - protected FilePlanPermissionService filePlanPermissionService; - protected CapabilityService capabilityService; - protected VitalRecordService vitalRecordService; - protected DataSetService dataSetService; - protected FreezeService freezeService; - protected RecordService recordService; - protected FilePlanService filePlanService; - protected RecordFolderService recordFolderService; - protected ExtendedSecurityService extendedSecurityService; - protected ReportService reportService; - protected RecordsManagementAuditService rmAuditService; - protected IdentifierService identifierService; - protected HoldService holdService; - protected InplaceRecordService inplaceRecordService; - protected RelationshipService relationshipService; - - /** test data */ - protected String siteId; - protected StoreRef storeRef; - protected NodeRef rootNodeRef; - protected SiteInfo siteInfo; - protected NodeRef folder; - protected NodeRef filePlan; - protected NodeRef rmContainer; - protected DispositionSchedule dispositionSchedule; - protected NodeRef rmFolder; - protected NodeRef unfiledContainer; - protected String collabSiteId; - protected NodeRef holdsContainer; - protected NodeRef transfersContainer; - - /** multi-hierarchy test data - * - * |--rmRootContainer - * | - * |--mhContainer - * | - * |--mhContainer-1-1 (has schedule - folder level) - * | | - * | |--mhContainer-2-1 - * | | - * | |--mhContainer-3-1 - * | - * |--mhContainer-1-2 (has schedule - folder level) - * | - * |--mhContainer-2-2 - * | | - * | |--mhContainer-3-2 - * | | - * | |--mhContainer-3-3 (has schedule - record level) - * | - * |--mhContainer-2-3 (has schedule - folder level) - * | - * |--mhContainer-3-4 - * | - * |--mhContainer-3-5 (has schedule- record level) - */ - - protected NodeRef mhContainer; - - protected NodeRef mhContainer11; - protected DispositionSchedule mhDispositionSchedule11; - protected NodeRef mhContainer12; - protected DispositionSchedule mhDispositionSchedule12; - - protected NodeRef mhContainer21; - protected NodeRef mhContainer22; - protected NodeRef mhContainer23; - protected DispositionSchedule mhDispositionSchedule23; - - protected NodeRef mhContainer31; - protected NodeRef mhContainer32; - protected NodeRef mhContainer33; - protected DispositionSchedule mhDispositionSchedule33; - protected NodeRef mhContainer34; - protected NodeRef mhContainer35; - protected DispositionSchedule mhDispositionSchedule35; - - protected NodeRef mhRecordFolder41; - protected NodeRef mhRecordFolder42; - protected NodeRef mhRecordFolder43; - protected NodeRef mhRecordFolder44; - protected NodeRef mhRecordFolder45; - - /** test user names */ - protected String[] testUsers; - protected String userName; - protected String rmUserName; - protected String powerUserName; - protected String securityOfficerName; - protected String recordsManagerName; - - /** test people */ - protected NodeRef userPerson; - protected NodeRef rmUserPerson; - protected NodeRef powerUserPerson; - protected NodeRef securityOfficerPerson; - protected NodeRef recordsManagerPerson; - - /** test records */ - protected NodeRef recordOne; - protected NodeRef recordTwo; - protected NodeRef recordThree; - protected NodeRef recordFour; - protected NodeRef recordFive; - protected NodeRef recordDeclaredOne; - protected NodeRef recordDeclaredTwo; - - /** collaboration site artifacts */ - protected SiteInfo collaborationSite; - protected NodeRef documentLibrary; - protected NodeRef dmFolder; - protected NodeRef dmDocument; - - /** collaboration site users */ - protected String dmConsumer; - protected NodeRef dmConsumerNodeRef; - protected String dmContributor; - protected NodeRef dmContributorNodeRef; - protected String dmCollaborator; - protected NodeRef dmCollaboratorNodeRef; - - /** - * Indicates whether this is a RM site test or not. If true then the test RM site is created along with a basic - * file plan structure, otherwise not. - */ - protected boolean isRMSiteTest() - { - return true; - } - - /** - * Indicates whether this is a multi-hierarchy test or not. If it is then the multi-hierarchy record - * taxonomy test data is loaded. - */ - protected boolean isMultiHierarchyTest() - { - return false; - } - - /** - * Indicates whether the test users should be created or not. - */ - protected boolean isUserTest() - { - return false; - } - - /** - * Indicates whether the test records should be created or not. - */ - protected boolean isRecordTest() - { - return false; - } - - /** - * Indicates whether the test users should have filling on the file plan structure - * by default or not. - */ - protected boolean isFillingForAllUsers() - { - return false; - } - - /** - * Indicates whether the test collaboration site should be created - * or not. - */ - protected boolean isCollaborationSiteTest() - { - return false; - } - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception - { - // Get the application context - applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations()); - utils = new CommonRMTestUtils(applicationContext); - - // Initialise the service beans - initServices(); - - // Setup test data - setupTestData(); - - // Create multi hierarchy data - if (isMultiHierarchyTest()) - { - setupMultiHierarchyTestData(); - } - - // Create collaboration data - if (isCollaborationSiteTest()) - { - setupCollaborationSiteTestData(); - } - - // Create the users here - if (isUserTest()) - { - setupTestUsers(filePlan); - } - } - - /** - * Initialise the service beans. - */ - protected void initServices() - { - // Get services - nodeService = (NodeService)applicationContext.getBean("NodeService"); - contentService = (ContentService)applicationContext.getBean("ContentService"); - retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); - namespaceService = (NamespaceService)this.applicationContext.getBean("NamespaceService"); - searchService = (SearchService)this.applicationContext.getBean("SearchService"); - policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent"); - dictionaryService = (DictionaryService)this.applicationContext.getBean("DictionaryService"); - siteService = (SiteService)this.applicationContext.getBean("SiteService"); - authorityService = (AuthorityService)this.applicationContext.getBean("AuthorityService"); - authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("AuthenticationService"); - personService = (PersonService)this.applicationContext.getBean("PersonService"); - transactionService = (TransactionService)applicationContext.getBean("TransactionService"); - fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService"); - permissionService = (PermissionService)applicationContext.getBean("PermissionService"); - taggingService = (TaggingService)applicationContext.getBean("TaggingService"); - actionService = (ActionService)applicationContext.getBean("ActionService"); - ownableService = (OwnableService)applicationContext.getBean("OwnableService"); - versionService = (VersionService)applicationContext.getBean("VersionService"); - - // Get RM services - dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); - rmEventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); - rmAdminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); - rmActionService = (RecordsManagementActionService)this.applicationContext.getBean("RecordsManagementActionService"); - rmSearchService = (RecordsManagementSearchService)this.applicationContext.getBean("RecordsManagementSearchService"); - filePlanRoleService = (FilePlanRoleService)this.applicationContext.getBean("FilePlanRoleService"); - filePlanPermissionService = (FilePlanPermissionService)this.applicationContext.getBean("FilePlanPermissionService"); - capabilityService = (CapabilityService)this.applicationContext.getBean("CapabilityService"); - vitalRecordService = (VitalRecordService)this.applicationContext.getBean("VitalRecordService"); - dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); - freezeService = (FreezeService) applicationContext.getBean("FreezeService"); - recordService = (RecordService) applicationContext.getBean("RecordService"); - filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService"); - recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); - extendedSecurityService = (ExtendedSecurityService) applicationContext.getBean("ExtendedSecurityService"); - reportService = (ReportService) applicationContext.getBean("ReportService"); - rmAuditService = (RecordsManagementAuditService) applicationContext.getBean("RecordsManagementAuditService"); - identifierService = (IdentifierService) applicationContext.getBean("recordsManagementIdentifierService"); - holdService = (HoldService) applicationContext.getBean("HoldService"); - inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService"); - relationshipService = (RelationshipService) applicationContext.getBean("RelationshipService"); - } - - /** - * @see junit.framework.TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - // Do the tear down - AuthenticationUtil.runAsSystem(() -> - { - tearDownImpl(); - return null; - }); - - return null; - } - }); - } - - /** - * Tear down implementation - */ - protected void tearDownImpl() - { - BehaviourFilter filter = (BehaviourFilter)applicationContext.getBean("policyBehaviourFilter"); - filter.disableBehaviour(); - try - { - if (filePlan != null && nodeService.exists(filePlan)) - { - List holds = holdService.getHolds(filePlan); - for (NodeRef hold : holds) - { - holdService.deleteHold(hold); - } - } - - if (folder != null && nodeService.exists(folder)) - { - // Delete the folder - nodeService.deleteNode(folder); - } - - if (siteId != null && siteService.getSite(siteId) != null) - { - // Delete the site - siteService.deleteSite(siteId); - } - - // delete the collaboration site (if required) - if (isCollaborationSiteTest() && siteService.getSite(collabSiteId) != null) - { - siteService.deleteSite(collabSiteId); - } - } - finally - { - filter.enableBehaviour(); - } - } - - /** - * @see org.alfresco.util.RetryingTransactionHelperTestCase#getRetryingTransactionHelper() - */ - @Override - public RetryingTransactionHelper getRetryingTransactionHelper() - { - return retryingTransactionHelper; - } - - /** - * Setup test data for tests - */ - protected void setupTestData() - { - doTestInTransaction(new Test() - { - public Void run() - { - setupTestDataImpl(); - - if (isRecordTest() && isRMSiteTest()) - { - setupTestRecords(); - } - - return null; - } - - @Override - public void test(Void result) throws Exception - { - if (isRMSiteTest()) - { - if (isRecordTest()) - { - // declare a record - utils.completeRecord(recordDeclaredOne); - utils.completeRecord(recordDeclaredTwo); - } - - // unfiled container - unfiledContainer = filePlanService.getUnfiledContainer(filePlan); - assertNotNull(unfiledContainer); - - // holds container - holdsContainer = filePlanService.getHoldContainer(filePlan); - assertNotNull(holdsContainer); - - // transfers container - transfersContainer = filePlanService.getTransferContainer(filePlan); - assertNotNull(transfersContainer); - } - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Impl of test data setup - */ - protected void setupTestDataImpl() - { - AuthorityDAO authDao = (AuthorityDAO)applicationContext.getBean("authorityDAO"); - if (!authDao.authorityExists(AuthenticationUtil.getSystemUserName())) - { - createPerson(AuthenticationUtil.getSystemUserName(), false); - } - assertTrue("No person object for System available.", authDao.authorityExists(AuthenticationUtil.getSystemUserName())); - - storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; - rootNodeRef = nodeService.getRootNode(storeRef); - - // Create folder - String containerName = "RM2_" + System.currentTimeMillis(); - Map containerProps = new HashMap(1); - containerProps.put(ContentModel.PROP_NAME, containerName); - folder = nodeService.createNode( - rootNodeRef, - ContentModel.ASSOC_CHILDREN, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, containerName), - ContentModel.TYPE_FOLDER, - containerProps).getChildRef(); - assertNotNull("Could not create base folder", folder); - - permissionService.setPermission(folder, ADMIN_USER, PermissionService.WRITE, true); - permissionService.setPermission(folder, ADMIN_USER, PermissionService.ADD_CHILDREN, true); - - if (isRMSiteTest()) - { - siteId = GUID.generate(); - siteInfo = siteService.createSite( - "rm-site-dashboard", - siteId, - "title", - "descrition", - SiteVisibility.PUBLIC, - RecordsManagementModel.TYPE_RM_SITE); - - filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - assertNotNull("Site document library container was not created successfully.", filePlan); - - // Create RM container - rmContainer = filePlanService.createRecordCategory(filePlan, "rmContainer"); - assertNotNull("Could not create rm container", rmContainer); - - // Create disposition schedule - dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer); - - // Create RM folder - rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder"); - assertNotNull("Could not create rm folder", rmFolder); - } - } - - protected void setupTestRecords() - { - recordOne = utils.createRecord(rmFolder, "one.txt"); - recordTwo = utils.createRecord(rmFolder, "two.txt"); - recordThree = utils.createRecord(rmFolder, "three.txt"); - recordFour = utils.createRecord(rmFolder, "four.txt"); - recordFive = utils.createRecord(rmFolder, "five.txt"); - recordDeclaredOne = utils.createRecord(rmFolder, "declaredOne.txt"); - recordDeclaredTwo = utils.createRecord(rmFolder, "declaredTwo.txt"); - } - - protected void setupTestUsers(final NodeRef filePlan) - { - AuthenticationUtil.runAs(() -> - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - setupTestUsersImpl(filePlan); - return null; - } - }); - - return null; - }, - AuthenticationUtil.getAdminUserName()); - } - - /** - * - * @param filePlan - */ - protected void setupTestUsersImpl(NodeRef filePlan) - { - userName = GUID.generate(); - userPerson = createPerson(userName); - - rmUserName = GUID.generate(); - rmUserPerson = createPerson(rmUserName); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, rmUserName); - - powerUserName = GUID.generate(); - powerUserPerson = createPerson(powerUserName); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_POWER_USER, powerUserName); - - securityOfficerName = GUID.generate(); - securityOfficerPerson = createPerson(securityOfficerName); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER, securityOfficerName); - - recordsManagerName = GUID.generate(); - recordsManagerPerson = createPerson(recordsManagerName); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, recordsManagerName); - - testUsers = new String[] - { - userName, - rmUserName, - powerUserName, - securityOfficerName, - recordsManagerName - }; - - if (isFillingForAllUsers()) - { - // Give all the users file permission objects - for (String user : testUsers) - { - filePlanPermissionService.setPermission(filePlan, user, FILING); - filePlanPermissionService.setPermission(rmContainer, user, FILING); - filePlanPermissionService.setPermission(rmFolder, user, FILING); - filePlanPermissionService.setPermission(unfiledContainer, user, FILING); - } - } - } - - /** - * Util method to create a person. - * @param userName user name - * @return NodeRef user node reference - */ - protected NodeRef createPerson(String userName, boolean createAuth) - { - if (createAuth) - { - authenticationService.createAuthentication(userName, "password".toCharArray()); - } - Map properties = new HashMap(); - properties.put(ContentModel.PROP_USERNAME, userName); - return personService.createPerson(properties); - } - - protected NodeRef createPerson(String userName) - { - return createPerson(userName, true); - } - - /** - * Setup multi hierarchy test data - */ - protected void setupMultiHierarchyTestData() - { - AuthenticationUtil.runAsSystem(() -> - { - return retryingTransactionHelper.doInTransaction(() -> - { - // Do setup - setupMultiHierarchyTestDataImpl(); - - return null; - }); - }); - } - - /** - * Impl of multi hierarchy test data - */ - protected void setupMultiHierarchyTestDataImpl() - { - // Create root mh container - mhContainer = filePlanService.createRecordCategory(filePlan, "mhContainer"); - - // Level 1 - mhContainer11 = filePlanService.createRecordCategory(mhContainer, "mhContainer11"); - mhDispositionSchedule11 = utils.createBasicDispositionSchedule(mhContainer11, "ds11", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); - mhContainer12 = filePlanService.createRecordCategory(mhContainer, "mhContainer12"); - mhDispositionSchedule12 = utils.createBasicDispositionSchedule(mhContainer12, "ds12", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); - - // Level 2 - mhContainer21 = filePlanService.createRecordCategory(mhContainer11, "mhContainer21"); - mhContainer22 = filePlanService.createRecordCategory(mhContainer12, "mhContainer22"); - mhContainer23 = filePlanService.createRecordCategory(mhContainer12, "mhContainer23"); - mhDispositionSchedule23 = utils.createBasicDispositionSchedule(mhContainer23, "ds23", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); - - // Level 3 - mhContainer31 = filePlanService.createRecordCategory(mhContainer21, "mhContainer31"); - mhContainer32 = filePlanService.createRecordCategory(mhContainer22, "mhContainer32"); - mhContainer33 = filePlanService.createRecordCategory(mhContainer22, "mhContainer33"); - mhDispositionSchedule33 = utils.createBasicDispositionSchedule(mhContainer33, "ds33", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true); - mhContainer34 = filePlanService.createRecordCategory(mhContainer23, "mhContainer34"); - mhContainer35 = filePlanService.createRecordCategory(mhContainer23, "mhContainer35"); - mhDispositionSchedule35 = utils.createBasicDispositionSchedule(mhContainer35, "ds35", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true); - - // Record folders - mhRecordFolder41 = recordFolderService.createRecordFolder(mhContainer31, "mhFolder41"); - mhRecordFolder42 = recordFolderService.createRecordFolder(mhContainer32, "mhFolder42"); - mhRecordFolder43 = recordFolderService.createRecordFolder(mhContainer33, "mhFolder43"); - mhRecordFolder44 = recordFolderService.createRecordFolder(mhContainer34, "mhFolder44"); - mhRecordFolder45 = recordFolderService.createRecordFolder(mhContainer35, "mhFolder45"); - } - - protected void setupCollaborationSiteTestData() - { - doTestInTransaction(new Test() - { - public Void run() - { - setupCollaborationSiteTestDataImpl(); - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - protected void setupCollaborationSiteTestDataImpl() - { - // create collaboration site - collabSiteId = GUID.generate(); - collaborationSite = siteService.createSite("site-dashboard", collabSiteId, "title", "description", SiteVisibility.PRIVATE); - documentLibrary = SiteServiceImpl.getSiteContainer( - collabSiteId, - SiteService.DOCUMENT_LIBRARY, - true, - siteService, - transactionService, - taggingService); - - assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary); - - // create a folder and documents - dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - dmDocument = fileFolderService.create(dmFolder, NAME_DM_DOCUMENT, ContentModel.TYPE_CONTENT).getNodeRef(); - - dmConsumer = GUID.generate(); - dmConsumerNodeRef = createPerson(dmConsumer); - siteService.setMembership(collabSiteId, dmConsumer, SiteModel.SITE_CONSUMER); - - dmContributor = GUID.generate(); - dmContributorNodeRef = createPerson(dmContributor); - siteService.setMembership(collabSiteId, dmContributor, SiteModel.SITE_CONTRIBUTOR); - - dmCollaborator = GUID.generate(); - dmCollaboratorNodeRef = createPerson(dmCollaborator); - siteService.setMembership(collabSiteId, dmCollaborator, SiteModel.SITE_COLLABORATOR); - } - - /** - * Override to ensure the tests are run as the 'admin' user by default. - */ - - @Override - protected A doTestInTransaction(Test test) - { - return super.doTestInTransaction(test, AuthenticationUtil.getAdminUserName()); - } - - @Override - protected void doTestInTransaction(FailureTest test) - { - super.doTestInTransaction(test, AuthenticationUtil.getAdminUserName()); - } - - /** - * Helper class to try and simplify {@link Void} tests. - * - * @author Roy Wetherall - * @since 2.1 - */ - protected abstract class VoidTest extends Test - { - @Override - public Void run() throws Exception - { - runImpl(); - return null; - } - - public abstract void runImpl() throws Exception; - - @Override - public void test(Void result) throws Exception - { - testImpl(); - } - - public void testImpl() throws Exception - { - // empty implementation - } - } - - /** - * Execute behaviour driven test. - * - * @param test - */ - protected void doBehaviourDrivenTest(BehaviourDrivenTest test) - { - try - { - test.run(); - } - catch (Exception exception) - { - throw new RuntimeException(exception); - } - } - - /** - * Behaviour driven test. - * - * @author Roy Wetherall - * @since 2.2 - */ - protected abstract class BehaviourDrivenTest - { - /** run in transaction */ - protected boolean runInTransactionTests = true; - - /** run as user */ - protected String runAsUser = AuthenticationUtil.getAdminUserName(); - - /** expected exception */ - protected Class expectedException; - - /** - * Default constructor - */ - public BehaviourDrivenTest() - { - } - - public BehaviourDrivenTest(Class expectedException) - { - this.expectedException = expectedException; - } - - public BehaviourDrivenTest(Class expectedException, String runAsUser) - { - this.expectedException = expectedException; - this.runAsUser = runAsUser; - } - - public BehaviourDrivenTest(String runAsUser) - { - this.runAsUser = runAsUser; - } - - public BehaviourDrivenTest(String runAsUser, boolean runInTransactionTests) - { - this.runInTransactionTests = runInTransactionTests; - if (runAsUser != null) - { - this.runAsUser = runAsUser; - } - } - - public void given() throws Exception { /** empty implementation */ } - - public void when() throws Exception { /** empty implementation */ } - - public void then() throws Exception { /** empty implementation */ } - - public void after() throws Exception { /** empty implementation */ } - - public void run() throws Exception - { - try - { - if (runInTransactionTests) - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - given(); - } - }, runAsUser); - } - else - { - given(); - } - - if (expectedException == null) - { - if (runInTransactionTests) - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - when(); - } - }, runAsUser); - - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - then(); - } - }, runAsUser); - } - else - { - when(); - then(); - } - } - else - { - doTestInTransaction(new FailureTest(expectedException) - { - @Override - public void run() throws Exception - { - when(); - } - }, runAsUser); - } - } - finally - { - if (runInTransactionTests) - { - doTestInTransaction(new VoidTest() - { - @Override - public void runImpl() throws Exception - { - after(); - } - }, runAsUser); - } - else - { - after(); - } - } - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; +import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.report.ReportService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authority.AuthorityDAO; +import org.alfresco.repo.site.SiteModel; +import org.alfresco.repo.site.SiteServiceImpl; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.action.ActionService; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.MutableAuthenticationService; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.service.cmr.tagging.TaggingService; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.GUID; +import org.alfresco.util.RetryingTransactionHelperTestCase; +import org.springframework.context.ApplicationContext; + +/** + * Base test case class to use for RM unit tests. + * + * @author Roy Wetherall + */ +public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase + implements RecordsManagementModel, ContentModel, RMPermissionModel +{ + /** Application context */ + protected String[] getConfigLocations() + { + return new String[] + { + "classpath:alfresco/application-context.xml", + "classpath:test-context.xml" + }; + } + protected ApplicationContext applicationContext; + + /** test model constants */ + protected String URI = "http://www.alfresco.org/model/rmtest/1.0"; + protected String PREFIX = "rmt"; + protected QName TYPE_CUSTOM_TYPE = QName.createQName(URI, "customType"); + protected QName ASPECT_CUSTOM_ASPECT = QName.createQName(URI, "customAspect"); + protected QName ASPECT_RECORD_META_DATA = QName.createQName(URI, "recordMetaData"); + + /** test data */ + protected String NAME_DM_DOCUMENT = "collabDocument.txt"; + + /** admin user */ + protected static final String ADMIN_USER = "admin"; + + /** Common test utils */ + protected CommonRMTestUtils utils; + + /** Services */ + protected NodeService nodeService; + protected ContentService contentService; + protected DictionaryService dictionaryService; + protected RetryingTransactionHelper retryingTransactionHelper; + protected PolicyComponent policyComponent; + protected NamespaceService namespaceService; + protected SearchService searchService; + protected SiteService siteService; + protected MutableAuthenticationService authenticationService; + protected AuthorityService authorityService; + protected PersonService personService; + protected TransactionService transactionService; + protected FileFolderService fileFolderService; + protected PermissionService permissionService; + protected TaggingService taggingService; + protected ActionService actionService; + protected OwnableService ownableService; + protected VersionService versionService; + + /** RM Services */ + protected DispositionService dispositionService; + protected RecordsManagementEventService rmEventService; + protected RecordsManagementAdminService rmAdminService; + protected RecordsManagementActionService rmActionService; + protected RecordsManagementSearchService rmSearchService; + protected FilePlanRoleService filePlanRoleService; + protected FilePlanPermissionService filePlanPermissionService; + protected CapabilityService capabilityService; + protected VitalRecordService vitalRecordService; + protected DataSetService dataSetService; + protected FreezeService freezeService; + protected RecordService recordService; + protected FilePlanService filePlanService; + protected RecordFolderService recordFolderService; + protected ExtendedSecurityService extendedSecurityService; + protected ReportService reportService; + protected RecordsManagementAuditService rmAuditService; + protected IdentifierService identifierService; + protected HoldService holdService; + protected InplaceRecordService inplaceRecordService; + protected RelationshipService relationshipService; + + /** test data */ + protected String siteId; + protected StoreRef storeRef; + protected NodeRef rootNodeRef; + protected SiteInfo siteInfo; + protected NodeRef folder; + protected NodeRef filePlan; + protected NodeRef rmContainer; + protected DispositionSchedule dispositionSchedule; + protected NodeRef rmFolder; + protected NodeRef unfiledContainer; + protected String collabSiteId; + protected NodeRef holdsContainer; + protected NodeRef transfersContainer; + + /** multi-hierarchy test data + * + * |--rmRootContainer + * | + * |--mhContainer + * | + * |--mhContainer-1-1 (has schedule - folder level) + * | | + * | |--mhContainer-2-1 + * | | + * | |--mhContainer-3-1 + * | + * |--mhContainer-1-2 (has schedule - folder level) + * | + * |--mhContainer-2-2 + * | | + * | |--mhContainer-3-2 + * | | + * | |--mhContainer-3-3 (has schedule - record level) + * | + * |--mhContainer-2-3 (has schedule - folder level) + * | + * |--mhContainer-3-4 + * | + * |--mhContainer-3-5 (has schedule- record level) + */ + + protected NodeRef mhContainer; + + protected NodeRef mhContainer11; + protected DispositionSchedule mhDispositionSchedule11; + protected NodeRef mhContainer12; + protected DispositionSchedule mhDispositionSchedule12; + + protected NodeRef mhContainer21; + protected NodeRef mhContainer22; + protected NodeRef mhContainer23; + protected DispositionSchedule mhDispositionSchedule23; + + protected NodeRef mhContainer31; + protected NodeRef mhContainer32; + protected NodeRef mhContainer33; + protected DispositionSchedule mhDispositionSchedule33; + protected NodeRef mhContainer34; + protected NodeRef mhContainer35; + protected DispositionSchedule mhDispositionSchedule35; + + protected NodeRef mhRecordFolder41; + protected NodeRef mhRecordFolder42; + protected NodeRef mhRecordFolder43; + protected NodeRef mhRecordFolder44; + protected NodeRef mhRecordFolder45; + + /** test user names */ + protected String[] testUsers; + protected String userName; + protected String rmUserName; + protected String powerUserName; + protected String securityOfficerName; + protected String recordsManagerName; + + /** test people */ + protected NodeRef userPerson; + protected NodeRef rmUserPerson; + protected NodeRef powerUserPerson; + protected NodeRef securityOfficerPerson; + protected NodeRef recordsManagerPerson; + + /** test records */ + protected NodeRef recordOne; + protected NodeRef recordTwo; + protected NodeRef recordThree; + protected NodeRef recordFour; + protected NodeRef recordFive; + protected NodeRef recordDeclaredOne; + protected NodeRef recordDeclaredTwo; + + /** collaboration site artifacts */ + protected SiteInfo collaborationSite; + protected NodeRef documentLibrary; + protected NodeRef dmFolder; + protected NodeRef dmDocument; + + /** collaboration site users */ + protected String dmConsumer; + protected NodeRef dmConsumerNodeRef; + protected String dmContributor; + protected NodeRef dmContributorNodeRef; + protected String dmCollaborator; + protected NodeRef dmCollaboratorNodeRef; + + /** + * Indicates whether this is a RM site test or not. If true then the test RM site is created along with a basic + * file plan structure, otherwise not. + */ + protected boolean isRMSiteTest() + { + return true; + } + + /** + * Indicates whether this is a multi-hierarchy test or not. If it is then the multi-hierarchy record + * taxonomy test data is loaded. + */ + protected boolean isMultiHierarchyTest() + { + return false; + } + + /** + * Indicates whether the test users should be created or not. + */ + protected boolean isUserTest() + { + return false; + } + + /** + * Indicates whether the test records should be created or not. + */ + protected boolean isRecordTest() + { + return false; + } + + /** + * Indicates whether the test users should have filling on the file plan structure + * by default or not. + */ + protected boolean isFillingForAllUsers() + { + return false; + } + + /** + * Indicates whether the test collaboration site should be created + * or not. + */ + protected boolean isCollaborationSiteTest() + { + return false; + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + // Get the application context + applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations()); + utils = new CommonRMTestUtils(applicationContext); + + // Initialise the service beans + initServices(); + + // Setup test data + setupTestData(); + + // Create multi hierarchy data + if (isMultiHierarchyTest()) + { + setupMultiHierarchyTestData(); + } + + // Create collaboration data + if (isCollaborationSiteTest()) + { + setupCollaborationSiteTestData(); + } + + // Create the users here + if (isUserTest()) + { + setupTestUsers(filePlan); + } + } + + /** + * Initialise the service beans. + */ + protected void initServices() + { + // Get services + nodeService = (NodeService)applicationContext.getBean("NodeService"); + contentService = (ContentService)applicationContext.getBean("ContentService"); + retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); + namespaceService = (NamespaceService)this.applicationContext.getBean("NamespaceService"); + searchService = (SearchService)this.applicationContext.getBean("SearchService"); + policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent"); + dictionaryService = (DictionaryService)this.applicationContext.getBean("DictionaryService"); + siteService = (SiteService)this.applicationContext.getBean("SiteService"); + authorityService = (AuthorityService)this.applicationContext.getBean("AuthorityService"); + authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("AuthenticationService"); + personService = (PersonService)this.applicationContext.getBean("PersonService"); + transactionService = (TransactionService)applicationContext.getBean("TransactionService"); + fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService"); + permissionService = (PermissionService)applicationContext.getBean("PermissionService"); + taggingService = (TaggingService)applicationContext.getBean("TaggingService"); + actionService = (ActionService)applicationContext.getBean("ActionService"); + ownableService = (OwnableService)applicationContext.getBean("OwnableService"); + versionService = (VersionService)applicationContext.getBean("VersionService"); + + // Get RM services + dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); + rmEventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); + rmAdminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); + rmActionService = (RecordsManagementActionService)this.applicationContext.getBean("RecordsManagementActionService"); + rmSearchService = (RecordsManagementSearchService)this.applicationContext.getBean("RecordsManagementSearchService"); + filePlanRoleService = (FilePlanRoleService)this.applicationContext.getBean("FilePlanRoleService"); + filePlanPermissionService = (FilePlanPermissionService)this.applicationContext.getBean("FilePlanPermissionService"); + capabilityService = (CapabilityService)this.applicationContext.getBean("CapabilityService"); + vitalRecordService = (VitalRecordService)this.applicationContext.getBean("VitalRecordService"); + dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); + freezeService = (FreezeService) applicationContext.getBean("FreezeService"); + recordService = (RecordService) applicationContext.getBean("RecordService"); + filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService"); + recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); + extendedSecurityService = (ExtendedSecurityService) applicationContext.getBean("ExtendedSecurityService"); + reportService = (ReportService) applicationContext.getBean("ReportService"); + rmAuditService = (RecordsManagementAuditService) applicationContext.getBean("RecordsManagementAuditService"); + identifierService = (IdentifierService) applicationContext.getBean("recordsManagementIdentifierService"); + holdService = (HoldService) applicationContext.getBean("HoldService"); + inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService"); + relationshipService = (RelationshipService) applicationContext.getBean("RelationshipService"); + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + // Do the tear down + AuthenticationUtil.runAsSystem(() -> + { + tearDownImpl(); + return null; + }); + + return null; + } + }); + } + + /** + * Tear down implementation + */ + protected void tearDownImpl() + { + BehaviourFilter filter = (BehaviourFilter)applicationContext.getBean("policyBehaviourFilter"); + filter.disableBehaviour(); + try + { + if (filePlan != null && nodeService.exists(filePlan)) + { + List holds = holdService.getHolds(filePlan); + for (NodeRef hold : holds) + { + holdService.deleteHold(hold); + } + } + + if (folder != null && nodeService.exists(folder)) + { + // Delete the folder + nodeService.deleteNode(folder); + } + + if (siteId != null && siteService.getSite(siteId) != null) + { + // Delete the site + siteService.deleteSite(siteId); + } + + // delete the collaboration site (if required) + if (isCollaborationSiteTest() && siteService.getSite(collabSiteId) != null) + { + siteService.deleteSite(collabSiteId); + } + } + finally + { + filter.enableBehaviour(); + } + } + + /** + * @see org.alfresco.util.RetryingTransactionHelperTestCase#getRetryingTransactionHelper() + */ + @Override + public RetryingTransactionHelper getRetryingTransactionHelper() + { + return retryingTransactionHelper; + } + + /** + * Setup test data for tests + */ + protected void setupTestData() + { + doTestInTransaction(new Test() + { + public Void run() + { + setupTestDataImpl(); + + if (isRecordTest() && isRMSiteTest()) + { + setupTestRecords(); + } + + return null; + } + + @Override + public void test(Void result) throws Exception + { + if (isRMSiteTest()) + { + if (isRecordTest()) + { + // declare a record + utils.completeRecord(recordDeclaredOne); + utils.completeRecord(recordDeclaredTwo); + } + + // unfiled container + unfiledContainer = filePlanService.getUnfiledContainer(filePlan); + assertNotNull(unfiledContainer); + + // holds container + holdsContainer = filePlanService.getHoldContainer(filePlan); + assertNotNull(holdsContainer); + + // transfers container + transfersContainer = filePlanService.getTransferContainer(filePlan); + assertNotNull(transfersContainer); + } + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Impl of test data setup + */ + protected void setupTestDataImpl() + { + AuthorityDAO authDao = (AuthorityDAO)applicationContext.getBean("authorityDAO"); + if (!authDao.authorityExists(AuthenticationUtil.getSystemUserName())) + { + createPerson(AuthenticationUtil.getSystemUserName(), false); + } + assertTrue("No person object for System available.", authDao.authorityExists(AuthenticationUtil.getSystemUserName())); + + storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; + rootNodeRef = nodeService.getRootNode(storeRef); + + // Create folder + String containerName = "RM2_" + System.currentTimeMillis(); + Map containerProps = new HashMap(1); + containerProps.put(ContentModel.PROP_NAME, containerName); + folder = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, containerName), + ContentModel.TYPE_FOLDER, + containerProps).getChildRef(); + assertNotNull("Could not create base folder", folder); + + permissionService.setPermission(folder, ADMIN_USER, PermissionService.WRITE, true); + permissionService.setPermission(folder, ADMIN_USER, PermissionService.ADD_CHILDREN, true); + + if (isRMSiteTest()) + { + siteId = GUID.generate(); + siteInfo = siteService.createSite( + "rm-site-dashboard", + siteId, + "title", + "descrition", + SiteVisibility.PUBLIC, + RecordsManagementModel.TYPE_RM_SITE); + + filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); + assertNotNull("Site document library container was not created successfully.", filePlan); + + // Create RM container + rmContainer = filePlanService.createRecordCategory(filePlan, "rmContainer"); + assertNotNull("Could not create rm container", rmContainer); + + // Create disposition schedule + dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer); + + // Create RM folder + rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder"); + assertNotNull("Could not create rm folder", rmFolder); + } + } + + protected void setupTestRecords() + { + recordOne = utils.createRecord(rmFolder, "one.txt"); + recordTwo = utils.createRecord(rmFolder, "two.txt"); + recordThree = utils.createRecord(rmFolder, "three.txt"); + recordFour = utils.createRecord(rmFolder, "four.txt"); + recordFive = utils.createRecord(rmFolder, "five.txt"); + recordDeclaredOne = utils.createRecord(rmFolder, "declaredOne.txt"); + recordDeclaredTwo = utils.createRecord(rmFolder, "declaredTwo.txt"); + } + + protected void setupTestUsers(final NodeRef filePlan) + { + AuthenticationUtil.runAs(() -> + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + setupTestUsersImpl(filePlan); + return null; + } + }); + + return null; + }, + AuthenticationUtil.getAdminUserName()); + } + + /** + * + * @param filePlan + */ + protected void setupTestUsersImpl(NodeRef filePlan) + { + userName = GUID.generate(); + userPerson = createPerson(userName); + + rmUserName = GUID.generate(); + rmUserPerson = createPerson(rmUserName); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, rmUserName); + + powerUserName = GUID.generate(); + powerUserPerson = createPerson(powerUserName); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_POWER_USER, powerUserName); + + securityOfficerName = GUID.generate(); + securityOfficerPerson = createPerson(securityOfficerName); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_SECURITY_OFFICER, securityOfficerName); + + recordsManagerName = GUID.generate(); + recordsManagerPerson = createPerson(recordsManagerName); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, recordsManagerName); + + testUsers = new String[] + { + userName, + rmUserName, + powerUserName, + securityOfficerName, + recordsManagerName + }; + + if (isFillingForAllUsers()) + { + // Give all the users file permission objects + for (String user : testUsers) + { + filePlanPermissionService.setPermission(filePlan, user, FILING); + filePlanPermissionService.setPermission(rmContainer, user, FILING); + filePlanPermissionService.setPermission(rmFolder, user, FILING); + filePlanPermissionService.setPermission(unfiledContainer, user, FILING); + } + } + } + + /** + * Util method to create a person. + * @param userName user name + * @return NodeRef user node reference + */ + protected NodeRef createPerson(String userName, boolean createAuth) + { + if (createAuth) + { + authenticationService.createAuthentication(userName, "password".toCharArray()); + } + Map properties = new HashMap(); + properties.put(ContentModel.PROP_USERNAME, userName); + return personService.createPerson(properties); + } + + protected NodeRef createPerson(String userName) + { + return createPerson(userName, true); + } + + /** + * Setup multi hierarchy test data + */ + protected void setupMultiHierarchyTestData() + { + AuthenticationUtil.runAsSystem(() -> + { + return retryingTransactionHelper.doInTransaction(() -> + { + // Do setup + setupMultiHierarchyTestDataImpl(); + + return null; + }); + }); + } + + /** + * Impl of multi hierarchy test data + */ + protected void setupMultiHierarchyTestDataImpl() + { + // Create root mh container + mhContainer = filePlanService.createRecordCategory(filePlan, "mhContainer"); + + // Level 1 + mhContainer11 = filePlanService.createRecordCategory(mhContainer, "mhContainer11"); + mhDispositionSchedule11 = utils.createBasicDispositionSchedule(mhContainer11, "ds11", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); + mhContainer12 = filePlanService.createRecordCategory(mhContainer, "mhContainer12"); + mhDispositionSchedule12 = utils.createBasicDispositionSchedule(mhContainer12, "ds12", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); + + // Level 2 + mhContainer21 = filePlanService.createRecordCategory(mhContainer11, "mhContainer21"); + mhContainer22 = filePlanService.createRecordCategory(mhContainer12, "mhContainer22"); + mhContainer23 = filePlanService.createRecordCategory(mhContainer12, "mhContainer23"); + mhDispositionSchedule23 = utils.createBasicDispositionSchedule(mhContainer23, "ds23", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, false, true); + + // Level 3 + mhContainer31 = filePlanService.createRecordCategory(mhContainer21, "mhContainer31"); + mhContainer32 = filePlanService.createRecordCategory(mhContainer22, "mhContainer32"); + mhContainer33 = filePlanService.createRecordCategory(mhContainer22, "mhContainer33"); + mhDispositionSchedule33 = utils.createBasicDispositionSchedule(mhContainer33, "ds33", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true); + mhContainer34 = filePlanService.createRecordCategory(mhContainer23, "mhContainer34"); + mhContainer35 = filePlanService.createRecordCategory(mhContainer23, "mhContainer35"); + mhDispositionSchedule35 = utils.createBasicDispositionSchedule(mhContainer35, "ds35", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true); + + // Record folders + mhRecordFolder41 = recordFolderService.createRecordFolder(mhContainer31, "mhFolder41"); + mhRecordFolder42 = recordFolderService.createRecordFolder(mhContainer32, "mhFolder42"); + mhRecordFolder43 = recordFolderService.createRecordFolder(mhContainer33, "mhFolder43"); + mhRecordFolder44 = recordFolderService.createRecordFolder(mhContainer34, "mhFolder44"); + mhRecordFolder45 = recordFolderService.createRecordFolder(mhContainer35, "mhFolder45"); + } + + protected void setupCollaborationSiteTestData() + { + doTestInTransaction(new Test() + { + public Void run() + { + setupCollaborationSiteTestDataImpl(); + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + protected void setupCollaborationSiteTestDataImpl() + { + // create collaboration site + collabSiteId = GUID.generate(); + collaborationSite = siteService.createSite("site-dashboard", collabSiteId, "title", "description", SiteVisibility.PRIVATE); + documentLibrary = SiteServiceImpl.getSiteContainer( + collabSiteId, + SiteService.DOCUMENT_LIBRARY, + true, + siteService, + transactionService, + taggingService); + + assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary); + + // create a folder and documents + dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef(); + dmDocument = fileFolderService.create(dmFolder, NAME_DM_DOCUMENT, ContentModel.TYPE_CONTENT).getNodeRef(); + + dmConsumer = GUID.generate(); + dmConsumerNodeRef = createPerson(dmConsumer); + siteService.setMembership(collabSiteId, dmConsumer, SiteModel.SITE_CONSUMER); + + dmContributor = GUID.generate(); + dmContributorNodeRef = createPerson(dmContributor); + siteService.setMembership(collabSiteId, dmContributor, SiteModel.SITE_CONTRIBUTOR); + + dmCollaborator = GUID.generate(); + dmCollaboratorNodeRef = createPerson(dmCollaborator); + siteService.setMembership(collabSiteId, dmCollaborator, SiteModel.SITE_COLLABORATOR); + } + + /** + * Override to ensure the tests are run as the 'admin' user by default. + */ + + @Override + protected A doTestInTransaction(Test test) + { + return super.doTestInTransaction(test, AuthenticationUtil.getAdminUserName()); + } + + @Override + protected void doTestInTransaction(FailureTest test) + { + super.doTestInTransaction(test, AuthenticationUtil.getAdminUserName()); + } + + /** + * Helper class to try and simplify {@link Void} tests. + * + * @author Roy Wetherall + * @since 2.1 + */ + protected abstract class VoidTest extends Test + { + @Override + public Void run() throws Exception + { + runImpl(); + return null; + } + + public abstract void runImpl() throws Exception; + + @Override + public void test(Void result) throws Exception + { + testImpl(); + } + + public void testImpl() throws Exception + { + // empty implementation + } + } + + /** + * Execute behaviour driven test. + * + * @param test + */ + protected void doBehaviourDrivenTest(BehaviourDrivenTest test) + { + try + { + test.run(); + } + catch (Exception exception) + { + throw new RuntimeException(exception); + } + } + + /** + * Behaviour driven test. + * + * @author Roy Wetherall + * @since 2.2 + */ + protected abstract class BehaviourDrivenTest + { + /** run in transaction */ + protected boolean runInTransactionTests = true; + + /** run as user */ + protected String runAsUser = AuthenticationUtil.getAdminUserName(); + + /** expected exception */ + protected Class expectedException; + + /** + * Default constructor + */ + public BehaviourDrivenTest() + { + } + + public BehaviourDrivenTest(Class expectedException) + { + this.expectedException = expectedException; + } + + public BehaviourDrivenTest(Class expectedException, String runAsUser) + { + this.expectedException = expectedException; + this.runAsUser = runAsUser; + } + + public BehaviourDrivenTest(String runAsUser) + { + this.runAsUser = runAsUser; + } + + public BehaviourDrivenTest(String runAsUser, boolean runInTransactionTests) + { + this.runInTransactionTests = runInTransactionTests; + if (runAsUser != null) + { + this.runAsUser = runAsUser; + } + } + + public void given() throws Exception { /** empty implementation */ } + + public void when() throws Exception { /** empty implementation */ } + + public void then() throws Exception { /** empty implementation */ } + + public void after() throws Exception { /** empty implementation */ } + + public void run() throws Exception + { + try + { + if (runInTransactionTests) + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + given(); + } + }, runAsUser); + } + else + { + given(); + } + + if (expectedException == null) + { + if (runInTransactionTests) + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + when(); + } + }, runAsUser); + + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + then(); + } + }, runAsUser); + } + else + { + when(); + then(); + } + } + else + { + doTestInTransaction(new FailureTest(expectedException) + { + @Override + public void run() throws Exception + { + when(); + } + }, runAsUser); + } + } + finally + { + if (runInTransactionTests) + { + doTestInTransaction(new VoidTest() + { + @Override + public void runImpl() throws Exception + { + after(); + } + }, runAsUser); + } + else + { + after(); + } + } + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java index ac9c6f6798..0224c2a4fe 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java @@ -1,391 +1,391 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.site.SiteServiceImpl; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.web.scripts.BaseWebScriptTest; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Period; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; -import org.springframework.context.ApplicationContext; - -/** - * @author Roy Wetherall - */ -public class BaseRMWebScriptTestCase extends BaseWebScriptTest -{ - /** Common test utils */ - protected CommonRMTestUtils utils; - - /** Application context */ - protected ApplicationContext applicationContext; - - /** Services */ - protected NodeService nodeService; - protected ContentService contentService; - protected DictionaryService dictionaryService; - protected RetryingTransactionHelper retryingTransactionHelper; - protected PolicyComponent policyComponent; - protected NamespaceService namespaceService; - protected SearchService searchService; - protected SiteService siteService; - protected MutableAuthenticationService authenticationService; - protected AuthorityService authorityService; - protected PersonService personService; - protected TransactionService transactionService; - protected TaggingService taggingService; - - /** RM Services */ - protected DispositionService dispositionService; - protected RecordsManagementEventService eventService; - protected RecordsManagementAdminService adminService; - protected RecordsManagementActionService actionService; - protected RecordsManagementSearchService rmSearchService; - protected FilePlanRoleService filePlanRoleService; - protected FilePlanPermissionService filePlanPermissionService; - protected RecordsManagementAuditService auditService; - protected CapabilityService capabilityService; - protected VitalRecordService vitalRecordService; - protected FilePlanService filePlanService; - protected RecordFolderService recordFolderService; - protected RMCaveatConfigService caveatConfigService; - - /** test data */ - protected String siteId; - protected StoreRef storeRef; - protected NodeRef rootNodeRef; - protected SiteInfo siteInfo; - protected NodeRef folder; - protected NodeRef filePlan; - protected NodeRef recordSeries; // A category with no disposition schedule - protected NodeRef recordCategory; - protected DispositionSchedule dispositionSchedule; - protected NodeRef recordFolder; - protected NodeRef recordFolder2; - protected String collabSiteId; - - /** admin user name */ - protected static final String ADMIN_USER = "admin"; - - /** - * Indicates whether the test collaboration site should be created - * or not. - */ - protected boolean isCollaborationSiteTest() - { - return false; - } - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - // Initialise the service beans - initServices(); - - // Setup test data - setupTestData(); - } - - /** - * Initialise the service beans. - */ - protected void initServices() - { - applicationContext = getServer().getApplicationContext(); - - // Common test utils - utils = new CommonRMTestUtils(applicationContext); - - // Get services - nodeService = (NodeService)applicationContext.getBean("NodeService"); - contentService = (ContentService)applicationContext.getBean("ContentService"); - retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); - namespaceService = (NamespaceService)applicationContext.getBean("NamespaceService"); - searchService = (SearchService)applicationContext.getBean("SearchService"); - policyComponent = (PolicyComponent)applicationContext.getBean("policyComponent"); - dictionaryService = (DictionaryService)applicationContext.getBean("DictionaryService"); - siteService = (SiteService)applicationContext.getBean("SiteService"); - authorityService = (AuthorityService)applicationContext.getBean("AuthorityService"); - authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService"); - personService = (PersonService)applicationContext.getBean("PersonService"); - transactionService = (TransactionService)applicationContext.getBean("TransactionService"); - taggingService = (TaggingService)applicationContext.getBean("TaggingService"); - - // Get RM services - dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); - eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); - adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); - actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService"); - rmSearchService = (RecordsManagementSearchService)applicationContext.getBean("RecordsManagementSearchService"); - filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); - filePlanPermissionService = (FilePlanPermissionService)applicationContext.getBean("FilePlanPermissionService"); - auditService = (RecordsManagementAuditService)applicationContext.getBean("RecordsManagementAuditService"); - capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); - vitalRecordService = (VitalRecordService)applicationContext.getBean("VitalRecordService"); - filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService"); - recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); - caveatConfigService = (RMCaveatConfigService)applicationContext.getBean("CaveatConfigService"); - } - - /** - * @see junit.framework.TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - // As system user - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - // Do the tear down - tearDownImpl(); - - return null; - } - }); - } - - /** - * Tear down implementation - */ - protected void tearDownImpl() - { - // Delete the folder - nodeService.deleteNode(folder); - - // Delete the site - siteService.deleteSite(siteId); - - // Delete the collaboration site (if required) - if (isCollaborationSiteTest()) - { - siteService.deleteSite(collabSiteId); - } - } - - /** - * Setup test data for tests - */ - protected void setupTestData() - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - setupTestDataImpl(); - return null; - } - }); - - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - // As system user - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, ADMIN_USER); - - return null; - } - }); - } - - /** - * Impl of test data setup - */ - protected void setupTestDataImpl() - { - storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; - rootNodeRef = nodeService.getRootNode(storeRef); - - // Create folder - String containerName = "RM2_" + System.currentTimeMillis(); - Map containerProps = new HashMap(1); - containerProps.put(ContentModel.PROP_NAME, containerName); - folder = nodeService.createNode( - rootNodeRef, - ContentModel.ASSOC_CHILDREN, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, containerName), - ContentModel.TYPE_FOLDER, - containerProps).getChildRef(); - assertNotNull("Could not create base folder", folder); - - // Create the site - siteId = getRMSiteId(); - siteInfo = siteService.createSite("rm-site-dashboard", siteId, "title", "descrition", SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE); - filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - assertNotNull("Site document library container was not created successfully.", filePlan); - - recordSeries = filePlanService.createRecordCategory(filePlan, "recordSeries"); - assertNotNull("Could not create record category with no disposition schedule", recordSeries); - - recordCategory = filePlanService.createRecordCategory(recordSeries, "rmContainer"); - assertNotNull("Could not create record category", recordCategory); - - // Make vital record - vitalRecordService.setVitalRecordDefintion(recordCategory, true, new Period("week|1")); - - // Create disposition schedule - dispositionSchedule = utils.createBasicDispositionSchedule(recordCategory); - - // Create RM folder - recordFolder = recordFolderService.createRecordFolder(recordCategory, "rmFolder"); - assertNotNull("Could not create rm folder", recordFolder); - recordFolder2 = recordFolderService.createRecordFolder(recordCategory, "rmFolder2"); - assertNotNull("Could not create rm folder 2", recordFolder2); - - // Create collaboration data - if (isCollaborationSiteTest()) - { - setupCollaborationSiteTestData(); - } - } - - protected void setupCollaborationSiteTestData() - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - @Override - public Object execute() throws Throwable - { - // As system user - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - setupCollaborationSiteTestDataImpl(); - - return null; - } - }); - } - - protected void setupCollaborationSiteTestDataImpl() - { - // create collaboration site - collabSiteId = GUID.generate(); - siteService.createSite("preset", collabSiteId, "title", "description", SiteVisibility.PRIVATE); - NodeRef documentLibrary = SiteServiceImpl.getSiteContainer( - collabSiteId, - SiteService.DOCUMENT_LIBRARY, - true, - siteService, - transactionService, - taggingService); - - assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary); - } - - protected void createUser(String userName) - { - if (!authenticationService.authenticationExists(userName)) - { - authenticationService.createAuthentication(userName, "PWD".toCharArray()); - - PropertyMap ppOne = new PropertyMap(4); - ppOne.put(ContentModel.PROP_USERNAME, userName); - ppOne.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + userName); - ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName"); - ppOne.put(ContentModel.PROP_LASTNAME, "lastName"); - ppOne.put(ContentModel.PROP_EMAIL, "email@email.com"); - ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); - - personService.createPerson(ppOne); - } - } - - protected void deleteUser(String userName) - { - if (authenticationService.authenticationExists(userName)) - { - personService.deletePerson(userName); - } - } - - protected void createGroup(String groupName) - { - if (!authorityService.authorityExists(groupName)) - { - authorityService.createAuthority(AuthorityType.GROUP, groupName); - } - } - - protected void deleteGroup(String groupName) - { - if (authorityService.authorityExists(groupName)) - { - authorityService.deleteAuthority(groupName, true); - } - } - - protected String getRMSiteId() - { - return GUID.generate(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.site.SiteServiceImpl; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.repo.web.scripts.BaseWebScriptTest; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.AuthorityType; +import org.alfresco.service.cmr.security.MutableAuthenticationService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; +import org.alfresco.service.cmr.tagging.TaggingService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.GUID; +import org.alfresco.util.PropertyMap; +import org.springframework.context.ApplicationContext; + +/** + * @author Roy Wetherall + */ +public class BaseRMWebScriptTestCase extends BaseWebScriptTest +{ + /** Common test utils */ + protected CommonRMTestUtils utils; + + /** Application context */ + protected ApplicationContext applicationContext; + + /** Services */ + protected NodeService nodeService; + protected ContentService contentService; + protected DictionaryService dictionaryService; + protected RetryingTransactionHelper retryingTransactionHelper; + protected PolicyComponent policyComponent; + protected NamespaceService namespaceService; + protected SearchService searchService; + protected SiteService siteService; + protected MutableAuthenticationService authenticationService; + protected AuthorityService authorityService; + protected PersonService personService; + protected TransactionService transactionService; + protected TaggingService taggingService; + + /** RM Services */ + protected DispositionService dispositionService; + protected RecordsManagementEventService eventService; + protected RecordsManagementAdminService adminService; + protected RecordsManagementActionService actionService; + protected RecordsManagementSearchService rmSearchService; + protected FilePlanRoleService filePlanRoleService; + protected FilePlanPermissionService filePlanPermissionService; + protected RecordsManagementAuditService auditService; + protected CapabilityService capabilityService; + protected VitalRecordService vitalRecordService; + protected FilePlanService filePlanService; + protected RecordFolderService recordFolderService; + protected RMCaveatConfigService caveatConfigService; + + /** test data */ + protected String siteId; + protected StoreRef storeRef; + protected NodeRef rootNodeRef; + protected SiteInfo siteInfo; + protected NodeRef folder; + protected NodeRef filePlan; + protected NodeRef recordSeries; // A category with no disposition schedule + protected NodeRef recordCategory; + protected DispositionSchedule dispositionSchedule; + protected NodeRef recordFolder; + protected NodeRef recordFolder2; + protected String collabSiteId; + + /** admin user name */ + protected static final String ADMIN_USER = "admin"; + + /** + * Indicates whether the test collaboration site should be created + * or not. + */ + protected boolean isCollaborationSiteTest() + { + return false; + } + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + // Initialise the service beans + initServices(); + + // Setup test data + setupTestData(); + } + + /** + * Initialise the service beans. + */ + protected void initServices() + { + applicationContext = getServer().getApplicationContext(); + + // Common test utils + utils = new CommonRMTestUtils(applicationContext); + + // Get services + nodeService = (NodeService)applicationContext.getBean("NodeService"); + contentService = (ContentService)applicationContext.getBean("ContentService"); + retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); + namespaceService = (NamespaceService)applicationContext.getBean("NamespaceService"); + searchService = (SearchService)applicationContext.getBean("SearchService"); + policyComponent = (PolicyComponent)applicationContext.getBean("policyComponent"); + dictionaryService = (DictionaryService)applicationContext.getBean("DictionaryService"); + siteService = (SiteService)applicationContext.getBean("SiteService"); + authorityService = (AuthorityService)applicationContext.getBean("AuthorityService"); + authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService"); + personService = (PersonService)applicationContext.getBean("PersonService"); + transactionService = (TransactionService)applicationContext.getBean("TransactionService"); + taggingService = (TaggingService)applicationContext.getBean("TaggingService"); + + // Get RM services + dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); + eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); + adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); + actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService"); + rmSearchService = (RecordsManagementSearchService)applicationContext.getBean("RecordsManagementSearchService"); + filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); + filePlanPermissionService = (FilePlanPermissionService)applicationContext.getBean("FilePlanPermissionService"); + auditService = (RecordsManagementAuditService)applicationContext.getBean("RecordsManagementAuditService"); + capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); + vitalRecordService = (VitalRecordService)applicationContext.getBean("VitalRecordService"); + filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService"); + recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); + caveatConfigService = (RMCaveatConfigService)applicationContext.getBean("CaveatConfigService"); + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + // As system user + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + // Do the tear down + tearDownImpl(); + + return null; + } + }); + } + + /** + * Tear down implementation + */ + protected void tearDownImpl() + { + // Delete the folder + nodeService.deleteNode(folder); + + // Delete the site + siteService.deleteSite(siteId); + + // Delete the collaboration site (if required) + if (isCollaborationSiteTest()) + { + siteService.deleteSite(collabSiteId); + } + } + + /** + * Setup test data for tests + */ + protected void setupTestData() + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + setupTestDataImpl(); + return null; + } + }); + + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + // As system user + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); + + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, ADMIN_USER); + + return null; + } + }); + } + + /** + * Impl of test data setup + */ + protected void setupTestDataImpl() + { + storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; + rootNodeRef = nodeService.getRootNode(storeRef); + + // Create folder + String containerName = "RM2_" + System.currentTimeMillis(); + Map containerProps = new HashMap(1); + containerProps.put(ContentModel.PROP_NAME, containerName); + folder = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, containerName), + ContentModel.TYPE_FOLDER, + containerProps).getChildRef(); + assertNotNull("Could not create base folder", folder); + + // Create the site + siteId = getRMSiteId(); + siteInfo = siteService.createSite("rm-site-dashboard", siteId, "title", "descrition", SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE); + filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); + assertNotNull("Site document library container was not created successfully.", filePlan); + + recordSeries = filePlanService.createRecordCategory(filePlan, "recordSeries"); + assertNotNull("Could not create record category with no disposition schedule", recordSeries); + + recordCategory = filePlanService.createRecordCategory(recordSeries, "rmContainer"); + assertNotNull("Could not create record category", recordCategory); + + // Make vital record + vitalRecordService.setVitalRecordDefintion(recordCategory, true, new Period("week|1")); + + // Create disposition schedule + dispositionSchedule = utils.createBasicDispositionSchedule(recordCategory); + + // Create RM folder + recordFolder = recordFolderService.createRecordFolder(recordCategory, "rmFolder"); + assertNotNull("Could not create rm folder", recordFolder); + recordFolder2 = recordFolderService.createRecordFolder(recordCategory, "rmFolder2"); + assertNotNull("Could not create rm folder 2", recordFolder2); + + // Create collaboration data + if (isCollaborationSiteTest()) + { + setupCollaborationSiteTestData(); + } + } + + protected void setupCollaborationSiteTestData() + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Object execute() throws Throwable + { + // As system user + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + setupCollaborationSiteTestDataImpl(); + + return null; + } + }); + } + + protected void setupCollaborationSiteTestDataImpl() + { + // create collaboration site + collabSiteId = GUID.generate(); + siteService.createSite("preset", collabSiteId, "title", "description", SiteVisibility.PRIVATE); + NodeRef documentLibrary = SiteServiceImpl.getSiteContainer( + collabSiteId, + SiteService.DOCUMENT_LIBRARY, + true, + siteService, + transactionService, + taggingService); + + assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary); + } + + protected void createUser(String userName) + { + if (!authenticationService.authenticationExists(userName)) + { + authenticationService.createAuthentication(userName, "PWD".toCharArray()); + + PropertyMap ppOne = new PropertyMap(4); + ppOne.put(ContentModel.PROP_USERNAME, userName); + ppOne.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + userName); + ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName"); + ppOne.put(ContentModel.PROP_LASTNAME, "lastName"); + ppOne.put(ContentModel.PROP_EMAIL, "email@email.com"); + ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); + + personService.createPerson(ppOne); + } + } + + protected void deleteUser(String userName) + { + if (authenticationService.authenticationExists(userName)) + { + personService.deletePerson(userName); + } + } + + protected void createGroup(String groupName) + { + if (!authorityService.authorityExists(groupName)) + { + authorityService.createAuthority(AuthorityType.GROUP, groupName); + } + } + + protected void deleteGroup(String groupName) + { + if (authorityService.authorityExists(groupName)) + { + authorityService.deleteAuthority(groupName, true); + } + } + + protected String getRMSiteId() + { + return GUID.generate(); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java index c9abd8935e..3d66cb81bb 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java @@ -1,312 +1,312 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; -import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ContentService; -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.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.springframework.context.ApplicationContext; - -/** - * Common RM test utility methods. - * - * @author Roy Wetherall - */ -public class CommonRMTestUtils implements RecordsManagementModel -{ - private DispositionService dispositionService; - private NodeService nodeService; - private ContentService contentService; - private RecordsManagementActionService actionService; - private ModelSecurityService modelSecurityService; - private FilePlanRoleService filePlanRoleService; - private CapabilityService capabilityService; - - /** test values */ - public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority"; - public static final String DEFAULT_DISPOSITION_INSTRUCTIONS = "disposition instructions"; - public static final String DEFAULT_DISPOSITION_DESCRIPTION = "disposition action description"; - public static final String DEFAULT_EVENT_NAME = "case_closed"; - public static final String PERIOD_NONE = "none|0"; - public static final String PERIOD_IMMEDIATELY = "immediately|0"; - - /** - * Constructor - * - * @param applicationContext application context - */ - public CommonRMTestUtils(ApplicationContext applicationContext) - { - dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); - nodeService = (NodeService)applicationContext.getBean("NodeService"); - contentService = (ContentService)applicationContext.getBean("ContentService"); - actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService"); - modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService"); - filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); - capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); - } - - /** - * Create a disposition schedule - * - * @param container record category - * @return {@link DispositionSchedule} created disposition schedule node reference - */ - public DispositionSchedule createBasicDispositionSchedule(NodeRef container) - { - return createBasicDispositionSchedule(container, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true); - } - - /** - * Create test disposition schedule - */ - public DispositionSchedule createBasicDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions) - { - return createDispositionSchedule(container, dispositionInstructions, dispositionAuthority, isRecordLevel, defaultDispositionActions, false); - } - - /** - * Create test disposition schedule - */ - public DispositionSchedule createDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions, - boolean extendedDispositionSchedule) - { - return createDispositionSchedule( - container, - dispositionInstructions, - dispositionAuthority, - isRecordLevel, - defaultDispositionActions, - extendedDispositionSchedule, - DEFAULT_EVENT_NAME); - } - - /** - * Create test disposition schedule - */ - public DispositionSchedule createDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions, - boolean extendedDispositionSchedule, - String defaultEvent) - { - Map dsProps = new HashMap(3); - dsProps.put(PROP_DISPOSITION_AUTHORITY, dispositionAuthority); - dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, dispositionInstructions); - dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, isRecordLevel); - DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(container, dsProps); - - if (defaultDispositionActions) - { - Map adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); - - List events = new ArrayList(1); - events.add(defaultEvent); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - - dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - - if (extendedDispositionSchedule) - { - adParams = new HashMap(4); - adParams.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); - adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY); - adParams.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY); - - dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - } - - adParams = new HashMap(3); - adParams.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME); - adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); - adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY); - - dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - } - - return dispositionSchedule; - } - - public NodeRef createRecord(NodeRef recordFolder, String name) - { - return createRecord(recordFolder, name, null, "Some test content"); - } - - public NodeRef createRecord(NodeRef recordFolder, String name, String title) - { - Map props = new HashMap(1); - props.put(ContentModel.PROP_TITLE, title); - return createRecord(recordFolder, name, props, "Some test content"); - } - - public NodeRef createRecord(NodeRef recordFolder, String name, Map properties, String content) - { - // Create the document - if (properties == null) - { - properties = new HashMap(1); - } - if (!properties.containsKey(ContentModel.PROP_NAME)) - { - properties.put(ContentModel.PROP_NAME, name); - } - NodeRef recordOne = nodeService.createNode(recordFolder, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), - ContentModel.TYPE_CONTENT, - properties).getChildRef(); - - // Set the content - ContentWriter writer = contentService.getWriter(recordOne, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - writer.putContent(content); - - return recordOne; - } - - /** - * Helper method to complete record. - */ - public void completeRecord(final NodeRef record) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - modelSecurityService.setEnabled(false); - try - { - nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date()); - nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue"); - actionService.executeRecordsManagementAction(record, "declareRecord"); - } - finally - { - modelSecurityService.setEnabled(true); - } - - return null; - } - - }, AuthenticationUtil.getAdminUserName()); - - } - - public void closeFolder(final NodeRef recordFolder) - { - AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public Void doWork() throws Exception - { - modelSecurityService.setEnabled(false); - try - { - actionService.executeRecordsManagementAction(recordFolder, "closeRecordFolder"); - } - finally - { - modelSecurityService.setEnabled(true); - } - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames) - { - Set capabilities = new HashSet(capabilityNames.length); - for (String name : capabilityNames) - { - Capability capability = capabilityService.getCapability(name); - if (capability == null) - { - throw new AlfrescoRuntimeException("capability " + name + " not found."); - } - capabilities.add(capability); - } - - return filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); - } - - /** - * Helper method to complete event on disposable item - * - * @param disposableItem disposable item (record or record folder) - * @param eventName event name - */ - public void completeEvent(NodeRef disposableItem, String eventName) - { - // build action properties - Map params = new HashMap(1); - params.put(CompleteEventAction.PARAM_EVENT_NAME, eventName); - - // complete event - actionService.executeRecordsManagementAction(disposableItem, CompleteEventAction.NAME, params); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.repository.ContentService; +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.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.StringUtils; +import org.springframework.context.ApplicationContext; + +/** + * Common RM test utility methods. + * + * @author Roy Wetherall + */ +public class CommonRMTestUtils implements RecordsManagementModel +{ + private DispositionService dispositionService; + private NodeService nodeService; + private ContentService contentService; + private RecordsManagementActionService actionService; + private ModelSecurityService modelSecurityService; + private FilePlanRoleService filePlanRoleService; + private CapabilityService capabilityService; + + /** test values */ + public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority"; + public static final String DEFAULT_DISPOSITION_INSTRUCTIONS = "disposition instructions"; + public static final String DEFAULT_DISPOSITION_DESCRIPTION = "disposition action description"; + public static final String DEFAULT_EVENT_NAME = "case_closed"; + public static final String PERIOD_NONE = "none|0"; + public static final String PERIOD_IMMEDIATELY = "immediately|0"; + + /** + * Constructor + * + * @param applicationContext application context + */ + public CommonRMTestUtils(ApplicationContext applicationContext) + { + dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); + nodeService = (NodeService)applicationContext.getBean("NodeService"); + contentService = (ContentService)applicationContext.getBean("ContentService"); + actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService"); + modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService"); + filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); + capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); + } + + /** + * Create a disposition schedule + * + * @param container record category + * @return {@link DispositionSchedule} created disposition schedule node reference + */ + public DispositionSchedule createBasicDispositionSchedule(NodeRef container) + { + return createBasicDispositionSchedule(container, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_AUTHORITY, false, true); + } + + /** + * Create test disposition schedule + */ + public DispositionSchedule createBasicDispositionSchedule( + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions) + { + return createDispositionSchedule(container, dispositionInstructions, dispositionAuthority, isRecordLevel, defaultDispositionActions, false); + } + + /** + * Create test disposition schedule + */ + public DispositionSchedule createDispositionSchedule( + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions, + boolean extendedDispositionSchedule) + { + return createDispositionSchedule( + container, + dispositionInstructions, + dispositionAuthority, + isRecordLevel, + defaultDispositionActions, + extendedDispositionSchedule, + DEFAULT_EVENT_NAME); + } + + /** + * Create test disposition schedule + */ + public DispositionSchedule createDispositionSchedule( + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions, + boolean extendedDispositionSchedule, + String defaultEvent) + { + Map dsProps = new HashMap(3); + dsProps.put(PROP_DISPOSITION_AUTHORITY, dispositionAuthority); + dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, dispositionInstructions); + dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, isRecordLevel); + DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(container, dsProps); + + if (defaultDispositionActions) + { + Map adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); + + List events = new ArrayList(1); + events.add(defaultEvent); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); + + if (extendedDispositionSchedule) + { + adParams = new HashMap(4); + adParams.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); + adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY); + adParams.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); + } + + adParams = new HashMap(3); + adParams.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME); + adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION); + adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); + } + + return dispositionSchedule; + } + + public NodeRef createRecord(NodeRef recordFolder, String name) + { + return createRecord(recordFolder, name, null, "Some test content"); + } + + public NodeRef createRecord(NodeRef recordFolder, String name, String title) + { + Map props = new HashMap(1); + props.put(ContentModel.PROP_TITLE, title); + return createRecord(recordFolder, name, props, "Some test content"); + } + + public NodeRef createRecord(NodeRef recordFolder, String name, Map properties, String content) + { + // Create the document + if (properties == null) + { + properties = new HashMap(1); + } + if (!properties.containsKey(ContentModel.PROP_NAME)) + { + properties.put(ContentModel.PROP_NAME, name); + } + NodeRef recordOne = nodeService.createNode(recordFolder, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), + ContentModel.TYPE_CONTENT, + properties).getChildRef(); + + // Set the content + ContentWriter writer = contentService.getWriter(recordOne, ContentModel.PROP_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.setEncoding("UTF-8"); + writer.putContent(content); + + return recordOne; + } + + /** + * Helper method to complete record. + */ + public void completeRecord(final NodeRef record) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + modelSecurityService.setEnabled(false); + try + { + nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date()); + nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue"); + actionService.executeRecordsManagementAction(record, "declareRecord"); + } + finally + { + modelSecurityService.setEnabled(true); + } + + return null; + } + + }, AuthenticationUtil.getAdminUserName()); + + } + + public void closeFolder(final NodeRef recordFolder) + { + AuthenticationUtil.runAs(new RunAsWork() + { + @Override + public Void doWork() throws Exception + { + modelSecurityService.setEnabled(false); + try + { + actionService.executeRecordsManagementAction(recordFolder, "closeRecordFolder"); + } + finally + { + modelSecurityService.setEnabled(true); + } + return null; + } + }, AuthenticationUtil.getAdminUserName()); + } + + public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames) + { + Set capabilities = new HashSet(capabilityNames.length); + for (String name : capabilityNames) + { + Capability capability = capabilityService.getCapability(name); + if (capability == null) + { + throw new AlfrescoRuntimeException("capability " + name + " not found."); + } + capabilities.add(capability); + } + + return filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + } + + /** + * Helper method to complete event on disposable item + * + * @param disposableItem disposable item (record or record folder) + * @param eventName event name + */ + public void completeEvent(NodeRef disposableItem, String eventName) + { + // build action properties + Map params = new HashMap(1); + params.put(CompleteEventAction.PARAM_EVENT_NAME, eventName); + + // complete event + actionService.executeRecordsManagementAction(disposableItem, CompleteEventAction.NAME, params); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/GenerateCapabilityReport.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/GenerateCapabilityReport.java index 5da184efee..82c268a4a6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/GenerateCapabilityReport.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/GenerateCapabilityReport.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.Group; - - -/** - * Utility test case to generate a report of the capabilities in the system. - * - * @author Roy Wetherall - * @since 2.1 - */ -public class GenerateCapabilityReport extends BaseRMTestCase -{ - public void testGetCapability() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - FileWriter writer = new FileWriter("c:\\mywork\\capabilityReport.csv"); - BufferedWriter out = new BufferedWriter(writer); - try - { - Set capabilities = capabilityService.getCapabilities(true); - for (Capability capability : capabilities) - { - Group group = capability.getGroup(); - String groupId = "none"; - if (group != null) - { - groupId = group.getId(); - } - - out.write(groupId); - out.write(","); - out.write(capability.getName()); - out.write(","); - out.write(Boolean.toString(capability.isPrivate())); - out.write("\n"); - } - } - finally - { - out.close(); - } - - return null; - } - }); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.Group; + + +/** + * Utility test case to generate a report of the capabilities in the system. + * + * @author Roy Wetherall + * @since 2.1 + */ +public class GenerateCapabilityReport extends BaseRMTestCase +{ + public void testGetCapability() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + FileWriter writer = new FileWriter("c:\\mywork\\capabilityReport.csv"); + BufferedWriter out = new BufferedWriter(writer); + try + { + Set capabilities = capabilityService.getCapabilities(true); + for (Capability capability : capabilities) + { + Group group = capability.getGroup(); + String groupId = "none"; + if (group != null) + { + groupId = group.getId(); + } + + out.write(groupId); + out.write(","); + out.write(capability.getName()); + out.write(","); + out.write(Boolean.toString(capability.isPrivate())); + out.write("\n"); + } + } + finally + { + out.close(); + } + + return null; + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/RetryingTransactionHelperBaseTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/RetryingTransactionHelperBaseTest.java index a46cc21897..29d3eb4617 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/RetryingTransactionHelperBaseTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/RetryingTransactionHelperBaseTest.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.RetryingTransactionHelperTestCase; -import org.springframework.context.ApplicationContext; - -/** - * Base unit test for a simple retrying transaction helper test case. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RetryingTransactionHelperBaseTest extends RetryingTransactionHelperTestCase -{ - /** Application context */ - protected static final String[] CONFIG_LOCATIONS = new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml" - }; - protected ApplicationContext applicationContext; - - /** retrying transaction helper */ - protected RetryingTransactionHelper retryingTransactionHelper; - - /** - * @see org.alfresco.util.RetryingTransactionHelperTestCase#getRetryingTransactionHelper() - */ - @Override - public RetryingTransactionHelper getRetryingTransactionHelper() - { - return retryingTransactionHelper; - } - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception - { - // Get the application context - applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); - - // get the retrying transaction helper - retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.RetryingTransactionHelperTestCase; +import org.springframework.context.ApplicationContext; + +/** + * Base unit test for a simple retrying transaction helper test case. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RetryingTransactionHelperBaseTest extends RetryingTransactionHelperTestCase +{ + /** Application context */ + protected static final String[] CONFIG_LOCATIONS = new String[] + { + "classpath:alfresco/application-context.xml", + "classpath:test-context.xml" + }; + protected ApplicationContext applicationContext; + + /** retrying transaction helper */ + protected RetryingTransactionHelper retryingTransactionHelper; + + /** + * @see org.alfresco.util.RetryingTransactionHelperTestCase#getRetryingTransactionHelper() + */ + @Override + public RetryingTransactionHelper getRetryingTransactionHelper() + { + return retryingTransactionHelper; + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + // Get the application context + applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); + + // get the retrying transaction helper + retryingTransactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction.java index e329ba5bed..f2e76befe3 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -public class TestAction extends RMActionExecuterAbstractBase -{ - public static final String NAME = "testAction"; - public static final String PARAM = "testActionParam"; - public static final String PARAM_VALUE = "value"; - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - if (!action.getParameterValue(PARAM).equals(PARAM_VALUE)) - { - throw new RuntimeException("Unexpected parameter value. Expected " + PARAM_VALUE + " actual " + action.getParameterValue(PARAM)); - } - this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_RECORD, null); - } - - @Override - public boolean isDispositionAction() - { - return true; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +public class TestAction extends RMActionExecuterAbstractBase +{ + public static final String NAME = "testAction"; + public static final String PARAM = "testActionParam"; + public static final String PARAM_VALUE = "value"; + + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + if (!action.getParameterValue(PARAM).equals(PARAM_VALUE)) + { + throw new RuntimeException("Unexpected parameter value. Expected " + PARAM_VALUE + " actual " + action.getParameterValue(PARAM)); + } + this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_RECORD, null); + } + + @Override + public boolean isDispositionAction() + { + return true; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction2.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction2.java index ae32d8a920..b79f3c3ce6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction2.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestAction2.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -public class TestAction2 extends RMActionExecuterAbstractBase -{ - public static final String NAME = "testAction2"; - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // Do nothing - } - - @Override - public boolean isDispositionAction() - { - return false; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +public class TestAction2 extends RMActionExecuterAbstractBase +{ + public static final String NAME = "testAction2"; + + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // Do nothing + } + + @Override + public boolean isDispositionAction() + { + return false; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionParams.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionParams.java index 8bbecc22e3..fbd502b7f8 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionParams.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionParams.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; - -public class TestActionParams extends RMActionExecuterAbstractBase -{ - public static final String NAME = "testActionParams"; - public static final String PARAM_DATE = "paramDate"; - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - Object dateValue = action.getParameterValue(PARAM_DATE); - if (!(dateValue instanceof java.util.Date)) - { - throw new AlfrescoRuntimeException("Param was not a Date as expected."); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; + +public class TestActionParams extends RMActionExecuterAbstractBase +{ + public static final String NAME = "testActionParams"; + public static final String PARAM_DATE = "paramDate"; + + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + Object dateValue = action.getParameterValue(PARAM_DATE); + if (!(dateValue instanceof java.util.Date)) + { + throw new AlfrescoRuntimeException("Param was not a Date as expected."); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionPropertySubs.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionPropertySubs.java index 3c4186ab3b..f6a8f2a781 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionPropertySubs.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestActionPropertySubs.java @@ -1,102 +1,102 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.springframework.extensions.surf.util.I18NUtil; - -public class TestActionPropertySubs extends RMActionExecuterAbstractBase -{ - public static final String NAME = "testActionPropertySubs"; - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl("dayShort", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("dayShort2", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("dayLong", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("dayNumber", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("dayYear", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("monthShort", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("monthShort2", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("monthLong", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("monthNumber", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("yearShort", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("yearShort2", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("yearLong", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("yearWeek", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("name", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("company", DataTypeDefinition.TEXT, false, "")); - paramList.add(new ParameterDefinitionImpl("combo", DataTypeDefinition.TEXT, false, "")); - } - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - Date date = new Date(); - String dayShort = new SimpleDateFormat("EE").format(date); - String dayLong = new SimpleDateFormat("EEEE").format(date); - String dayNumber = new SimpleDateFormat("uu").format(date); - String dayYear = new SimpleDateFormat("DDD").format(date); - String monthShort = new SimpleDateFormat("MMM").format(date); - String monthLong = new SimpleDateFormat("MMMM").format(date); - String monthNumber = new SimpleDateFormat("MM").format(date); - String yearShort = new SimpleDateFormat("yy").format(date); - String yearLong = new SimpleDateFormat("yyyy").format(date); - String yearWeek = new SimpleDateFormat("ww").format(date); - String name = (String) getNodeService().getProperty(actionedUponNodeRef, ContentModel.PROP_NAME); - String company = I18NUtil.getMessage("test.company"); - - assertEquals(dayShort, (String) action.getParameterValue("dayShort")); - assertEquals(dayShort, (String) action.getParameterValue("dayShort2")); - assertEquals(dayLong, (String) action.getParameterValue("dayLong")); - assertEquals(dayNumber, (String) action.getParameterValue("dayNumber")); - assertEquals(dayYear, (String) action.getParameterValue("dayYear")); - assertEquals(monthShort, (String) action.getParameterValue("monthShort")); - assertEquals(monthShort, (String) action.getParameterValue("monthShort2")); - assertEquals(monthLong, (String) action.getParameterValue("monthLong")); - assertEquals(monthNumber, (String) action.getParameterValue("monthNumber")); - assertEquals(yearShort, (String) action.getParameterValue("yearShort")); - assertEquals(yearShort, (String) action.getParameterValue("yearShort2")); - assertEquals(yearLong, (String) action.getParameterValue("yearLong")); - assertEquals(yearWeek, (String) action.getParameterValue("yearWeek")); - assertEquals(name, (String)action.getParameterValue("name")); - assertEquals(company, (String)action.getParameterValue("company")); - assertEquals(yearLong + "/" + monthShort + "/" + name + "-" + company +".txt", (String) action.getParameterValue("combo")); - } - - private void assertEquals(String expected, String actual) - { - if (!expected.equals(actual)) - { - throw new AlfrescoRuntimeException("Expected value " + expected + " does not match actual value " + actual); - } - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +public class TestActionPropertySubs extends RMActionExecuterAbstractBase +{ + public static final String NAME = "testActionPropertySubs"; + + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl("dayShort", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("dayShort2", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("dayLong", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("dayNumber", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("dayYear", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("monthShort", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("monthShort2", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("monthLong", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("monthNumber", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("yearShort", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("yearShort2", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("yearLong", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("yearWeek", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("name", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("company", DataTypeDefinition.TEXT, false, "")); + paramList.add(new ParameterDefinitionImpl("combo", DataTypeDefinition.TEXT, false, "")); + } + + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + Date date = new Date(); + String dayShort = new SimpleDateFormat("EE").format(date); + String dayLong = new SimpleDateFormat("EEEE").format(date); + String dayNumber = new SimpleDateFormat("uu").format(date); + String dayYear = new SimpleDateFormat("DDD").format(date); + String monthShort = new SimpleDateFormat("MMM").format(date); + String monthLong = new SimpleDateFormat("MMMM").format(date); + String monthNumber = new SimpleDateFormat("MM").format(date); + String yearShort = new SimpleDateFormat("yy").format(date); + String yearLong = new SimpleDateFormat("yyyy").format(date); + String yearWeek = new SimpleDateFormat("ww").format(date); + String name = (String) getNodeService().getProperty(actionedUponNodeRef, ContentModel.PROP_NAME); + String company = I18NUtil.getMessage("test.company"); + + assertEquals(dayShort, (String) action.getParameterValue("dayShort")); + assertEquals(dayShort, (String) action.getParameterValue("dayShort2")); + assertEquals(dayLong, (String) action.getParameterValue("dayLong")); + assertEquals(dayNumber, (String) action.getParameterValue("dayNumber")); + assertEquals(dayYear, (String) action.getParameterValue("dayYear")); + assertEquals(monthShort, (String) action.getParameterValue("monthShort")); + assertEquals(monthShort, (String) action.getParameterValue("monthShort2")); + assertEquals(monthLong, (String) action.getParameterValue("monthLong")); + assertEquals(monthNumber, (String) action.getParameterValue("monthNumber")); + assertEquals(yearShort, (String) action.getParameterValue("yearShort")); + assertEquals(yearShort, (String) action.getParameterValue("yearShort2")); + assertEquals(yearLong, (String) action.getParameterValue("yearLong")); + assertEquals(yearWeek, (String) action.getParameterValue("yearWeek")); + assertEquals(name, (String)action.getParameterValue("name")); + assertEquals(company, (String)action.getParameterValue("company")); + assertEquals(yearLong + "/" + monthShort + "/" + name + "-" + company +".txt", (String) action.getParameterValue("combo")); + } + + private void assertEquals(String expected, String actual) + { + if (!expected.equals(actual)) + { + throw new AlfrescoRuntimeException("Expected value " + expected + " does not match actual value " + actual); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java index ecc7b77c9e..d8c4bef661 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.util.List; - -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Roy Wetherall - * @since 2.1 - */ -public class TestDmAction extends ActionExecuterAbstractBase -{ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - } - - @Override - protected void addParameterDefinitions(List paramDefs) - { - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.util.List; + +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + * @since 2.1 + */ +public class TestDmAction extends ActionExecuterAbstractBase +{ + @Override + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + } + + @Override + protected void addParameterDefinitions(List paramDefs) + { + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestModel.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestModel.java index 31b2690545..b5483bda26 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestModel.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestModel.java @@ -1,34 +1,34 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - * @since 2.3 - */ -public interface TestModel -{ - public static final String TEST_URI = "http://www.alfresco.org/model/rmtest/1.0"; - public static final String TEST_PREFIX = "rmt"; - - public static final QName ASPECT_RECORD_METADATA = QName.createQName(TEST_URI, "recordMetaData"); - public static final QName PROPERTY_RECORD_METADATA = QName.createQName(TEST_URI, "recordMetaDataProperty"); -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + * @since 2.3 + */ +public interface TestModel +{ + public static final String TEST_URI = "http://www.alfresco.org/model/rmtest/1.0"; + public static final String TEST_PREFIX = "rmt"; + + public static final QName ASPECT_RECORD_METADATA = QName.createQName(TEST_URI, "recordMetaData"); + public static final QName PROPERTY_RECORD_METADATA = QName.createQName(TEST_URI, "recordMetaDataProperty"); +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestService.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestService.java index 5a3942d30c..d1f7cb074a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestService.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestService.java @@ -1,11 +1,11 @@ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.alfresco.service.cmr.repository.NodeRef; - -public interface TestService -{ - void testMethodOne(NodeRef nodeRef); - - void testMethodTwo(NodeRef nodeRef); - -} +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.alfresco.service.cmr.repository.NodeRef; + +public interface TestService +{ + void testMethodOne(NodeRef nodeRef); + + void testMethodTwo(NodeRef nodeRef); + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestServiceImpl.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestServiceImpl.java index f86ee1e877..fa0fedd780 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestServiceImpl.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestServiceImpl.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * @author Roy Wetherall - * @since 2.1 - */ -public class TestServiceImpl extends ServiceBaseImpl implements TestService -{ - @Override - public void testMethodOne(NodeRef nodeRef) - { - } - - @Override - public void testMethodTwo(NodeRef nodeRef) - { - } - - public boolean doInstanceOf(NodeRef nodeRef, QName ofClassName) - { - return instanceOf(nodeRef, ofClassName); - } - - public int doGetNextCount(NodeRef nodeRef) - { - return getNextCount(nodeRef); - } - - public Set doGetTypeAndApsects(NodeRef nodeRef) - { - return getTypeAndApsects(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * @author Roy Wetherall + * @since 2.1 + */ +public class TestServiceImpl extends ServiceBaseImpl implements TestService +{ + @Override + public void testMethodOne(NodeRef nodeRef) + { + } + + @Override + public void testMethodTwo(NodeRef nodeRef) + { + } + + public boolean doInstanceOf(NodeRef nodeRef, QName ofClassName) + { + return instanceOf(nodeRef, ofClassName); + } + + public int doGetNextCount(NodeRef nodeRef) + { + return getNextCount(nodeRef); + } + + public Set doGetTypeAndApsects(NodeRef nodeRef) + { + return getTypeAndApsects(nodeRef); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestWebScriptRepoServer.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestWebScriptRepoServer.java index f03385bb1f..8c8b3157ea 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestWebScriptRepoServer.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestWebScriptRepoServer.java @@ -1,221 +1,221 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.alfresco.repo.security.authentication.AuthenticationException; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.util.EqualsHelper; -import org.springframework.extensions.webscripts.TestWebScriptServer; -import org.springframework.context.support.ClassPathXmlApplicationContext; - - -/** - * Stand-alone Web Script Test Server - * - * @author davidc - */ -public class TestWebScriptRepoServer extends TestWebScriptServer -{ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.alfresco.repo.security.authentication.AuthenticationException; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.security.AuthenticationService; +import org.alfresco.util.EqualsHelper; +import org.springframework.extensions.webscripts.TestWebScriptServer; +import org.springframework.context.support.ClassPathXmlApplicationContext; + + +/** + * Stand-alone Web Script Test Server + * + * @author davidc + */ +public class TestWebScriptRepoServer extends TestWebScriptServer +{ /** - * Main entry point. - */ - public static void main(String[] args) - { - try - { - TestWebScriptServer testServer = getTestServer(); - AuthenticationUtil.setRunAsUserSystem(); - testServer.rep(); - } - catch(Throwable e) - { - StringWriter strWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(strWriter); - e.printStackTrace(printWriter); - System.out.println(strWriter.toString()); - } - finally - { - System.exit(0); - } - } - - private final static String[] CONFIG_LOCATIONS = new String[] + * Main entry point. + */ + public static void main(String[] args) + { + try + { + TestWebScriptServer testServer = getTestServer(); + AuthenticationUtil.setRunAsUserSystem(); + testServer.rep(); + } + catch(Throwable e) + { + StringWriter strWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(strWriter); + e.printStackTrace(printWriter); + System.out.println(strWriter.toString()); + } + finally + { + System.exit(0); + } + } + + private final static String[] CONFIG_LOCATIONS = new String[] { "classpath:alfresco/application-context.xml", "classpath:alfresco/web-scripts-application-context.xml", "classpath:alfresco/web-scripts-application-context-test.xml" }; - - /** A static reference to the application context being used */ - private static ClassPathXmlApplicationContext ctx; - private static String appendedTestConfiguration; - - private RetryingTransactionHelper retryingTransactionHelper; - private AuthenticationService authenticationService; - - - /** - * Sets helper that provides transaction callbacks - */ - public void setTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @param authenticationService - */ - public void setAuthenticationService(AuthenticationService authenticationService) - { - this.authenticationService = authenticationService; - } - - /** - * Get default user name - */ - protected String getDefaultUserName() - { - return AuthenticationUtil.getAdminUserName(); - } - - /** - * {@inheritDoc #getTestServer(String)} - */ - public static TestWebScriptServer getTestServer() - { - return getTestServer(null); - } - - /** - * Start up a context and get the server bean. - *

- * This method will close and restart the application context only if the configuration has - * changed. - * - * @param appendTestConfigLocation additional context file to include in the application context - * @return Test Server - */ - public static synchronized TestWebScriptServer getTestServer(String appendTestConfigLocation) - { - if (TestWebScriptRepoServer.ctx != null) - { - boolean configChanged = !EqualsHelper.nullSafeEquals( - appendTestConfigLocation, - TestWebScriptRepoServer.appendedTestConfiguration); - if (configChanged) - { - // The config changed, so close the context (it'll be restarted later) - try - { - ctx.close(); - ctx = null; - } - catch (Throwable e) - { - throw new RuntimeException("Failed to shut down existing application context", e); - } - } - else - { - // There is already a context with the required configuration - } - } - - // Check if we need to start/restart the context - if (TestWebScriptRepoServer.ctx == null) - { - // Restart it - final String[] configLocations; - if (appendTestConfigLocation == null) - { - configLocations = CONFIG_LOCATIONS; - } - else - { - configLocations = new String[CONFIG_LOCATIONS.length+1]; - System.arraycopy(CONFIG_LOCATIONS, 0, configLocations, 0, CONFIG_LOCATIONS.length); - configLocations[CONFIG_LOCATIONS.length] = appendTestConfigLocation; - } - TestWebScriptRepoServer.ctx = new ClassPathXmlApplicationContext(configLocations); - TestWebScriptRepoServer.appendedTestConfiguration = appendTestConfigLocation; - } - - // Get the bean - TestWebScriptServer testServer = (org.alfresco.repo.web.scripts.TestWebScriptRepoServer)TestWebScriptRepoServer.ctx.getBean("webscripts.test"); - return testServer; - } - - /** - * Interpret a single command using the BufferedReader passed in for any data needed. - * - * @param line The unparsed command - * @return The textual output of the command. - */ - @Override - protected String interpretCommand(final String line) - throws IOException - { - try - { - if (username.startsWith("TICKET_")) - { - try - { - retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public Object execute() throws Exception - { - authenticationService.validate(username); - return null; - } - }); - return executeCommand(line); - } - finally - { - authenticationService.clearCurrentSecurityContext(); - } - } - } - catch(AuthenticationException e) - { + + /** A static reference to the application context being used */ + private static ClassPathXmlApplicationContext ctx; + private static String appendedTestConfiguration; + + private RetryingTransactionHelper retryingTransactionHelper; + private AuthenticationService authenticationService; + + + /** + * Sets helper that provides transaction callbacks + */ + public void setTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + /** + * @param authenticationService + */ + public void setAuthenticationService(AuthenticationService authenticationService) + { + this.authenticationService = authenticationService; + } + + /** + * Get default user name + */ + protected String getDefaultUserName() + { + return AuthenticationUtil.getAdminUserName(); + } + + /** + * {@inheritDoc #getTestServer(String)} + */ + public static TestWebScriptServer getTestServer() + { + return getTestServer(null); + } + + /** + * Start up a context and get the server bean. + *

+ * This method will close and restart the application context only if the configuration has + * changed. + * + * @param appendTestConfigLocation additional context file to include in the application context + * @return Test Server + */ + public static synchronized TestWebScriptServer getTestServer(String appendTestConfigLocation) + { + if (TestWebScriptRepoServer.ctx != null) + { + boolean configChanged = !EqualsHelper.nullSafeEquals( + appendTestConfigLocation, + TestWebScriptRepoServer.appendedTestConfiguration); + if (configChanged) + { + // The config changed, so close the context (it'll be restarted later) + try + { + ctx.close(); + ctx = null; + } + catch (Throwable e) + { + throw new RuntimeException("Failed to shut down existing application context", e); + } + } + else + { + // There is already a context with the required configuration + } + } + + // Check if we need to start/restart the context + if (TestWebScriptRepoServer.ctx == null) + { + // Restart it + final String[] configLocations; + if (appendTestConfigLocation == null) + { + configLocations = CONFIG_LOCATIONS; + } + else + { + configLocations = new String[CONFIG_LOCATIONS.length+1]; + System.arraycopy(CONFIG_LOCATIONS, 0, configLocations, 0, CONFIG_LOCATIONS.length); + configLocations[CONFIG_LOCATIONS.length] = appendTestConfigLocation; + } + TestWebScriptRepoServer.ctx = new ClassPathXmlApplicationContext(configLocations); + TestWebScriptRepoServer.appendedTestConfiguration = appendTestConfigLocation; + } + + // Get the bean + TestWebScriptServer testServer = (org.alfresco.repo.web.scripts.TestWebScriptRepoServer)TestWebScriptRepoServer.ctx.getBean("webscripts.test"); + return testServer; + } + + /** + * Interpret a single command using the BufferedReader passed in for any data needed. + * + * @param line The unparsed command + * @return The textual output of the command. + */ + @Override + protected String interpretCommand(final String line) + throws IOException + { + try + { + if (username.startsWith("TICKET_")) + { + try + { + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() + { + public Object execute() throws Exception + { + authenticationService.validate(username); + return null; + } + }); + return executeCommand(line); + } + finally + { + authenticationService.clearCurrentSecurityContext(); + } + } + } + catch(AuthenticationException e) + { executeCommand("user " + getDefaultUserName()); - } - - // execute command in context of currently selected user - return AuthenticationUtil.runAs(new RunAsWork() - { - @SuppressWarnings("synthetic-access") - public String doWork() throws Exception - { - return executeCommand(line); - } - }, username); - } - -} + } + + // execute command in context of currently selected user + return AuthenticationUtil.runAs(new RunAsWork() + { + @SuppressWarnings("synthetic-access") + public String doWork() throws Exception + { + return executeCommand(line); + } + }, username); + } + +} diff --git a/rm-server/test/resources/alfresco/extension/rm-method-security.properties b/rm-server/test/resources/alfresco/extension/rm-method-security.properties index f1427d4545..0e1e0079dc 100644 --- a/rm-server/test/resources/alfresco/extension/rm-method-security.properties +++ b/rm-server/test/resources/alfresco/extension/rm-method-security.properties @@ -1,2 +1,2 @@ -rm.methodsecurity.org.alfresco.module.org_alfresco_module_rm.test.util.TestService.testMethodOne=RM_ALLOW +rm.methodsecurity.org.alfresco.module.org_alfresco_module_rm.test.util.TestService.testMethodOne=RM_ALLOW rm.methodsecurity.org.alfresco.module.org_alfresco_module_rm.test.util.TestService.*=RM_DENY \ No newline at end of file diff --git a/rm-server/test/resources/test-context.xml b/rm-server/test/resources/test-context.xml index b3abc98753..64cb8ff572 100644 --- a/rm-server/test/resources/test-context.xml +++ b/rm-server/test/resources/test-context.xml @@ -1,266 +1,266 @@ - - - - - - - - - - test-model.xml - - - - - - - - - - test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - RECORD - RECORD_FOLDER - - - - - - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - 0 30 3 * * ? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.test.util.TestService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - Search - - - buildonly - - - - manager - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + test-model.xml + + + + + + + + + + test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + RECORD + RECORD_FOLDER + + + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + + + 0 30 3 * * ? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.test.util.TestService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + Search + + + buildonly + + + + manager + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/test/resources/test-filePlan.xml b/rm-server/test/resources/test-filePlan.xml index b12a93f680..89054370b1 100644 --- a/rm-server/test/resources/test-filePlan.xml +++ b/rm-server/test/resources/test-filePlan.xml @@ -1,285 +1,285 @@ - - - - - - TestRecordCategory1 - 0001 - TestRecordCategory1 - TestRecordCategory1 description - - - - - - - - - TestRecordCategory11 - 0001-01 - TestRecordCategory11 - TestRecordCategory11 description - week|1 - true - - - - - - T0-000-00-1 item 001 - Cut off monthly, hold 1 month, then destroy. - - - - - - cutoff - monthend|1 - - - - - destroy - month|1 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - TestRecordFolder1 - TestRecordFolder1 - 0001-01-01 - week|1 - true - - - - - TestRecordFolder2 - TestRecordFolder2 - 0001-01-02 - week|1 - true - - - - - - - - - - - TestRecordCategory12 - 0001-02 - TestRecordCategory12 - TestRecordCategory12 description - - - - - - T0-000-00-1 item 002 - Cut off every 3 months, hold 3 months, then destroy. - - - - - - cutoff - quarterend|1 - - - - - destroy - month|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - TestRecordFolder3 - 0001-02-01 - TestRecordFolder3 - - - - - - - - - - - TestRecordCategory13 - 0001-03 - TestRecordCategory13 - TestRecordCategory13 description - - - - - - T0-000-00-1 item 003 - Cut off at end of FY, hold 3 years, then destroy. - - - - - - cutoff - fyend|1 - - - - - destroy - year|3 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - - TestRecordCategory2 - 0002 - TestRecordCategory2 - TestRecordCategory2 description - - - - - - - - - TestRecordCategory21 - 0002-01 - TestRecordCategory21 - TestRecordCategory21 description - - - - - - T0-000-00-2 item 001 - Cut off when superseded, hold 5 years, then destroy. - true - - - - - - cutoff - superseded - - - - - destroy - year|5 - {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate - - - - - - - - - - - - - - TestRecordCategory22 - 0002-02 - TestRecordCategory22 - TestRecordCategory22 description - - - - - - T0-000-00-2 item 002 - Cut off when no longer needed and destroy immediately. - - - - - - cutoff - no_longer_needed - - - - - destroy - immediately|0 - - - - - - - - - - TestRecordFolder4 - 0002-02-01 - TestRecordFolder4 - - - - - TestRecordFolder5 - 0002-02-02 - TestRecordFolder5 - - - - - - - - + + + + + + TestRecordCategory1 + 0001 + TestRecordCategory1 + TestRecordCategory1 description + + + + + + + + + TestRecordCategory11 + 0001-01 + TestRecordCategory11 + TestRecordCategory11 description + week|1 + true + + + + + + T0-000-00-1 item 001 + Cut off monthly, hold 1 month, then destroy. + + + + + + cutoff + monthend|1 + + + + + destroy + month|1 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + TestRecordFolder1 + TestRecordFolder1 + 0001-01-01 + week|1 + true + + + + + TestRecordFolder2 + TestRecordFolder2 + 0001-01-02 + week|1 + true + + + + + + + + + + + TestRecordCategory12 + 0001-02 + TestRecordCategory12 + TestRecordCategory12 description + + + + + + T0-000-00-1 item 002 + Cut off every 3 months, hold 3 months, then destroy. + + + + + + cutoff + quarterend|1 + + + + + destroy + month|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + TestRecordFolder3 + 0001-02-01 + TestRecordFolder3 + + + + + + + + + + + TestRecordCategory13 + 0001-03 + TestRecordCategory13 + TestRecordCategory13 description + + + + + + T0-000-00-1 item 003 + Cut off at end of FY, hold 3 years, then destroy. + + + + + + cutoff + fyend|1 + + + + + destroy + year|3 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + + TestRecordCategory2 + 0002 + TestRecordCategory2 + TestRecordCategory2 description + + + + + + + + + TestRecordCategory21 + 0002-01 + TestRecordCategory21 + TestRecordCategory21 description + + + + + + T0-000-00-2 item 001 + Cut off when superseded, hold 5 years, then destroy. + true + + + + + + cutoff + superseded + + + + + destroy + year|5 + {http://www.alfresco.org/model/recordsmanagement/1.0}cutOffDate + + + + + + + + + + + + + + TestRecordCategory22 + 0002-02 + TestRecordCategory22 + TestRecordCategory22 description + + + + + + T0-000-00-2 item 002 + Cut off when no longer needed and destroy immediately. + + + + + + cutoff + no_longer_needed + + + + + destroy + immediately|0 + + + + + + + + + + TestRecordFolder4 + 0002-02-01 + TestRecordFolder4 + + + + + TestRecordFolder5 + 0002-02-02 + TestRecordFolder5 + + + + + + + + \ No newline at end of file diff --git a/rm-server/test/resources/test-job-context.xml b/rm-server/test/resources/test-job-context.xml index 2cfee8877d..ea535d5f17 100644 --- a/rm-server/test/resources/test-job-context.xml +++ b/rm-server/test/resources/test-job-context.xml @@ -1,18 +1,18 @@ - - - - - - - - - - - - - - 0/30 * * * * ? - - - + + + + + + + + + + + + + + 0/30 * * * * ? + + + \ No newline at end of file diff --git a/rm-server/test/resources/test-model.xml b/rm-server/test/resources/test-model.xml index 41869338d5..6e4ea7aff2 100644 --- a/rm-server/test/resources/test-model.xml +++ b/rm-server/test/resources/test-model.xml @@ -1,69 +1,69 @@ - - - - - RM Test Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - cm:content - - - - - - - - - - - - - d:text - - - d:text - - - - - - - - d:text - - - - - - - - d:text - true - - - - - - + + + + + RM Test Model + Roy Wetherall + 1.0 + + + + + + + + + + + + + + + + + + + + + + cm:content + + + + + + + + + + + + + d:text + + + d:text + + + + + + + + d:text + + + + + + + + d:text + true + + + + + + \ No newline at end of file diff --git a/rm-server/test/resources/testCaveatConfig1.json b/rm-server/test/resources/testCaveatConfig1.json index 1fac03e309..a7c77f4894 100644 --- a/rm-server/test/resources/testCaveatConfig1.json +++ b/rm-server/test/resources/testCaveatConfig1.json @@ -1,8 +1,8 @@ -{ - "rmc:prjList": { - "admin" : ["Project A", "Project B", "Project C"] - }, - "rmc:smList": { - "admin" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"] - } -} +{ + "rmc:prjList": { + "admin" : ["Project A", "Project B", "Project C"] + }, + "rmc:smList": { + "admin" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"] + } +} diff --git a/rm-server/test/resources/testCaveatConfig2.json b/rm-server/test/resources/testCaveatConfig2.json index fec003535f..6d0dbfea80 100644 --- a/rm-server/test/resources/testCaveatConfig2.json +++ b/rm-server/test/resources/testCaveatConfig2.json @@ -1,27 +1,27 @@ -{ - "rmc:prjList": { - "dmartinz" : ["Project A", "Project B", "Project C"], - "jrogers" : ["Project A", "Project B"], - "GROUP_Engineering" : ["Project A"], - "dfranco" : ["Project A", "Project C"], - "admin" : ["Project A", "Project B", "Project C"], - "GROUP_Finance" : ["Project C"] - }, - "rmc:smList": { - "jrangel" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], - "dmartinz" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], - "jrogers" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], - "hmcneil" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], - "dfranco" : ["NOFORN", "FOUO"], - "gsmith" : ["NOFORN", "FOUO"], - "eharris" : ["NOCONTRACT", "FOUO"], - "bbayless" : ["NOCONTRACT", "FOUO"], - "mhouse" : ["NOCONTRACT", "FOUO"], - "aly" : ["FOUO"], - "dsandy" : ["FGI"], - "driggs" : ["NOFORN"], - "admin" : ["FOUO", "NOFORN"], - "test1" : ["NOCONTRACT"], - "GROUP_test1" : ["NOCONTRACT"] - } -} +{ + "rmc:prjList": { + "dmartinz" : ["Project A", "Project B", "Project C"], + "jrogers" : ["Project A", "Project B"], + "GROUP_Engineering" : ["Project A"], + "dfranco" : ["Project A", "Project C"], + "admin" : ["Project A", "Project B", "Project C"], + "GROUP_Finance" : ["Project C"] + }, + "rmc:smList": { + "jrangel" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], + "dmartinz" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], + "jrogers" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], + "hmcneil" : ["NOFORN", "NOCONTRACT", "FOUO", "FGI"], + "dfranco" : ["NOFORN", "FOUO"], + "gsmith" : ["NOFORN", "FOUO"], + "eharris" : ["NOCONTRACT", "FOUO"], + "bbayless" : ["NOCONTRACT", "FOUO"], + "mhouse" : ["NOCONTRACT", "FOUO"], + "aly" : ["FOUO"], + "dsandy" : ["FGI"], + "driggs" : ["NOFORN"], + "admin" : ["FOUO", "NOFORN"], + "test1" : ["NOCONTRACT"], + "GROUP_test1" : ["NOCONTRACT"] + } +} diff --git a/rm-server/test/resources/testng.xml b/rm-server/test/resources/testng.xml index cc24c41946..5e48020c09 100644 --- a/rm-server/test/resources/testng.xml +++ b/rm-server/test/resources/testng.xml @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/BaseActionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/BaseActionUnitTest.java index 3a6207aa7b..ae7d002572 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/BaseActionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/BaseActionUnitTest.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action; - -import static org.mockito.Mockito.doReturn; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.action.Action; -import org.mockito.Mock; - -/** - * Declare as version record action unit test. - * - * @author Roy Wetherall - * @since 2.3 - */ -public abstract class BaseActionUnitTest extends BaseUnitTest -{ - /** mocked action */ - private @Mock Action mockedAction; - - /** - * @return mocked action - */ - protected Action getMockedAction() - { - return mockedAction; - } - - /** - * Helper to mock an action parameter value - */ - protected void mockActionParameterValue(String name, Object value) - { - doReturn(value).when(mockedAction).getParameterValue(name); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action; + +import static org.mockito.Mockito.doReturn; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.action.Action; +import org.mockito.Mock; + +/** + * Declare as version record action unit test. + * + * @author Roy Wetherall + * @since 2.3 + */ +public abstract class BaseActionUnitTest extends BaseUnitTest +{ + /** mocked action */ + private @Mock Action mockedAction; + + /** + * @return mocked action + */ + protected Action getMockedAction() + { + return mockedAction; + } + + /** + * Helper to mock an action parameter value + */ + protected void mockActionParameterValue(String name, Object value) + { + doReturn(value).when(mockedAction).getParameterValue(name); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordActionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordActionUnitTest.java index b66367cf6d..9fbff743fe 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordActionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/dm/DeclareAsVersionRecordActionUnitTest.java @@ -1,293 +1,293 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.dm; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Declare as version record action unit test. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class DeclareAsVersionRecordActionUnitTest extends BaseActionUnitTest -{ - /** Sync Model */ - private static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; - private static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); - - /** actioned upon node reference */ - private NodeRef actionedUponNodeRef; - - /** declare as version record action */ - private @InjectMocks DeclareAsVersionRecordAction declareAsVersionRecordAction; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Override - public void before() throws Exception - { - super.before(); - - // mocked action - declareAsVersionRecordAction.setAuditable(false); - - // mocked actioned upon noderef - actionedUponNodeRef = generateNodeRef(); - } - - /** - * Given that the actioned upon node reference doesn't exist - * When I execute the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefDoesntExist() - { - doReturn(false).when(mockedNodeService).exists(actionedUponNodeRef); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference isn't a subtype of cm:content - * When I execute the action - * Then nothing happens - */ - @Test - public void aciontedUponNodeRefIsntSubTypeOfCmContent() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(false).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference doesn't have the versionable aspect applied - * When I executed the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefDoesntHaveVersionableApplied() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference is already an record - * When I execute the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefAlreadyRecord() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference is a working copy - * When I execute the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefWorkingCopy() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference is a rejected record - * When I execute the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefRejectedRecord() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that the actioned upon node reference is synced to the cloud - * When I execute the action - * Then nothing happens - */ - @Test - public void actionedUponNodeRefSynced() - { - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that no file plan is provided - * And no default file plan exists - * When I execute the action - * Then an exception is thrown - */ - @Test - public void noFilePlanParameterNoDefaultFilePlan() - { - // setup - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); - - // no default file plan - doReturn(null).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - // expect exception - exception.expect(AlfrescoRuntimeException.class); - - // exceute action - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - } - - /** - * Given that no file plan is provided - * And adefault file plan exists - * When I execute the action - * Then a version record is declared - */ - @Test - public void noFilePlanParameterDefaultFilePlan() - { - // setup - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); - - // no default file plan - doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - // exceute action - declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); - verify(mockedRecordableVersionService, times(1)).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); - } - - /** - * Given that a file plan is provided - * And it isn't a file plan - * When I execute the action - * Then an exception is thrown - */ - @Test - public void invalidFilePlanParameter() - { - // setup - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); - - // not a file plan is provided in the parameters - mockActionParameterValue(DeclareAsVersionRecordAction.PARAM_FILE_PLAN, generateNodeRef()); - - // expect exception - exception.expect(AlfrescoRuntimeException.class); - - // exceute action - declareAsVersionRecordAction.executeImpl(getMockedAction(), actionedUponNodeRef); - } - - /** - * Given that a file plan is provided - * And it is a file plan - * When I execute the action - * Then a version record is declared - */ - @Test - public void validFilePlanParameter() - { - // setup - doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); - doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); - doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); - doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); - - // not a file plan is provided in the parameters - NodeRef myFilePlan = generateNodeRef(TYPE_FILE_PLAN); - doReturn(true).when(mockedFilePlanService).isFilePlan(myFilePlan); - mockActionParameterValue(DeclareAsVersionRecordAction.PARAM_FILE_PLAN, myFilePlan); - - // exceute action - declareAsVersionRecordAction.executeImpl(getMockedAction(), actionedUponNodeRef); - verify(mockedRecordableVersionService, times(1)).createRecordFromLatestVersion(myFilePlan, actionedUponNodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.dm; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Declare as version record action unit test. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class DeclareAsVersionRecordActionUnitTest extends BaseActionUnitTest +{ + /** Sync Model */ + private static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0"; + private static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced"); + + /** actioned upon node reference */ + private NodeRef actionedUponNodeRef; + + /** declare as version record action */ + private @InjectMocks DeclareAsVersionRecordAction declareAsVersionRecordAction; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Override + public void before() throws Exception + { + super.before(); + + // mocked action + declareAsVersionRecordAction.setAuditable(false); + + // mocked actioned upon noderef + actionedUponNodeRef = generateNodeRef(); + } + + /** + * Given that the actioned upon node reference doesn't exist + * When I execute the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefDoesntExist() + { + doReturn(false).when(mockedNodeService).exists(actionedUponNodeRef); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference isn't a subtype of cm:content + * When I execute the action + * Then nothing happens + */ + @Test + public void aciontedUponNodeRefIsntSubTypeOfCmContent() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(false).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference doesn't have the versionable aspect applied + * When I executed the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefDoesntHaveVersionableApplied() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference is already an record + * When I execute the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefAlreadyRecord() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference is a working copy + * When I execute the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefWorkingCopy() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference is a rejected record + * When I execute the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefRejectedRecord() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that the actioned upon node reference is synced to the cloud + * When I execute the action + * Then nothing happens + */ + @Test + public void actionedUponNodeRefSynced() + { + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, never()).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that no file plan is provided + * And no default file plan exists + * When I execute the action + * Then an exception is thrown + */ + @Test + public void noFilePlanParameterNoDefaultFilePlan() + { + // setup + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); + + // no default file plan + doReturn(null).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + // expect exception + exception.expect(AlfrescoRuntimeException.class); + + // exceute action + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + } + + /** + * Given that no file plan is provided + * And adefault file plan exists + * When I execute the action + * Then a version record is declared + */ + @Test + public void noFilePlanParameterDefaultFilePlan() + { + // setup + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); + + // no default file plan + doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + // exceute action + declareAsVersionRecordAction.executeImpl(mock(Action.class), actionedUponNodeRef); + verify(mockedRecordableVersionService, times(1)).createRecordFromLatestVersion(filePlan, actionedUponNodeRef); + } + + /** + * Given that a file plan is provided + * And it isn't a file plan + * When I execute the action + * Then an exception is thrown + */ + @Test + public void invalidFilePlanParameter() + { + // setup + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); + + // not a file plan is provided in the parameters + mockActionParameterValue(DeclareAsVersionRecordAction.PARAM_FILE_PLAN, generateNodeRef()); + + // expect exception + exception.expect(AlfrescoRuntimeException.class); + + // exceute action + declareAsVersionRecordAction.executeImpl(getMockedAction(), actionedUponNodeRef); + } + + /** + * Given that a file plan is provided + * And it is a file plan + * When I execute the action + * Then a version record is declared + */ + @Test + public void validFilePlanParameter() + { + // setup + doReturn(true).when(mockedNodeService).exists(actionedUponNodeRef); + doReturn(true).when(mockedDictionaryService).isSubClass(any(QName.class), eq(ContentModel.TYPE_CONTENT)); + doReturn(true).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS); + doReturn(false).when(mockedNodeService).hasAspect(actionedUponNodeRef, ASPECT_SYNCED); + + // not a file plan is provided in the parameters + NodeRef myFilePlan = generateNodeRef(TYPE_FILE_PLAN); + doReturn(true).when(mockedFilePlanService).isFilePlan(myFilePlan); + mockActionParameterValue(DeclareAsVersionRecordAction.PARAM_FILE_PLAN, myFilePlan); + + // exceute action + declareAsVersionRecordAction.executeImpl(getMockedAction(), actionedUponNodeRef); + verify(mockedRecordableVersionService, times(1)).createRecordFromLatestVersion(myFilePlan, actionedUponNodeRef); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportActionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportActionUnitTest.java index a3cbd6bc97..23bfc00146 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportActionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportActionUnitTest.java @@ -1,106 +1,106 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import static org.mockito.Mockito.verifyZeroInteractions; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Unit test for file report action. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class FileReportActionUnitTest extends BaseActionUnitTest -{ - /** actioned upon node reference */ - private NodeRef actionedUponNodeRef; - - /** file report action */ - private @InjectMocks FileReportAction fileReportAction; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Override - public void before() throws Exception - { - super.before(); - - // actioned upon node reference - actionedUponNodeRef = generateRecord(); - - // mocked action - fileReportAction.setAuditable(false); - } - - /** - * given the destination is not set, ensure that an exception is thrown - */ - @Test - public void destinationNotSet() - { - // == given == - - // set action parameter values - mockActionParameterValue(FileReportAction.MIMETYPE, MimetypeMap.MIMETYPE_HTML); - mockActionParameterValue(FileReportAction.REPORT_TYPE, "rma:destructionReport"); - - // expected exception - exception.expect(AlfrescoRuntimeException.class); - - // == when == - - // execute action - fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); - - // == then == - verifyZeroInteractions(mockedReportService, mockedNodeService); - } - - /** - * given no report type set, ensure that an exception is thrown - */ - @Test - public void reportTypeNotSet() - { - // == given == - - // set action parameter values - mockActionParameterValue(FileReportAction.MIMETYPE, MimetypeMap.MIMETYPE_HTML); - mockActionParameterValue(FileReportAction.DESTINATION, generateNodeRef().toString()); - - // expected exception - exception.expect(AlfrescoRuntimeException.class); - - // == when == - - // execute action - fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); - - // == then == - verifyZeroInteractions(mockedReportService, mockedNodeService); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import static org.mockito.Mockito.verifyZeroInteractions; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for file report action. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class FileReportActionUnitTest extends BaseActionUnitTest +{ + /** actioned upon node reference */ + private NodeRef actionedUponNodeRef; + + /** file report action */ + private @InjectMocks FileReportAction fileReportAction; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Override + public void before() throws Exception + { + super.before(); + + // actioned upon node reference + actionedUponNodeRef = generateRecord(); + + // mocked action + fileReportAction.setAuditable(false); + } + + /** + * given the destination is not set, ensure that an exception is thrown + */ + @Test + public void destinationNotSet() + { + // == given == + + // set action parameter values + mockActionParameterValue(FileReportAction.MIMETYPE, MimetypeMap.MIMETYPE_HTML); + mockActionParameterValue(FileReportAction.REPORT_TYPE, "rma:destructionReport"); + + // expected exception + exception.expect(AlfrescoRuntimeException.class); + + // == when == + + // execute action + fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); + + // == then == + verifyZeroInteractions(mockedReportService, mockedNodeService); + } + + /** + * given no report type set, ensure that an exception is thrown + */ + @Test + public void reportTypeNotSet() + { + // == given == + + // set action parameter values + mockActionParameterValue(FileReportAction.MIMETYPE, MimetypeMap.MIMETYPE_HTML); + mockActionParameterValue(FileReportAction.DESTINATION, generateNodeRef().toString()); + + // expected exception + exception.expect(AlfrescoRuntimeException.class); + + // == when == + + // execute action + fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); + + // == then == + verifyZeroInteractions(mockedReportService, mockedNodeService); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromActionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromActionUnitTest.java index 312bcda9f3..4535eac02c 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromActionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnlinkFromActionUnitTest.java @@ -1,143 +1,143 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.action.impl; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Unit test for unlink from action - * - * @author Roy Wetherall - * @since 2.3 - */ -public class UnlinkFromActionUnitTest extends BaseActionUnitTest -{ - private NodeRef record; - private NodeRef recordFolder; - - @InjectMocks - private UnlinkFromAction action; - - @Before - @Override - public void before() throws Exception - { - super.before(); - - record = generateRecord(); - recordFolder = generateRecordFolder(); - } - - /** - * Given the actioned upon node does not exist - * When the action is executed - * Then nothing happens - */ - @Test - public void nodeDoesNotExist() - { - doReturn(false).when(mockedNodeService).exists(record); - action.executeImpl(mock(Action.class), record); - verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); - } - - /** - * Given the actioned upon node is pending delete - * When the action is executed - * Then nothing happens - */ - @Test - public void nodePendingDelete() - { - doReturn(true).when(mockedNodeService).exists(record); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); - action.executeImpl(mock(Action.class), record); - verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); - } - - /** - * Given that actioned upon node is not a record - * When the action is executed - * Then nothing happens - */ - @Test - public void nodeNotRecord() - { - NodeRef notRecord = generateCmContent(generateText()); - doReturn(true).when(mockedNodeService).exists(notRecord); - doReturn(false).when(mockedNodeService).hasAspect(notRecord, ASPECT_PENDING_DELETE); - action.executeImpl(mock(Action.class), notRecord); - verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); - } - - /** - * Given that the record folder parameter is not provided - * When the action is executed - * Then an exception is thrown - */ - @Test(expected=AlfrescoRuntimeException.class) - public void recordFolderParamMissing() - { - // setup record - doReturn(true).when(mockedNodeService).exists(record); - doReturn(false).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); - - // create action mock - mockActionParameterValue(UnlinkFromAction.PARAM_RECORD_FOLDER, null); - - // execute action - action.executeImpl(getMockedAction(), record); - } - - /** - * Given that a valid record folder is provided - * When the action is executed - * Then the record is unlinked from the record folder - */ - @Test - public void validUnlink() - { - // setup record - doReturn(true).when(mockedNodeService).exists(record); - doReturn(false).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); - - // create action mock - mockActionParameterValue(UnlinkFromAction.PARAM_RECORD_FOLDER, recordFolder.toString()); - - // execute action - action.executeImpl(getMockedAction(), record); - - // verify unlink - verify(mockedRecordService, times(1)).unlink(record, recordFolder); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.action.impl; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for unlink from action + * + * @author Roy Wetherall + * @since 2.3 + */ +public class UnlinkFromActionUnitTest extends BaseActionUnitTest +{ + private NodeRef record; + private NodeRef recordFolder; + + @InjectMocks + private UnlinkFromAction action; + + @Before + @Override + public void before() throws Exception + { + super.before(); + + record = generateRecord(); + recordFolder = generateRecordFolder(); + } + + /** + * Given the actioned upon node does not exist + * When the action is executed + * Then nothing happens + */ + @Test + public void nodeDoesNotExist() + { + doReturn(false).when(mockedNodeService).exists(record); + action.executeImpl(mock(Action.class), record); + verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); + } + + /** + * Given the actioned upon node is pending delete + * When the action is executed + * Then nothing happens + */ + @Test + public void nodePendingDelete() + { + doReturn(true).when(mockedNodeService).exists(record); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); + action.executeImpl(mock(Action.class), record); + verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); + } + + /** + * Given that actioned upon node is not a record + * When the action is executed + * Then nothing happens + */ + @Test + public void nodeNotRecord() + { + NodeRef notRecord = generateCmContent(generateText()); + doReturn(true).when(mockedNodeService).exists(notRecord); + doReturn(false).when(mockedNodeService).hasAspect(notRecord, ASPECT_PENDING_DELETE); + action.executeImpl(mock(Action.class), notRecord); + verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class)); + } + + /** + * Given that the record folder parameter is not provided + * When the action is executed + * Then an exception is thrown + */ + @Test(expected=AlfrescoRuntimeException.class) + public void recordFolderParamMissing() + { + // setup record + doReturn(true).when(mockedNodeService).exists(record); + doReturn(false).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); + + // create action mock + mockActionParameterValue(UnlinkFromAction.PARAM_RECORD_FOLDER, null); + + // execute action + action.executeImpl(getMockedAction(), record); + } + + /** + * Given that a valid record folder is provided + * When the action is executed + * Then the record is unlinked from the record folder + */ + @Test + public void validUnlink() + { + // setup record + doReturn(true).when(mockedNodeService).exists(record); + doReturn(false).when(mockedNodeService).hasAspect(record, ASPECT_PENDING_DELETE); + + // create action mock + mockActionParameterValue(UnlinkFromAction.PARAM_RECORD_FOLDER, recordFolder.toString()); + + // execute action + action.executeImpl(getMockedAction(), record); + + // verify unlink + verify(mockedRecordService, times(1)).unlink(record, recordFolder); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java index 102304dd1e..2f12e830fc 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.importer.ImporterBootstrap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Bootstrap importer module component unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class BootstrapImporterModuleComponentUnitTest extends BaseUnitTest -{ - /** RM config node */ - private static final NodeRef configNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); - - /** mocks */ - @Mock(name="importer") private ImporterBootstrap mockedImporter; - @Mock(name="modulePatchExecuter") private ModulePatchExecuter mockedModulePatchExecuter; - @Mock(name="recordContributorsGroupBootstrapComponent") private RecordContributorsGroupBootstrapComponent mockedRecordContributorsGroupBootstrapComponent; - - /** importer */ - @InjectMocks - private BootstrapImporterModuleComponent importer; - - /** - * Given that the system has already been bootstraped - * When I try and boostrap the system - * Then the system is not bootstraped again - */ - @Test - public void alreadyBootstraped() throws Throwable - { - // config node exists - doReturn(true).when(mockedNodeService).exists(configNodeRef); - - // boostrap - importer.executeInternal(); - - // not bootstraped - verify(mockedImporter, never()).bootstrap(); - verify(mockedModulePatchExecuter, never()).initSchemaVersion(); - verify(mockedRecordContributorsGroupBootstrapComponent, never()).createRecordContributorsGroup(); - } - - /** - * Given that the system has not been bootstraped - * When I try and bootstrap the system - * Then the system is bootstraped - */ - @Test - public void boostrap() throws Throwable - { - // config node does not exist - doReturn(false).when(mockedNodeService).exists(configNodeRef); - - // boostrap - importer.executeInternal(); - - // not bootstraped - verify(mockedImporter, times(1)).bootstrap(); - verify(mockedModulePatchExecuter, times(1)).initSchemaVersion(); - verify(mockedRecordContributorsGroupBootstrapComponent, times(1)).createRecordContributorsGroup(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.importer.ImporterBootstrap; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +/** + * Bootstrap importer module component unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class BootstrapImporterModuleComponentUnitTest extends BaseUnitTest +{ + /** RM config node */ + private static final NodeRef configNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); + + /** mocks */ + @Mock(name="importer") private ImporterBootstrap mockedImporter; + @Mock(name="modulePatchExecuter") private ModulePatchExecuter mockedModulePatchExecuter; + @Mock(name="recordContributorsGroupBootstrapComponent") private RecordContributorsGroupBootstrapComponent mockedRecordContributorsGroupBootstrapComponent; + + /** importer */ + @InjectMocks + private BootstrapImporterModuleComponent importer; + + /** + * Given that the system has already been bootstraped + * When I try and boostrap the system + * Then the system is not bootstraped again + */ + @Test + public void alreadyBootstraped() throws Throwable + { + // config node exists + doReturn(true).when(mockedNodeService).exists(configNodeRef); + + // boostrap + importer.executeInternal(); + + // not bootstraped + verify(mockedImporter, never()).bootstrap(); + verify(mockedModulePatchExecuter, never()).initSchemaVersion(); + verify(mockedRecordContributorsGroupBootstrapComponent, never()).createRecordContributorsGroup(); + } + + /** + * Given that the system has not been bootstraped + * When I try and bootstrap the system + * Then the system is bootstraped + */ + @Test + public void boostrap() throws Throwable + { + // config node does not exist + doReturn(false).when(mockedNodeService).exists(configNodeRef); + + // boostrap + importer.executeInternal(); + + // not bootstraped + verify(mockedImporter, times(1)).bootstrap(); + verify(mockedModulePatchExecuter, times(1)).initSchemaVersion(); + verify(mockedRecordContributorsGroupBootstrapComponent, times(1)).createRecordContributorsGroup(); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponentUnitTest.java index 48f1d3315c..b4cdab23b3 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponentUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordContributorsGroupBootstrapComponentUnitTest.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.security.AuthorityType; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Record contributors group bootstrap component unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordContributorsGroupBootstrapComponentUnitTest extends BaseUnitTest -{ - @InjectMocks - private RecordContributorsGroupBootstrapComponent component; - - /** - * Given that the record contributors group already exists - * When I try and create the group - * Then nothing happens - */ - @Test - public void groupAlreadyExists() - { - // group already exists - doReturn(true).when(mockedAuthorityService).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); - - // create group - component.createRecordContributorsGroup(); - - // group not created - verify(mockedAuthorityService, times(1)).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); - verifyNoMoreInteractions(mockedAuthorityService); - } - - /** - * Given that the record contributors group does not exist - * When I try and create the group - * Then the group is successfully created - * And 'everyone' is added to the new group - */ - @Test - public void createGroup() - { - // group does not exists - doReturn(false).when(mockedAuthorityService).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); - - // create group - component.createRecordContributorsGroup(); - - // group not created - verify(mockedAuthorityService, times(1)).createAuthority(AuthorityType.GROUP, RecordContributorsGroupBootstrapComponent.RECORD_CONTRIBUTORS); - verify(mockedAuthorityService, times(1)).addAuthority(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS, "admin"); - verify(mockedAuthorityService, times(1)).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); - verifyNoMoreInteractions(mockedAuthorityService); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.security.AuthorityType; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Record contributors group bootstrap component unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordContributorsGroupBootstrapComponentUnitTest extends BaseUnitTest +{ + @InjectMocks + private RecordContributorsGroupBootstrapComponent component; + + /** + * Given that the record contributors group already exists + * When I try and create the group + * Then nothing happens + */ + @Test + public void groupAlreadyExists() + { + // group already exists + doReturn(true).when(mockedAuthorityService).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); + + // create group + component.createRecordContributorsGroup(); + + // group not created + verify(mockedAuthorityService, times(1)).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); + verifyNoMoreInteractions(mockedAuthorityService); + } + + /** + * Given that the record contributors group does not exist + * When I try and create the group + * Then the group is successfully created + * And 'everyone' is added to the new group + */ + @Test + public void createGroup() + { + // group does not exists + doReturn(false).when(mockedAuthorityService).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); + + // create group + component.createRecordContributorsGroup(); + + // group not created + verify(mockedAuthorityService, times(1)).createAuthority(AuthorityType.GROUP, RecordContributorsGroupBootstrapComponent.RECORD_CONTRIBUTORS); + verify(mockedAuthorityService, times(1)).addAuthority(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS, "admin"); + verify(mockedAuthorityService, times(1)).authorityExists(RecordContributorsGroupBootstrapComponent.GROUP_RECORD_CONTRIBUTORS); + verifyNoMoreInteractions(mockedAuthorityService); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoterUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoterUnitTest.java index 461ddd3289..6f2319227d 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoterUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoterUnitTest.java @@ -1,220 +1,220 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.junit.Assert.*; - -import java.lang.reflect.Method; -import java.util.Iterator; - -import net.sf.acegisecurity.Authentication; -import net.sf.acegisecurity.ConfigAttribute; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition; -import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * RM entry voter unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RMEntryVoterUnitTest extends BaseUnitTest -{ - private static final String POLICY_NAME = "myPolicy"; - - /** RM Entry */ - private @InjectMocks RMEntryVoter entryVoter; - - /** mocked policy */ - private @Mock Policy mockedPolicy; - - /** mocked authentication */ - private @Mock Authentication mockedAuthentication; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Before - @Override - public void before() throws Exception - { - super.before(); - - // don't run as system - when(mockedAuthenticationUtil.isRunAsUserTheSystemUser()) - .thenReturn(false); - - // indicate that "vote" transaction value is not set - when(mockedTransactionalResourceHelper.isResourcePresent("voting")) - .thenReturn(false); - } - - /** - * Given that the system is already voting - * When I vote - * Then access granted - */ - @Test - public void alreadyVoting() throws Exception - { - // indicate already voting - when(mockedTransactionalResourceHelper.isResourcePresent("voting")) - .thenReturn(true); - - // given I am providing an invalid policy for a method - MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); - net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); - - // call vote - assertEquals( - AccessDecisionVoter.ACCESS_GRANTED, - entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef)); - } - - /** - * Given that I am running this as the system user - * When I evaluate - * Then access granted - */ - @Test - public void runAsSystem() throws Exception - { - // run as system - when(mockedAuthenticationUtil.isRunAsUserTheSystemUser()) - .thenReturn(true); - - // given I am providing an invalid policy for a method - MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); - net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); - - // call vote - assertEquals( - AccessDecisionVoter.ACCESS_GRANTED, - entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef)); - } - - /** - * Given that we have provided an invalid policy - * When I evaluate the voter - * Then an AlfrescoRuntimeException is thrown - */ - @Test - public void invalidPolicy() throws Exception - { - // given I am providing an invalid policy for a method - MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); - net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); - - // I expect an Alfresco Runtime Exception - exception.expect(AlfrescoRuntimeException.class); - - // call vote - entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef); - } - - /** - * Given that I have provided a valid policy - * When I evaluate the voter - * Then the corresponding policy will be evaluated - */ - @Test - public void validPolicy() throws Exception - { - // valid policy - when(mockedPolicy.getName()) - .thenReturn(POLICY_NAME); - entryVoter.registerPolicy(mockedPolicy); - - // mock calling details - MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); - net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM." + POLICY_NAME); - - // call vote - entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef); - - // verify that the policy was executed - verify(mockedPolicy, times(1)).evaluate(eq(mockedMethodInvocation), any(Class[].class), any(ConfigAttributeDefinition.class)); - } - - /** - * Helper method to create configuration object - */ - @SuppressWarnings("rawtypes") - private net.sf.acegisecurity.ConfigAttributeDefinition createConfigDefinition(String value) - { - net.sf.acegisecurity.ConfigAttributeDefinition mockedConfig = mock(net.sf.acegisecurity.ConfigAttributeDefinition.class); - - ConfigAttribute mockedConfigAttr = mock(ConfigAttribute.class); - when(mockedConfigAttr.getAttribute()) - .thenReturn(value); - - Iterator mockedIter = mock(Iterator.class); - when(mockedIter.hasNext()) - .thenReturn(true) - .thenReturn(false); - when(mockedIter.next()) - .thenReturn(mockedConfigAttr); - - when(mockedConfig.getConfigAttributes()) - .thenReturn(mockedIter); - - return mockedConfig; - } - - /** - * Helper method to create method invocation mock - */ - private MethodInvocation createMethodInvoation(String methodName, Class ... parameterTypes) - throws Exception - { - // mock method invocation - MethodInvocation mockedMethodInvocation = mock(MethodInvocation.class); - - // get method object .. assumed to be a method on this object - Method method = RMEntryVoterUnitTest.class.getMethod(methodName, parameterTypes); - when(mockedMethodInvocation.getMethod()) - .thenReturn(method); - - return mockedMethodInvocation; - } - - /** ========= Test methods ======== */ - - public void myTestMethod(NodeRef nodeRef) - { - // does nothing - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.junit.Assert.*; + +import java.lang.reflect.Method; +import java.util.Iterator; + +import net.sf.acegisecurity.Authentication; +import net.sf.acegisecurity.ConfigAttribute; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition; +import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.aopalliance.intercept.MethodInvocation; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +/** + * RM entry voter unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RMEntryVoterUnitTest extends BaseUnitTest +{ + private static final String POLICY_NAME = "myPolicy"; + + /** RM Entry */ + private @InjectMocks RMEntryVoter entryVoter; + + /** mocked policy */ + private @Mock Policy mockedPolicy; + + /** mocked authentication */ + private @Mock Authentication mockedAuthentication; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Before + @Override + public void before() throws Exception + { + super.before(); + + // don't run as system + when(mockedAuthenticationUtil.isRunAsUserTheSystemUser()) + .thenReturn(false); + + // indicate that "vote" transaction value is not set + when(mockedTransactionalResourceHelper.isResourcePresent("voting")) + .thenReturn(false); + } + + /** + * Given that the system is already voting + * When I vote + * Then access granted + */ + @Test + public void alreadyVoting() throws Exception + { + // indicate already voting + when(mockedTransactionalResourceHelper.isResourcePresent("voting")) + .thenReturn(true); + + // given I am providing an invalid policy for a method + MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); + net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); + + // call vote + assertEquals( + AccessDecisionVoter.ACCESS_GRANTED, + entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef)); + } + + /** + * Given that I am running this as the system user + * When I evaluate + * Then access granted + */ + @Test + public void runAsSystem() throws Exception + { + // run as system + when(mockedAuthenticationUtil.isRunAsUserTheSystemUser()) + .thenReturn(true); + + // given I am providing an invalid policy for a method + MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); + net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); + + // call vote + assertEquals( + AccessDecisionVoter.ACCESS_GRANTED, + entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef)); + } + + /** + * Given that we have provided an invalid policy + * When I evaluate the voter + * Then an AlfrescoRuntimeException is thrown + */ + @Test + public void invalidPolicy() throws Exception + { + // given I am providing an invalid policy for a method + MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); + net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM.invalid"); + + // I expect an Alfresco Runtime Exception + exception.expect(AlfrescoRuntimeException.class); + + // call vote + entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef); + } + + /** + * Given that I have provided a valid policy + * When I evaluate the voter + * Then the corresponding policy will be evaluated + */ + @Test + public void validPolicy() throws Exception + { + // valid policy + when(mockedPolicy.getName()) + .thenReturn(POLICY_NAME); + entryVoter.registerPolicy(mockedPolicy); + + // mock calling details + MethodInvocation mockedMethodInvocation = createMethodInvoation("myTestMethod", NodeRef.class); + net.sf.acegisecurity.ConfigAttributeDefinition mockedConfigDef = createConfigDefinition("RM." + POLICY_NAME); + + // call vote + entryVoter.vote(mockedAuthentication, mockedMethodInvocation, mockedConfigDef); + + // verify that the policy was executed + verify(mockedPolicy, times(1)).evaluate(eq(mockedMethodInvocation), any(Class[].class), any(ConfigAttributeDefinition.class)); + } + + /** + * Helper method to create configuration object + */ + @SuppressWarnings("rawtypes") + private net.sf.acegisecurity.ConfigAttributeDefinition createConfigDefinition(String value) + { + net.sf.acegisecurity.ConfigAttributeDefinition mockedConfig = mock(net.sf.acegisecurity.ConfigAttributeDefinition.class); + + ConfigAttribute mockedConfigAttr = mock(ConfigAttribute.class); + when(mockedConfigAttr.getAttribute()) + .thenReturn(value); + + Iterator mockedIter = mock(Iterator.class); + when(mockedIter.hasNext()) + .thenReturn(true) + .thenReturn(false); + when(mockedIter.next()) + .thenReturn(mockedConfigAttr); + + when(mockedConfig.getConfigAttributes()) + .thenReturn(mockedIter); + + return mockedConfig; + } + + /** + * Helper method to create method invocation mock + */ + private MethodInvocation createMethodInvoation(String methodName, Class ... parameterTypes) + throws Exception + { + // mock method invocation + MethodInvocation mockedMethodInvocation = mock(MethodInvocation.class); + + // get method object .. assumed to be a method on this object + Method method = RMEntryVoterUnitTest.class.getMethod(methodName, parameterTypes); + when(mockedMethodInvocation.getMethod()) + .thenReturn(method); + + return mockedMethodInvocation; + } + + /** ========= Test methods ======== */ + + public void myTestMethod(NodeRef nodeRef) + { + // does nothing + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CapabilityDeclarativeConditionSuite.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CapabilityDeclarativeConditionSuite.java index b27a9ba6b3..73f23092e3 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CapabilityDeclarativeConditionSuite.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CapabilityDeclarativeConditionSuite.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * capability.declarative.condition unit test suite - * - * @author Roy Wetherall - * @since 2.3 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - HoldCapabilityConditionUnitTest.class, - FillingOnHoldContainerCapabilityConditionUnitTest.class, - FrozenCapabilityConditionUnitTest.class -}) -public class CapabilityDeclarativeConditionSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * capability.declarative.condition unit test suite + * + * @author Roy Wetherall + * @since 2.3 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + HoldCapabilityConditionUnitTest.class, + FillingOnHoldContainerCapabilityConditionUnitTest.class, + FrozenCapabilityConditionUnitTest.class +}) +public class CapabilityDeclarativeConditionSuite +{ +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityConditionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityConditionUnitTest.java index 6fb7262306..b68eed0727 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityConditionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FillingOnHoldContainerCapabilityConditionUnitTest.java @@ -1,141 +1,141 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import static org.mockito.Mockito.*; -import static org.junit.Assert.*; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Filling on hold container capability condition unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class FillingOnHoldContainerCapabilityConditionUnitTest extends BaseUnitTest -{ - /** evaluator */ - private @InjectMocks FillingOnHoldContainerCapabilityCondition condition; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Before - @Override - public void before() throws Exception - { - super.before(); - } - - /** - * Given hold container node - * And no filling permission - * When evaluate - * Then false - */ - @Test - public void noFillingOnHoldContainer() - { - NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); - when(mockedFilePlanService.isFilePlan(holdContainer)) - .thenReturn(false); - when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) - .thenReturn(AccessStatus.DENIED); - - assertFalse(condition.evaluateImpl(holdContainer)); - } - - /** - * Given hold container node - * And filling permission - * When evaluate - * Then true - */ - @Test - public void fillingOnHoldContainer() - { - NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); - when(mockedFilePlanService.isFilePlan(holdContainer)) - .thenReturn(false); - when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) - .thenReturn(AccessStatus.ALLOWED); - - assertTrue(condition.evaluateImpl(holdContainer)); - } - - /** - * Given file-plan node - * And no filling permission on hold container - * When evaluate - * Then false - */ - @Test - public void filePlanNoFilling() - { - NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); - when(mockedFilePlanService.getHoldContainer(filePlan)) - .thenReturn(holdContainer); - when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) - .thenReturn(AccessStatus.DENIED); - - assertFalse(condition.evaluateImpl(holdContainer)); - } - - /** - * Given file-plan node - * And filling permission on hold container - * When evaluate - * Then true - */ - @Test - public void filePlanFilling() - { - NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); - when(mockedFilePlanService.getHoldContainer(filePlan)) - .thenReturn(holdContainer); - when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) - .thenReturn(AccessStatus.ALLOWED); - - assertTrue(condition.evaluateImpl(holdContainer)); - } - - /** - * Given unexpected node type - * When evaluate - * Then false - */ - @Test - public void unexpectedNode() - { - NodeRef unexpectedNode = generateNodeRef(); - when(mockedFilePlanService.isFilePlan(unexpectedNode)) - .thenReturn(false); - when(mockedPermissionService.hasPermission(unexpectedNode, RMPermissionModel.FILE_RECORDS)) - .thenReturn(AccessStatus.ALLOWED); - - assertFalse(condition.evaluateImpl(unexpectedNode)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import static org.mockito.Mockito.*; +import static org.junit.Assert.*; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Filling on hold container capability condition unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class FillingOnHoldContainerCapabilityConditionUnitTest extends BaseUnitTest +{ + /** evaluator */ + private @InjectMocks FillingOnHoldContainerCapabilityCondition condition; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Before + @Override + public void before() throws Exception + { + super.before(); + } + + /** + * Given hold container node + * And no filling permission + * When evaluate + * Then false + */ + @Test + public void noFillingOnHoldContainer() + { + NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); + when(mockedFilePlanService.isFilePlan(holdContainer)) + .thenReturn(false); + when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) + .thenReturn(AccessStatus.DENIED); + + assertFalse(condition.evaluateImpl(holdContainer)); + } + + /** + * Given hold container node + * And filling permission + * When evaluate + * Then true + */ + @Test + public void fillingOnHoldContainer() + { + NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); + when(mockedFilePlanService.isFilePlan(holdContainer)) + .thenReturn(false); + when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) + .thenReturn(AccessStatus.ALLOWED); + + assertTrue(condition.evaluateImpl(holdContainer)); + } + + /** + * Given file-plan node + * And no filling permission on hold container + * When evaluate + * Then false + */ + @Test + public void filePlanNoFilling() + { + NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); + when(mockedFilePlanService.getHoldContainer(filePlan)) + .thenReturn(holdContainer); + when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) + .thenReturn(AccessStatus.DENIED); + + assertFalse(condition.evaluateImpl(holdContainer)); + } + + /** + * Given file-plan node + * And filling permission on hold container + * When evaluate + * Then true + */ + @Test + public void filePlanFilling() + { + NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); + when(mockedFilePlanService.getHoldContainer(filePlan)) + .thenReturn(holdContainer); + when(mockedPermissionService.hasPermission(holdContainer, RMPermissionModel.FILE_RECORDS)) + .thenReturn(AccessStatus.ALLOWED); + + assertTrue(condition.evaluateImpl(holdContainer)); + } + + /** + * Given unexpected node type + * When evaluate + * Then false + */ + @Test + public void unexpectedNode() + { + NodeRef unexpectedNode = generateNodeRef(); + when(mockedFilePlanService.isFilePlan(unexpectedNode)) + .thenReturn(false); + when(mockedPermissionService.hasPermission(unexpectedNode, RMPermissionModel.FILE_RECORDS)) + .thenReturn(AccessStatus.ALLOWED); + + assertFalse(condition.evaluateImpl(unexpectedNode)); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityConditionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityConditionUnitTest.java index 55f10e24c5..8ffdc75e4f 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityConditionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/FrozenCapabilityConditionUnitTest.java @@ -1,232 +1,232 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Frozen capability condition unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class FrozenCapabilityConditionUnitTest extends BaseUnitTest -{ - /** evaluator */ - private @InjectMocks FrozenCapabilityCondition condition; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Before - @Override - public void before() throws Exception - { - super.before(); - } - - /** - * Given hold - * When evaluate - * Then true - */ - @Test - public void evaluateHold() - { - // is a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(true); - - // evaluate - assertTrue(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, never()).isFrozen(nodeRef); - verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); - } - - /** - * Given is frozen - * And no check children - * When evaluate - * Then true - */ - @Test - public void frozenDontCheckChildren() - { - // is not a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(false); - - // dont check children - condition.setCheckChildren(false); - - // is frozen - when(mockedFreezeService.isFrozen(nodeRef)) - .thenReturn(true); - - // evaluate - assertTrue(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, times(1)).isFrozen(nodeRef); - verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); - } - - /** - * Given is not frozen - * And no check children - * When evaluate - * Then false - */ - @Test - public void notFrozenDontCheckChildren() - { - // is not a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(false); - - // dont check children - condition.setCheckChildren(false); - - // is not frozen - when(mockedFreezeService.isFrozen(nodeRef)) - .thenReturn(false); - - // evaluate - assertFalse(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, times(1)).isFrozen(nodeRef); - verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); - } - - /** - * Given is frozen - * And check children - * When evaluate - * Then true - */ - @Test - public void frozenCheckChildren() - { - // is not a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(false); - - // check children - condition.setCheckChildren(true); - - // is frozen - when(mockedFreezeService.isFrozen(nodeRef)) - .thenReturn(true); - - // evaluate - assertTrue(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, times(1)).isFrozen(nodeRef); - verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); - } - - /** - * Given is not frozen - * And check children - * And children no frozen - * When evaluate - * Then false - */ - @Test - public void notFrozenCheckChildrenNotFrozen() - { - // is not a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(false); - - // check children - condition.setCheckChildren(true); - - // is not frozen - when(mockedFreezeService.isFrozen(nodeRef)) - .thenReturn(false); - - // children not frozen - when(mockedFreezeService.hasFrozenChildren(nodeRef)) - .thenReturn(false); - - // evaluate - assertFalse(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, times(1)).isFrozen(nodeRef); - verify(mockedFreezeService, times(1)).hasFrozenChildren(nodeRef); - } - - /** - * Given is not frozen - * And check children - * And children frozen - * When evaluate - * Then true - */ - @Test - public void notFrozenCheckChildrenFrozen() - { - // is not a hold - NodeRef nodeRef = generateNodeRef(); - when(mockedHoldService.isHold(nodeRef)) - .thenReturn(false); - - // check children - condition.setCheckChildren(true); - - // is not frozen - when(mockedFreezeService.isFrozen(nodeRef)) - .thenReturn(false); - - // children frozen - when(mockedFreezeService.hasFrozenChildren(nodeRef)) - .thenReturn(true); - - // evaluate - assertTrue(condition.evaluate(nodeRef)); - - // verify - verify(mockedHoldService, times(1)).isHold(nodeRef); - verify(mockedFreezeService, times(1)).isFrozen(nodeRef); - verify(mockedFreezeService, times(1)).hasFrozenChildren(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Frozen capability condition unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class FrozenCapabilityConditionUnitTest extends BaseUnitTest +{ + /** evaluator */ + private @InjectMocks FrozenCapabilityCondition condition; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Before + @Override + public void before() throws Exception + { + super.before(); + } + + /** + * Given hold + * When evaluate + * Then true + */ + @Test + public void evaluateHold() + { + // is a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(true); + + // evaluate + assertTrue(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, never()).isFrozen(nodeRef); + verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); + } + + /** + * Given is frozen + * And no check children + * When evaluate + * Then true + */ + @Test + public void frozenDontCheckChildren() + { + // is not a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(false); + + // dont check children + condition.setCheckChildren(false); + + // is frozen + when(mockedFreezeService.isFrozen(nodeRef)) + .thenReturn(true); + + // evaluate + assertTrue(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, times(1)).isFrozen(nodeRef); + verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); + } + + /** + * Given is not frozen + * And no check children + * When evaluate + * Then false + */ + @Test + public void notFrozenDontCheckChildren() + { + // is not a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(false); + + // dont check children + condition.setCheckChildren(false); + + // is not frozen + when(mockedFreezeService.isFrozen(nodeRef)) + .thenReturn(false); + + // evaluate + assertFalse(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, times(1)).isFrozen(nodeRef); + verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); + } + + /** + * Given is frozen + * And check children + * When evaluate + * Then true + */ + @Test + public void frozenCheckChildren() + { + // is not a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(false); + + // check children + condition.setCheckChildren(true); + + // is frozen + when(mockedFreezeService.isFrozen(nodeRef)) + .thenReturn(true); + + // evaluate + assertTrue(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, times(1)).isFrozen(nodeRef); + verify(mockedFreezeService, never()).hasFrozenChildren(nodeRef); + } + + /** + * Given is not frozen + * And check children + * And children no frozen + * When evaluate + * Then false + */ + @Test + public void notFrozenCheckChildrenNotFrozen() + { + // is not a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(false); + + // check children + condition.setCheckChildren(true); + + // is not frozen + when(mockedFreezeService.isFrozen(nodeRef)) + .thenReturn(false); + + // children not frozen + when(mockedFreezeService.hasFrozenChildren(nodeRef)) + .thenReturn(false); + + // evaluate + assertFalse(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, times(1)).isFrozen(nodeRef); + verify(mockedFreezeService, times(1)).hasFrozenChildren(nodeRef); + } + + /** + * Given is not frozen + * And check children + * And children frozen + * When evaluate + * Then true + */ + @Test + public void notFrozenCheckChildrenFrozen() + { + // is not a hold + NodeRef nodeRef = generateNodeRef(); + when(mockedHoldService.isHold(nodeRef)) + .thenReturn(false); + + // check children + condition.setCheckChildren(true); + + // is not frozen + when(mockedFreezeService.isFrozen(nodeRef)) + .thenReturn(false); + + // children frozen + when(mockedFreezeService.hasFrozenChildren(nodeRef)) + .thenReturn(true); + + // evaluate + assertTrue(condition.evaluate(nodeRef)); + + // verify + verify(mockedHoldService, times(1)).isHold(nodeRef); + verify(mockedFreezeService, times(1)).isFrozen(nodeRef); + verify(mockedFreezeService, times(1)).hasFrozenChildren(nodeRef); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityConditionUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityConditionUnitTest.java index ad4b3484bf..c1efe1be6b 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityConditionUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/HoldCapabilityConditionUnitTest.java @@ -1,143 +1,143 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.anyBoolean; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -/** - * Freeze evaluator unit test. - * - * @author Roy Wetherall - */ -public class HoldCapabilityConditionUnitTest extends BaseUnitTest -{ - /** test data */ - private NodeRef hold1; - private NodeRef hold2; - private List holds; - - /** mocked objects */ - private @Mock(name="kinds") Set mockedKinds; - - /** evaluator */ - private @Spy @InjectMocks HoldCapabilityCondition evaluator; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Before - @Override - public void before() throws Exception - { - super.before(); - - // setup test data - hold1 = generateNodeRef(TYPE_HOLD); - hold2 = generateNodeRef(TYPE_HOLD); - holds = new ArrayList(2); - holds.add(hold1); - holds.add(hold2); - - // setup interactions - doReturn(false).when(mockedKinds).contains(FilePlanComponentKind.RECORD_CATEGORY); - doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD_FOLDER); - doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.HOLD); - } - - /** - * Test given there are no holds - */ - @Test - public void noHolds() - { - // given - doReturn(Collections.EMPTY_LIST).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); - - // when - boolean result = evaluator.evaluateImpl(recordFolder); - - // then - assertFalse(result); - verify(mockedPermissionService, never()).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); - - } - - /** - * Test given the user has no filling permissions on any of the available holds - */ - @Test - public void noFillingOnHolds() - { - // given - doReturn(holds).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); - doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold1, RMPermissionModel.FILING); - doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold2, RMPermissionModel.FILING); - - // when - boolean result = evaluator.evaluateImpl(recordFolder); - - // then - assertFalse(result); - verify(mockedPermissionService, times(2)).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); - - } - - /** - * Test given the user has filling on one of the available holds - */ - @Test - public void fillingOnHolds() - { - // given - doReturn(holds).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); - doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold1, RMPermissionModel.FILING); - doReturn(AccessStatus.ALLOWED).when(mockedPermissionService).hasPermission(hold2, RMPermissionModel.FILING); - - // when - boolean result = evaluator.evaluateImpl(recordFolder); - - // then - assertTrue(result); - verify(mockedPermissionService, times(2)).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.anyBoolean; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; + +/** + * Freeze evaluator unit test. + * + * @author Roy Wetherall + */ +public class HoldCapabilityConditionUnitTest extends BaseUnitTest +{ + /** test data */ + private NodeRef hold1; + private NodeRef hold2; + private List holds; + + /** mocked objects */ + private @Mock(name="kinds") Set mockedKinds; + + /** evaluator */ + private @Spy @InjectMocks HoldCapabilityCondition evaluator; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Before + @Override + public void before() throws Exception + { + super.before(); + + // setup test data + hold1 = generateNodeRef(TYPE_HOLD); + hold2 = generateNodeRef(TYPE_HOLD); + holds = new ArrayList(2); + holds.add(hold1); + holds.add(hold2); + + // setup interactions + doReturn(false).when(mockedKinds).contains(FilePlanComponentKind.RECORD_CATEGORY); + doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD_FOLDER); + doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.HOLD); + } + + /** + * Test given there are no holds + */ + @Test + public void noHolds() + { + // given + doReturn(Collections.EMPTY_LIST).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); + + // when + boolean result = evaluator.evaluateImpl(recordFolder); + + // then + assertFalse(result); + verify(mockedPermissionService, never()).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); + + } + + /** + * Test given the user has no filling permissions on any of the available holds + */ + @Test + public void noFillingOnHolds() + { + // given + doReturn(holds).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); + doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold1, RMPermissionModel.FILING); + doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold2, RMPermissionModel.FILING); + + // when + boolean result = evaluator.evaluateImpl(recordFolder); + + // then + assertFalse(result); + verify(mockedPermissionService, times(2)).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); + + } + + /** + * Test given the user has filling on one of the available holds + */ + @Test + public void fillingOnHolds() + { + // given + doReturn(holds).when(mockedHoldService).heldBy(eq(recordFolder), anyBoolean()); + doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold1, RMPermissionModel.FILING); + doReturn(AccessStatus.ALLOWED).when(mockedPermissionService).hasPermission(hold2, RMPermissionModel.FILING); + + // when + boolean result = evaluator.evaluateImpl(recordFolder); + + // then + assertTrue(result); + verify(mockedPermissionService, times(2)).hasPermission(any(NodeRef.class), eq(RMPermissionModel.FILING)); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordsMetadataCapabilityUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordsMetadataCapabilityUnitTest.java index e622588d5c..3a69b3d53e 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordsMetadataCapabilityUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/EditNonRecordsMetadataCapabilityUnitTest.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.capability.impl; - -import static org.mockito.Mockito.when; - -import java.util.Set; - -import net.sf.acegisecurity.vote.AccessDecisionVoter; - -import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Edit non records metadata capability unit test - * - * @author Roy Wetherall - * @since 2.3 - */ -public class EditNonRecordsMetadataCapabilityUnitTest extends BaseUnitTest -{ - /** mocked set */ - @Mock private Set mockedSet; - - /** test capability */ - @InjectMocks private EditNonRecordMetadataCapability capability; - - /** - * Given that the evaluated node is held in the transaction cache as new - * When evaluated - * Then access is granted - */ - @Test - public void newRecord() - { - NodeRef nodeRef = generateNodeRef(); - when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) - .thenReturn(mockedSet); - when(mockedSet.contains(nodeRef)) - .thenReturn(true); - - Assert.assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(nodeRef)); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.capability.impl; + +import static org.mockito.Mockito.when; + +import java.util.Set; + +import net.sf.acegisecurity.vote.AccessDecisionVoter; + +import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +/** + * Edit non records metadata capability unit test + * + * @author Roy Wetherall + * @since 2.3 + */ +public class EditNonRecordsMetadataCapabilityUnitTest extends BaseUnitTest +{ + /** mocked set */ + @Mock private Set mockedSet; + + /** test capability */ + @InjectMocks private EditNonRecordMetadataCapability capability; + + /** + * Given that the evaluated node is held in the transaction cache as new + * When evaluated + * Then access is granted + */ + @Test + public void newRecord() + { + NodeRef nodeRef = generateNodeRef(); + when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) + .thenReturn(mockedSet); + when(mockedSet.contains(nodeRef)) + .thenReturn(true); + + Assert.assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(nodeRef)); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilterUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilterUnitTest.java index 0af4780f7e..23dc7d8cf3 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilterUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilterUnitTest.java @@ -1,176 +1,176 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.forms; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.forms.Field; -import org.alfresco.repo.forms.FieldDefinition; -import org.alfresco.repo.forms.Form; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -/** - * RecordsManagementTypeFormFilter Unit Test - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RecordsManagementTypeFormFilterUnitTest extends BaseUnitTest -{ - private static final QName MY_CUSTOM_TYPE = generateQName(); - - @Mock private Form mockForm; - @Mock private TypeDefinition mockTypeDefinition; - @Mock(name="recordsManagementAdminService") private RecordsManagementAdminService mockRecordsManagementAdminService; - - @Spy @InjectMocks RecordsManagementTypeFormFilter typeFormFilter; - - /** - * Test addCustomRMProperties - no custom properties found - */ - @Test - public void testAddCustomRMPropertiesNoneFound() - { - typeFormFilter.addCustomRMProperties(MY_CUSTOM_TYPE, mockForm); - verifyZeroInteractions(mockForm); - } - - /** - * Test that non-customisable types are being treated correctly - */ - @Test - public void testAfterGenerateNotCustomisable() - { - when(mockTypeDefinition.getName()).thenReturn(MY_CUSTOM_TYPE); - when(mockRecordsManagementAdminService.isCustomisable(MY_CUSTOM_TYPE)).thenReturn(false); - - typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); - - verify(typeFormFilter, never()).addCustomRMProperties(any(QName.class), any(Form.class)); - } - - /** - * Test that customisable types are being treated correctly - */ - @Test - public void testAfterGenerateCustomisable() - { - when(mockTypeDefinition.getName()).thenReturn(MY_CUSTOM_TYPE); - when(mockRecordsManagementAdminService.isCustomisable(MY_CUSTOM_TYPE)).thenReturn(true); - - typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); - - verify(typeFormFilter, times(1)).addCustomRMProperties(any(QName.class), any(Form.class)); - } - - /** - * Test the default values for certain properties are being set correctly - */ - @Test - public void testDefaultFormValues() - { - List defs = new ArrayList(3); - FieldDefinition idDef = mockFieldDefinition("rma:identifier"); - defs.add(idDef); - FieldDefinition vrDef = mockFieldDefinition("rma:vitalRecordIndicator"); - defs.add(vrDef); - FieldDefinition rpDef = mockFieldDefinition("rma:reviewPeriod"); - defs.add(rpDef); - - when(mockForm.getFieldDefinitions()).thenReturn(defs); - - typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); - - verify(mockedIdentifierService).generateIdentifier(any(QName.class), any(NodeRef.class)); - verify(idDef).setDefaultValue(anyString()); - verify(vrDef).setDefaultValue(Boolean.FALSE.toString()); - verify(rpDef).setDefaultValue("none|0"); - } - - /** - * Helper to mock field definition - */ - private FieldDefinition mockFieldDefinition(String name) - { - FieldDefinition def = mock(FieldDefinition.class); - when(def.getName()).thenReturn(name); - return def; - } - - /** - * Test addCustomRMProperties - two custom properties found - */ - @Test - public void testAddCustomRMProperties() - { - // map of custom properties - Map properties = mockPropertyDefintionMap(2); - - // setup rm admin service to return properties for my custom type - when(mockRecordsManagementAdminService.getCustomPropertyDefinitions(MY_CUSTOM_TYPE)).thenReturn(properties); - - // call method - typeFormFilter.addCustomRMProperties(MY_CUSTOM_TYPE, mockForm); - - // ensure that two custom properties have been added to the form - verify(mockForm, times(1)).addFields(anyListOf(Field.class)); - } - - /** - * Helper method to createa a mock property definition map - */ - private Map mockPropertyDefintionMap(int size) - { - Map properties = new HashMap(size); - for (int i = 0; i < size; i++) - { - QName name = generateQName(); - PropertyDefinition propDef = mock(PropertyDefinition.class); - when(propDef.getName()).thenReturn(name); - DataTypeDefinition mockDataTypeDefinition = mock(DataTypeDefinition.class); - when(mockDataTypeDefinition.getName()).thenReturn(DataTypeDefinition.TEXT); - when(propDef.getDataType()).thenReturn(mockDataTypeDefinition); - properties.put(name, propDef); - } - return properties; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.forms; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.forms.Field; +import org.alfresco.repo.forms.FieldDefinition; +import org.alfresco.repo.forms.Form; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; + +/** + * RecordsManagementTypeFormFilter Unit Test + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RecordsManagementTypeFormFilterUnitTest extends BaseUnitTest +{ + private static final QName MY_CUSTOM_TYPE = generateQName(); + + @Mock private Form mockForm; + @Mock private TypeDefinition mockTypeDefinition; + @Mock(name="recordsManagementAdminService") private RecordsManagementAdminService mockRecordsManagementAdminService; + + @Spy @InjectMocks RecordsManagementTypeFormFilter typeFormFilter; + + /** + * Test addCustomRMProperties - no custom properties found + */ + @Test + public void testAddCustomRMPropertiesNoneFound() + { + typeFormFilter.addCustomRMProperties(MY_CUSTOM_TYPE, mockForm); + verifyZeroInteractions(mockForm); + } + + /** + * Test that non-customisable types are being treated correctly + */ + @Test + public void testAfterGenerateNotCustomisable() + { + when(mockTypeDefinition.getName()).thenReturn(MY_CUSTOM_TYPE); + when(mockRecordsManagementAdminService.isCustomisable(MY_CUSTOM_TYPE)).thenReturn(false); + + typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); + + verify(typeFormFilter, never()).addCustomRMProperties(any(QName.class), any(Form.class)); + } + + /** + * Test that customisable types are being treated correctly + */ + @Test + public void testAfterGenerateCustomisable() + { + when(mockTypeDefinition.getName()).thenReturn(MY_CUSTOM_TYPE); + when(mockRecordsManagementAdminService.isCustomisable(MY_CUSTOM_TYPE)).thenReturn(true); + + typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); + + verify(typeFormFilter, times(1)).addCustomRMProperties(any(QName.class), any(Form.class)); + } + + /** + * Test the default values for certain properties are being set correctly + */ + @Test + public void testDefaultFormValues() + { + List defs = new ArrayList(3); + FieldDefinition idDef = mockFieldDefinition("rma:identifier"); + defs.add(idDef); + FieldDefinition vrDef = mockFieldDefinition("rma:vitalRecordIndicator"); + defs.add(vrDef); + FieldDefinition rpDef = mockFieldDefinition("rma:reviewPeriod"); + defs.add(rpDef); + + when(mockForm.getFieldDefinitions()).thenReturn(defs); + + typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null); + + verify(mockedIdentifierService).generateIdentifier(any(QName.class), any(NodeRef.class)); + verify(idDef).setDefaultValue(anyString()); + verify(vrDef).setDefaultValue(Boolean.FALSE.toString()); + verify(rpDef).setDefaultValue("none|0"); + } + + /** + * Helper to mock field definition + */ + private FieldDefinition mockFieldDefinition(String name) + { + FieldDefinition def = mock(FieldDefinition.class); + when(def.getName()).thenReturn(name); + return def; + } + + /** + * Test addCustomRMProperties - two custom properties found + */ + @Test + public void testAddCustomRMProperties() + { + // map of custom properties + Map properties = mockPropertyDefintionMap(2); + + // setup rm admin service to return properties for my custom type + when(mockRecordsManagementAdminService.getCustomPropertyDefinitions(MY_CUSTOM_TYPE)).thenReturn(properties); + + // call method + typeFormFilter.addCustomRMProperties(MY_CUSTOM_TYPE, mockForm); + + // ensure that two custom properties have been added to the form + verify(mockForm, times(1)).addFields(anyListOf(Field.class)); + } + + /** + * Helper method to createa a mock property definition map + */ + private Map mockPropertyDefintionMap(int size) + { + Map properties = new HashMap(size); + for (int i = 0; i < size; i++) + { + QName name = generateQName(); + PropertyDefinition propDef = mock(PropertyDefinition.class); + when(propDef.getName()).thenReturn(name); + DataTypeDefinition mockDataTypeDefinition = mock(DataTypeDefinition.class); + when(mockDataTypeDefinition.getName()).thenReturn(DataTypeDefinition.TEXT); + when(propDef.getDataType()).thenReturn(mockDataTypeDefinition); + properties.put(name, propDef); + } + return properties; + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java index 4b017a54cf..55b57c4fef 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java @@ -1,459 +1,459 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.hold; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - - -/** - * Hold service implementation unit test - * - * @author Roy Wetherall - * @since 2.2 - */ -public class HoldServiceImplUnitTest extends BaseUnitTest -{ - /** test values */ - private static final String HOLD_NAME = "holdname"; - private static final String HOLD_REASON = "holdreason"; - private static final String HOLD_DESCRIPTION = "holddescription"; - - protected NodeRef holdContainer; - protected NodeRef hold; - protected NodeRef hold2; - - @Spy @InjectMocks HoldServiceImpl holdService; - - @Before - @Override - public void before() throws Exception - { - super.before(); - - // setup objects used in mock interactions - holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); - hold = generateNodeRef(TYPE_HOLD); - hold2 = generateNodeRef(TYPE_HOLD); - - // setup interactions - doReturn(holdContainer).when(mockedFilePlanService).getHoldContainer(filePlan); - } - - @Test - public void isHold() - { - assertTrue(holdService.isHold(hold)); - assertFalse(holdService.isHold(recordFolder)); - } - - @Test - public void heldByMultipleResults() - { - // setup record folder in multiple holds - List holds = new ArrayList(2); - holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold, ASSOC_FROZEN_RECORDS, recordFolder, true, 1)); - holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold2, ASSOC_FROZEN_RECORDS, recordFolder, true, 2)); - doReturn(holds).when(mockedNodeService).getParentAssocs(recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - - // check that both holds are found for record folder - List heldByHolds = holdService.heldBy(recordFolder, true); - assertNotNull(heldByHolds); - assertEquals(2, heldByHolds.size()); - assertTrue(holdService.heldBy(recordFolder, false).isEmpty()); - - // check that both holds are found for record (even thou they are one level deep) - heldByHolds = holdService.heldBy(record, true); - assertNotNull(heldByHolds); - assertEquals(2, heldByHolds.size()); - assertTrue(holdService.heldBy(record, false).isEmpty()); - } - - @Test (expected=AlfrescoRuntimeException.class) - public void getHold() - { - // setup node service interactions - when(mockedNodeService.getChildByName(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), anyString())).thenReturn(null) - .thenReturn(hold) - .thenReturn(recordFolder); - - // no hold - NodeRef noHold = holdService.getHold(filePlan, "notAHold"); - assertNull(noHold); - - // found hold - NodeRef someHold = holdService.getHold(filePlan, "someHold"); - assertNotNull(someHold); - assertEquals(TYPE_HOLD, mockedNodeService.getType(someHold)); - - // ensure runtime exception is thrown - holdService.getHold(filePlan, "notHold"); - } - - @Test (expected=RuntimeException.class) - public void getHeldNotAHold() - { - holdService.getHeld(recordFolder); - } - - @Test - public void getHeldNoResults() - { - assertTrue(holdService.getHeld(hold).isEmpty()); - } - - @Test - public void getHeldWithResults() - { - // setup record folder in hold - List holds = new ArrayList(1); - holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold, ASSOC_FROZEN_RECORDS, recordFolder, true, 1)); - doReturn(holds).when(mockedNodeService).getChildAssocs(hold, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL); - - List list = holdService.getHeld(hold); - assertEquals(1, list.size()); - assertEquals(recordFolder, list.get(0)); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - public void createHold() - { - // setup node service interactions - when(mockedNodeService.createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), any(QName.class) , eq(TYPE_HOLD), any(Map.class))) - .thenReturn(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, holdContainer, generateQName(), hold)); - - // create hold - NodeRef newHold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); - assertNotNull(newHold); - assertEquals(TYPE_HOLD, mockedNodeService.getType(newHold)); - assertEquals(hold, newHold); - - // check the node service interactions - ArgumentCaptor propertyMapCaptor = ArgumentCaptor.forClass(Map.class); - ArgumentCaptor assocNameCaptor = ArgumentCaptor.forClass(QName.class); - verify(mockedNodeService).createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), assocNameCaptor.capture() , eq(TYPE_HOLD), propertyMapCaptor.capture()); - - // check property map - Map propertyMap = (Map)propertyMapCaptor.getValue(); - assertNotNull(propertyMap); - assertEquals(3, propertyMap.size()); - assertTrue(propertyMap.containsKey(ContentModel.PROP_NAME)); - assertEquals(HOLD_NAME, propertyMap.get(ContentModel.PROP_NAME)); - assertTrue(propertyMap.containsKey(ContentModel.PROP_DESCRIPTION)); - assertEquals(HOLD_DESCRIPTION, propertyMap.get(ContentModel.PROP_DESCRIPTION)); - assertTrue(propertyMap.containsKey(PROP_HOLD_REASON)); - assertEquals(HOLD_REASON, propertyMap.get(PROP_HOLD_REASON)); - - // check assoc name - assertNotNull(assocNameCaptor.getValue()); - assertEquals(NamespaceService.CONTENT_MODEL_1_0_URI, assocNameCaptor.getValue().getNamespaceURI()); - assertEquals(HOLD_NAME, assocNameCaptor.getValue().getLocalName()); - } - - @Test - public void getHoldReason() - { - // setup node service interactions - when(mockedNodeService.exists(hold)) - .thenReturn(false) - .thenReturn(true) - .thenReturn(true) - .thenReturn(true); - when(mockedNodeService.getProperty(eq(hold), eq(PROP_HOLD_REASON))) - .thenReturn(null) - .thenReturn(HOLD_REASON); - - // node does not exist - assertNull(holdService.getHoldReason(hold)); - - // node isn't a hold - assertNull(holdService.getHoldReason(recordFolder)); - - // hold reason isn't set - assertNull(holdService.getHoldReason(hold)); - - // hold reason set - assertEquals(HOLD_REASON, holdService.getHoldReason(hold)); - } - - @Test - public void setHoldReason() - { - // setup node service interactions - when(mockedNodeService.exists(hold)) - .thenReturn(false) - .thenReturn(true) - .thenReturn(true); - - // node does not exist - holdService.setHoldReason(hold, HOLD_REASON); - verify(mockedNodeService, never()).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); - - // node isn't a hold - holdService.setHoldReason(recordFolder, HOLD_REASON); - verify(mockedNodeService, never()).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); - - // set hold reason - holdService.setHoldReason(hold, HOLD_REASON); - verify(mockedNodeService).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); - } - - @Test (expected=AlfrescoRuntimeException.class) - public void deleteHoldNotAHold() - { - holdService.deleteHold(recordFolder); - verify(mockedNodeService, never()).deleteNode(hold); - } - - @Test - public void deleteHold() - { - // delete hold - holdService.deleteHold(hold); - verify(mockedNodeService).deleteNode(hold); - - // TODO check interactions with policy component!!! - } - - @Test (expected=AlfrescoRuntimeException.class) - public void addToHoldNotAHold() - { - holdService.addToHold(recordFolder, recordFolder); - } - - @Test (expected=AlfrescoRuntimeException.class) - public void addToHoldNotARecordFolderOrRecord() - { - NodeRef anotherThing = generateNodeRef(TYPE_RECORD_CATEGORY); - holdService.addToHold(hold, anotherThing); - } - - @SuppressWarnings("unchecked") - @Test - public void addToHoldNotInHold() - { - holdService.addToHold(hold, recordFolder); - - verify(mockedNodeService).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedNodeService).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); - - holdService.addToHold(hold, record); - verify(mockedNodeService).addChild(hold, record, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedNodeService, times(2)).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(record), anyString()); - } - - @SuppressWarnings("unchecked") - @Test - public void addToHoldAlreadyInHold() - { - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); - - holdService.addToHold(hold, recordFolder); - - verify(mockedNodeService, never()).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService, never()).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedNodeService, never()).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedRecordsManagementAuditService, never()).auditEvent(eq(recordFolder), anyString()); - } - - @SuppressWarnings("unchecked") - @Test - public void addToHoldAldeadyFrozen() - { - doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); - - holdService.addToHold(hold, recordFolder); - - verify(mockedNodeService, times(1)).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService, never()).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedNodeService, never()).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); - } - - @SuppressWarnings("unchecked") - @Test - public void addToHolds() - { - // ensure the interaction indicates that a node has the frozen aspect applied if it has - doAnswer(new Answer() - { - public Void answer(InvocationOnMock invocation) - { - NodeRef nodeRef = (NodeRef)invocation.getArguments()[0]; - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ASPECT_FROZEN); - return null; - } - - }).when(mockedNodeService).addAspect(any(NodeRef.class), eq(ASPECT_FROZEN), any(Map.class)); - - // build a list of holds - List holds = new ArrayList(2); - holds.add(hold); - holds.add(hold2); - - // add the record folder to both holds - holdService.addToHolds(holds, recordFolder); - - // verify the interactions - verify(mockedNodeService, times(1)).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService, times(1)).addChild(hold2, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); - verify(mockedNodeService, times(1)).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedNodeService, times(1)).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); - verify(mockedRecordsManagementAuditService, times(2)).auditEvent(eq(recordFolder), anyString()); - } - - @Test (expected=AlfrescoRuntimeException.class) - public void removeFromHoldNotAHold() - { - holdService.removeFromHold(recordFolder, recordFolder); - } - - @Test - public void removeFromHoldNotInHold() - { - holdService.removeFromHold(hold, recordFolder); - - verify(mockedNodeService, never()).removeChild(hold, recordFolder); - verify(mockedNodeService, never()).removeAspect(recordFolder, ASPECT_FROZEN); - verify(mockedNodeService, never()).removeAspect(record, ASPECT_FROZEN); - verify(mockedRecordsManagementAuditService, never()).auditEvent(eq(recordFolder), anyString()); - } - - @Test - public void removeFromHold() - { - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); - doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); - - holdService.removeFromHold(hold, recordFolder); - - verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); - verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); - verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); - verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); - } - - @Test - public void removeFromHolds() - { - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold2); - doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); - - // build a list of holds - List holds = new ArrayList(2); - holds.add(hold); - holds.add(hold2); - - holdService.removeFromHolds(holds, recordFolder); - - verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); - verify(mockedNodeService, times(1)).removeChild(hold2, recordFolder); - verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); - verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); - verify(mockedRecordsManagementAuditService, times(2)).auditEvent(any(NodeRef.class), anyString()); - } - - @Test - public void removeFromAllHolds() - { - // build a list of holds - List holds = new ArrayList(2); - holds.add(hold); - holds.add(hold2); - - doAnswer(new Answer() - { - public Void answer(InvocationOnMock invocation) - { - doReturn(Collections.singletonList(hold2)).when(holdService).heldBy(recordFolder, true); - return null; - } - - }).when(mockedNodeService).removeChild(hold, recordFolder); - - doAnswer(new Answer() - { - public Void answer(InvocationOnMock invocation) - { - doReturn(new ArrayList()).when(holdService).heldBy(recordFolder, true); - return null; - } - - }).when(mockedNodeService).removeChild(hold2, recordFolder); - - // define interactions - doReturn(holds).when(holdService).heldBy(recordFolder, true); - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); - doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold2); - doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); - - // remove record folder from all holds - holdService.removeFromAllHolds(recordFolder); - - // verify interactions - verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); - verify(mockedNodeService, times(1)).removeChild(hold2, recordFolder); - verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); - verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.hold; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + + +/** + * Hold service implementation unit test + * + * @author Roy Wetherall + * @since 2.2 + */ +public class HoldServiceImplUnitTest extends BaseUnitTest +{ + /** test values */ + private static final String HOLD_NAME = "holdname"; + private static final String HOLD_REASON = "holdreason"; + private static final String HOLD_DESCRIPTION = "holddescription"; + + protected NodeRef holdContainer; + protected NodeRef hold; + protected NodeRef hold2; + + @Spy @InjectMocks HoldServiceImpl holdService; + + @Before + @Override + public void before() throws Exception + { + super.before(); + + // setup objects used in mock interactions + holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER); + hold = generateNodeRef(TYPE_HOLD); + hold2 = generateNodeRef(TYPE_HOLD); + + // setup interactions + doReturn(holdContainer).when(mockedFilePlanService).getHoldContainer(filePlan); + } + + @Test + public void isHold() + { + assertTrue(holdService.isHold(hold)); + assertFalse(holdService.isHold(recordFolder)); + } + + @Test + public void heldByMultipleResults() + { + // setup record folder in multiple holds + List holds = new ArrayList(2); + holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold, ASSOC_FROZEN_RECORDS, recordFolder, true, 1)); + holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold2, ASSOC_FROZEN_RECORDS, recordFolder, true, 2)); + doReturn(holds).when(mockedNodeService).getParentAssocs(recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + + // check that both holds are found for record folder + List heldByHolds = holdService.heldBy(recordFolder, true); + assertNotNull(heldByHolds); + assertEquals(2, heldByHolds.size()); + assertTrue(holdService.heldBy(recordFolder, false).isEmpty()); + + // check that both holds are found for record (even thou they are one level deep) + heldByHolds = holdService.heldBy(record, true); + assertNotNull(heldByHolds); + assertEquals(2, heldByHolds.size()); + assertTrue(holdService.heldBy(record, false).isEmpty()); + } + + @Test (expected=AlfrescoRuntimeException.class) + public void getHold() + { + // setup node service interactions + when(mockedNodeService.getChildByName(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), anyString())).thenReturn(null) + .thenReturn(hold) + .thenReturn(recordFolder); + + // no hold + NodeRef noHold = holdService.getHold(filePlan, "notAHold"); + assertNull(noHold); + + // found hold + NodeRef someHold = holdService.getHold(filePlan, "someHold"); + assertNotNull(someHold); + assertEquals(TYPE_HOLD, mockedNodeService.getType(someHold)); + + // ensure runtime exception is thrown + holdService.getHold(filePlan, "notHold"); + } + + @Test (expected=RuntimeException.class) + public void getHeldNotAHold() + { + holdService.getHeld(recordFolder); + } + + @Test + public void getHeldNoResults() + { + assertTrue(holdService.getHeld(hold).isEmpty()); + } + + @Test + public void getHeldWithResults() + { + // setup record folder in hold + List holds = new ArrayList(1); + holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold, ASSOC_FROZEN_RECORDS, recordFolder, true, 1)); + doReturn(holds).when(mockedNodeService).getChildAssocs(hold, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL); + + List list = holdService.getHeld(hold); + assertEquals(1, list.size()); + assertEquals(recordFolder, list.get(0)); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test + public void createHold() + { + // setup node service interactions + when(mockedNodeService.createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), any(QName.class) , eq(TYPE_HOLD), any(Map.class))) + .thenReturn(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, holdContainer, generateQName(), hold)); + + // create hold + NodeRef newHold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); + assertNotNull(newHold); + assertEquals(TYPE_HOLD, mockedNodeService.getType(newHold)); + assertEquals(hold, newHold); + + // check the node service interactions + ArgumentCaptor propertyMapCaptor = ArgumentCaptor.forClass(Map.class); + ArgumentCaptor assocNameCaptor = ArgumentCaptor.forClass(QName.class); + verify(mockedNodeService).createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), assocNameCaptor.capture() , eq(TYPE_HOLD), propertyMapCaptor.capture()); + + // check property map + Map propertyMap = (Map)propertyMapCaptor.getValue(); + assertNotNull(propertyMap); + assertEquals(3, propertyMap.size()); + assertTrue(propertyMap.containsKey(ContentModel.PROP_NAME)); + assertEquals(HOLD_NAME, propertyMap.get(ContentModel.PROP_NAME)); + assertTrue(propertyMap.containsKey(ContentModel.PROP_DESCRIPTION)); + assertEquals(HOLD_DESCRIPTION, propertyMap.get(ContentModel.PROP_DESCRIPTION)); + assertTrue(propertyMap.containsKey(PROP_HOLD_REASON)); + assertEquals(HOLD_REASON, propertyMap.get(PROP_HOLD_REASON)); + + // check assoc name + assertNotNull(assocNameCaptor.getValue()); + assertEquals(NamespaceService.CONTENT_MODEL_1_0_URI, assocNameCaptor.getValue().getNamespaceURI()); + assertEquals(HOLD_NAME, assocNameCaptor.getValue().getLocalName()); + } + + @Test + public void getHoldReason() + { + // setup node service interactions + when(mockedNodeService.exists(hold)) + .thenReturn(false) + .thenReturn(true) + .thenReturn(true) + .thenReturn(true); + when(mockedNodeService.getProperty(eq(hold), eq(PROP_HOLD_REASON))) + .thenReturn(null) + .thenReturn(HOLD_REASON); + + // node does not exist + assertNull(holdService.getHoldReason(hold)); + + // node isn't a hold + assertNull(holdService.getHoldReason(recordFolder)); + + // hold reason isn't set + assertNull(holdService.getHoldReason(hold)); + + // hold reason set + assertEquals(HOLD_REASON, holdService.getHoldReason(hold)); + } + + @Test + public void setHoldReason() + { + // setup node service interactions + when(mockedNodeService.exists(hold)) + .thenReturn(false) + .thenReturn(true) + .thenReturn(true); + + // node does not exist + holdService.setHoldReason(hold, HOLD_REASON); + verify(mockedNodeService, never()).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); + + // node isn't a hold + holdService.setHoldReason(recordFolder, HOLD_REASON); + verify(mockedNodeService, never()).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); + + // set hold reason + holdService.setHoldReason(hold, HOLD_REASON); + verify(mockedNodeService).setProperty(hold, PROP_HOLD_REASON, HOLD_REASON); + } + + @Test (expected=AlfrescoRuntimeException.class) + public void deleteHoldNotAHold() + { + holdService.deleteHold(recordFolder); + verify(mockedNodeService, never()).deleteNode(hold); + } + + @Test + public void deleteHold() + { + // delete hold + holdService.deleteHold(hold); + verify(mockedNodeService).deleteNode(hold); + + // TODO check interactions with policy component!!! + } + + @Test (expected=AlfrescoRuntimeException.class) + public void addToHoldNotAHold() + { + holdService.addToHold(recordFolder, recordFolder); + } + + @Test (expected=AlfrescoRuntimeException.class) + public void addToHoldNotARecordFolderOrRecord() + { + NodeRef anotherThing = generateNodeRef(TYPE_RECORD_CATEGORY); + holdService.addToHold(hold, anotherThing); + } + + @SuppressWarnings("unchecked") + @Test + public void addToHoldNotInHold() + { + holdService.addToHold(hold, recordFolder); + + verify(mockedNodeService).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedNodeService).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); + + holdService.addToHold(hold, record); + verify(mockedNodeService).addChild(hold, record, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedNodeService, times(2)).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(record), anyString()); + } + + @SuppressWarnings("unchecked") + @Test + public void addToHoldAlreadyInHold() + { + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); + + holdService.addToHold(hold, recordFolder); + + verify(mockedNodeService, never()).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService, never()).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedNodeService, never()).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedRecordsManagementAuditService, never()).auditEvent(eq(recordFolder), anyString()); + } + + @SuppressWarnings("unchecked") + @Test + public void addToHoldAldeadyFrozen() + { + doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); + + holdService.addToHold(hold, recordFolder); + + verify(mockedNodeService, times(1)).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService, never()).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedNodeService, never()).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); + } + + @SuppressWarnings("unchecked") + @Test + public void addToHolds() + { + // ensure the interaction indicates that a node has the frozen aspect applied if it has + doAnswer(new Answer() + { + public Void answer(InvocationOnMock invocation) + { + NodeRef nodeRef = (NodeRef)invocation.getArguments()[0]; + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ASPECT_FROZEN); + return null; + } + + }).when(mockedNodeService).addAspect(any(NodeRef.class), eq(ASPECT_FROZEN), any(Map.class)); + + // build a list of holds + List holds = new ArrayList(2); + holds.add(hold); + holds.add(hold2); + + // add the record folder to both holds + holdService.addToHolds(holds, recordFolder); + + // verify the interactions + verify(mockedNodeService, times(1)).addChild(hold, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService, times(1)).addChild(hold2, recordFolder, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS); + verify(mockedNodeService, times(1)).addAspect(eq(recordFolder), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedNodeService, times(1)).addAspect(eq(record), eq(ASPECT_FROZEN), any(Map.class)); + verify(mockedRecordsManagementAuditService, times(2)).auditEvent(eq(recordFolder), anyString()); + } + + @Test (expected=AlfrescoRuntimeException.class) + public void removeFromHoldNotAHold() + { + holdService.removeFromHold(recordFolder, recordFolder); + } + + @Test + public void removeFromHoldNotInHold() + { + holdService.removeFromHold(hold, recordFolder); + + verify(mockedNodeService, never()).removeChild(hold, recordFolder); + verify(mockedNodeService, never()).removeAspect(recordFolder, ASPECT_FROZEN); + verify(mockedNodeService, never()).removeAspect(record, ASPECT_FROZEN); + verify(mockedRecordsManagementAuditService, never()).auditEvent(eq(recordFolder), anyString()); + } + + @Test + public void removeFromHold() + { + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); + doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); + + holdService.removeFromHold(hold, recordFolder); + + verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); + verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); + verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); + verify(mockedRecordsManagementAuditService, times(1)).auditEvent(eq(recordFolder), anyString()); + } + + @Test + public void removeFromHolds() + { + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold2); + doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); + + // build a list of holds + List holds = new ArrayList(2); + holds.add(hold); + holds.add(hold2); + + holdService.removeFromHolds(holds, recordFolder); + + verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); + verify(mockedNodeService, times(1)).removeChild(hold2, recordFolder); + verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); + verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); + verify(mockedRecordsManagementAuditService, times(2)).auditEvent(any(NodeRef.class), anyString()); + } + + @Test + public void removeFromAllHolds() + { + // build a list of holds + List holds = new ArrayList(2); + holds.add(hold); + holds.add(hold2); + + doAnswer(new Answer() + { + public Void answer(InvocationOnMock invocation) + { + doReturn(Collections.singletonList(hold2)).when(holdService).heldBy(recordFolder, true); + return null; + } + + }).when(mockedNodeService).removeChild(hold, recordFolder); + + doAnswer(new Answer() + { + public Void answer(InvocationOnMock invocation) + { + doReturn(new ArrayList()).when(holdService).heldBy(recordFolder, true); + return null; + } + + }).when(mockedNodeService).removeChild(hold2, recordFolder); + + // define interactions + doReturn(holds).when(holdService).heldBy(recordFolder, true); + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold); + doReturn(Collections.singletonList(recordFolder)).when(holdService).getHeld(hold2); + doReturn(true).when(mockedNodeService).hasAspect(recordFolder, ASPECT_FROZEN); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_FROZEN); + + // remove record folder from all holds + holdService.removeFromAllHolds(recordFolder); + + // verify interactions + verify(mockedNodeService, times(1)).removeChild(hold, recordFolder); + verify(mockedNodeService, times(1)).removeChild(hold2, recordFolder); + verify(mockedNodeService, times(1)).removeAspect(recordFolder, ASPECT_FROZEN); + verify(mockedNodeService, times(1)).removeAspect(record, ASPECT_FROZEN); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java index ced4613d26..61518d6875 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java @@ -1,245 +1,245 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.job; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.anyMap; -import static org.mockito.Mockito.contains; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Disposition lifecycle job execution unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest -{ - /** disposition actions */ - private static final String CUTOFF = "cutoff"; - private static final String RETAIN = "retain"; - private static final String DESTROY = "destroy"; - - /** test query snipit */ - private static final String QUERY = "\"" + CUTOFF + "\" OR \"" + RETAIN + "\""; - - /** mocked result set */ - @Mock ResultSet mockedResultSet; - - /** disposition lifecycle job executer */ - @InjectMocks DispositionLifecycleJobExecuter executer; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Override - @Before - public void before() throws Exception - { - super.before(); - - // setup data - List dispositionActions = buildList(CUTOFF, RETAIN); - executer.setDispositionActions(dispositionActions); - - // setup interactions - doReturn(mockedResultSet).when(mockedSearchService).query(eq(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), eq(SearchService.LANGUAGE_FTS_ALFRESCO), anyString()); - } - - /** - * Helper method to verify that the query has been executed and closed - */ - private void verifyQuery() - { - verify(mockedSearchService, times(1)).query(eq(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), eq(SearchService.LANGUAGE_FTS_ALFRESCO), contains(QUERY)); - verify(mockedResultSet, times(1)).getNodeRefs(); - verify(mockedResultSet, times(1)).close(); - } - - /** - * When the are no results in query. - */ - @Test - public void noResultsInQuery() - { - // given - doReturn(Collections.EMPTY_LIST).when(mockedResultSet).getNodeRefs(); - - // when - executer.executeImpl(); - - // then - - // ensure the query is executed and closed - verifyQuery(); - - // ensure nothing else happens becuase we have no results - verifyZeroInteractions(mockedNodeService, mockedRecordFolderService, mockedRetryingTransactionHelper); - } - - /** - * When the disposition actions do not match those that can be processed automatically. - */ - @SuppressWarnings("unchecked") - @Test - public void dispositionActionDoesNotMatch() - { - // test data - NodeRef node1 = generateNodeRef(); - NodeRef node2 = generateNodeRef(); - List nodeRefs = buildList(node1, node2); - - // given - doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); - doReturn(DESTROY).when(mockedNodeService).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); - doReturn(DESTROY).when(mockedNodeService).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); - - // when - executer.executeImpl(); - - // then - - // ensure the query is executed and closed - verifyQuery(); - - // ensure work is executed in transaction for each node processed - verify(mockedNodeService, times(2)).exists(any(NodeRef.class)); - verify(mockedRetryingTransactionHelper, times(2)).doInTransaction(any(RetryingTransactionCallback.class)); - - // ensure each node is process correctly - verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); - verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); - - // ensure no more interactions - verifyNoMoreInteractions(mockedNodeService); - verifyZeroInteractions(mockedRecordsManagementActionService); - - } - - /** - * When a node does not exist - */ - @Test - public void nodeDoesNotExist() - { - // test data - NodeRef node1 = generateNodeRef(null, false); - List nodeRefs = buildList(node1); - - // given - doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); - - // when - executer.executeImpl(); - - // then - - // ensure the query is executed and closed - verifyQuery(); - - // ensure the node exist check is made for the node - verify(mockedNodeService, times(1)).exists(any(NodeRef.class)); - - // ensure no more interactions - verifyNoMoreInteractions(mockedNodeService); - verifyZeroInteractions(mockedRecordsManagementActionService, mockedRetryingTransactionHelper); - } - - /** - * When there are disposition actions eligible for processing - */ - @SuppressWarnings("unchecked") - @Test - public void dispositionActionProcessed() - { - // test data - NodeRef node1 = generateNodeRef(); - NodeRef node2 = generateNodeRef(); - List nodeRefs = buildList(node1, node2); - NodeRef parent = generateNodeRef(); - ChildAssociationRef parentAssoc = new ChildAssociationRef(ASSOC_NEXT_DISPOSITION_ACTION, parent, generateQName(), generateNodeRef()); - - // given - doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); - doReturn(CUTOFF).when(mockedNodeService).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); - doReturn(RETAIN).when(mockedNodeService).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); - doReturn(parentAssoc).when(mockedNodeService).getPrimaryParent(any(NodeRef.class)); - - // when - executer.executeImpl(); - - // then - - // ensure the query is executed and closed - verifyQuery(); - - // ensure work is executed in transaction for each node processed - verify(mockedNodeService, times(2)).exists(any(NodeRef.class)); - verify(mockedRetryingTransactionHelper, times(2)).doInTransaction(any(RetryingTransactionCallback.class)); - - // ensure each node is process correctly - // node1 - verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); - verify(mockedNodeService, times(1)).getPrimaryParent(node1); - verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(CUTOFF), anyMap()); - // node2 - verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); - verify(mockedNodeService, times(1)).getPrimaryParent(node2); - verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(RETAIN), anyMap()); - - // ensure no more interactions - verifyNoMoreInteractions(mockedNodeService, mockedRecordsManagementActionService); - } - - /** - * Brittle unit test that simply checks the generated query is an exact string when the supplied disposition actions - * are "CUTOFF" and "RETAIN" (see {@link #before}). - */ - @Test - public void testGetQuery() - { - String actual = executer.getQuery(); - - String expected = "TYPE:\"rma:dispositionAction\" + (@rma\\:dispositionAction:(\"cutoff\" OR \"retain\")) AND ISUNSET:\"rma:dispositionActionCompletedAt\" AND ( @rma\\:dispositionEventsEligible:true OR @rma\\:dispositionAsOf:[MIN TO NOW] ) "; - assertEquals(expected, actual); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.job; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.anyMap; +import static org.mockito.Mockito.contains; + +import java.util.Collections; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.ResultSet; +import org.alfresco.service.cmr.search.SearchService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +/** + * Disposition lifecycle job execution unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest +{ + /** disposition actions */ + private static final String CUTOFF = "cutoff"; + private static final String RETAIN = "retain"; + private static final String DESTROY = "destroy"; + + /** test query snipit */ + private static final String QUERY = "\"" + CUTOFF + "\" OR \"" + RETAIN + "\""; + + /** mocked result set */ + @Mock ResultSet mockedResultSet; + + /** disposition lifecycle job executer */ + @InjectMocks DispositionLifecycleJobExecuter executer; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Override + @Before + public void before() throws Exception + { + super.before(); + + // setup data + List dispositionActions = buildList(CUTOFF, RETAIN); + executer.setDispositionActions(dispositionActions); + + // setup interactions + doReturn(mockedResultSet).when(mockedSearchService).query(eq(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), eq(SearchService.LANGUAGE_FTS_ALFRESCO), anyString()); + } + + /** + * Helper method to verify that the query has been executed and closed + */ + private void verifyQuery() + { + verify(mockedSearchService, times(1)).query(eq(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), eq(SearchService.LANGUAGE_FTS_ALFRESCO), contains(QUERY)); + verify(mockedResultSet, times(1)).getNodeRefs(); + verify(mockedResultSet, times(1)).close(); + } + + /** + * When the are no results in query. + */ + @Test + public void noResultsInQuery() + { + // given + doReturn(Collections.EMPTY_LIST).when(mockedResultSet).getNodeRefs(); + + // when + executer.executeImpl(); + + // then + + // ensure the query is executed and closed + verifyQuery(); + + // ensure nothing else happens becuase we have no results + verifyZeroInteractions(mockedNodeService, mockedRecordFolderService, mockedRetryingTransactionHelper); + } + + /** + * When the disposition actions do not match those that can be processed automatically. + */ + @SuppressWarnings("unchecked") + @Test + public void dispositionActionDoesNotMatch() + { + // test data + NodeRef node1 = generateNodeRef(); + NodeRef node2 = generateNodeRef(); + List nodeRefs = buildList(node1, node2); + + // given + doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); + doReturn(DESTROY).when(mockedNodeService).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); + doReturn(DESTROY).when(mockedNodeService).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); + + // when + executer.executeImpl(); + + // then + + // ensure the query is executed and closed + verifyQuery(); + + // ensure work is executed in transaction for each node processed + verify(mockedNodeService, times(2)).exists(any(NodeRef.class)); + verify(mockedRetryingTransactionHelper, times(2)).doInTransaction(any(RetryingTransactionCallback.class)); + + // ensure each node is process correctly + verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); + verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); + + // ensure no more interactions + verifyNoMoreInteractions(mockedNodeService); + verifyZeroInteractions(mockedRecordsManagementActionService); + + } + + /** + * When a node does not exist + */ + @Test + public void nodeDoesNotExist() + { + // test data + NodeRef node1 = generateNodeRef(null, false); + List nodeRefs = buildList(node1); + + // given + doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); + + // when + executer.executeImpl(); + + // then + + // ensure the query is executed and closed + verifyQuery(); + + // ensure the node exist check is made for the node + verify(mockedNodeService, times(1)).exists(any(NodeRef.class)); + + // ensure no more interactions + verifyNoMoreInteractions(mockedNodeService); + verifyZeroInteractions(mockedRecordsManagementActionService, mockedRetryingTransactionHelper); + } + + /** + * When there are disposition actions eligible for processing + */ + @SuppressWarnings("unchecked") + @Test + public void dispositionActionProcessed() + { + // test data + NodeRef node1 = generateNodeRef(); + NodeRef node2 = generateNodeRef(); + List nodeRefs = buildList(node1, node2); + NodeRef parent = generateNodeRef(); + ChildAssociationRef parentAssoc = new ChildAssociationRef(ASSOC_NEXT_DISPOSITION_ACTION, parent, generateQName(), generateNodeRef()); + + // given + doReturn(nodeRefs).when(mockedResultSet).getNodeRefs(); + doReturn(CUTOFF).when(mockedNodeService).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); + doReturn(RETAIN).when(mockedNodeService).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); + doReturn(parentAssoc).when(mockedNodeService).getPrimaryParent(any(NodeRef.class)); + + // when + executer.executeImpl(); + + // then + + // ensure the query is executed and closed + verifyQuery(); + + // ensure work is executed in transaction for each node processed + verify(mockedNodeService, times(2)).exists(any(NodeRef.class)); + verify(mockedRetryingTransactionHelper, times(2)).doInTransaction(any(RetryingTransactionCallback.class)); + + // ensure each node is process correctly + // node1 + verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION); + verify(mockedNodeService, times(1)).getPrimaryParent(node1); + verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(CUTOFF), anyMap()); + // node2 + verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION); + verify(mockedNodeService, times(1)).getPrimaryParent(node2); + verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(RETAIN), anyMap()); + + // ensure no more interactions + verifyNoMoreInteractions(mockedNodeService, mockedRecordsManagementActionService); + } + + /** + * Brittle unit test that simply checks the generated query is an exact string when the supplied disposition actions + * are "CUTOFF" and "RETAIN" (see {@link #before}). + */ + @Test + public void testGetQuery() + { + String actual = executer.getQuery(); + + String expected = "TYPE:\"rma:dispositionAction\" + (@rma\\:dispositionAction:(\"cutoff\" OR \"retain\")) AND ISUNSET:\"rma:dispositionActionCompletedAt\" AND ( @rma\\:dispositionEventsEligible:true OR @rma\\:dispositionAsOf:[MIN TO NOW] ) "; + assertEquals(expected, actual); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluatorUnitTest.java index e8d510a30a..dece078cd5 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluatorUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FrozenEvaluatorUnitTest.java @@ -1,107 +1,107 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.Collections; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -/** - * Freeze evaluator unit test. - * - * @author Roy Wetherall - */ -public class FrozenEvaluatorUnitTest extends BaseUnitTest -{ - @Mock(name="kinds") Set mockedKinds; - - @Spy @InjectMocks FrozenEvaluator evaluator; - - @Before - @Override - public void before() throws Exception - { - super.before(); - - // setup interactions - doReturn(false).when(mockedKinds).contains(FilePlanComponentKind.RECORD_CATEGORY); - doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD_FOLDER); - doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD); - } - - @Test - public void isNotRecordOrRecordFolder() - { - // setup interactions - NodeRef nodeRef = generateNodeRef(TYPE_RECORD_CATEGORY); - doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(mockedFilePlanService).getFilePlanComponentKind(nodeRef); - - // evaluate - boolean result = evaluator.evaluate(filePlanComponent); - assertFalse(result); - - // verify interactions - verify(mockedHoldService, never()).heldBy(filePlanComponent, true); - } - - @Test - public void isNotHeld() - { - // setup interactions - doReturn(FilePlanComponentKind.RECORD).when(mockedFilePlanService).getFilePlanComponentKind(record); - doReturn(Collections.EMPTY_LIST).when(mockedHoldService).heldBy(record, true); - - // evaluate - boolean result = evaluator.evaluate(record); - assertFalse(result); - - // verify interactions - verify(mockedHoldService, times(1)).heldBy(record, true); - } - - @Test - public void isHeldByAtLeastOne() - { - // setup interactions - doReturn(FilePlanComponentKind.RECORD).when(mockedFilePlanService).getFilePlanComponentKind(record); - doReturn(Collections.singletonList(generateNodeRef(TYPE_HOLD))).when(mockedHoldService).heldBy(record, true); - - // evaluate - boolean result = evaluator.evaluate(record); - assertTrue(result); - - // verify interactions - verify(mockedHoldService, times(1)).heldBy(record, true); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Collections; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; + +/** + * Freeze evaluator unit test. + * + * @author Roy Wetherall + */ +public class FrozenEvaluatorUnitTest extends BaseUnitTest +{ + @Mock(name="kinds") Set mockedKinds; + + @Spy @InjectMocks FrozenEvaluator evaluator; + + @Before + @Override + public void before() throws Exception + { + super.before(); + + // setup interactions + doReturn(false).when(mockedKinds).contains(FilePlanComponentKind.RECORD_CATEGORY); + doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD_FOLDER); + doReturn(true).when(mockedKinds).contains(FilePlanComponentKind.RECORD); + } + + @Test + public void isNotRecordOrRecordFolder() + { + // setup interactions + NodeRef nodeRef = generateNodeRef(TYPE_RECORD_CATEGORY); + doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(mockedFilePlanService).getFilePlanComponentKind(nodeRef); + + // evaluate + boolean result = evaluator.evaluate(filePlanComponent); + assertFalse(result); + + // verify interactions + verify(mockedHoldService, never()).heldBy(filePlanComponent, true); + } + + @Test + public void isNotHeld() + { + // setup interactions + doReturn(FilePlanComponentKind.RECORD).when(mockedFilePlanService).getFilePlanComponentKind(record); + doReturn(Collections.EMPTY_LIST).when(mockedHoldService).heldBy(record, true); + + // evaluate + boolean result = evaluator.evaluate(record); + assertFalse(result); + + // verify interactions + verify(mockedHoldService, times(1)).heldBy(record, true); + } + + @Test + public void isHeldByAtLeastOne() + { + // setup interactions + doReturn(FilePlanComponentKind.RECORD).when(mockedFilePlanService).getFilePlanComponentKind(record); + doReturn(Collections.singletonList(generateNodeRef(TYPE_HOLD))).when(mockedHoldService).heldBy(record, true); + + // evaluate + boolean result = evaluator.evaluate(record); + assertTrue(result); + + // verify interactions + verify(mockedHoldService, times(1)).heldBy(record, true); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluatorUnitTest.java index 2dfdd1b359..cf89c8af3a 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluatorUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/TransferEvaluatorUnitTest.java @@ -1,171 +1,171 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; - -/** - * Transfer evaluator unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class TransferEvaluatorUnitTest extends BaseUnitTest -{ - private NodeRef transfer; - - @Spy @InjectMocks TransferEvaluator transferEvaluator; - - @Override - public void before() throws Exception - { - super.before(); - - // setup node references - transfer = generateNodeRef(TYPE_TRANSFER); - } - - private List getParentAssocs(NodeRef provided) - { - List result = new ArrayList(1); - result.add(new ChildAssociationRef(ASSOC_TRANSFERRED, transfer, generateQName(), provided, false, 1)); - return result; - } - - @Test - public void isNotTransferringRecord() - { - // setup interactions - doReturn(Collections.emptyList()).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - - // evaluate - assertFalse(transferEvaluator.evaluate(record)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, never()).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, times(1)).getRecordFolders(record); - - } - - @Test - public void isTransferringWhenExpectingAccending() - { - // setup interactions - doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - transferEvaluator.setTransferAccessionIndicator(true); - - // evaluate - assertFalse(transferEvaluator.evaluate(record)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, never()).getRecordFolders(record); - } - - @Test - public void transferringRecord() - { - // setup interactions - doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - - // evaluate - assertTrue(transferEvaluator.evaluate(record)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, never()).getRecordFolders(record); - - } - - @Test - public void transferringRecordFolder() - { - // setup interactions - doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - doReturn(getParentAssocs(recordFolder)).when(mockedNodeService).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - - // evaluate - assertTrue(transferEvaluator.evaluate(recordFolder)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, never()).getRecordFolders(record); - } - - @Test - public void transferringRecordWithinRecordFolder() - { - // setup interactions - doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - doReturn(Collections.emptyList()).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - doReturn(getParentAssocs(recordFolder)).when(mockedNodeService).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - - // evaluate - assertTrue(transferEvaluator.evaluate(record)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, times(1)).getRecordFolders(record); - - } - - @Test - public void accendingRecord() - { - // setup interactions - doReturn(Boolean.TRUE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - transferEvaluator.setTransferAccessionIndicator(true); - - // evaluate - assertTrue(transferEvaluator.evaluate(record)); - - // verify interactions - verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); - verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); - verify(mockedRecordFolderService, never()).getRecordFolders(record); - - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; + +/** + * Transfer evaluator unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class TransferEvaluatorUnitTest extends BaseUnitTest +{ + private NodeRef transfer; + + @Spy @InjectMocks TransferEvaluator transferEvaluator; + + @Override + public void before() throws Exception + { + super.before(); + + // setup node references + transfer = generateNodeRef(TYPE_TRANSFER); + } + + private List getParentAssocs(NodeRef provided) + { + List result = new ArrayList(1); + result.add(new ChildAssociationRef(ASSOC_TRANSFERRED, transfer, generateQName(), provided, false, 1)); + return result; + } + + @Test + public void isNotTransferringRecord() + { + // setup interactions + doReturn(Collections.emptyList()).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + + // evaluate + assertFalse(transferEvaluator.evaluate(record)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, never()).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, times(1)).getRecordFolders(record); + + } + + @Test + public void isTransferringWhenExpectingAccending() + { + // setup interactions + doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + transferEvaluator.setTransferAccessionIndicator(true); + + // evaluate + assertFalse(transferEvaluator.evaluate(record)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, never()).getRecordFolders(record); + } + + @Test + public void transferringRecord() + { + // setup interactions + doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + + // evaluate + assertTrue(transferEvaluator.evaluate(record)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, never()).getRecordFolders(record); + + } + + @Test + public void transferringRecordFolder() + { + // setup interactions + doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + doReturn(getParentAssocs(recordFolder)).when(mockedNodeService).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + + // evaluate + assertTrue(transferEvaluator.evaluate(recordFolder)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, never()).getRecordFolders(record); + } + + @Test + public void transferringRecordWithinRecordFolder() + { + // setup interactions + doReturn(Boolean.FALSE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + doReturn(Collections.emptyList()).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + doReturn(getParentAssocs(recordFolder)).when(mockedNodeService).getParentAssocs(recordFolder, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + + // evaluate + assertTrue(transferEvaluator.evaluate(record)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, times(1)).getRecordFolders(record); + + } + + @Test + public void accendingRecord() + { + // setup interactions + doReturn(Boolean.TRUE).when(mockedNodeService).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + doReturn(getParentAssocs(record)).when(mockedNodeService).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + transferEvaluator.setTransferAccessionIndicator(true); + + // evaluate + assertTrue(transferEvaluator.evaluate(record)); + + // verify interactions + verify(mockedNodeService, times(1)).getParentAssocs(record, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + verify(mockedNodeService, times(1)).getProperty(transfer, RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR); + verify(mockedRecordFolderService, never()).getRecordFolders(record); + + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessorUnitTest.java index f306c5f53d..7427a0dd27 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessorUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/compatibility/DictionaryBootstrapPostProcessorUnitTest.java @@ -1,96 +1,96 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.model.compatibility; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; - - -/** - * Dictionary bootstrap post processor unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class DictionaryBootstrapPostProcessorUnitTest extends BaseUnitTest -{ - /** bean id's */ - private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap"; - private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap"; - - @Mock private ConfigurableListableBeanFactory mockedBeanFactory; - @Mock private BeanDefinition mockedBeanDefinition; - - @InjectMocks private DictionaryBootstrapPostProcessor postProcessor; - - /** - * given the bean factory does not contain the site service bootstrap bean then ensure that it is - * not added as a dependency - */ - @Test - public void noSiteServiceBootstrapBeanAvailable() - { - // === given ==== - doReturn(false).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP); - - // === when === - postProcessor.postProcessBeanFactory(mockedBeanFactory); - - // === then === - verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP); - verifyNoMoreInteractions(mockedBeanFactory); - verifyZeroInteractions(mockedBeanDefinition); - } - - /** - * given that the site service bootstrap bean is contained within the bean factory, ensure that - * it is added as a dependency - */ - @Test - public void siteServiceBootstrapBeanAvailable() - { - // === given ==== - doReturn(true).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP); - doReturn(true).when(mockedBeanFactory).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP); - doReturn(mockedBeanDefinition).when(mockedBeanFactory).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); - - // === when === - postProcessor.postProcessBeanFactory(mockedBeanFactory); - - // === then === - verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP); - verify(mockedBeanFactory, times(1)).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP); - - verify(mockedBeanFactory, times(1)).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); - verify(mockedBeanDefinition, times(1)).setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP}); - - verifyNoMoreInteractions(mockedBeanFactory, mockedBeanDefinition); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.model.compatibility; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; + + +/** + * Dictionary bootstrap post processor unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class DictionaryBootstrapPostProcessorUnitTest extends BaseUnitTest +{ + /** bean id's */ + private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap"; + private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap"; + + @Mock private ConfigurableListableBeanFactory mockedBeanFactory; + @Mock private BeanDefinition mockedBeanDefinition; + + @InjectMocks private DictionaryBootstrapPostProcessor postProcessor; + + /** + * given the bean factory does not contain the site service bootstrap bean then ensure that it is + * not added as a dependency + */ + @Test + public void noSiteServiceBootstrapBeanAvailable() + { + // === given ==== + doReturn(false).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP); + + // === when === + postProcessor.postProcessBeanFactory(mockedBeanFactory); + + // === then === + verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP); + verifyNoMoreInteractions(mockedBeanFactory); + verifyZeroInteractions(mockedBeanDefinition); + } + + /** + * given that the site service bootstrap bean is contained within the bean factory, ensure that + * it is added as a dependency + */ + @Test + public void siteServiceBootstrapBeanAvailable() + { + // === given ==== + doReturn(true).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP); + doReturn(true).when(mockedBeanFactory).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP); + doReturn(mockedBeanDefinition).when(mockedBeanFactory).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); + + // === when === + postProcessor.postProcessBeanFactory(mockedBeanFactory); + + // === then === + verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP); + verify(mockedBeanFactory, times(1)).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP); + + verify(mockedBeanFactory, times(1)).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP); + verify(mockedBeanDefinition, times(1)).setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP}); + + verifyNoMoreInteractions(mockedBeanFactory, mockedBeanDefinition); + + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspectUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspectUnitTest.java index 8069678d65..bb460d6adf 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspectUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/VersionRecordAspectUnitTest.java @@ -1,90 +1,90 @@ -/* - * Copyright (C) 2005-2015 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.model.rma.aspect; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.cmr.version.VersionService; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Version record aspect unit tests - * - * @author Roy Wetherall - * @since 2.3.1 - */ -public class VersionRecordAspectUnitTest extends BaseUnitTest -{ - /** service mocks */ - private @Mock VersionHistory mockedVersionHistory; - private @Mock Version mockedVersion; - private @Mock VersionService mockedVersionService; - private @Mock RelationshipService mockedRelationshipService; - - /** test object */ - private @InjectMocks VersionRecordAspect versionRecordAspect; - - /** - * given that there is no recorded version - * before delete of record - * then nothing happens - */ - @Test - public void beforeDeleteNoVersionNodeRef() - { - NodeRef nodeRef = generateNodeRef(); - - when(mockedRecordableVersionService.getRecordedVersion(nodeRef)) - .thenReturn(null); - - versionRecordAspect.beforeDeleteNode(nodeRef); - - verify(mockedNodeService, never()).getProperty(nodeRef, RecordableVersionModel.PROP_VERSION_LABEL); - verify(mockedRecordableVersionService, never()).destroyRecordedVersion(any(Version.class)); - } - - /** - * given that there is a recorded version - * before delete of record - * then the version is marked as destroyed - */ - @Test - public void beforeDeleteMarkVersionDestroyed() - { - NodeRef nodeRef = generateNodeRef(); - - when(mockedRecordableVersionService.getRecordedVersion(nodeRef)) - .thenReturn(mockedVersion); - - versionRecordAspect.beforeDeleteNode(nodeRef); - - verify(mockedRecordableVersionService).destroyRecordedVersion(mockedVersion); - } -} +/* + * Copyright (C) 2005-2015 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.model.rma.aspect; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionHistory; +import org.alfresco.service.cmr.version.VersionService; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +/** + * Version record aspect unit tests + * + * @author Roy Wetherall + * @since 2.3.1 + */ +public class VersionRecordAspectUnitTest extends BaseUnitTest +{ + /** service mocks */ + private @Mock VersionHistory mockedVersionHistory; + private @Mock Version mockedVersion; + private @Mock VersionService mockedVersionService; + private @Mock RelationshipService mockedRelationshipService; + + /** test object */ + private @InjectMocks VersionRecordAspect versionRecordAspect; + + /** + * given that there is no recorded version + * before delete of record + * then nothing happens + */ + @Test + public void beforeDeleteNoVersionNodeRef() + { + NodeRef nodeRef = generateNodeRef(); + + when(mockedRecordableVersionService.getRecordedVersion(nodeRef)) + .thenReturn(null); + + versionRecordAspect.beforeDeleteNode(nodeRef); + + verify(mockedNodeService, never()).getProperty(nodeRef, RecordableVersionModel.PROP_VERSION_LABEL); + verify(mockedRecordableVersionService, never()).destroyRecordedVersion(any(Version.class)); + } + + /** + * given that there is a recorded version + * before delete of record + * then the version is marked as destroyed + */ + @Test + public void beforeDeleteMarkVersionDestroyed() + { + NodeRef nodeRef = generateNodeRef(); + + when(mockedRecordableVersionService.getRecordedVersion(nodeRef)) + .thenReturn(mockedVersion); + + versionRecordAspect.beforeDeleteNode(nodeRef); + + verify(mockedRecordableVersionService).destroyRecordedVersion(mockedVersion); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/PatchV22Suite.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/PatchV22Suite.java index 186ae0876e..fc2d787c06 100755 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/PatchV22Suite.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/PatchV22Suite.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * patch.v22 unit test suite - * - * @author Roy Wetherall - * @since 2.3 - */ -@RunWith(Suite.class) -@SuiteClasses( -{ - RMv22RemoveInPlaceRolesFromAllPatchUnitTest.class, - RMv22CapabilityPatchUnitTest.class -}) -public class PatchV22Suite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * patch.v22 unit test suite + * + * @author Roy Wetherall + * @since 2.3 + */ +@RunWith(Suite.class) +@SuiteClasses( +{ + RMv22RemoveInPlaceRolesFromAllPatchUnitTest.class, + RMv22CapabilityPatchUnitTest.class +}) +public class PatchV22Suite +{ +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java index aa080f0977..1a86d8f947 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java @@ -1,124 +1,124 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; - -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.security.AuthorityType; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Unit test for RMv22CapabilityPatch - * - * @author Roy Wetherall - */ -public class RMv22CapabilityPatchUnitTest extends BaseUnitTest -{ - /** patch */ - private @InjectMocks RMv22CapabilityPatch patch; - - /** - * Given that I am upgrading an existing repository to v2.2 - * When I execute the patch - * Then the capabilities are updated - */ - @Test - public void executePatch() - { - when(mockedFilePlanService.getFilePlans()) - .thenReturn(Collections.singleton(filePlan)); - when(mockedAuthorityService.getName(eq(AuthorityType.GROUP), anyString())) - .thenReturn( - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_ADMIN, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - FilePlanRoleService.ROLE_SECURITY_OFFICER, - FilePlanRoleService.ROLE_RECORDS_MANAGER); - - // execute patch - patch.applyInternal(); - - // verify that the correct capabilities have been added - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_ADMIN, - "FileDestructionReport", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - "FileDestructionReport", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_ADMIN, - "CreateHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - "CreateHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_ADMIN, - "AddToHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - "AddToHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_ADMIN, - "RemoveFromHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - "RemoveFromHold", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_RECORDS_MANAGER, - "ManageAccessControls", - true); - verify(mockedPermissionService, times(1)).setPermission( - filePlan, - FilePlanRoleService.ROLE_SECURITY_OFFICER, - "ManageAccessControls", - true); - } - -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Collections; + +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.security.AuthorityType; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for RMv22CapabilityPatch + * + * @author Roy Wetherall + */ +public class RMv22CapabilityPatchUnitTest extends BaseUnitTest +{ + /** patch */ + private @InjectMocks RMv22CapabilityPatch patch; + + /** + * Given that I am upgrading an existing repository to v2.2 + * When I execute the patch + * Then the capabilities are updated + */ + @Test + public void executePatch() + { + when(mockedFilePlanService.getFilePlans()) + .thenReturn(Collections.singleton(filePlan)); + when(mockedAuthorityService.getName(eq(AuthorityType.GROUP), anyString())) + .thenReturn( + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + + // execute patch + patch.applyInternal(); + + // verify that the correct capabilities have been added + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "FileDestructionReport", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "FileDestructionReport", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "CreateHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "CreateHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "AddToHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "AddToHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "RemoveFromHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "RemoveFromHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "ManageAccessControls", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_SECURITY_OFFICER, + "ManageAccessControls", + true); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatchUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatchUnitTest.java index 2be813297a..b9a3fb9b66 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatchUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22RemoveInPlaceRolesFromAllPatchUnitTest.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v22; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.mock; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.role.Role; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Unit test for remove in-place roles from 'all roles' group patch unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RMv22RemoveInPlaceRolesFromAllPatchUnitTest extends BaseUnitTest -{ - /** test data */ - private static final String ALL_ROLES = "allroles"; - - /** patch */ - @InjectMocks private RMv22RemoveInPlaceRolesFromAllPatch patch; - - /** - * Given there are no file plans to update then the 'all roles' group should not - * be changed. - */ - @Test - public void noFilePlans() - { - // given - doReturn(Collections.EMPTY_SET).when(mockedFilePlanService).getFilePlans(); - - // when - patch.applyInternal(); - - // then - verifyZeroInteractions(mockedAuthorityService); - } - - /** - * Given that there is one file plan whose 'all roles' group does not contain the - * in-place roles the 'all roles' groups should not be changed. - */ - @Test - public void rolesDontNeedRemovingFromGroup() - { - // given - doReturn(Collections.singleton(filePlan)).when(mockedFilePlanService).getFilePlans(); - doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_READERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); - doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_WRITERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - doReturn(ALL_ROLES).when(mockedFilePlanRoleService).getAllRolesContainerGroup(filePlan); - doReturn(Collections.EMPTY_SET).when(mockedAuthorityService).getContainedAuthorities(null, ALL_ROLES, true); - - // when - patch.applyInternal(); - - // then - verify(mockedAuthorityService, times(1)).getContainedAuthorities(null, ALL_ROLES, true); - verifyNoMoreInteractions(mockedAuthorityService); - } - - /** - * Given that there is one file plan whose 'all roles' group contains the in-place - * roles then they should be revoved. - */ - @Test - public void removeRolesFromGroup() - { - // given - doReturn(Collections.singleton(filePlan)).when(mockedFilePlanService).getFilePlans(); - doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_READERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); - doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_WRITERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - doReturn(ALL_ROLES).when(mockedFilePlanRoleService).getAllRolesContainerGroup(filePlan); - Set contains = new HashSet(2); - contains.add(FilePlanRoleService.ROLE_EXTENDED_READERS); - contains.add(FilePlanRoleService.ROLE_EXTENDED_WRITERS); - doReturn(contains).when(mockedAuthorityService).getContainedAuthorities(null, ALL_ROLES, true); - - // when - patch.applyInternal(); - - // then - verify(mockedAuthorityService, times(1)).getContainedAuthorities(null, ALL_ROLES, true); - verify(mockedAuthorityService, times(1)).removeAuthority(ALL_ROLES, FilePlanRoleService.ROLE_EXTENDED_READERS); - verify(mockedAuthorityService, times(1)).removeAuthority(ALL_ROLES, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - verifyNoMoreInteractions(mockedAuthorityService); - } - - /** - * Helper method to create a mocked role. - */ - private Role getMockedRole(String name) - { - Role mockedRole = mock(Role.class); - doReturn(name).when(mockedRole).getRoleGroupName(); - return mockedRole; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch.v22; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.mock; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for remove in-place roles from 'all roles' group patch unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RMv22RemoveInPlaceRolesFromAllPatchUnitTest extends BaseUnitTest +{ + /** test data */ + private static final String ALL_ROLES = "allroles"; + + /** patch */ + @InjectMocks private RMv22RemoveInPlaceRolesFromAllPatch patch; + + /** + * Given there are no file plans to update then the 'all roles' group should not + * be changed. + */ + @Test + public void noFilePlans() + { + // given + doReturn(Collections.EMPTY_SET).when(mockedFilePlanService).getFilePlans(); + + // when + patch.applyInternal(); + + // then + verifyZeroInteractions(mockedAuthorityService); + } + + /** + * Given that there is one file plan whose 'all roles' group does not contain the + * in-place roles the 'all roles' groups should not be changed. + */ + @Test + public void rolesDontNeedRemovingFromGroup() + { + // given + doReturn(Collections.singleton(filePlan)).when(mockedFilePlanService).getFilePlans(); + doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_READERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); + doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_WRITERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); + doReturn(ALL_ROLES).when(mockedFilePlanRoleService).getAllRolesContainerGroup(filePlan); + doReturn(Collections.EMPTY_SET).when(mockedAuthorityService).getContainedAuthorities(null, ALL_ROLES, true); + + // when + patch.applyInternal(); + + // then + verify(mockedAuthorityService, times(1)).getContainedAuthorities(null, ALL_ROLES, true); + verifyNoMoreInteractions(mockedAuthorityService); + } + + /** + * Given that there is one file plan whose 'all roles' group contains the in-place + * roles then they should be revoved. + */ + @Test + public void removeRolesFromGroup() + { + // given + doReturn(Collections.singleton(filePlan)).when(mockedFilePlanService).getFilePlans(); + doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_READERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_READERS); + doReturn(getMockedRole(FilePlanRoleService.ROLE_EXTENDED_WRITERS)).when(mockedFilePlanRoleService).getRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); + doReturn(ALL_ROLES).when(mockedFilePlanRoleService).getAllRolesContainerGroup(filePlan); + Set contains = new HashSet(2); + contains.add(FilePlanRoleService.ROLE_EXTENDED_READERS); + contains.add(FilePlanRoleService.ROLE_EXTENDED_WRITERS); + doReturn(contains).when(mockedAuthorityService).getContainedAuthorities(null, ALL_ROLES, true); + + // when + patch.applyInternal(); + + // then + verify(mockedAuthorityService, times(1)).getContainedAuthorities(null, ALL_ROLES, true); + verify(mockedAuthorityService, times(1)).removeAuthority(ALL_ROLES, FilePlanRoleService.ROLE_EXTENDED_READERS); + verify(mockedAuthorityService, times(1)).removeAuthority(ALL_ROLES, FilePlanRoleService.ROLE_EXTENDED_WRITERS); + verifyNoMoreInteractions(mockedAuthorityService); + } + + /** + * Helper method to create a mocked role. + */ + private Role getMockedRole(String name) + { + Role mockedRole = mock(Role.class); + doReturn(name).when(mockedRole).getRoleGroupName(); + return mockedRole; + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrapUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrapUnitTest.java index 1b7fd3eed9..40b667148a 100755 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrapUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordMetadataBootstrapUnitTest.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import static org.mockito.Mockito.verify; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; - -/** - * Unit test for RecordMetadataBootstrap - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RecordMetadataBootstrapUnitTest extends BaseUnitTest -{ - @InjectMocks private RecordMetadataBootstrap bootstrap; - - /** - * Test init method to ensure set map will register correctly with record service. - */ - @Test - public void testInit() - { - // create and set map - Map map = new HashMap(2); - map.put("rma:test1", "rma:filePlan"); - map.put("rma:test2", "rma:filePlan"); - bootstrap.setRecordMetadataAspects(map); - - // call init - bootstrap.init(); - - // verify that the metedata aspects where registered - QName test1 = QName.createQName(RM_URI, "test1"); - QName test2 = QName.createQName(RM_URI, "test2"); - verify(mockedRecordService).registerRecordMetadataAspect(test1, TYPE_FILE_PLAN); - verify(mockedRecordService).registerRecordMetadataAspect(test2, TYPE_FILE_PLAN); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import static org.mockito.Mockito.verify; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.namespace.QName; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for RecordMetadataBootstrap + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RecordMetadataBootstrapUnitTest extends BaseUnitTest +{ + @InjectMocks private RecordMetadataBootstrap bootstrap; + + /** + * Test init method to ensure set map will register correctly with record service. + */ + @Test + public void testInit() + { + // create and set map + Map map = new HashMap(2); + map.put("rma:test1", "rma:filePlan"); + map.put("rma:test2", "rma:filePlan"); + bootstrap.setRecordMetadataAspects(map); + + // call init + bootstrap.init(); + + // verify that the metedata aspects where registered + QName test1 = QName.createQName(RM_URI, "test1"); + QName test2 = QName.createQName(RM_URI, "test2"); + verify(mockedRecordService).registerRecordMetadataAspect(test1, TYPE_FILE_PLAN); + verify(mockedRecordService).registerRecordMetadataAspect(test2, TYPE_FILE_PLAN); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java index 0f2ac51bfe..76b0f0cf11 100755 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java @@ -1,455 +1,455 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.record; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.policy.Behaviour; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.collections.CollectionUtils; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; - -/** - * Unit test for RecordServiceImpl - * - * @author Roy Wetherall - * @since 2.2 - */ -public class RecordServiceImplUnitTest extends BaseUnitTest -{ - private NodeRef nonStandardFilePlanComponent; - private NodeRef nonStandardFilePlan; - - private static QName TYPE_MY_FILE_PLAN = generateQName(); - private static QName ASPECT_FOR_FILE_PLAN = generateQName(); - - @Spy @InjectMocks private RecordServiceImpl recordService; - - @SuppressWarnings("unchecked") - @Before - @Override - public void before() throws Exception - { - super.before(); - - nonStandardFilePlanComponent = generateNodeRef(TYPE_RECORD_CATEGORY); - nonStandardFilePlan = generateNodeRef(TYPE_MY_FILE_PLAN); - - // set-up node service - when(mockedNodeService.getProperty(nonStandardFilePlanComponent, PROP_ROOT_NODEREF)).thenReturn(nonStandardFilePlan); - - // set-up dictionary service - when(mockedDictionaryService.getAllAspects()).thenReturn(CollectionUtils.EMPTY_COLLECTION); - - // mock up getting behaviours - when(recordService.getBehaviour(any(String.class))).thenReturn(mock(Behaviour.class)); - } - - @Test - public void testRegisterRecordMetadataAspect() - { - Map> map = recordService.getRecordMetadataAspectsMap(); - assertTrue(map.isEmpty()); - recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN); - map = recordService.getRecordMetadataAspectsMap(); - assertEquals(1, map.size()); - assertTrue(map.containsKey(ASPECT_FOR_FILE_PLAN)); - Set types = map.get(ASPECT_FOR_FILE_PLAN); - assertNotNull(types); - assertEquals(1, types.size()); - assertTrue(types.contains(TYPE_FILE_PLAN)); - } - - /** - * Given invalid types - * When linking - * Then exception thrown - */ - @Test - public void linkNonRecord() - { - NodeRef nonRecord = generateNodeRef(TYPE_CONTENT); - NodeRef recordFolder = generateRecordFolder(); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // link - recordService.link(nonRecord, recordFolder); - } - @Test - public void linkNonRecordFolder() - { - NodeRef record = generateRecord(); - NodeRef nonRecordFolder = generateNodeRef(TYPE_FOLDER); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // link - recordService.link(record, nonRecordFolder); - } - - /** - * Given that the record is already a child of the record folder - * When I try to link the record to the same record folder - * Then an exception is thrown - */ - @Test - public void linkRecordToRecordFolderFailsIfAlreadyAChild() - { - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - - // given that the record is already a child of the record folder - makeChildrenOf(recordFolder, record); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // link - recordService.link(record, recordFolder); - } - - /** - * Given a record that is not a child of a record folder - * When I link the record to the record folder - * Then the record is now linked to the record folder - */ - @Test - public void linkRecordToRecordFolder() - { - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - - // given that the record is already a child of the record folder - makeChildrenOf(generateRecordFolder(), record); - - // set the name of the record - String name = generateText(); - doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); - - // link - recordService.link(record, recordFolder); - - // verify link was created - verify(mockedNodeService, times(1)).addChild( - recordFolder, - record, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); - } - - /** - * Given that the source record has no disposition schedule - * When I link - * Then it is successful - */ - @Test public void linkNoSourceDisposition() - { - // create record and record folder - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - makeChildrenOf(generateRecordFolder(), record); - - // set the name of the record - String name = generateText(); - doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); - - // set dispositions - when(mockedDispositionService.getDispositionSchedule(record)) - .thenReturn(null); - - // link - recordService.link(record, recordFolder); - - // verify link was created - verify(mockedNodeService, times(1)).addChild( - recordFolder, - record, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); - } - - /** - * Given that the target record folder has no disposition schedule - * When I link - * Then it is successful - */ - @Test public void linkNoTargetDisposition() - { - // create record and record folder - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - makeChildrenOf(generateRecordFolder(), record); - - // set the name of the record - String name = generateText(); - doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); - - // set dispositions - when(mockedDispositionService.getDispositionSchedule(record)) - .thenReturn(mock(DispositionSchedule.class)); - when(mockedDispositionService.getDispositionSchedule(record)) - .thenReturn(null); - - // link - recordService.link(record, recordFolder); - - // verify link was created - verify(mockedNodeService, times(1)).addChild( - recordFolder, - record, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); - } - - /** - * Given that the source record and target record folder have incompatible disposition schedules - * When I link - * Then I expect a failure - */ - @Test public void linkIncompatibleDispositions() - { - // create record and record folder - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - makeChildrenOf(generateRecordFolder(), record); - - // set the name of the record - String name = generateText(); - doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); - - // set dispositions - DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class); - when(recordDispositionSchedule.isRecordLevelDisposition()) - .thenReturn(true); - when(mockedDispositionService.getDispositionSchedule(record)) - .thenReturn(recordDispositionSchedule); - - DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class); - when(recordFolderDispositionSchedule.isRecordLevelDisposition()) - .thenReturn(false); - when(mockedDispositionService.getDispositionSchedule(recordFolder)) - .thenReturn(recordFolderDispositionSchedule); - - // expect exception - exception.expect(RecordLinkRuntimeException.class); - exception.expectMessage("incompatible disposition schedule"); - - // link - recordService.link(record, recordFolder); - } - - /** - * Given that the source record and target record folder have compatible disposition schedules - * When I link - * Then it is successful - */ - @Test public void linkCompatibleDispositions() - { - // create record and record folder - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - makeChildrenOf(generateRecordFolder(), record); - - // set the name of the record - String name = generateText(); - doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); - - // set dispositions - DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class); - when(recordDispositionSchedule.isRecordLevelDisposition()) - .thenReturn(true); - when(mockedDispositionService.getDispositionSchedule(record)) - .thenReturn(recordDispositionSchedule); - - DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class); - when(recordFolderDispositionSchedule.isRecordLevelDisposition()) - .thenReturn(true); - when(mockedDispositionService.getDispositionSchedule(recordFolder)) - .thenReturn(recordFolderDispositionSchedule); - - // link - recordService.link(record, recordFolder); - - // verify link was created - verify(mockedNodeService, times(1)).addChild( - recordFolder, - record, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); - } - - /** - * Given invalid types - * When unlinking - * Then exception thrown - */ - @Test - public void unlinkNonRecord() - { - NodeRef nonRecord = generateNodeRef(TYPE_CONTENT); - NodeRef recordFolder = generateRecordFolder(); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // unlink - recordService.unlink(nonRecord, recordFolder); - } - @Test - public void unlinkNonRecordFolder() - { - NodeRef record = generateRecord(); - NodeRef nonRecordFolder = generateNodeRef(TYPE_FOLDER); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // unlink - recordService.unlink(record, nonRecordFolder); - } - - /** - * Given a record folder is a records primary parent - * When I try and unlink the record from that record folder - * Then an exception is thrown - */ - @Test - public void unlinkRecordFromPrimaryRecordFolder() - { - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - - // given that the record is already a child of the record folder - makePrimaryParentOf(record, recordFolder); - - // set expected exception - exception.expect(RecordLinkRuntimeException.class); - - // link - recordService.unlink(record, recordFolder); - } - - /** - * Given a record that is linked to a record - * And that the record is not the primary parent of the record - * When I unlink the record to the record folder - * Then the record is no longer linked to the record folder - */ - @Test - public void unlinkRecordFromRecordFolder() - { - NodeRef record = generateRecord(); - NodeRef recordFolder = generateRecordFolder(); - - // the records primary parent is another record folder - makePrimaryParentOf(record, generateRecordFolder()); - - // unlink - recordService.unlink(record, recordFolder); - - // verify link was created - verify(mockedNodeService, times(1)).removeChild(recordFolder, record); - } - - /** - * Given that a new record is being created - * When the behaviour is triggered - * Then the record is stored for later reference in the transaction - */ - @SuppressWarnings("unchecked") - @Test - public void onCreateChildAssociationNewRecord() - { - // standard content node - NodeRef nodeRef = generateCmContent("test.txt"); - ChildAssociationRef assoc = generateChildAssociationRef(generateNodeRef(), nodeRef); - - doNothing().when(recordService).file(nodeRef); - - // doesn't have no content aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) - .thenReturn(false); - - Set values = mock(HashSet.class); - when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) - .thenReturn(values); - - // trigger behaviour - recordService.onCreateChildAssociation(assoc, true); - - // verify - verify(values, times(1)).add(nodeRef); - } - - /** - * Given that an existing record is linked - * When the behaviour is triggered - * Then the record is not stored for later reference in the transaction - */ - @SuppressWarnings("unchecked") - @Test - public void onCreateChildAssociationExistingRecord() - { - // standard content node - NodeRef nodeRef = generateCmContent("test.txt"); - ChildAssociationRef assoc = generateChildAssociationRef(generateNodeRef(), nodeRef); - - doNothing().when(recordService).file(nodeRef); - - // doesn't have no content aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) - .thenReturn(false); - - Set values = mock(HashSet.class); - when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) - .thenReturn(values); - - // trigger behaviour - recordService.onCreateChildAssociation(assoc, false); - - // verify - verify(values, never()).add(nodeRef); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.record; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.policy.Behaviour; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.apache.commons.collections.CollectionUtils; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; + +/** + * Unit test for RecordServiceImpl + * + * @author Roy Wetherall + * @since 2.2 + */ +public class RecordServiceImplUnitTest extends BaseUnitTest +{ + private NodeRef nonStandardFilePlanComponent; + private NodeRef nonStandardFilePlan; + + private static QName TYPE_MY_FILE_PLAN = generateQName(); + private static QName ASPECT_FOR_FILE_PLAN = generateQName(); + + @Spy @InjectMocks private RecordServiceImpl recordService; + + @SuppressWarnings("unchecked") + @Before + @Override + public void before() throws Exception + { + super.before(); + + nonStandardFilePlanComponent = generateNodeRef(TYPE_RECORD_CATEGORY); + nonStandardFilePlan = generateNodeRef(TYPE_MY_FILE_PLAN); + + // set-up node service + when(mockedNodeService.getProperty(nonStandardFilePlanComponent, PROP_ROOT_NODEREF)).thenReturn(nonStandardFilePlan); + + // set-up dictionary service + when(mockedDictionaryService.getAllAspects()).thenReturn(CollectionUtils.EMPTY_COLLECTION); + + // mock up getting behaviours + when(recordService.getBehaviour(any(String.class))).thenReturn(mock(Behaviour.class)); + } + + @Test + public void testRegisterRecordMetadataAspect() + { + Map> map = recordService.getRecordMetadataAspectsMap(); + assertTrue(map.isEmpty()); + recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN); + map = recordService.getRecordMetadataAspectsMap(); + assertEquals(1, map.size()); + assertTrue(map.containsKey(ASPECT_FOR_FILE_PLAN)); + Set types = map.get(ASPECT_FOR_FILE_PLAN); + assertNotNull(types); + assertEquals(1, types.size()); + assertTrue(types.contains(TYPE_FILE_PLAN)); + } + + /** + * Given invalid types + * When linking + * Then exception thrown + */ + @Test + public void linkNonRecord() + { + NodeRef nonRecord = generateNodeRef(TYPE_CONTENT); + NodeRef recordFolder = generateRecordFolder(); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // link + recordService.link(nonRecord, recordFolder); + } + @Test + public void linkNonRecordFolder() + { + NodeRef record = generateRecord(); + NodeRef nonRecordFolder = generateNodeRef(TYPE_FOLDER); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // link + recordService.link(record, nonRecordFolder); + } + + /** + * Given that the record is already a child of the record folder + * When I try to link the record to the same record folder + * Then an exception is thrown + */ + @Test + public void linkRecordToRecordFolderFailsIfAlreadyAChild() + { + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + + // given that the record is already a child of the record folder + makeChildrenOf(recordFolder, record); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // link + recordService.link(record, recordFolder); + } + + /** + * Given a record that is not a child of a record folder + * When I link the record to the record folder + * Then the record is now linked to the record folder + */ + @Test + public void linkRecordToRecordFolder() + { + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + + // given that the record is already a child of the record folder + makeChildrenOf(generateRecordFolder(), record); + + // set the name of the record + String name = generateText(); + doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); + + // link + recordService.link(record, recordFolder); + + // verify link was created + verify(mockedNodeService, times(1)).addChild( + recordFolder, + record, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); + } + + /** + * Given that the source record has no disposition schedule + * When I link + * Then it is successful + */ + @Test public void linkNoSourceDisposition() + { + // create record and record folder + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + makeChildrenOf(generateRecordFolder(), record); + + // set the name of the record + String name = generateText(); + doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); + + // set dispositions + when(mockedDispositionService.getDispositionSchedule(record)) + .thenReturn(null); + + // link + recordService.link(record, recordFolder); + + // verify link was created + verify(mockedNodeService, times(1)).addChild( + recordFolder, + record, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); + } + + /** + * Given that the target record folder has no disposition schedule + * When I link + * Then it is successful + */ + @Test public void linkNoTargetDisposition() + { + // create record and record folder + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + makeChildrenOf(generateRecordFolder(), record); + + // set the name of the record + String name = generateText(); + doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); + + // set dispositions + when(mockedDispositionService.getDispositionSchedule(record)) + .thenReturn(mock(DispositionSchedule.class)); + when(mockedDispositionService.getDispositionSchedule(record)) + .thenReturn(null); + + // link + recordService.link(record, recordFolder); + + // verify link was created + verify(mockedNodeService, times(1)).addChild( + recordFolder, + record, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); + } + + /** + * Given that the source record and target record folder have incompatible disposition schedules + * When I link + * Then I expect a failure + */ + @Test public void linkIncompatibleDispositions() + { + // create record and record folder + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + makeChildrenOf(generateRecordFolder(), record); + + // set the name of the record + String name = generateText(); + doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); + + // set dispositions + DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class); + when(recordDispositionSchedule.isRecordLevelDisposition()) + .thenReturn(true); + when(mockedDispositionService.getDispositionSchedule(record)) + .thenReturn(recordDispositionSchedule); + + DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class); + when(recordFolderDispositionSchedule.isRecordLevelDisposition()) + .thenReturn(false); + when(mockedDispositionService.getDispositionSchedule(recordFolder)) + .thenReturn(recordFolderDispositionSchedule); + + // expect exception + exception.expect(RecordLinkRuntimeException.class); + exception.expectMessage("incompatible disposition schedule"); + + // link + recordService.link(record, recordFolder); + } + + /** + * Given that the source record and target record folder have compatible disposition schedules + * When I link + * Then it is successful + */ + @Test public void linkCompatibleDispositions() + { + // create record and record folder + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + makeChildrenOf(generateRecordFolder(), record); + + // set the name of the record + String name = generateText(); + doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME); + + // set dispositions + DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class); + when(recordDispositionSchedule.isRecordLevelDisposition()) + .thenReturn(true); + when(mockedDispositionService.getDispositionSchedule(record)) + .thenReturn(recordDispositionSchedule); + + DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class); + when(recordFolderDispositionSchedule.isRecordLevelDisposition()) + .thenReturn(true); + when(mockedDispositionService.getDispositionSchedule(recordFolder)) + .thenReturn(recordFolderDispositionSchedule); + + // link + recordService.link(record, recordFolder); + + // verify link was created + verify(mockedNodeService, times(1)).addChild( + recordFolder, + record, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name)); + } + + /** + * Given invalid types + * When unlinking + * Then exception thrown + */ + @Test + public void unlinkNonRecord() + { + NodeRef nonRecord = generateNodeRef(TYPE_CONTENT); + NodeRef recordFolder = generateRecordFolder(); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // unlink + recordService.unlink(nonRecord, recordFolder); + } + @Test + public void unlinkNonRecordFolder() + { + NodeRef record = generateRecord(); + NodeRef nonRecordFolder = generateNodeRef(TYPE_FOLDER); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // unlink + recordService.unlink(record, nonRecordFolder); + } + + /** + * Given a record folder is a records primary parent + * When I try and unlink the record from that record folder + * Then an exception is thrown + */ + @Test + public void unlinkRecordFromPrimaryRecordFolder() + { + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + + // given that the record is already a child of the record folder + makePrimaryParentOf(record, recordFolder); + + // set expected exception + exception.expect(RecordLinkRuntimeException.class); + + // link + recordService.unlink(record, recordFolder); + } + + /** + * Given a record that is linked to a record + * And that the record is not the primary parent of the record + * When I unlink the record to the record folder + * Then the record is no longer linked to the record folder + */ + @Test + public void unlinkRecordFromRecordFolder() + { + NodeRef record = generateRecord(); + NodeRef recordFolder = generateRecordFolder(); + + // the records primary parent is another record folder + makePrimaryParentOf(record, generateRecordFolder()); + + // unlink + recordService.unlink(record, recordFolder); + + // verify link was created + verify(mockedNodeService, times(1)).removeChild(recordFolder, record); + } + + /** + * Given that a new record is being created + * When the behaviour is triggered + * Then the record is stored for later reference in the transaction + */ + @SuppressWarnings("unchecked") + @Test + public void onCreateChildAssociationNewRecord() + { + // standard content node + NodeRef nodeRef = generateCmContent("test.txt"); + ChildAssociationRef assoc = generateChildAssociationRef(generateNodeRef(), nodeRef); + + doNothing().when(recordService).file(nodeRef); + + // doesn't have no content aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) + .thenReturn(false); + + Set values = mock(HashSet.class); + when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) + .thenReturn(values); + + // trigger behaviour + recordService.onCreateChildAssociation(assoc, true); + + // verify + verify(values, times(1)).add(nodeRef); + } + + /** + * Given that an existing record is linked + * When the behaviour is triggered + * Then the record is not stored for later reference in the transaction + */ + @SuppressWarnings("unchecked") + @Test + public void onCreateChildAssociationExistingRecord() + { + // standard content node + NodeRef nodeRef = generateCmContent("test.txt"); + ChildAssociationRef assoc = generateChildAssociationRef(generateNodeRef(), nodeRef); + + doNothing().when(recordService).file(nodeRef); + + // doesn't have no content aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)) + .thenReturn(false); + + Set values = mock(HashSet.class); + when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)) + .thenReturn(values); + + // trigger behaviour + recordService.onCreateChildAssociation(assoc, false); + + // verify + verify(values, never()).add(nodeRef); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/BaseRecordedVersionConfigTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/BaseRecordedVersionConfigTest.java index 16e4ab880a..50c77f9647 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/BaseRecordedVersionConfigTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/BaseRecordedVersionConfigTest.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; - -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Base test class for the recorded version config tests - * - * @author Tuna Aksoy - * @since 2.3 - */ -public abstract class BaseRecordedVersionConfigTest extends BaseWebScriptUnitTest implements RecordableVersionModel -{ - /** Recorded version config web script root folder */ - protected static final String RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT = "alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/"; - - /** Node ref for test document */ - protected NodeRef testdoc; - - /** Setup web script parameters */ - protected Map buildParameters() - { - testdoc = generateCmContent("testdoc.txt"); - - return buildParameters - ( - "store_type", testdoc.getStoreRef().getProtocol(), - "store_id", testdoc.getStoreRef().getIdentifier(), - "id", testdoc.getId() - ); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; + +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Base test class for the recorded version config tests + * + * @author Tuna Aksoy + * @since 2.3 + */ +public abstract class BaseRecordedVersionConfigTest extends BaseWebScriptUnitTest implements RecordableVersionModel +{ + /** Recorded version config web script root folder */ + protected static final String RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT = "alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/"; + + /** Node ref for test document */ + protected NodeRef testdoc; + + /** Setup web script parameters */ + protected Map buildParameters() + { + testdoc = generateCmContent("testdoc.txt"); + + return buildParameters + ( + "store_type", testdoc.getStoreRef().getProtocol(), + "store_id", testdoc.getStoreRef().getIdentifier(), + "id", testdoc.getId() + ); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigGetTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigGetTest.java index 60a404e8e1..802b6d041c 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigGetTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigGetTest.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; - -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.MAJOR_ONLY; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigGet; -import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Recorded Version Config REST API GET implementation unit test. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordedVersionConfigGetTest extends BaseRecordedVersionConfigTest -{ - /** RecordedVersionConfigGet webscript instance */ - protected @InjectMocks RecordedVersionConfigGet webScript; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recorded.version.config.BaseRecordedVersionConfigTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.recorded.version.config.BaseRecordedVersionConfigTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT + "recorded-version-config.get.json.ftl"; - } - - @Test - public void getRecordedVersionConfig() throws Exception - { - // Build parameters - Map parameters = buildParameters(); - - // Test document should not have any recordable version policy set - doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); - - // Setup versions - List versions = Arrays.asList( - new Version(NONE.toString(), true), - new Version(MAJOR_ONLY.toString(), false), - new Version(ALL.toString(), false)); - - // Stub getVersions - doReturn(versions).when(mockedRecordableVersionConfigService).getVersions(testdoc); - - // Execute web script - JSONObject json = executeJSONWebScript(parameters); - - // Do checks - assertNotNull(json); - - assertTrue(json.has("data")); - JSONObject data = json.getJSONObject("data"); - assertNotNull(data); - - assertTrue(data.has("recordableVersions")); - JSONArray recordableVersions = data.getJSONArray("recordableVersions"); - assertNotNull(recordableVersions); - assertEquals(recordableVersions.length(), 3); - - List policies = new ArrayList(); - boolean isSelected = false; - int selectedOnce = 0; - for (int i = 0; i < recordableVersions.length(); i++) - { - JSONObject jsonObject = recordableVersions.getJSONObject(i); - String policy = jsonObject.getString("policy"); - policies.add(RecordableVersionPolicy.valueOf(policy)); - boolean selected = Boolean.valueOf(jsonObject.getString("selected")).booleanValue(); - if (selected) - { - isSelected = true; - selectedOnce++; - } - } - assertEquals(policies, Arrays.asList(RecordableVersionPolicy.values())); - assertTrue(isSelected); - assertEquals(selectedOnce, 1); - - // Test document should still not have any recordable version policy set - doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; + +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.MAJOR_ONLY; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.doReturn; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigGet; +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.Version; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.springframework.extensions.webscripts.DeclarativeWebScript; + +/** + * Recorded Version Config REST API GET implementation unit test. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordedVersionConfigGetTest extends BaseRecordedVersionConfigTest +{ + /** RecordedVersionConfigGet webscript instance */ + protected @InjectMocks RecordedVersionConfigGet webScript; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recorded.version.config.BaseRecordedVersionConfigTest#getWebScript() + */ + @Override + protected DeclarativeWebScript getWebScript() + { + return webScript; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recorded.version.config.BaseRecordedVersionConfigTest#getWebScriptTemplate() + */ + @Override + protected String getWebScriptTemplate() + { + return RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT + "recorded-version-config.get.json.ftl"; + } + + @Test + public void getRecordedVersionConfig() throws Exception + { + // Build parameters + Map parameters = buildParameters(); + + // Test document should not have any recordable version policy set + doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); + + // Setup versions + List versions = Arrays.asList( + new Version(NONE.toString(), true), + new Version(MAJOR_ONLY.toString(), false), + new Version(ALL.toString(), false)); + + // Stub getVersions + doReturn(versions).when(mockedRecordableVersionConfigService).getVersions(testdoc); + + // Execute web script + JSONObject json = executeJSONWebScript(parameters); + + // Do checks + assertNotNull(json); + + assertTrue(json.has("data")); + JSONObject data = json.getJSONObject("data"); + assertNotNull(data); + + assertTrue(data.has("recordableVersions")); + JSONArray recordableVersions = data.getJSONArray("recordableVersions"); + assertNotNull(recordableVersions); + assertEquals(recordableVersions.length(), 3); + + List policies = new ArrayList(); + boolean isSelected = false; + int selectedOnce = 0; + for (int i = 0; i < recordableVersions.length(); i++) + { + JSONObject jsonObject = recordableVersions.getJSONObject(i); + String policy = jsonObject.getString("policy"); + policies.add(RecordableVersionPolicy.valueOf(policy)); + boolean selected = Boolean.valueOf(jsonObject.getString("selected")).booleanValue(); + if (selected) + { + isSelected = true; + selectedOnce++; + } + } + assertEquals(policies, Arrays.asList(RecordableVersionPolicy.values())); + assertTrue(isSelected); + assertEquals(selectedOnce, 1); + + // Test document should still not have any recordable version policy set + doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigPostTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigPostTest.java index 969666ab75..64b2631d75 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigPostTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/recorded/version/config/RecordedVersionConfigPostTest.java @@ -1,104 +1,104 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; - -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost.RECORDED_VERSION; -import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; -import static org.testng.Assert.assertEquals; - -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Recorded Version Config REST API POST implementation unit test. - * - * @author Tuna Aksoy - * @since 2.3 - */ -public class RecordedVersionConfigPostTest extends BaseRecordedVersionConfigTest -{ - /** RecordedVersionConfigPost webscript instance */ - protected @InjectMocks RecordedVersionConfigPost webScript; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT + "recorded-version-config.post.json.ftl"; - } - - @Test - public void setRecordedVersionConfig() throws Exception - { - // Build the content - String content = buildContent(ALL); - - // Build parameters - Map parameters = buildParameters(); - - // Test document should not have any recordable version policy set - doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); - - // execute web script - JSONObject json = executeJSONWebScript(parameters, content); - - // Do checks - assertNotNull(json); - assertEquals(json.length(), 0); - - // Test document must have recordable version policy "ALL" set - doReturn(ALL).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); - } - - /** - * Helper method to build the content for the POST request - * @param policy The recordable version policy - * - * @return Content for the build request - */ - private String buildContent(RecordableVersionPolicy policy) - { - StringBuilder sb = new StringBuilder(); - sb.append("{\""); - sb.append(RECORDED_VERSION); - sb.append("\":\""); - sb.append(policy.toString()); - sb.append("\"}"); - return sb.toString(); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.recorded.version.config; + +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost.RECORDED_VERSION; +import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.ALL; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.doReturn; +import static org.testng.Assert.assertEquals; + +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RecordedVersionConfigPost; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy; +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.springframework.extensions.webscripts.DeclarativeWebScript; + +/** + * Recorded Version Config REST API POST implementation unit test. + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RecordedVersionConfigPostTest extends BaseRecordedVersionConfigTest +{ + /** RecordedVersionConfigPost webscript instance */ + protected @InjectMocks RecordedVersionConfigPost webScript; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() + */ + @Override + protected DeclarativeWebScript getWebScript() + { + return webScript; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() + */ + @Override + protected String getWebScriptTemplate() + { + return RECORDED_VERSION_CONFIG_WEBSCRIPT_ROOT + "recorded-version-config.post.json.ftl"; + } + + @Test + public void setRecordedVersionConfig() throws Exception + { + // Build the content + String content = buildContent(ALL); + + // Build parameters + Map parameters = buildParameters(); + + // Test document should not have any recordable version policy set + doReturn(null).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); + + // execute web script + JSONObject json = executeJSONWebScript(parameters, content); + + // Do checks + assertNotNull(json); + assertEquals(json.length(), 0); + + // Test document must have recordable version policy "ALL" set + doReturn(ALL).when(mockedNodeService).getProperty(testdoc, PROP_RECORDABLE_VERSION_POLICY); + } + + /** + * Helper method to build the content for the POST request + * @param policy The recordable version policy + * + * @return Content for the build request + */ + private String buildContent(RecordableVersionPolicy policy) + { + StringBuilder sb = new StringBuilder(); + sb.append("{\""); + sb.append(RECORDED_VERSION); + sb.append("\":\""); + sb.append(policy.toString()); + sb.append("\"}"); + return sb.toString(); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptUnitTest.java index 16196af815..36b551d7fb 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptUnitTest.java @@ -1,51 +1,51 @@ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Base hold web script unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class BaseHoldWebScriptUnitTest extends BaseWebScriptUnitTest -{ - /** test holds */ - protected NodeRef hold1NodeRef; - protected NodeRef hold2NodeRef; - protected List holds; - protected List records; - protected List recordFolders; - protected List filePlanComponents; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Override - public void before() throws Exception - { - super.before(); - - // generate test holds - hold1NodeRef = generateHoldNodeRef("hold1"); - hold2NodeRef = generateHoldNodeRef("hold2"); - - // list of holds - holds = new ArrayList(2); - Collections.addAll(holds, hold1NodeRef, hold2NodeRef); - - // list of records - records = Collections.singletonList(record); - - // list of record folders - recordFolders = Collections.singletonList(recordFolder); - - // list of file plan components - filePlanComponents = Collections.singletonList(filePlanComponent); - } -} +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Base hold web script unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class BaseHoldWebScriptUnitTest extends BaseWebScriptUnitTest +{ + /** test holds */ + protected NodeRef hold1NodeRef; + protected NodeRef hold2NodeRef; + protected List holds; + protected List records; + protected List recordFolders; + protected List filePlanComponents; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Override + public void before() throws Exception + { + super.before(); + + // generate test holds + hold1NodeRef = generateHoldNodeRef("hold1"); + hold2NodeRef = generateHoldNodeRef("hold2"); + + // list of holds + holds = new ArrayList(2); + Collections.addAll(holds, hold1NodeRef, hold2NodeRef); + + // list of records + records = Collections.singletonList(record); + + // list of record folders + recordFolders = Collections.singletonList(recordFolder); + + // list of file plan components + filePlanComponents = Collections.singletonList(filePlanComponent); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptWithContentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptWithContentUnitTest.java index e951c2069f..8ca8a4c7aa 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptWithContentUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHoldWebScriptWithContentUnitTest.java @@ -1,222 +1,222 @@ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExceptionMatcher.badRequest; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.junit.Test; -import org.springframework.extensions.webscripts.WebScriptException; - -/** - * Base hold web script with content unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class BaseHoldWebScriptWithContentUnitTest extends BaseHoldWebScriptUnitTest -{ - /** - * Helper method to build JSON content to send to hold webscripts. - */ - protected String buildContent(List nodeRefs, List holds) - { - StringBuilder builder = new StringBuilder(255); - builder.append("{"); - - if (nodeRefs != null) - { - builder.append("'nodeRefs':["); - - boolean bFirst = true; - for (NodeRef nodeRef : nodeRefs) - { - if (!bFirst) - { - builder.append(","); - } - else - { - bFirst = false; - } - - builder.append("'" + nodeRef.toString() + "'"); - } - - builder.append("]"); - } - - if (nodeRefs != null && holds != null) - { - builder.append(","); - } - - if (holds != null) - { - builder.append("'holds':["); - - boolean bFirst = true; - for (NodeRef hold : holds) - { - if (!bFirst) - { - builder.append(","); - } - else - { - bFirst = false; - } - - builder.append("'" + hold.toString() + "'"); - } - - builder.append("]"); - } - - builder.append("}"); - - return builder.toString(); - } - - /** - * Test for expected exception when invalid JSON sent - */ - @SuppressWarnings("unchecked") - @Test - public void sendInvalidJSON() throws Exception - { - // invalid JSON - String content = "invalid JSON"; - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected exception when one of the holds doesn't exist. - */ - @SuppressWarnings("unchecked") - @Test - public void holdDoesNotExist() throws Exception - { - // setup interactions - when(mockedNodeService.exists(eq(hold1NodeRef))).thenReturn(false); - - // build content - String content = buildContent(records, holds); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected excpetion when the item being added to the hold - * does not exist. - */ - @SuppressWarnings("unchecked") - @Test - public void nodeRefDoesNotExist() throws Exception - { - // setup interactions - when(mockedNodeService.exists(eq(record))).thenReturn(false); - - // build content - String content = buildContent(records, holds); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected exception when hold information is missing from - * sent JSON. - */ - @SuppressWarnings("unchecked") - @Test - public void holdMissingFromContent() throws Exception - { - // build content - String content = buildContent(records, null); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected exception when noderef information is missing - * from send JSON. - */ - @SuppressWarnings("unchecked") - @Test - public void nodeRefMissingFromContent() throws Exception - { - // build content - String content = buildContent(null, holds); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected exception when adding an item to something - * that isn't a hold. - */ - @SuppressWarnings("unchecked") - @Test - public void holdIsNotAHold() throws Exception - { - // build json content to send to server - List notAHold = Collections.singletonList(recordFolder); - String content = buildContent(records, notAHold); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } - - /** - * Test for expected exception when adding an item to a hold - * that isn't a record or record folder. - */ - @SuppressWarnings("unchecked") - @Test - public void nodeRefIsNotARecordOrRecordFolder() throws Exception - { - // build json content to send to server - List notAHold = Collections.singletonList(recordFolder); - String content = buildContent(filePlanComponents, notAHold); - - // expected exception - exception.expect(WebScriptException.class); - exception.expect(badRequest()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP, content); - } -} +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExceptionMatcher.badRequest; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.junit.Test; +import org.springframework.extensions.webscripts.WebScriptException; + +/** + * Base hold web script with content unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class BaseHoldWebScriptWithContentUnitTest extends BaseHoldWebScriptUnitTest +{ + /** + * Helper method to build JSON content to send to hold webscripts. + */ + protected String buildContent(List nodeRefs, List holds) + { + StringBuilder builder = new StringBuilder(255); + builder.append("{"); + + if (nodeRefs != null) + { + builder.append("'nodeRefs':["); + + boolean bFirst = true; + for (NodeRef nodeRef : nodeRefs) + { + if (!bFirst) + { + builder.append(","); + } + else + { + bFirst = false; + } + + builder.append("'" + nodeRef.toString() + "'"); + } + + builder.append("]"); + } + + if (nodeRefs != null && holds != null) + { + builder.append(","); + } + + if (holds != null) + { + builder.append("'holds':["); + + boolean bFirst = true; + for (NodeRef hold : holds) + { + if (!bFirst) + { + builder.append(","); + } + else + { + bFirst = false; + } + + builder.append("'" + hold.toString() + "'"); + } + + builder.append("]"); + } + + builder.append("}"); + + return builder.toString(); + } + + /** + * Test for expected exception when invalid JSON sent + */ + @SuppressWarnings("unchecked") + @Test + public void sendInvalidJSON() throws Exception + { + // invalid JSON + String content = "invalid JSON"; + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected exception when one of the holds doesn't exist. + */ + @SuppressWarnings("unchecked") + @Test + public void holdDoesNotExist() throws Exception + { + // setup interactions + when(mockedNodeService.exists(eq(hold1NodeRef))).thenReturn(false); + + // build content + String content = buildContent(records, holds); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected excpetion when the item being added to the hold + * does not exist. + */ + @SuppressWarnings("unchecked") + @Test + public void nodeRefDoesNotExist() throws Exception + { + // setup interactions + when(mockedNodeService.exists(eq(record))).thenReturn(false); + + // build content + String content = buildContent(records, holds); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected exception when hold information is missing from + * sent JSON. + */ + @SuppressWarnings("unchecked") + @Test + public void holdMissingFromContent() throws Exception + { + // build content + String content = buildContent(records, null); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected exception when noderef information is missing + * from send JSON. + */ + @SuppressWarnings("unchecked") + @Test + public void nodeRefMissingFromContent() throws Exception + { + // build content + String content = buildContent(null, holds); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected exception when adding an item to something + * that isn't a hold. + */ + @SuppressWarnings("unchecked") + @Test + public void holdIsNotAHold() throws Exception + { + // build json content to send to server + List notAHold = Collections.singletonList(recordFolder); + String content = buildContent(records, notAHold); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } + + /** + * Test for expected exception when adding an item to a hold + * that isn't a record or record folder. + */ + @SuppressWarnings("unchecked") + @Test + public void nodeRefIsNotARecordOrRecordFolder() throws Exception + { + // build json content to send to server + List notAHold = Collections.singletonList(recordFolder); + String content = buildContent(filePlanComponents, notAHold); + + // expected exception + exception.expect(WebScriptException.class); + exception.expect(badRequest()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP, content); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPostUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPostUnitTest.java index e5d52d4d02..e99b28dddc 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPostUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPostUnitTest.java @@ -1,100 +1,100 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.Collections; - -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Hold ReST API POST implementation unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class HoldPostUnitTest extends BaseHoldWebScriptWithContentUnitTest -{ - /** classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "hold.post.json.ftl"; - - /** HoldPost webscript instance */ - protected @Spy @InjectMocks HoldPost webScript; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test that a record can be added to holds. - */ - @SuppressWarnings("unchecked") - @Test - public void addRecordToHolds() throws Exception - { - // build json to send to server - String content = buildContent(records, holds); - - // execute web script - JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); - assertNotNull(json); - - // verify that the record was added to the holds - verify(mockedHoldService, times(1)).addToHolds(holds, records); - } - - /** - * Test that a record folder can be added to holds. - */ - @SuppressWarnings("unchecked") - @Test - public void addRecordFolderToHolds() throws Exception - { - // build json to send to server - String content = buildContent(recordFolders, holds); - - // execute web script - JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); - assertNotNull(json); - - // verify that the record was added to the holds - verify(mockedHoldService, times(1)).addToHolds(holds, recordFolders); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Collections; + +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.springframework.extensions.webscripts.DeclarativeWebScript; + +/** + * Hold ReST API POST implementation unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class HoldPostUnitTest extends BaseHoldWebScriptWithContentUnitTest +{ + /** classpath location of ftl template for web script */ + private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "hold.post.json.ftl"; + + /** HoldPost webscript instance */ + protected @Spy @InjectMocks HoldPost webScript; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() + */ + @Override + protected DeclarativeWebScript getWebScript() + { + return webScript; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() + */ + @Override + protected String getWebScriptTemplate() + { + return WEBSCRIPT_TEMPLATE; + } + + /** + * Test that a record can be added to holds. + */ + @SuppressWarnings("unchecked") + @Test + public void addRecordToHolds() throws Exception + { + // build json to send to server + String content = buildContent(records, holds); + + // execute web script + JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); + assertNotNull(json); + + // verify that the record was added to the holds + verify(mockedHoldService, times(1)).addToHolds(holds, records); + } + + /** + * Test that a record folder can be added to holds. + */ + @SuppressWarnings("unchecked") + @Test + public void addRecordFolderToHolds() throws Exception + { + // build json to send to server + String content = buildContent(recordFolders, holds); + + // execute web script + JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); + assertNotNull(json); + + // verify that the record was added to the holds + verify(mockedHoldService, times(1)).addToHolds(holds, recordFolders); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPutUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPutUnitTest.java index e1615b7c1d..1fec706036 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPutUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPutUnitTest.java @@ -1,100 +1,100 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.Collections; - -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Hold ReST API PUT implementation unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class HoldPutUnitTest extends BaseHoldWebScriptWithContentUnitTest -{ - /** classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "hold.put.json.ftl"; - - /** HoldPut webscript instance */ - protected @Spy @InjectMocks HoldPut webScript; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test that a record can be removed from holds. - */ - @SuppressWarnings("unchecked") - @Test - public void removeRecordFromHolds() throws Exception - { - // build json to send to server - String content = buildContent(records, holds); - - // execute web script - JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); - assertNotNull(json); - - // verify that the record was removed from holds - verify(mockedHoldService, times(1)).removeFromHolds(holds, records); - } - - /** - * Test that a record folder can be removed from holds. - */ - @SuppressWarnings("unchecked") - @Test - public void removeRecordFolderFromHolds() throws Exception - { - // build json to send to server - String content = buildContent(recordFolders, holds); - - // execute web script - JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); - assertNotNull(json); - - // verify that the record was removed from holds - verify(mockedHoldService, times(1)).removeFromHolds(holds, recordFolders); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Collections; + +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.springframework.extensions.webscripts.DeclarativeWebScript; + +/** + * Hold ReST API PUT implementation unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class HoldPutUnitTest extends BaseHoldWebScriptWithContentUnitTest +{ + /** classpath location of ftl template for web script */ + private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "hold.put.json.ftl"; + + /** HoldPut webscript instance */ + protected @Spy @InjectMocks HoldPut webScript; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() + */ + @Override + protected DeclarativeWebScript getWebScript() + { + return webScript; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() + */ + @Override + protected String getWebScriptTemplate() + { + return WEBSCRIPT_TEMPLATE; + } + + /** + * Test that a record can be removed from holds. + */ + @SuppressWarnings("unchecked") + @Test + public void removeRecordFromHolds() throws Exception + { + // build json to send to server + String content = buildContent(records, holds); + + // execute web script + JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); + assertNotNull(json); + + // verify that the record was removed from holds + verify(mockedHoldService, times(1)).removeFromHolds(holds, records); + } + + /** + * Test that a record folder can be removed from holds. + */ + @SuppressWarnings("unchecked") + @Test + public void removeRecordFolderFromHolds() throws Exception + { + // build json to send to server + String content = buildContent(recordFolders, holds); + + // execute web script + JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP, content); + assertNotNull(json); + + // verify that the record was removed from holds + verify(mockedHoldService, times(1)).removeFromHolds(holds, recordFolders); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGetUnitTest.java index 85602a132c..07323b5d1b 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGetUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGetUnitTest.java @@ -1,269 +1,269 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.script.hold; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; -import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExceptionMatcher.fileNotFound; - -import java.util.Collections; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.service.cmr.security.AccessStatus; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.WebScriptException; - -/** - * Holds ReST API GET implementation unit test. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class HoldsGetUnitTest extends BaseHoldWebScriptUnitTest -{ - /** classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "holds.get.json.ftl"; - - /** HoldsGet webscript instance */ - protected @Spy @InjectMocks HoldsGet webScript; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the outcome of calling the web script with an invalid file plan - */ - @Test - public void invalidFilePlan() throws Exception - { - // setup web script parameters - Map parameters = buildParameters - ( - "store_type", filePlan.getStoreRef().getProtocol(), - "store_id", filePlan.getStoreRef().getIdentifier(), - "id", "imadethisup" - ); - - // setup expected exception - exception.expect(WebScriptException.class); - exception.expect(fileNotFound()); - - // execute web script - executeWebScript(parameters); - } - - /** - * Test the outcome of calling the web script with no file plan specified - * and with no default file plan created. - */ - @SuppressWarnings("unchecked") - @Test - public void defaultFilePlanDoesNotExist() throws Exception - { - // setup expected exception - exception.expect(WebScriptException.class); - exception.expect(fileNotFound()); - - // execute web script - executeWebScript(Collections.EMPTY_MAP); - } - - /** - * Test the successful retrieval of holds defined for a specified file - * plan. - */ - @Test - public void getHoldsForFilePlan() throws Exception - { - // setup interactions - doReturn(holds).when(mockedHoldService).getHolds(filePlan); - - // setup web script parameters - Map parameters = buildParameters - ( - "store_type", filePlan.getStoreRef().getProtocol(), - "store_id", filePlan.getStoreRef().getIdentifier(), - "id", filePlan.getId() - ); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - - // check the JSON result - testForBothHolds(json); - } - - /** - * Test the retrieval of holds for the default file plan. - */ - @SuppressWarnings("unchecked") - @Test - public void getHoldsForDefaultFilePlan() throws Exception - { - // setup interactions - doReturn(holds).when(mockedHoldService).getHolds(filePlan); - doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - // execute web script - JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP); - assertNotNull(json); - - // check the JSON result - testForBothHolds(json); - } - - /** - * Test the retrieval of holds that hold a specified node. - */ - @Test - public void getHoldsThatNodeRefIsHeldBy() throws Exception - { - // setup interactions - doReturn(holds).when(mockedHoldService).heldBy(record, true); - - // setup web script parameters - Map parameters = buildParameters - ( - "store_type", filePlan.getStoreRef().getProtocol(), - "store_id", filePlan.getStoreRef().getIdentifier(), - "id", filePlan.getId(), - "itemNodeRef", record.toString() - ); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - - // check the JSON result - testForBothHolds(json); - - } - - /** - * Test the retrieval of holds that a node is not held in. - */ - @Test - public void getHoldsThatNodeRefIsNotHeldBy() throws Exception - { - // setup interactions - doReturn(holds).when(mockedHoldService).heldBy(record, false); - - // setup web script parameters - Map parameters = buildParameters - ( - "store_type", filePlan.getStoreRef().getProtocol(), - "store_id", filePlan.getStoreRef().getIdentifier(), - "id", filePlan.getId(), - "itemNodeRef", record.toString(), - "includedInHold", "false" - ); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - - // check the JSON result - testForBothHolds(json); - } - - public void getFileOnlyHolds() throws Exception - { - doReturn(AccessStatus.ALLOWED).when(mockedPermissionService).hasPermission(hold1NodeRef, RMPermissionModel.FILING); - doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold2NodeRef, RMPermissionModel.FILING); - - // setup web script parameters - Map parameters = buildParameters - ( - "store_type", filePlan.getStoreRef().getProtocol(), - "store_id", filePlan.getStoreRef().getIdentifier(), - "id", filePlan.getId(), - "itemNodeRef", record.toString(), - "includedInHold", "false", - "fileOnly", "true" - ); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - - // check the JSON result - assertTrue(json.has("data")); - assertTrue(json.getJSONObject("data").has("holds")); - - JSONArray jsonHolds = json.getJSONObject("data").getJSONArray("holds"); - assertNotNull(jsonHolds); - assertEquals(1, jsonHolds.length()); - - JSONObject hold1 = jsonHolds.getJSONObject(0); - assertNotNull(hold1); - assertEquals("hold1", hold1.getString("name")); - assertEquals(hold1NodeRef.toString(), hold1.getString("nodeRef")); - } - - /** - * Helper method to test JSON object for the presence of both test holds. - * - * @param json json result from web script - */ - private void testForBothHolds(JSONObject json) throws Exception - { - // check the JSON result - assertTrue(json.has("data")); - assertTrue(json.getJSONObject("data").has("holds")); - - JSONArray jsonHolds = json.getJSONObject("data").getJSONArray("holds"); - assertNotNull(jsonHolds); - assertEquals(2, jsonHolds.length()); - - JSONObject hold1 = jsonHolds.getJSONObject(0); - assertNotNull(hold1); - assertEquals("hold1", hold1.getString("name")); - assertEquals(hold1NodeRef.toString(), hold1.getString("nodeRef")); - - JSONObject hold2 = jsonHolds.getJSONObject(1); - assertNotNull(hold2); - assertEquals("hold2", hold2.getString("name")); - assertEquals(hold2NodeRef.toString(), hold2.getString("nodeRef")); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExceptionMatcher.fileNotFound; + +import java.util.Collections; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.service.cmr.security.AccessStatus; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.WebScriptException; + +/** + * Holds ReST API GET implementation unit test. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class HoldsGetUnitTest extends BaseHoldWebScriptUnitTest +{ + /** classpath location of ftl template for web script */ + private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "holds.get.json.ftl"; + + /** HoldsGet webscript instance */ + protected @Spy @InjectMocks HoldsGet webScript; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() + */ + @Override + protected DeclarativeWebScript getWebScript() + { + return webScript; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() + */ + @Override + protected String getWebScriptTemplate() + { + return WEBSCRIPT_TEMPLATE; + } + + /** + * Test the outcome of calling the web script with an invalid file plan + */ + @Test + public void invalidFilePlan() throws Exception + { + // setup web script parameters + Map parameters = buildParameters + ( + "store_type", filePlan.getStoreRef().getProtocol(), + "store_id", filePlan.getStoreRef().getIdentifier(), + "id", "imadethisup" + ); + + // setup expected exception + exception.expect(WebScriptException.class); + exception.expect(fileNotFound()); + + // execute web script + executeWebScript(parameters); + } + + /** + * Test the outcome of calling the web script with no file plan specified + * and with no default file plan created. + */ + @SuppressWarnings("unchecked") + @Test + public void defaultFilePlanDoesNotExist() throws Exception + { + // setup expected exception + exception.expect(WebScriptException.class); + exception.expect(fileNotFound()); + + // execute web script + executeWebScript(Collections.EMPTY_MAP); + } + + /** + * Test the successful retrieval of holds defined for a specified file + * plan. + */ + @Test + public void getHoldsForFilePlan() throws Exception + { + // setup interactions + doReturn(holds).when(mockedHoldService).getHolds(filePlan); + + // setup web script parameters + Map parameters = buildParameters + ( + "store_type", filePlan.getStoreRef().getProtocol(), + "store_id", filePlan.getStoreRef().getIdentifier(), + "id", filePlan.getId() + ); + + // execute web script + JSONObject json = executeJSONWebScript(parameters); + assertNotNull(json); + + // check the JSON result + testForBothHolds(json); + } + + /** + * Test the retrieval of holds for the default file plan. + */ + @SuppressWarnings("unchecked") + @Test + public void getHoldsForDefaultFilePlan() throws Exception + { + // setup interactions + doReturn(holds).when(mockedHoldService).getHolds(filePlan); + doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + // execute web script + JSONObject json = executeJSONWebScript(Collections.EMPTY_MAP); + assertNotNull(json); + + // check the JSON result + testForBothHolds(json); + } + + /** + * Test the retrieval of holds that hold a specified node. + */ + @Test + public void getHoldsThatNodeRefIsHeldBy() throws Exception + { + // setup interactions + doReturn(holds).when(mockedHoldService).heldBy(record, true); + + // setup web script parameters + Map parameters = buildParameters + ( + "store_type", filePlan.getStoreRef().getProtocol(), + "store_id", filePlan.getStoreRef().getIdentifier(), + "id", filePlan.getId(), + "itemNodeRef", record.toString() + ); + + // execute web script + JSONObject json = executeJSONWebScript(parameters); + assertNotNull(json); + + // check the JSON result + testForBothHolds(json); + + } + + /** + * Test the retrieval of holds that a node is not held in. + */ + @Test + public void getHoldsThatNodeRefIsNotHeldBy() throws Exception + { + // setup interactions + doReturn(holds).when(mockedHoldService).heldBy(record, false); + + // setup web script parameters + Map parameters = buildParameters + ( + "store_type", filePlan.getStoreRef().getProtocol(), + "store_id", filePlan.getStoreRef().getIdentifier(), + "id", filePlan.getId(), + "itemNodeRef", record.toString(), + "includedInHold", "false" + ); + + // execute web script + JSONObject json = executeJSONWebScript(parameters); + assertNotNull(json); + + // check the JSON result + testForBothHolds(json); + } + + public void getFileOnlyHolds() throws Exception + { + doReturn(AccessStatus.ALLOWED).when(mockedPermissionService).hasPermission(hold1NodeRef, RMPermissionModel.FILING); + doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold2NodeRef, RMPermissionModel.FILING); + + // setup web script parameters + Map parameters = buildParameters + ( + "store_type", filePlan.getStoreRef().getProtocol(), + "store_id", filePlan.getStoreRef().getIdentifier(), + "id", filePlan.getId(), + "itemNodeRef", record.toString(), + "includedInHold", "false", + "fileOnly", "true" + ); + + // execute web script + JSONObject json = executeJSONWebScript(parameters); + assertNotNull(json); + + // check the JSON result + assertTrue(json.has("data")); + assertTrue(json.getJSONObject("data").has("holds")); + + JSONArray jsonHolds = json.getJSONObject("data").getJSONArray("holds"); + assertNotNull(jsonHolds); + assertEquals(1, jsonHolds.length()); + + JSONObject hold1 = jsonHolds.getJSONObject(0); + assertNotNull(hold1); + assertEquals("hold1", hold1.getString("name")); + assertEquals(hold1NodeRef.toString(), hold1.getString("nodeRef")); + } + + /** + * Helper method to test JSON object for the presence of both test holds. + * + * @param json json result from web script + */ + private void testForBothHolds(JSONObject json) throws Exception + { + // check the JSON result + assertTrue(json.has("data")); + assertTrue(json.getJSONObject("data").has("holds")); + + JSONArray jsonHolds = json.getJSONObject("data").getJSONArray("holds"); + assertNotNull(jsonHolds); + assertEquals(2, jsonHolds.length()); + + JSONObject hold1 = jsonHolds.getJSONObject(0); + assertNotNull(hold1); + assertEquals("hold1", hold1.getString("name")); + assertEquals(hold1NodeRef.toString(), hold1.getString("nodeRef")); + + JSONObject hold2 = jsonHolds.getJSONObject(1); + assertNotNull(hold2); + assertEquals("hold2", hold2.getString("name")); + assertEquals(hold2NodeRef.toString(), hold2.getString("nodeRef")); + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImplUnitTest.java index 3414321c3e..d97dceb755 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImplUnitTest.java @@ -1,440 +1,440 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.security; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.security.permissions.impl.AccessPermissionImpl; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.verification.VerificationMode; - -/** - * File plan permission service implementation unit test. - *

- * Primarily tests the file plan permission service interaction with the - * permission service. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class FilePlanPermissionServiceImplUnitTest extends BaseUnitTest -{ - /** test authority */ - protected static final String AUTHORITY = "anAuthority"; - protected static final String AUTHORITY2 = "anOtherAuthority"; - - /** fileplan nodes */ - protected NodeRef rootRecordCategory; - protected NodeRef recordCategory; - protected NodeRef newRecordFolder; - protected NodeRef newRecord; - - /** unfiled nodes */ - protected NodeRef unfiledRecordContainer; - protected NodeRef unfiledRecordFolder; - protected NodeRef unfiledRecordFolderChild; - protected NodeRef unfiledRecord; - - /** held nodes */ - protected NodeRef holdContainer; - protected NodeRef hold; - protected NodeRef heldRecord; - - /** file plan permission service implementation */ - @Spy @InjectMocks FilePlanPermissionServiceImpl filePlanPermissionService; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @Override - public void before() throws Exception - { - super.before(); - - // initialize node's - unfiledRecordContainer = generateContainerNodeRef(TYPE_UNFILED_RECORD_CONTAINER); - unfiledRecordFolder = generateContainerNodeRef(TYPE_UNFILED_RECORD_FOLDER); - unfiledRecordFolderChild = generateContainerNodeRef(TYPE_UNFILED_RECORD_FOLDER); - unfiledRecord = generateRecord(); - holdContainer = generateContainerNodeRef(TYPE_HOLD_CONTAINER); - hold = generateHoldNodeRef("my test hold"); - heldRecord = generateRecord(); - rootRecordCategory = generateContainerNodeRef(TYPE_RECORD_CATEGORY); - recordCategory = generateContainerNodeRef(TYPE_RECORD_CATEGORY); - newRecordFolder = generateRecordFolder(); - newRecord = generateRecord(); - - // setup parent hierarchy - makePrimaryParentOf(filePlan, generateNodeRef(ContentModel.TYPE_FOLDER)); - - makePrimaryParentOf(rootRecordCategory, filePlan); - makePrimaryParentOf(recordCategory, rootRecordCategory); - makePrimaryParentOf(newRecordFolder, recordCategory); - makePrimaryParentOf(newRecord, newRecordFolder); - - makePrimaryParentOf(unfiledRecordFolder, unfiledRecordContainer); - makePrimaryParentOf(unfiledRecordContainer, filePlan); - - makePrimaryParentOf(hold, holdContainer); - makePrimaryParentOf(holdContainer, filePlan); - - - // setup child hierarchy - makeChildrenOf(filePlan, rootRecordCategory); - makeChildrenOf(rootRecordCategory, recordCategory); - makeChildrenOf(recordCategory, newRecordFolder); - makeChildrenOf(newRecordFolder, newRecord); - - makeChildrenOf(unfiledRecordFolder, unfiledRecordFolderChild); - makeChildrenOf(unfiledRecordFolderChild, unfiledRecord); - - makeChildrenOf(holdContainer, hold); - makeChildrenOf(hold, heldRecord); - - doReturn(FilePlanComponentKind.FILE_PLAN).when(filePlanPermissionService).getFilePlanComponentKind(filePlan); - doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(filePlanPermissionService).getFilePlanComponentKind(rootRecordCategory); - doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(filePlanPermissionService).getFilePlanComponentKind(recordCategory); - doReturn(FilePlanComponentKind.RECORD_FOLDER).when(filePlanPermissionService).getFilePlanComponentKind(newRecordFolder); - doReturn(FilePlanComponentKind.RECORD).when(filePlanPermissionService).getFilePlanComponentKind(newRecord); - doReturn(FilePlanComponentKind.UNFILED_RECORD_FOLDER).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecordFolder); - doReturn(FilePlanComponentKind.UNFILED_RECORD_CONTAINER).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecordContainer); - doReturn(FilePlanComponentKind.RECORD).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecord); - doReturn(FilePlanComponentKind.HOLD_CONTAINER).when(filePlanPermissionService).getFilePlanComponentKind(holdContainer); - doReturn(FilePlanComponentKind.HOLD).when(filePlanPermissionService).getFilePlanComponentKind(hold); - } - - /** - * Helper method to generate a container node ref of a perticular type. - * - * @param type type of node reference - * @return {@link NodeRef} node reference that behaves like a container of the type given. - */ - private NodeRef generateContainerNodeRef(QName type) - { - NodeRef nodeRef = generateNodeRef(type); - setupAsFilePlanComponent(nodeRef); - doReturn(true).when(filePlanPermissionService).isFilePlanContainer(nodeRef); - return nodeRef; - } - - /** - * Set read permission on unfiled record folder. - */ - @Test - public void setReadPermissionOnUnfiledRecordFolder() - { - // set read permission on unfiled record folder - filePlanPermissionService.setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS, true); - } - - /** - * Set filling permission on unfiled record folder - */ - @Test - public void setReadAndFilePermissionOnUnfileRecordFolder() - { - // set read permission on unfiled record folder - filePlanPermissionService.setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.FILING); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.FILING, true); - } - - /** - * Remove permission from unfiled record folders. - */ - @Test - public void deletePermissionFromUnfiledRecordFolder() - { - // delete read permission from unfiled record folder - filePlanPermissionService.deletePermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); - - // verify permission deleted on target node - verify(mockedPermissionService, times(1)).deletePermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); - } - - /** - * Set read permission on hold container - */ - @Test - public void setReadPermissionOnHoldContainer() - { - // set read permission on hold - filePlanPermissionService.setPermission(holdContainer, AUTHORITY, RMPermissionModel.READ_RECORDS); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(holdContainer, AUTHORITY, RMPermissionModel.READ_RECORDS, true); - } - - /** - * Set filing permission on hold container - */ - @Test - public void setFilingPermissionOnHoldContainer() - { - // set read permission on hold - filePlanPermissionService.setPermission(holdContainer, AUTHORITY, RMPermissionModel.FILING); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(holdContainer, AUTHORITY, RMPermissionModel.FILING, true); - } - - /** - * Set read permission on hold. - */ - @Test - public void setReadPermissionOnHold() - { - // set read permission on hold - filePlanPermissionService.setPermission(hold, AUTHORITY, RMPermissionModel.READ_RECORDS); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(hold, AUTHORITY, RMPermissionModel.READ_RECORDS, true); - } - - /** - * Set filing permission on hold. - */ - @Test - public void setFilingPermissionOnHold() - { - // set filing permission on hold - filePlanPermissionService.setPermission(hold, AUTHORITY, RMPermissionModel.FILING); - - // verify permission set on target node - verify(mockedPermissionService, times(1)).setPermission(hold, AUTHORITY, RMPermissionModel.FILING, true); - } - - /** - * Helper method to setup permissions on mock objects - */ - private void setupPermissions(NodeRef nodeRef) - { - Set perms = new HashSet(4); - - // setup basic file and read for authorities - perms.add(new AccessPermissionImpl(RMPermissionModel.READ_RECORDS, AccessStatus.ALLOWED, AUTHORITY, 0)); - perms.add(new AccessPermissionImpl(RMPermissionModel.FILING, AccessStatus.ALLOWED, AUTHORITY2, 1)); - - doReturn(perms).when(mockedPermissionService).getAllSetPermissions(nodeRef); - } - - /** - * Helper to verify the core permissions have been initialized correctly - */ - private void verifyInitPermissions(NodeRef nodeRef, boolean isInherited) - { - verify(mockedPermissionService).getAllSetPermissions(nodeRef); - verify(mockedPermissionService).setInheritParentPermissions(nodeRef, isInherited); - verify(mockedPermissionService).clearPermission(nodeRef, null); - verify(mockedOwnableService).setOwner(nodeRef, OwnableService.NO_OWNER); - } - - /** - * Helper to verify that permissions have been set correctly on the child - * - * @param parent parent node - * @param child child node - * @param read verification mode relating to setting read on the child - * @param filling verification mode relating to setting filling on the child - */ - private void verifyInitPermissions(NodeRef parent, NodeRef child, VerificationMode read, VerificationMode filling, boolean isParentFilePlan, boolean isInherited) - { - // verify the core permissions are set-up correctly - verifyInitPermissions(child, isInherited); - - if (isParentFilePlan) - { - // verify the permissions came from the correct parent - verify(mockedPermissionService).getAllSetPermissions(parent); - - // verify all the inherited permissions are set correctly (note read are not inherited from fileplan) - verify(mockedPermissionService, filling).setPermission(child, AUTHORITY2, RMPermissionModel.FILING, true); - verify(mockedPermissionService, read).setPermission(child, AUTHORITY, RMPermissionModel.READ_RECORDS, true); - } - } - - /** - * Test the initialisation of permissions for a new root category - */ - @Test - public void initPermissionsForNewRootRecordCategory() - { - // setup permissions for file plan - setupPermissions(filePlan); - - // setup permissions - filePlanPermissionService.setupRecordCategoryPermissions(rootRecordCategory); - - // verify permission init - verifyInitPermissions(filePlan, rootRecordCategory, never(), times(1), true, false); - } - - /** - * Test the initialisation of permissions for a new category - */ - @Test - public void initPermissionsForNewRecordCategory() - { - // setup permissions for parent - setupPermissions(rootRecordCategory); - - // setup permissions - filePlanPermissionService.setupRecordCategoryPermissions(recordCategory); - - // verify permission init - verifyInitPermissions(rootRecordCategory, recordCategory, times(1), times(1), false, true); - } - - /** - * Test initialisation new record folder permissions - */ - @Test - public void initPermissionsForNewRecordFolder() - { - // setup permissions for parent - setupPermissions(recordCategory); - - // setup permissions - filePlanPermissionService.setupPermissions(recordCategory, newRecordFolder); - - // verify permission init - verifyInitPermissions(recordCategory, newRecordFolder, times(1), times(1), false, true); - - } - - /** - * Test setup of new record permissions - */ - @Test - public void initPermissionsForNewRecord() - { - // setup permissions for parent - setupPermissions(newRecordFolder); - - // setup permissions for record - filePlanPermissionService.setupPermissions(newRecordFolder, newRecord); - - // verify permission init - verifyInitPermissions(newRecordFolder, newRecord, times(1), times(1), false, true); - } - - /** - * Test setup of permissions for new hold container - */ - @Test - public void initPermnissionsForNewHoldContainer() - { - // setup permissions for parent - setupPermissions(filePlan); - - // setup permissions for record - filePlanPermissionService.setupPermissions(filePlan, holdContainer); - - // verify permissions are set-up correctly - verifyInitPermissions(filePlan, holdContainer, times(1), times(1), false, true); - } - - /** - * Test setup of permissions for new hold - */ - @Test - public void initPermissionsForNewHold() - { - // setup permissions for parent - setupPermissions(holdContainer); - - // setup permissions for record - filePlanPermissionService.setupPermissions(holdContainer, hold); - - // verify permissions are set-up correctly - verifyInitPermissions(holdContainer, hold, never(), times(1), false, false); - - } - - /** - * Test setup of permissions for new unfiled container - */ - @Test - public void initPermissionsForNewUnfiledContainer() - { - // setup permissions for parent - setupPermissions(filePlan); - - // setup permissions for record - filePlanPermissionService.setupPermissions(filePlan, unfiledRecordContainer); - - // verify permissions are set-up correctly - verifyInitPermissions(filePlan, unfiledRecordContainer, times(1), times(1), false, false); - } - - /** - * Test setup of permissions for new unfiled record folder - */ - @Test - public void initPermissionsForNewUnfiledRecordFolder() - { - // setup permissions for parent - setupPermissions(unfiledRecordContainer); - - // setup permissions for record - filePlanPermissionService.setupPermissions(unfiledRecordContainer, unfiledRecordFolder); - - // verify permissions are set-up correctly - verifyInitPermissions(unfiledRecordContainer, unfiledRecordFolder, never(), times(1), false, true); - - } - - /** - * Test setup of permissions for new unfiled record - */ - @Test - public void initPermissionsForNewUnfiledRecord() - { - // setup permissions for parent - setupPermissions(unfiledRecordFolder); - - // setup permissions for record - filePlanPermissionService.setupPermissions(unfiledRecordFolder, unfiledRecord); - - // verify permission init - verifyInitPermissions(unfiledRecordFolder, unfiledRecord, times(1), times(1), false, true); - - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.security; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.security.permissions.impl.AccessPermissionImpl; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessPermission; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.namespace.QName; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.verification.VerificationMode; + +/** + * File plan permission service implementation unit test. + *

+ * Primarily tests the file plan permission service interaction with the + * permission service. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class FilePlanPermissionServiceImplUnitTest extends BaseUnitTest +{ + /** test authority */ + protected static final String AUTHORITY = "anAuthority"; + protected static final String AUTHORITY2 = "anOtherAuthority"; + + /** fileplan nodes */ + protected NodeRef rootRecordCategory; + protected NodeRef recordCategory; + protected NodeRef newRecordFolder; + protected NodeRef newRecord; + + /** unfiled nodes */ + protected NodeRef unfiledRecordContainer; + protected NodeRef unfiledRecordFolder; + protected NodeRef unfiledRecordFolderChild; + protected NodeRef unfiledRecord; + + /** held nodes */ + protected NodeRef holdContainer; + protected NodeRef hold; + protected NodeRef heldRecord; + + /** file plan permission service implementation */ + @Spy @InjectMocks FilePlanPermissionServiceImpl filePlanPermissionService; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @Override + public void before() throws Exception + { + super.before(); + + // initialize node's + unfiledRecordContainer = generateContainerNodeRef(TYPE_UNFILED_RECORD_CONTAINER); + unfiledRecordFolder = generateContainerNodeRef(TYPE_UNFILED_RECORD_FOLDER); + unfiledRecordFolderChild = generateContainerNodeRef(TYPE_UNFILED_RECORD_FOLDER); + unfiledRecord = generateRecord(); + holdContainer = generateContainerNodeRef(TYPE_HOLD_CONTAINER); + hold = generateHoldNodeRef("my test hold"); + heldRecord = generateRecord(); + rootRecordCategory = generateContainerNodeRef(TYPE_RECORD_CATEGORY); + recordCategory = generateContainerNodeRef(TYPE_RECORD_CATEGORY); + newRecordFolder = generateRecordFolder(); + newRecord = generateRecord(); + + // setup parent hierarchy + makePrimaryParentOf(filePlan, generateNodeRef(ContentModel.TYPE_FOLDER)); + + makePrimaryParentOf(rootRecordCategory, filePlan); + makePrimaryParentOf(recordCategory, rootRecordCategory); + makePrimaryParentOf(newRecordFolder, recordCategory); + makePrimaryParentOf(newRecord, newRecordFolder); + + makePrimaryParentOf(unfiledRecordFolder, unfiledRecordContainer); + makePrimaryParentOf(unfiledRecordContainer, filePlan); + + makePrimaryParentOf(hold, holdContainer); + makePrimaryParentOf(holdContainer, filePlan); + + + // setup child hierarchy + makeChildrenOf(filePlan, rootRecordCategory); + makeChildrenOf(rootRecordCategory, recordCategory); + makeChildrenOf(recordCategory, newRecordFolder); + makeChildrenOf(newRecordFolder, newRecord); + + makeChildrenOf(unfiledRecordFolder, unfiledRecordFolderChild); + makeChildrenOf(unfiledRecordFolderChild, unfiledRecord); + + makeChildrenOf(holdContainer, hold); + makeChildrenOf(hold, heldRecord); + + doReturn(FilePlanComponentKind.FILE_PLAN).when(filePlanPermissionService).getFilePlanComponentKind(filePlan); + doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(filePlanPermissionService).getFilePlanComponentKind(rootRecordCategory); + doReturn(FilePlanComponentKind.RECORD_CATEGORY).when(filePlanPermissionService).getFilePlanComponentKind(recordCategory); + doReturn(FilePlanComponentKind.RECORD_FOLDER).when(filePlanPermissionService).getFilePlanComponentKind(newRecordFolder); + doReturn(FilePlanComponentKind.RECORD).when(filePlanPermissionService).getFilePlanComponentKind(newRecord); + doReturn(FilePlanComponentKind.UNFILED_RECORD_FOLDER).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecordFolder); + doReturn(FilePlanComponentKind.UNFILED_RECORD_CONTAINER).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecordContainer); + doReturn(FilePlanComponentKind.RECORD).when(filePlanPermissionService).getFilePlanComponentKind(unfiledRecord); + doReturn(FilePlanComponentKind.HOLD_CONTAINER).when(filePlanPermissionService).getFilePlanComponentKind(holdContainer); + doReturn(FilePlanComponentKind.HOLD).when(filePlanPermissionService).getFilePlanComponentKind(hold); + } + + /** + * Helper method to generate a container node ref of a perticular type. + * + * @param type type of node reference + * @return {@link NodeRef} node reference that behaves like a container of the type given. + */ + private NodeRef generateContainerNodeRef(QName type) + { + NodeRef nodeRef = generateNodeRef(type); + setupAsFilePlanComponent(nodeRef); + doReturn(true).when(filePlanPermissionService).isFilePlanContainer(nodeRef); + return nodeRef; + } + + /** + * Set read permission on unfiled record folder. + */ + @Test + public void setReadPermissionOnUnfiledRecordFolder() + { + // set read permission on unfiled record folder + filePlanPermissionService.setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS, true); + } + + /** + * Set filling permission on unfiled record folder + */ + @Test + public void setReadAndFilePermissionOnUnfileRecordFolder() + { + // set read permission on unfiled record folder + filePlanPermissionService.setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.FILING); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.FILING, true); + } + + /** + * Remove permission from unfiled record folders. + */ + @Test + public void deletePermissionFromUnfiledRecordFolder() + { + // delete read permission from unfiled record folder + filePlanPermissionService.deletePermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); + + // verify permission deleted on target node + verify(mockedPermissionService, times(1)).deletePermission(unfiledRecordFolder, AUTHORITY, RMPermissionModel.READ_RECORDS); + } + + /** + * Set read permission on hold container + */ + @Test + public void setReadPermissionOnHoldContainer() + { + // set read permission on hold + filePlanPermissionService.setPermission(holdContainer, AUTHORITY, RMPermissionModel.READ_RECORDS); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(holdContainer, AUTHORITY, RMPermissionModel.READ_RECORDS, true); + } + + /** + * Set filing permission on hold container + */ + @Test + public void setFilingPermissionOnHoldContainer() + { + // set read permission on hold + filePlanPermissionService.setPermission(holdContainer, AUTHORITY, RMPermissionModel.FILING); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(holdContainer, AUTHORITY, RMPermissionModel.FILING, true); + } + + /** + * Set read permission on hold. + */ + @Test + public void setReadPermissionOnHold() + { + // set read permission on hold + filePlanPermissionService.setPermission(hold, AUTHORITY, RMPermissionModel.READ_RECORDS); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(hold, AUTHORITY, RMPermissionModel.READ_RECORDS, true); + } + + /** + * Set filing permission on hold. + */ + @Test + public void setFilingPermissionOnHold() + { + // set filing permission on hold + filePlanPermissionService.setPermission(hold, AUTHORITY, RMPermissionModel.FILING); + + // verify permission set on target node + verify(mockedPermissionService, times(1)).setPermission(hold, AUTHORITY, RMPermissionModel.FILING, true); + } + + /** + * Helper method to setup permissions on mock objects + */ + private void setupPermissions(NodeRef nodeRef) + { + Set perms = new HashSet(4); + + // setup basic file and read for authorities + perms.add(new AccessPermissionImpl(RMPermissionModel.READ_RECORDS, AccessStatus.ALLOWED, AUTHORITY, 0)); + perms.add(new AccessPermissionImpl(RMPermissionModel.FILING, AccessStatus.ALLOWED, AUTHORITY2, 1)); + + doReturn(perms).when(mockedPermissionService).getAllSetPermissions(nodeRef); + } + + /** + * Helper to verify the core permissions have been initialized correctly + */ + private void verifyInitPermissions(NodeRef nodeRef, boolean isInherited) + { + verify(mockedPermissionService).getAllSetPermissions(nodeRef); + verify(mockedPermissionService).setInheritParentPermissions(nodeRef, isInherited); + verify(mockedPermissionService).clearPermission(nodeRef, null); + verify(mockedOwnableService).setOwner(nodeRef, OwnableService.NO_OWNER); + } + + /** + * Helper to verify that permissions have been set correctly on the child + * + * @param parent parent node + * @param child child node + * @param read verification mode relating to setting read on the child + * @param filling verification mode relating to setting filling on the child + */ + private void verifyInitPermissions(NodeRef parent, NodeRef child, VerificationMode read, VerificationMode filling, boolean isParentFilePlan, boolean isInherited) + { + // verify the core permissions are set-up correctly + verifyInitPermissions(child, isInherited); + + if (isParentFilePlan) + { + // verify the permissions came from the correct parent + verify(mockedPermissionService).getAllSetPermissions(parent); + + // verify all the inherited permissions are set correctly (note read are not inherited from fileplan) + verify(mockedPermissionService, filling).setPermission(child, AUTHORITY2, RMPermissionModel.FILING, true); + verify(mockedPermissionService, read).setPermission(child, AUTHORITY, RMPermissionModel.READ_RECORDS, true); + } + } + + /** + * Test the initialisation of permissions for a new root category + */ + @Test + public void initPermissionsForNewRootRecordCategory() + { + // setup permissions for file plan + setupPermissions(filePlan); + + // setup permissions + filePlanPermissionService.setupRecordCategoryPermissions(rootRecordCategory); + + // verify permission init + verifyInitPermissions(filePlan, rootRecordCategory, never(), times(1), true, false); + } + + /** + * Test the initialisation of permissions for a new category + */ + @Test + public void initPermissionsForNewRecordCategory() + { + // setup permissions for parent + setupPermissions(rootRecordCategory); + + // setup permissions + filePlanPermissionService.setupRecordCategoryPermissions(recordCategory); + + // verify permission init + verifyInitPermissions(rootRecordCategory, recordCategory, times(1), times(1), false, true); + } + + /** + * Test initialisation new record folder permissions + */ + @Test + public void initPermissionsForNewRecordFolder() + { + // setup permissions for parent + setupPermissions(recordCategory); + + // setup permissions + filePlanPermissionService.setupPermissions(recordCategory, newRecordFolder); + + // verify permission init + verifyInitPermissions(recordCategory, newRecordFolder, times(1), times(1), false, true); + + } + + /** + * Test setup of new record permissions + */ + @Test + public void initPermissionsForNewRecord() + { + // setup permissions for parent + setupPermissions(newRecordFolder); + + // setup permissions for record + filePlanPermissionService.setupPermissions(newRecordFolder, newRecord); + + // verify permission init + verifyInitPermissions(newRecordFolder, newRecord, times(1), times(1), false, true); + } + + /** + * Test setup of permissions for new hold container + */ + @Test + public void initPermnissionsForNewHoldContainer() + { + // setup permissions for parent + setupPermissions(filePlan); + + // setup permissions for record + filePlanPermissionService.setupPermissions(filePlan, holdContainer); + + // verify permissions are set-up correctly + verifyInitPermissions(filePlan, holdContainer, times(1), times(1), false, true); + } + + /** + * Test setup of permissions for new hold + */ + @Test + public void initPermissionsForNewHold() + { + // setup permissions for parent + setupPermissions(holdContainer); + + // setup permissions for record + filePlanPermissionService.setupPermissions(holdContainer, hold); + + // verify permissions are set-up correctly + verifyInitPermissions(holdContainer, hold, never(), times(1), false, false); + + } + + /** + * Test setup of permissions for new unfiled container + */ + @Test + public void initPermissionsForNewUnfiledContainer() + { + // setup permissions for parent + setupPermissions(filePlan); + + // setup permissions for record + filePlanPermissionService.setupPermissions(filePlan, unfiledRecordContainer); + + // verify permissions are set-up correctly + verifyInitPermissions(filePlan, unfiledRecordContainer, times(1), times(1), false, false); + } + + /** + * Test setup of permissions for new unfiled record folder + */ + @Test + public void initPermissionsForNewUnfiledRecordFolder() + { + // setup permissions for parent + setupPermissions(unfiledRecordContainer); + + // setup permissions for record + filePlanPermissionService.setupPermissions(unfiledRecordContainer, unfiledRecordFolder); + + // verify permissions are set-up correctly + verifyInitPermissions(unfiledRecordContainer, unfiledRecordFolder, never(), times(1), false, true); + + } + + /** + * Test setup of permissions for new unfiled record + */ + @Test + public void initPermissionsForNewUnfiledRecord() + { + // setup permissions for parent + setupPermissions(unfiledRecordFolder); + + // setup permissions for record + filePlanPermissionService.setupPermissions(unfiledRecordFolder, unfiledRecord); + + // verify permission init + verifyInitPermissions(unfiledRecordFolder, unfiledRecord, times(1), times(1), false, true); + + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java index ff73cacd40..c80da8f9a5 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test; - -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; -import org.junit.runner.RunWith; - -/** - * All unit test suite. - * - * @author Roy Wetherall - * @since 2.2 - */ -@RunWith(ClasspathSuite.class) -@ClassnameFilters({ - // Execute all test classes ending with "UnitTest" - ".*UnitTest", - // Put the test classes you want to exclude here - "!.*FilePlanPermissionServiceImplUnitTest" -}) -public class AllUnitTestSuite -{ -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test; + +import org.junit.extensions.cpsuite.ClasspathSuite; +import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; +import org.junit.runner.RunWith; + +/** + * All unit test suite. + * + * @author Roy Wetherall + * @since 2.2 + */ +@RunWith(ClasspathSuite.class) +@ClassnameFilters({ + // Execute all test classes ending with "UnitTest" + ".*UnitTest", + // Put the test classes you want to exclude here + "!.*FilePlanPermissionServiceImplUnitTest" +}) +public class AllUnitTestSuite +{ +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java index ab726af049..47f802d028 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java @@ -1,443 +1,443 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; -import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; -import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.CmObjectType; -import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.report.ReportService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; -import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; -import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.CopyService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.QNamePattern; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; -import org.alfresco.util.collections.CollectionUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.springframework.context.ApplicationContext; - -/** - * Base unit test. - *

- * Contains core and records management service mocks ready for injection. Helper methods - * provide an easy way to build RM or Alfresco constructs for use in tests. - * - * @author Roy Wetherall - * @since 2.2 - */ -public class BaseUnitTest implements RecordsManagementModel, ContentModel -{ - protected NodeRef filePlanComponent; - protected NodeRef filePlan; - - protected NodeRef recordFolder; - protected NodeRef record; - - /** core service mocks */ - @Mock(name="nodeService") protected NodeService mockedNodeService; - @Mock(name="dictionaryService") protected DictionaryService mockedDictionaryService; - @Mock(name="namespaceService") protected NamespaceService mockedNamespaceService; - @Mock(name="identifierService") protected IdentifierService mockedIdentifierService; - @Mock(name="permissionService") protected PermissionService mockedPermissionService; - @Mock(name="ownableService") protected OwnableService mockedOwnableService; - @Mock(name="searchService") protected SearchService mockedSearchService; - @Mock(name="retryingTransactionHelper") protected RetryingTransactionHelper mockedRetryingTransactionHelper; - @Mock(name="authorityService") protected AuthorityService mockedAuthorityService; - @Mock(name="policyComponent") protected PolicyComponent mockedPolicyComponent; - @Mock(name="copyService") protected CopyService mockedCopyService; - @Mock(name="fileFolderService") protected FileFolderService mockedFileFolderService; - @Mock(name="modelSecurityService") protected ModelSecurityService mockedModelSecurityService; - - /** rm service mocks */ - @Mock(name="filePlanService") protected FilePlanService mockedFilePlanService; - @Mock(name="recordFolderService") protected RecordFolderService mockedRecordFolderService; - @Mock(name="recordService") protected RecordService mockedRecordService; - @Mock(name="holdService") protected HoldService mockedHoldService; - @Mock(name="recordsManagementActionService") protected RecordsManagementActionService mockedRecordsManagementActionService; - @Mock(name="reportService") protected ReportService mockedReportService; - @Mock(name="filePlanRoleService") protected FilePlanRoleService mockedFilePlanRoleService; - @Mock(name="recordsManagementAuditService") protected RecordsManagementAuditService mockedRecordsManagementAuditService; - @Mock(name="policyBehaviourFilter") protected BehaviourFilter mockedBehaviourFilter; - @Mock(name="authenticationUtil") protected AuthenticationUtil mockedAuthenticationUtil; - @Mock(name="extendedPermissionService") protected ExtendedPermissionService mockedExtendedPermissionService; - @Mock(name="extendedSecurityService") protected ExtendedSecurityService mockedExtendedSecurityService; - @Mock(name="recordableVersionConfigService") protected RecordableVersionConfigService mockedRecordableVersionConfigService; - @Mock(name="cmObjectType") protected CmObjectType mockedCmObjectType; - @Mock(name="recordableVersionService") protected RecordableVersionService mockedRecordableVersionService; - @Mock(name="transactionalResourceHelper") protected TransactionalResourceHelper mockedTransactionalResourceHelper; - @Mock(name="alfrescoTransactionSupport") protected AlfrescoTransactionSupport mockedAlfrescoTransactionSupport; - @Mock(name="freezeService") protected FreezeService mockedFreezeService; - @Mock(name="dispositionService") protected DispositionService mockedDispositionService; - - /** application context mock */ - @Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext; - - /** expected exception rule */ - @Rule - public ExpectedException exception = ExpectedException.none(); - - /** - * Test method setup - */ - @SuppressWarnings("unchecked") - @Before - public void before() throws Exception - { - MockitoAnnotations.initMocks(this); - - // setup application context - doReturn(mockedNodeService).when(mockedApplicationContext).getBean("dbNodeService"); - - // setup retrying transaction helper - Answer doInTransactionAnswer = new Answer() - { - @SuppressWarnings("rawtypes") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable - { - RetryingTransactionCallback callback = (RetryingTransactionCallback)invocation.getArguments()[0]; - return callback.execute(); - } - }; - doAnswer(doInTransactionAnswer).when(mockedRetryingTransactionHelper).doInTransaction(any(RetryingTransactionCallback.class)); - - // setup mocked authentication util - setupAuthenticationUtilMock(); - - // setup file plan - filePlan = generateNodeRef(TYPE_FILE_PLAN); - setupAsFilePlanComponent(filePlan); - doReturn(true).when(mockedFilePlanService).isFilePlan(filePlan); - - // setup basic file plan component - filePlanComponent = generateNodeRef(); - setupAsFilePlanComponent(filePlanComponent); - - // setup namespace service - doReturn(RM_URI).when(mockedNamespaceService).getNamespaceURI(RM_PREFIX); - doReturn(CollectionUtils.unmodifiableSet(RM_PREFIX)).when(mockedNamespaceService).getPrefixes(RM_URI); - - // setup record folder and record - recordFolder = generateRecordFolder(); - record = generateRecord(); - - // set record as child of record folder - List result = new ArrayList(1); - result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, recordFolder, generateQName(), record, true, 1)); - doReturn(result).when(mockedNodeService).getChildAssocs(eq(recordFolder), eq(ContentModel.ASSOC_CONTAINS), any(QNamePattern.class)); - doReturn(result).when(mockedNodeService).getParentAssocs(record); - doReturn(Collections.singletonList(recordFolder)).when(mockedRecordFolderService).getRecordFolders(record); - doReturn(Collections.singletonList(record)).when(mockedRecordService).getRecords(recordFolder); - } - - /** - * Setup authentication util mock - */ - @SuppressWarnings("unchecked") - private void setupAuthenticationUtilMock() - { - // just do the work - doAnswer(new Answer() - { - @SuppressWarnings("rawtypes") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable - { - RunAsWork work = (RunAsWork)invocation.getArguments()[0]; - return work.doWork(); - } - - }).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class)); - - // just do the work - doAnswer(new Answer() - { - @SuppressWarnings("rawtypes") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable - { - RunAsWork work = (RunAsWork)invocation.getArguments()[0]; - return work.doWork(); - } - - }).when(mockedAuthenticationUtil).runAs(any(RunAsWork.class), anyString()); - - // assume admin - doReturn("admin").when(mockedAuthenticationUtil).getAdminUserName(); - doReturn("admin").when(mockedAuthenticationUtil).getFullyAuthenticatedUser(); - } - - /** - * Helper to generate random text value suitable for a property - * value or node name - */ - protected String generateText() - { - return UUID.randomUUID().toString(); - } - - /** - * Helper method to generate a qname. - * - * @return QName qualified name - */ - protected static QName generateQName() - { - return QName.createQName(RM_URI, GUID.generate()); - } - - /** - * Helper method to generate hold reference - * - * @param name hold name - * @return {@link NodeRef} node reference that will behave like a hold - */ - protected NodeRef generateHoldNodeRef(String name) - { - NodeRef hold = generateNodeRef(TYPE_HOLD); - doReturn(name).when(mockedNodeService).getProperty(hold, ContentModel.PROP_NAME); - doReturn(true).when(mockedHoldService).isHold(hold); - return hold; - } - - /** - * Helper method to generate record folder reference - * - * @return {@link NodeRef} node reference that will behave like a record folder - */ - protected NodeRef generateRecordFolder() - { - NodeRef recordFolder = generateNodeRef(TYPE_RECORD_FOLDER); - setupAsFilePlanComponent(recordFolder); - doReturn(true).when(mockedRecordFolderService).isRecordFolder(recordFolder); - return recordFolder; - } - - /** - * Helper method to generate a record node reference. - * - * @return {@link NodeRef} node reference that will behave like a record or type cm:content - */ - protected NodeRef generateRecord() - { - NodeRef record = generateNodeRef(ContentModel.TYPE_CONTENT); - setupAsFilePlanComponent(record); - doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_RECORD); - doReturn(true).when(mockedRecordService).isRecord(record); - return record; - } - - /** - * Helper method to setup a node reference as a file plan component. - * - * @param nodeRef {@link NodeRef} node reference that will now behave like a file plan component - */ - protected void setupAsFilePlanComponent(NodeRef nodeRef) - { - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT); - doReturn(true).when(mockedFilePlanService).isFilePlanComponent(nodeRef); - doReturn(filePlan).when(mockedFilePlanService).getFilePlan(nodeRef); - doReturn(filePlan).when(mockedNodeService).getProperty(nodeRef, PROP_ROOT_NODEREF); - } - - /** - * Helper method to generate a node reference. - * - * @return {@link NodeRef} node reference that behaves like a node that exists in the spaces store - */ - protected NodeRef generateNodeRef() - { - return generateNodeRef(null); - } - - /** - * Helper method to generate a node reference of a particular type. - * - * @param type content type qualified name - * @return {@link NodeRef} node reference that behaves like a node that exists in the spaces store with - * the content type provided - */ - protected NodeRef generateNodeRef(QName type) - { - return generateNodeRef(type, true); - } - - /** - * Helper method to generate a cm:content node reference with a given name. - * - * @param name content name - * @return NodeRef node reference - */ - protected NodeRef generateCmContent(String name) - { - NodeRef nodeRef = generateNodeRef(ContentModel.TYPE_CONTENT, true); - doReturn(name).when(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_NAME); - return nodeRef; - } - - /** - * Helper method to generate a node reference of a particular type with a given existence characteristic. - * - * @param type content type qualified name - * @param exists indicates whether this node should behave like a node that exists or not - * @return {@link NodeRef} node reference that behaves like a node that exists (or not) in the spaces store with - * the content type provided - */ - protected NodeRef generateNodeRef(QName type, boolean exists) - { - NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); - when(mockedNodeService.exists(eq(nodeRef))).thenReturn(exists); - if (type != null) - { - when(mockedNodeService.getType(eq(nodeRef))).thenReturn(type); - } - return nodeRef; - } - - /** - * Helper method to generate a mocked child association reference. - * - * @param parent parent node (optional) - * @param child child node (optional) - * @return {@link ChildAssociationRef} mocked to return the parent and child nodes - */ - protected ChildAssociationRef generateChildAssociationRef(NodeRef parent, NodeRef child) - { - ChildAssociationRef mockedChildAssociationRef = mock(ChildAssociationRef.class); - - if (parent != null) - { - doReturn(parent).when(mockedChildAssociationRef).getParentRef(); - } - - if (child != null) - { - doReturn(child).when(mockedChildAssociationRef).getChildRef(); - } - - return mockedChildAssociationRef; - } - - /** - * Helper method to make one node the primary parent of the other. - *

- * Assumes the cm:contains assoc type. - * - * @param child - * @param parent - */ - protected void makePrimaryParentOf(NodeRef child, NodeRef parent) - { - makePrimaryParentOf(child, parent, ContentModel.ASSOC_CONTAINS, generateQName()); - } - - protected void makePrimaryParentOf(NodeRef child, NodeRef parent, QName assocType, QName assocName) - { - makePrimaryParentOf(child, parent, assocType, assocName, mockedNodeService); - } - - protected void makePrimaryParentOf(NodeRef child, NodeRef parent, QName assocType, QName assocName, NodeService mockedNodeService) - { - doReturn(new ChildAssociationRef(assocType, parent, assocName, child)) - .when(mockedNodeService) - .getPrimaryParent(child); - } - - /** - * Helper method to make a number of nodes children of another. - *

- * Assumes the cm:contains assoc type. - * - * @param parent - * @param children - */ - protected void makeChildrenOf(NodeRef parent, NodeRef ... children) - { - List assocs = new ArrayList(children.length); - for (NodeRef child : children) - { - assocs.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parent, generateQName(), child)); - doReturn(assocs).when(mockedNodeService).getParentAssocs(child); - } - doReturn(assocs).when(mockedNodeService).getChildAssocs(parent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - } - - @SuppressWarnings("unchecked") - protected List buildList(T ... values) - { - List result = new ArrayList(values.length); - for (T value : values) - { - result.add(value); - } - return result; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; +import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; +import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.rma.type.CmObjectType; +import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordableversion.RecordableVersionConfigService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.report.ReportService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; +import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.CopyService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.OwnableService; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.QNamePattern; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.GUID; +import org.alfresco.util.collections.CollectionUtils; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.springframework.context.ApplicationContext; + +/** + * Base unit test. + *

+ * Contains core and records management service mocks ready for injection. Helper methods + * provide an easy way to build RM or Alfresco constructs for use in tests. + * + * @author Roy Wetherall + * @since 2.2 + */ +public class BaseUnitTest implements RecordsManagementModel, ContentModel +{ + protected NodeRef filePlanComponent; + protected NodeRef filePlan; + + protected NodeRef recordFolder; + protected NodeRef record; + + /** core service mocks */ + @Mock(name="nodeService") protected NodeService mockedNodeService; + @Mock(name="dictionaryService") protected DictionaryService mockedDictionaryService; + @Mock(name="namespaceService") protected NamespaceService mockedNamespaceService; + @Mock(name="identifierService") protected IdentifierService mockedIdentifierService; + @Mock(name="permissionService") protected PermissionService mockedPermissionService; + @Mock(name="ownableService") protected OwnableService mockedOwnableService; + @Mock(name="searchService") protected SearchService mockedSearchService; + @Mock(name="retryingTransactionHelper") protected RetryingTransactionHelper mockedRetryingTransactionHelper; + @Mock(name="authorityService") protected AuthorityService mockedAuthorityService; + @Mock(name="policyComponent") protected PolicyComponent mockedPolicyComponent; + @Mock(name="copyService") protected CopyService mockedCopyService; + @Mock(name="fileFolderService") protected FileFolderService mockedFileFolderService; + @Mock(name="modelSecurityService") protected ModelSecurityService mockedModelSecurityService; + + /** rm service mocks */ + @Mock(name="filePlanService") protected FilePlanService mockedFilePlanService; + @Mock(name="recordFolderService") protected RecordFolderService mockedRecordFolderService; + @Mock(name="recordService") protected RecordService mockedRecordService; + @Mock(name="holdService") protected HoldService mockedHoldService; + @Mock(name="recordsManagementActionService") protected RecordsManagementActionService mockedRecordsManagementActionService; + @Mock(name="reportService") protected ReportService mockedReportService; + @Mock(name="filePlanRoleService") protected FilePlanRoleService mockedFilePlanRoleService; + @Mock(name="recordsManagementAuditService") protected RecordsManagementAuditService mockedRecordsManagementAuditService; + @Mock(name="policyBehaviourFilter") protected BehaviourFilter mockedBehaviourFilter; + @Mock(name="authenticationUtil") protected AuthenticationUtil mockedAuthenticationUtil; + @Mock(name="extendedPermissionService") protected ExtendedPermissionService mockedExtendedPermissionService; + @Mock(name="extendedSecurityService") protected ExtendedSecurityService mockedExtendedSecurityService; + @Mock(name="recordableVersionConfigService") protected RecordableVersionConfigService mockedRecordableVersionConfigService; + @Mock(name="cmObjectType") protected CmObjectType mockedCmObjectType; + @Mock(name="recordableVersionService") protected RecordableVersionService mockedRecordableVersionService; + @Mock(name="transactionalResourceHelper") protected TransactionalResourceHelper mockedTransactionalResourceHelper; + @Mock(name="alfrescoTransactionSupport") protected AlfrescoTransactionSupport mockedAlfrescoTransactionSupport; + @Mock(name="freezeService") protected FreezeService mockedFreezeService; + @Mock(name="dispositionService") protected DispositionService mockedDispositionService; + + /** application context mock */ + @Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext; + + /** expected exception rule */ + @Rule + public ExpectedException exception = ExpectedException.none(); + + /** + * Test method setup + */ + @SuppressWarnings("unchecked") + @Before + public void before() throws Exception + { + MockitoAnnotations.initMocks(this); + + // setup application context + doReturn(mockedNodeService).when(mockedApplicationContext).getBean("dbNodeService"); + + // setup retrying transaction helper + Answer doInTransactionAnswer = new Answer() + { + @SuppressWarnings("rawtypes") + @Override + public Object answer(InvocationOnMock invocation) throws Throwable + { + RetryingTransactionCallback callback = (RetryingTransactionCallback)invocation.getArguments()[0]; + return callback.execute(); + } + }; + doAnswer(doInTransactionAnswer).when(mockedRetryingTransactionHelper).doInTransaction(any(RetryingTransactionCallback.class)); + + // setup mocked authentication util + setupAuthenticationUtilMock(); + + // setup file plan + filePlan = generateNodeRef(TYPE_FILE_PLAN); + setupAsFilePlanComponent(filePlan); + doReturn(true).when(mockedFilePlanService).isFilePlan(filePlan); + + // setup basic file plan component + filePlanComponent = generateNodeRef(); + setupAsFilePlanComponent(filePlanComponent); + + // setup namespace service + doReturn(RM_URI).when(mockedNamespaceService).getNamespaceURI(RM_PREFIX); + doReturn(CollectionUtils.unmodifiableSet(RM_PREFIX)).when(mockedNamespaceService).getPrefixes(RM_URI); + + // setup record folder and record + recordFolder = generateRecordFolder(); + record = generateRecord(); + + // set record as child of record folder + List result = new ArrayList(1); + result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, recordFolder, generateQName(), record, true, 1)); + doReturn(result).when(mockedNodeService).getChildAssocs(eq(recordFolder), eq(ContentModel.ASSOC_CONTAINS), any(QNamePattern.class)); + doReturn(result).when(mockedNodeService).getParentAssocs(record); + doReturn(Collections.singletonList(recordFolder)).when(mockedRecordFolderService).getRecordFolders(record); + doReturn(Collections.singletonList(record)).when(mockedRecordService).getRecords(recordFolder); + } + + /** + * Setup authentication util mock + */ + @SuppressWarnings("unchecked") + private void setupAuthenticationUtilMock() + { + // just do the work + doAnswer(new Answer() + { + @SuppressWarnings("rawtypes") + @Override + public Object answer(InvocationOnMock invocation) throws Throwable + { + RunAsWork work = (RunAsWork)invocation.getArguments()[0]; + return work.doWork(); + } + + }).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class)); + + // just do the work + doAnswer(new Answer() + { + @SuppressWarnings("rawtypes") + @Override + public Object answer(InvocationOnMock invocation) throws Throwable + { + RunAsWork work = (RunAsWork)invocation.getArguments()[0]; + return work.doWork(); + } + + }).when(mockedAuthenticationUtil).runAs(any(RunAsWork.class), anyString()); + + // assume admin + doReturn("admin").when(mockedAuthenticationUtil).getAdminUserName(); + doReturn("admin").when(mockedAuthenticationUtil).getFullyAuthenticatedUser(); + } + + /** + * Helper to generate random text value suitable for a property + * value or node name + */ + protected String generateText() + { + return UUID.randomUUID().toString(); + } + + /** + * Helper method to generate a qname. + * + * @return QName qualified name + */ + protected static QName generateQName() + { + return QName.createQName(RM_URI, GUID.generate()); + } + + /** + * Helper method to generate hold reference + * + * @param name hold name + * @return {@link NodeRef} node reference that will behave like a hold + */ + protected NodeRef generateHoldNodeRef(String name) + { + NodeRef hold = generateNodeRef(TYPE_HOLD); + doReturn(name).when(mockedNodeService).getProperty(hold, ContentModel.PROP_NAME); + doReturn(true).when(mockedHoldService).isHold(hold); + return hold; + } + + /** + * Helper method to generate record folder reference + * + * @return {@link NodeRef} node reference that will behave like a record folder + */ + protected NodeRef generateRecordFolder() + { + NodeRef recordFolder = generateNodeRef(TYPE_RECORD_FOLDER); + setupAsFilePlanComponent(recordFolder); + doReturn(true).when(mockedRecordFolderService).isRecordFolder(recordFolder); + return recordFolder; + } + + /** + * Helper method to generate a record node reference. + * + * @return {@link NodeRef} node reference that will behave like a record or type cm:content + */ + protected NodeRef generateRecord() + { + NodeRef record = generateNodeRef(ContentModel.TYPE_CONTENT); + setupAsFilePlanComponent(record); + doReturn(true).when(mockedNodeService).hasAspect(record, ASPECT_RECORD); + doReturn(true).when(mockedRecordService).isRecord(record); + return record; + } + + /** + * Helper method to setup a node reference as a file plan component. + * + * @param nodeRef {@link NodeRef} node reference that will now behave like a file plan component + */ + protected void setupAsFilePlanComponent(NodeRef nodeRef) + { + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT); + doReturn(true).when(mockedFilePlanService).isFilePlanComponent(nodeRef); + doReturn(filePlan).when(mockedFilePlanService).getFilePlan(nodeRef); + doReturn(filePlan).when(mockedNodeService).getProperty(nodeRef, PROP_ROOT_NODEREF); + } + + /** + * Helper method to generate a node reference. + * + * @return {@link NodeRef} node reference that behaves like a node that exists in the spaces store + */ + protected NodeRef generateNodeRef() + { + return generateNodeRef(null); + } + + /** + * Helper method to generate a node reference of a particular type. + * + * @param type content type qualified name + * @return {@link NodeRef} node reference that behaves like a node that exists in the spaces store with + * the content type provided + */ + protected NodeRef generateNodeRef(QName type) + { + return generateNodeRef(type, true); + } + + /** + * Helper method to generate a cm:content node reference with a given name. + * + * @param name content name + * @return NodeRef node reference + */ + protected NodeRef generateCmContent(String name) + { + NodeRef nodeRef = generateNodeRef(ContentModel.TYPE_CONTENT, true); + doReturn(name).when(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_NAME); + return nodeRef; + } + + /** + * Helper method to generate a node reference of a particular type with a given existence characteristic. + * + * @param type content type qualified name + * @param exists indicates whether this node should behave like a node that exists or not + * @return {@link NodeRef} node reference that behaves like a node that exists (or not) in the spaces store with + * the content type provided + */ + protected NodeRef generateNodeRef(QName type, boolean exists) + { + NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); + when(mockedNodeService.exists(eq(nodeRef))).thenReturn(exists); + if (type != null) + { + when(mockedNodeService.getType(eq(nodeRef))).thenReturn(type); + } + return nodeRef; + } + + /** + * Helper method to generate a mocked child association reference. + * + * @param parent parent node (optional) + * @param child child node (optional) + * @return {@link ChildAssociationRef} mocked to return the parent and child nodes + */ + protected ChildAssociationRef generateChildAssociationRef(NodeRef parent, NodeRef child) + { + ChildAssociationRef mockedChildAssociationRef = mock(ChildAssociationRef.class); + + if (parent != null) + { + doReturn(parent).when(mockedChildAssociationRef).getParentRef(); + } + + if (child != null) + { + doReturn(child).when(mockedChildAssociationRef).getChildRef(); + } + + return mockedChildAssociationRef; + } + + /** + * Helper method to make one node the primary parent of the other. + *

+ * Assumes the cm:contains assoc type. + * + * @param child + * @param parent + */ + protected void makePrimaryParentOf(NodeRef child, NodeRef parent) + { + makePrimaryParentOf(child, parent, ContentModel.ASSOC_CONTAINS, generateQName()); + } + + protected void makePrimaryParentOf(NodeRef child, NodeRef parent, QName assocType, QName assocName) + { + makePrimaryParentOf(child, parent, assocType, assocName, mockedNodeService); + } + + protected void makePrimaryParentOf(NodeRef child, NodeRef parent, QName assocType, QName assocName, NodeService mockedNodeService) + { + doReturn(new ChildAssociationRef(assocType, parent, assocName, child)) + .when(mockedNodeService) + .getPrimaryParent(child); + } + + /** + * Helper method to make a number of nodes children of another. + *

+ * Assumes the cm:contains assoc type. + * + * @param parent + * @param children + */ + protected void makeChildrenOf(NodeRef parent, NodeRef ... children) + { + List assocs = new ArrayList(children.length); + for (NodeRef child : children) + { + assocs.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parent, generateQName(), child)); + doReturn(assocs).when(mockedNodeService).getParentAssocs(child); + } + doReturn(assocs).when(mockedNodeService).getChildAssocs(parent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + } + + @SuppressWarnings("unchecked") + protected List buildList(T ... values) + { + List result = new ArrayList(values.length); + for (T value : values) + { + result.add(value); + } + return result; + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseWebScriptUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseWebScriptUnitTest.java index 2a0f18a927..807610699c 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseWebScriptUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseWebScriptUnitTest.java @@ -1,269 +1,269 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import java.io.StringWriter; -import java.util.HashMap; -import java.util.Map; - -import org.json.JSONObject; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.springframework.extensions.surf.util.Content; -import org.springframework.extensions.webscripts.Container; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Description; -import org.springframework.extensions.webscripts.Description.RequiredCache; -import org.springframework.extensions.webscripts.DescriptionExtension; -import org.springframework.extensions.webscripts.FormatRegistry; -import org.springframework.extensions.webscripts.Match; -import org.springframework.extensions.webscripts.ScriptProcessorRegistry; -import org.springframework.extensions.webscripts.SearchPath; -import org.springframework.extensions.webscripts.TemplateProcessorRegistry; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.springframework.extensions.webscripts.WebScriptResponse; -import org.springframework.extensions.webscripts.json.JSONUtils; -import org.springframework.extensions.webscripts.processor.FTLTemplateProcessor; - -import freemarker.cache.ClassTemplateLoader; -import freemarker.cache.TemplateLoader; - -/** - * Base Web Script Unit Test. - *

- * Provides helper methods that mock the nessesery classes needed to execute - * a Java backed webscript that implements DeclarativeWebScript. - *

- * Note that execution of java script controllers is not currently supported. - * - * @author Roy Wetherall - * @since 2.2 - */ -public abstract class BaseWebScriptUnitTest extends BaseUnitTest -{ - /** web script root folder for RM webscripts */ - protected static final String WEBSCRIPT_ROOT_RM = "alfresco/templates/webscripts/org/alfresco/rma/"; - - /** - * @return declarative webscript - */ - protected abstract DeclarativeWebScript getWebScript(); - - /** - * @return classpath location of webscript template - */ - protected abstract String getWebScriptTemplate(); - - /** - * Helper method to build a map of web script parameter values - * mimicking those provided on the URL - * - * @param values - * @return - */ - protected Map buildParameters(String ... values) - { - Map result = new HashMap(values.length/2); - for (int i = 0; i < values.length; i=i+2) - { - String key = values[i]; - String value = values[i+1]; - result.put(key, value); - } - return result; - } - - /** - * - * @param parameters - * @return - * @throws Exception - */ - protected JSONObject executeJSONWebScript(Map parameters) throws Exception - { - return executeJSONWebScript(parameters, null); - } - - /** - * Execute web script and convert result into a JSON object. - * - * @param parameters map of all parameter values - * @return {@link JSONObject} result, parsed into a JSON object - */ - protected JSONObject executeJSONWebScript(Map parameters, String content) throws Exception - { - String result = executeWebScript(parameters, content); - return new JSONObject(result); - } - - /** - * - * @param parameters - * @return - * @throws Exception - */ - protected String executeWebScript(Map parameters) throws Exception - { - return executeWebScript( parameters, null); - } - - /** - * Execute web script and return result as a string. - * - * @param parameters map of all parameter values - * @return {@link String} result of web script - */ - protected String executeWebScript(Map parameters, String content) throws Exception - { - DeclarativeWebScript webScript = getWebScript(); - String template = getWebScriptTemplate(); - - // initialise webscript - webScript.init(getMockedContainer(template), getMockedDescription()); - - // execute webscript - WebScriptResponse mockedResponse = getMockedWebScriptResponse(); - webScript.execute(getMockedWebScriptRequest(webScript, parameters, content), mockedResponse); - - // return results - return mockedResponse.getWriter().toString(); - } - - /** - * Helper method to get the mocked web script request. - * - * @param webScript declarative web script - * @param parameters web script parameter values - * @return {@link WebScriptRequest} mocked web script request - */ - @SuppressWarnings("rawtypes") - protected WebScriptRequest getMockedWebScriptRequest(DeclarativeWebScript webScript, final Map parameters, String content) throws Exception - { - Match match = new Match(null, parameters, null, webScript); - org.springframework.extensions.webscripts.Runtime mockedRuntime = mock(org.springframework.extensions.webscripts.Runtime.class); - - WebScriptRequest mockedRequest = mock(WebScriptRequest.class); - doReturn(match).when(mockedRequest).getServiceMatch(); - doReturn(mockedRuntime).when(mockedRequest).getRuntime(); - - if (content != null && !content.isEmpty()) - { - Content mockedContent = mock(Content.class); - doReturn(content).when(mockedContent).getContent(); - doReturn(mockedContent).when(mockedRequest).getContent(); - } - - String [] paramNames = (String[])parameters.keySet().toArray(new String[parameters.size()]); - doReturn(paramNames).when(mockedRequest).getParameterNames(); - doAnswer(new Answer() - { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable - { - String paramName = (String)invocation.getArguments()[0]; - return parameters.get(paramName); - } - - }).when(mockedRequest).getParameter(anyString()); - - doReturn(new String[0]).when(mockedRequest).getHeaderNames(); - doReturn("json").when(mockedRequest).getFormat(); - - return mockedRequest; - } - - /** - * Helper method to get mocked web script response - * - * @return {@link WebScriptResponse} mocked web script response - */ - protected WebScriptResponse getMockedWebScriptResponse() throws Exception - { - WebScriptResponse mockedResponse = mock(WebScriptResponse.class); - StringWriter writer = new StringWriter(); - doReturn(writer).when(mockedResponse).getWriter(); - return mockedResponse; - } - - /** - * Helper method to get mocked container object. - * - * @param template classpath location of webscripts ftl template - * @return {@link Container} mocked container - */ - protected Container getMockedContainer(String template) throws Exception - { - FormatRegistry mockedFormatRegistry = mock(FormatRegistry.class); - doReturn("application/json").when(mockedFormatRegistry).getMimeType(anyString(), anyString()); - - ScriptProcessorRegistry mockedScriptProcessorRegistry = mock(ScriptProcessorRegistry.class); - doReturn(null).when(mockedScriptProcessorRegistry).findValidScriptPath(anyString()); - - TemplateProcessorRegistry mockedTemplateProcessorRegistry = mock(TemplateProcessorRegistry.class); - doReturn(template).when(mockedTemplateProcessorRegistry).findValidTemplatePath(anyString()); - - FTLTemplateProcessor ftlTemplateProcessor = new FTLTemplateProcessor() - { - @Override - protected TemplateLoader getTemplateLoader() - { - return new ClassTemplateLoader(getClass(), "/"); - } - }; - ftlTemplateProcessor.init(); - - doReturn(ftlTemplateProcessor).when(mockedTemplateProcessorRegistry).getTemplateProcessor(anyString()); - - Container mockedContainer = mock(Container.class); - doReturn(mockedFormatRegistry).when(mockedContainer).getFormatRegistry(); - doReturn(mockedScriptProcessorRegistry).when(mockedContainer).getScriptProcessorRegistry(); - doReturn(mockedTemplateProcessorRegistry).when(mockedContainer).getTemplateProcessorRegistry(); - - Map containerTemplateParameters = new HashMap(5); - containerTemplateParameters.put("jsonUtils", new JSONUtils()); - doReturn(containerTemplateParameters).when(mockedContainer).getTemplateParameters(); - - SearchPath mockedSearchPath = mock(SearchPath.class); - doReturn(false).when(mockedSearchPath).hasDocument(anyString()); - doReturn(mockedSearchPath).when(mockedContainer).getSearchPath(); - - // setup description - Description mockDescription = mock(Description.class); - doReturn(mock(RequiredCache.class)).when(mockDescription).getRequiredCache(); - - return mockedContainer; - } - - /** - * Helper method to get mocked description class - * - * @return {@link DescriptionExtension} mocked description class - */ - protected Description getMockedDescription() - { - Description mockedDescription = mock(Description.class); - doReturn(mock(RequiredCache.class)).when(mockedDescription).getRequiredCache(); - return mockedDescription; - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; + +import org.json.JSONObject; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.springframework.extensions.surf.util.Content; +import org.springframework.extensions.webscripts.Container; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Description; +import org.springframework.extensions.webscripts.Description.RequiredCache; +import org.springframework.extensions.webscripts.DescriptionExtension; +import org.springframework.extensions.webscripts.FormatRegistry; +import org.springframework.extensions.webscripts.Match; +import org.springframework.extensions.webscripts.ScriptProcessorRegistry; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.TemplateProcessorRegistry; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.json.JSONUtils; +import org.springframework.extensions.webscripts.processor.FTLTemplateProcessor; + +import freemarker.cache.ClassTemplateLoader; +import freemarker.cache.TemplateLoader; + +/** + * Base Web Script Unit Test. + *

+ * Provides helper methods that mock the nessesery classes needed to execute + * a Java backed webscript that implements DeclarativeWebScript. + *

+ * Note that execution of java script controllers is not currently supported. + * + * @author Roy Wetherall + * @since 2.2 + */ +public abstract class BaseWebScriptUnitTest extends BaseUnitTest +{ + /** web script root folder for RM webscripts */ + protected static final String WEBSCRIPT_ROOT_RM = "alfresco/templates/webscripts/org/alfresco/rma/"; + + /** + * @return declarative webscript + */ + protected abstract DeclarativeWebScript getWebScript(); + + /** + * @return classpath location of webscript template + */ + protected abstract String getWebScriptTemplate(); + + /** + * Helper method to build a map of web script parameter values + * mimicking those provided on the URL + * + * @param values + * @return + */ + protected Map buildParameters(String ... values) + { + Map result = new HashMap(values.length/2); + for (int i = 0; i < values.length; i=i+2) + { + String key = values[i]; + String value = values[i+1]; + result.put(key, value); + } + return result; + } + + /** + * + * @param parameters + * @return + * @throws Exception + */ + protected JSONObject executeJSONWebScript(Map parameters) throws Exception + { + return executeJSONWebScript(parameters, null); + } + + /** + * Execute web script and convert result into a JSON object. + * + * @param parameters map of all parameter values + * @return {@link JSONObject} result, parsed into a JSON object + */ + protected JSONObject executeJSONWebScript(Map parameters, String content) throws Exception + { + String result = executeWebScript(parameters, content); + return new JSONObject(result); + } + + /** + * + * @param parameters + * @return + * @throws Exception + */ + protected String executeWebScript(Map parameters) throws Exception + { + return executeWebScript( parameters, null); + } + + /** + * Execute web script and return result as a string. + * + * @param parameters map of all parameter values + * @return {@link String} result of web script + */ + protected String executeWebScript(Map parameters, String content) throws Exception + { + DeclarativeWebScript webScript = getWebScript(); + String template = getWebScriptTemplate(); + + // initialise webscript + webScript.init(getMockedContainer(template), getMockedDescription()); + + // execute webscript + WebScriptResponse mockedResponse = getMockedWebScriptResponse(); + webScript.execute(getMockedWebScriptRequest(webScript, parameters, content), mockedResponse); + + // return results + return mockedResponse.getWriter().toString(); + } + + /** + * Helper method to get the mocked web script request. + * + * @param webScript declarative web script + * @param parameters web script parameter values + * @return {@link WebScriptRequest} mocked web script request + */ + @SuppressWarnings("rawtypes") + protected WebScriptRequest getMockedWebScriptRequest(DeclarativeWebScript webScript, final Map parameters, String content) throws Exception + { + Match match = new Match(null, parameters, null, webScript); + org.springframework.extensions.webscripts.Runtime mockedRuntime = mock(org.springframework.extensions.webscripts.Runtime.class); + + WebScriptRequest mockedRequest = mock(WebScriptRequest.class); + doReturn(match).when(mockedRequest).getServiceMatch(); + doReturn(mockedRuntime).when(mockedRequest).getRuntime(); + + if (content != null && !content.isEmpty()) + { + Content mockedContent = mock(Content.class); + doReturn(content).when(mockedContent).getContent(); + doReturn(mockedContent).when(mockedRequest).getContent(); + } + + String [] paramNames = (String[])parameters.keySet().toArray(new String[parameters.size()]); + doReturn(paramNames).when(mockedRequest).getParameterNames(); + doAnswer(new Answer() + { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable + { + String paramName = (String)invocation.getArguments()[0]; + return parameters.get(paramName); + } + + }).when(mockedRequest).getParameter(anyString()); + + doReturn(new String[0]).when(mockedRequest).getHeaderNames(); + doReturn("json").when(mockedRequest).getFormat(); + + return mockedRequest; + } + + /** + * Helper method to get mocked web script response + * + * @return {@link WebScriptResponse} mocked web script response + */ + protected WebScriptResponse getMockedWebScriptResponse() throws Exception + { + WebScriptResponse mockedResponse = mock(WebScriptResponse.class); + StringWriter writer = new StringWriter(); + doReturn(writer).when(mockedResponse).getWriter(); + return mockedResponse; + } + + /** + * Helper method to get mocked container object. + * + * @param template classpath location of webscripts ftl template + * @return {@link Container} mocked container + */ + protected Container getMockedContainer(String template) throws Exception + { + FormatRegistry mockedFormatRegistry = mock(FormatRegistry.class); + doReturn("application/json").when(mockedFormatRegistry).getMimeType(anyString(), anyString()); + + ScriptProcessorRegistry mockedScriptProcessorRegistry = mock(ScriptProcessorRegistry.class); + doReturn(null).when(mockedScriptProcessorRegistry).findValidScriptPath(anyString()); + + TemplateProcessorRegistry mockedTemplateProcessorRegistry = mock(TemplateProcessorRegistry.class); + doReturn(template).when(mockedTemplateProcessorRegistry).findValidTemplatePath(anyString()); + + FTLTemplateProcessor ftlTemplateProcessor = new FTLTemplateProcessor() + { + @Override + protected TemplateLoader getTemplateLoader() + { + return new ClassTemplateLoader(getClass(), "/"); + } + }; + ftlTemplateProcessor.init(); + + doReturn(ftlTemplateProcessor).when(mockedTemplateProcessorRegistry).getTemplateProcessor(anyString()); + + Container mockedContainer = mock(Container.class); + doReturn(mockedFormatRegistry).when(mockedContainer).getFormatRegistry(); + doReturn(mockedScriptProcessorRegistry).when(mockedContainer).getScriptProcessorRegistry(); + doReturn(mockedTemplateProcessorRegistry).when(mockedContainer).getTemplateProcessorRegistry(); + + Map containerTemplateParameters = new HashMap(5); + containerTemplateParameters.put("jsonUtils", new JSONUtils()); + doReturn(containerTemplateParameters).when(mockedContainer).getTemplateParameters(); + + SearchPath mockedSearchPath = mock(SearchPath.class); + doReturn(false).when(mockedSearchPath).hasDocument(anyString()); + doReturn(mockedSearchPath).when(mockedContainer).getSearchPath(); + + // setup description + Description mockDescription = mock(Description.class); + doReturn(mock(RequiredCache.class)).when(mockDescription).getRequiredCache(); + + return mockedContainer; + } + + /** + * Helper method to get mocked description class + * + * @return {@link DescriptionExtension} mocked description class + */ + protected Description getMockedDescription() + { + Description mockedDescription = mock(Description.class); + doReturn(mock(RequiredCache.class)).when(mockedDescription).getRequiredCache(); + return mockedDescription; + } +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/WebScriptExceptionMatcher.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/WebScriptExceptionMatcher.java index 046b9fccf6..4e0d97748d 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/WebScriptExceptionMatcher.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/WebScriptExceptionMatcher.java @@ -1,80 +1,80 @@ -package org.alfresco.module.org_alfresco_module_rm.test.util; - -import org.junit.internal.matchers.TypeSafeMatcher; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; - -/** - * Web script exception matcher. - *

- * Allows use to check whether the raised web script exception has the correct - * status number or not. - * - * @author Roy Wetherall - * @since 2.2 - */ -@SuppressWarnings("deprecation") -public class WebScriptExceptionMatcher extends TypeSafeMatcher -{ - /** - * Helper method to create a matcher for the file not found (404) - * exception status. - * - * @return {@link WebScriptExceptionMatcher} - */ - public static WebScriptExceptionMatcher fileNotFound() - { - return new WebScriptExceptionMatcher(Status.STATUS_NOT_FOUND); - } - - /** - * Helper method to create a matcher for the bad request status (400) - * exception status. - * - * @return {@link WebScriptExceptionMatcher} - */ - public static WebScriptExceptionMatcher badRequest() - { - return new WebScriptExceptionMatcher(Status.STATUS_BAD_REQUEST); - } - - /** expected status */ - public int expectedStatus; - - /** actual status */ - public int actualStatus; - - /** - * Constructor - * - * @param expectedStatus expected status - */ - public WebScriptExceptionMatcher(int expectedStatus) - { - this.expectedStatus = expectedStatus; - } - - /** - * Determines if the expected outcome matches the actual - * outcome. - * - * @return true if matches, false otherwise - */ - @Override - public boolean matchesSafely(WebScriptException exception) - { - actualStatus = exception.getStatus(); - return (actualStatus == expectedStatus); - } - - /** - * Describe unexpected outcome. - */ - @Override - public void describeTo(org.hamcrest.Description description) - { - description.appendValue(actualStatus) - .appendText(" was found instead of ") - .appendValue(expectedStatus); - } +package org.alfresco.module.org_alfresco_module_rm.test.util; + +import org.junit.internal.matchers.TypeSafeMatcher; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; + +/** + * Web script exception matcher. + *

+ * Allows use to check whether the raised web script exception has the correct + * status number or not. + * + * @author Roy Wetherall + * @since 2.2 + */ +@SuppressWarnings("deprecation") +public class WebScriptExceptionMatcher extends TypeSafeMatcher +{ + /** + * Helper method to create a matcher for the file not found (404) + * exception status. + * + * @return {@link WebScriptExceptionMatcher} + */ + public static WebScriptExceptionMatcher fileNotFound() + { + return new WebScriptExceptionMatcher(Status.STATUS_NOT_FOUND); + } + + /** + * Helper method to create a matcher for the bad request status (400) + * exception status. + * + * @return {@link WebScriptExceptionMatcher} + */ + public static WebScriptExceptionMatcher badRequest() + { + return new WebScriptExceptionMatcher(Status.STATUS_BAD_REQUEST); + } + + /** expected status */ + public int expectedStatus; + + /** actual status */ + public int actualStatus; + + /** + * Constructor + * + * @param expectedStatus expected status + */ + public WebScriptExceptionMatcher(int expectedStatus) + { + this.expectedStatus = expectedStatus; + } + + /** + * Determines if the expected outcome matches the actual + * outcome. + * + * @return true if matches, false otherwise + */ + @Override + public boolean matchesSafely(WebScriptException exception) + { + actualStatus = exception.getStatus(); + return (actualStatus == expectedStatus); + } + + /** + * Describe unexpected outcome. + */ + @Override + public void describeTo(org.hamcrest.Description description) + { + description.appendValue(actualStatus) + .appendText(" was found instead of ") + .appendValue(expectedStatus); + } } \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspectUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspectUnitTest.java index 8b6acb4195..4fbe955c3b 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspectUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/ExtendedVersionableAspectUnitTest.java @@ -1,400 +1,400 @@ -/* - * Copyright (C) 2005-2015 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.version; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.times; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.lock.LockService; -import org.alfresco.service.cmr.lock.LockStatus; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.springframework.extensions.webscripts.GUID; - -/** - * Extended versionable aspect unit test. - * - * @author Roy Wetherall - * @since 2.3.1 - */ -public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel -{ - /** Transaction resource key */ - private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs"; - - /** test data */ - private NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); - private NodeRef anotherNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); - private QName oldType = QName.createQName(RM_URI, GUID.generate()); - private QName newType = QName.createQName(RM_URI, GUID.generate()); - - /** service mocks */ - private @Mock NodeService mockedNodeService; - private @Mock VersionService mockedVersionService; - private @Mock LockService mockedLockService; - private @Mock AlfrescoTransactionSupport mockedAlfrescoTransactionSupport; - private @Mock AuthenticationUtil mockedAuthenticationUtil; - - /** test instance of extended versionable aspect behaviour bean */ - private @InjectMocks ExtendedVersionableAspect extendedVersionableAspect; - - @SuppressWarnings("unchecked") - @Before - public void testSetup() - { - MockitoAnnotations.initMocks(this); - - // just do the work - doAnswer(new Answer() - { - @SuppressWarnings("rawtypes") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable - { - RunAsWork work = (RunAsWork)invocation.getArguments()[0]; - return work.doWork(); - } - - }).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class)); - } - - /** - * given that autoversion on type change is configured off - * when the type set behvaiour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void autoVersionOff() - { - // auto version off - extendedVersionableAspect.setAutoVersionOnTypeChange(false); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given the node doesn't exist - * when the type set behaviour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void nodeDoesNotExist() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does not exist - when(mockedNodeService.exists(nodeRef)) - .thenReturn(false); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that the node is locked - * when the type set behaviour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void nodeLocked() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.LOCKED); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that the node does not have the versionable aspect - * when the type set behaviour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void nodeIsNotVersionable() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is not locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.NO_LOCK); - - // node does not have the versionable aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(false); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - verify(mockedLockService).getLockStatus(nodeRef); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that the node has the temporary aspect - * when the type set behaviour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void nodeIsTemporary() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is not locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.NO_LOCK); - - // node has the versionable aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(true); - - // node has the temporary aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) - .thenReturn(true); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - verify(mockedLockService).getLockStatus(nodeRef); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that the node is already being versioned - * when the type set behvaiour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void nodeIsBeingVersioned() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is not locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.NO_LOCK); - - // node has the versionable aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(true); - - // node does not have the temporary aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) - .thenReturn(false); - - // node is currently being processed for versioning - when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) - .thenReturn(Collections.singletonMap(nodeRef, nodeRef)); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - verify(mockedLockService).getLockStatus(nodeRef); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that the node has the auto version property set to false - * when the type set behaviour is executed - * then a new version is not created - */ - @SuppressWarnings("unchecked") - @Test - public void autoVersionFalse() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is not locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.NO_LOCK); - - // node has the versionable aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(true); - - // node does not have the temporary aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) - .thenReturn(false); - - // node is not being processed for versioning - when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) - .thenReturn(Collections.singletonMap(anotherNodeRef, anotherNodeRef)); - - // auto version false - when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) - .thenReturn(Boolean.FALSE); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - verify(mockedLockService).getLockStatus(nodeRef); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); - verify(mockedAlfrescoTransactionSupport).getResource(KEY_VERSIONED_NODEREFS); - - // assert the version was not created - verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); - } - - /** - * given that autoversion on type change is configured on - * and the node exists - * and the node is not locked - * and the node has the versionable aspect - * and the node doesn't have the temporary aspect - * and the node isn't already being versioned - * and the auto version property is true - * when the type set behavour is executed - * then a new version is created - */ - @SuppressWarnings("unchecked") - @Test - public void createVersion() - { - // auto version on - extendedVersionableAspect.setAutoVersionOnTypeChange(true); - - // node does exists - when(mockedNodeService.exists(nodeRef)) - .thenReturn(true); - - // node is not locked - when(mockedLockService.getLockStatus(nodeRef)) - .thenReturn(LockStatus.NO_LOCK); - - // node has the versionable aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(true); - - // node does not have the temporary aspect - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) - .thenReturn(false); - - // node is not being processed for versioning - when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) - .thenReturn(new HashMap(Collections.singletonMap(anotherNodeRef, anotherNodeRef))); - - // auto version false - when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) - .thenReturn(Boolean.TRUE); - - // execute behaviour - extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); - - // verify other - verify(mockedNodeService).exists(nodeRef); - verify(mockedLockService).getLockStatus(nodeRef); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); - verify(mockedAlfrescoTransactionSupport, times(2)).getResource(KEY_VERSIONED_NODEREFS); - verify(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION); - - // assert the version was not created - verify(mockedVersionService).createVersion(eq(nodeRef), any(Map.class)); - } - -} +/* + * Copyright (C) 2005-2015 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.version; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.times; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport; +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.service.cmr.lock.LockService; +import org.alfresco.service.cmr.lock.LockStatus; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.namespace.QName; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.springframework.extensions.webscripts.GUID; + +/** + * Extended versionable aspect unit test. + * + * @author Roy Wetherall + * @since 2.3.1 + */ +public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel +{ + /** Transaction resource key */ + private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs"; + + /** test data */ + private NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); + private NodeRef anotherNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); + private QName oldType = QName.createQName(RM_URI, GUID.generate()); + private QName newType = QName.createQName(RM_URI, GUID.generate()); + + /** service mocks */ + private @Mock NodeService mockedNodeService; + private @Mock VersionService mockedVersionService; + private @Mock LockService mockedLockService; + private @Mock AlfrescoTransactionSupport mockedAlfrescoTransactionSupport; + private @Mock AuthenticationUtil mockedAuthenticationUtil; + + /** test instance of extended versionable aspect behaviour bean */ + private @InjectMocks ExtendedVersionableAspect extendedVersionableAspect; + + @SuppressWarnings("unchecked") + @Before + public void testSetup() + { + MockitoAnnotations.initMocks(this); + + // just do the work + doAnswer(new Answer() + { + @SuppressWarnings("rawtypes") + @Override + public Object answer(InvocationOnMock invocation) throws Throwable + { + RunAsWork work = (RunAsWork)invocation.getArguments()[0]; + return work.doWork(); + } + + }).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class)); + } + + /** + * given that autoversion on type change is configured off + * when the type set behvaiour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void autoVersionOff() + { + // auto version off + extendedVersionableAspect.setAutoVersionOnTypeChange(false); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given the node doesn't exist + * when the type set behaviour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void nodeDoesNotExist() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does not exist + when(mockedNodeService.exists(nodeRef)) + .thenReturn(false); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that the node is locked + * when the type set behaviour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void nodeLocked() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.LOCKED); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that the node does not have the versionable aspect + * when the type set behaviour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void nodeIsNotVersionable() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is not locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.NO_LOCK); + + // node does not have the versionable aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(false); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + verify(mockedLockService).getLockStatus(nodeRef); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that the node has the temporary aspect + * when the type set behaviour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void nodeIsTemporary() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is not locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.NO_LOCK); + + // node has the versionable aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(true); + + // node has the temporary aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) + .thenReturn(true); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + verify(mockedLockService).getLockStatus(nodeRef); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that the node is already being versioned + * when the type set behvaiour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void nodeIsBeingVersioned() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is not locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.NO_LOCK); + + // node has the versionable aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(true); + + // node does not have the temporary aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) + .thenReturn(false); + + // node is currently being processed for versioning + when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) + .thenReturn(Collections.singletonMap(nodeRef, nodeRef)); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + verify(mockedLockService).getLockStatus(nodeRef); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that the node has the auto version property set to false + * when the type set behaviour is executed + * then a new version is not created + */ + @SuppressWarnings("unchecked") + @Test + public void autoVersionFalse() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is not locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.NO_LOCK); + + // node has the versionable aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(true); + + // node does not have the temporary aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) + .thenReturn(false); + + // node is not being processed for versioning + when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) + .thenReturn(Collections.singletonMap(anotherNodeRef, anotherNodeRef)); + + // auto version false + when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) + .thenReturn(Boolean.FALSE); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + verify(mockedLockService).getLockStatus(nodeRef); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); + verify(mockedAlfrescoTransactionSupport).getResource(KEY_VERSIONED_NODEREFS); + + // assert the version was not created + verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); + } + + /** + * given that autoversion on type change is configured on + * and the node exists + * and the node is not locked + * and the node has the versionable aspect + * and the node doesn't have the temporary aspect + * and the node isn't already being versioned + * and the auto version property is true + * when the type set behavour is executed + * then a new version is created + */ + @SuppressWarnings("unchecked") + @Test + public void createVersion() + { + // auto version on + extendedVersionableAspect.setAutoVersionOnTypeChange(true); + + // node does exists + when(mockedNodeService.exists(nodeRef)) + .thenReturn(true); + + // node is not locked + when(mockedLockService.getLockStatus(nodeRef)) + .thenReturn(LockStatus.NO_LOCK); + + // node has the versionable aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(true); + + // node does not have the temporary aspect + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) + .thenReturn(false); + + // node is not being processed for versioning + when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) + .thenReturn(new HashMap(Collections.singletonMap(anotherNodeRef, anotherNodeRef))); + + // auto version false + when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) + .thenReturn(Boolean.TRUE); + + // execute behaviour + extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); + + // verify other + verify(mockedNodeService).exists(nodeRef); + verify(mockedLockService).getLockStatus(nodeRef); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); + verify(mockedAlfrescoTransactionSupport, times(2)).getResource(KEY_VERSIONED_NODEREFS); + verify(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION); + + // assert the version was not created + verify(mockedVersionService).createVersion(eq(nodeRef), any(Map.class)); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImplUnitTest.java index 19dd235cae..a3985b779e 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImplUnitTest.java @@ -1,661 +1,661 @@ -/* - * Copyright (C) 2005-2015 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.version; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.repo.version.Version2Model; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.repo.version.common.VersionImpl; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -/** - * Recordable version service implementation unit test. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class RecordableVersionServiceImplUnitTest extends BaseUnitTest -{ - /** versioned content name */ - private static final String CONTENT_NAME = "test.txt"; - - /** versioned node reference */ - private NodeRef nodeRef; - private NodeRef record; - private NodeRef unfiledRecordContainer; - private NodeRef version; - - /** mocked version properties */ - private Map versionProperties; - - /** mocked services */ - private @Mock(name="dbNodeService") NodeService mockedDbNodeService; - - /** recordable version service */ - private @InjectMocks @Spy TestRecordableVersionServiceImpl recordableVersionService; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() - */ - @SuppressWarnings("unchecked") - @Override - public void before() throws Exception - { - super.before(); - - nodeRef = generateCmContent(CONTENT_NAME); - doReturn(123l).when(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_NODE_DBID); - - versionProperties = new HashMap(5); - - recordableVersionService.initialise(); - - doReturn(generateChildAssociationRef(null, generateNodeRef(Version2Model.TYPE_QNAME_VERSION_HISTORY))) - .when(mockedDbNodeService).createNode(any(NodeRef.class), - any(QName.class), - any(QName.class), - eq(Version2Model.TYPE_QNAME_VERSION_HISTORY), - anyMap()); - doReturn(generateChildAssociationRef(null, generateNodeRef(TYPE_CONTENT))) - .when(mockedDbNodeService).createNode(any(NodeRef.class), - any(QName.class), - any(QName.class), - eq(TYPE_CONTENT), - anyMap()); - - doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - doReturn(unfiledRecordContainer).when(mockedFilePlanService).getUnfiledContainer(any(NodeRef.class)); - - record = generateCmContent(CONTENT_NAME); - FileInfo mockedFileInfo = mock(FileInfo.class); - doReturn(record).when(mockedFileInfo).getNodeRef(); - doReturn(mockedFileInfo).when(mockedFileFolderService).copy(any(NodeRef.class), - any(NodeRef.class), - any(String.class)); - version = generateNodeRef(TYPE_CONTENT); - doReturn(generateChildAssociationRef(null, version)).when(mockedDbNodeService).createNode( - any(NodeRef.class), - eq(Version2Model.CHILD_QNAME_VERSIONS), - any(QName.class), - eq(TYPE_CONTENT), - anyMap()); - } - - /** - * Given that the node has no recordable version aspect - * When I create a version - * Then version service creates a normal version. - */ - @Test - public void noAspect() throws Exception - { - // setup given conditions - doReturn(false).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then a normal version is created - verifyNormalVersion(); - } - - /** - * Given that the node has a recordable version policy of null - * When I create a version - * Then the version service creates a normal version. - */ - @Test - public void policyNull() throws Exception - { - // setup given conditions - doReturn(false).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(null).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then a normal version is created - verifyNormalVersion(); - } - - /** - * Given that the node has a recordable version policy of NONE - * When I create a version - * Then the version service creates a normal version. - */ - @Test - public void policyNone() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.NONE.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then a normal version is created - verifyNormalVersion(); - } - - /** - * Given that the node has a recordable version policy of ALL - * When I create a MINOR version then - * the version service creates a recorded version - */ - @Test - public void policyAllVersionMinor() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.ALL.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); - } - - /** - * Helper method that verified that a recorded version was not created. - */ - @SuppressWarnings("unchecked") - private void verifyNormalVersion() throws Exception - { - // verify no interactions - verify(mockedFilePlanService, never()).getUnfiledContainer(any(NodeRef.class)); - verify(mockedFileFolderService, never()).copy(eq(nodeRef), - eq(unfiledRecordContainer), - anyString()); - - // then the version is created - verify(mockedDbNodeService, times(1)).createNode(any(NodeRef.class), - eq(Version2Model.CHILD_QNAME_VERSIONS), - any(QName.class), - eq(TYPE_CONTENT), - anyMap()); - verify(mockedNodeService, times(1)).addAspect(eq(version), eq(Version2Model.ASPECT_VERSION), anyMap()); - verify(mockedNodeService, never()).addAspect(eq(version), eq(RecordableVersionModel.PROP_RECORD_NODE_REF), anyMap()); - } - - /** - * Given that the node has a recordable version policy of ALL - * When I create a MAJOR version then - * the version service creates a recorded version - */ - @Test - public void policyAllVersionMajor() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.ALL.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); - - } - - /** - * Given that the node has a recordable version policy of MAJOR_ONLY - * When I create a MINOR version then - * the version service creates a normal version - */ - @Test - public void policyMajorOnlyVersionMinor() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then a normal version is created - verifyNormalVersion(); - } - - /** - * Given that the node has a recordable version policy of MAJOR_ONLY - * When I create a MAJOR version then - * the version service creates a recorded version - */ - @Test - public void policyMajorOnlyVersionMajor() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); - } - - /** - * Given that the node has a valid recordable version policy - * And there is no file plan - * When I create a new version - * Then an exception should be thrown to indicate that there is no file plan - */ - @Test - public void noFilePlan() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - doReturn(null).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - - // expected exception - exception.expect(AlfrescoRuntimeException.class); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - } - - /** - * Given that the node has a valid recordable version policy - * And that I set a specific file plan in the version properties - * When I create a new version - * Then the recorded version should be directed to the specified file plan, not the default file plan - */ - @Test - public void filePlanSpecifiedWithPolicy() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - - // specify the file plan - NodeRef anotherFilePlan = generateNodeRef(TYPE_FILE_PLAN); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, anotherFilePlan); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(0)).createRecordFromCopy(filePlan, nodeRef); - } - - /** - * Given that the node has specifically indicated that a recorded version should be created - * And that I set a specific file plan in the version properties - * When I create a new version - * Then the recorded version should be directed to the specified file plan, not the default file plan - */ - @Test - public void filePlanSpecifiedNoPolicy() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - - // specify the file plan - NodeRef anotherFilePlan = generateNodeRef(TYPE_FILE_PLAN); - versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, anotherFilePlan); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(0)).createRecordFromCopy(filePlan, nodeRef); - } - - @Test - public void adHocRecordedVersionNoPolicy() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); - } - - @Test - public void adHocRecordedVersionOverridePolicy() throws Exception - { - // setup given conditions - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); - doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); - - // when version is created - recordableVersionService.createVersion(nodeRef, versionProperties); - - // then the recorded version is created - verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); - } - - /** - * Given that a node is not versionable - * When I try and create a record from the latest version - * Then nothing will happen, because there is not version to record - */ - @Test - public void notVersionableCreateRecordFromVersion() - { - // content node is not versionable - doReturn(false).when(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - - // create record from version - recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); - - // nothing happens - verify(mockedRecordService, never()).createRecordFromCopy(eq(filePlan), any(NodeRef.class)); - } - - /** - * Given that a nodes last version is recorded - * When I try and create a record from the latest version - * Then nothing will happen, because the latest version is already recorded - */ - @Test - public void alreadyRecordedCreateRecordFromVersion() - { - // latest version is already recorded - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - - when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) - .thenReturn(true); - when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) - .thenReturn(true); - doReturn(mockedVersion) - .when(recordableVersionService).getCurrentVersion(nodeRef); - - // create record from version - recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); - - // nothing happens - verify(mockedRecordService, never()).createRecordFromCopy(eq(filePlan), any(NodeRef.class)); - } - - /** - * Given that a nodes last version is not recorded - * When I try to create a record from the latest version - * Then the latest version is marked as record and a new record version is created to store the version state - */ - @SuppressWarnings("unchecked") - @Test - public void notRecordedCreateRecordFromVersion() - { - // latest version is not recorded - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - doReturn(Collections.emptyMap()).when(mockedVersion).getVersionProperties(); - doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); - - // version history - NodeRef versionHistoryNodeRef = generateNodeRef(); - doReturn(versionHistoryNodeRef).when(mockedDbNodeService).getChildByName(any(NodeRef.class), eq(Version2Model.CHILD_QNAME_VERSION_HISTORIES), any(String.class)); - - // version number - doReturn(mockedVersion).when(recordableVersionService).getCurrentVersion(nodeRef); - doReturn(versionNodeRef).when(recordableVersionService).convertNodeRef(any(NodeRef.class)); - makePrimaryParentOf(versionNodeRef, versionHistoryNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "something-0"), mockedDbNodeService); - - // created version - NodeRef newVersionNodeRef = generateNodeRef(); - doReturn(generateChildAssociationRef(versionHistoryNodeRef, newVersionNodeRef)).when(mockedDbNodeService).createNode( - eq(versionHistoryNodeRef), - eq(Version2Model.CHILD_QNAME_VERSIONS), - any(QName.class), - any(QName.class), - any(Map.class)); - - // created record - NodeRef newRecordNodeRef = generateNodeRef(); - doReturn(newRecordNodeRef).when(mockedRecordService).createRecordFromContent( - eq(filePlan), - any(String.class), - any(QName.class), - any(Map.class), - any(ContentReader.class)); - - // create record from version - recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); - - // verify that the version is converted to a recorded version - verify(mockedRecordService, times(1)).createRecordFromContent( - eq(filePlan), - any(String.class), - any(QName.class), - any(Map.class), - any(ContentReader.class)); - verify(mockedDbNodeService, times(1)).deleteNode(any(NodeRef.class)); - verify(mockedDbNodeService, times(1)).createNode( - eq(versionHistoryNodeRef), - eq(Version2Model.CHILD_QNAME_VERSIONS), - any(QName.class), - any(QName.class), - any(Map.class)); - verify(mockedNodeService, times(1)).addAspect(eq(newVersionNodeRef), eq(Version2Model.ASPECT_VERSION), any(Map.class)); - verify(mockedNodeService, times(1)).addAspect( - newVersionNodeRef, - RecordableVersionModel.ASPECT_RECORDED_VERSION, - Collections.singletonMap(RecordableVersionModel.PROP_RECORD_NODE_REF, (Serializable)newRecordNodeRef)); - } - - - /** - * given the destroyed prop isn't set - * when I ask if the version is destroyed - * then the result is false - */ - @Test - public void propNotSetVersionNotDestroyed() - { - // set up version - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - - // set prop not set - when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) - .thenReturn(null); - - // is version destroyed - assertFalse(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); - } - - /** - * given the destroyed prop is set - * when I ask if the version is destroyed - * then the result matches the value set in the destroy property - */ - @Test - public void propSetVersionDestroyed() - { - // set up version - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - - // set prop - when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) - .thenReturn(Boolean.TRUE); - - // is version destroyed - assertTrue(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); - - // set prop - when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) - .thenReturn(Boolean.FALSE); - - // is version destroyed - assertFalse(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); - } - - /** - * given that the version node doesn't have the recorded version aspect applied - * when I mark the version as destroyed - * then nothing happens - */ - @Test - public void noAspectMarkAsDestroyed() - { - // set up version - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - - // indicate that the version doesn't have the aspect - when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) - .thenReturn(false); - - // mark as destroyed - recordableVersionService.destroyRecordedVersion(mockedVersion); - - // verify nothing happened - verify(mockedDbNodeService, never()) - .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); - } - - /** - * given that the version node ref has the recorded version aspect applied - * and the record version reference exists - * when I mark the version as destroyed - * then the version is marked as destroyed - */ - @Test - public void markAsDestroyed() - { - // set up version - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - NodeRef versionRecordNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - when(mockedDbNodeService.exists(versionRecordNodeRef)) - .thenReturn(true); - - // indicate that the version doesn't have the aspect - when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) - .thenReturn(true); - - // indicate that the associated version record exists - when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF)) - .thenReturn(versionRecordNodeRef); - - // mark as destroyed - recordableVersionService.destroyRecordedVersion(mockedVersion); - - // verify that the version was marked as destroyed - verify(mockedDbNodeService) - .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); - // and the reference to the version record was cleared - verify(mockedDbNodeService) - .setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); - } - - /** - * given that the version node ref has the recorded version aspect applied - * and the associated version record has been deleted - * when I mark the version as destroyed - * then the version is marked as destroyed - * and the reference to the deleted version record is removed - */ - @Test - public void markAsDestroyedClearNodeRef() - { - // set up version - Version mockedVersion = mock(VersionImpl.class); - NodeRef versionNodeRef = generateNodeRef(); - NodeRef versionRecordNodeRef = generateNodeRef(); - when(mockedVersion.getFrozenStateNodeRef()) - .thenReturn(versionNodeRef); - when(mockedDbNodeService.exists(versionRecordNodeRef)) - .thenReturn(false); - - // indicate that the version doesn't have the aspect - when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) - .thenReturn(true); - - // indicate that the associated version record exists - when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF)) - .thenReturn(versionRecordNodeRef); - - // mark as destroyed - recordableVersionService.destroyRecordedVersion(mockedVersion); - - // verify that the version was marked as destroyed - verify(mockedDbNodeService) - .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); - // and the reference to the version record was cleared - verify(mockedDbNodeService) - .setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); - } +/* + * Copyright (C) 2005-2015 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.version; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.repo.version.Version2Model; +import org.alfresco.repo.version.VersionModel; +import org.alfresco.repo.version.common.VersionImpl; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionType; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; + +/** + * Recordable version service implementation unit test. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class RecordableVersionServiceImplUnitTest extends BaseUnitTest +{ + /** versioned content name */ + private static final String CONTENT_NAME = "test.txt"; + + /** versioned node reference */ + private NodeRef nodeRef; + private NodeRef record; + private NodeRef unfiledRecordContainer; + private NodeRef version; + + /** mocked version properties */ + private Map versionProperties; + + /** mocked services */ + private @Mock(name="dbNodeService") NodeService mockedDbNodeService; + + /** recordable version service */ + private @InjectMocks @Spy TestRecordableVersionServiceImpl recordableVersionService; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest#before() + */ + @SuppressWarnings("unchecked") + @Override + public void before() throws Exception + { + super.before(); + + nodeRef = generateCmContent(CONTENT_NAME); + doReturn(123l).when(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_NODE_DBID); + + versionProperties = new HashMap(5); + + recordableVersionService.initialise(); + + doReturn(generateChildAssociationRef(null, generateNodeRef(Version2Model.TYPE_QNAME_VERSION_HISTORY))) + .when(mockedDbNodeService).createNode(any(NodeRef.class), + any(QName.class), + any(QName.class), + eq(Version2Model.TYPE_QNAME_VERSION_HISTORY), + anyMap()); + doReturn(generateChildAssociationRef(null, generateNodeRef(TYPE_CONTENT))) + .when(mockedDbNodeService).createNode(any(NodeRef.class), + any(QName.class), + any(QName.class), + eq(TYPE_CONTENT), + anyMap()); + + doReturn(filePlan).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + doReturn(unfiledRecordContainer).when(mockedFilePlanService).getUnfiledContainer(any(NodeRef.class)); + + record = generateCmContent(CONTENT_NAME); + FileInfo mockedFileInfo = mock(FileInfo.class); + doReturn(record).when(mockedFileInfo).getNodeRef(); + doReturn(mockedFileInfo).when(mockedFileFolderService).copy(any(NodeRef.class), + any(NodeRef.class), + any(String.class)); + version = generateNodeRef(TYPE_CONTENT); + doReturn(generateChildAssociationRef(null, version)).when(mockedDbNodeService).createNode( + any(NodeRef.class), + eq(Version2Model.CHILD_QNAME_VERSIONS), + any(QName.class), + eq(TYPE_CONTENT), + anyMap()); + } + + /** + * Given that the node has no recordable version aspect + * When I create a version + * Then version service creates a normal version. + */ + @Test + public void noAspect() throws Exception + { + // setup given conditions + doReturn(false).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then a normal version is created + verifyNormalVersion(); + } + + /** + * Given that the node has a recordable version policy of null + * When I create a version + * Then the version service creates a normal version. + */ + @Test + public void policyNull() throws Exception + { + // setup given conditions + doReturn(false).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(null).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then a normal version is created + verifyNormalVersion(); + } + + /** + * Given that the node has a recordable version policy of NONE + * When I create a version + * Then the version service creates a normal version. + */ + @Test + public void policyNone() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.NONE.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then a normal version is created + verifyNormalVersion(); + } + + /** + * Given that the node has a recordable version policy of ALL + * When I create a MINOR version then + * the version service creates a recorded version + */ + @Test + public void policyAllVersionMinor() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.ALL.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); + } + + /** + * Helper method that verified that a recorded version was not created. + */ + @SuppressWarnings("unchecked") + private void verifyNormalVersion() throws Exception + { + // verify no interactions + verify(mockedFilePlanService, never()).getUnfiledContainer(any(NodeRef.class)); + verify(mockedFileFolderService, never()).copy(eq(nodeRef), + eq(unfiledRecordContainer), + anyString()); + + // then the version is created + verify(mockedDbNodeService, times(1)).createNode(any(NodeRef.class), + eq(Version2Model.CHILD_QNAME_VERSIONS), + any(QName.class), + eq(TYPE_CONTENT), + anyMap()); + verify(mockedNodeService, times(1)).addAspect(eq(version), eq(Version2Model.ASPECT_VERSION), anyMap()); + verify(mockedNodeService, never()).addAspect(eq(version), eq(RecordableVersionModel.PROP_RECORD_NODE_REF), anyMap()); + } + + /** + * Given that the node has a recordable version policy of ALL + * When I create a MAJOR version then + * the version service creates a recorded version + */ + @Test + public void policyAllVersionMajor() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.ALL.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); + + } + + /** + * Given that the node has a recordable version policy of MAJOR_ONLY + * When I create a MINOR version then + * the version service creates a normal version + */ + @Test + public void policyMajorOnlyVersionMinor() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then a normal version is created + verifyNormalVersion(); + } + + /** + * Given that the node has a recordable version policy of MAJOR_ONLY + * When I create a MAJOR version then + * the version service creates a recorded version + */ + @Test + public void policyMajorOnlyVersionMajor() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); + } + + /** + * Given that the node has a valid recordable version policy + * And there is no file plan + * When I create a new version + * Then an exception should be thrown to indicate that there is no file plan + */ + @Test + public void noFilePlan() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + doReturn(null).when(mockedFilePlanService).getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + + // expected exception + exception.expect(AlfrescoRuntimeException.class); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + } + + /** + * Given that the node has a valid recordable version policy + * And that I set a specific file plan in the version properties + * When I create a new version + * Then the recorded version should be directed to the specified file plan, not the default file plan + */ + @Test + public void filePlanSpecifiedWithPolicy() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + + // specify the file plan + NodeRef anotherFilePlan = generateNodeRef(TYPE_FILE_PLAN); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, anotherFilePlan); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(0)).createRecordFromCopy(filePlan, nodeRef); + } + + /** + * Given that the node has specifically indicated that a recorded version should be created + * And that I set a specific file plan in the version properties + * When I create a new version + * Then the recorded version should be directed to the specified file plan, not the default file plan + */ + @Test + public void filePlanSpecifiedNoPolicy() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + + // specify the file plan + NodeRef anotherFilePlan = generateNodeRef(TYPE_FILE_PLAN); + versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, anotherFilePlan); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(0)).createRecordFromCopy(filePlan, nodeRef); + } + + @Test + public void adHocRecordedVersionNoPolicy() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); + } + + @Test + public void adHocRecordedVersionOverridePolicy() throws Exception + { + // setup given conditions + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, RecordableVersionModel.ASPECT_VERSIONABLE); + doReturn(RecordableVersionPolicy.MAJOR_ONLY.toString()).when(mockedNodeService).getProperty(nodeRef, RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true); + + // when version is created + recordableVersionService.createVersion(nodeRef, versionProperties); + + // then the recorded version is created + verify(mockedRecordService, times(1)).createRecordFromCopy(filePlan, nodeRef); + } + + /** + * Given that a node is not versionable + * When I try and create a record from the latest version + * Then nothing will happen, because there is not version to record + */ + @Test + public void notVersionableCreateRecordFromVersion() + { + // content node is not versionable + doReturn(false).when(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + + // create record from version + recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); + + // nothing happens + verify(mockedRecordService, never()).createRecordFromCopy(eq(filePlan), any(NodeRef.class)); + } + + /** + * Given that a nodes last version is recorded + * When I try and create a record from the latest version + * Then nothing will happen, because the latest version is already recorded + */ + @Test + public void alreadyRecordedCreateRecordFromVersion() + { + // latest version is already recorded + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + + when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + .thenReturn(true); + when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) + .thenReturn(true); + doReturn(mockedVersion) + .when(recordableVersionService).getCurrentVersion(nodeRef); + + // create record from version + recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); + + // nothing happens + verify(mockedRecordService, never()).createRecordFromCopy(eq(filePlan), any(NodeRef.class)); + } + + /** + * Given that a nodes last version is not recorded + * When I try to create a record from the latest version + * Then the latest version is marked as record and a new record version is created to store the version state + */ + @SuppressWarnings("unchecked") + @Test + public void notRecordedCreateRecordFromVersion() + { + // latest version is not recorded + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + doReturn(Collections.emptyMap()).when(mockedVersion).getVersionProperties(); + doReturn(true).when(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); + + // version history + NodeRef versionHistoryNodeRef = generateNodeRef(); + doReturn(versionHistoryNodeRef).when(mockedDbNodeService).getChildByName(any(NodeRef.class), eq(Version2Model.CHILD_QNAME_VERSION_HISTORIES), any(String.class)); + + // version number + doReturn(mockedVersion).when(recordableVersionService).getCurrentVersion(nodeRef); + doReturn(versionNodeRef).when(recordableVersionService).convertNodeRef(any(NodeRef.class)); + makePrimaryParentOf(versionNodeRef, versionHistoryNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "something-0"), mockedDbNodeService); + + // created version + NodeRef newVersionNodeRef = generateNodeRef(); + doReturn(generateChildAssociationRef(versionHistoryNodeRef, newVersionNodeRef)).when(mockedDbNodeService).createNode( + eq(versionHistoryNodeRef), + eq(Version2Model.CHILD_QNAME_VERSIONS), + any(QName.class), + any(QName.class), + any(Map.class)); + + // created record + NodeRef newRecordNodeRef = generateNodeRef(); + doReturn(newRecordNodeRef).when(mockedRecordService).createRecordFromContent( + eq(filePlan), + any(String.class), + any(QName.class), + any(Map.class), + any(ContentReader.class)); + + // create record from version + recordableVersionService.createRecordFromLatestVersion(filePlan, nodeRef); + + // verify that the version is converted to a recorded version + verify(mockedRecordService, times(1)).createRecordFromContent( + eq(filePlan), + any(String.class), + any(QName.class), + any(Map.class), + any(ContentReader.class)); + verify(mockedDbNodeService, times(1)).deleteNode(any(NodeRef.class)); + verify(mockedDbNodeService, times(1)).createNode( + eq(versionHistoryNodeRef), + eq(Version2Model.CHILD_QNAME_VERSIONS), + any(QName.class), + any(QName.class), + any(Map.class)); + verify(mockedNodeService, times(1)).addAspect(eq(newVersionNodeRef), eq(Version2Model.ASPECT_VERSION), any(Map.class)); + verify(mockedNodeService, times(1)).addAspect( + newVersionNodeRef, + RecordableVersionModel.ASPECT_RECORDED_VERSION, + Collections.singletonMap(RecordableVersionModel.PROP_RECORD_NODE_REF, (Serializable)newRecordNodeRef)); + } + + + /** + * given the destroyed prop isn't set + * when I ask if the version is destroyed + * then the result is false + */ + @Test + public void propNotSetVersionNotDestroyed() + { + // set up version + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + + // set prop not set + when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) + .thenReturn(null); + + // is version destroyed + assertFalse(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); + } + + /** + * given the destroyed prop is set + * when I ask if the version is destroyed + * then the result matches the value set in the destroy property + */ + @Test + public void propSetVersionDestroyed() + { + // set up version + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + + // set prop + when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) + .thenReturn(Boolean.TRUE); + + // is version destroyed + assertTrue(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); + + // set prop + when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED)) + .thenReturn(Boolean.FALSE); + + // is version destroyed + assertFalse(recordableVersionService.isRecordedVersionDestroyed(mockedVersion)); + } + + /** + * given that the version node doesn't have the recorded version aspect applied + * when I mark the version as destroyed + * then nothing happens + */ + @Test + public void noAspectMarkAsDestroyed() + { + // set up version + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + + // indicate that the version doesn't have the aspect + when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) + .thenReturn(false); + + // mark as destroyed + recordableVersionService.destroyRecordedVersion(mockedVersion); + + // verify nothing happened + verify(mockedDbNodeService, never()) + .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); + } + + /** + * given that the version node ref has the recorded version aspect applied + * and the record version reference exists + * when I mark the version as destroyed + * then the version is marked as destroyed + */ + @Test + public void markAsDestroyed() + { + // set up version + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + NodeRef versionRecordNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + when(mockedDbNodeService.exists(versionRecordNodeRef)) + .thenReturn(true); + + // indicate that the version doesn't have the aspect + when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) + .thenReturn(true); + + // indicate that the associated version record exists + when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF)) + .thenReturn(versionRecordNodeRef); + + // mark as destroyed + recordableVersionService.destroyRecordedVersion(mockedVersion); + + // verify that the version was marked as destroyed + verify(mockedDbNodeService) + .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); + // and the reference to the version record was cleared + verify(mockedDbNodeService) + .setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); + } + + /** + * given that the version node ref has the recorded version aspect applied + * and the associated version record has been deleted + * when I mark the version as destroyed + * then the version is marked as destroyed + * and the reference to the deleted version record is removed + */ + @Test + public void markAsDestroyedClearNodeRef() + { + // set up version + Version mockedVersion = mock(VersionImpl.class); + NodeRef versionNodeRef = generateNodeRef(); + NodeRef versionRecordNodeRef = generateNodeRef(); + when(mockedVersion.getFrozenStateNodeRef()) + .thenReturn(versionNodeRef); + when(mockedDbNodeService.exists(versionRecordNodeRef)) + .thenReturn(false); + + // indicate that the version doesn't have the aspect + when(mockedDbNodeService.hasAspect(versionNodeRef, RecordableVersionModel.ASPECT_RECORDED_VERSION)) + .thenReturn(true); + + // indicate that the associated version record exists + when(mockedDbNodeService.getProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF)) + .thenReturn(versionRecordNodeRef); + + // mark as destroyed + recordableVersionService.destroyRecordedVersion(mockedVersion); + + // verify that the version was marked as destroyed + verify(mockedDbNodeService) + .setProperty(versionNodeRef, RecordableVersionModel.PROP_DESTROYED, Boolean.TRUE); + // and the reference to the version record was cleared + verify(mockedDbNodeService) + .setProperty(versionNodeRef, RecordableVersionModel.PROP_RECORD_NODE_REF, null); + } } \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/TestRecordableVersionServiceImpl.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/TestRecordableVersionServiceImpl.java index 69cad5317d..256995daf9 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/TestRecordableVersionServiceImpl.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/version/TestRecordableVersionServiceImpl.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.module.org_alfresco_module_rm.version; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.policy.PolicyScope; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.namespace.QName; - -/** - * Helper class to help with the unit testing of RecordableVersionServiceImpl. - * - * @author Roy Wetherall - * @since 2.3 - */ -public class TestRecordableVersionServiceImpl extends RecordableVersionServiceImpl -{ - @Override - protected void invokeBeforeCreateVersion(NodeRef nodeRef) - { - } - - @Override - protected void invokeAfterCreateVersion(NodeRef nodeRef, Version version) - { - } - - @Override - protected void invokeAfterVersionRevert(NodeRef nodeRef, Version version) - { - } - - @Override - protected void invokeOnCreateVersion(NodeRef nodeRef, Map versionProperties,PolicyScope nodeDetails) - { - } - - @Override - protected String invokeCalculateVersionLabel(QName classRef, Version preceedingVersion, int versionNumber, Map versionProperties) - { - return "1.1"; - } +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.version; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.policy.PolicyScope; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.version.Version; +import org.alfresco.service.namespace.QName; + +/** + * Helper class to help with the unit testing of RecordableVersionServiceImpl. + * + * @author Roy Wetherall + * @since 2.3 + */ +public class TestRecordableVersionServiceImpl extends RecordableVersionServiceImpl +{ + @Override + protected void invokeBeforeCreateVersion(NodeRef nodeRef) + { + } + + @Override + protected void invokeAfterCreateVersion(NodeRef nodeRef, Version version) + { + } + + @Override + protected void invokeAfterVersionRevert(NodeRef nodeRef, Version version) + { + } + + @Override + protected void invokeOnCreateVersion(NodeRef nodeRef, Map versionProperties,PolicyScope nodeDetails) + { + } + + @Override + protected String invokeCalculateVersionLabel(QName classRef, Version preceedingVersion, int versionNumber, Map versionProperties) + { + return "1.1"; + } } \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/repo/action/parameter/DateParameterProcessorUnitTest.java b/rm-server/unit-test/java/org/alfresco/repo/action/parameter/DateParameterProcessorUnitTest.java index 9f3703ab48..a3529faabc 100644 --- a/rm-server/unit-test/java/org/alfresco/repo/action/parameter/DateParameterProcessorUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/repo/action/parameter/DateParameterProcessorUnitTest.java @@ -1,122 +1,122 @@ -/* - * Copyright (C) 2005-2014 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.action.parameter; - -import java.util.List; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -/** - * Tests for the DateParameterProcessor - * - * @author Mark Hibbins - * @since 2.2 - */ -public class DateParameterProcessorUnitTest -{ - private DateParameterProcessor dateParameterProcessor; - - @Before - public void setUp() throws Exception - { - this.dateParameterProcessor = new DateParameterProcessor(); - this.dateParameterProcessor.setName("date"); - } - - @Test - public void testGetSubstitutionSuggestions_01() - { - List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("date"); - assertTrue(suggestions.contains("date.day.short")); - assertTrue(suggestions.contains("date.day")); - assertTrue(suggestions.contains("date.day.long")); - assertTrue(suggestions.contains("date.day.number")); - assertTrue(suggestions.contains("date.day.month")); - assertTrue(suggestions.contains("date.day.year")); - assertTrue(suggestions.contains("date.month.short")); - assertTrue(suggestions.contains("date.month")); - assertTrue(suggestions.contains("date.month.long")); - assertTrue(suggestions.contains("date.month.number")); - assertEquals(10, suggestions.size()); - } - - @Test - public void testGetSubstitutionSuggestions_02() - { - List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("dat"); - assertTrue(suggestions.contains("date.day.short")); - assertTrue(suggestions.contains("date.day")); - assertTrue(suggestions.contains("date.day.long")); - assertTrue(suggestions.contains("date.day.number")); - assertTrue(suggestions.contains("date.day.month")); - assertTrue(suggestions.contains("date.day.year")); - assertTrue(suggestions.contains("date.month.short")); - assertTrue(suggestions.contains("date.month")); - assertTrue(suggestions.contains("date.month.long")); - assertTrue(suggestions.contains("date.month.number")); - assertEquals(10, suggestions.size()); - } - - @Test - public void testGetSubstitutionSuggestions_03() - { - List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("at"); - assertTrue(suggestions.contains("date.day.short")); - assertTrue(suggestions.contains("date.day")); - assertTrue(suggestions.contains("date.day.long")); - assertTrue(suggestions.contains("date.day.number")); - assertTrue(suggestions.contains("date.day.month")); - assertTrue(suggestions.contains("date.day.year")); - assertTrue(suggestions.contains("date.month.short")); - assertTrue(suggestions.contains("date.month")); - assertTrue(suggestions.contains("date.month.long")); - assertTrue(suggestions.contains("date.month.number")); - assertEquals(10, suggestions.size()); - } - - @Test - public void testGetSubstitutionSuggestions_05() - { - List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("ay"); - assertTrue(suggestions.contains("date.day.short")); - assertTrue(suggestions.contains("date.day")); - assertTrue(suggestions.contains("date.day.long")); - assertTrue(suggestions.contains("date.day.number")); - assertTrue(suggestions.contains("date.day.month")); - assertTrue(suggestions.contains("date.day.year")); - assertEquals(6, suggestions.size()); - } - - @Test - public void testGetSubstitutionSuggestions_06() - { - List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("on"); - assertTrue(suggestions.contains("date.day.long")); - assertTrue(suggestions.contains("date.month.short")); - assertTrue(suggestions.contains("date.month")); - assertTrue(suggestions.contains("date.month.long")); - assertTrue(suggestions.contains("date.month.number")); - assertTrue(suggestions.contains("date.year.long")); - assertTrue(suggestions.contains("date.day.month")); - assertEquals(7, suggestions.size()); - } -} +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.action.parameter; + +import java.util.List; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the DateParameterProcessor + * + * @author Mark Hibbins + * @since 2.2 + */ +public class DateParameterProcessorUnitTest +{ + private DateParameterProcessor dateParameterProcessor; + + @Before + public void setUp() throws Exception + { + this.dateParameterProcessor = new DateParameterProcessor(); + this.dateParameterProcessor.setName("date"); + } + + @Test + public void testGetSubstitutionSuggestions_01() + { + List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("date"); + assertTrue(suggestions.contains("date.day.short")); + assertTrue(suggestions.contains("date.day")); + assertTrue(suggestions.contains("date.day.long")); + assertTrue(suggestions.contains("date.day.number")); + assertTrue(suggestions.contains("date.day.month")); + assertTrue(suggestions.contains("date.day.year")); + assertTrue(suggestions.contains("date.month.short")); + assertTrue(suggestions.contains("date.month")); + assertTrue(suggestions.contains("date.month.long")); + assertTrue(suggestions.contains("date.month.number")); + assertEquals(10, suggestions.size()); + } + + @Test + public void testGetSubstitutionSuggestions_02() + { + List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("dat"); + assertTrue(suggestions.contains("date.day.short")); + assertTrue(suggestions.contains("date.day")); + assertTrue(suggestions.contains("date.day.long")); + assertTrue(suggestions.contains("date.day.number")); + assertTrue(suggestions.contains("date.day.month")); + assertTrue(suggestions.contains("date.day.year")); + assertTrue(suggestions.contains("date.month.short")); + assertTrue(suggestions.contains("date.month")); + assertTrue(suggestions.contains("date.month.long")); + assertTrue(suggestions.contains("date.month.number")); + assertEquals(10, suggestions.size()); + } + + @Test + public void testGetSubstitutionSuggestions_03() + { + List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("at"); + assertTrue(suggestions.contains("date.day.short")); + assertTrue(suggestions.contains("date.day")); + assertTrue(suggestions.contains("date.day.long")); + assertTrue(suggestions.contains("date.day.number")); + assertTrue(suggestions.contains("date.day.month")); + assertTrue(suggestions.contains("date.day.year")); + assertTrue(suggestions.contains("date.month.short")); + assertTrue(suggestions.contains("date.month")); + assertTrue(suggestions.contains("date.month.long")); + assertTrue(suggestions.contains("date.month.number")); + assertEquals(10, suggestions.size()); + } + + @Test + public void testGetSubstitutionSuggestions_05() + { + List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("ay"); + assertTrue(suggestions.contains("date.day.short")); + assertTrue(suggestions.contains("date.day")); + assertTrue(suggestions.contains("date.day.long")); + assertTrue(suggestions.contains("date.day.number")); + assertTrue(suggestions.contains("date.day.month")); + assertTrue(suggestions.contains("date.day.year")); + assertEquals(6, suggestions.size()); + } + + @Test + public void testGetSubstitutionSuggestions_06() + { + List suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("on"); + assertTrue(suggestions.contains("date.day.long")); + assertTrue(suggestions.contains("date.month.short")); + assertTrue(suggestions.contains("date.month")); + assertTrue(suggestions.contains("date.month.long")); + assertTrue(suggestions.contains("date.month.number")); + assertTrue(suggestions.contains("date.year.long")); + assertTrue(suggestions.contains("date.day.month")); + assertEquals(7, suggestions.size()); + } +}