mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Audit - working without filters
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3646 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
75ead51be8
commit
e75b18d742
@ -25,6 +25,7 @@
|
|||||||
<import resource="classpath:alfresco/workflow-context.xml" />
|
<import resource="classpath:alfresco/workflow-context.xml" />
|
||||||
<import resource="classpath:alfresco/bootstrap-context.xml" />
|
<import resource="classpath:alfresco/bootstrap-context.xml" />
|
||||||
<import resource="classpath:alfresco/jcr-api-context.xml" />
|
<import resource="classpath:alfresco/jcr-api-context.xml" />
|
||||||
|
<import resource="classpath:alfresco/audit-services-context.xml" />
|
||||||
<import resource="classpath*:alfresco/patch/*-context.xml" />
|
<import resource="classpath*:alfresco/patch/*-context.xml" />
|
||||||
<import resource="classpath*:alfresco/domain/*-context.xml" />
|
<import resource="classpath*:alfresco/domain/*-context.xml" />
|
||||||
|
|
||||||
|
87
config/alfresco/audit-services-context.xml
Normal file
87
config/alfresco/audit-services-context.xml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<!-- Base audit service - non TX -->
|
||||||
|
|
||||||
|
<bean id="auditService" class="org.alfresco.repo.audit.AuditServiceImpl">
|
||||||
|
<property name="auditComponent">
|
||||||
|
<ref bean="auditComponent"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Audit component -->
|
||||||
|
|
||||||
|
<bean id="auditComponent" class="org.alfresco.repo.audit.AuditComponentImpl">
|
||||||
|
<property name="publicServiceIdentifier">
|
||||||
|
<ref bean="publicServiceIdentifier"/>
|
||||||
|
</property>
|
||||||
|
<property name="auditDAO">
|
||||||
|
<ref bean="auditDao"/>
|
||||||
|
</property>
|
||||||
|
<property name="auditFailedDAO">
|
||||||
|
<ref bean="auditFailedDao"/>
|
||||||
|
</property>
|
||||||
|
<property name="auditConfiguration">
|
||||||
|
<ref bean="auditConfiguration"/>
|
||||||
|
</property>
|
||||||
|
<property name="auditModel">
|
||||||
|
<ref bean="auditModel"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Public service idntifier -->
|
||||||
|
|
||||||
|
<bean id="publicServiceIdentifier" class="org.alfresco.repo.audit.PublicServiceIdentifierImpl"/>
|
||||||
|
|
||||||
|
<!-- The configuration of the audit model -->
|
||||||
|
|
||||||
|
<bean id="auditConfiguration" class="org.alfresco.repo.audit.AuditConfigurationImpl">
|
||||||
|
<property name="config">
|
||||||
|
<value>alfresco/auditConfig.xml</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- The content store in which to store audit information -->
|
||||||
|
|
||||||
|
<bean id="auditFileContentStore" class="org.alfresco.repo.content.filestore.FileContentStore">
|
||||||
|
<constructor-arg>
|
||||||
|
<value>${dir.auditcontentstore}</value>
|
||||||
|
</constructor-arg>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- The audit model -->
|
||||||
|
|
||||||
|
<bean id="auditModel" class="org.alfresco.repo.audit.model.AuditEntry">
|
||||||
|
<property name="auditConfiguration">
|
||||||
|
<ref bean="auditConfiguration"/>
|
||||||
|
</property>
|
||||||
|
<property name="namespacePrefixResolver">
|
||||||
|
<ref bean="namespaceService"/>
|
||||||
|
</property>
|
||||||
|
<property name="publicServiceIdentifier">
|
||||||
|
<ref bean="publicServiceIdentifier"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- The audit DAO wapped to use another TX so we can log exceptions -->
|
||||||
|
|
||||||
|
<bean id='auditFailedDao' class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||||
|
<property name="proxyInterfaces">
|
||||||
|
<value>org.alfresco.repo.audit.AuditDAO</value>
|
||||||
|
</property>
|
||||||
|
<property name="transactionManager">
|
||||||
|
<ref bean="transactionManager" />
|
||||||
|
</property>
|
||||||
|
<property name="target">
|
||||||
|
<ref bean="auditDao" />
|
||||||
|
</property>
|
||||||
|
<property name="transactionAttributes">
|
||||||
|
<props>
|
||||||
|
<prop key="*">${server.transaction.mode.default}, PROPAGATION_REQUIRES_NEW</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</beans>
|
@ -3,7 +3,7 @@
|
|||||||
<!-- Default Audit Configuration -->
|
<!-- Default Audit Configuration -->
|
||||||
|
|
||||||
|
|
||||||
<Audit xmlns="http://www.alfresco.org/model/audit/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" enabled="true" auditInternal="false" mode="all">
|
<Audit xmlns="http://www.alfresco.org/model/audit/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" enabled="false" auditInternal="false" mode="all">
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- Global options -->
|
<!-- Global options -->
|
||||||
@ -174,7 +174,7 @@
|
|||||||
|
|
||||||
<Service name="LicenseService" mode="none" enabled="false"/>
|
<Service name="LicenseService" mode="none" enabled="false"/>
|
||||||
|
|
||||||
<Service name="NamespaceService"/>
|
<Service name="NamespaceService" mode="none" enabled="false"/>
|
||||||
|
|
||||||
<Service name="TransactionService" mode="none" enabled="false"/>
|
<Service name="TransactionService" mode="none" enabled="false"/>
|
||||||
|
|
||||||
|
@ -32,7 +32,9 @@
|
|||||||
|
|
||||||
<!-- Abstract Filter entry -->
|
<!-- Abstract Filter entry -->
|
||||||
|
|
||||||
<xs:complexType name="Filter" abstract="true"/>
|
<xs:complexType name="Filter" abstract="true">
|
||||||
|
<xs:attribute name="invert" type="xs:boolean" default="false"/>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
<!-- Simple Filter entry -->
|
<!-- Simple Filter entry -->
|
||||||
<!--
|
<!--
|
||||||
@ -47,17 +49,17 @@
|
|||||||
A simple value (intended for use with non node arguments)
|
A simple value (intended for use with non node arguments)
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<xs:simpleType name="KeyFilterType">
|
<xs:simpleType name="KeyFilterMode">
|
||||||
<xs:restriction base="xs:string">
|
<xs:restriction base="xs:string">
|
||||||
<xs:enumeration value="path"/>
|
<xs:enumeration value="path"/>
|
||||||
<xs:enumeration value="type"/>
|
<xs:enumeration value="type"/>
|
||||||
<xs:enumeration value="aspect"/>
|
<xs:enumeration value="aspect"/>
|
||||||
<xs:enumeration value="id"/>
|
<xs:enumeration value="node_ref"/>
|
||||||
<xs:enumeration value="all"/>
|
<xs:enumeration value="all"/>
|
||||||
<xs:enumeration value="xpath"/>
|
<xs:enumeration value="xpath"/>
|
||||||
<xs:enumeration value="value"/>
|
<xs:enumeration value="value"/>
|
||||||
<xs:enumeration value="protocol"/>
|
<xs:enumeration value="store_protocol"/>
|
||||||
<xs:enumeration value="store"/>
|
<xs:enumeration value="store_identifier"/>
|
||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
|
|
||||||
@ -102,7 +104,7 @@
|
|||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="Expression" type="xs:string"/>
|
<xs:element name="Expression" type="xs:string"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute name="type" type="a:KeyFilterType" use="required"/>
|
<xs:attribute name="mode" type="a:KeyFilterMode" use="required"/>
|
||||||
</xs:extension>
|
</xs:extension>
|
||||||
</xs:complexContent>
|
</xs:complexContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
@ -196,6 +198,7 @@
|
|||||||
<xs:extension base="a:MandatoryAuditEntry">
|
<xs:extension base="a:MandatoryAuditEntry">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="Service" type="a:Service" minOccurs="0" maxOccurs="unbounded"/>
|
<xs:element name="Service" type="a:Service" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<xs:element name="Application" type="a:Application" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:extension>
|
</xs:extension>
|
||||||
</xs:complexContent>
|
</xs:complexContent>
|
||||||
|
@ -124,4 +124,21 @@
|
|||||||
name="org.alfresco.repo.domain.hibernate.DbAuthorityImpl.externalKeys"
|
name="org.alfresco.repo.domain.hibernate.DbAuthorityImpl.externalKeys"
|
||||||
maxElementsInMemory="5000"
|
maxElementsInMemory="5000"
|
||||||
/>
|
/>
|
||||||
|
<!-- Audit caches -->
|
||||||
|
<cache
|
||||||
|
name="org.alfresco.repo.audit.hibernate.AuditConfigImpl"
|
||||||
|
maxElementsInMemory="2"
|
||||||
|
eternal="true"
|
||||||
|
overflowToDisk="false"/>
|
||||||
|
<cache
|
||||||
|
name="org.alfresco.repo.audit.hibernate.AuditDateImpl"
|
||||||
|
maxElementsInMemory="2"
|
||||||
|
eternal="true"
|
||||||
|
overflowToDisk="false"/>
|
||||||
|
<cache
|
||||||
|
name="org.alfresco.repo.audit.hibernate.AuditSourceImpl"
|
||||||
|
maxElementsInMemory="2000"
|
||||||
|
eternal="true"
|
||||||
|
overflowToDisk="false"/>
|
||||||
|
|
||||||
</ehcache>
|
</ehcache>
|
@ -41,6 +41,10 @@
|
|||||||
<value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value>
|
<value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value>
|
||||||
<value>org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml</value>
|
<value>org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml</value>
|
||||||
<value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value>
|
<value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value>
|
||||||
|
|
||||||
|
<!-- Audit config -->
|
||||||
|
<!-- TODO: Move into org/alfresco/repo/domain/hibernate/ -->
|
||||||
|
<value>org/alfresco/repo/audit/hibernate/Audit.hbm.xml</value>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- JBoss jBPM Workflow Engine -->
|
<!-- JBoss jBPM Workflow Engine -->
|
||||||
@ -153,6 +157,10 @@
|
|||||||
<prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl">${cache.strategy}</prop>
|
<prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl">${cache.strategy}</prop>
|
||||||
<prop key="org.alfresco.repo.domain.hibernate.DbPermissionImpl">${cache.strategy}</prop>
|
<prop key="org.alfresco.repo.domain.hibernate.DbPermissionImpl">${cache.strategy}</prop>
|
||||||
<prop key="org.alfresco.repo.domain.hibernate.DbAuthorityImpl">${cache.strategy}</prop>
|
<prop key="org.alfresco.repo.domain.hibernate.DbAuthorityImpl">${cache.strategy}</prop>
|
||||||
|
|
||||||
|
<prop key="org.alfresco.repo.audit.hibernate.AuditConfigImpl">${cache.strategy}</prop>
|
||||||
|
<prop key="org.alfresco.repo.audit.hibernate.AuditDateImpl">${cache.strategy}</prop>
|
||||||
|
<prop key="org.alfresco.repo.audit.hibernate.AuditSourceImpl">${cache.strategy}</prop>
|
||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
<property name="collectionCacheStrategies" >
|
<property name="collectionCacheStrategies" >
|
||||||
@ -201,16 +209,19 @@
|
|||||||
<ref bean="sessionFactory" />
|
<ref bean="sessionFactory" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="dbNodeDaoServiceTxnRegistration" class="org.alfresco.repo.transaction.TransactionalDaoInterceptor" >
|
<bean id="dbNodeDaoServiceTxnRegistration" class="org.alfresco.repo.transaction.TransactionalDaoInterceptor" >
|
||||||
<property name="daoService">
|
<property name="daoService">
|
||||||
<ref bean="nodeDaoServiceImpl" />
|
<ref bean="nodeDaoServiceImpl" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="persmissionsDaoServiceTxnRegistration" class="org.alfresco.repo.transaction.TransactionalDaoInterceptor" >
|
<bean id="persmissionsDaoServiceTxnRegistration" class="org.alfresco.repo.transaction.TransactionalDaoInterceptor" >
|
||||||
<property name="daoService">
|
<property name="daoService">
|
||||||
<ref bean="permissionsDaoComponent" />
|
<ref bean="permissionsDaoComponent" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="nodeDaoService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="nodeDaoService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
<property name="proxyInterfaces">
|
<property name="proxyInterfaces">
|
||||||
<value>org.alfresco.repo.node.db.NodeDaoService</value>
|
<value>org.alfresco.repo.node.db.NodeDaoService</value>
|
||||||
@ -225,4 +236,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="auditDao" class="org.alfresco.repo.audit.hibernate.HibernateAuditDAO">
|
||||||
|
<property name="sessionFactory">
|
||||||
|
<ref bean="sessionFactory"/>
|
||||||
|
</property>
|
||||||
|
<property name="contentStore">
|
||||||
|
<ref bean="auditFileContentStore"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
File diff suppressed because it is too large
Load Diff
@ -712,4 +712,20 @@
|
|||||||
|
|
||||||
<bean id="ScriptService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
<bean id="ScriptService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||||
|
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Workflow Service -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<!-- TODO: Add workflow security -->
|
||||||
|
|
||||||
|
<bean id="WorkflowService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||||
|
|
||||||
|
<!-- ============= -->
|
||||||
|
<!-- Audit Service -->
|
||||||
|
<!-- ============= -->
|
||||||
|
|
||||||
|
<!-- TODO: Add audit security -->
|
||||||
|
|
||||||
|
<bean id="AuditService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -5,6 +5,8 @@ dir.root=./alf_data
|
|||||||
dir.contentstore=${dir.root}/contentstore
|
dir.contentstore=${dir.root}/contentstore
|
||||||
dir.contentstore.deleted=${dir.root}/contentstore.deleted
|
dir.contentstore.deleted=${dir.root}/contentstore.deleted
|
||||||
|
|
||||||
|
dir.auditcontentstore=${dir.root}/audit.contentstore
|
||||||
|
|
||||||
# The location for lucene index files
|
# The location for lucene index files
|
||||||
|
|
||||||
dir.indexes=${dir.root}/lucene-indexes
|
dir.indexes=${dir.root}/lucene-indexes
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
public interface ApplicationAuditModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour can be determined before the method call
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, String application, String description,
|
||||||
|
NodeRef key, Object... args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour can be determined after the method call
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, String application, String description,
|
||||||
|
NodeRef key, Object... args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour should be invoked on error. It could be we look at the error and filter - this is not supported at the moment.
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode onError(AuditMode auditMode, String application, String description,
|
||||||
|
NodeRef key, Object... args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the optional parameters that are to be recorded
|
||||||
|
*
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RecordOptions getAuditRecordOptions(String application);
|
||||||
|
}
|
52
source/java/org/alfresco/repo/audit/AuditComponent.java
Normal file
52
source/java/org/alfresco/repo/audit/AuditComponent.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audit component.
|
||||||
|
*
|
||||||
|
* Used by the AuditService and AuditMethodInterceptor to insert audit entries.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditComponent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Audit entry point for method interceptors.
|
||||||
|
*
|
||||||
|
* @param methodInvocation
|
||||||
|
*/
|
||||||
|
public Object audit(MethodInvocation methodInvocation) throws Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param source -
|
||||||
|
* a string that represents the application
|
||||||
|
* @param description -
|
||||||
|
* the audit entry *
|
||||||
|
* @param key -
|
||||||
|
* a node ref to use as the key for filtering etc
|
||||||
|
* @param args -
|
||||||
|
* an arbitrary list of parameters
|
||||||
|
*/
|
||||||
|
public void audit(String source, String description, NodeRef key, Object... args);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
425
source/java/org/alfresco/repo/audit/AuditComponentImpl.java
Normal file
425
source/java/org/alfresco/repo/audit/AuditComponentImpl.java
Normal file
@ -0,0 +1,425 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default audit component implementation. TODO: Implement before, after and exception filtering. At the moment these filters are ignired. TODO: Respect audit internal - at the
|
||||||
|
* moment audit internal is fixed to false.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditComponentImpl implements AuditComponent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application name to use for audit entries generated by method interception around public services.
|
||||||
|
*/
|
||||||
|
private static final String SYSTEM_APPLICATION = "SystemMethodInterceptor";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging
|
||||||
|
*/
|
||||||
|
private static Log s_logger = LogFactory.getLog(AuditComponentImpl.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suspend resume auditing
|
||||||
|
*/
|
||||||
|
private static ThreadLocal<Boolean> auditFlag = new ThreadLocal<Boolean>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IOC
|
||||||
|
*/
|
||||||
|
private PublicServiceIdentifier publicServiceIdentifier;
|
||||||
|
|
||||||
|
private AuditConfiguration auditConfiguration;
|
||||||
|
|
||||||
|
private AuditDAO auditDAO;
|
||||||
|
|
||||||
|
private AuditDAO auditFailedDAO;
|
||||||
|
|
||||||
|
private AuditModel auditModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep hold of the host where the audit occurs. TODO: Check that we get the correct address ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
private InetAddress auditHost;
|
||||||
|
|
||||||
|
public AuditComponentImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
// Initialise the host address
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditHost = InetAddress.getLocalHost();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
s_logger.error("Failed to get local host address", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IOC property setters
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void setAuditDAO(AuditDAO auditDAO)
|
||||||
|
{
|
||||||
|
this.auditDAO = auditDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditFailedDAO(AuditDAO auditFailedDAO)
|
||||||
|
{
|
||||||
|
this.auditFailedDAO = auditFailedDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||||
|
{
|
||||||
|
this.auditConfiguration = auditConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicServiceIdentifier(PublicServiceIdentifier publicServiceIdentifier)
|
||||||
|
{
|
||||||
|
this.publicServiceIdentifier = publicServiceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditModel(AuditModel auditModel)
|
||||||
|
{
|
||||||
|
this.auditModel = auditModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object audit(MethodInvocation mi) throws Throwable
|
||||||
|
{
|
||||||
|
if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue()))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditFlag.set(Boolean.TRUE);
|
||||||
|
|
||||||
|
Method method = mi.getMethod();
|
||||||
|
String methodName = method.getName();
|
||||||
|
String serviceName = publicServiceIdentifier.getPublicServiceName(mi);
|
||||||
|
if (method.isAnnotationPresent(Auditable.class))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (serviceName != null)
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Auditing - " + serviceName + "." + methodName);
|
||||||
|
}
|
||||||
|
return auditImpl(mi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("UnknownService." + methodName);
|
||||||
|
}
|
||||||
|
return auditImpl(mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (method.isAnnotationPresent(NotAuditable.class))
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Not Audited. " + serviceName + "." + methodName);
|
||||||
|
}
|
||||||
|
return mi.proceed();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Unannotated service method " + serviceName + "." + methodName);
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Unannotated service method " + serviceName + "." + methodName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
auditFlag.set(Boolean.FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mi.proceed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Audit a method invocation
|
||||||
|
*/
|
||||||
|
public Object auditImpl(MethodInvocation mi) throws Throwable
|
||||||
|
{
|
||||||
|
AuditInfo auditInfo = new AuditInfo(auditConfiguration);
|
||||||
|
// RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||||
|
AuditMode auditMode = AuditMode.UNSET;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditMode = beforeInvocation(auditMode, auditInfo, mi);
|
||||||
|
Object o = mi.proceed();
|
||||||
|
auditMode = postInvocation(auditMode, auditInfo, mi, o);
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.SUCCESS))
|
||||||
|
{
|
||||||
|
auditDAO.audit(auditInfo);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
auditMode = onError(auditMode, auditInfo, mi, t);
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditFailedDAO.audit(auditInfo);
|
||||||
|
}
|
||||||
|
catch (Throwable tt)
|
||||||
|
{
|
||||||
|
throw new AuditException("Failed to audit exception", new Object[] { tt }, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set auditable properties and to determine if auditing is required when an exception is caught in the audited method.
|
||||||
|
*
|
||||||
|
* @param auditMode
|
||||||
|
* @param auditInfo
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private AuditMode onError(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi, Throwable t)
|
||||||
|
{
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||||
|
{
|
||||||
|
auditInfo.setFail(true);
|
||||||
|
auditInfo.setThrowable(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return auditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set audited information after method invocation and to determine if auditing should take place based on the method return value.
|
||||||
|
*
|
||||||
|
* @param auditMode
|
||||||
|
* @param auditInfo
|
||||||
|
* @param mi
|
||||||
|
* @param returnObject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private AuditMode postInvocation(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi, Object returnObject)
|
||||||
|
{
|
||||||
|
if (returnObject == null)
|
||||||
|
{
|
||||||
|
auditInfo.setReturnObject(null);
|
||||||
|
}
|
||||||
|
else if (returnObject instanceof Serializable)
|
||||||
|
{
|
||||||
|
auditInfo.setReturnObject((Serializable) returnObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auditInfo.setReturnObject(returnObject.toString());
|
||||||
|
}
|
||||||
|
return auditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set auditable information and determine if auditing is required before method invocation. This would normally be based on the method arguments.
|
||||||
|
*
|
||||||
|
* @param auditMode
|
||||||
|
* @param auditInfo
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private AuditMode beforeInvocation(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, mi);
|
||||||
|
|
||||||
|
if (auditMode != AuditMode.NONE)
|
||||||
|
{
|
||||||
|
String methodName = mi.getMethod().getName();
|
||||||
|
String serviceName = publicServiceIdentifier.getPublicServiceName(mi);
|
||||||
|
auditInfo.setAuditApplication(SYSTEM_APPLICATION);
|
||||||
|
auditInfo.setAuditConfiguration(auditConfiguration);
|
||||||
|
auditInfo.setAuditMethod(methodName);
|
||||||
|
auditInfo.setAuditService(serviceName);
|
||||||
|
auditInfo.setClientAddress(null);
|
||||||
|
auditInfo.setDate(new Date());
|
||||||
|
auditInfo.setFail(false);
|
||||||
|
auditInfo.setFiltered(false);
|
||||||
|
auditInfo.setHostAddress(auditHost);
|
||||||
|
auditInfo.setKeyGUID(null);
|
||||||
|
auditInfo.setKeyPropertiesAfter(null);
|
||||||
|
auditInfo.setKeyPropertiesBefore(null);
|
||||||
|
auditInfo.setKeyStore(null);
|
||||||
|
auditInfo.setMessage(null);
|
||||||
|
if (mi.getArguments() != null)
|
||||||
|
{
|
||||||
|
Serializable[] serArgs = new Serializable[mi.getArguments().length];
|
||||||
|
for (int i = 0; i < mi.getArguments().length; i++)
|
||||||
|
{
|
||||||
|
if (mi.getArguments()[i] == null)
|
||||||
|
{
|
||||||
|
serArgs[i] = null;
|
||||||
|
}
|
||||||
|
else if (mi.getArguments()[i] instanceof Serializable)
|
||||||
|
{
|
||||||
|
serArgs[i] = (Serializable) mi.getArguments()[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serArgs[i] = mi.getArguments()[i].toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auditInfo.setMethodArguments(serArgs);
|
||||||
|
}
|
||||||
|
auditInfo.setPath(null);
|
||||||
|
auditInfo.setReturnObject(null);
|
||||||
|
auditInfo.setSessionId(null);
|
||||||
|
auditInfo.setThrowable(null);
|
||||||
|
auditInfo.setTxId(AlfrescoTransactionSupport.getTransactionId());
|
||||||
|
auditInfo.setUserIdentifier(AuthenticationUtil.getCurrentUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return effectiveAuditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple audit entry Currently we ignore filtering here.
|
||||||
|
*/
|
||||||
|
public void audit(String source, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
AuditInfo auditInfo = new AuditInfo(auditConfiguration);
|
||||||
|
// RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||||
|
AuditMode auditMode = AuditMode.UNSET;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditMode = onApplicationAudit(auditMode, auditInfo, source, description, key, args);
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.SUCCESS))
|
||||||
|
{
|
||||||
|
auditDAO.audit(auditInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
auditMode = onError(auditMode, auditInfo, t, source, description, key, args);
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditFailedDAO.audit(auditInfo);
|
||||||
|
}
|
||||||
|
catch (Throwable tt)
|
||||||
|
{
|
||||||
|
throw new AuditException("Failed to audit exception", new Object[] { tt }, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new AuditException("Application audit failed", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditMode onApplicationAudit(AuditMode auditMode, AuditInfo auditInfo, String source, String description,
|
||||||
|
NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, source, description, key, args);
|
||||||
|
|
||||||
|
if (auditMode != AuditMode.NONE)
|
||||||
|
{
|
||||||
|
if(source.equals(SYSTEM_APPLICATION))
|
||||||
|
{
|
||||||
|
throw new AuditException("Application audit can not use the reserved identifier "+SYSTEM_APPLICATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
auditInfo.setAuditApplication(source);
|
||||||
|
auditInfo.setAuditConfiguration(auditConfiguration);
|
||||||
|
auditInfo.setAuditMethod(null);
|
||||||
|
auditInfo.setAuditService(null);
|
||||||
|
auditInfo.setClientAddress(null);
|
||||||
|
auditInfo.setDate(new Date());
|
||||||
|
auditInfo.setFail(false);
|
||||||
|
auditInfo.setFiltered(false);
|
||||||
|
auditInfo.setHostAddress(auditHost);
|
||||||
|
auditInfo.setKeyGUID(null);
|
||||||
|
auditInfo.setKeyPropertiesAfter(null);
|
||||||
|
auditInfo.setKeyPropertiesBefore(null);
|
||||||
|
auditInfo.setKeyStore(null);
|
||||||
|
auditInfo.setMessage(description);
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
Serializable[] serArgs = new Serializable[args.length];
|
||||||
|
for (int i = 0; i < args.length; i++)
|
||||||
|
{
|
||||||
|
if (args[i] == null)
|
||||||
|
{
|
||||||
|
serArgs[i] = null;
|
||||||
|
}
|
||||||
|
else if (args[i] instanceof Serializable)
|
||||||
|
{
|
||||||
|
serArgs[i] = (Serializable) args[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serArgs[i] = args[i].toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auditInfo.setMethodArguments(serArgs);
|
||||||
|
}
|
||||||
|
auditInfo.setPath(null);
|
||||||
|
auditInfo.setReturnObject(null);
|
||||||
|
auditInfo.setSessionId(null);
|
||||||
|
auditInfo.setThrowable(null);
|
||||||
|
auditInfo.setTxId(AlfrescoTransactionSupport.getTransactionId());
|
||||||
|
auditInfo.setUserIdentifier(AuthenticationUtil.getCurrentUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return effectiveAuditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditMode onError(AuditMode auditMode, AuditInfo auditInfo, Throwable t, String source, String description,
|
||||||
|
NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||||
|
{
|
||||||
|
auditInfo.setFail(true);
|
||||||
|
auditInfo.setThrowable(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return auditMode;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
36
source/java/org/alfresco/repo/audit/AuditConfiguration.java
Normal file
36
source/java/org/alfresco/repo/audit/AuditConfiguration.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An audit configuration is xml content from an input stream.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the XML content for the configuration as a stream.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract InputStream getInputStream();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to read the audit configuration from the class path
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditConfigurationImpl implements InitializingBean, AuditConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
private String config;
|
||||||
|
|
||||||
|
public AuditConfigurationImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfig(String config)
|
||||||
|
{
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.getInputStream#getInputStream()
|
||||||
|
*/
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.AuditConfiguration#getInputStream()
|
||||||
|
*/
|
||||||
|
public InputStream getInputStream()
|
||||||
|
{
|
||||||
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream(config);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void afterPropertiesSet() throws Exception
|
||||||
|
{
|
||||||
|
// Read and set up the audit configuration
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
source/java/org/alfresco/repo/audit/AuditDAO.java
Normal file
32
source/java/org/alfresco/repo/audit/AuditDAO.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface to persist audit information.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create an audit entry.
|
||||||
|
*
|
||||||
|
* @param auditInfo
|
||||||
|
*/
|
||||||
|
public void audit(AuditInfo auditInfo);
|
||||||
|
}
|
54
source/java/org/alfresco/repo/audit/AuditException.java
Normal file
54
source/java/org/alfresco/repo/audit/AuditException.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Audit related exceptions.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditException extends AlfrescoRuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment for <code>serialVersionUID</code>
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -7947190775692164588L;
|
||||||
|
|
||||||
|
public AuditException(String msgId)
|
||||||
|
{
|
||||||
|
super(msgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditException(String msgId, Object[] msgParams)
|
||||||
|
{
|
||||||
|
super(msgId, msgParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditException(String msgId, Throwable cause)
|
||||||
|
{
|
||||||
|
super(msgId, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditException(String msgId, Object[] msgParams, Throwable cause)
|
||||||
|
{
|
||||||
|
super(msgId, msgParams, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
385
source/java/org/alfresco/repo/audit/AuditInfo.java
Normal file
385
source/java/org/alfresco/repo/audit/AuditInfo.java
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to encapsulate audit information supplied to the DAO layer.
|
||||||
|
*
|
||||||
|
* Null entries should be stored.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditInfo
|
||||||
|
{
|
||||||
|
private static Logger s_logger = Logger.getLogger(AuditInfo.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user identifier for the person who caused this audit entry
|
||||||
|
*/
|
||||||
|
private String userIdentifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date for this audit entry
|
||||||
|
*/
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The transaction id in which this entry was made
|
||||||
|
*/
|
||||||
|
private String txId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The session is for this action
|
||||||
|
*/
|
||||||
|
private String sessionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The store in which the action occured.
|
||||||
|
*/
|
||||||
|
private StoreRef keyStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a node ref, the node for the action.
|
||||||
|
*/
|
||||||
|
private String keyGUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path of the key
|
||||||
|
*/
|
||||||
|
private String keyPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audit application
|
||||||
|
* Internal uses the "System" key and will only audit method information.
|
||||||
|
*/
|
||||||
|
private String auditApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The service holding the audited method.
|
||||||
|
*/
|
||||||
|
private String auditService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the audited method.
|
||||||
|
*/
|
||||||
|
private String auditMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Did this entry passa filter?
|
||||||
|
* If false - all entries were being recorded.
|
||||||
|
*/
|
||||||
|
private boolean filtered;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audit configuration in use at the time.
|
||||||
|
*/
|
||||||
|
private AuditConfiguration auditConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object returned by the audited method.
|
||||||
|
*/
|
||||||
|
private Serializable returnObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arguments to the audited method.
|
||||||
|
*/
|
||||||
|
private Serializable[] methodArguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any Exception thrown by the audited method.
|
||||||
|
*/
|
||||||
|
private Throwable throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Did the audited method throw an exception?
|
||||||
|
*/
|
||||||
|
private boolean fail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The host address for where the audit was generated.
|
||||||
|
*/
|
||||||
|
private InetAddress hostAddress;
|
||||||
|
|
||||||
|
private static InetAddress s_hostAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client address causing the audit
|
||||||
|
*/
|
||||||
|
private InetAddress clientAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The properties of the key node before the method execution.
|
||||||
|
*/
|
||||||
|
private Map<QName, Serializable> keyPropertiesBefore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The properties of the key node after the method execution.
|
||||||
|
*/
|
||||||
|
private Map<QName, Serializable> keyPropertiesAfter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For general auditing - the audit message.
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
s_hostAddress = InetAddress.getLocalHost();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
s_logger.error(e);
|
||||||
|
s_hostAddress = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditInfo(AuditConfiguration auditConfiguration)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
// Add default information
|
||||||
|
userIdentifier = AuthenticationUtil.getCurrentUserName();
|
||||||
|
date = new Date();
|
||||||
|
txId = AlfrescoTransactionSupport.getTransactionId();
|
||||||
|
sessionId = "Unavailable";
|
||||||
|
hostAddress = s_hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuditApplication()
|
||||||
|
{
|
||||||
|
return auditApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditApplication(String auditApplication)
|
||||||
|
{
|
||||||
|
this.auditApplication = auditApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditConfiguration getAuditConfiguration()
|
||||||
|
{
|
||||||
|
return auditConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||||
|
{
|
||||||
|
this.auditConfiguration = auditConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuditMethod()
|
||||||
|
{
|
||||||
|
return auditMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditMethod(String auditMethod)
|
||||||
|
{
|
||||||
|
this.auditMethod = auditMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuditService()
|
||||||
|
{
|
||||||
|
return auditService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditService(String auditService)
|
||||||
|
{
|
||||||
|
this.auditService = auditService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InetAddress getClientAddress()
|
||||||
|
{
|
||||||
|
return clientAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientAddress(InetAddress clientAddress)
|
||||||
|
{
|
||||||
|
this.clientAddress = clientAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate()
|
||||||
|
{
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date)
|
||||||
|
{
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFail()
|
||||||
|
{
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFail(boolean fail)
|
||||||
|
{
|
||||||
|
this.fail = fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFiltered()
|
||||||
|
{
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFiltered(boolean filtered)
|
||||||
|
{
|
||||||
|
this.filtered = filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InetAddress getHostAddress()
|
||||||
|
{
|
||||||
|
return hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostAddress(InetAddress hostAddress)
|
||||||
|
{
|
||||||
|
this.hostAddress = hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyGUID()
|
||||||
|
{
|
||||||
|
return keyGUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyGUID(String keyGUID)
|
||||||
|
{
|
||||||
|
this.keyGUID = keyGUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||||
|
{
|
||||||
|
return keyPropertiesAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyPropertiesAfter(Map<QName, Serializable> keyPropertiesAfter)
|
||||||
|
{
|
||||||
|
this.keyPropertiesAfter = keyPropertiesAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||||
|
{
|
||||||
|
return keyPropertiesBefore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyPropertiesBefore(Map<QName, Serializable> keyPropertiesBefore)
|
||||||
|
{
|
||||||
|
this.keyPropertiesBefore = keyPropertiesBefore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreRef getKeyStore()
|
||||||
|
{
|
||||||
|
return keyStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyStore(StoreRef keyStore)
|
||||||
|
{
|
||||||
|
this.keyStore = keyStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Serializable[] getMethodArguments()
|
||||||
|
{
|
||||||
|
return methodArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethodArguments(Serializable[] methodArguments)
|
||||||
|
{
|
||||||
|
this.methodArguments = methodArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return keyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String keyPath)
|
||||||
|
{
|
||||||
|
this.keyPath = keyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Serializable getReturnObject()
|
||||||
|
{
|
||||||
|
return returnObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReturnObject(Serializable returnObject)
|
||||||
|
{
|
||||||
|
this.returnObject = returnObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionId()
|
||||||
|
{
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionId(String sessionId)
|
||||||
|
{
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Throwable getThrowable()
|
||||||
|
{
|
||||||
|
return throwable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThrowable(Throwable throwable)
|
||||||
|
{
|
||||||
|
this.throwable = throwable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTxId()
|
||||||
|
{
|
||||||
|
return txId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTxId(String txId)
|
||||||
|
{
|
||||||
|
this.txId = txId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserIdentifier()
|
||||||
|
{
|
||||||
|
return userIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIdentifier(String userIdentifier)
|
||||||
|
{
|
||||||
|
this.userIdentifier = userIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A method interceptor to wrap method invocations with auditing.
|
||||||
|
*
|
||||||
|
* A single instance is used to wrap all services. If the single instance is disabled
|
||||||
|
* no auditing will be carried out and there will be minimal overhead.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditMethodInterceptor implements MethodInterceptor
|
||||||
|
{
|
||||||
|
//private static Log s_logger = LogFactory.getLog(AuditMethodInterceptor.class);
|
||||||
|
|
||||||
|
private AuditComponent auditComponent;
|
||||||
|
|
||||||
|
private boolean disabled = false;
|
||||||
|
|
||||||
|
public AuditMethodInterceptor()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabled(boolean disabled)
|
||||||
|
{
|
||||||
|
this.disabled = disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditComponent(AuditComponent auditComponent)
|
||||||
|
{
|
||||||
|
this.auditComponent = auditComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object invoke(MethodInvocation mi) throws Throwable
|
||||||
|
{
|
||||||
|
if(disabled)
|
||||||
|
{
|
||||||
|
return mi.proceed();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return auditComponent.audit(mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
67
source/java/org/alfresco/repo/audit/AuditMode.java
Normal file
67
source/java/org/alfresco/repo/audit/AuditMode.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.model.AuditModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum to specify the audit mode:
|
||||||
|
*
|
||||||
|
* <ol>
|
||||||
|
* <li> ALL - all calls are audited
|
||||||
|
* <li> SUCCESS - only successful calls are audited (audited in the same TX)
|
||||||
|
* <li> FAIL - only fail calls are audited (in a new transaction)
|
||||||
|
* <li> NONE - noting is audited
|
||||||
|
* <li> UNSET
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* The mode is inherited from containers if nothing is specified
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public enum AuditMode
|
||||||
|
{
|
||||||
|
ALL, SUCCESS, FAIL, NONE, UNSET;
|
||||||
|
|
||||||
|
public static AuditMode getAuditMode(String value)
|
||||||
|
{
|
||||||
|
if(value.equalsIgnoreCase("all"))
|
||||||
|
{
|
||||||
|
return AuditMode.ALL;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("success"))
|
||||||
|
{
|
||||||
|
return AuditMode.SUCCESS;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("fail"))
|
||||||
|
{
|
||||||
|
return AuditMode.FAIL;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("none"))
|
||||||
|
{
|
||||||
|
return AuditMode.NONE;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("unset"))
|
||||||
|
{
|
||||||
|
return AuditMode.UNSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Invalid audit mode: "+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
source/java/org/alfresco/repo/audit/AuditModel.java
Normal file
74
source/java/org/alfresco/repo/audit/AuditModel.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API for querying the audit model
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditModel extends ApplicationAuditModel, MethodAuditModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constants for reading the xml model definition.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* package */final static String NAME_SPACE = "http://www.alfresco.org/model/audit/1.0";
|
||||||
|
|
||||||
|
/* package */final static String EL_AUDIT = "Audit";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_OPTIONS = "RecordOptions";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_PATH = "recordPath";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_FILTERS = "recordFilters";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_SER_RETURN_VAL = "recordSerializedReturnValue";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_SER_EX = "recordSerializedExceptions";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_SER_ARGS = "recordSerializedMethodArguments";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_SER_PROP_BEFORE = "recordSerializedKeyPropertiesBeforeInvocation";
|
||||||
|
|
||||||
|
/* package */final static String EL_RECORD_SER_PROP_AFTER = "recordSerializedKeyPropertiesAferInvocation";
|
||||||
|
|
||||||
|
/* package */final static String EL_FILTER = "Filter";
|
||||||
|
|
||||||
|
/* package */final static String EL_METHOD = "Method";
|
||||||
|
|
||||||
|
/* package */final static String EL_SERVICE = "Service";
|
||||||
|
|
||||||
|
/* package */final static String EL_APPLICATION = "Application";
|
||||||
|
|
||||||
|
/* package */final static String EL_EXPRESSION = "Expression";
|
||||||
|
|
||||||
|
/* package */final static String EL_PARAMETER_NAME = "ParameterName";
|
||||||
|
|
||||||
|
/* package */final static String AT_MODE = "mode";
|
||||||
|
|
||||||
|
/* package */final static String AT_ENABLED = "enabled";
|
||||||
|
|
||||||
|
/* package */final static String AT_AUDIT_INTERNAL = "auditInternal";
|
||||||
|
|
||||||
|
/* package */final static String AT_NAME = "name";
|
||||||
|
|
||||||
|
/* package */final static String AT_INVERT = "invert";
|
||||||
|
|
||||||
|
/* package */final static String AT_TYPE = "type";
|
||||||
|
}
|
88
source/java/org/alfresco/repo/audit/AuditServiceImpl.java
Normal file
88
source/java/org/alfresco/repo/audit/AuditServiceImpl.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.audit.AuditService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The implementation of the AuditService for application auditing.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditServiceImpl implements AuditService
|
||||||
|
{
|
||||||
|
private AuditComponent auditComponent;
|
||||||
|
|
||||||
|
public AuditServiceImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditComponent(AuditComponent auditComponent)
|
||||||
|
{
|
||||||
|
this.auditComponent = auditComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audit(String source, String description)
|
||||||
|
{
|
||||||
|
auditComponent.audit(source, description, null, (Object[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audit(String source, String description, NodeRef key)
|
||||||
|
{
|
||||||
|
auditComponent.audit(source, description, key, (Object[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audit(String source, String description, Object... args)
|
||||||
|
{
|
||||||
|
auditComponent.audit(source, description, null, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audit(String source, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
auditComponent.audit(source, description, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception
|
||||||
|
{
|
||||||
|
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
AuditService as = (AuditService) ctx.getBean("AuditService");
|
||||||
|
|
||||||
|
TransactionService txs = (TransactionService) ctx.getBean("transactionComponent");
|
||||||
|
UserTransaction tx = txs.getUserTransaction();
|
||||||
|
tx.begin();
|
||||||
|
as.audit("AuditedApp", "First");
|
||||||
|
as.audit("AuditedApp", "Second", new NodeRef(new StoreRef("test", "audit"), "id"));
|
||||||
|
as.audit("AuditedApp", "Third", new Object[]{"one", "two", "three"});
|
||||||
|
as.audit("AuditedApp", "Fourth", new NodeRef(new StoreRef("test", "audit"), "id"), new Object[]{"one", "two", "three"});
|
||||||
|
|
||||||
|
as.audit("UnAuditedApp", "First");
|
||||||
|
as.audit("UnAuditedApp", "Second", new NodeRef(new StoreRef("test", "audit"), "id"));
|
||||||
|
as.audit("UnAuditedApp", "Third", new Object[]{"one", "two", "three"});
|
||||||
|
as.audit("UnAuditedApp", "Fourth", new NodeRef(new StoreRef("test", "audit"), "id"), new Object[]{"one", "two", "three"});
|
||||||
|
|
||||||
|
tx.commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
57
source/java/org/alfresco/repo/audit/MethodAuditModel.java
Normal file
57
source/java/org/alfresco/repo/audit/MethodAuditModel.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
|
||||||
|
public interface MethodAuditModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour can be determined before the method call
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour can be determined after the method call
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report if audit behaviour should be invoked on error. It could be we look at the error and filter - this is not supported at the moment.
|
||||||
|
*
|
||||||
|
* @param auditState,
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuditMode onError(AuditMode auditMode, MethodInvocation mi);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the optional parameters that are to be recorded
|
||||||
|
*
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RecordOptions getAuditRecordOptions(MethodInvocation mi);
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This defines the API to identify the public service upon which a method invocation has been made.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface PublicServiceIdentifier
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the name of the public service for the method invocation.
|
||||||
|
*
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getPublicServiceName(MethodInvocation mi);
|
||||||
|
}
|
@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify public services by method invocation. Look ups are cached on a thread local as they are quite expensive. All public service names end with "Service" and start with
|
||||||
|
* capital letter. This pattern is used to filter bean names. TODO: Look at pulling out all the mappings at start up.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class PublicServiceIdentifierImpl implements PublicServiceIdentifier, BeanFactoryPostProcessor
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(PublicServiceIdentifierImpl.class);
|
||||||
|
|
||||||
|
private static ThreadLocal<HashMap<Method, String>> methodToServiceMap = new ThreadLocal<HashMap<Method, String>>();
|
||||||
|
|
||||||
|
private ConfigurableListableBeanFactory beanFactory;
|
||||||
|
|
||||||
|
public PublicServiceIdentifierImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||||
|
{
|
||||||
|
this.beanFactory = beanFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicServiceName(MethodInvocation mi)
|
||||||
|
{
|
||||||
|
return getServiceName(mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache service name look up.
|
||||||
|
*
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
* @throws BeansException
|
||||||
|
*/
|
||||||
|
private String getServiceName(MethodInvocation mi) throws BeansException
|
||||||
|
{
|
||||||
|
if (methodToServiceMap.get() == null)
|
||||||
|
{
|
||||||
|
methodToServiceMap.set(new HashMap<Method, String>());
|
||||||
|
}
|
||||||
|
Method method = mi.getMethod();
|
||||||
|
String serviceName = methodToServiceMap.get().get(method);
|
||||||
|
if (serviceName == null)
|
||||||
|
{
|
||||||
|
serviceName = getServiceNameImpl(mi);
|
||||||
|
methodToServiceMap.get().put(method, serviceName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Cached look up for " + serviceName + "." + method.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do the look up by interface type.
|
||||||
|
*
|
||||||
|
* @param mi
|
||||||
|
* @return
|
||||||
|
* @throws BeansException
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String getServiceNameImpl(MethodInvocation mi) throws BeansException
|
||||||
|
{
|
||||||
|
Class clazz = mi.getThis().getClass();
|
||||||
|
while (clazz != null)
|
||||||
|
{
|
||||||
|
Class[] interfaces = clazz.getInterfaces();
|
||||||
|
for (Class iFace : interfaces)
|
||||||
|
{
|
||||||
|
Class publicServiceInterface = findPublicService(iFace);
|
||||||
|
if (publicServiceInterface != null)
|
||||||
|
{
|
||||||
|
Map beans = beanFactory.getBeansOfType(publicServiceInterface);
|
||||||
|
Iterator iter = beans.entrySet().iterator();
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
|
String serviceName = (String) entry.getKey();
|
||||||
|
if ((serviceName.endsWith("Service"))
|
||||||
|
&& (Character.isUpperCase(serviceName.charAt(0)))
|
||||||
|
&& !serviceName.equals("DescriptorService"))
|
||||||
|
{
|
||||||
|
return serviceName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We use a marker annotation to identify public interfaces.
|
||||||
|
* The interfaces have to be walked to determine if a public interface is implemented.
|
||||||
|
*
|
||||||
|
* Only one public service interface is expected.
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Class findPublicService(Class clazz)
|
||||||
|
{
|
||||||
|
if (!clazz.isInterface())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clazz.isAnnotationPresent(PublicService.class))
|
||||||
|
{
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class[] classes = clazz.getInterfaces();
|
||||||
|
for(Class implemented: classes)
|
||||||
|
{
|
||||||
|
Class answer = findPublicService(implemented);
|
||||||
|
if(answer != null)
|
||||||
|
{
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
38
source/java/org/alfresco/repo/audit/RecordOptions.java
Normal file
38
source/java/org/alfresco/repo/audit/RecordOptions.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public interface RecordOptions
|
||||||
|
{
|
||||||
|
public TrueFalseUnset getRecordFilters();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordPath();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedExceptions();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedKeyPropertiesAfterEvaluation();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedKeyPropertiesBeforeEvaluation();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedMethodArguments();
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedReturnValue();
|
||||||
|
}
|
158
source/java/org/alfresco/repo/audit/hibernate/Audit.hbm.xml
Normal file
158
source/java/org/alfresco/repo/audit/hibernate/Audit.hbm.xml
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
|
||||||
|
<!DOCTYPE hibernate-mapping PUBLIC
|
||||||
|
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
|
||||||
|
'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
|
||||||
|
|
||||||
|
<!-- Hibernate mapping for storing audit information -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- This generates a simple star schema for audit -->
|
||||||
|
<!-- breakdown and roll up. -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<hibernate-mapping>
|
||||||
|
|
||||||
|
<!-- The fact -->
|
||||||
|
|
||||||
|
<class name="org.alfresco.repo.audit.hibernate.AuditFactImpl" proxy="org.alfresco.repo.audit.hibernate.AuditFact" table="alf_audit_fact" dynamic-update="false" dynamic-insert="false"
|
||||||
|
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||||
|
|
||||||
|
<!-- An auto-generated id -->
|
||||||
|
<id name="id" column="id" type="long">
|
||||||
|
<generator class="native"/>
|
||||||
|
</id>
|
||||||
|
|
||||||
|
<!-- Fact properties -->
|
||||||
|
|
||||||
|
<property name="userId" column="user_id" type="string" length="255" not-null="true" index="adt_user_idx"/>
|
||||||
|
<property name="date" column="timestamp" type="timestamp" not-null="true"/>
|
||||||
|
<property name="transactionId" column="transaction_id" type="string" length="56" not-null="true"/>
|
||||||
|
<property name="sessionId" column="session_id" type="string" length="56" not-null="false"/>
|
||||||
|
<property name="storeProtocol" column="store_protocol" type="string" length="50" not-null="false" index="adt_store_idx"/>
|
||||||
|
<property name="storeId" column="store_id" type="string" length="100" not-null="false" index="adt_store_idx"/>
|
||||||
|
<property name="nodeUUID" column="node_uuid" type="string" length="36" not-null="false" index="adt_store_idx"/>
|
||||||
|
<property name="path" column="path" type="string" length="512" not-null="false"/>
|
||||||
|
<property name="filtered" column="filtered" type="boolean" not-null="true"/>
|
||||||
|
<property name="returnValue" column="return_val" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="arg1" column="arg_1" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="arg2" column="arg_2" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="arg3" column="arg_3" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="arg4" column="arg_4" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="arg5" column="arg_5" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="fail" column="fail" type="boolean" not-null="true"/>
|
||||||
|
<!-- TODO: Check the URL length ...-->
|
||||||
|
<property name="serialisedURL" column="serialized_url" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="exception" column="exception" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="hostInetAddress" column="host_address" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="clientInetAddress" column="client_address" type="string" length="1024" not-null="false"/>
|
||||||
|
<property name="message" column="message" type="string" length="1024" not-null="false"/>
|
||||||
|
|
||||||
|
<!-- Links to dimensions -->
|
||||||
|
|
||||||
|
<many-to-one name="auditDate" class="org.alfresco.repo.audit.hibernate.AuditDateImpl" not-null="true" lazy="proxy" column="audit_date_id" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||||
|
<many-to-one name="auditConfig" class="org.alfresco.repo.audit.hibernate.AuditConfigImpl" not-null="true" lazy="proxy" column="audit_conf_id" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||||
|
<many-to-one name="auditSource" class="org.alfresco.repo.audit.hibernate.AuditSourceImpl" not-null="true" lazy="proxy" column="audit_source_id" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||||
|
|
||||||
|
</class>
|
||||||
|
|
||||||
|
<!-- The audit date dimension -->
|
||||||
|
|
||||||
|
<class name="org.alfresco.repo.audit.hibernate.AuditDateImpl" proxy="org.alfresco.repo.audit.hibernate.AuditDate" table="alf_audit_date" dynamic-update="false" dynamic-insert="false"
|
||||||
|
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||||
|
|
||||||
|
<!-- An auto-generated id -->
|
||||||
|
<id name="id" column="id" type="long">
|
||||||
|
<generator class="native"/>
|
||||||
|
</id>
|
||||||
|
|
||||||
|
<!-- Date is used as the key for look up -->
|
||||||
|
|
||||||
|
<property name="date" column="date" type="date" index="adt_date_idx" not-null="true"/>
|
||||||
|
<property name="dayOfYear" column="day_of_year" type="integer" index="adt_doy_idx" not-null="true"/>
|
||||||
|
<property name="dayOfMonth" column="day_of_month" type="integer" index="adt_dom_idx" not-null="true"/>
|
||||||
|
<property name="dayOfWeek" column="day_of_week" type="integer" index="adt_dow_idx" not-null="true"/>
|
||||||
|
<property name="weekOfYear" column="week_of_year" type="integer" index="adt_woy_idx" not-null="true"/>
|
||||||
|
<property name="weekOfMonth" column="week_of_month" type="integer" index="adt_wom_idx" not-null="true"/>
|
||||||
|
<property name="month" column="month" type="integer" index="adt_m_idx" not-null="true"/>
|
||||||
|
<property name="quarter" column="quarter" type="integer" index="adt_q_idx" not-null="true"/>
|
||||||
|
<property name="halfYear" column="halfYear" type="integer" index="adt_hy_idx" not-null="true"/>
|
||||||
|
<property name="year" column="year" type="integer" index="adt_y_idx" not-null="true"/>
|
||||||
|
|
||||||
|
</class>
|
||||||
|
|
||||||
|
<!-- The audit configuration dimension -->
|
||||||
|
|
||||||
|
<class name="org.alfresco.repo.audit.hibernate.AuditConfigImpl" proxy="org.alfresco.repo.audit.hibernate.AuditConfig" table="alf_audit_config" dynamic-update="false" dynamic-insert="false"
|
||||||
|
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||||
|
|
||||||
|
<!-- Max id is used to find the latest audit configuration -->
|
||||||
|
|
||||||
|
<!-- An auto-generated id -->
|
||||||
|
<id name="id" column="id" type="long">
|
||||||
|
<generator class="native"/>
|
||||||
|
</id>
|
||||||
|
|
||||||
|
<property name="configURL" column="config_url" type="string" length="256" not-null="true"/>
|
||||||
|
|
||||||
|
</class>
|
||||||
|
|
||||||
|
<!-- The audit source dimension -->
|
||||||
|
|
||||||
|
<class name="org.alfresco.repo.audit.hibernate.AuditSourceImpl" proxy="org.alfresco.repo.audit.hibernate.AuditSource" table="alf_audit_source" dynamic-update="false" dynamic-insert="false"
|
||||||
|
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||||
|
|
||||||
|
<!-- An auto-generated id -->
|
||||||
|
<id name="id" column="id" type="long">
|
||||||
|
<generator class="native"/>
|
||||||
|
</id>
|
||||||
|
|
||||||
|
<!-- The app_source_idx index is used to find the app source -->
|
||||||
|
<!-- The look up is always the tripple, the service and method or just the method may be null -->
|
||||||
|
|
||||||
|
<property name="application" column="application" type="string" length="256" not-null="true" index="app_source_idx"/>
|
||||||
|
<property name="service" column="service" type="string" length="256" not-null="false" index="app_source_idx"/>
|
||||||
|
<property name="method" column="method" type="string" length="256" not-null="false" index="app_source_idx"/>
|
||||||
|
|
||||||
|
</class>
|
||||||
|
|
||||||
|
<query name="audit.GetLatestAuditDate">
|
||||||
|
select
|
||||||
|
audit_date
|
||||||
|
from
|
||||||
|
org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date
|
||||||
|
where
|
||||||
|
audit_date.id = (select max(audit_date_2.id) from org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date_2)
|
||||||
|
</query>
|
||||||
|
|
||||||
|
<query name="audit.GetLatestAuditConfig">
|
||||||
|
select
|
||||||
|
audit_config
|
||||||
|
from
|
||||||
|
org.alfresco.repo.audit.hibernate.AuditConfigImpl as audit_config
|
||||||
|
where
|
||||||
|
audit_config.id = (select max(audit_config_2.id) from org.alfresco.repo.audit.hibernate.AuditConfigImpl as audit_config_2)
|
||||||
|
</query>
|
||||||
|
|
||||||
|
<query name="audit.GetAuditSourceByApplication">
|
||||||
|
select
|
||||||
|
audit_store
|
||||||
|
from
|
||||||
|
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
|
||||||
|
where
|
||||||
|
audit_store.application = :application and
|
||||||
|
audit_store.service is null and
|
||||||
|
audit_store.method is null
|
||||||
|
</query>
|
||||||
|
|
||||||
|
<query name="audit.GetAuditSourceByApplicationServiceMethod">
|
||||||
|
select
|
||||||
|
audit_store
|
||||||
|
from
|
||||||
|
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
|
||||||
|
where
|
||||||
|
audit_store.application = :application and
|
||||||
|
audit_store.service = :service and
|
||||||
|
audit_store.method = :method
|
||||||
|
</query>
|
||||||
|
|
||||||
|
</hibernate-mapping>
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hibernate interface for audit configuration persistence.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditConfig
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the content URL for a copy of the configuration file.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract String getConfigURL();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the surrogate key for the configuration entry.
|
||||||
|
* The creation is managed by hibernate.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract long getId();
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
public class AuditConfigImpl implements AuditConfig, InitializingBean
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The hibernate generated internal key.
|
||||||
|
*/
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL to the content that contains the configuration file
|
||||||
|
*/
|
||||||
|
private String configURL;
|
||||||
|
|
||||||
|
public AuditConfigImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditContig#getConfigURL()
|
||||||
|
*/
|
||||||
|
public String getConfigURL()
|
||||||
|
{
|
||||||
|
return configURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigURL(String configURL)
|
||||||
|
{
|
||||||
|
this.configURL = configURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void afterPropertiesSet() throws Exception
|
||||||
|
{
|
||||||
|
// Read the audit configuration
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditContig#getId()
|
||||||
|
*/
|
||||||
|
public long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal setter for hibernate.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void setId(long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to get the latest audit config
|
||||||
|
*/
|
||||||
|
public static AuditConfigImpl getLatestConfig(Session session)
|
||||||
|
{
|
||||||
|
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_LAST_AUDIT_CONFIG);
|
||||||
|
return (AuditConfigImpl) query.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (this == o)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!(o instanceof AuditConfigImpl))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuditConfigImpl other = (AuditConfigImpl)o;
|
||||||
|
return EqualsHelper.nullSafeEquals(this.configURL, other.configURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return configURL == null ? 0 : configURL.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
106
source/java/org/alfresco/repo/audit/hibernate/AuditDate.java
Normal file
106
source/java/org/alfresco/repo/audit/hibernate/AuditDate.java
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hibernate date dimension for audit roll ups
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public interface AuditDate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the date
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract Date getDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the day of the year.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getDayOfYear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the day of the month.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getDayOfMonth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the day of the week
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getDayOfWeek();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the half year;
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getHalfYear();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the surrogate key
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract long getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the month
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getMonth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the quarter
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getQuarter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the week of the month.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getWeekOfMonth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the week of the year.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getWeekOfYear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the year.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract int getYear();
|
||||||
|
|
||||||
|
}
|
289
source/java/org/alfresco/repo/audit/hibernate/AuditDateImpl.java
Normal file
289
source/java/org/alfresco/repo/audit/hibernate/AuditDateImpl.java
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hibernate persistence for a date dimension.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditDateImpl implements AuditDate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Surrogate key
|
||||||
|
*/
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date
|
||||||
|
*/
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The day
|
||||||
|
*/
|
||||||
|
private int dayOfYear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Day of month.
|
||||||
|
*/
|
||||||
|
private int dayOfMonth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The day of the week
|
||||||
|
*/
|
||||||
|
private int dayOfWeek;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The week in the year
|
||||||
|
*/
|
||||||
|
private int weekOfYear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The week of the month
|
||||||
|
*/
|
||||||
|
private int weekOfMonth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The month in the year
|
||||||
|
*/
|
||||||
|
private int month;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The quarter in the year
|
||||||
|
*/
|
||||||
|
private int quarter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The half year in the year
|
||||||
|
*/
|
||||||
|
private int halfYear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The year
|
||||||
|
*/
|
||||||
|
private int year;
|
||||||
|
|
||||||
|
protected AuditDateImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditDateImpl(Date date)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
setDate(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getDate()
|
||||||
|
*/
|
||||||
|
public Date getDate()
|
||||||
|
{
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date)
|
||||||
|
{
|
||||||
|
Calendar cal = GregorianCalendar.getInstance();
|
||||||
|
cal.setTime(date);
|
||||||
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
this.date = cal.getTime();
|
||||||
|
|
||||||
|
this.setDayOfYear(cal.get(Calendar.DAY_OF_YEAR));
|
||||||
|
this.setDayOfMonth(cal.get(Calendar.DAY_OF_MONTH));
|
||||||
|
this.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK));
|
||||||
|
this.setMonth(cal.get(Calendar.MONTH));
|
||||||
|
this.setHalfYear(getMonth() <= Calendar.JUNE ? 0 : 1);
|
||||||
|
this.setQuarter((getMonth()/3));
|
||||||
|
this.setWeekOfMonth(cal.get(Calendar.WEEK_OF_MONTH));
|
||||||
|
this.setWeekOfYear(cal.get(Calendar.WEEK_OF_YEAR));
|
||||||
|
this.setYear(cal.get(Calendar.YEAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getDayOfYear()
|
||||||
|
*/
|
||||||
|
public int getDayOfYear()
|
||||||
|
{
|
||||||
|
return dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDayOfYear(int dayOfYear)
|
||||||
|
{
|
||||||
|
this.dayOfYear = dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getDayOfMonth()
|
||||||
|
*/
|
||||||
|
public int getDayOfMonth()
|
||||||
|
{
|
||||||
|
return dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDayOfMonth(int dayOfMonth)
|
||||||
|
{
|
||||||
|
this.dayOfMonth = dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getDayOfWeek()
|
||||||
|
*/
|
||||||
|
public int getDayOfWeek()
|
||||||
|
{
|
||||||
|
return dayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDayOfWeek(int dayOfWeek)
|
||||||
|
{
|
||||||
|
this.dayOfWeek = dayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getHalfYear()
|
||||||
|
*/
|
||||||
|
public int getHalfYear()
|
||||||
|
{
|
||||||
|
return halfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setHalfYear(int halfYear)
|
||||||
|
{
|
||||||
|
this.halfYear = halfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getId()
|
||||||
|
*/
|
||||||
|
public long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setId(long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getMonth()
|
||||||
|
*/
|
||||||
|
public int getMonth()
|
||||||
|
{
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMonth(int month)
|
||||||
|
{
|
||||||
|
this.month = month;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getQuarter()
|
||||||
|
*/
|
||||||
|
public int getQuarter()
|
||||||
|
{
|
||||||
|
return quarter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setQuarter(int quarter)
|
||||||
|
{
|
||||||
|
this.quarter = quarter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getWeekOfMonth()
|
||||||
|
*/
|
||||||
|
public int getWeekOfMonth()
|
||||||
|
{
|
||||||
|
return weekOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setWeekOfMonth(int weekOfMonth)
|
||||||
|
{
|
||||||
|
this.weekOfMonth = weekOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getWeekOfYear()
|
||||||
|
*/
|
||||||
|
public int getWeekOfYear()
|
||||||
|
{
|
||||||
|
return weekOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setWeekOfYear(int weekOfYear)
|
||||||
|
{
|
||||||
|
this.weekOfYear = weekOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditDate#getYear()
|
||||||
|
*/
|
||||||
|
public int getYear()
|
||||||
|
{
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setYear(int year)
|
||||||
|
{
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if(this == o)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!(o instanceof AuditDateImpl))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuditDateImpl that = (AuditDateImpl)o;
|
||||||
|
return EqualsHelper.nullSafeEquals(this.date, that.date);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.date.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to get the latest audit date
|
||||||
|
*/
|
||||||
|
public static AuditDateImpl getLatestDate(Session session)
|
||||||
|
{
|
||||||
|
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_LAST_AUDIT_DATE);
|
||||||
|
return (AuditDateImpl) query.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
74
source/java/org/alfresco/repo/audit/hibernate/AuditFact.java
Normal file
74
source/java/org/alfresco/repo/audit/hibernate/AuditFact.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface AuditFact
|
||||||
|
{
|
||||||
|
|
||||||
|
public abstract String getArg1();
|
||||||
|
|
||||||
|
public abstract String getArg2();
|
||||||
|
|
||||||
|
public abstract String getArg3();
|
||||||
|
|
||||||
|
public abstract String getArg4();
|
||||||
|
|
||||||
|
public abstract String getArg5();
|
||||||
|
|
||||||
|
public abstract AuditConfig getAuditConfig();
|
||||||
|
|
||||||
|
public abstract AuditDate getAuditDate();
|
||||||
|
|
||||||
|
public abstract AuditSource getAuditSource();
|
||||||
|
|
||||||
|
public abstract String getClientInetAddress();
|
||||||
|
|
||||||
|
public abstract Date getDate();
|
||||||
|
|
||||||
|
public abstract String getException();
|
||||||
|
|
||||||
|
public abstract boolean isFail();
|
||||||
|
|
||||||
|
public abstract boolean isFiltered();
|
||||||
|
|
||||||
|
public abstract String getHostInetAddress();
|
||||||
|
|
||||||
|
public abstract long getId();
|
||||||
|
|
||||||
|
public abstract String getMessage();
|
||||||
|
|
||||||
|
public abstract String getNodeUUID();
|
||||||
|
|
||||||
|
public abstract String getPath();
|
||||||
|
|
||||||
|
public abstract String getReturnValue();
|
||||||
|
|
||||||
|
public abstract String getSerialisedURL();
|
||||||
|
|
||||||
|
public abstract String getSessionId();
|
||||||
|
|
||||||
|
public abstract String getStoreId();
|
||||||
|
|
||||||
|
public abstract String getStoreProtocol();
|
||||||
|
|
||||||
|
public abstract String getTransactionId();
|
||||||
|
|
||||||
|
public abstract String getUserId();
|
||||||
|
|
||||||
|
}
|
578
source/java/org/alfresco/repo/audit/hibernate/AuditFactImpl.java
Normal file
578
source/java/org/alfresco/repo/audit/hibernate/AuditFactImpl.java
Normal file
@ -0,0 +1,578 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Audit fact Rely on standard equals and hash code as they should all be unique.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditFactImpl implements AuditFact
|
||||||
|
{
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private AuditDate auditDate;
|
||||||
|
|
||||||
|
private AuditConfig auditConfig;
|
||||||
|
|
||||||
|
private AuditSource auditSource;
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
private String transactionId;
|
||||||
|
|
||||||
|
private String sessionId;
|
||||||
|
|
||||||
|
private String storeProtocol;
|
||||||
|
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
private String nodeUUID;
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
private boolean filtered;
|
||||||
|
|
||||||
|
private String returnValue;
|
||||||
|
|
||||||
|
private String arg1;
|
||||||
|
|
||||||
|
private String arg2;
|
||||||
|
|
||||||
|
private String arg3;
|
||||||
|
|
||||||
|
private String arg4;
|
||||||
|
|
||||||
|
private String arg5;
|
||||||
|
|
||||||
|
private boolean fail;
|
||||||
|
|
||||||
|
private String serialisedURL;
|
||||||
|
|
||||||
|
private String exception;
|
||||||
|
|
||||||
|
private String hostInetAddress;
|
||||||
|
|
||||||
|
private String clientInetAddress;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public AuditFactImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg1()
|
||||||
|
*/
|
||||||
|
public String getArg1()
|
||||||
|
{
|
||||||
|
return arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg1(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setArg1(String arg1)
|
||||||
|
{
|
||||||
|
this.arg1 = arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg2()
|
||||||
|
*/
|
||||||
|
public String getArg2()
|
||||||
|
{
|
||||||
|
return arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg2(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setArg2(String arg2)
|
||||||
|
{
|
||||||
|
this.arg2 = arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg3()
|
||||||
|
*/
|
||||||
|
public String getArg3()
|
||||||
|
{
|
||||||
|
return arg3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg3(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setArg3(String arg3)
|
||||||
|
{
|
||||||
|
this.arg3 = arg3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg4()
|
||||||
|
*/
|
||||||
|
public String getArg4()
|
||||||
|
{
|
||||||
|
return arg4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg4(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setArg4(String arg4)
|
||||||
|
{
|
||||||
|
this.arg4 = arg4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg5()
|
||||||
|
*/
|
||||||
|
public String getArg5()
|
||||||
|
{
|
||||||
|
return arg5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg5(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setArg5(String arg5)
|
||||||
|
{
|
||||||
|
this.arg5 = arg5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditConfig()
|
||||||
|
*/
|
||||||
|
public AuditConfig getAuditConfig()
|
||||||
|
{
|
||||||
|
return auditConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditConfig(org.alfresco.repo.audit.hibernate.AuditConfig)
|
||||||
|
*/
|
||||||
|
public void setAuditConfig(AuditConfig auditConfig)
|
||||||
|
{
|
||||||
|
this.auditConfig = auditConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditDate()
|
||||||
|
*/
|
||||||
|
public AuditDate getAuditDate()
|
||||||
|
{
|
||||||
|
return auditDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditDate(org.alfresco.repo.audit.hibernate.AuditDate)
|
||||||
|
*/
|
||||||
|
public void setAuditDate(AuditDate auditDate)
|
||||||
|
{
|
||||||
|
this.auditDate = auditDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditSource()
|
||||||
|
*/
|
||||||
|
public AuditSource getAuditSource()
|
||||||
|
{
|
||||||
|
return auditSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditSource(org.alfresco.repo.audit.hibernate.AuditSource)
|
||||||
|
*/
|
||||||
|
public void setAuditSource(AuditSource auditSource)
|
||||||
|
{
|
||||||
|
this.auditSource = auditSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getClientInetAddress()
|
||||||
|
*/
|
||||||
|
public String getClientInetAddress()
|
||||||
|
{
|
||||||
|
return clientInetAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setClientInetAddress(java.net.InetAddress)
|
||||||
|
*/
|
||||||
|
public void setClientInetAddress(String clientInetAddress)
|
||||||
|
{
|
||||||
|
this.clientInetAddress = clientInetAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getDate()
|
||||||
|
*/
|
||||||
|
public Date getDate()
|
||||||
|
{
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setDate(java.util.Date)
|
||||||
|
*/
|
||||||
|
public void setDate(Date date)
|
||||||
|
{
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getException()
|
||||||
|
*/
|
||||||
|
public String getException()
|
||||||
|
{
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setException(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setException(String exception)
|
||||||
|
{
|
||||||
|
this.exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#isFail()
|
||||||
|
*/
|
||||||
|
public boolean isFail()
|
||||||
|
{
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setFail(boolean)
|
||||||
|
*/
|
||||||
|
public void setFail(boolean fail)
|
||||||
|
{
|
||||||
|
this.fail = fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#isFiltered()
|
||||||
|
*/
|
||||||
|
public boolean isFiltered()
|
||||||
|
{
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setFiltered(boolean)
|
||||||
|
*/
|
||||||
|
public void setFiltered(boolean filtered)
|
||||||
|
{
|
||||||
|
this.filtered = filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getHostInetAddress()
|
||||||
|
*/
|
||||||
|
public String getHostInetAddress()
|
||||||
|
{
|
||||||
|
return hostInetAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setHostInetAddress(java.net.InetAddress)
|
||||||
|
*/
|
||||||
|
public void setHostInetAddress(String hostInetAddress)
|
||||||
|
{
|
||||||
|
this.hostInetAddress = hostInetAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getId()
|
||||||
|
*/
|
||||||
|
public long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setId(long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getMessage()
|
||||||
|
*/
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setMessage(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setMessage(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getNodeGUID()
|
||||||
|
*/
|
||||||
|
public String getNodeUUID()
|
||||||
|
{
|
||||||
|
return nodeUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setNodeGUID(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setNodeUUID(String nodeUUID)
|
||||||
|
{
|
||||||
|
this.nodeUUID = nodeUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getPath()
|
||||||
|
*/
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setPath(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setPath(String path)
|
||||||
|
{
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getReturnValue()
|
||||||
|
*/
|
||||||
|
public String getReturnValue()
|
||||||
|
{
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setReturnValue(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setReturnValue(String returnValue)
|
||||||
|
{
|
||||||
|
this.returnValue = returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getSerialisedURL()
|
||||||
|
*/
|
||||||
|
public String getSerialisedURL()
|
||||||
|
{
|
||||||
|
return serialisedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setSerialisedURL(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setSerialisedURL(String serialisedURL)
|
||||||
|
{
|
||||||
|
this.serialisedURL = serialisedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getSessionId()
|
||||||
|
*/
|
||||||
|
public String getSessionId()
|
||||||
|
{
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setSessionId(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setSessionId(String sessionId)
|
||||||
|
{
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getStoreId()
|
||||||
|
*/
|
||||||
|
public String getStoreId()
|
||||||
|
{
|
||||||
|
return storeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setStoreId(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setStoreId(String storeId)
|
||||||
|
{
|
||||||
|
this.storeId = storeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getStoreProtocol()
|
||||||
|
*/
|
||||||
|
public String getStoreProtocol()
|
||||||
|
{
|
||||||
|
return storeProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setStoreProtocol(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setStoreProtocol(String storeProtocol)
|
||||||
|
{
|
||||||
|
this.storeProtocol = storeProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getTransactionId()
|
||||||
|
*/
|
||||||
|
public String getTransactionId()
|
||||||
|
{
|
||||||
|
return transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setTransactionId(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setTransactionId(String transactionId)
|
||||||
|
{
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#getUserId()
|
||||||
|
*/
|
||||||
|
public String getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.audit.hibernate.AuditFact#setUserId(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setUserId(String userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
public interface AuditSource
|
||||||
|
{
|
||||||
|
public String getApplication();
|
||||||
|
|
||||||
|
public long getId();
|
||||||
|
|
||||||
|
public String getMethod();
|
||||||
|
|
||||||
|
public String getService();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
|
||||||
|
public class AuditSourceImpl implements AuditSource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The surrogate key
|
||||||
|
*/
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The auditing application (System for method audits)
|
||||||
|
*/
|
||||||
|
private String application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audited service
|
||||||
|
*/
|
||||||
|
private String service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audited method
|
||||||
|
*/
|
||||||
|
private String method;
|
||||||
|
|
||||||
|
public AuditSourceImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplication()
|
||||||
|
{
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplication(String application)
|
||||||
|
{
|
||||||
|
this.application = application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setId(long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod()
|
||||||
|
{
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method)
|
||||||
|
{
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getService()
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(String service)
|
||||||
|
{
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuditSourceImpl getApplicationSource(Session session, String application)
|
||||||
|
{
|
||||||
|
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE);
|
||||||
|
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||||
|
return (AuditSourceImpl) query.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuditSourceImpl getApplicationSource(Session session, String application, String service,
|
||||||
|
String method)
|
||||||
|
{
|
||||||
|
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_METHOD_SOURCE);
|
||||||
|
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||||
|
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_SER, service);
|
||||||
|
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_MET, method);
|
||||||
|
return (AuditSourceImpl) query.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (this == o)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof AuditSourceImpl))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuditSourceImpl other = (AuditSourceImpl) o;
|
||||||
|
return EqualsHelper.nullSafeEquals(this.application, other.application)
|
||||||
|
&& EqualsHelper.nullSafeEquals(this.service, other.service)
|
||||||
|
&& EqualsHelper.nullSafeEquals(this.method, other.method);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int hash = application.hashCode();
|
||||||
|
if(service != null)
|
||||||
|
{
|
||||||
|
hash = (hash * 37) + service.hashCode();
|
||||||
|
}
|
||||||
|
if(method != null)
|
||||||
|
{
|
||||||
|
hash = (hash * 37) + method.hashCode();
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,439 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.hibernate;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.repo.audit.AuditConfiguration;
|
||||||
|
import org.alfresco.repo.audit.AuditDAO;
|
||||||
|
import org.alfresco.repo.audit.AuditInfo;
|
||||||
|
import org.alfresco.repo.content.AbstractContentStore;
|
||||||
|
import org.alfresco.repo.content.ContentStore;
|
||||||
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.transaction.TransactionalDao;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.Duration;
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.alfresco.util.GUID;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.springframework.orm.hibernate3.HibernateCallback;
|
||||||
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assumes mimetype and encoding sent to the content store (we are not saving this anywhere)
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, TransactionalDao
|
||||||
|
{
|
||||||
|
public static final String QUERY_LAST_AUDIT_DATE = "audit.GetLatestAuditDate";
|
||||||
|
|
||||||
|
public static final String QUERY_LAST_AUDIT_CONFIG = "audit.GetLatestAuditConfig";
|
||||||
|
|
||||||
|
public static final String QUERY_AUDIT_APP_SOURCE = "audit.GetAuditSourceByApplication";
|
||||||
|
|
||||||
|
public static final String QUERY_AUDIT_METHOD_SOURCE = "audit.GetAuditSourceByApplicationServiceMethod";
|
||||||
|
|
||||||
|
public static final String QUERY_AUDIT_APP_SOURCE_APP = "application";
|
||||||
|
|
||||||
|
public static final String QUERY_AUDIT_APP_SOURCE_SER = "service";
|
||||||
|
|
||||||
|
public static final String QUERY_AUDIT_APP_SOURCE_MET = "method";
|
||||||
|
|
||||||
|
/** a uuid identifying this unique instance */
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
private ContentStore contentStore;
|
||||||
|
|
||||||
|
private ThreadLocal<AuditConfiguration> auditConfiguration = new ThreadLocal<AuditConfiguration>();
|
||||||
|
|
||||||
|
private ThreadLocal<Long> auditConfigImplId = new ThreadLocal<Long>();
|
||||||
|
|
||||||
|
private ThreadLocal<Long> auditDateImplId = new ThreadLocal<Long>();
|
||||||
|
|
||||||
|
private ThreadLocal<HashMap<SourceKey, Long>> sourceIds = new ThreadLocal<HashMap<SourceKey, Long>>();
|
||||||
|
|
||||||
|
public HibernateAuditDAO()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.uuid = GUID.generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentStore getContentStore()
|
||||||
|
{
|
||||||
|
return contentStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentStore(ContentStore contentStore)
|
||||||
|
{
|
||||||
|
this.contentStore = contentStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audit(AuditInfo auditInfo)
|
||||||
|
{
|
||||||
|
// Find/Build the configuraton entry
|
||||||
|
AuditConfigImpl auditConfig = getAuditConfig(auditInfo);
|
||||||
|
|
||||||
|
// Find/Build any dates
|
||||||
|
AuditDateImpl auditDate = getAuditDate(auditInfo);
|
||||||
|
|
||||||
|
// Find/Build the source
|
||||||
|
AuditSourceImpl auditSource = getAuditSource(auditInfo);
|
||||||
|
|
||||||
|
// Build the new audit fact information
|
||||||
|
AuditFactImpl auditFact = new AuditFactImpl();
|
||||||
|
auditFact.setAuditConfig(auditConfig);
|
||||||
|
auditFact.setAuditDate(auditDate);
|
||||||
|
auditFact.setAuditSource(auditSource);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
|
||||||
|
Serializable[] args = auditInfo.getMethodArguments();
|
||||||
|
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
switch (args.length)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 5:
|
||||||
|
auditFact.setArg5(getStringOrNull(args[4]));
|
||||||
|
case 4:
|
||||||
|
auditFact.setArg4(getStringOrNull(args[3]));
|
||||||
|
case 3:
|
||||||
|
auditFact.setArg3(getStringOrNull(args[2]));
|
||||||
|
case 2:
|
||||||
|
auditFact.setArg2(getStringOrNull(args[1]));
|
||||||
|
case 1:
|
||||||
|
auditFact.setArg1(getStringOrNull(args[0]));
|
||||||
|
case 0:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auditFact.setClientInetAddress(auditInfo.getClientAddress() == null ? null : auditInfo.getClientAddress()
|
||||||
|
.toString());
|
||||||
|
auditFact.setDate(auditInfo.getDate());
|
||||||
|
auditFact.setException(auditInfo.getThrowable() == null ? null : auditInfo.getThrowable().getMessage());
|
||||||
|
auditFact.setFail(auditInfo.isFail());
|
||||||
|
auditFact.setFiltered(auditInfo.isFiltered());
|
||||||
|
auditFact.setHostInetAddress(auditInfo.getHostAddress() == null ? null : auditInfo.getHostAddress().toString());
|
||||||
|
auditFact.setMessage(auditInfo.getMessage());
|
||||||
|
auditFact.setNodeUUID(auditInfo.getKeyGUID());
|
||||||
|
auditFact.setPath(auditInfo.getPath());
|
||||||
|
auditFact.setReturnValue(auditInfo.getReturnObject() == null ? null : auditInfo.getReturnObject().toString());
|
||||||
|
// auditFact.setSerialisedURL()
|
||||||
|
auditFact.setSessionId(auditInfo.getSessionId());
|
||||||
|
if (auditInfo.getKeyStore() != null)
|
||||||
|
{
|
||||||
|
auditFact.setStoreId(auditInfo.getKeyStore().getIdentifier());
|
||||||
|
auditFact.setStoreProtocol(auditInfo.getKeyStore().getProtocol());
|
||||||
|
}
|
||||||
|
auditFact.setTransactionId(auditInfo.getTxId());
|
||||||
|
auditFact.setUserId(auditInfo.getUserIdentifier());
|
||||||
|
|
||||||
|
// Save
|
||||||
|
getSession().save(auditFact);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStringOrNull(Object o)
|
||||||
|
{
|
||||||
|
if (o == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return o.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditSourceImpl getAuditSource(AuditInfo auditInfo)
|
||||||
|
{
|
||||||
|
AuditSourceImpl auditSourceImpl;
|
||||||
|
|
||||||
|
SourceKey sourceKey = new SourceKey(auditInfo.getAuditApplication(), auditInfo.getAuditService(), auditInfo.getAuditMethod());
|
||||||
|
if(sourceIds.get() == null)
|
||||||
|
{
|
||||||
|
sourceIds.set(new HashMap<SourceKey, Long>());
|
||||||
|
}
|
||||||
|
Long id = sourceIds.get().get(sourceKey);
|
||||||
|
if(id != null)
|
||||||
|
{
|
||||||
|
auditSourceImpl = (AuditSourceImpl) getSession().get(AuditSourceImpl.class, id.longValue());
|
||||||
|
if(auditSourceImpl != null)
|
||||||
|
{
|
||||||
|
return auditSourceImpl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((auditInfo.getAuditService() != null)
|
||||||
|
&& (auditInfo.getAuditService().length() > 0) && (auditInfo.getAuditMethod() != null)
|
||||||
|
&& (auditInfo.getAuditMethod().length() > 0))
|
||||||
|
{
|
||||||
|
auditSourceImpl = AuditSourceImpl.getApplicationSource(getSession(), auditInfo.getAuditApplication(),
|
||||||
|
auditInfo.getAuditService(), auditInfo.getAuditMethod());
|
||||||
|
if (auditSourceImpl == null)
|
||||||
|
{
|
||||||
|
auditSourceImpl = new AuditSourceImpl();
|
||||||
|
auditSourceImpl.setApplication(auditInfo.getAuditApplication());
|
||||||
|
auditSourceImpl.setService(auditInfo.getAuditService());
|
||||||
|
auditSourceImpl.setMethod(auditInfo.getAuditMethod());
|
||||||
|
getSession().save(auditSourceImpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auditSourceImpl = AuditSourceImpl.getApplicationSource(getSession(), auditInfo.getAuditApplication());
|
||||||
|
if (auditSourceImpl == null)
|
||||||
|
{
|
||||||
|
auditSourceImpl = new AuditSourceImpl();
|
||||||
|
auditSourceImpl.setApplication(auditInfo.getAuditApplication());
|
||||||
|
getSession().save(auditSourceImpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceIds.get().put(sourceKey, Long.valueOf(auditSourceImpl.getId()));
|
||||||
|
return auditSourceImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditDateImpl getAuditDate(AuditInfo auditInfo)
|
||||||
|
{
|
||||||
|
Calendar cal = GregorianCalendar.getInstance();
|
||||||
|
cal.setTime(auditInfo.getDate());
|
||||||
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
Date required = cal.getTime();
|
||||||
|
|
||||||
|
AuditDateImpl auditDate;
|
||||||
|
if (auditDateImplId.get() == null)
|
||||||
|
{
|
||||||
|
auditDate = AuditDateImpl.getLatestDate(getSession());
|
||||||
|
if (auditDate == null)
|
||||||
|
{
|
||||||
|
// The first entry ever so we just make it
|
||||||
|
auditDate = new AuditDateImpl(auditInfo.getDate());
|
||||||
|
getSession().save(auditDate);
|
||||||
|
}
|
||||||
|
auditDateImplId.set(Long.valueOf(auditDate.getId()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auditDate = (AuditDateImpl) getSession().get(AuditDateImpl.class, auditDateImplId.get().longValue());
|
||||||
|
if ((auditDate == null) || (!required.equals(auditDate.getDate())))
|
||||||
|
{
|
||||||
|
auditDate = AuditDateImpl.getLatestDate(getSession());
|
||||||
|
if (auditDate == null)
|
||||||
|
{
|
||||||
|
// The first entry ever so we just make it
|
||||||
|
auditDate = new AuditDateImpl(auditInfo.getDate());
|
||||||
|
getSession().save(auditDate);
|
||||||
|
}
|
||||||
|
auditDateImplId.set(Long.valueOf(auditDate.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!required.equals(auditDate.getDate()))
|
||||||
|
{
|
||||||
|
Date nextDate = Duration.add(auditDate.getDate(), new Duration("P1D"));
|
||||||
|
auditDate = new AuditDateImpl(nextDate);
|
||||||
|
getSession().save(auditDate);
|
||||||
|
auditDateImplId.set(Long.valueOf(auditDate.getId()));
|
||||||
|
}
|
||||||
|
return auditDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditConfigImpl getAuditConfig(AuditInfo auditInfo)
|
||||||
|
{
|
||||||
|
AuditConfigImpl auditConfig;
|
||||||
|
if ((auditConfiguration.get() == null) || (auditConfiguration.get() != auditInfo.getAuditConfiguration()))
|
||||||
|
{
|
||||||
|
auditConfig = AuditConfigImpl.getLatestConfig(getSession());
|
||||||
|
if (auditConfig == null)
|
||||||
|
{
|
||||||
|
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InputStream current = new BufferedInputStream(auditInfo.getAuditConfiguration().getInputStream());
|
||||||
|
ContentReader reader = contentStore.getReader(auditConfig.getConfigURL());
|
||||||
|
reader.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||||
|
reader.setEncoding("UTF-8");
|
||||||
|
InputStream last = new BufferedInputStream(reader.getContentInputStream());
|
||||||
|
int currentValue = -2;
|
||||||
|
int lastValue = -2;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while ((currentValue != -1) && (lastValue != -1) && (currentValue == lastValue))
|
||||||
|
{
|
||||||
|
currentValue = current.read();
|
||||||
|
lastValue = last.read();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Failed to read and validate current audit configuration against the last", e);
|
||||||
|
}
|
||||||
|
if (currentValue != lastValue)
|
||||||
|
{
|
||||||
|
// Files are different - require a new entry
|
||||||
|
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auditConfigImplId.set(Long.valueOf(auditConfig.getId()));
|
||||||
|
auditConfiguration.set(auditInfo.getAuditConfiguration());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auditConfig = (AuditConfigImpl) getSession()
|
||||||
|
.get(AuditConfigImpl.class, auditConfigImplId.get().longValue());
|
||||||
|
if (auditConfig == null)
|
||||||
|
{
|
||||||
|
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return auditConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditConfigImpl createNewAuditConfigImpl(AuditInfo auditInfo)
|
||||||
|
{
|
||||||
|
AuditConfigImpl auditConfig = new AuditConfigImpl();
|
||||||
|
InputStream is = new BufferedInputStream(auditInfo.getAuditConfiguration().getInputStream());
|
||||||
|
String url = AbstractContentStore.createNewUrl();
|
||||||
|
ContentWriter writer = contentStore.getWriter(null, url);
|
||||||
|
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||||
|
writer.setEncoding("UTF-8");
|
||||||
|
writer.putContent(is);
|
||||||
|
auditConfig.setConfigURL(url);
|
||||||
|
getSession().save(auditConfig);
|
||||||
|
return auditConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks equality by type and uuid
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!(obj instanceof HibernateAuditDAO))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HibernateAuditDAO that = (HibernateAuditDAO) obj;
|
||||||
|
return this.uuid.equals(that.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #uuid
|
||||||
|
*/
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return uuid.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this <tt>Session</tt> contain any changes which must be synchronized with the store?
|
||||||
|
*
|
||||||
|
* @return true => changes are pending
|
||||||
|
*/
|
||||||
|
public boolean isDirty()
|
||||||
|
{
|
||||||
|
// create a callback for the task
|
||||||
|
HibernateCallback callback = new HibernateCallback()
|
||||||
|
{
|
||||||
|
public Object doInHibernate(Session session)
|
||||||
|
{
|
||||||
|
return session.isDirty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// execute the callback
|
||||||
|
return ((Boolean) getHibernateTemplate().execute(callback)).booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just flushes the session
|
||||||
|
*/
|
||||||
|
public void flush()
|
||||||
|
{
|
||||||
|
getSession().flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SourceKey
|
||||||
|
{
|
||||||
|
String application;
|
||||||
|
|
||||||
|
String service;
|
||||||
|
|
||||||
|
String method;
|
||||||
|
|
||||||
|
SourceKey(String application, String service, String method)
|
||||||
|
{
|
||||||
|
this.application = application;
|
||||||
|
this.service = service;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (this == o)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(this instanceof SourceKey))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SourceKey other = (SourceKey) o;
|
||||||
|
return EqualsHelper.nullSafeEquals(this.application, other.application)
|
||||||
|
&& EqualsHelper.nullSafeEquals(this.service, other.service)
|
||||||
|
&& EqualsHelper.nullSafeEquals(this.method, other.method);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int hash = application.hashCode();
|
||||||
|
if (service != null)
|
||||||
|
{
|
||||||
|
hash = (hash * 37) + service.hashCode();
|
||||||
|
}
|
||||||
|
if (method != null)
|
||||||
|
{
|
||||||
|
hash = (hash * 37) + method.hashCode();
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc. Licensed under the Mozilla Public License version 1.1 with a permitted attribution clause. You may obtain a copy of the License at
|
||||||
|
* http://www.alfresco.org/legal/license.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditMode;
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.repo.audit.PublicServiceIdentifier;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Attribute;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public abstract class AbstractAuditEntry
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(AbstractAuditEntry.class);
|
||||||
|
|
||||||
|
private RecordOptionsImpl recordOptions = null;
|
||||||
|
|
||||||
|
private AbstractFilter filter = null;
|
||||||
|
|
||||||
|
private AuditMode auditMode = AuditMode.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset enabled = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset auditInternal = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private AbstractAuditEntry parent;
|
||||||
|
|
||||||
|
private PublicServiceIdentifier publicServiceIdentifier;
|
||||||
|
|
||||||
|
public AbstractAuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicServiceIdentifier getPublicServiceIdentifier()
|
||||||
|
{
|
||||||
|
return publicServiceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicServiceIdentifier(PublicServiceIdentifier publicServiceIdentifier)
|
||||||
|
{
|
||||||
|
this.publicServiceIdentifier = publicServiceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
this.parent = parent;
|
||||||
|
|
||||||
|
Attribute auditModeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||||
|
if (auditModeAttribute != null)
|
||||||
|
{
|
||||||
|
auditMode = AuditMode.getAuditMode(auditModeAttribute.getValue());
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Audit Mode = "+auditMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Attribute enabledAttribute = element.attribute(AuditModel.AT_ENABLED);
|
||||||
|
if (enabledAttribute != null)
|
||||||
|
{
|
||||||
|
enabled = TrueFalseUnset.getTrueFalseUnset(enabledAttribute.getValue());
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Enabled = "+enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
Attribute auditInternalAttribute = element.attribute(AuditModel.AT_AUDIT_INTERNAL);
|
||||||
|
if (auditInternalAttribute != null)
|
||||||
|
{
|
||||||
|
auditInternal = TrueFalseUnset.getTrueFalseUnset(auditInternalAttribute.getValue());
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Audit Internal = "+auditInternal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make record options
|
||||||
|
Element recordOptionElement = element.element(AuditModel.EL_RECORD_OPTIONS);
|
||||||
|
if (recordOptionElement != null)
|
||||||
|
{
|
||||||
|
recordOptions = new RecordOptionsImpl();
|
||||||
|
recordOptions.configure(recordOptionElement, namespacePrefixResolver);
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Record Options = "+recordOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make filters
|
||||||
|
Element filterElement = element.element(AuditModel.EL_FILTER);
|
||||||
|
if (filterElement != null)
|
||||||
|
{
|
||||||
|
filter = AbstractFilter.createFilter(filterElement, namespacePrefixResolver);
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Filter = "+filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */TrueFalseUnset getAuditInternal()
|
||||||
|
{
|
||||||
|
return auditInternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */AuditMode getAuditMode()
|
||||||
|
{
|
||||||
|
return auditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */TrueFalseUnset getEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */AbstractFilter getFilter()
|
||||||
|
{
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */AbstractAuditEntry getParent()
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */RecordOptionsImpl getRecordOptions()
|
||||||
|
{
|
||||||
|
return recordOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AuditMode getEffectiveAuditMode()
|
||||||
|
{
|
||||||
|
AuditMode auditMode;
|
||||||
|
if (checkEnabled() == TrueFalseUnset.TRUE)
|
||||||
|
{
|
||||||
|
auditMode = getAuditModeOrParentAuditMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auditMode = AuditMode.NONE;
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("... Effective audit mode is = "+auditMode);
|
||||||
|
}
|
||||||
|
return auditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuditMode getAuditModeOrParentAuditMode()
|
||||||
|
{
|
||||||
|
AuditMode auditMode = getAuditMode();
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("... ... audit mode is = "+auditMode);
|
||||||
|
}
|
||||||
|
if (auditMode == AuditMode.UNSET)
|
||||||
|
{
|
||||||
|
if (getParent() == null)
|
||||||
|
{
|
||||||
|
return AuditMode.UNSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return getParent().getAuditModeOrParentAuditMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return auditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrueFalseUnset checkEnabled()
|
||||||
|
{
|
||||||
|
TrueFalseUnset effective = getEnabled();
|
||||||
|
if (getParent() != null)
|
||||||
|
{
|
||||||
|
if ((getParent().checkEnabled() == TrueFalseUnset.TRUE) && (effective != TrueFalseUnset.FALSE))
|
||||||
|
{
|
||||||
|
return TrueFalseUnset.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (effective == TrueFalseUnset.TRUE)
|
||||||
|
{
|
||||||
|
return TrueFalseUnset.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TrueFalseUnset.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Attribute;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base class for filtering.
|
||||||
|
*
|
||||||
|
* This supports negating the filter, ie NOT.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public abstract class AbstractFilter implements XMLModelElement
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(AbstractFilter.class);
|
||||||
|
|
||||||
|
private boolean invert = false;
|
||||||
|
|
||||||
|
public AbstractFilter()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AbstractFilter createFilter(Element filterElement, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
AbstractFilter filter;
|
||||||
|
|
||||||
|
Attribute typeAttribute = filterElement.attribute(AuditModel.AT_TYPE);
|
||||||
|
if (typeAttribute == null)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("A filter must specify it concrete type using xsi:type");
|
||||||
|
}
|
||||||
|
if (typeAttribute.getStringValue().endsWith("FilterSet"))
|
||||||
|
{
|
||||||
|
filter = new FilterSet();
|
||||||
|
}
|
||||||
|
else if (typeAttribute.getStringValue().endsWith("KeyFilter"))
|
||||||
|
{
|
||||||
|
filter = new KeyFilter();
|
||||||
|
}
|
||||||
|
else if (typeAttribute.getStringValue().endsWith("ParameterFilter"))
|
||||||
|
{
|
||||||
|
filter = new ParameterFilter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException(
|
||||||
|
"Invalid filter type. It must be one of: FilterSet, KeyFilter, ParameterFilter ");
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.configure(filterElement, namespacePrefixResolver);
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
Attribute invertAttribute = element.attribute(AuditModel.AT_INVERT);
|
||||||
|
if (invertAttribute != null)
|
||||||
|
{
|
||||||
|
invert = Boolean.valueOf(invertAttribute.getStringValue()).booleanValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
invert = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */boolean isInvert()
|
||||||
|
{
|
||||||
|
return invert;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Attribute;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public abstract class AbstractNamedAuditEntry extends AbstractAuditEntry
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(AbstractNamedAuditEntry.class);
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public AbstractNamedAuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
Attribute nameAttribute = element.attribute(AuditModel.AT_NAME);
|
||||||
|
if (nameAttribute != null)
|
||||||
|
{
|
||||||
|
name = nameAttribute.getStringValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException("The name attribute is mandatory");
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Name = "+name);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.configure(parent, element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.ApplicationAuditModel;
|
||||||
|
import org.alfresco.repo.audit.AuditMode;
|
||||||
|
import org.alfresco.repo.audit.RecordOptions;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
public class ApplicationAuditEntry extends AbstractNamedAuditEntry implements ApplicationAuditModel
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(ApplicationAuditEntry.class);
|
||||||
|
|
||||||
|
public ApplicationAuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Evaluating if application is audited ..."+application);
|
||||||
|
}
|
||||||
|
return getEffectiveAuditMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode onError(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordOptions getAuditRecordOptions(String application)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
220
source/java/org/alfresco/repo/audit/model/AuditEntry.java
Normal file
220
source/java/org/alfresco/repo/audit/model/AuditEntry.java
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditConfiguration;
|
||||||
|
import org.alfresco.repo.audit.AuditMode;
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.repo.audit.RecordOptions;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentException;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
public class AuditEntry extends AbstractAuditEntry implements InitializingBean, AuditModel
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(AuditEntry.class);
|
||||||
|
|
||||||
|
private Map<String, ServiceAuditEntry> services = new HashMap<String, ServiceAuditEntry>();
|
||||||
|
|
||||||
|
private Map<String, ApplicationAuditEntry> applications = new HashMap<String, ApplicationAuditEntry>();
|
||||||
|
|
||||||
|
private AuditConfiguration auditConfiguration;
|
||||||
|
|
||||||
|
private NamespacePrefixResolver namespacePrefixResolver;
|
||||||
|
|
||||||
|
public AuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditConfiguration getAuditConfiguration()
|
||||||
|
{
|
||||||
|
return auditConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||||
|
{
|
||||||
|
this.auditConfiguration = auditConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void afterPropertiesSet() throws Exception
|
||||||
|
{
|
||||||
|
Document document = createDocument();
|
||||||
|
Element root = document.getRootElement();
|
||||||
|
// Check it is the correct thing
|
||||||
|
configure(null, root, namespacePrefixResolver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
if (!element.getNamespaceURI().equals(AuditModel.NAME_SPACE))
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Audit model has incorrect name space");
|
||||||
|
}
|
||||||
|
if (!element.getName().equals(AuditModel.EL_AUDIT))
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Audit model has incorrect root node");
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Audit configuration");
|
||||||
|
}
|
||||||
|
super.configure(parent, element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
// Add services
|
||||||
|
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Adding services ...");
|
||||||
|
}
|
||||||
|
for (Iterator nsit = element.elementIterator(AuditModel.EL_SERVICE); nsit.hasNext(); /**/)
|
||||||
|
{
|
||||||
|
Element serviceElement = (Element) nsit.next();
|
||||||
|
ServiceAuditEntry service = new ServiceAuditEntry();
|
||||||
|
service.configure(this, serviceElement, namespacePrefixResolver);
|
||||||
|
services.put(service.getName(), service);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Applications
|
||||||
|
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Adding applications ...");
|
||||||
|
}
|
||||||
|
for (Iterator nsit = element.elementIterator(AuditModel.EL_APPLICATION); nsit.hasNext(); /**/)
|
||||||
|
{
|
||||||
|
Element applicationElement = (Element) nsit.next();
|
||||||
|
ApplicationAuditEntry application = new ApplicationAuditEntry();
|
||||||
|
application.configure(this, applicationElement, namespacePrefixResolver);
|
||||||
|
applications.put(application.getName(), application);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi);
|
||||||
|
ServiceAuditEntry service = services.get(serviceName);
|
||||||
|
if(service != null)
|
||||||
|
{
|
||||||
|
return service.beforeExecution(auditMode, mi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("No specific audit entry for service "+serviceName);
|
||||||
|
}
|
||||||
|
return getEffectiveAuditMode();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordOptions getAuditRecordOptions(MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document createDocument()
|
||||||
|
{
|
||||||
|
InputStream is = auditConfiguration.getInputStream();
|
||||||
|
if (is == null)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Audit configuration could not be opened");
|
||||||
|
}
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Document document = reader.read(is);
|
||||||
|
is.close();
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
catch (DocumentException e)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Failed to create audit model document ", e);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Failed to close audit model document ", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
ApplicationAuditEntry aae = applications.get(application);
|
||||||
|
if(aae != null)
|
||||||
|
{
|
||||||
|
return aae.beforeExecution(auditMode, application, description, key, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("No specific audit entry for application "+application);
|
||||||
|
}
|
||||||
|
return getEffectiveAuditMode();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode onError(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordOptions getAuditRecordOptions(String application)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exceptions from the audit model package.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class AuditModelException extends AlfrescoRuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment for <code>serialVersionUID</code>
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -2527034441058184109L;
|
||||||
|
|
||||||
|
public AuditModelException(String msgId)
|
||||||
|
{
|
||||||
|
super(msgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditModelException(String msgId, Object[] msgParams)
|
||||||
|
{
|
||||||
|
super(msgId, msgParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditModelException(String msgId, Throwable cause)
|
||||||
|
{
|
||||||
|
super(msgId, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditModelException(String msgId, Object[] msgParams, Throwable cause)
|
||||||
|
{
|
||||||
|
super(msgId, msgParams, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
source/java/org/alfresco/repo/audit/model/FilterSet.java
Normal file
72
source/java/org/alfresco/repo/audit/model/FilterSet.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Attribute;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This groups a set of filters together using AND or OR. They are evaluated in definition order with short cut evaluation if possible. The default beahviour is to or Filters
|
||||||
|
* together.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class FilterSet extends AbstractFilter implements XMLModelElement
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(FilterSet.class);
|
||||||
|
|
||||||
|
private List<AbstractFilter> filters = new ArrayList<AbstractFilter>();
|
||||||
|
|
||||||
|
private FilterSetMode mode = FilterSetMode.OR;
|
||||||
|
|
||||||
|
public FilterSet()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
super.configure(element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
// Mode
|
||||||
|
Attribute modeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||||
|
if (modeAttribute != null)
|
||||||
|
{
|
||||||
|
mode = FilterSetMode.getFilterSetMode(modeAttribute.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
|
||||||
|
for (Iterator nsit = element.elementIterator(AuditModel.EL_FILTER); nsit.hasNext(); /**/)
|
||||||
|
{
|
||||||
|
Element filterElement = (Element) nsit.next();
|
||||||
|
AbstractFilter filter = AbstractFilter.createFilter(filterElement, namespacePrefixResolver);
|
||||||
|
filters.add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
source/java/org/alfresco/repo/audit/model/FilterSetMode.java
Normal file
43
source/java/org/alfresco/repo/audit/model/FilterSetMode.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum to define if elements of a filter set are combined using AND or OR.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public enum FilterSetMode
|
||||||
|
{
|
||||||
|
AND, OR;
|
||||||
|
|
||||||
|
public static FilterSetMode getFilterSetMode(String value)
|
||||||
|
{
|
||||||
|
if(value.equalsIgnoreCase("or"))
|
||||||
|
{
|
||||||
|
return FilterSetMode.OR;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("or"))
|
||||||
|
{
|
||||||
|
return FilterSetMode.AND;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Invalid FilterSetMode: "+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
70
source/java/org/alfresco/repo/audit/model/KeyFilter.java
Normal file
70
source/java/org/alfresco/repo/audit/model/KeyFilter.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Attribute;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public class KeyFilter extends AbstractFilter
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(KeyFilter.class);
|
||||||
|
|
||||||
|
private String expression;
|
||||||
|
|
||||||
|
private KeyFilterMode keyFilterMode;
|
||||||
|
|
||||||
|
public KeyFilter()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
super.configure(element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
// Filter mode
|
||||||
|
Attribute keyFilterTypeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||||
|
if(keyFilterTypeAttribute != null)
|
||||||
|
{
|
||||||
|
keyFilterMode = KeyFilterMode.getKeyFilterMode(keyFilterTypeAttribute.getStringValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keyFilterMode = KeyFilterMode.ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expression
|
||||||
|
|
||||||
|
Element expressionElement = element.element(AuditModel.EL_EXPRESSION);
|
||||||
|
if(expressionElement == null)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("An expression is mandatory for a key filter");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expression = expressionElement.getText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
86
source/java/org/alfresco/repo/audit/model/KeyFilterMode.java
Normal file
86
source/java/org/alfresco/repo/audit/model/KeyFilterMode.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum defines the type of restriction to apply to filter based on the key node ref.
|
||||||
|
*
|
||||||
|
* This restriction can be based upon:
|
||||||
|
*
|
||||||
|
* <ol>
|
||||||
|
* <li> The path to the node
|
||||||
|
* <li> The type of the node
|
||||||
|
* <li> The presence of an aspect
|
||||||
|
* <li> The NodeRef of the node
|
||||||
|
* <li> An XPATH expression evaluated in the context of the node with the return tested for the node.
|
||||||
|
* e.g. ".[@cm:content = 'woof']"
|
||||||
|
* <li> A simple value for equality tests given a non node argument
|
||||||
|
* <li> The protocol of the store containing the node
|
||||||
|
* <li> The identifier of the store containing the node
|
||||||
|
* <li> Or no restriction
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public enum KeyFilterMode
|
||||||
|
{
|
||||||
|
PATH, TYPE, ASPECT, NODE_REF, ALL, XPATH, VALUE, STORE_PROTOCOL, STORE_IDENTIFIER;
|
||||||
|
|
||||||
|
public static KeyFilterMode getKeyFilterMode(String value)
|
||||||
|
{
|
||||||
|
if(value.equalsIgnoreCase("path"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.PATH;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("type"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.TYPE;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("aspect"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.ASPECT;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("node_ref"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.NODE_REF;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("all"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.ALL;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("xpath"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.XPATH;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("value"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.VALUE;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("store_protocol"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.STORE_PROTOCOL;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("store_identifier"))
|
||||||
|
{
|
||||||
|
return KeyFilterMode.STORE_IDENTIFIER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Unknown KeyFilterMode: "+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditMode;
|
||||||
|
import org.alfresco.repo.audit.MethodAuditModel;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
public class MethodAuditEntry extends AbstractNamedAuditEntry implements MethodAuditModel
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(MethodAuditEntry.class);
|
||||||
|
|
||||||
|
public MethodAuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Evaluating if method is audited ..."+((ServiceAuditEntry)getParent()).getName()+"."+getName());
|
||||||
|
}
|
||||||
|
return getEffectiveAuditMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordOptionsImpl getAuditRecordOptions(MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public class ParameterFilter extends KeyFilter implements XMLModelElement
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(ParameterFilter.class);
|
||||||
|
|
||||||
|
private QName parameterName;
|
||||||
|
|
||||||
|
public ParameterFilter()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
super.configure(element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
Element parameterNameElement = element.element(AuditModel.EL_PARAMETER_NAME);
|
||||||
|
if(parameterNameElement == null)
|
||||||
|
{
|
||||||
|
throw new AuditModelException("A parameter is mandatory for a parameter filter");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String stringQName = parameterNameElement.getStringValue();
|
||||||
|
if (stringQName.charAt(1) == '{')
|
||||||
|
{
|
||||||
|
parameterName = QName.createQName(stringQName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parameterName = QName.createQName(stringQName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
189
source/java/org/alfresco/repo/audit/model/RecordOptionsImpl.java
Normal file
189
source/java/org/alfresco/repo/audit/model/RecordOptionsImpl.java
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.repo.audit.RecordOptions;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public class RecordOptionsImpl implements XMLModelElement, RecordOptions
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(RecordOptionsImpl.class);
|
||||||
|
|
||||||
|
private TrueFalseUnset recordPath = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordFilters = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordSerializedReturnValue = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordSerializedExceptions = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordSerializedMethodArguments = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordSerializedKeyPropertiesBeforeEvaluation = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
private TrueFalseUnset recordSerializedKeyPropertiesAfterEvaluation = TrueFalseUnset.UNSET;
|
||||||
|
|
||||||
|
public RecordOptionsImpl()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RecordOptionsImpl mergeRecordOptions(RecordOptions primary, RecordOptions secondary)
|
||||||
|
{
|
||||||
|
RecordOptionsImpl answer = new RecordOptionsImpl();
|
||||||
|
setOptions(answer, primary, true);
|
||||||
|
setOptions(answer, secondary, false);
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setOptions(RecordOptionsImpl on, RecordOptions from, boolean force)
|
||||||
|
{
|
||||||
|
if(force || on.recordFilters.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordFilters = from.getRecordFilters();
|
||||||
|
}
|
||||||
|
if(force || on.recordPath.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordPath = from.getRecordPath();
|
||||||
|
}
|
||||||
|
if(force || on.recordSerializedExceptions.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordSerializedExceptions = from.getRecordSerializedExceptions();
|
||||||
|
}
|
||||||
|
if(force || on.recordSerializedKeyPropertiesAfterEvaluation.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordSerializedKeyPropertiesAfterEvaluation = from.getRecordSerializedKeyPropertiesAfterEvaluation();
|
||||||
|
}
|
||||||
|
if(force || on.recordSerializedKeyPropertiesBeforeEvaluation.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordSerializedKeyPropertiesBeforeEvaluation = from.getRecordSerializedKeyPropertiesBeforeEvaluation();
|
||||||
|
}
|
||||||
|
if(force || on.recordSerializedMethodArguments.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordSerializedMethodArguments = from.getRecordSerializedMethodArguments();
|
||||||
|
}
|
||||||
|
if(force || on.recordSerializedReturnValue.equals( TrueFalseUnset.UNSET))
|
||||||
|
{
|
||||||
|
on.recordSerializedReturnValue = from.getRecordSerializedReturnValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordFilters()
|
||||||
|
{
|
||||||
|
return recordFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordPath()
|
||||||
|
{
|
||||||
|
return recordPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedExceptions()
|
||||||
|
{
|
||||||
|
return recordSerializedExceptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedKeyPropertiesAfterEvaluation()
|
||||||
|
{
|
||||||
|
return recordSerializedKeyPropertiesAfterEvaluation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedKeyPropertiesBeforeEvaluation()
|
||||||
|
{
|
||||||
|
return recordSerializedKeyPropertiesBeforeEvaluation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedMethodArguments()
|
||||||
|
{
|
||||||
|
return recordSerializedMethodArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueFalseUnset getRecordSerializedReturnValue()
|
||||||
|
{
|
||||||
|
return recordSerializedReturnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configure(Element recordOptionElement, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
Element recordFiltersElement = recordOptionElement.element(AuditModel.EL_RECORD_FILTERS);
|
||||||
|
if (recordFiltersElement != null)
|
||||||
|
{
|
||||||
|
recordFilters = TrueFalseUnset.getTrueFalseUnset(recordFiltersElement.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordPathElement = recordOptionElement.element(AuditModel.EL_RECORD_PATH);
|
||||||
|
if (recordPathElement != null)
|
||||||
|
{
|
||||||
|
recordPath = TrueFalseUnset.getTrueFalseUnset(recordPathElement.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordSerAgrsElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_ARGS);
|
||||||
|
if (recordSerAgrsElement != null)
|
||||||
|
{
|
||||||
|
recordSerializedMethodArguments = TrueFalseUnset.getTrueFalseUnset(recordSerAgrsElement.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordSerExElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_EX);
|
||||||
|
if (recordSerExElement != null)
|
||||||
|
{
|
||||||
|
recordSerializedExceptions = TrueFalseUnset.getTrueFalseUnset(recordSerExElement.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordSerPropAfterElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_PROP_AFTER);
|
||||||
|
if (recordSerPropAfterElement != null)
|
||||||
|
{
|
||||||
|
recordSerializedKeyPropertiesAfterEvaluation = TrueFalseUnset.getTrueFalseUnset(recordSerPropAfterElement
|
||||||
|
.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordSerPropBeforeElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_PROP_BEFORE);
|
||||||
|
if (recordSerPropBeforeElement != null)
|
||||||
|
{
|
||||||
|
recordSerializedKeyPropertiesBeforeEvaluation = TrueFalseUnset.getTrueFalseUnset(recordSerPropBeforeElement
|
||||||
|
.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element recordSerRetElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_RETURN_VAL);
|
||||||
|
if (recordSerRetElement != null)
|
||||||
|
{
|
||||||
|
recordSerializedReturnValue = TrueFalseUnset.getTrueFalseUnset(recordSerRetElement.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("Record Options(");
|
||||||
|
builder.append("Filters=").append(getRecordFilters());
|
||||||
|
builder.append(",Path=").append(getRecordPath());
|
||||||
|
builder.append(",Exception=").append(getRecordSerializedExceptions());
|
||||||
|
builder.append(",PropertiesBefore=").append(getRecordSerializedKeyPropertiesAfterEvaluation());
|
||||||
|
builder.append(",PropertiesAfter=").append(getRecordSerializedKeyPropertiesBeforeEvaluation());
|
||||||
|
builder.append(",Args=").append(getRecordSerializedMethodArguments());
|
||||||
|
builder.append(",Return=").append(getRecordSerializedReturnValue());
|
||||||
|
builder.append(")");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
100
source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java
Normal file
100
source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.audit.AuditMode;
|
||||||
|
import org.alfresco.repo.audit.AuditModel;
|
||||||
|
import org.alfresco.repo.audit.MethodAuditModel;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public class ServiceAuditEntry extends AbstractNamedAuditEntry implements MethodAuditModel
|
||||||
|
{
|
||||||
|
private static Log s_logger = LogFactory.getLog(ServiceAuditEntry.class);
|
||||||
|
|
||||||
|
private Map<String, MethodAuditEntry> methods = new HashMap<String, MethodAuditEntry>();
|
||||||
|
|
||||||
|
public ServiceAuditEntry()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
super.configure(parent, element, namespacePrefixResolver);
|
||||||
|
|
||||||
|
// Add Methods
|
||||||
|
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Adding methods to service "+getName());
|
||||||
|
}
|
||||||
|
for (Iterator nsit = element.elementIterator(AuditModel.EL_METHOD); nsit.hasNext(); /**/)
|
||||||
|
{
|
||||||
|
Element methodElement = (Element) nsit.next();
|
||||||
|
MethodAuditEntry method = new MethodAuditEntry();
|
||||||
|
method.configure(this, methodElement, namespacePrefixResolver);
|
||||||
|
methods.put(method.getName(), method);
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("...added methods for service "+getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
String methodName = mi.getMethod().getName();
|
||||||
|
MethodAuditEntry method = methods.get(methodName);
|
||||||
|
if (method != null)
|
||||||
|
{
|
||||||
|
return method.beforeExecution(auditMode, mi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Evaluating if service is audited (no specific setting) for "+getName()+"."+methodName);
|
||||||
|
}
|
||||||
|
return getEffectiveAuditMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordOptionsImpl getAuditRecordOptions(MethodInvocation mi)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum for the values
|
||||||
|
* <ol>
|
||||||
|
* <li> TRUE
|
||||||
|
* <li> FALSE
|
||||||
|
* <li> UNSET
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public enum TrueFalseUnset
|
||||||
|
{
|
||||||
|
TRUE, FALSE, UNSET;
|
||||||
|
|
||||||
|
public static TrueFalseUnset getTrueFalseUnset(String value)
|
||||||
|
{
|
||||||
|
if(value.equalsIgnoreCase("true"))
|
||||||
|
{
|
||||||
|
return TrueFalseUnset.TRUE;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("false"))
|
||||||
|
{
|
||||||
|
return TrueFalseUnset.FALSE;
|
||||||
|
}
|
||||||
|
else if(value.equalsIgnoreCase("unset"))
|
||||||
|
{
|
||||||
|
return TrueFalseUnset.UNSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuditModelException("Invalid value for TrueFalseUnset: "+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.audit.model;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
|
public interface XMLModelElement
|
||||||
|
{
|
||||||
|
void configure(Element element, NamespacePrefixResolver namespacePrefixResolver );
|
||||||
|
}
|
@ -21,6 +21,7 @@ package org.alfresco.service;
|
|||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface AnnotationTestInterface
|
public interface AnnotationTestInterface
|
||||||
{
|
{
|
||||||
@Auditable()
|
@Auditable()
|
||||||
|
36
source/java/org/alfresco/service/PublicService.java
Normal file
36
source/java/org/alfresco/service/PublicService.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.service;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifically indicate that an interface defines a public service.
|
||||||
|
*
|
||||||
|
* This is a marker annotation.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface PublicService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -52,6 +52,7 @@ import org.alfresco.service.transaction.TransactionService;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ServiceRegistry
|
public interface ServiceRegistry
|
||||||
{
|
{
|
||||||
// Service Bean Names
|
// Service Bean Names
|
||||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +29,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ActionService
|
public interface ActionService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,12 +18,15 @@ package org.alfresco.service.cmr.admin;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General administration tasks and system information.
|
* General administration tasks and system information.
|
||||||
*
|
*
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface AdminService
|
public interface AdminService
|
||||||
{
|
{
|
||||||
// public List<PatchInfo> getPatches();
|
// public List<PatchInfo> getPatches();
|
||||||
|
85
source/java/org/alfresco/service/cmr/audit/AuditService.java
Normal file
85
source/java/org/alfresco/service/cmr/audit/AuditService.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.service.cmr.audit;
|
||||||
|
|
||||||
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The public API by which applications can create audit entries.
|
||||||
|
* This does not affect auditing using method interceptors.
|
||||||
|
* The information recorded can not be confused between the two.
|
||||||
|
*
|
||||||
|
* This API could be used by an audit action.
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
@PublicService
|
||||||
|
public interface AuditService
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an application audit entry.
|
||||||
|
*
|
||||||
|
* @param source -
|
||||||
|
* a string that represents the application
|
||||||
|
* @param description -
|
||||||
|
* the audit entry
|
||||||
|
*/
|
||||||
|
@NotAuditable
|
||||||
|
public void audit(String source, String description);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param source -
|
||||||
|
* a string that represents the application
|
||||||
|
* @param description -
|
||||||
|
* the audit entry
|
||||||
|
* @param key -
|
||||||
|
* a node ref to use as the key for filtering etc
|
||||||
|
*/
|
||||||
|
@NotAuditable
|
||||||
|
public void audit(String source, String description, NodeRef key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param source -
|
||||||
|
* a string that represents the application
|
||||||
|
* @param description -
|
||||||
|
* the audit entry
|
||||||
|
* @param args -
|
||||||
|
* an arbitrary list of parameters
|
||||||
|
*/
|
||||||
|
@NotAuditable
|
||||||
|
public void audit(String source, String description, Object... args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param source -
|
||||||
|
* a string that represents the application
|
||||||
|
* @param description -
|
||||||
|
* the audit entry *
|
||||||
|
* @param key -
|
||||||
|
* a node ref to use as the key for filtering etc
|
||||||
|
* @param args -
|
||||||
|
* an arbitrary list of parameters
|
||||||
|
*/
|
||||||
|
@NotAuditable
|
||||||
|
public void audit(String source, String description, NodeRef key, Object... args);
|
||||||
|
|
||||||
|
}
|
@ -20,6 +20,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface CheckOutCheckInService
|
public interface CheckOutCheckInService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.dictionary;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.alfresco.service.NotAuditable;
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface DictionaryService
|
public interface DictionaryService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface LockService
|
public interface LockService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@ -32,6 +33,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface FileFolderService
|
public interface FileFolderService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package org.alfresco.service.cmr.repository;
|
|||||||
|
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ContentService
|
public interface ContentService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.repository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface CopyService
|
public interface CopyService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.service.NotAuditable;
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.NotAuditable;
|
|||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface MimetypeService
|
public interface MimetypeService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@ -32,6 +33,7 @@ import org.alfresco.service.namespace.QNamePattern;
|
|||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface NodeService
|
public interface NodeService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.repository;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +37,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ScriptService
|
public interface ScriptService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.repository;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template Service.
|
* Template Service.
|
||||||
@ -34,6 +35,7 @@ import org.alfresco.service.Auditable;
|
|||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface TemplateService
|
public interface TemplateService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.rule;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface RuleService
|
public interface RuleService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.search;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@ -37,6 +38,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface CategoryService
|
public interface CategoryService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
@ -38,6 +39,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* @author Andy hind
|
* @author Andy hind
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface SearchService
|
public interface SearchService
|
||||||
{
|
{
|
||||||
public static final String LANGUAGE_LUCENE = "lucene";
|
public static final String LANGUAGE_LUCENE = "lucene";
|
||||||
|
@ -20,6 +20,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication service defines the API for managing authentication information
|
* The authentication service defines the API for managing authentication information
|
||||||
@ -28,6 +29,7 @@ import org.alfresco.service.Auditable;
|
|||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface AuthenticationService
|
public interface AuthenticationService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.security;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service that encapsulates authorities granted to users.
|
* The service that encapsulates authorities granted to users.
|
||||||
@ -34,6 +35,7 @@ import org.alfresco.service.Auditable;
|
|||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface AuthorityService
|
public interface AuthorityService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.alfresco.service.cmr.security;
|
package org.alfresco.service.cmr.security;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +25,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface OwnableService
|
public interface OwnableService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.security;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface PermissionService
|
public interface PermissionService
|
||||||
{
|
{
|
||||||
public static final String ROLE_PREFIX = "ROLE_";
|
public static final String ROLE_PREFIX = "ROLE_";
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface PersonService
|
public interface PersonService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Collection;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.AspectMissingException;
|
import org.alfresco.service.cmr.repository.AspectMissingException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@ -31,6 +32,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface VersionService
|
public interface VersionService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.view;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,6 +27,7 @@ import org.alfresco.service.Auditable;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ExporterService
|
public interface ExporterService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.view;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,6 +28,7 @@ import org.alfresco.service.Auditable;
|
|||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface ImporterService
|
public interface ImporterService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.cmr.view;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
*
|
*
|
||||||
* @author davidc
|
* @author davidc
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface RepositoryExporterService
|
public interface RepositoryExporterService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author davidc
|
* @author davidc
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface WorkflowService
|
public interface WorkflowService
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -46,6 +49,7 @@ public interface WorkflowService
|
|||||||
* @param mimetype the mimetype of the workflow definition
|
* @param mimetype the mimetype of the workflow definition
|
||||||
* @return workflow deployment descriptor
|
* @return workflow deployment descriptor
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"engineId", "workflowDefinition", "mimetype"})
|
||||||
public WorkflowDeployment deployDefinition(String engineId, InputStream workflowDefinition, String mimetype);
|
public WorkflowDeployment deployDefinition(String engineId, InputStream workflowDefinition, String mimetype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,6 +61,7 @@ public interface WorkflowService
|
|||||||
* @param workflowDefinition the content object containing the definition
|
* @param workflowDefinition the content object containing the definition
|
||||||
* @return workflow deployment descriptor
|
* @return workflow deployment descriptor
|
||||||
*/
|
*/
|
||||||
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"workflowDefinition"})
|
||||||
public WorkflowDeployment deployDefinition(NodeRef workflowDefinition);
|
public WorkflowDeployment deployDefinition(NodeRef workflowDefinition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,6 +75,7 @@ public interface WorkflowService
|
|||||||
* @param mimetype the mimetype of the definition
|
* @param mimetype the mimetype of the definition
|
||||||
* @return true => already deployed
|
* @return true => already deployed
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"engineId", "workflowDefinition", "mimetype"})
|
||||||
public boolean isDefinitionDeployed(String engineId, InputStream workflowDefinition, String mimetype);
|
public boolean isDefinitionDeployed(String engineId, InputStream workflowDefinition, String mimetype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +85,7 @@ public interface WorkflowService
|
|||||||
*
|
*
|
||||||
* @param workflowDefinitionId the id of the definition to undeploy
|
* @param workflowDefinitionId the id of the definition to undeploy
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowDefinitionId"})
|
||||||
public void undeployDefinition(String workflowDefinitionId);
|
public void undeployDefinition(String workflowDefinitionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,6 +93,7 @@ public interface WorkflowService
|
|||||||
*
|
*
|
||||||
* @return the deployed workflow definitions
|
* @return the deployed workflow definitions
|
||||||
*/
|
*/
|
||||||
|
@Auditable
|
||||||
public List<WorkflowDefinition> getDefinitions();
|
public List<WorkflowDefinition> getDefinitions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,6 +102,7 @@ public interface WorkflowService
|
|||||||
* @param workflowDefinitionId the workflow definition id
|
* @param workflowDefinitionId the workflow definition id
|
||||||
* @return the deployed workflow definition
|
* @return the deployed workflow definition
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowDefinitionId"})
|
||||||
public WorkflowDefinition getDefinitionById(String workflowDefinitionId);
|
public WorkflowDefinition getDefinitionById(String workflowDefinitionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,6 +126,7 @@ public interface WorkflowService
|
|||||||
* @param parameters the initial set of parameters used to populate the "Start Task" properties
|
* @param parameters the initial set of parameters used to populate the "Start Task" properties
|
||||||
* @return the initial workflow path
|
* @return the initial workflow path
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowDefinitionId", "parameters"})
|
||||||
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters);
|
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,6 +136,7 @@ public interface WorkflowService
|
|||||||
* @param templateDefinition the node representing the Start Task properties
|
* @param templateDefinition the node representing the Start Task properties
|
||||||
* @return the initial workflow path
|
* @return the initial workflow path
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"templateDefinition"})
|
||||||
public WorkflowPath startWorkflowFromTemplate(NodeRef templateDefinition);
|
public WorkflowPath startWorkflowFromTemplate(NodeRef templateDefinition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,6 +145,7 @@ public interface WorkflowService
|
|||||||
* @param workflowDefinitionId the workflow definition id
|
* @param workflowDefinitionId the workflow definition id
|
||||||
* @return the list of "in-fligth" workflow instances
|
* @return the list of "in-fligth" workflow instances
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowDefinitionId"})
|
||||||
public List<WorkflowInstance> getActiveWorkflows(String workflowDefinitionId);
|
public List<WorkflowInstance> getActiveWorkflows(String workflowDefinitionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,6 +154,7 @@ public interface WorkflowService
|
|||||||
* @param workflowId workflow instance id
|
* @param workflowId workflow instance id
|
||||||
* @return the list of workflow paths
|
* @return the list of workflow paths
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowId"})
|
||||||
public List<WorkflowPath> getWorkflowPaths(String workflowId);
|
public List<WorkflowPath> getWorkflowPaths(String workflowId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,6 +163,7 @@ public interface WorkflowService
|
|||||||
* @param workflowId the workflow instance to cancel
|
* @param workflowId the workflow instance to cancel
|
||||||
* @return an updated representation of the workflow instance
|
* @return an updated representation of the workflow instance
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"workflowId"})
|
||||||
public WorkflowInstance cancelWorkflow(String workflowId);
|
public WorkflowInstance cancelWorkflow(String workflowId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,6 +173,7 @@ public interface WorkflowService
|
|||||||
* @param transition the transition to follow (or null, for the default transition)
|
* @param transition the transition to follow (or null, for the default transition)
|
||||||
* @return the updated workflow path
|
* @return the updated workflow path
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"pathId", "transitionId"})
|
||||||
public WorkflowPath signal(String pathId, String transitionId);
|
public WorkflowPath signal(String pathId, String transitionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,6 +182,7 @@ public interface WorkflowService
|
|||||||
* @param pathId the path id
|
* @param pathId the path id
|
||||||
* @return the list of associated tasks
|
* @return the list of associated tasks
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"pathId"})
|
||||||
public List<WorkflowTask> getTasksForWorkflowPath(String pathId);
|
public List<WorkflowTask> getTasksForWorkflowPath(String pathId);
|
||||||
|
|
||||||
|
|
||||||
@ -180,6 +196,7 @@ public interface WorkflowService
|
|||||||
* @param taskId the task id
|
* @param taskId the task id
|
||||||
* @return the task
|
* @return the task
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"taskId"})
|
||||||
public WorkflowTask getTaskById(String taskId);
|
public WorkflowTask getTaskById(String taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,6 +206,7 @@ public interface WorkflowService
|
|||||||
* @param state filter by specified workflow task state
|
* @param state filter by specified workflow task state
|
||||||
* @return the list of assigned tasks
|
* @return the list of assigned tasks
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"authority", "state"})
|
||||||
public List<WorkflowTask> getAssignedTasks(String authority, WorkflowTaskState state);
|
public List<WorkflowTask> getAssignedTasks(String authority, WorkflowTaskState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,6 +215,7 @@ public interface WorkflowService
|
|||||||
* @param authority the authority
|
* @param authority the authority
|
||||||
* @return the list of pooled tasks
|
* @return the list of pooled tasks
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"authority"})
|
||||||
public List<WorkflowTask> getPooledTasks(String authority);
|
public List<WorkflowTask> getPooledTasks(String authority);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,6 +227,7 @@ public interface WorkflowService
|
|||||||
* @param remove the map of items to dis-associate with the task (or null, if none to remove)
|
* @param remove the map of items to dis-associate with the task (or null, if none to remove)
|
||||||
* @return the update task
|
* @return the update task
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"taskId", "properties", "add", "remove"})
|
||||||
public WorkflowTask updateTask(String taskId, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add, Map<QName, List<NodeRef>> remove);
|
public WorkflowTask updateTask(String taskId, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add, Map<QName, List<NodeRef>> remove);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,6 +237,7 @@ public interface WorkflowService
|
|||||||
* @param transition the task transition to take on completion (or null, for the default transition)
|
* @param transition the task transition to take on completion (or null, for the default transition)
|
||||||
* @return the updated task
|
* @return the updated task
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"taskId", "transitionId"})
|
||||||
public WorkflowTask endTask(String taskId, String transitionId);
|
public WorkflowTask endTask(String taskId, String transitionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,6 +248,7 @@ public interface WorkflowService
|
|||||||
* @param container (optional) a pre-created container (e.g. folder, versioned folder or layered folder)
|
* @param container (optional) a pre-created container (e.g. folder, versioned folder or layered folder)
|
||||||
* @return the workflow package
|
* @return the workflow package
|
||||||
*/
|
*/
|
||||||
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"container"})
|
||||||
public NodeRef createPackage(NodeRef container);
|
public NodeRef createPackage(NodeRef container);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.alfresco.service.license.LicenseDescriptor;
|
|||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
// This is not a public service in the normal sense
|
||||||
public interface DescriptorService
|
public interface DescriptorService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.alfresco.service.license;
|
package org.alfresco.service.license;
|
||||||
|
|
||||||
import org.alfresco.service.NotAuditable;
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +25,7 @@ import org.alfresco.service.NotAuditable;
|
|||||||
*
|
*
|
||||||
* @author davidc
|
* @author davidc
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface LicenseService
|
public interface LicenseService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.namespace;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>NamespacePrefixResolver</code> provides a mapping between
|
* The <code>NamespacePrefixResolver</code> provides a mapping between
|
||||||
@ -26,6 +27,7 @@ import org.alfresco.service.Auditable;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface NamespacePrefixResolver
|
public interface NamespacePrefixResolver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.alfresco.service.namespace;
|
package org.alfresco.service.namespace;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import org.alfresco.service.Auditable;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface NamespaceService extends NamespacePrefixResolver
|
public interface NamespaceService extends NamespacePrefixResolver
|
||||||
{
|
{
|
||||||
/** Default Namespace URI */
|
/** Default Namespace URI */
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.service.transaction;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.service.NotAuditable;
|
import org.alfresco.service.NotAuditable;
|
||||||
|
import org.alfresco.service.PublicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract for retrieving access to a user transaction.
|
* Contract for retrieving access to a user transaction.
|
||||||
@ -29,6 +30,7 @@ import org.alfresco.service.NotAuditable;
|
|||||||
*
|
*
|
||||||
* @author David Caruana
|
* @author David Caruana
|
||||||
*/
|
*/
|
||||||
|
@PublicService
|
||||||
public interface TransactionService
|
public interface TransactionService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -183,6 +183,7 @@ public abstract class Tool
|
|||||||
*/
|
*/
|
||||||
public final void start(String[] args)
|
public final void start(String[] args)
|
||||||
{
|
{
|
||||||
|
long startTime = System.nanoTime();
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -202,7 +203,11 @@ public abstract class Tool
|
|||||||
logInfo(getToolName());
|
logInfo(getToolName());
|
||||||
initialiseRepository();
|
initialiseRepository();
|
||||||
login();
|
login();
|
||||||
|
long loginTime = System.nanoTime();
|
||||||
|
logInfo("Time to login "+((loginTime - startTime)/1000000000f)+" seconds");
|
||||||
status = execute();
|
status = execute();
|
||||||
|
long executeTime = System.nanoTime();
|
||||||
|
logInfo("Time to execute "+((executeTime - loginTime)/1000000000f)+" seconds");
|
||||||
logInfo(getToolName() + " successfully completed.");
|
logInfo(getToolName() + " successfully completed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user