Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

103947: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      103926: Merged NESS/5.0.N-2015_03_23 (5.0.2) to 5.0.N (5.0.2)
         103902: MNT-13205 - hide the cancel exception from the log, small refactoring of the exception logging


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@104034 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tatyana Valkevych
2015-05-12 15:32:40 +00:00
parent 04916eb008
commit dee9fdcf00
7 changed files with 80 additions and 13 deletions

View File

@@ -31,6 +31,7 @@ import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.repo.action.executer.ActionExecuter;
import org.alfresco.repo.action.executer.LoggingAwareExecuter;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.CopyServicePolicies;
@@ -1816,4 +1817,12 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
ActionParameterTypeCopyBehaviourCallback.INSTANCE.repointNodeRefs(sourceNodeRef, targetNodeRef,
ActionModel.PROP_PARAMETER_VALUE, copyMap, nodeService);
}
@Override
public boolean onLogException(Action action, Log logger, Throwable t, String message)
{
LoggingAwareExecuter executer = (LoggingAwareExecuter) this.applicationContext.getBean(action.getActionDefinitionName());
return executer.onLogException(logger,t, message);
}
}

View File

@@ -29,8 +29,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.error.StackTraceUtil;
import org.alfresco.repo.action.AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute;
import org.alfresco.repo.content.transform.UnimportantTransformException;
import org.alfresco.repo.content.transform.UnsupportedTransformationException;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.rule.RuleServiceImpl;
@@ -444,16 +442,9 @@ public class AsynchronousActionExecutionQueueImpl implements AsynchronousActionE
Throwable rootCause = (e instanceof AlfrescoRuntimeException) ? ((AlfrescoRuntimeException)e).getRootCause() : null;
String message = (rootCause == null ? null : rootCause.getMessage());
message = "Failed to execute asynchronous action: " + action+ (message == null ? "" : ": "+message);
if (rootCause instanceof UnimportantTransformException)
{
logger.debug(message);
}
else if (rootCause instanceof UnsupportedTransformationException)
{
logger.error(message);
}
else
if(!ActionExecutionWrapper.this.actionService.onLogException(action, logger, rootCause, message))
{
//if not handled by the executor just show in the log
logger.error(message, e);
}
}

View File

@@ -26,6 +26,7 @@ import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
/**
* Runtime action service. This interface contains methods useful for integration with the action
@@ -105,4 +106,16 @@ public interface RuntimeActionService
* @param actionedUponNodeRef the actioned upon node reference
*/
public void directActionExecution(Action action, NodeRef actionedUponNodeRef);
/**
* Optional logging of errors callback for the action executer
* for the cases when the error might be ignored
* or shown in a different manner for the action
* @param action the action
* @param logger the logger
* @param t the exception thrown
* @param message the proposed message that will be logged
* @return true if it was handled, false for default handling
*/
public boolean onLogException(Action action, Log logger, Throwable t, String message);
}

View File

@@ -41,7 +41,7 @@ import org.apache.commons.logging.LogFactory;
*
* @author Roy Wetherall
*/
public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstractBase implements ActionExecuter
public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstractBase implements ActionExecuter, LoggingAwareExecuter
{
private static Log logger = LogFactory.getLog(ActionExecuterAbstractBase.class);
@@ -296,4 +296,10 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
public String getQueueName() {
return queueName;
}
@Override
public boolean onLogException(Log logger, Throwable t, String message)
{
return false;
}
}

View File

@@ -0,0 +1,18 @@
package org.alfresco.repo.action.executer;
import org.apache.commons.logging.Log;
public interface LoggingAwareExecuter
{
/**
* Optional logging of errors callback for the action executer
* for the cases when the error might be ignored
* or shown in a different manner for the action
* @param action the action
* @param logger the logger
* @param t the exception thrown
* @param message the proposed message that will be logged
* @return true if it was handled, false for default handling
*/
boolean onLogException(Log logger, Throwable t, String message);
}

View File

@@ -24,6 +24,8 @@ import org.alfresco.model.ContentModel;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.content.transform.UnimportantTransformException;
import org.alfresco.repo.content.transform.UnsupportedTransformationException;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
@@ -33,12 +35,12 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NoTransformerException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
import org.alfresco.service.cmr.rule.RuleServiceException;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -400,4 +402,21 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
return potentialExtensionString.length() > 0 && potentialExtensionString.indexOf(' ') == -1;
}
@Override
public boolean onLogException(Log logger, Throwable t, String message)
{
if (t instanceof UnimportantTransformException )
{
logger.debug(message);
return true;
}
else if (t instanceof UnsupportedTransformationException)
{
logger.error(message);
return true;
}
return false;
}
}

View File

@@ -370,6 +370,17 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
}
}
@Override
public boolean onLogException(Log logger, Throwable t, String message)
{
if(t instanceof ActionCancelledException)
{
logger.debug(message);
return true;
}
return false;
}
/**
* A {@link TransferCallback} which periodically renews the
* lock held against a {@link ReplicationDefinition}