mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-7026 Audit Create Hold updates
This commit is contained in:
@@ -28,22 +28,17 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldServicePolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
import static org.alfresco.model.ContentModel.PROP_DESCRIPTION;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
/**
|
||||
* Create hold audit event.
|
||||
*
|
||||
@@ -51,12 +46,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
* @since 3.3
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CreateHoldAuditEvent extends AuditEvent implements HoldServicePolicies.OnCreateHoldPolicy
|
||||
public class CreateHoldAuditEvent extends AuditEvent
|
||||
{
|
||||
/** QNames to display for the hold's properties. */
|
||||
private static final QName HOLD_NAME = QName.createQName(RecordsManagementModel.RM_URI, "Hold Name");
|
||||
private static final QName HOLD_DESCRIPTION = QName.createQName(RecordsManagementModel.RM_URI, "Hold Description");
|
||||
|
||||
/** Node Service */
|
||||
private NodeService nodeService;
|
||||
|
||||
@@ -71,20 +62,21 @@ public class CreateHoldAuditEvent extends AuditEvent implements HoldServicePolic
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldServicePolicies.OnCreateHoldPolicy#onCreateHold(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @param childAssociationRef child association reference
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:hold"
|
||||
type = "rma:hold",
|
||||
policy = "alf:onCreateNode",
|
||||
notificationFrequency= NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onCreateHold(NodeRef holdNodeRef)
|
||||
public void onCreateHold(ChildAssociationRef childAssociationRef)
|
||||
{
|
||||
Map<QName, Serializable> auditProperties = new HashMap<>();
|
||||
auditProperties.put(ContentModel.PROP_NAME, nodeService.getProperty(holdNodeRef, ContentModel.PROP_NAME));
|
||||
NodeRef holdNodeRef = childAssociationRef.getChildRef();
|
||||
|
||||
Map<QName, Serializable> auditProperties = HoldUtils.makePropertiesMap(holdNodeRef, nodeService);
|
||||
auditProperties.put(PROP_HOLD_REASON, nodeService.getProperty(holdNodeRef, PROP_HOLD_REASON));
|
||||
auditProperties.put(PROP_DESCRIPTION, nodeService.getProperty(holdNodeRef, PROP_DESCRIPTION));
|
||||
|
||||
recordsManagementAuditService.auditEvent(holdNodeRef, getName(), null, auditProperties);
|
||||
}
|
||||
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class for creating audit events about holds.
|
||||
*
|
||||
* @author Sara Aspery
|
||||
* @since 3.3
|
||||
*/
|
||||
class HoldUtils
|
||||
{
|
||||
/**
|
||||
* Create a properties map containing the hold name for the given hold.
|
||||
*
|
||||
* @param nodeRef The nodeRef of the hold.
|
||||
* @param nodeService The node service.
|
||||
* @return A map containing the name of the hold.
|
||||
*/
|
||||
static Map<QName, Serializable> makePropertiesMap(NodeRef nodeRef, NodeService nodeService)
|
||||
{
|
||||
Map<QName, Serializable> auditProperties = new HashMap<>();
|
||||
|
||||
auditProperties.put(ContentModel.PROP_NAME, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||
|
||||
return auditProperties;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user