From e7865b1fcb52b3ade02d1046f54ca238ef561dea Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Sun, 25 Nov 2012 21:05:40 +0000 Subject: [PATCH] RM-563 (Add group id and title to Capability API and definitions) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@43933 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-capabilities-audit-context.xml | 102 +-- .../rm-capabilities-disposition-context.xml | 200 +++--- .../rm-capabilities-fileplan-context.xml | 25 +- .../rm-capabilities-freeze-context.xml | 78 +-- .../rm-capabilities-list-context.xml | 46 +- .../rm-capabilities-record-context.xml | 351 +++++----- .../rm-capabilities-recordfolder-context.xml | 114 ++-- .../messages/capability-service.properties | 96 +++ .../org_alfresco_module_rm/module-context.xml | 3 +- .../rm-capabilities-context.xml | 529 ++++++++------- .../rma/capability/capabilities.get.desc.xml | 2 +- .../rma/capability/capabilities.get.json.ftl | 38 +- .../capability/AbstractCapability.java | 607 +++++++++--------- .../capability/Capability.java | 150 +++-- .../capability/CapabilityService.java | 132 ++-- .../capability/CapabilityServiceImpl.java | 266 ++++---- .../script/admin/RmRolesGet.java | 92 +-- .../script/capability/CapabilitiesGet.java | 145 +++-- 18 files changed, 1651 insertions(+), 1325 deletions(-) create mode 100644 rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties 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 d96c8fbe13..7b6fe1e98f 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 @@ -2,61 +2,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + \ 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 abfd0ae413..008ae8e12f 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 @@ -2,113 +2,117 @@ - - + - - - - - - RECORD_FOLDER - RECORD - - - - - - - - + + + + + + RECORD_FOLDER + RECORD + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + - - + + - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - + parent="declarativeCapability"> + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + 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 497a7e661d..14ff0e3fea 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 @@ -2,20 +2,21 @@ - + - - - - + + + + - - - - - - + + + + + + + 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 6d1deaeabb..435f51abba 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 @@ -2,48 +2,48 @@ - + - - - - - - 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-list-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-list-context.xml index 07e035e4df..01291f0f66 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-list-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-list-context.xml @@ -2,33 +2,35 @@ - + - - - - + + + + + + + + + + + - - - - - - - + + - - - - - - - + + + + + + + \ 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 127bd49f6b..df828dc745 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 @@ -2,52 +2,54 @@ - - - - - - - - - - - RECORD - - - - - - - - - - + + + + - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - + + + + + + + RECORD + + + + + + + + + + + - + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + @@ -86,159 +88,126 @@ - - - - - - RECORD - - - - - - - - - - + + + + + + RECORD + + + + + + + + + + + - - - - - - - RECORD - - - - - - - - - - - + + + + + + + RECORD + + + + + + + + - - - - - - - RECORD - - - - - - - - - - - - - - - RECORD - - - - - - - - - - - - - - - + + + + + RECORD + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + - - - - - RECORD - - - - - - - - - - - - - - + + + + RECORD + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ 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 e12c43321f..3d85ca332a 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 @@ -2,46 +2,46 @@ - - - - - - - RECORD_FOLDER - - - - - - - - - - + + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + RECORD_CATEGORY + RECORD_FOLDER + + + + + + + + + + - - - - - - RECORD_CATEGORY - RECORD_FOLDER - - - - - - - - - - - - @@ -55,4 +55,42 @@ + + + + + + RECORD_FOLDER + + + + + + + + + + + + + + + + + + RECORD + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000000..e70df7ade0 --- /dev/null +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties @@ -0,0 +1,96 @@ +# Records +capability.group.records.title=Records +capability.DeclareRecords.title=Declare Records +capability.ViewRecords.title=View Records +capability.UndeclareRecords.title=Undeclare Records + +# Metadata Control +capability.group.metadataControl.title=Metadata Control +capability.EditRecordMetadata.title=Edit Record Metadata +capability.EditDeclaredRecordMetadata.title=Edit Declared 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=Declare 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.referencesAndLinks.title=References and Links +capability.ChangeOrDeleteReferences.title=Change Or Delete References +capability.DeleteLinks.title=Delete Links + +# 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=Cutoff +capability.ApproveRecordsScheduledForCutoff.title=Approve Records Scheduled For Cutoff +capability.CreateModifyRecordsInCutoffFolders.title=Create Modify Records In Cutoff 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 Records Scheduled For Destruction +capability.DestroyRecords.title=Destroy Records +capability.DeleteRecords.title=Delete Records +capability.TriggerAnEvent.title=Trigger An Event + +# 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 + +# 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 + +# Roles and Access Rights +capability.group.rolesAndAccessRights.title=Roles and Access Rights +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=Manage Access Controls +capability.ManageAccessRights.title=Manage Access Rights + +# File Plan Metadata, Lists and Email +capability.group.filePlanMetadataListsAndEmail.title=File Plan Metadata, Lists and Email +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 + +# Classified Records +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/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml index 8aabd4625d..1feccfa8d6 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 @@ -79,7 +79,8 @@ 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.audit-service + alfresco.module.org_alfresco_module_rm.messages.capability-service diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml index 0f381d7dd9..5e97e8ad35 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 @@ -10,167 +10,243 @@ - - + - + - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - + + + - - - - - - - - - - - - - + - - - - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + parent="rmRolesAndAccessRightsGroup"> @@ -181,113 +257,116 @@ - - - - + + + + - - - - + + + + + - - - - - - - - - - - - - - - + parent="rmRolesAndAccessRightsGroup"> + + - - - - - - - RECORD_FOLDER - RECORD - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + RECORD_FOLDER + RECORD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + parent="rmVitalRecordsGroup"> + + + + + + + - + - + - - + + - + - + - + - + - + - + \ No newline at end of file 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 cfd9beacc4..51cb5a1f98 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 @@ -2,7 +2,7 @@ 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?} + /api/capabilities?includeAll={includeAll?}&grouped={grouped?} argument user required 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 857485dfce..89ea2a8a26 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,11 +1,31 @@ { - "data" : - { - "capabilities" : - [ - <#list capabilities as capability> - "${capability}"<#if capability_has_next>, - - ] - } + "data": + { + <#if groupedCapabilities??> + "groupedCapabilities": + [ + <#assign keys = groupedCapabilities?keys> + <#list keys as key> + { + "${key}": + <#assign capabilitiesMap = groupedCapabilities[key]> + <#assign capabilitiesKeys = capabilitiesMap?keys> + { + <#list capabilitiesKeys as capabilitiesKey> + "${capabilitiesKey}": "${capabilitiesMap[capabilitiesKey]}" + <#if capabilitiesKey_has_next>, + + } + }<#if key_has_next>, + + ] + <#else> + "capabilities": + [ + <#list capabilities as capability> + "${capability}"<#if capability_has_next>, + + ] + + } } \ No newline at end of file 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 643f87795e..bffae26036 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 @@ -27,6 +27,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction 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.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; @@ -40,313 +41,345 @@ import org.springframework.extensions.surf.util.I18NUtil; public abstract class AbstractCapability extends RMSecurityCommon implements Capability, RecordsManagementModel, RMPermissionModel { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(AbstractCapability.class); + /** Logger */ + @SuppressWarnings("unused") + private static Log logger = LogFactory.getLog(AbstractCapability.class); - /** RM entry voter */ - protected RMEntryVoter voter; - - /** Capability service */ - protected CapabilityService capabilityService; - - /** Capability name */ - protected String name; - - /** Capability title and description */ - protected String title; - protected String description; - - /** Indicates whether this is a private capability or not */ - protected boolean isPrivate = false; + /** RM entry voter */ + protected RMEntryVoter voter; - /** List of actions */ - protected List actions = new ArrayList(1); + /** Capability service */ + protected CapabilityService capabilityService; - /** Action names */ - protected List actionNames = new ArrayList(1); + /** Capability name */ + protected String name; - /** - * @param voter RM entry voter - */ - public void setVoter(RMEntryVoter voter) - { - this.voter = voter; - } - - /** - * @param capabilityService capability service - */ - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * Init method - */ - public void init() - { - capabilityService.registerCapability(this); - } + /** Capability title and description */ + protected String title; + protected String description; - /** - * Registers an action - * - * @param action - */ - public void registerAction(RecordsManagementAction action) - { - this.actions.add(action); - this.actionNames.add(action.getName()); - voter.addProtectedAspects(action.getProtectedAspects()); - voter.addProtectedProperties(action.getProtectedProperties()); - } - - /** - * @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; - } + /** Capability group id and title*/ + protected String groupId; + protected String groupTitle; - /** - * @param titleId message id - */ - public void setTitleId(String titleId) - { - this.title = I18NUtil.getMessage(titleId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle() - */ - @Override - public String getTitle() - { - 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; - } + /** Indicates whether this is a private capability or not */ + protected boolean isPrivate = false; - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate() - */ - public boolean isPrivate() - { - return isPrivate; - } + /** List of actions */ + protected List actions = new ArrayList(1); - /** - * @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: + /** Action names */ + protected List actionNames = new ArrayList(1); + + /** + * @param voter RM entry voter + */ + public void setVoter(RMEntryVoter voter) + { + this.voter = voter; + } + + /** + * @param capabilityService capability service + */ + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * Init method + */ + public void init() + { + capabilityService.registerCapability(this); + } + + /** + * Registers an action + * + * @param action + */ + public void registerAction(RecordsManagementAction action) + { + this.actions.add(action); + this.actionNames.add(action.getName()); + voter.addProtectedAspects(action.getProtectedAspects()); + voter.addProtectedProperties(action.getProtectedProperties()); + } + + /** + * @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"); + } + 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: + case AccessDecisionVoter.ACCESS_GRANTED: return AccessStatus.ALLOWED; - case AccessDecisionVoter.ACCESS_DENIED: + case AccessDecisionVoter.ACCESS_DENIED: return AccessStatus.DENIED; - default: + default: return AccessStatus.UNDETERMINED; - } - } + } + } - /** - * - * @param nodeRef - * @return - */ - public int checkActionConditionsIfPresent(NodeRef nodeRef) - { - String prefix = "checkActionConditionsIfPresent" + getName(); - int result = getTransactionCache(prefix, nodeRef); - if (result != NOSET_VALUE) - { - return result; - } - - if (actions.size() > 0) - { - for (RecordsManagementAction action : actions) + /** + * + * @param nodeRef + * @return + */ + public int checkActionConditionsIfPresent(NodeRef nodeRef) + { + String prefix = "checkActionConditionsIfPresent" + getName(); + int result = getTransactionCache(prefix, nodeRef); + if (result != NOSET_VALUE) + { + return result; + } + + if (actions.size() > 0) + { + for (RecordsManagementAction action : actions) + { + if (action.isExecutable(nodeRef, null)) { - if (action.isExecutable(nodeRef, null)) - { - return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED); - } + return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED); } - return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_DENIED); - } - else - { - return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED); - } - } + } + return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_DENIED); + } + else + { + return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED); + } + } - /** - * @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) - { - return result; - } - - if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - else if (checkActionConditionsIfPresent(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) - { - result = AccessDecisionVoter.ACCESS_DENIED; - } - else - { - result = hasPermissionImpl(nodeRef); - } - - return setTransactionCache(prefix, nodeRef, 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#hasPermission(org.alfresco.service.cmr.repository.NodeRef) + */ + public AccessStatus hasPermission(NodeRef nodeRef) + { + return translate(hasPermissionRaw(nodeRef)); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActionNames() - */ - public List getActionNames() - { - return actionNames; - } + /** + * 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) + { + return result; + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActions() - */ - public List getActions() - { - return actions; - } + if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + else if (checkActionConditionsIfPresent(nodeRef) == AccessDecisionVoter.ACCESS_DENIED) + { + result = AccessDecisionVoter.ACCESS_DENIED; + } + else + { + result = hasPermissionImpl(nodeRef); + } - /** - * @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; - } + return setTransactionCache(prefix, nodeRef, result); + } - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) + /** + * 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#getActionNames() + */ + public List getActionNames() + { + return actionNames; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActions() + */ + public List getActions() + { + return actions; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroupId() + */ + public String getGroupId() + { + return this.groupId; + } + + public void setGroupId(String groupId) + { + this.groupId = groupId; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroupTitle() + */ + public String getGroupTitle() + { + String groupTitle = this.groupTitle; + if (StringUtils.isBlank(groupTitle)) + { + groupTitle = I18NUtil.getMessage("capability.group." + getGroupId() + ".title"); + } + return groupTitle; + } + + public void setGroupTitle(String groupTitle) + { + this.groupTitle = groupTitle; + } + + /** + * @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; - 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; - } + } + 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 4510a2eca1..ec3addc916 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 @@ -32,75 +32,89 @@ import org.alfresco.service.cmr.security.AccessStatus; */ public interface Capability { - /** - * Does this capability apply to this nodeRef? - * @param nodeRef - * @return - */ - AccessStatus hasPermission(NodeRef nodeRef); - - /** - * - * @param nodeRef - * @return - */ - int hasPermissionRaw(NodeRef nodeRef); + /** + * Does this capability apply to this nodeRef? + * @param nodeRef + * @return + */ + AccessStatus hasPermission(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(); + /** + * + * @param nodeRef + * @return + */ + int hasPermissionRaw(NodeRef nodeRef); - /** - * Get the description of the capability - * - * @return String capability description - */ - String getDescription(); - - /** - * Get the name of optional actions tied to this capability - * @return - */ - List getActionNames(); + /** + * Evaluates the capability. + * + * @param nodeRef + * @return + */ + int evaluate(NodeRef nodeRef); - /** - * - * @return - */ - List getActions(); + /** + * 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(); + + /** + * Get the name of optional actions tied to this capability + * @return + */ + List getActionNames(); + + /** + * + * @return + */ + List getActions(); + + /** + * Gets the group id of a capability + * + * @return String capability group id + */ + String getGroupId(); + + /** + * Gets the group title of a capability + * + * @return String capability group title + */ + String getGroupTitle(); } 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 f1e5f2dcaf..7906e3f111 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 @@ -33,66 +33,74 @@ import org.alfresco.service.cmr.security.AccessStatus; */ 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); + /** + * 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 all the capabilities grouped by their ids. The map key is the group id of a capability and the + * value is another map with the key being the capability name and the value being the capability title + * + * @return Map of capabilities grouped by their ids + */ + Map> getGroupedCapabilities(); } 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 3ab90eb468..2a31a808ef 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 @@ -27,6 +27,8 @@ import java.util.Set; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; /** * @author Roy Wetherall @@ -34,125 +36,169 @@ import org.alfresco.service.cmr.security.AccessStatus; */ public class CapabilityServiceImpl implements CapabilityService { - /** Capabilities */ - private Map capabilities = new HashMap(57); - - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String) - */ - @Override - public Capability getCapability(String name) - { - return capabilities.get(name); - } + /** Capabilities */ + private Map capabilities = new HashMap(57); - /** - * @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) - { - capabilities.put(capability.getName(), capability); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String) + */ + @Override + public Capability getCapability(String name) + { + ParameterCheck.mandatoryString("name", name); - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities() - */ - @Override - public Set getCapabilities() - { - return getCapabilities(true); - } + 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 == true) - { - result = new HashSet(capabilities.values()); - } - else - { - result = new HashSet(capabilities.size()); - for (Capability capability : capabilities.values()) + /** + * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean) + */ + @Override + public Set getCapabilities(boolean includePrivate) + { + Set result = null; + if (includePrivate == true) + { + result = new HashSet(capabilities.values()); + } + else + { + result = new HashSet(capabilities.size()); + for (Capability capability : capabilities.values()) + { + if (capability.isPrivate() == false) { - if (capability.isPrivate() == false) - { - result.add(capability); - } + 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) - { - 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) - { - Set listOfCapabilites = getCapabilities(includePrivate); - HashMap answer = new HashMap(); - for (Capability capability : listOfCapabilites) - { + 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(); + 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) - { - 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) - { - 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; - } + } + } + 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#getGroupedCapabilities() + */ + @Override + public Map> getGroupedCapabilities() + { + Map> groupedCapabilities = new HashMap>(capabilities.size()); + for (Capability capability : getCapabilities(true)) + { + String groupTitle = capability.getGroupTitle(); + if (StringUtils.isNotBlank(groupTitle)) + { + String capabilityName = capability.getName(); + String capabilityTitle = capability.getTitle(); + + if (groupedCapabilities.containsKey(groupTitle)) + { + groupedCapabilities.get(groupTitle).put(capabilityName, capabilityTitle); + } + else + { + Map capabilityList = new HashMap(13); + capabilityList.put(capabilityName, capabilityTitle); + groupedCapabilities.put(groupTitle, capabilityList); + } + } + } + + return groupedCapabilities; + } } 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 1255120eb3..3e920deae0 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 @@ -37,57 +37,57 @@ import org.apache.commons.logging.LogFactory; /** * Get information about record management roles - * + * * @author Roy Wetherall */ public class RmRolesGet extends DeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRolesGet.class); - - private RecordsManagementService rmService; - private RecordsManagementSecurityService rmSecurityService; - - public void setRecordsManagementSecurityService(RecordsManagementSecurityService rmSecurityService) - { - this.rmSecurityService = rmSecurityService; - } - - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } + @SuppressWarnings("unused") + private static Log logger = LogFactory.getLog(RmRolesGet.class); - @Override - public Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map model = new HashMap(); - Set roles = null; - - // TODO should be passed - List roots = rmService.getFilePlans(); - if (roots != null && roots.size() > 0) - { - NodeRef root = roots.get(0); - - // Get the user filter - String user = req.getParameter("user"); - if (user != null && user.length() != 0) - { - roles = rmSecurityService.getRolesByUser(root, user); - } - else - { - roles = rmSecurityService.getRoles(root); - } - } - else - { - roles = new HashSet(1); - } + private RecordsManagementService rmService; + private RecordsManagementSecurityService rmSecurityService; - model.put("roles", roles); - - return model; + public void setRecordsManagementSecurityService(RecordsManagementSecurityService rmSecurityService) + { + this.rmSecurityService = rmSecurityService; + } + + public void setRecordsManagementService(RecordsManagementService rmService) + { + this.rmService = rmService; + } + + @Override + public Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + Set roles = null; + + // TODO should be passed + List roots = rmService.getFilePlans(); + if (roots != null && roots.size() > 0) + { + NodeRef root = roots.get(0); + + // Get the user filter + String user = req.getParameter("user"); + if (user != null && user.length() != 0) + { + roles = rmSecurityService.getRolesByUser(root, user); + } + else + { + roles = rmSecurityService.getRoles(root); + } + } + else + { + roles = new HashSet(1); + } + + model.put("roles", roles); + + return model; } } \ 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 86612fb061..8144f15ca6 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 @@ -31,6 +31,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; 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; @@ -39,73 +40,87 @@ import org.springframework.extensions.webscripts.WebScriptRequest; public class CapabilitiesGet extends DeclarativeWebScript { - private RecordsManagementService recordsManagementService; - - private CapabilityService capabilityService; - - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - - /** - * @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"); - - boolean includePrivate = false; - String includePrivateString = req.getParameter("includeAll"); - if (includePrivateString != null) - { + private RecordsManagementService recordsManagementService; + + private CapabilityService capabilityService; + + public void setRecordsManagementService(RecordsManagementService recordsManagementService) + { + this.recordsManagementService = recordsManagementService; + } + + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + + /** + * @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! + List filePlans = recordsManagementService.getFilePlans(); + if (filePlans.isEmpty() == true) + { + throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file plan node has been found."); + } + else if (filePlans.size() != 1) + { + throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "More than one file plan has been found."); + } + nodeRef = filePlans.get(0); + } + + boolean grouped = false; + String groupedString = req.getParameter("grouped"); + if (StringUtils.isNotBlank(groupedString)) + { + grouped = Boolean.parseBoolean(groupedString); + } + + Map model = new HashMap(1); + if (grouped == true) + { + model.put("groupedCapabilities", capabilityService.getGroupedCapabilities()); + } + else + { + boolean includePrivate = false; + String includePrivateString = req.getParameter("includeAll"); + if (StringUtils.isNotBlank(includePrivateString)) + { includePrivate = Boolean.parseBoolean(includePrivateString); - } - - NodeRef nodeRef = null; - if (storeType != null && storeId != null && nodeId != null) - { - 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! - List filePlans = recordsManagementService.getFilePlans(); - if (filePlans.isEmpty() == true) - { - throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file plan node has been found."); - } - else if (filePlans.size() != 1) - { - throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "More than one file plan has been found."); - } - nodeRef = filePlans.get(0); - } - - Map map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate); - List list = new ArrayList(map.size()); - for (Map.Entry entry : map.entrySet()) - { + } + + 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) == false) { - Capability capability = entry.getKey(); - list.add(capability.getName()); - } - } - - Map model = new HashMap(1); - model.put("capabilities", list); - return model; - } + Capability capability = entry.getKey(); + list.add(capability.getName()); + } + } + model.put("capabilities", list); + } + + return model; + } } \ No newline at end of file