cancel
Showing results for 
Search instead for 
Did you mean: 

How to audit the consultation document?

unknown-user
Champ on-the-rise
Champ on-the-rise
I want to audit the consultation of the documents. How I can do?
Is possible audit Web Scripts?

Thanks
2 REPLIES 2

unknown-user
Champ on-the-rise
Champ on-the-rise
I have solved the problem, I have created a web script javaBacked:

public class Audit extends AbstractWebScript {
   private final Log logger = LogFactory.getLog(visorSignatures.class);
   private AuditComponent auditComponent;

   // for Spring injection
   public void setAuditComponent(AuditComponent auditComponent) {
      this.auditComponent = auditComponent;
   }

   public void execute(WebScriptRequest req, WebScriptResponse res)
         throws IOException {
      Map<String, Serializable> auditMap = new HashMap<String, Serializable>();
      String source = req.getParameter("source");
      String userName = req.getParameter("userName");
      String fullName = req.getParameter("fullName");

      try {
         auditMap.put(AuditApplication.buildPath("/userName"), userName);
         auditMap.put(AuditApplication.buildPath("/source"), source);
         auditMap.put(AuditApplication.buildPath("/fullName"), fullName);

         auditComponent.recordAuditValues(source, auditMap);

         logger.debug("RM Audit: Auditing values: \n" + auditMap);

      } catch (Exception e) {
         throw new AlfrescoRuntimeException(
               "Error en la generació de registres d'auditoria", e);
      }
   }
}

Also is necesary to add a new path in rm-audit.xml:
<?xml version='1.0' encoding='UTF-8'?>

<!– Default Audit Configuration –>

<Audit
    xmlns="http://www.alfresco.org/repo/audit/model/3.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.alfresco.org/repo/audit/model/3.2 alfresco-audit-3.2.xsd"
    >

    <DataExtractors>
       <DataExtractor name="simpleValue" registeredName="auditModel.extractor.simpleValue"/>
       <DataExtractor name="nullValue" registeredName="auditModel.extractor.nullValue"/>
       <DataExtractor name="nodeName" registeredName="auditModel.extractor.nodeName"/>
       <DataExtractor name="nodeType" registeredName="auditModel.extractor.nodeType"/>
       <DataExtractor name="userRoles" registeredName="org_alfresco_module_dod5015_userRolesExtractor"/>
       <DataExtractor name="namePath" registeredName="org_alfresco_module_dod5015_namePathExtractor"/>
       <DataExtractor name="nodeRefPath" registeredName="org_alfresco_module_dod5015_nodeRefPathExtractor"/>
       <DataExtractor name="nodeIdentifier" registeredName="org_alfresco_module_dod5015_identifierExtractor"/>
    </DataExtractors>
   
    <DataGenerators>
       <DataGenerator name="personFullName" registeredName="auditModel.generator.personFullName"/>
    </DataGenerators>

    <PathMappings>
        <PathMap source="/DOD5015" target="/DOD5015"/>
        <!– Force the fullName generator to trigger –>
        <PathMap source="/DOD5015/event/node" target="/DOD5015/event/person"/>
        <PathMap source="/alfresco-api/post/AuthenticationService/authenticate" target="/DOD5015/login"/>
        <PathMap source="/DOD5015/visorSignatures" target="/DOD5015/visorSignatures"/>
        <PathMap source="/DOD5015/consultaDocument" target="/DOD5015/consultaDocument"/>       
    </PathMappings>

    <Application name="DOD5015" key="DOD5015">
        <AuditPath key="event">
            <!– Record user details –>
            <AuditPath key="person">
                <RecordValue key="roles" dataExtractor="userRoles"/>
                <GenerateValue key="fullName" dataGenerator="personFullName"/>
            </AuditPath>
            <!– Record a description of the event –>
            <AuditPath key="name">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
            <!– Record the node's details –>
            <AuditPath key="node">
                <RecordValue key="noderef" dataExtractor="simpleValue"/>
                <RecordValue key="name" dataExtractor="nodeName"/>
                <RecordValue key="type" dataExtractor="nodeType"/>
                <RecordValue key="namePath" dataExtractor="namePath"/>
                <RecordValue key="nodeRefPath" dataExtractor="nodeRefPath"/>
                <RecordValue key="identifier" dataExtractor="nodeIdentifier"/>
                <AuditPath key="changes">
                   <AuditPath key="before">
                       <RecordValue key="value" dataExtractor="simpleValue"/>
                   </AuditPath>
                    <AuditPath key="after">
                        <RecordValue key="value" dataExtractor="simpleValue"/>
                    </AuditPath>
                </AuditPath>
            </AuditPath>
            <!–
                RM action parameters
                * Keyed by action name to be more selective
                * Only record the parameters if they are of interest
            –>
            <!– A test action –>
            <AuditPath key="testAction">
                <AuditPath key="parameters">
                    <AuditPath key="testActionParam">
                        <RecordValue key="value" dataExtractor="simpleValue"/>
                    </AuditPath>
                </AuditPath>
            </AuditPath>
        </AuditPath>
        <AuditPath key="login">
            <AuditPath key="args">
                <AuditPath key="userName">
                    <RecordValue key="value" dataExtractor="simpleValue"/>
                </AuditPath>
            </AuditPath>
            <AuditPath key="no-error">
                <GenerateValue key="fullName" dataGenerator="personFullName"/>
            </AuditPath>
            <AuditPath key="error">
                <RecordValue key="value" dataExtractor="nullValue"/>
            </AuditPath>
        </AuditPath>

        <AuditPath key="visorSignatures">
            <AuditPath key="userName">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
            <AuditPath key="fullName">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
            <AuditPath key="source">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
        </AuditPath>

        <AuditPath key="consultaDocument">
            <AuditPath key="userName">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
            <AuditPath key="fullName">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
            <AuditPath key="source">
                <RecordValue key="value" dataExtractor="simpleValue"/>
            </AuditPath>
        </AuditPath>

    </Application>

</Audit>

The last step is to call to the new webscript javabacked from the webscript named web-preview. I have added the remote call in the file web-preview.get.js

lammersjo
Champ in-the-making
Champ in-the-making
Hi RCR,

Did you solve the problem to audit the 'read' access of a document.