RM: Fix up "Access Denied" issues when sending record reject notification email

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@46459 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-02-11 03:30:36 +00:00
parent d72f12738f
commit f85e45a3e7
3 changed files with 17 additions and 8 deletions

View File

@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
@@ -309,7 +310,7 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod
*
* @param record rejected record
*/
public void recordRejectedEmailNotification(NodeRef record)
public void recordRejectedEmailNotification(NodeRef record, String recordId)
{
ParameterCheck.mandatory("record", record);
@@ -320,14 +321,17 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod
String rejectReason = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON);
String rejectedPerson = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID);
Date rejectDate = (Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE);
String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
Map<String, Serializable> args = new HashMap<String, Serializable>(6);
Map<String, Serializable> args = new HashMap<String, Serializable>(8);
args.put("record", record);
args.put("site", site);
args.put("recordCreator", recordCreator);
args.put("rejectReason", rejectReason);
args.put("rejectedPerson", rejectedPerson);
args.put("rejectDate", rejectDate);
args.put("recordId", recordId);
args.put("recordName", recordName);
NotificationContext notificationContext = new NotificationContext();
notificationContext.setAsyncNotification(true);

View File

@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.record;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -41,9 +40,9 @@ import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagement
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -368,8 +367,11 @@ public class RecordServiceImpl implements RecordService,
nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
// set the extended security
extendedSecurityService.addExtendedSecurity(nodeRef, readers, writers);
extendedSecurityService.addExtendedSecurity(nodeRef, null, Collections.singleton(owner));
Set<String> combinedWriters = new HashSet<String>(writers);
combinedWriters.add(owner);
combinedWriters.add(AuthenticationUtil.getFullyAuthenticatedUser());
extendedSecurityService.addExtendedSecurity(nodeRef, readers, combinedWriters);
}
return null;
@@ -521,6 +523,9 @@ public class RecordServiceImpl implements RecordService,
@Override
public Void doWork() throws Exception
{
// take note of the record id
String recordId = (String)nodeService.getProperty(nodeRef, PROP_IDENTIFIER);
// first remove the secondary link association
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
@@ -565,7 +570,7 @@ public class RecordServiceImpl implements RecordService,
ownableService.setOwner(nodeRef, documentOwner);
// send an email to the record creator
notificationHelper.recordRejectedEmailNotification(nodeRef);
notificationHelper.recordRejectedEmailNotification(nodeRef, recordId);
return null;
}