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:
Mark Rogers
2014-04-30 16:20:50 +00:00
parent eb0220cb38
commit b9cce28a70
3 changed files with 29 additions and 15 deletions

View File

@@ -75,8 +75,6 @@ public interface AuditComponent
* 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
* 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)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* 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.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.audit.AuditQueryParameters;
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
@@ -247,16 +248,8 @@ public class AuditComponentImpl implements AuditComponent
*/
public boolean areAuditValuesRequired()
{
if (transactionService.isReadOnly())
{
return false;
}
else
{
return
(loggerInbound.isDebugEnabled()) ||
return (loggerInbound.isDebugEnabled()) ||
(isAuditEnabled() && !auditModelRegistry.getAuditPathMapper().isEmpty());
}
}
/**
@@ -580,7 +573,9 @@ public class AuditComponentImpl implements AuditComponent
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:
return recordAuditValuesImpl(mappedValues);
default:

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* 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.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.audit.AuditQueryParameters;
import org.alfresco.service.cmr.audit.AuditService;
@@ -94,6 +95,7 @@ public class AuditComponentTest extends TestCase
private AuditService auditService;
private ServiceRegistry serviceRegistry;
private TransactionService transactionService;
private TransactionServiceImpl transactionServiceImpl;
private NodeService nodeService;
private FileFolderService fileFolderService;
@@ -113,6 +115,7 @@ public class AuditComponentTest extends TestCase
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
auditService = serviceRegistry.getAuditService();
transactionService = serviceRegistry.getTransactionService();
transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService");
nodeService = serviceRegistry.getNodeService();
fileFolderService = serviceRegistry.getFileFolderService();
@@ -263,7 +266,7 @@ public class AuditComponentTest extends TestCase
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());
}
/**
* 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);
}
}
}