ALF-4106 AuditService REST API: Added 'dataTrigger' to 'RecordValue'

- Prevents RecordValue elements from activating unnecessarily
 - Without any entries, everything behaves as before i.e. 'RecordValue' triggers on data entries at the current path


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22197 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-09-02 18:11:43 +00:00
parent 797930fae1
commit 7594b32677
17 changed files with 68 additions and 238 deletions

View File

@@ -87,6 +87,7 @@
<xs:extension base="a:KeyedAuditDefinition"> <xs:extension base="a:KeyedAuditDefinition">
<xs:attribute name="dataExtractor" type="a:NameAttribute" use="required" /> <xs:attribute name="dataExtractor" type="a:NameAttribute" use="required" />
<xs:attribute name="dataSource" type="a:PathAttribute" use="optional" /> <xs:attribute name="dataSource" type="a:PathAttribute" use="optional" />
<xs:attribute name="dataTrigger" type="a:PathAttribute" use="optional" />
</xs:extension> </xs:extension>
</xs:complexContent> </xs:complexContent>
</xs:complexType> </xs:complexType>

View File

@@ -15,6 +15,7 @@
<DataGenerators> <DataGenerators>
<DataGenerator name="personFullName" registeredName="auditModel.generator.personFullName"/> <DataGenerator name="personFullName" registeredName="auditModel.generator.personFullName"/>
<DataGenerator name="authenticatedUser" registeredName="auditModel.generator.user"/>
</DataGenerators> </DataGenerators>
<PathMappings> <PathMappings>
@@ -23,11 +24,9 @@
<Application name="AlfrescoRepository" key="repository"> <Application name="AlfrescoRepository" key="repository">
<AuditPath key="login"> <AuditPath key="login">
<!--
<AuditPath key="no-error"> <AuditPath key="no-error">
<RecordValue key="user" dataExtractor="simpleValue" dataSource="/repository/login/args/userName"/> <RecordValue key="user" dataExtractor="simpleValue" dataSource="/repository/login/args/userName"/>
</AuditPath> </AuditPath>
-->
<AuditPath key="error"> <AuditPath key="error">
<RecordValue key="user" dataExtractor="simpleValue" dataSource="/repository/login/args/userName"/> <RecordValue key="user" dataExtractor="simpleValue" dataSource="/repository/login/args/userName"/>
</AuditPath> </AuditPath>

View File

@@ -651,9 +651,16 @@ public class AuditComponentImpl implements AuditComponent
for (DataExtractorDefinition extractorDef : extractors) for (DataExtractorDefinition extractorDef : extractors)
{ {
DataExtractor extractor = extractorDef.getDataExtractor(); DataExtractor extractor = extractorDef.getDataExtractor();
String triggerPath = extractorDef.getDataTrigger();
String sourcePath = extractorDef.getDataSource(); String sourcePath = extractorDef.getDataSource();
String targetPath = extractorDef.getDataTarget(); String targetPath = extractorDef.getDataTarget();
// Check if it is triggered
if (!values.containsKey(triggerPath))
{
continue; // It is not triggered
}
// We observe the key, not the actual value // We observe the key, not the actual value
if (!values.containsKey(sourcePath)) if (!values.containsKey(sourcePath))
{ {

View File

@@ -290,22 +290,33 @@ public class AuditApplication
*/ */
public static class DataExtractorDefinition public static class DataExtractorDefinition
{ {
private final String dataTrigger;
private final String dataSource; private final String dataSource;
private final String dataTarget; private final String dataTarget;
private final DataExtractor dataExtractor; private final DataExtractor dataExtractor;
/** /**
* @param dataTrigger the data path that must exist for this extractor to be triggered
* @param dataSource the path to get data from * @param dataSource the path to get data from
* @param dataTarget the path to write data to * @param dataTarget the path to write data to
* @param dataExtractor the implementation to use * @param dataExtractor the implementation to use
*/ */
public DataExtractorDefinition(String dataSource, String dataTarget, DataExtractor dataExtractor) public DataExtractorDefinition(String dataTrigger, String dataSource, String dataTarget, DataExtractor dataExtractor)
{ {
this.dataTrigger = dataTrigger;
this.dataSource = dataSource; this.dataSource = dataSource;
this.dataTarget = dataTarget; this.dataTarget = dataTarget;
this.dataExtractor = dataExtractor; this.dataExtractor = dataExtractor;
} }
/**
* The data path that must exist for the extractor to be triggered.
*/
public String getDataTrigger()
{
return dataTrigger;
}
public String getDataSource() public String getDataSource()
{ {
return dataSource; return dataSource;
@@ -442,8 +453,14 @@ public class AuditApplication
{ {
sourcePath = currentPath; sourcePath = currentPath;
} }
// The extractor may be triggered by data from elsewhere
String dataTrigger = element.getDataTrigger();
if (dataTrigger == null)
{
dataTrigger = currentPath;
}
// Store the extractor definition // Store the extractor definition
DataExtractorDefinition extractorDef = new DataExtractorDefinition(sourcePath, extractorPath, extractor); DataExtractorDefinition extractorDef = new DataExtractorDefinition(dataTrigger, sourcePath, extractorPath, extractor);
dataExtractors.add(extractorDef); dataExtractors.add(extractorDef);
} }

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,21 +1,4 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.repo.audit.model._3; package org.alfresco.repo.audit.model._3;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@@ -35,6 +18,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;extension base="{http://www.alfresco.org/repo/audit/model/3.2}KeyedAuditDefinition"> * &lt;extension base="{http://www.alfresco.org/repo/audit/model/3.2}KeyedAuditDefinition">
* &lt;attribute name="dataExtractor" use="required" type="{http://www.alfresco.org/repo/audit/model/3.2}NameAttribute" /> * &lt;attribute name="dataExtractor" use="required" type="{http://www.alfresco.org/repo/audit/model/3.2}NameAttribute" />
* &lt;attribute name="dataSource" type="{http://www.alfresco.org/repo/audit/model/3.2}PathAttribute" /> * &lt;attribute name="dataSource" type="{http://www.alfresco.org/repo/audit/model/3.2}PathAttribute" />
* &lt;attribute name="dataTrigger" type="{http://www.alfresco.org/repo/audit/model/3.2}PathAttribute" />
* &lt;/extension> * &lt;/extension>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@@ -52,6 +36,8 @@ public class RecordValue
protected String dataExtractor; protected String dataExtractor;
@XmlAttribute @XmlAttribute
protected String dataSource; protected String dataSource;
@XmlAttribute
protected String dataTrigger;
/** /**
* Gets the value of the dataExtractor property. * Gets the value of the dataExtractor property.
@@ -101,4 +87,28 @@ public class RecordValue
this.dataSource = value; this.dataSource = value;
} }
/**
* Gets the value of the dataTrigger property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDataTrigger() {
return dataTrigger;
}
/**
* Sets the value of the dataTrigger property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDataTrigger(String value) {
this.dataTrigger = value;
}
} }