mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature-2.4/RM-3293_Audit_not_log_default_scheduled' into 'release/V2.4'
Feature 2.4/rm 3293 audit not log default scheduled See merge request !242
This commit is contained in:
@@ -17,6 +17,9 @@ imap.server.attachments.extraction.enabled=false
|
|||||||
#
|
#
|
||||||
audit.enabled=true
|
audit.enabled=true
|
||||||
audit.rm.enabled=true
|
audit.rm.enabled=true
|
||||||
|
#audit.rm.runas=admin
|
||||||
|
|
||||||
|
#audit.filter.alfresco-access.transaction.user=~null;.*
|
||||||
|
|
||||||
#
|
#
|
||||||
# Extended permission service cache sizing
|
# Extended permission service cache sizing
|
||||||
@@ -46,7 +49,7 @@ rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes=rma:record,cm:c
|
|||||||
#
|
#
|
||||||
# Global RM disposition lifecycle trigger cron job expression
|
# Global RM disposition lifecycle trigger cron job expression
|
||||||
#
|
#
|
||||||
rm.dispositionlifecycletrigger.cronexpression=0 0/5 * * * ?
|
rm.dispositionlifecycletrigger.cronexpression=0 0/2 * * * ?
|
||||||
|
|
||||||
#
|
#
|
||||||
# Records contributors group
|
# Records contributors group
|
||||||
|
@@ -51,23 +51,25 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Disposition Lifecycle Job -->
|
<!-- Disposition Lifecycle Job -->
|
||||||
<bean id="scheduledDispositionLifecyceleJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
|
<bean id="scheduledDispositionLifecyceleJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
|
||||||
<property name="jobClass">
|
|
||||||
<value>org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob</value>
|
<property name="jobClass">
|
||||||
</property>
|
<value>org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob</value>
|
||||||
<property name="jobDataAsMap">
|
</property>
|
||||||
<map>
|
<property name="jobDataAsMap">
|
||||||
<entry key="jobName" value="dispositionLifecycle"/>
|
<map>
|
||||||
<entry key="jobLockService">
|
<entry key="jobName" value="dispositionLifecycle" />
|
||||||
<ref bean="jobLockService" />
|
<entry key="runAuditAs" value="${audit.rm.runas}" />
|
||||||
</entry>
|
<entry key="jobLockService">
|
||||||
<entry key="jobExecuter">
|
<ref bean="jobLockService" />
|
||||||
<ref bean="dispositionLifecycleJobExecuter" />
|
</entry>
|
||||||
</entry>
|
<entry key="jobExecuter">
|
||||||
</map>
|
<ref bean="dispositionLifecycleJobExecuter" />
|
||||||
</property>
|
</entry>
|
||||||
</bean>
|
</map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="dispositionLifecycleJobExecuter"
|
<bean id="dispositionLifecycleJobExecuter"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.job.DispositionLifecycleJobExecuter"
|
class="org.alfresco.module.org_alfresco_module_rm.job.DispositionLifecycleJobExecuter"
|
||||||
@@ -83,6 +85,7 @@
|
|||||||
|
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="nodeService" />
|
||||||
<property name="searchService" ref="searchService" />
|
<property name="searchService" ref="searchService" />
|
||||||
|
<property name="authenticationService" ref="authenticationService" />
|
||||||
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
@@ -94,7 +97,7 @@
|
|||||||
<ref bean="schedulerFactory" />
|
<ref bean="schedulerFactory" />
|
||||||
</property>
|
</property>
|
||||||
<property name="cronExpression">
|
<property name="cronExpression">
|
||||||
|
|
||||||
<!-- run at 3am -->
|
<!-- run at 3am -->
|
||||||
<!-- <value>0 30 3 * * ?</value> -->
|
<!-- <value>0 30 3 * * ?</value> -->
|
||||||
<!-- <value>0/30 * * * * ?</value> -->
|
<!-- <value>0/30 * * * * ?</value> -->
|
||||||
|
@@ -43,16 +43,13 @@ import org.alfresco.service.cmr.repository.NodeService;
|
|||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Disposition Lifecycle Job Finds all disposition action nodes which are
|
* The Disposition Lifecycle Job Finds all disposition action nodes which are for disposition actions specified Where
|
||||||
* for disposition actions specified Where asOf > now OR
|
* asOf > now OR dispositionEventsEligible = true; Runs the cut off or retain action for eligible records.
|
||||||
* dispositionEventsEligible = true;
|
|
||||||
*
|
|
||||||
* Runs the cut off or retain action for
|
|
||||||
* eligible records.
|
|
||||||
*
|
*
|
||||||
* @author mrogers
|
* @author mrogers
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
@@ -77,10 +74,13 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
/** search service */
|
/** search service */
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
|
|
||||||
|
/** authenticationService service */
|
||||||
|
private AuthenticationService authenticationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of disposition actions to automatically execute when eligible.
|
* List of disposition actions to automatically execute when eligible.
|
||||||
*
|
*
|
||||||
* @param dispositionActions disposition actions
|
* @param dispositionActions disposition actions
|
||||||
*/
|
*/
|
||||||
public void setDispositionActions(List<String> dispositionActions)
|
public void setDispositionActions(List<String> dispositionActions)
|
||||||
{
|
{
|
||||||
@@ -88,7 +88,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordsManagementActionService records management action service
|
* @param recordsManagementActionService records management action service
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeService node service
|
* @param nodeService node service
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -114,7 +114,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
/**
|
/**
|
||||||
* Get the search query string.
|
* Get the search query string.
|
||||||
*
|
*
|
||||||
* @return job query string
|
* @return job query string
|
||||||
*/
|
*/
|
||||||
protected String getQuery()
|
protected String getQuery()
|
||||||
{
|
{
|
||||||
@@ -165,7 +165,8 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
if (dispositionActions != null && !dispositionActions.isEmpty())
|
if (dispositionActions != null && !dispositionActions.isEmpty())
|
||||||
{
|
{
|
||||||
// execute search
|
// execute search
|
||||||
ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, getQuery());
|
ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
|
||||||
|
SearchService.LANGUAGE_FTS_ALFRESCO, getQuery());
|
||||||
List<NodeRef> resultNodes = results.getNodeRefs();
|
List<NodeRef> resultNodes = results.getNodeRefs();
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
@@ -183,7 +184,8 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
{
|
{
|
||||||
public Boolean execute()
|
public Boolean execute()
|
||||||
{
|
{
|
||||||
final String dispAction = (String) nodeService.getProperty(currentNode, RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
final String dispAction = (String) nodeService.getProperty(currentNode,
|
||||||
|
RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
||||||
|
|
||||||
// Run disposition action
|
// Run disposition action
|
||||||
if (dispAction != null && dispositionActions.contains(dispAction))
|
if (dispAction != null && dispositionActions.contains(dispAction))
|
||||||
@@ -192,12 +194,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
if (parent.getTypeQName().equals(RecordsManagementModel.ASSOC_NEXT_DISPOSITION_ACTION))
|
if (parent.getTypeQName().equals(RecordsManagementModel.ASSOC_NEXT_DISPOSITION_ACTION))
|
||||||
{
|
{
|
||||||
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
||||||
props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE);
|
props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK,
|
||||||
|
Boolean.FALSE);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// execute disposition action
|
// execute disposition action
|
||||||
recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction, props);
|
recordsManagementActionService.executeRecordsManagementAction(
|
||||||
|
parent.getParentRef(), dispAction, props);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
@@ -236,4 +240,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthenticationService getAuthenticationService()
|
||||||
|
{
|
||||||
|
return authenticationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthenticationService(AuthenticationService authenticationService)
|
||||||
|
{
|
||||||
|
this.authenticationService = authenticationService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,8 +46,7 @@ import org.quartz.JobExecutionException;
|
|||||||
/**
|
/**
|
||||||
* Base records management job implementation.
|
* Base records management job implementation.
|
||||||
* <p>
|
* <p>
|
||||||
* Delegates job execution and ensures locking
|
* Delegates job execution and ensures locking is enforced.
|
||||||
* is enforced.
|
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
@@ -55,11 +54,14 @@ public class RecordsManagementJob implements Job
|
|||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(RecordsManagementJob.class);
|
private static Log logger = LogFactory.getLog(RecordsManagementJob.class);
|
||||||
|
|
||||||
|
/** which user should be used to log audit */
|
||||||
|
private String runAuditAs = AuthenticationUtil.getSystemUserName();
|
||||||
|
|
||||||
private static final long DEFAULT_TIME = 30000L;
|
private static final long DEFAULT_TIME = 30000L;
|
||||||
|
|
||||||
private JobLockService jobLockService;
|
private JobLockService jobLockService;
|
||||||
|
|
||||||
private RecordsManagementJobExecuter jobExecuter;
|
private RecordsManagementJobExecuter jobExecuter = null;
|
||||||
|
|
||||||
private String jobName;
|
private String jobName;
|
||||||
|
|
||||||
@@ -67,17 +69,17 @@ public class RecordsManagementJob implements Job
|
|||||||
{
|
{
|
||||||
return QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, jobName);
|
return QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, jobName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LockCallback implements JobLockRefreshCallback
|
private class LockCallback implements JobLockRefreshCallback
|
||||||
{
|
{
|
||||||
final AtomicBoolean running = new AtomicBoolean(true);
|
final AtomicBoolean running = new AtomicBoolean(true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive()
|
public boolean isActive()
|
||||||
{
|
{
|
||||||
return running.get();
|
return running.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lockReleased()
|
public void lockReleased()
|
||||||
{
|
{
|
||||||
@@ -85,11 +87,10 @@ public class RecordsManagementJob implements Job
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
|
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
|
||||||
*
|
*
|
||||||
* @return Returns the lock token or <tt>null</tt>
|
* @return Returns the lock token or <tt>null</tt>
|
||||||
*/
|
*/
|
||||||
private String getLock()
|
private String getLock()
|
||||||
{
|
{
|
||||||
@@ -103,31 +104,54 @@ public class RecordsManagementJob implements Job
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
|
||||||
|
*/
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException
|
public void execute(JobExecutionContext context) throws JobExecutionException
|
||||||
{
|
{
|
||||||
|
|
||||||
// get the job lock service
|
// get the job lock service
|
||||||
jobLockService = (JobLockService)context.getJobDetail().getJobDataMap().get("jobLockService");
|
jobLockService = (JobLockService) context.getJobDetail().getJobDataMap().get("jobLockService");
|
||||||
if (jobLockService == null)
|
if (jobLockService == null) { throw new AlfrescoRuntimeException("Job lock service has not been specified."); }
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Job lock service has not been specified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the job executer
|
// get the job executer
|
||||||
jobExecuter = (RecordsManagementJobExecuter)context.getJobDetail().getJobDataMap().get("jobExecuter");
|
jobExecuter = (RecordsManagementJobExecuter) context.getJobDetail().getJobDataMap().get("jobExecuter");
|
||||||
if (jobExecuter == null)
|
if (jobExecuter == null) { throw new AlfrescoRuntimeException("Job executer has not been specified."); }
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Job executer has not been specified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the job name
|
// get the job name
|
||||||
jobName = (String)context.getJobDetail().getJobDataMap().get("jobName");
|
jobName = (String) context.getJobDetail().getJobDataMap().get("jobName");
|
||||||
if (jobName == null)
|
|
||||||
|
if (jobName == null) { throw new AlfrescoRuntimeException("Job name has not been specified."); }
|
||||||
|
|
||||||
|
if (jobName.compareTo("dispositionLifecycle") == 0)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Job name has not been specified.");
|
//RM-3293 - set user for audit
|
||||||
|
if (jobExecuter instanceof DispositionLifecycleJobExecuter)
|
||||||
|
{
|
||||||
|
String auditUser = (String) context.getJobDetail().getJobDataMap().get("runAuditAs");
|
||||||
|
if (((DispositionLifecycleJobExecuter) jobExecuter).getAuthenticationService()
|
||||||
|
.authenticationExists(auditUser))
|
||||||
|
{
|
||||||
|
|
||||||
|
setRunAuditAs(auditUser);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setRunAuditAs(AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("DispositionLifecycleJobExecuter() logged audit history with user: " + getRunAuditAs());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final LockCallback lockCallback = new LockCallback();
|
final LockCallback lockCallback = new LockCallback();
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
@@ -154,7 +178,8 @@ public class RecordsManagementJob implements Job
|
|||||||
// Ignore
|
// Ignore
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "(" + e.getMessage() + ")");
|
logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "("
|
||||||
|
+ e.getMessage() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,6 +188,18 @@ public class RecordsManagementJob implements Job
|
|||||||
// return
|
// return
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, getRunAuditAs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRunAuditAs()
|
||||||
|
{
|
||||||
|
return runAuditAs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunAuditAs(String runAuditAs)
|
||||||
|
{
|
||||||
|
|
||||||
|
this.runAuditAs = runAuditAs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user