Fix for ALF-11931

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32880 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Steven Glover
2011-12-20 11:57:22 +00:00
parent 2413f55253
commit d163e918b8
2 changed files with 24 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
replication.exception.targetNotGiven=The target is required but wasn't given
replication.exception.noPayloadsSpecified=No payloads were specified
replication.exception.replicationDefIsDisabled=Unable to execute a disabled replication definition
replication.exception.unableToReplicate=Unable to replicate. The replication service is not enabled
replication.exception.errorProcessingPayload=Error processing payload list - {0}
replication.exception.errorExecutingTransfer=Error executing transfer - {0}

View File

@@ -55,12 +55,23 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
/** /**
* @author Nick Burch * @author Nick Burch
* @since 3.4 * @since 3.4
*/ */
public class ReplicationActionExecutor extends ActionExecuterAbstractBase { public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
/**
* I18N labels
*/
private static final String MSG_ERR_TARGET_NOT_GIVEN = "replication.targetNotGiven";
private static final String MSG_ERR_NO_PAYLOADS_SPECIFIED = "replication.exception.noPayloadsSpecified";
private static final String MSG_ERR_REPLICATION_DEF_DISABLED = "replication.exception.replicationDefIsDisabled";
private static final String MSG_ERR_UNABLE_TO_REPLICATE = "replication.exception.unableToReplicate";
private static final String MSG_ERR_PROCESSING_PAYLOAD = "replication.exception.errorProcessingPayload";
private static final String MSG_ERR_EXECUTING_TRANSFER = "replication.exception.errorExecutingTransfer";
/** /**
* The logger * The logger
*/ */
@@ -251,19 +262,19 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
if(replicationDef.getTargetName() == null || if(replicationDef.getTargetName() == null ||
replicationDef.getTargetName().equals("")) replicationDef.getTargetName().equals(""))
{ {
throw new ReplicationServiceException("The target is required but wasn't given"); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_TARGET_NOT_GIVEN));
} }
if(replicationDef.getPayload().size() == 0) if(replicationDef.getPayload().size() == 0)
{ {
throw new ReplicationServiceException("No payloads were specified"); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_NO_PAYLOADS_SPECIFIED));
} }
if(!replicationDef.isEnabled()) if(!replicationDef.isEnabled())
{ {
throw new ReplicationServiceException("Unable to execute a disabled replication definition"); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_REPLICATION_DEF_DISABLED));
} }
if(!replicationParams.isEnabled()) if(!replicationParams.isEnabled())
{ {
throw new ReplicationServiceException("Unable to replicate. The replication service is not enabled"); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_UNABLE_TO_REPLICATE));
} }
// Lock the service - only one instance of the replication // Lock the service - only one instance of the replication
@@ -280,7 +291,7 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
} }
catch(Exception e) { catch(Exception e) {
lock.close(); lock.close();
throw new ReplicationServiceException("Error processing payload list - " + e.getMessage(), e); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_PROCESSING_PAYLOAD, e.getMessage()), e);
} }
// Ask the transfer service to do the replication // Ask the transfer service to do the replication
@@ -325,10 +336,10 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
TransferEventError failureEndEvent = ((TransferFailureException)e).getErrorEvent(); TransferEventError failureEndEvent = ((TransferFailureException)e).getErrorEvent();
writeDefinitionReports(replicationDef, failureEndEvent.getSourceReport(), failureEndEvent.getDestinationReport()); writeDefinitionReports(replicationDef, failureEndEvent.getSourceReport(), failureEndEvent.getDestinationReport());
Throwable cause = (e.getCause() == null) ? e : e.getCause(); Throwable cause = (e.getCause() == null) ? e : e.getCause();
throw new ReplicationServiceException("Error executing transfer - " + cause.getMessage(), cause); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_EXECUTING_TRANSFER, cause.getMessage()), cause);
} }
writeDefinitionReports(replicationDef, null, null); writeDefinitionReports(replicationDef, null, null);
throw new ReplicationServiceException("Error executing transfer - " + e.getMessage(), e); throw new ReplicationServiceException(I18NUtil.getMessage(MSG_ERR_EXECUTING_TRANSFER, e.getMessage()), e);
} }
finally finally
{ {