Added APi to get the audit trail.

Fixes for persistence and simple test.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3668 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2006-09-04 09:59:22 +00:00
parent 0fa1d85631
commit 7b3ce70218
8 changed files with 133 additions and 42 deletions

View File

@@ -16,8 +16,12 @@
*/
package org.alfresco.repo.audit;
import java.util.List;
import javax.transaction.UserTransaction;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.audit.AuditInfo;
import org.alfresco.service.cmr.audit.AuditService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -66,23 +70,41 @@ public class AuditServiceImpl implements AuditService
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"});
AuthenticationUtil.setSystemUserAsCurrentUser();
try
{
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" });
}
finally
{
AuthenticationUtil.clearCurrentSecurityContext();
}
tx.commit();
}
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
{
// TODO Auto-generated method stub
return null;
}
}