Resolve ALF-4548: Replication job fails at start

- added checks to transfer service to ensure all mandatory transfer target properties are populated, and raise exception with appropriate message in each case

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22153 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-09-02 08:40:58 +00:00
parent 9592eef2a3
commit 0212c01c1a
2 changed files with 44 additions and 9 deletions

View File

@@ -25,4 +25,11 @@ transfer_service.receiver.error_committing_transfer=An error has occurred while
transfer_service.receiver.transfer_not_found=Failed to find any record of requested transfer: {0}
transfer_service.receiver.transfer_cancelled=Transfer has been cancelled: {0}
transfer_service.no_encoding=Unable to deserialize value, no transformation for encoding {0}
transfer_service.unable_to_deserialise=Unable to deserialize value
transfer_service.unable_to_deserialise=Unable to deserialize value
transfer_service.missing_endpoint_path=An endpoint path has not been specified for transfer target: {0}
transfer_service.missing_endpoint_protocol=An endpoint protocol has not been specified for transfer target: {0}
transfer_service.missing_endpoint_host=An endpoint host has not been specified for transfer target: {0}
transfer_service.missing_endpoint_port=An endpoint port has not been specified for transfer target: {0}
transfer_service.missing_endpoint_username=An endpoint username has not been specified for transfer target: {0}
transfer_service.missing_endpoint_password=An endpoint password has not been specified for transfer target: {0}

View File

@@ -103,6 +103,12 @@ public class TransferServiceImpl implements TransferService
private static final String MSG_ERR_TRANSFER_ASYNC = "transfer_service.unable_to_transfer_async";
private static final String MSG_TARGET_EXISTS = "transfer_service.target_exists";
private static final String MSG_NO_NODES = "transfer_service.no_nodes";
private static final String MSG_MISSING_ENDPOINT_PATH = "transfer_service.missing_endpoint_path";
private static final String MSG_MISSING_ENDPOINT_PROTOCOL = "transfer_service.missing_endpoint_protocol";
private static final String MSG_MISSING_ENDPOINT_HOST = "transfer_service.missing_endpoint_host";
private static final String MSG_MISSING_ENDPOINT_PORT = "transfer_service.missing_endpoint_port";
private static final String MSG_MISSING_ENDPOINT_USERNAME = "transfer_service.missing_endpoint_username";
private static final String MSG_MISSING_ENDPOINT_PASSWORD = "transfer_service.missing_endpoint_password";
/**
* The synchronised list of transfers in progress.
@@ -1080,12 +1086,36 @@ public class TransferServiceImpl implements TransferService
{
def.setNodeRef(nodeRef);
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
def.setEndpointPath((String)properties.get(TransferModel.PROP_ENDPOINT_PATH));
def.setEndpointProtocol((String)properties.get(TransferModel.PROP_ENDPOINT_PROTOCOL));
def.setEndpointHost((String)properties.get(TransferModel.PROP_ENDPOINT_HOST));
def.setEndpointPort((Integer)properties.get(TransferModel.PROP_ENDPOINT_PORT));
Serializable passwordVal = properties.get(TransferModel.PROP_PASSWORD);
String name = (String)properties.get(ContentModel.PROP_NAME);
String endpointPath = (String)properties.get(TransferModel.PROP_ENDPOINT_PATH);
if (endpointPath == null)
throw new TransferException(MSG_MISSING_ENDPOINT_PATH, new Object[] {name});
def.setEndpointPath(endpointPath);
String endpointProtocol = (String)properties.get(TransferModel.PROP_ENDPOINT_PROTOCOL);
if (endpointProtocol == null)
throw new TransferException(MSG_MISSING_ENDPOINT_PROTOCOL, new Object[] {name});
def.setEndpointProtocol(endpointProtocol);
String endpointHost = (String)properties.get(TransferModel.PROP_ENDPOINT_HOST);
if (endpointHost== null)
throw new TransferException(MSG_MISSING_ENDPOINT_HOST, new Object[] {name});
def.setEndpointHost(endpointHost);
Integer endpointPort = (Integer)properties.get(TransferModel.PROP_ENDPOINT_PORT);
if (endpointPort == null)
throw new TransferException(MSG_MISSING_ENDPOINT_PORT, new Object[] {name});
def.setEndpointPort(endpointPort);
String username = (String)properties.get(TransferModel.PROP_USERNAME);
if (username == null)
throw new TransferException(MSG_MISSING_ENDPOINT_USERNAME, new Object[] {name});
def.setUsername(username);
Serializable passwordVal = properties.get(TransferModel.PROP_PASSWORD);
if (passwordVal == null)
throw new TransferException(MSG_MISSING_ENDPOINT_PASSWORD, new Object[] {name});
if(passwordVal.getClass().isArray())
{
def.setPassword(decrypt((char[])passwordVal));
@@ -1096,9 +1126,7 @@ public class TransferServiceImpl implements TransferService
def.setPassword(decrypt(password.toCharArray()));
}
def.setUsername((String)properties.get(TransferModel.PROP_USERNAME));
def.setName((String)properties.get(ContentModel.PROP_NAME));
def.setName(name);
def.setTitle((String)properties.get(ContentModel.PROP_TITLE));
def.setDescription((String)properties.get(ContentModel.PROP_DESCRIPTION));