diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl
index 98702e42dc..19733a7aa0 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl
@@ -44,7 +44,7 @@
-
Hello ${args.userName},
+
Hello ${args.recordCreator},
${args.rejectedPerson} has rejected the following record with this reason:
diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml
index 2bcae5a8c2..2dfe40845f 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml
@@ -1143,13 +1143,29 @@
The originating details of a record
-
- d:any
+
+ d:text
-
+
d:date
-
+
+ d:any
+
+
+
+
+
+
+ The rejection details of a record
+
+
+ d:text
+
+
+ d:date
+
+
d:text
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java
index 5239dbf204..f1b6aefede 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/HideRecordAction.java
@@ -116,11 +116,11 @@ public class HideRecordAction extends ActionExecuterAbstractBase implements Reco
else
{
// remove the child association
- NodeRef originalLocation = (NodeRef) nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINAL_LOCATION);
+ NodeRef originatingLocation = (NodeRef) nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION);
List parentAssocs = nodeService.getParentAssocs(actionedUponNodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs)
{
- if (childAssociationRef.isPrimary() == false && childAssociationRef.getParentRef().equals(originalLocation))
+ if (childAssociationRef.isPrimary() == false && childAssociationRef.getParentRef().equals(originatingLocation))
{
nodeService.removeChildAssociation(childAssociationRef);
break;
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java
index 1dc8027a60..34e5a55ca4 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java
@@ -231,9 +231,15 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName ASPECT_EXTENDED_READERS = QName.createQName(RM_URI, "extendedReaders");
public static final QName PROP_READERS = QName.createQName(RM_URI, "readers");
- // Original location of a record
+ // Originating details of a record
public static final QName ASPECT_RECORD_ORIGINATING_DETAILS = QName.createQName(RM_URI, "recordOriginatingDetails");
- public static final QName PROP_RECORD_ORIGINAL_LOCATION = QName.createQName(RM_URI, "recordOrginalLocation");
- public static final QName PROP_RECORD_CREATION_DATE = QName.createQName(RM_URI, "recordCreationDate");
- public static final QName PROP_RECORD_USER_ID = QName.createQName(RM_URI, "recordUserId");
+ public static final QName PROP_RECORD_ORIGINATING_USER_ID = QName.createQName(RM_URI, "recordOriginatingUserId");
+ public static final QName PROP_RECORD_ORIGINATING_CREATION_DATE = QName.createQName(RM_URI, "recordOriginatingCreationDate");
+ public static final QName PROP_RECORD_ORIGINATING_LOCATION = QName.createQName(RM_URI, "recordOriginatingLocation");
+
+ // Rejection details of a record
+ public static final QName ASPECT_RECORD_REJECTION_DETAILS = QName.createQName(RM_URI, "recordRejectionDetails");
+ public static final QName PROP_RECORD_REJECTION_USER_ID = QName.createQName(RM_URI, "recordRejectionUserId");
+ public static final QName PROP_RECORD_REJECTION_DATE = QName.createQName(RM_URI, "recordRejectionDate");
+ public static final QName PROP_RECORD_REJECTION_REASON = QName.createQName(RM_URI, "recordRejectionReason");
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java
index 597d2cbb59..a27d45fcce 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java
@@ -308,49 +308,77 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod
* Sends record rejected email notification.
*
* @param record rejected record
- * @param reason reason for rejection
- * @param userId the user id who rejected the record
*/
- public void recordRejectedEmailNotification(NodeRef record, String reason, String userId)
+ public void recordRejectedEmailNotification(NodeRef record)
{
ParameterCheck.mandatory("record", record);
- ParameterCheck.mandatoryString("reason", reason);
- ParameterCheck.mandatoryString("userId", userId);
- String recordCreator = (String) nodeService.getProperty(record, PROP_RECORD_USER_ID);
- if (StringUtils.isNotBlank(recordCreator) == true)
+ if (canSendRejectEmail(record) == true)
{
- SiteInfo site = siteService.getSite(record);
- if (site == null)
- {
- throw new AlfrescoRuntimeException("Could not find the site which should contain the node '" + record.toString() + "'.");
- }
+ String site = siteService.getSite(record).getShortName();
+ String recordCreator = (String) nodeService.getProperty(record, PROP_RECORD_ORIGINATING_USER_ID);
+ 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);
+
+ Map args = new HashMap(6);
+ args.put("record", record);
+ args.put("site", site);
+ args.put("recordCreator", recordCreator);
+ args.put("rejectReason", rejectReason);
+ args.put("rejectedPerson", rejectedPerson);
+ args.put("rejectDate", rejectDate);
NotificationContext notificationContext = new NotificationContext();
notificationContext.addTo(recordCreator);
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_REJECTED));
notificationContext.setBodyTemplate(getRejectedTemplate());
-
- Map args = new HashMap(6);
- args.put("site", site.getShortName());
- args.put("record", record);
- args.put("userName", recordCreator);
- args.put("rejectReason", reason);
- args.put("rejectDate", new Date());
- args.put("rejectedPerson", userId);
-
notificationContext.setTemplateArgs(args);
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
}
- else
+ }
+
+ /**
+ * Helper method to check if the mandatory properties are set
+ *
+ * @param record rejected record
+ */
+ private boolean canSendRejectEmail(NodeRef record)
+ {
+ boolean result = true;
+
+ String msg1 = "Unable to send record rejected email notification, because ";
+ String msg2 = " could not be found!";
+
+ if (siteService.getSite(record) == null)
{
- if (logger.isWarnEnabled() == true)
- {
- logger.warn("Unable to send record rejected email notification, because notification user was empty.");
- }
+ result = false;
+ logger.warn(msg1 + "the site which should contain the node '" + record.toString() + "'" + msg2);
}
+ if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_ORIGINATING_USER_ID)) == true)
+ {
+ result = false;
+ logger.warn(msg1 + "the user, who created the record" + msg2);
+ }
+ if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON)) == true)
+ {
+ result = false;
+ logger.warn(msg1 + "the reason for rejection" + msg2);
+ }
+ if (StringUtils.isBlank((String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID)) == true)
+ {
+ result = false;
+ logger.warn(msg1 + "the user, who rejected the record" + msg2);
+ }
+ if (((Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE)) == null)
+ {
+ result = false;
+ logger.warn(msg1 + "the date, when the record was rejected" + msg2);
+ }
+
+ return result;
}
/**
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
index 48d92f2a73..c32a35247f 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
@@ -330,11 +330,11 @@ public class RecordServiceImpl implements RecordService,
// move the document into the file plan
nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
- // Add the information about the original location
+ // save the information about the originating details
Map aspectProperties = new HashMap(3);
- aspectProperties.put(PROP_RECORD_ORIGINAL_LOCATION, (Serializable) parentAssoc.getParentRef());
- aspectProperties.put(PROP_RECORD_USER_ID, userId);
- aspectProperties.put(PROP_RECORD_CREATION_DATE, new Date());
+ aspectProperties.put(PROP_RECORD_ORIGINATING_LOCATION, (Serializable) parentAssoc.getParentRef());
+ aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, userId);
+ aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date());
nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties);
// make the document a record
@@ -461,11 +461,11 @@ public class RecordServiceImpl implements RecordService,
public Void doWork() throws Exception
{
// first remove the secondary link association
- NodeRef originalLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINAL_LOCATION);
+ NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
List parentAssocs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs)
{
- if (childAssociationRef.isPrimary() == false && childAssociationRef.getParentRef().equals(originalLocation))
+ if (childAssociationRef.isPrimary() == false && childAssociationRef.getParentRef().equals(originatingLocation))
{
nodeService.removeChildAssociation(childAssociationRef);
break;
@@ -483,13 +483,20 @@ public class RecordServiceImpl implements RecordService,
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
// move the record into the collaboration site
- nodeService.moveNode(nodeRef, originalLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
+ nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// remove all extended readers
extendedSecurityService.removeAllExtendedReaders(nodeRef);
- // Send an email to the record creator
- notificationHelper.recordRejectedEmailNotification(nodeRef, reason, userId);
+ // save the information about the rejection details
+ Map aspectProperties = new HashMap(3);
+ aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId);
+ aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date());
+ aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason);
+ nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties);
+
+ // send an email to the record creator
+ notificationHelper.recordRejectedEmailNotification(nodeRef);
return null;
}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/HideRecordActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/HideRecordActionTest.java
index 7173859046..700700a665 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/HideRecordActionTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/HideRecordActionTest.java
@@ -89,7 +89,7 @@ public class HideRecordActionTest extends BaseRMTestCase
assertTrue(recordService.isRecord(doc));
// The record should have the original location information
- assertNotNull(nodeService.getProperty(doc, PROP_RECORD_ORIGINAL_LOCATION));
+ assertNotNull(nodeService.getProperty(doc, PROP_RECORD_ORIGINATING_LOCATION));
// Check the parents. In this case the document should have two parents (doclib and fileplan)
assertTrue(nodeService.getParentAssocs(doc).size() == 2);
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/RejectActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/RejectActionTest.java
index 54ec9e6a8a..1af90cd232 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/RejectActionTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/action/RejectActionTest.java
@@ -75,7 +75,7 @@ public class RejectActionTest extends BaseRMTestCase
assertTrue(recordService.isRecord(dmDocument));
// The record should have the original location information
- assertNotNull(nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
+ assertNotNull(nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION));
// Check the parents. In this case the document should have two parents (doclib and fileplan)
assertTrue(nodeService.getParentAssocs(dmDocument).size() == 2);
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java
index c19c534919..98e27cd485 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java
@@ -258,7 +258,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
// show that the record has meta-data about it's original location
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS));
- assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
+ assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION));
assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef());
// show that the record is linked to it's original location
@@ -346,7 +346,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
// show that the record has meta-data about it's original location
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS));
- assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
+ assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINATING_LOCATION));
assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef());
// show that the record is linked to it's original location