mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/V2.0 to HEAD:
48720: RM-657: Items section is not displayed on Start Workflow page when RM installed 48749: RM-664 (Not possible to edit event without changing the name) 48772: RM-664 (Not possible to edit event without changing the name) 49445: RM-675: CLONE - Document Details page: 'Comment' link is not working git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@51945 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -175,7 +175,6 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Disposition Service -->
|
<!-- Disposition Service -->
|
||||||
|
|
||||||
<bean id="dispositionService" class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl" init-method="init">
|
<bean id="dispositionService" class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl" init-method="init">
|
||||||
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
||||||
<property name="nodeService" ref="NodeService"/>
|
<property name="nodeService" ref="NodeService"/>
|
||||||
@@ -554,6 +553,7 @@
|
|||||||
<property name="policyComponent" ref="policyComponent"/>
|
<property name="policyComponent" ref="policyComponent"/>
|
||||||
<property name="filePlanService" ref="FilePlanService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="filePlanAuthenticationService" ref="FilePlanAuthenticationService" />
|
<property name="filePlanAuthenticationService" ref="FilePlanAuthenticationService" />
|
||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="FilePlanRoleService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="FilePlanRoleService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
@@ -617,7 +617,6 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Records Management Extended Security Service -->
|
<!-- Records Management Extended Security Service -->
|
||||||
|
|
||||||
<bean id="extendedSecurityService"
|
<bean id="extendedSecurityService"
|
||||||
@@ -840,7 +839,8 @@
|
|||||||
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.addEvent=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.addEvent=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.removeEvent=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.removeEvent=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.existsEvent=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.existsEvent=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.existsEventDisplayLabel=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.canCreateEvent=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.canEditEvent=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.*=RM_DENY
|
org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService.*=RM_DENY
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
@@ -1197,8 +1197,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Custom EMail Mapping Service -->
|
|
||||||
|
|
||||||
|
<!-- Custom EMail Mapping Service -->
|
||||||
<bean id="customEmailMappingService"
|
<bean id="customEmailMappingService"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingServiceImpl" >
|
class="org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingServiceImpl" >
|
||||||
<property name="extracter" ref="extracter.RFC822" />
|
<property name="extracter" ref="extracter.RFC822" />
|
||||||
@@ -1221,7 +1221,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<bean id="CustomEmailMappingService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
<bean id="CustomEmailMappingService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||||
<property name="transactionManager">
|
<property name="transactionManager">
|
||||||
<ref bean="transactionManager"/>
|
<ref bean="transactionManager"/>
|
||||||
@@ -1276,7 +1275,6 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- RM Notification Helper -->
|
<!-- RM Notification Helper -->
|
||||||
|
|
||||||
<bean id="recordsManagementNotificationHelper" class="org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper" >
|
<bean id="recordsManagementNotificationHelper" class="org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper" >
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService"/>
|
<property name="filePlanRoleService" ref="FilePlanRoleService"/>
|
||||||
<property name="notificationService" ref="NotificationService"/>
|
<property name="notificationService" ref="NotificationService"/>
|
||||||
|
@@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
|
<!-- Abstract parent bean for many RM get and post beans -->
|
||||||
|
<bean id="rmBaseWebscript" parent="webscript" abstract="true">
|
||||||
|
<property name="nodeService" ref="NodeService"/>
|
||||||
|
<property name="namespaceService" ref="NamespaceService"/>
|
||||||
|
<property name="recordsManagementService" ref="RecordsManagementService"/>
|
||||||
|
<property name="dispositionService" ref="DispositionService"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- REST impl for RM Action Service -->
|
<!-- REST impl for RM Action Service -->
|
||||||
<bean id="webscript.org.alfresco.rma.rmaction.post"
|
<bean id="webscript.org.alfresco.rma.rmaction.post"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.RmActionPost"
|
class="org.alfresco.module.org_alfresco_module_rm.script.RmActionPost"
|
||||||
@@ -11,14 +19,6 @@
|
|||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Abstract parent bean for many RM get and post beans -->
|
|
||||||
<bean id="rmBaseWebscript" parent="webscript" abstract="true">
|
|
||||||
<property name="nodeService" ref="NodeService" />
|
|
||||||
<property name="namespaceService" ref="NamespaceService" />
|
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
|
||||||
<property name="dispositionService" ref="DispositionService" />
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- REST impl for GET DOD Custom Types -->
|
<!-- REST impl for GET DOD Custom Types -->
|
||||||
<bean id="webscript.org.alfresco.rma.dodcustomtypes.get"
|
<bean id="webscript.org.alfresco.rma.dodcustomtypes.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.DodCustomTypesGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.DodCustomTypesGet"
|
||||||
@@ -169,17 +169,6 @@
|
|||||||
<property name="namespaceService" ref="NamespaceService" />
|
<property name="namespaceService" ref="NamespaceService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- REST impl for GET Audit Log -->
|
|
||||||
<bean id="webscript.org.alfresco.rma.rmauditlog.get"
|
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogGet"
|
|
||||||
parent="webscript">
|
|
||||||
<property name="nodeService" ref="nodeService" />
|
|
||||||
<property name="contentService" ref="ContentService" />
|
|
||||||
<property name="permissionService" ref="PermissionService" />
|
|
||||||
<property name="mimetypeService" ref="mimetypeService" />
|
|
||||||
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService" />
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.rma.rmauditlogstatus.get"
|
<bean id="webscript.org.alfresco.rma.rmauditlogstatus.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogStatusGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogStatusGet"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
@@ -528,6 +517,17 @@
|
|||||||
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
|
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- REST impl for GET Audit Log -->
|
||||||
|
<bean id="webscript.org.alfresco.rma.rmauditlog.get" class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogGet" parent="webscript">
|
||||||
|
<property name="nodeService" ref="nodeService"/>
|
||||||
|
<property name="contentService" ref="ContentService"/>
|
||||||
|
<property name="permissionService" ref="PermissionService"/>
|
||||||
|
<property name="mimetypeService" ref="mimetypeService"/>
|
||||||
|
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- REST impl for GET Class Definitions for RM/DM -->
|
<!-- REST impl for GET Class Definitions for RM/DM -->
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.rm-classes.get"
|
<bean id="webscript.org.alfresco.repository.dictionary.rm-classes.get"
|
||||||
class="org.alfresco.repo.web.scripts.dictionary.RmClassesGet"
|
class="org.alfresco.repo.web.scripts.dictionary.RmClassesGet"
|
||||||
|
@@ -66,7 +66,7 @@ public interface RecordsManagementEventService
|
|||||||
RecordsManagementEvent getEvent(String eventName);
|
RecordsManagementEvent getEvent(String eventName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether a perticular event exists. Returns true if it does, false otherwise.
|
* Indicates whether a particular event exists. Returns true if it does, false otherwise.
|
||||||
*
|
*
|
||||||
* @param eventName event name
|
* @param eventName event name
|
||||||
* @return boolean true if event exists, false otherwise
|
* @return boolean true if event exists, false otherwise
|
||||||
@@ -74,12 +74,23 @@ public interface RecordsManagementEventService
|
|||||||
boolean existsEvent(String eventName);
|
boolean existsEvent(String eventName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether a particular event display label exists. Returns true if it does, false otherwise.
|
* Indicates whether a particular event can be created. Returns true if it is possible, false otherwise.
|
||||||
*
|
*
|
||||||
* @param eventDisplayLabel event display label
|
* @param eventDisplayLabel event display label
|
||||||
* @return true if event display label exists, false otherwise
|
* @param eventName event name
|
||||||
|
* @return true if the event can be created, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean existsEventDisplayLabel(String eventDisplayLabel);
|
boolean canCreateEvent(String eventDisplayLabel, String eventName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether a particular event can be edited. Returns true if it is possible, false otherwise.
|
||||||
|
*
|
||||||
|
* @param eventDisplayLabel event display label
|
||||||
|
* @param eventName event name
|
||||||
|
* @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
|
* Add an event
|
||||||
|
@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.event;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -134,14 +136,96 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#addEvent(java.lang.String,
|
* @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canCreateEvent(java.lang.String, java.lang.String)
|
||||||
* java.lang.String, java.lang.String)
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public boolean canCreateEvent(String eventDisplayLabel, String eventName)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel);
|
||||||
|
ParameterCheck.mandatoryString("eventName", eventName);
|
||||||
|
|
||||||
|
boolean canCreateEvent = true;
|
||||||
|
|
||||||
|
if (existsEvent(eventName) == true)
|
||||||
|
{
|
||||||
|
canCreateEvent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canCreateEvent == true)
|
||||||
|
{
|
||||||
|
for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();)
|
||||||
|
{
|
||||||
|
RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next();
|
||||||
|
if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel) == true)
|
||||||
|
{
|
||||||
|
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("unchecked")
|
||||||
|
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) == false)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("The event '" + eventName + "' does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();)
|
||||||
|
{
|
||||||
|
RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next();
|
||||||
|
if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel) == true)
|
||||||
|
{
|
||||||
|
if (recordsManagementEvent.getName().equalsIgnoreCase(eventName) == true)
|
||||||
|
{
|
||||||
|
if (recordsManagementEvent.getType().equalsIgnoreCase(eventType) == false)
|
||||||
|
{
|
||||||
|
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)
|
public RecordsManagementEvent addEvent(String eventType, String eventName, String eventDisplayLabel)
|
||||||
{
|
{
|
||||||
// Check that the eventType is valid
|
// Check that the eventType is valid
|
||||||
if (eventTypes.containsKey(eventType) == false) { throw new AlfrescoRuntimeException(
|
if (eventTypes.containsKey(eventType) == false)
|
||||||
"Can not add event because event " + eventName + " has an undefined eventType. (" + eventType + ")"); }
|
{
|
||||||
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Can not add event because event " +
|
||||||
|
eventName +
|
||||||
|
" has an undefined eventType. ("
|
||||||
|
+ eventType + ")");
|
||||||
|
}
|
||||||
|
|
||||||
// Create event and add to map
|
// Create event and add to map
|
||||||
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
||||||
@@ -191,8 +275,10 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
|||||||
public Object doWork() throws Exception
|
public Object doWork() throws Exception
|
||||||
{
|
{
|
||||||
// Get the event config node
|
// Get the event config node
|
||||||
if (nodeService.exists(CONFIG_NODE_REF) == false) { throw new AlfrescoRuntimeException(
|
if (nodeService.exists(CONFIG_NODE_REF) == false)
|
||||||
"Unable to find records management event configuration node."); }
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to find records management event configuration node.");
|
||||||
|
}
|
||||||
|
|
||||||
// Read content from config node
|
// Read content from config node
|
||||||
ContentReader reader = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT);
|
ContentReader reader = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT);
|
||||||
@@ -214,9 +300,14 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
|||||||
String eventDisplayLabel = eventJSON.getString("eventDisplayLabel");
|
String eventDisplayLabel = eventJSON.getString("eventDisplayLabel");
|
||||||
|
|
||||||
// Check that the eventType is valid
|
// Check that the eventType is valid
|
||||||
if (eventTypes.containsKey(eventType) == false) { throw new AlfrescoRuntimeException(
|
if (eventTypes.containsKey(eventType) == false)
|
||||||
"Can not load rm event configuration because event " + eventName
|
{
|
||||||
+ " has an undefined eventType. (" + eventType + ")"); }
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Can not load rm event configuration because event " +
|
||||||
|
eventName +
|
||||||
|
" has an undefined eventType. ("
|
||||||
|
+ eventType + ")");
|
||||||
|
}
|
||||||
|
|
||||||
// Create event and add to map
|
// Create event and add to map
|
||||||
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
||||||
@@ -238,8 +329,10 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
|||||||
public Object doWork() throws Exception
|
public Object doWork() throws Exception
|
||||||
{
|
{
|
||||||
// Get the event config node
|
// Get the event config node
|
||||||
if (nodeService.exists(CONFIG_NODE_REF) == false) { throw new AlfrescoRuntimeException(
|
if (nodeService.exists(CONFIG_NODE_REF) == false)
|
||||||
"Unable to find records management event configuration node."); }
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to find records management event configuration node.");
|
||||||
|
}
|
||||||
|
|
||||||
JSONObject configJSON = new JSONObject();
|
JSONObject configJSON = new JSONObject();
|
||||||
JSONArray eventsJSON = new JSONArray();
|
JSONArray eventsJSON = new JSONArray();
|
||||||
|
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for Records management event web scripts
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RMEventBase extends DeclarativeWebScript
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Helper method for getting the value for a key from a JSON object
|
||||||
|
*
|
||||||
|
* @param json The request content as JSON object
|
||||||
|
* @param key The key for which the value should be retrieved (e.g. "eventName")
|
||||||
|
* @return String The value for the provided key if the key exists, null otherwise
|
||||||
|
* @throws JSONException If there is no string value for the key
|
||||||
|
*/
|
||||||
|
protected String getValue(JSONObject json, String key) throws JSONException
|
||||||
|
{
|
||||||
|
String result = null;
|
||||||
|
if (json.has(key) == true)
|
||||||
|
{
|
||||||
|
result = json.getString(key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method for checking the key (e.g. "eventName")
|
||||||
|
*
|
||||||
|
* @param key String The key which will be checked
|
||||||
|
* @param msg String The error message to throw if the key doesn't have a value
|
||||||
|
*/
|
||||||
|
protected void doCheck(String key, String msg)
|
||||||
|
{
|
||||||
|
if (StringUtils.isBlank(key))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -22,30 +22,26 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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.RecordsManagementEvent;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.alfresco.util.ParameterCheck;
|
||||||
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.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
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
|
* Records management event PUT web script
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmEventPut extends DeclarativeWebScript
|
public class RmEventPut extends RMEventBase
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
/** Records management event service */
|
||||||
private static Log logger = LogFactory.getLog(RmEventPut.class);
|
|
||||||
|
|
||||||
/** Reccords management event service */
|
|
||||||
private RecordsManagementEventService rmEventService;
|
private RecordsManagementEventService rmEventService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,59 +54,49 @@ public class RmEventPut extends DeclarativeWebScript
|
|||||||
this.rmEventService = 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
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("req", req);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
JSONObject json = null;
|
JSONObject json = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Event name
|
// Convert the request content to JSON
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
|
||||||
String eventName = templateVars.get("eventname");
|
|
||||||
if (eventName == null)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided on the URL.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the event exists
|
|
||||||
if (rmEventService.existsEvent(eventName) == false)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
||||||
|
|
||||||
String eventDisplayLabel = null;
|
// Check the event name
|
||||||
if (json.has("eventDisplayLabel") == true)
|
String eventName = getValue(json, "eventName");
|
||||||
|
doCheck(eventName, "No event name was provided.");
|
||||||
|
|
||||||
|
// Check the event display label
|
||||||
|
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
|
||||||
|
doCheck(eventDisplayLabel, "No event display label was provided.");
|
||||||
|
|
||||||
|
// Check 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) == true)
|
||||||
{
|
{
|
||||||
eventDisplayLabel = json.getString("eventDisplayLabel");
|
// Create event
|
||||||
|
event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
|
||||||
}
|
}
|
||||||
if (eventDisplayLabel == null || eventDisplayLabel.length() == 0)
|
else
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event display label provided.");
|
// Get event
|
||||||
}
|
event = rmEventService.getEvent(eventName);
|
||||||
if (rmEventService.existsEventDisplayLabel(eventDisplayLabel))
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
|
||||||
"Cannot edit event. The event display label '"
|
|
||||||
+ eventDisplayLabel + "' already exists.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String eventType = null;
|
|
||||||
if (json.has("eventType") == true)
|
|
||||||
{
|
|
||||||
eventType = json.getString("eventType");
|
|
||||||
}
|
|
||||||
if (eventType == null || eventType.length() == 0)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event type provided.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
|
|
||||||
model.put("event", event);
|
model.put("event", event);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException iox)
|
catch (IOException iox)
|
||||||
{
|
{
|
||||||
@@ -125,4 +111,29 @@ public class RmEventPut extends DeclarativeWebScript
|
|||||||
|
|
||||||
return model;
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
return canEditEvent;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -25,28 +25,24 @@ import java.util.Map;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
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.RecordsManagementEventService;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.apache.commons.lang.StringUtils;
|
||||||
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;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
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
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmEventsPost extends DeclarativeWebScript
|
public class RmEventsPost extends RMEventBase
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
/** Records management event service */
|
||||||
private static Log logger = LogFactory.getLog(RmEventsPost.class);
|
|
||||||
|
|
||||||
/** Reccords management event service */
|
|
||||||
private RecordsManagementEventService rmEventService;
|
private RecordsManagementEventService rmEventService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,57 +55,41 @@ public class RmEventsPost extends DeclarativeWebScript
|
|||||||
this.rmEventService = 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
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("req", req);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
JSONObject json = null;
|
JSONObject json = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Convert the request content to JSON
|
||||||
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
||||||
|
|
||||||
String eventName = null;
|
// Get the event name
|
||||||
if (json.has("eventName") == true)
|
String eventName = getEventName(json);
|
||||||
{
|
|
||||||
eventName = json.getString("eventName");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eventName == null || eventName.length() == 0)
|
// Check the event display label
|
||||||
{
|
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
|
||||||
// Generate the event name
|
doCheck(eventDisplayLabel, "No event display label was provided.");
|
||||||
eventName = GUID.generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
String eventDisplayLabel = null;
|
// Check if the event can be created
|
||||||
if (json.has("eventDisplayLabel") == true)
|
canCreateEvent(eventDisplayLabel, eventName);
|
||||||
{
|
|
||||||
eventDisplayLabel = json.getString("eventDisplayLabel");
|
|
||||||
}
|
|
||||||
if (eventDisplayLabel == null || eventDisplayLabel.length() == 0)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event display label provided.");
|
|
||||||
}
|
|
||||||
if (rmEventService.existsEventDisplayLabel(eventDisplayLabel))
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
|
||||||
"Cannot create event. The event display label '"
|
|
||||||
+ eventDisplayLabel + "' already exists.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String eventType = null;
|
// Check the event type
|
||||||
if (json.has("eventType") == true)
|
String eventType = getValue(json, "eventType");
|
||||||
{
|
doCheck(eventType, "No event type was provided.");
|
||||||
eventType = json.getString("eventType");
|
|
||||||
}
|
|
||||||
if (eventType == null || eventType.length() == 0)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event type provided.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create event
|
||||||
RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
|
RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
|
||||||
model.put("event", event);
|
|
||||||
|
|
||||||
|
model.put("event", event);
|
||||||
}
|
}
|
||||||
catch (IOException iox)
|
catch (IOException iox)
|
||||||
{
|
{
|
||||||
@@ -124,4 +104,45 @@ public class RmEventsPost extends DeclarativeWebScript
|
|||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method for getting the event name
|
||||||
|
*
|
||||||
|
* @param json The request content as JSON object
|
||||||
|
* @return String The event name. A generated GUID if it doesn't exist
|
||||||
|
* @throws JSONException If there is no string value for the key
|
||||||
|
*/
|
||||||
|
private String getEventName(JSONObject json) throws JSONException
|
||||||
|
{
|
||||||
|
String eventName = getValue(json, "eventName");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(eventName))
|
||||||
|
{
|
||||||
|
// Generate the event name
|
||||||
|
eventName = GUID.generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method for checking if an event can be created or not. Throws an
|
||||||
|
* error if the event already exists.
|
||||||
|
*
|
||||||
|
* @param eventDisplayLabel The display label of the event
|
||||||
|
* @param eventName The name of the event
|
||||||
|
*/
|
||||||
|
private boolean canCreateEvent(String eventDisplayLabel, String eventName)
|
||||||
|
{
|
||||||
|
boolean canCreateEvent = true;
|
||||||
|
|
||||||
|
if (rmEventService.canCreateEvent(eventDisplayLabel, eventName) == false)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||||
|
"Cannot create event. An event with the display label '"
|
||||||
|
+ eventDisplayLabel + "' already exists.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return canCreateEvent;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user