Formatting during investigation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130612 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2016-09-13 16:04:19 +00:00
parent 735fee253a
commit 6b270998e9

View File

@@ -356,8 +356,9 @@ public class AuditMethodInterceptor implements MethodInterceptor
} }
else else
{ {
if(value instanceof List) if (value instanceof List)
{ {
@SuppressWarnings("rawtypes")
List valueList = (List) value; List valueList = (List) value;
List<Serializable> recordableList = new ArrayList<Serializable>(); List<Serializable> recordableList = new ArrayList<Serializable>();
for (Object valueListItem : valueList) for (Object valueListItem : valueList)
@@ -504,27 +505,27 @@ public class AuditMethodInterceptor implements MethodInterceptor
if (thrown != null) if (thrown != null)
{ {
// ALF-3055: an exception has occurred - make sure the audit occurs in a new thread // ALF-3055: an exception has occurred - make sure the audit occurs in a new thread
// rather than a nested transaction to avoid contention for the same audit table // rather than a nested transaction to avoid contention for the same audit table
// ALF-12638: ensure that the new thread context matches the current thread context // ALF-12638: ensure that the new thread context matches the current thread context
final Authentication authContext = AuthenticationUtil.getFullAuthentication(); final Authentication authContext = AuthenticationUtil.getFullAuthentication();
threadPoolExecutor.execute(new Runnable() threadPoolExecutor.execute(new Runnable()
{ {
public void run() public void run()
{ {
Map<String, Serializable> auditedData; Map<String, Serializable> auditedData;
StringBuilder sb = new StringBuilder(1024); StringBuilder sb = new StringBuilder(1024);
StackTraceUtil.buildStackTrace( StackTraceUtil.buildStackTrace(
thrown.getMessage(), thrown.getStackTrace(), sb, Integer.MAX_VALUE); thrown.getMessage(), thrown.getStackTrace(), sb, Integer.MAX_VALUE);
auditData.put(AUDIT_SNIPPET_ERROR, SchemaBootstrap.trimStringForTextFields(sb.toString())); auditData.put(AUDIT_SNIPPET_ERROR, SchemaBootstrap.trimStringForTextFields(sb.toString()));
// Ensure we have a transaction // Ensure we have a transaction
RetryingTransactionCallback<Map<String, Serializable>> auditCallback = RetryingTransactionCallback<Map<String, Serializable>> auditCallback =
new RetryingTransactionCallback<Map<String, Serializable>>() new RetryingTransactionCallback<Map<String, Serializable>>()
{ {
public Map<String, Serializable> execute() throws Throwable public Map<String, Serializable> execute() throws Throwable
{ {
// Record thrown exceptions regardless of userFilter in case of failed authentication // Record thrown exceptions regardless of userFilter in case of failed authentication
// see MNT-11760 // see MNT-11760
if (thrown instanceof AuthenticationException) if (thrown instanceof AuthenticationException)
@@ -536,27 +537,27 @@ public class AuditMethodInterceptor implements MethodInterceptor
return auditComponent.recordAuditValues(rootPath, auditData); return auditComponent.recordAuditValues(rootPath, auditData);
} }
} }
}; };
try try
{ {
AuthenticationUtil.setFullAuthentication(authContext); AuthenticationUtil.setFullAuthentication(authContext);
auditedData = transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback, false, true); auditedData = transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback, false, true);
} }
finally finally
{ {
AuthenticationUtil.clearCurrentSecurityContext(); AuthenticationUtil.clearCurrentSecurityContext();
} }
// Done // Done
if (logger.isDebugEnabled() && auditedData.size() > 0) if (logger.isDebugEnabled() && auditedData.size() > 0)
{ {
logger.debug( logger.debug(
"Audited after invocation: \n" + "Audited after invocation: \n" +
(thrown == null ? "" : " Exception: " + thrown.getMessage() + "\n") + (thrown == null ? "" : " Exception: " + thrown.getMessage() + "\n") +
" Values: " + auditedData); " Values: " + auditedData);
} }
} }
}); });
} }
else else
@@ -567,14 +568,14 @@ public class AuditMethodInterceptor implements MethodInterceptor
// The current transaction will be fine // The current transaction will be fine
auditedData = auditComponent.recordAuditValues(rootPath, auditData); auditedData = auditComponent.recordAuditValues(rootPath, auditData);
// Done // Done
if (logger.isDebugEnabled() && auditedData.size() > 0) if (logger.isDebugEnabled() && auditedData.size() > 0)
{ {
logger.debug( logger.debug(
"Audited after invocation: \n" + "Audited after invocation: \n" +
(thrown == null ? "" : " Exception: " + thrown.getMessage() + "\n") + (thrown == null ? "" : " Exception: " + thrown.getMessage() + "\n") +
" Values: " + auditedData); " Values: " + auditedData);
} }
} }
} }
} }