mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature/RM-7027_Add_Hold_Deleted_ToAudit' into 'master'
Resolve RM-7027 "Feature/ add hold deleted to audit" Closes RM-7027 See merge request records-management/records-management!1295
This commit is contained in:
@@ -14,6 +14,7 @@ rm.audit.moveTo=Move to
|
||||
rm.audit.copyTo=Copy to
|
||||
rm.audit.fileTo=File to
|
||||
rm.audit.createHold=Create Hold
|
||||
rm.audit.deleteHold=Delete Hold
|
||||
rm.audit.audit-start=Audit Start
|
||||
rm.audit.audit-stop=Audit Stop
|
||||
rm.audit.audit-clear=Audit Clear
|
||||
|
@@ -1024,7 +1024,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="deleteHold" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DeleteHoldAction" parent="rmAction">
|
||||
<property name="auditedImmediately" value="true"/>
|
||||
<property name="auditable" value="false"/>
|
||||
</bean>
|
||||
|
||||
<bean id="deleteHold_proxy" parent="rmProxyAction" >
|
||||
|
@@ -133,4 +133,9 @@
|
||||
<property name="label" value="rm.audit.createHold"/>
|
||||
</bean>
|
||||
|
||||
<bean id="audit-event.deleteHold" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.DeleteHoldAuditEvent">
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
<property name="name" value="Delete Hold"/>
|
||||
<property name="label" value="rm.audit.deleteHold"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* #%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 java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldServicePolicies;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.EVERY_EVENT;
|
||||
|
||||
/**
|
||||
* Delete hold audit event.
|
||||
*
|
||||
* @author Sara Aspery
|
||||
* @since 3.3
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class DeleteHoldAuditEvent extends AuditEvent implements HoldServicePolicies.BeforeDeleteHoldPolicy
|
||||
{
|
||||
/** Node Service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Sets the node service
|
||||
*
|
||||
* @param nodeService nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldServicePolicies.BeforeDeleteHoldPolicy#beforeDeleteHold(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:hold",
|
||||
notificationFrequency = EVERY_EVENT
|
||||
)
|
||||
public void beforeDeleteHold(NodeRef holdNodeRef)
|
||||
{
|
||||
Map<QName, Serializable> auditProperties = HoldUtils.makePropertiesMap(holdNodeRef, nodeService);
|
||||
recordsManagementAuditService.auditEvent(holdNodeRef, getName(), auditProperties, null, true, false);
|
||||
}
|
||||
}
|
@@ -574,6 +574,55 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have created a hold
|
||||
* When I delete the hold and get the RM audit filter by delete hold event
|
||||
* Then there will be an entry for the deleted hold, including the hold name
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testAuditForDeleteHold()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
final static String DELETE_HOLD_AUDIT_EVENT = "Delete Hold";
|
||||
|
||||
String holdName = "Hold " + GUID.generate();
|
||||
|
||||
NodeRef hold;
|
||||
Map<QName, Serializable> auditEventProperties;
|
||||
|
||||
@Override
|
||||
public void given()
|
||||
{
|
||||
rmAuditService.clearAuditLog(filePlan);
|
||||
hold = createHold(holdName, "Reason " + GUID.generate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void when()
|
||||
{
|
||||
deleteHold(hold);
|
||||
auditEventProperties = getAuditEntry(DELETE_HOLD_AUDIT_EVENT).getBeforeProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void then()
|
||||
{
|
||||
// check delete hold audit event includes the hold name
|
||||
assertEquals("Delete Hold event does not include hold name.", holdName,
|
||||
auditEventProperties.get(HOLD_NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after()
|
||||
{
|
||||
// Stop and delete all entries
|
||||
rmAuditService.stopAuditLog(filePlan);
|
||||
rmAuditService.clearAuditLog(filePlan);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have created a hold
|
||||
* When I will get the RM audit filter by create hold event
|
||||
|
@@ -720,6 +720,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
return holdService.createHold(filePlan, holdName, holdReason, generate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Util method to delete a hold.
|
||||
* @param nodeRef hold node reference
|
||||
*/
|
||||
protected void deleteHold(NodeRef nodeRef)
|
||||
{
|
||||
holdService.deleteHold(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup multi hierarchy test data
|
||||
*/
|
||||
|
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* #%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.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DeleteHoldAuditEvent}.
|
||||
*
|
||||
* @author Sara Aspery
|
||||
* @since 3.3
|
||||
*/
|
||||
public class DeleteHoldAuditEventUnitTest extends BaseUnitTest
|
||||
{
|
||||
@InjectMocks
|
||||
private DeleteHoldAuditEvent deleteHoldAuditEvent;
|
||||
|
||||
@Mock
|
||||
private NodeService mockedNodeService;
|
||||
|
||||
private NodeRef holdNodeRef;
|
||||
|
||||
/** Set up the mocks. */
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
initMocks(this);
|
||||
|
||||
holdNodeRef = generateNodeRef();
|
||||
String holdName = "Hold " + GUID.generate();
|
||||
|
||||
when(mockedNodeService.getProperty(holdNodeRef, PROP_NAME)).thenReturn(holdName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the delete hold event calls an audit event.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteHoldCausesAuditEvent()
|
||||
{
|
||||
deleteHoldAuditEvent.beforeDeleteHold(holdNodeRef);
|
||||
verify(mockedRecordsManagementAuditService, times(1))
|
||||
.auditEvent(eq(holdNodeRef), any(String.class), any(Map.class), isNull(Map.class), Matchers.eq(true), Matchers.eq(false));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user