mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
68159: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 67866: MNT-11072 : Auditing not logging when system is on read only mode Fixed audit to be recorded on a read-only system. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@68441 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -75,8 +75,6 @@ public interface AuditComponent
|
|||||||
* this method might return <tt>false</tt> are: auditing is disabled; no audit applications
|
* this method might return <tt>false</tt> are: auditing is disabled; no audit applications
|
||||||
* have been registered. Sometimes, depending on the log level, this method may always
|
* have been registered. Sometimes, depending on the log level, this method may always
|
||||||
* return <tt>true</tt>.
|
* return <tt>true</tt>.
|
||||||
* <p/>
|
|
||||||
* <tt>false</tt> will always be returned if the server is read-only.
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return Returns <code>true</code> if the calling code (data producers)
|
* @return Returns <code>true</code> if the calling code (data producers)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -42,6 +42,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||||
@@ -247,16 +248,8 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
*/
|
*/
|
||||||
public boolean areAuditValuesRequired()
|
public boolean areAuditValuesRequired()
|
||||||
{
|
{
|
||||||
if (transactionService.isReadOnly())
|
return (loggerInbound.isDebugEnabled()) ||
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(loggerInbound.isDebugEnabled()) ||
|
|
||||||
(isAuditEnabled() && !auditModelRegistry.getAuditPathMapper().isEmpty());
|
(isAuditEnabled() && !auditModelRegistry.getAuditPathMapper().isEmpty());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -580,7 +573,9 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
return recordAuditValuesImpl(mappedValues);
|
return recordAuditValuesImpl(mappedValues);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||||
|
txnHelper.setForceWritable(true);
|
||||||
|
return txnHelper.doInTransaction(callback, false, true);
|
||||||
case TXN_READ_WRITE:
|
case TXN_READ_WRITE:
|
||||||
return recordAuditValuesImpl(mappedValues);
|
return recordAuditValuesImpl(mappedValues);
|
||||||
default:
|
default:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -43,6 +43,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
|
import org.alfresco.repo.transaction.TransactionServiceImpl;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||||
import org.alfresco.service.cmr.audit.AuditService;
|
import org.alfresco.service.cmr.audit.AuditService;
|
||||||
@@ -94,6 +95,7 @@ public class AuditComponentTest extends TestCase
|
|||||||
private AuditService auditService;
|
private AuditService auditService;
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
private TransactionServiceImpl transactionServiceImpl;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private FileFolderService fileFolderService;
|
private FileFolderService fileFolderService;
|
||||||
|
|
||||||
@@ -113,6 +115,7 @@ public class AuditComponentTest extends TestCase
|
|||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
auditService = serviceRegistry.getAuditService();
|
auditService = serviceRegistry.getAuditService();
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
|
transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService");
|
||||||
nodeService = serviceRegistry.getNodeService();
|
nodeService = serviceRegistry.getNodeService();
|
||||||
fileFolderService = serviceRegistry.getFileFolderService();
|
fileFolderService = serviceRegistry.getFileFolderService();
|
||||||
|
|
||||||
@@ -263,7 +266,7 @@ public class AuditComponentTest extends TestCase
|
|||||||
return auditComponent.recordAuditValues(actionPath, adjustedValues);
|
return auditComponent.recordAuditValues(actionPath, adjustedValues);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback);
|
return transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -987,4 +990,22 @@ public class AuditComponentTest extends TestCase
|
|||||||
};
|
};
|
||||||
AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminRoleName());
|
AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminRoleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for <a href="https://issues.alfresco.com/jira/browse/MNT-11072">MNT-11072</a>
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testAuditInReadOnly() throws Exception
|
||||||
|
{
|
||||||
|
QName veto = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "TestVeto");
|
||||||
|
transactionServiceImpl.setAllowWrite(false, veto);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auditAction02("action-02");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
transactionServiceImpl.setAllowWrite(true, veto);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user