mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-4106 (ALF-4103): AuditService REST API
- Full start/stop/status using WebScripts - AuditService API additions to support - .ftl to generate json response - Some javadoc and debug additions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21802 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -9,43 +9,33 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
<DataExtractors>
|
<DataExtractors>
|
||||||
<DataExtractor name="simpleValue" class="org.alfresco.repo.audit.extractor.SimpleValueDataExtractor"/>
|
<DataExtractor name="simpleValue" registeredName="auditModel.extractor.simpleValue"/>
|
||||||
<!--
|
<DataExtractor name="nullValue" registeredName="auditModel.extractor.nullValue"/>
|
||||||
<DataExtractor name="stackTrace" class="org.alfresco.repo.audit.extractor.StackTraceDataExtractor"/>
|
|
||||||
<DataExtractor name="storeRootNode" class="org.alfresco.repo.audit.extractor.StoreRootNodeDataExtractor"/>
|
|
||||||
-->
|
|
||||||
</DataExtractors>
|
</DataExtractors>
|
||||||
|
|
||||||
<DataGenerators>
|
<DataGenerators>
|
||||||
<DataGenerator name="transactionId" class="org.alfresco.repo.audit.generator.TransactionIdDataGenerator"/>
|
<DataGenerator name="personFullName" registeredName="auditModel.generator.personFullName"/>
|
||||||
</DataGenerators>
|
</DataGenerators>
|
||||||
|
|
||||||
<PathMappings>
|
<PathMappings>
|
||||||
<PathMap source="/repository" target="/repository"/>
|
<PathMap source="/alfresco-api/post/AuthenticationService/authenticate" target="/repository/login"/>
|
||||||
</PathMappings>
|
</PathMappings>
|
||||||
|
|
||||||
<Application name="Alfresco Repository" key="repository">
|
<Application name="AlfrescoRepository" key="repository">
|
||||||
<AuditPath key="services">
|
<AuditPath key="login">
|
||||||
<GenerateValue key="txn" dataGenerator="transactionId"/>
|
<AuditPath key="args">
|
||||||
<AuditPath key="nodeservice">
|
<AuditPath key="userName">
|
||||||
<AuditPath key="createstore">
|
<RecordValue key="value" dataExtractor="simpleValue"/>
|
||||||
<AuditPath key="protocol">
|
|
||||||
<RecordValue key="value" dataExtractor="simpleValue"/>
|
|
||||||
</AuditPath>
|
|
||||||
<AuditPath key="identifier">
|
|
||||||
<RecordValue key="value" dataExtractor="simpleValue"/>
|
|
||||||
</AuditPath>
|
|
||||||
<AuditPath key="return">
|
|
||||||
<RecordValue key="value" dataExtractor="simpleValue"/>
|
|
||||||
<!--
|
|
||||||
<RecordValue key="root-node" dataExtractor="storeRootNode"/>
|
|
||||||
</AuditPath>
|
|
||||||
<AuditPath key="error">
|
|
||||||
<RecordValue key="value" dataExtractor="stackTrace"/>
|
|
||||||
-->
|
|
||||||
</AuditPath>
|
|
||||||
</AuditPath>
|
</AuditPath>
|
||||||
</AuditPath>
|
</AuditPath>
|
||||||
|
<!--
|
||||||
|
<AuditPath key="no-error">
|
||||||
|
<GenerateValue key="fullName" dataGenerator="personFullName"/>
|
||||||
|
</AuditPath>
|
||||||
|
-->
|
||||||
|
<AuditPath key="error">
|
||||||
|
<RecordValue key="value" dataExtractor="nullValue"/>
|
||||||
|
</AuditPath>
|
||||||
</AuditPath>
|
</AuditPath>
|
||||||
</Application>
|
</Application>
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ package org.alfresco.repo.audit;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.repo.audit.model.AuditApplication;
|
import org.alfresco.repo.audit.model.AuditApplication;
|
||||||
import org.alfresco.repo.audit.model.AuditModelRegistry;
|
import org.alfresco.repo.audit.model.AuditModelRegistry;
|
||||||
@@ -56,11 +55,11 @@ public interface AuditComponent
|
|||||||
/**
|
/**
|
||||||
* Get all registered audit applications, whether active or not.
|
* Get all registered audit applications, whether active or not.
|
||||||
*
|
*
|
||||||
* @return Returns a set of registered audit applications
|
* @return Returns a map of registered audit applications keyed by name
|
||||||
*
|
*
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
public Set<String> getAuditApplications();
|
public Map<String, AuditApplication> getAuditApplications();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the given source path is mapped to any audit applications. Allows optimizations to be made in
|
* Determines whether the given source path is mapped to any audit applications. Allows optimizations to be made in
|
||||||
|
@@ -48,7 +48,8 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default audit component implementation. TODO: Implement before, after and exception filtering. At the moment
|
* The default audit component implementation.
|
||||||
|
* <TODO: Implement before, after and exception filtering. At the moment
|
||||||
* these filters are ignored. TODO: Respect audit internal - at the moment audit internal is fixed to false.
|
* these filters are ignored. TODO: Respect audit internal - at the moment audit internal is fixed to false.
|
||||||
* <p/>
|
* <p/>
|
||||||
* The V3.2 audit functionality is contained within the same component. When the newer audit
|
* The V3.2 audit functionality is contained within the same component. When the newer audit
|
||||||
@@ -190,10 +191,9 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
public Set<String> getAuditApplications()
|
public Map<String, AuditApplication> getAuditApplications()
|
||||||
{
|
{
|
||||||
Map<String, AuditApplication> auditApps = auditModelRegistry.getAuditApplications();
|
return auditModelRegistry.getAuditApplications();
|
||||||
return auditApps.keySet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,7 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.audit;
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||||
import org.alfresco.service.cmr.audit.AuditService;
|
import org.alfresco.service.cmr.audit.AuditService;
|
||||||
@@ -67,9 +68,20 @@ public class AuditServiceImpl implements AuditService
|
|||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getAuditApplications()
|
public Map<String, AuditApplication> getAuditApplications()
|
||||||
{
|
{
|
||||||
return auditComponent.getAuditApplications();
|
Map<String, org.alfresco.repo.audit.model.AuditApplication> apps = auditComponent.getAuditApplications();
|
||||||
|
|
||||||
|
Map<String, AuditApplication> ret = new HashMap<String, AuditApplication>(apps.size() * 2);
|
||||||
|
for (String app : apps.keySet())
|
||||||
|
{
|
||||||
|
String name = app;
|
||||||
|
String key = org.alfresco.repo.audit.model.AuditApplication.AUDIT_PATH_SEPARATOR + apps.get(app).getApplicationKey();
|
||||||
|
boolean enabled = auditComponent.isAuditPathEnabled(app, key);
|
||||||
|
AuditApplication auditApplication = new AuditApplication(name, key, enabled);
|
||||||
|
ret.put(name, auditApplication);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -199,11 +199,12 @@ public class AuditApplication
|
|||||||
{
|
{
|
||||||
if (path == null || path.length() == 0)
|
if (path == null || path.length() == 0)
|
||||||
{
|
{
|
||||||
throw new AuditModelException("Empty or null audit path");
|
throw new AuditModelException("Empty or null audit path: " + path);
|
||||||
}
|
}
|
||||||
else if (!path.matches(AUDIT_PATH_REGEX))
|
else if (!path.matches(AUDIT_PATH_REGEX))
|
||||||
{
|
{
|
||||||
throw new AuditModelException("An audit must match regular expression: " + AUDIT_PATH_REGEX);
|
throw new AuditModelException(
|
||||||
|
"Audit path '" + path + "' does not match regular expression: " + AUDIT_PATH_REGEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,6 +37,14 @@ import org.alfresco.util.PropertyCheck;
|
|||||||
* A listener that ensures that an event is audited for every deleted node in a tree of nodes, not just the top one
|
* A listener that ensures that an event is audited for every deleted node in a tree of nodes, not just the top one
|
||||||
* captured by {@link AuditMethodInterceptor}!
|
* captured by {@link AuditMethodInterceptor}!
|
||||||
*
|
*
|
||||||
|
* The values passed to the audit component are:
|
||||||
|
* <pre>
|
||||||
|
* /alfresco-node
|
||||||
|
* /beforeDeleteNode
|
||||||
|
* /node=<nodeRef>
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @author dward
|
* @author dward
|
||||||
*/
|
*/
|
||||||
public class NodeAuditor implements InitializingBean, NodeServicePolicies.BeforeDeleteNodePolicy
|
public class NodeAuditor implements InitializingBean, NodeServicePolicies.BeforeDeleteNodePolicy
|
||||||
|
@@ -20,7 +20,6 @@ package org.alfresco.service.cmr.audit;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.service.PublicService;
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
@@ -47,15 +46,49 @@ public interface AuditService
|
|||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
void setAuditEnabled(boolean enable);
|
void setAuditEnabled(boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper bean to carry information about an audit application.
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 3.4
|
||||||
|
*/
|
||||||
|
public static class AuditApplication
|
||||||
|
{
|
||||||
|
private final String name;
|
||||||
|
private final String key;
|
||||||
|
private final boolean enabled;
|
||||||
|
/**
|
||||||
|
* Constructor for final variables
|
||||||
|
*/
|
||||||
|
public AuditApplication(String name, String key, boolean enabled)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.key = key;
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public String getKey()
|
||||||
|
{
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all registered audit applications
|
* Get all registered audit applications
|
||||||
*
|
*
|
||||||
* @return Returns a set of all available audit applications
|
* @return Returns a map of audit applications keyed by their name
|
||||||
*
|
*
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
Set<String> getAuditApplications();
|
Map<String, AuditApplication> getAuditApplications();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param applicationName the name of the application to check
|
* @param applicationName the name of the application to check
|
||||||
|
Reference in New Issue
Block a user