Audit session and bootstrap support

- Sessions are created using an application name (shared prop) and a persisted model ID
 - Added a bootstrap bean for audit that unmarshalls the models
 - Added hook points for repo-loading models, but won't implement yet


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15863 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-08-21 17:50:36 +00:00
parent 99395b7ed2
commit 00dfb8ee66
19 changed files with 877 additions and 280 deletions

View File

@@ -24,40 +24,32 @@
*/
package org.alfresco.repo.audit.model;
import java.io.File;
import java.net.URL;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.audit.model._3.Audit;
import org.alfresco.util.PropertyCheck;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.ResourceUtils;
/**
* A component used to load Audit configuration XML documents.
* A component used to load Audit model XML documents.
*
* @author Derek Hulley
* @since 3.2
*/
public class AuditModelReader implements InitializingBean
{
private URL configUrl;
private URL auditModelUrl;
private AuditModelRegistry auditModelRegistry;
/**
* Set the XML location using <b>file:</b>, <b>classpath:</b> or any of the
* {@link ResourceUtils Spring-supported} formats.
*
* @param configUrl the location of the XML file
* @param auditModelUrl the location of the XML file
*/
public void setConfigUrl(URL configUrl)
public void setAuditModelUrl(URL auditModelUrl)
{
this.configUrl = configUrl;
this.auditModelUrl = auditModelUrl;
}
/**
@@ -74,32 +66,9 @@ public class AuditModelReader implements InitializingBean
*/
public void afterPropertiesSet() throws Exception
{
PropertyCheck.mandatory(this, "configUrl", configUrl);
PropertyCheck.mandatory(this, "configUrl", auditModelUrl);
PropertyCheck.mandatory(this, "auditModelRegistry", auditModelRegistry);
File file = new File(configUrl.getFile());
if (!file.exists())
{
throw new AlfrescoRuntimeException("The Audit configuration XML was not found: " + configUrl);
}
// Load it
JAXBContext jaxbCtx = JAXBContext.newInstance("org.alfresco.repo.audit.model._3");
Unmarshaller jaxbUnmarshaller = jaxbCtx.createUnmarshaller();
try
{
@SuppressWarnings("unchecked")
JAXBElement<Audit> auditElement = (JAXBElement<Audit>) jaxbUnmarshaller.unmarshal(configUrl);
Audit audit = auditElement.getValue();
// Now register it
auditModelRegistry.registerModel(configUrl, audit);
}
catch (UnmarshalException e)
{
throw new AlfrescoRuntimeException(
"Failed to read Audit configuration XML: \n" +
" URL: " + configUrl + "\n" +
" Error: " + e.getMessage());
}
auditModelRegistry.registerModel(auditModelUrl);
}
}