Java Code Examples for org.alfresco.service.ServiceRegistry#getAuditService()

The following examples show how to use org.alfresco.service.ServiceRegistry#getAuditService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuditMethodInterceptorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception
{
    auditModelRegistry = (AuditModelRegistryImpl) ctx.getBean("auditModel.modelRegistry");
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    auditComponent = (AuditComponent) ctx.getBean("auditComponent");
    auditService = serviceRegistry.getAuditService();
    transactionService = serviceRegistry.getTransactionService();
    transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService");
    nodeService = serviceRegistry.getNodeService();
    searchService = serviceRegistry.getSearchService();

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
    nodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Register the models
    URL modelUrlMnt11072 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-11072.xml");
    URL modelUrlMnt16748 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-16748.xml");
    auditModelRegistry.registerModel(modelUrlMnt11072);
    auditModelRegistry.registerModel(modelUrlMnt16748);
    auditModelRegistry.loadAuditModels();
}
 
Example 2
Source File: GetMethodRegressionTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext();
    ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    davHelper = (WebDAVHelper) applicationContext.getBean(WebDAVHelper.BEAN_NAME);
    auditRegistry = (AuditModelRegistryImpl) applicationContext.getBean(AUDIT_REGISTRY_BEAN_NAME);

    auditService = registry.getAuditService();
    fileFolderService = registry.getFileFolderService();
    transactionService = registry.getTransactionService();

    testingMethod = new GetMethod();
    mockResponse = new MockHttpServletResponse();

    restartTransaction(TransactionActionEnum.ACTION_NONE);
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    companyHomeNodeRef = registry.getNodeLocatorService().getNode(CompanyHomeNodeLocator.NAME, null, null);
    rootTestFolder = fileFolderService.create(companyHomeNodeRef, ROOT_TEST_FOLDER_NAME, ContentModel.TYPE_FOLDER).getNodeRef();
}
 
Example 3
Source File: AuditComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setUp() throws Exception
{
    auditModelRegistry = (AuditModelRegistryImpl) ctx.getBean("auditModel.modelRegistry");
    //MNT-10807 : Auditing does not take into account audit.filter.alfresco-access.transaction.user
    UserAuditFilter userAuditFilter = new UserAuditFilter();
    userAuditFilter.setUserFilterPattern("~System;~null;.*");
    userAuditFilter.afterPropertiesSet();
    auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");
    auditComponent.setUserAuditFilter(userAuditFilter);
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    auditService = serviceRegistry.getAuditService();
    transactionService = serviceRegistry.getTransactionService();
    transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService");
    nodeService = serviceRegistry.getNodeService();
    fileFolderService = serviceRegistry.getFileFolderService();
    
    // Register the test model
    URL testModelUrl = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test.xml");
    auditModelRegistry.registerModel(testModelUrl);
    auditModelRegistry.loadAuditModels();
    
    RunAsWork<NodeRef> testRunAs = new RunAsWork<NodeRef>()
    {
        public NodeRef doWork() throws Exception
        {
            return nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
        }
    };
    nodeRef = AuthenticationUtil.runAs(testRunAs, AuthenticationUtil.getSystemUserName());

    // Authenticate
    user = "User-" + getName();
    AuthenticationUtil.setFullyAuthenticatedUser(user);

    final RetryingTransactionCallback<Void> resetDisabledPathsCallback = new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            auditComponent.resetDisabledPaths(APPLICATION_TEST);
            auditComponent.resetDisabledPaths(APPLICATION_ACTIONS_TEST);
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(resetDisabledPathsCallback);
}