Merge BRANCHES/DEV/BRIAN/FSTR to HEAD:

28906: File Transfer Receiver SPRINT1
 29365: Initial check in
 29378: Configuration properties can now be located in "filetransferreceiver.properties" separated from spring configuration files.
 29417: Delete, first check in
 29450: Now multiple distinct contents can be send over in one transfer.
 29516: 
 29517: 
 29531: Manage cases like /F1/F2/F3 ... becoming /F3/F2/F1
 29550: FTR:
    - Tidied project classpath
    - Removed incorrect reference to OpenOffice RuntimeException in JobLockServiceImpl
    - Removed references to StringOutputStream



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29643 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-08-09 21:02:03 +00:00
parent 62cfc60ce9
commit 153e2f8d33
10 changed files with 412 additions and 327 deletions

View File

@@ -96,6 +96,9 @@
</properties> </properties>
</type> </type>
<type name="trx:transferLock"> <type name="trx:transferLock">
<title>Transfer Lock</title> <title>Transfer Lock</title>
<description>Node type used to represent the transfer lock node <description>Node type used to represent the transfer lock node
@@ -160,7 +163,7 @@
<description>Transfer Report</description> <description>Transfer Report</description>
<parent>cm:content</parent> <parent>cm:content</parent>
</type> </type>
<type name="trx:transferReportDest"> <type name="trx:transferReportDest">
<title>Transfer Report From Destination</title> <title>Transfer Report From Destination</title>
<description>Transfer Report (Destination)</description> <description>Transfer Report (Destination)</description>
@@ -182,6 +185,24 @@
</properties> </properties>
</aspect> </aspect>
<aspect name="trx:fileTransferTarget">
<title>File Transfer Target</title>
<description>Aspect used to model a receiving root for file transfer</description>
<associations>
<association name="trx:rootFileTransfer">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
<aspect name="trx:transferRelated"> <aspect name="trx:transferRelated">
<title>Nodes with this aspect are related to a particular transfer. <title>Nodes with this aspect are related to a particular transfer.
</title> </title>
@@ -194,7 +215,7 @@
</property> </property>
</properties> </properties>
</aspect> </aspect>
<aspect name="trx:transferred"> <aspect name="trx:transferred">
<title>Transferred Node</title> <title>Transferred Node</title>
<description>Nodes with this aspect have been transferred from one repository to another</description> <description>Nodes with this aspect have been transferred from one repository to another</description>
@@ -220,7 +241,7 @@
</property> </property>
</properties> </properties>
</aspect> </aspect>
<aspect name="trx:alien"> <aspect name="trx:alien">
<title>Alien Node</title> <title>Alien Node</title>
<description>Nodes with this aspect are either alien nodes or have been invaded by other alien nodes</description> <description>Nodes with this aspect are either alien nodes or have been invaded by other alien nodes</description>
@@ -235,7 +256,7 @@
</property> </property>
</properties> </properties>
</aspect> </aspect>
</aspects> </aspects>
</model> </model>

View File

@@ -54,6 +54,7 @@
<bean id="transferTransmitter" class="org.alfresco.repo.transfer.HttpClientTransmitterImpl" <bean id="transferTransmitter" class="org.alfresco.repo.transfer.HttpClientTransmitterImpl"
init-method="init"> init-method="init">
<property name="contentService" ref="ContentService" /> <property name="contentService" ref="ContentService" />
<property name="nodeService" ref="nodeService" />
</bean> </bean>
<bean id="transferVersionChecker" class="org.alfresco.repo.transfer.TransferVersionCheckerImpl"> <bean id="transferVersionChecker" class="org.alfresco.repo.transfer.TransferVersionCheckerImpl">

View File

@@ -37,8 +37,6 @@ import org.alfresco.util.VmShutdownListener;
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 com.sun.star.uno.RuntimeException;
/** /**
* {@inheritDoc JobLockService} * {@inheritDoc JobLockService}
* *

View File

@@ -31,12 +31,18 @@ import java.nio.ByteBuffer;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.TransferException; import org.alfresco.service.cmr.transfer.TransferException;
import org.alfresco.service.cmr.transfer.TransferProgress; import org.alfresco.service.cmr.transfer.TransferProgress;
import org.alfresco.service.cmr.transfer.TransferTarget; import org.alfresco.service.cmr.transfer.TransferTarget;
@@ -68,34 +74,35 @@ import org.json.JSONObject;
/** /**
* HTTP implementation of TransferTransmitter. * HTTP implementation of TransferTransmitter.
* *
* Sends data via HTTP to the server. * Sends data via HTTP to the server.
* *
* @author brian * @author brian
*/ */
public class HttpClientTransmitterImpl implements TransferTransmitter public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
private static final Log log = LogFactory.getLog(HttpClientTransmitterImpl.class); private static final Log log = LogFactory.getLog(HttpClientTransmitterImpl.class);
private static final String MSG_UNSUPPORTED_PROTOCOL = "transfer_service.comms.unsupported_protocol"; private static final String MSG_UNSUPPORTED_PROTOCOL = "transfer_service.comms.unsupported_protocol";
private static final String MSG_UNSUCCESSFUL_RESPONSE = "transfer_service.comms.unsuccessful_response"; private static final String MSG_UNSUCCESSFUL_RESPONSE = "transfer_service.comms.unsuccessful_response";
private static final String MSG_HTTP_REQUEST_FAILED = "transfer_service.comms.http_request_failed"; private static final String MSG_HTTP_REQUEST_FAILED = "transfer_service.comms.http_request_failed";
private static final int DEFAULT_HTTP_PORT = 80; private static final int DEFAULT_HTTP_PORT = 80;
private static final int DEFAULT_HTTPS_PORT = 443; private static final int DEFAULT_HTTPS_PORT = 443;
private static final String HTTP_SCHEME_NAME = "http"; // lowercase is important private static final String HTTP_SCHEME_NAME = "http"; // lowercase is important
private static final String HTTPS_SCHEME_NAME = "https"; // lowercase is important private static final String HTTPS_SCHEME_NAME = "https"; // lowercase is important
private HttpClient httpClient = null; private HttpClient httpClient = null;
private Protocol httpProtocol = new Protocol(HTTP_SCHEME_NAME, new DefaultProtocolSocketFactory(), DEFAULT_HTTP_PORT); private Protocol httpProtocol = new Protocol(HTTP_SCHEME_NAME, new DefaultProtocolSocketFactory(), DEFAULT_HTTP_PORT);
private Protocol httpsProtocol = new Protocol(HTTPS_SCHEME_NAME, (ProtocolSocketFactory) new SSLProtocolSocketFactory(), DEFAULT_HTTPS_PORT); private Protocol httpsProtocol = new Protocol(HTTPS_SCHEME_NAME, (ProtocolSocketFactory) new SSLProtocolSocketFactory(), DEFAULT_HTTPS_PORT);
private Map<String,Protocol> protocolMap = null; private Map<String,Protocol> protocolMap = null;
private HttpMethodFactory httpMethodFactory = null; private HttpMethodFactory httpMethodFactory = null;
private JsonSerializer<Throwable, JSONObject> jsonErrorSerializer; private JsonSerializer<Throwable, JSONObject> jsonErrorSerializer;
private ContentService contentService; private ContentService contentService;
private NodeService nodeService;
public HttpClientTransmitterImpl() public HttpClientTransmitterImpl()
{ {
protocolMap = new TreeMap<String,Protocol>(); protocolMap = new TreeMap<String,Protocol>();
@@ -107,7 +114,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
httpMethodFactory = new StandardHttpMethodFactoryImpl(); httpMethodFactory = new StandardHttpMethodFactoryImpl();
jsonErrorSerializer = new ExceptionJsonSerializer(); jsonErrorSerializer = new ExceptionJsonSerializer();
} }
public void init() public void init()
{ {
PropertyCheck.mandatory(this, "contentService", contentService); PropertyCheck.mandatory(this, "contentService", contentService);
@@ -115,7 +122,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
/** /**
* By default this class uses the standard SSLProtocolSocketFactory, but this method allows this to be overridden. * By default this class uses the standard SSLProtocolSocketFactory, but this method allows this to be overridden.
* Useful if, for example, one wishes to permit support of self-signed certificates on the target. * Useful if, for example, one wishes to permit support of self-signed certificates on the target.
* @param socketFactory * @param socketFactory
*/ */
public void setHttpsSocketFactory(ProtocolSocketFactory socketFactory) public void setHttpsSocketFactory(ProtocolSocketFactory socketFactory)
@@ -124,7 +131,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
} }
/** /**
* By default, this class uses a plain HttpClient instance with the only non-default * By default, this class uses a plain HttpClient instance with the only non-default
* option being the multi-threaded connection manager. * option being the multi-threaded connection manager.
* Use this method to replace this with your own HttpClient instance configured how you wish * Use this method to replace this with your own HttpClient instance configured how you wish
* @param httpClient * @param httpClient
@@ -144,24 +151,24 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
verifyRequest.setPath(target.getEndpointPath() + "/test"); verifyRequest.setPath(target.getEndpointPath() + "/test");
try try
{ {
int response = httpClient.executeMethod(hostConfig, verifyRequest, httpState); int response = httpClient.executeMethod(hostConfig, verifyRequest, httpState);
checkResponseStatus("verifyTarget", response, verifyRequest); checkResponseStatus("verifyTarget", response, verifyRequest);
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"verifyTraget", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"verifyTraget", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
verifyRequest.releaseConnection(); verifyRequest.releaseConnection();
@@ -176,14 +183,14 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
if (response != 200) if (response != 200)
{ {
Throwable error = null; Throwable error = null;
try try
{ {
log.error("Received \"unsuccessful\" response code from target server: " + response); log.error("Received \"unsuccessful\" response code from target server: " + response);
String errorPayload = method.getResponseBodyAsString(); String errorPayload = method.getResponseBodyAsString();
JSONObject errorObj = new JSONObject(errorPayload); JSONObject errorObj = new JSONObject(errorPayload);
error = rehydrateError(errorObj); error = rehydrateError(errorObj);
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new TransferException(MSG_UNSUCCESSFUL_RESPONSE, new Object[] {methodName, response}); throw new TransferException(MSG_UNSUCCESSFUL_RESPONSE, new Object[] {methodName, response});
} }
@@ -206,8 +213,8 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
protected HttpState getHttpState(TransferTarget target) protected HttpState getHttpState(TransferTarget target)
{ {
HttpState httpState = new HttpState(); HttpState httpState = new HttpState();
httpState.setCredentials(new AuthScope(target.getEndpointHost(), target.getEndpointPort(), httpState.setCredentials(new AuthScope(target.getEndpointHost(), target.getEndpointPort(),
AuthScope.ANY_REALM), AuthScope.ANY_REALM),
new UsernamePasswordCredentials(target.getUsername(), new String(target.getPassword()))); new UsernamePasswordCredentials(target.getUsername(), new String(target.getPassword())));
return httpState; return httpState;
} }
@@ -223,7 +230,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
throw new TransferException(MSG_UNSUPPORTED_PROTOCOL, new Object[] {target.getEndpointProtocol()}); throw new TransferException(MSG_UNSUPPORTED_PROTOCOL, new Object[] {target.getEndpointProtocol()});
} }
Protocol protocol = protocolMap.get(requiredProtocol.toLowerCase().trim()); Protocol protocol = protocolMap.get(requiredProtocol.toLowerCase().trim());
if (protocol == null) { if (protocol == null) {
log.error("Unsupported protocol: " + target.getEndpointProtocol()); log.error("Unsupported protocol: " + target.getEndpointProtocol());
@@ -242,32 +249,45 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
beginRequest.setPath(target.getEndpointPath() + "/begin"); beginRequest.setPath(target.getEndpointPath() + "/begin");
try try
{ {
beginRequest.setRequestBody( new NameValuePair[] { NameValuePair[] nameValuePair = new NameValuePair[] {
new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId), new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId),
new NameValuePair(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF, "false"), new NameValuePair(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF, "false"),
new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition()),
new NameValuePair(TransferCommons.PARAM_VERSION_MAJOR, fromVersion.getVersionMajor()), new NameValuePair(TransferCommons.PARAM_VERSION_MAJOR, fromVersion.getVersionMajor()),
new NameValuePair(TransferCommons.PARAM_VERSION_MINOR, fromVersion.getVersionMinor()), new NameValuePair(TransferCommons.PARAM_VERSION_MINOR, fromVersion.getVersionMinor()),
new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision()), new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision())
new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition()) };
});
//add the parameter defining the root of the transfer on the file system if exist
NodeRef transferRootNode = this.getFileTransferRootNodeRef(target.getNodeRef());
if (transferRootNode != null)
{
//add the parameter
ArrayList<NameValuePair> nameValuePairArrayList= new ArrayList<NameValuePair>(nameValuePair.length + 1);
Collections.addAll(nameValuePairArrayList,nameValuePair);
nameValuePairArrayList.add(new NameValuePair(TransferCommons.PARAM_ROOT_FILE_TRANSFER, transferRootNode.toString()));
nameValuePair = nameValuePairArrayList.toArray(new NameValuePair[0]);
}
beginRequest.setRequestBody(nameValuePair);
int responseStatus = httpClient.executeMethod(hostConfig, beginRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, beginRequest, httpState);
checkResponseStatus("begin", responseStatus, beginRequest); checkResponseStatus("begin", responseStatus, beginRequest);
//If we get here then we've received a 200 response //If we get here then we've received a 200 response
//We're expecting the transfer id encoded in a JSON object... //We're expecting the transfer id encoded in a JSON object...
JSONObject response = new JSONObject(beginRequest.getResponseBodyAsString()); JSONObject response = new JSONObject(beginRequest.getResponseBodyAsString());
Transfer transfer = new Transfer(); Transfer transfer = new Transfer();
transfer.setTransferTarget(target); transfer.setTransferTarget(target);
String transferId = response.getString(TransferCommons.PARAM_TRANSFER_ID); String transferId = response.getString(TransferCommons.PARAM_TRANSFER_ID);
transfer.setTransferId(transferId); transfer.setTransferId(transferId);
if(response.has(TransferCommons.PARAM_VERSION_MAJOR)) if(response.has(TransferCommons.PARAM_VERSION_MAJOR))
{ {
String versionMajor = response.getString(TransferCommons.PARAM_VERSION_MAJOR); String versionMajor = response.getString(TransferCommons.PARAM_VERSION_MAJOR);
@@ -282,26 +302,26 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
TransferVersion version = new TransferVersionImpl("0", "0", "0", "Unknown"); TransferVersion version = new TransferVersionImpl("0", "0", "0", "Unknown");
transfer.setToVersion(version); transfer.setToVersion(version);
} }
if(log.isDebugEnabled()) if(log.isDebugEnabled())
{ {
log.debug("begin transfer transferId:" + transferId +", target:" + target); log.debug("begin transfer transferId:" + transferId +", target:" + target);
} }
return transfer; return transfer;
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
log.debug("unexpected exception", e); log.debug("unexpected exception", e);
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[] {"begin", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[] {"begin", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
log.debug("releasing connection"); log.debug("releasing connection");
@@ -314,38 +334,38 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
TransferTarget target = transfer.getTransferTarget(); TransferTarget target = transfer.getTransferTarget();
PostMethod postSnapshotRequest = getPostMethod(); PostMethod postSnapshotRequest = getPostMethod();
MultipartRequestEntity requestEntity; MultipartRequestEntity requestEntity;
if(log.isDebugEnabled()) if(log.isDebugEnabled())
{ {
log.debug("does manifest exist? " + manifest.exists()); log.debug("does manifest exist? " + manifest.exists());
log.debug("sendManifest file : " + manifest.getAbsoluteFile()); log.debug("sendManifest file : " + manifest.getAbsoluteFile());
} }
try try
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
try try
{ {
postSnapshotRequest.setPath(target.getEndpointPath() + "/post-snapshot"); postSnapshotRequest.setPath(target.getEndpointPath() + "/post-snapshot");
//Put the transferId on the query string //Put the transferId on the query string
postSnapshotRequest.setQueryString( postSnapshotRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
//TODO encapsulate the name of the manifest part //TODO encapsulate the name of the manifest part
//And add the manifest file as a "part" //And add the manifest file as a "part"
Part file = new FilePart(TransferCommons.PART_NAME_MANIFEST, manifest); Part file = new FilePart(TransferCommons.PART_NAME_MANIFEST, manifest);
requestEntity = new MultipartRequestEntity(new Part[] {file}, postSnapshotRequest.getParams()); requestEntity = new MultipartRequestEntity(new Part[] {file}, postSnapshotRequest.getParams());
postSnapshotRequest.setRequestEntity(requestEntity); postSnapshotRequest.setRequestEntity(requestEntity);
int responseStatus = httpClient.executeMethod(hostConfig, postSnapshotRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, postSnapshotRequest, httpState);
checkResponseStatus("sendManifest", responseStatus, postSnapshotRequest); checkResponseStatus("sendManifest", responseStatus, postSnapshotRequest);
InputStream is = postSnapshotRequest.getResponseBodyAsStream(); InputStream is = postSnapshotRequest.getResponseBodyAsStream();
final ReadableByteChannel inputChannel = Channels.newChannel(is); final ReadableByteChannel inputChannel = Channels.newChannel(is);
final WritableByteChannel outputChannel = Channels.newChannel(result); final WritableByteChannel outputChannel = Channels.newChannel(result);
try try
@@ -358,20 +378,20 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
inputChannel.close(); inputChannel.close();
outputChannel.close(); outputChannel.close();
} }
return; return;
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"sendManifest", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"sendManifest", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
postSnapshotRequest.releaseConnection(); postSnapshotRequest.releaseConnection();
@@ -386,30 +406,30 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
abortRequest.setPath(target.getEndpointPath() + "/abort"); abortRequest.setPath(target.getEndpointPath() + "/abort");
//Put the transferId on the query string //Put the transferId on the query string
abortRequest.setQueryString( abortRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
try try
{ {
int responseStatus = httpClient.executeMethod(hostConfig, abortRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, abortRequest, httpState);
checkResponseStatus("abort", responseStatus, abortRequest); checkResponseStatus("abort", responseStatus, abortRequest);
//If we get here then we've received a 200 response //If we get here then we've received a 200 response
//We're expecting the transfer id encoded in a JSON object... //We're expecting the transfer id encoded in a JSON object...
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"abort", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"abort", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
abortRequest.releaseConnection(); abortRequest.releaseConnection();
@@ -424,7 +444,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
commitRequest.setPath(target.getEndpointPath() + "/commit"); commitRequest.setPath(target.getEndpointPath() + "/commit");
//Put the transferId on the query string //Put the transferId on the query string
commitRequest.setQueryString( commitRequest.setQueryString(
@@ -435,18 +455,18 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
checkResponseStatus("commit", responseStatus, commitRequest); checkResponseStatus("commit", responseStatus, commitRequest);
//If we get here then we've received a 200 response //If we get here then we've received a 200 response
//We're expecting the transfer id encoded in a JSON object... //We're expecting the transfer id encoded in a JSON object...
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.error(error, e); log.error(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"commit", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"commit", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
commitRequest.releaseConnection(); commitRequest.releaseConnection();
@@ -461,7 +481,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
prepareRequest.setPath(target.getEndpointPath() + "/prepare"); prepareRequest.setPath(target.getEndpointPath() + "/prepare");
//Put the transferId on the query string //Put the transferId on the query string
prepareRequest.setQueryString( prepareRequest.setQueryString(
@@ -472,18 +492,18 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
checkResponseStatus("prepare", responseStatus, prepareRequest); checkResponseStatus("prepare", responseStatus, prepareRequest);
//If we get here then we've received a 200 response //If we get here then we've received a 200 response
//We're expecting the transfer id encoded in a JSON object... //We're expecting the transfer id encoded in a JSON object...
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"prepare", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"prepare", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
prepareRequest.releaseConnection(); prepareRequest.releaseConnection();
@@ -491,7 +511,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
} }
/** /**
* *
*/ */
public void sendContent(Transfer transfer, Set<ContentData> data) throws TransferException public void sendContent(Transfer transfer, Set<ContentData> data) throws TransferException
{ {
@@ -514,54 +534,54 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
//Put the transferId on the query string //Put the transferId on the query string
postContentRequest.setQueryString( postContentRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
//Put the transferId on the query string //Put the transferId on the query string
postContentRequest.setQueryString( postContentRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
Part[] parts = new Part[data.size()]; Part[] parts = new Part[data.size()];
int index = 0; int index = 0;
for(ContentData content : data) for(ContentData content : data)
{ {
String contentUrl = content.getContentUrl(); String contentUrl = content.getContentUrl();
String fileName = TransferCommons.URLToPartName(contentUrl); String fileName = TransferCommons.URLToPartName(contentUrl);
log.debug("content partName: " + fileName); log.debug("content partName: " + fileName);
parts[index++] = new ContentDataPart(getContentService(), fileName, content); parts[index++] = new ContentDataPart(getContentService(), fileName, content);
} }
MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts, postContentRequest.getParams()); MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts, postContentRequest.getParams());
postContentRequest.setRequestEntity(requestEntity); postContentRequest.setRequestEntity(requestEntity);
int responseStatus = httpClient.executeMethod(hostConfig, postContentRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, postContentRequest, httpState);
checkResponseStatus("sendContent", responseStatus, postContentRequest); checkResponseStatus("sendContent", responseStatus, postContentRequest);
if(log.isDebugEnabled()) if(log.isDebugEnabled())
{ {
log.debug("sent content"); log.debug("sent content");
} }
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"sendContent", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"sendContent", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
postContentRequest.releaseConnection(); postContentRequest.releaseConnection();
} }
} // end of sendContent } // end of sendContent
/** /**
* *
*/ */
public TransferProgress getStatus(Transfer transfer) throws TransferException public TransferProgress getStatus(Transfer transfer) throws TransferException
{ {
@@ -571,12 +591,12 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
statusRequest.setPath(target.getEndpointPath() + "/status"); statusRequest.setPath(target.getEndpointPath() + "/status");
//Put the transferId on the query string //Put the transferId on the query string
statusRequest.setQueryString( statusRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
try try
{ {
int responseStatus = httpClient.executeMethod(hostConfig, statusRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, statusRequest, httpState);
@@ -584,45 +604,45 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
//If we get here then we've received a 200 response //If we get here then we've received a 200 response
String statusPayload = statusRequest.getResponseBodyAsString(); String statusPayload = statusRequest.getResponseBodyAsString();
JSONObject statusObj = new JSONObject(statusPayload); JSONObject statusObj = new JSONObject(statusPayload);
//We're expecting the transfer progress encoded in a JSON object... //We're expecting the transfer progress encoded in a JSON object...
int currentPosition = statusObj.getInt("currentPosition"); int currentPosition = statusObj.getInt("currentPosition");
int endPosition = statusObj.getInt("endPosition"); int endPosition = statusObj.getInt("endPosition");
String statusStr= statusObj.getString("status"); String statusStr= statusObj.getString("status");
TransferProgress p = new TransferProgress(); TransferProgress p = new TransferProgress();
if(statusObj.has("error")) if(statusObj.has("error"))
{ {
JSONObject errorJSON = statusObj.getJSONObject("error"); JSONObject errorJSON = statusObj.getJSONObject("error");
Throwable throwable = rehydrateError(errorJSON); Throwable throwable = rehydrateError(errorJSON);
p.setError(throwable); p.setError(throwable);
} }
p.setStatus(TransferProgress.Status.valueOf(statusStr)); p.setStatus(TransferProgress.Status.valueOf(statusStr));
p.setCurrentPosition(currentPosition); p.setCurrentPosition(currentPosition);
p.setEndPosition(endPosition); p.setEndPosition(endPosition);
return p; return p;
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"status", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"status", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
statusRequest.releaseConnection(); statusRequest.releaseConnection();
} }
} }
/** /**
* *
*/ */
public void getTransferReport(Transfer transfer, OutputStream result) public void getTransferReport(Transfer transfer, OutputStream result)
{ {
@@ -632,20 +652,20 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
HostConfiguration hostConfig = getHostConfig(target); HostConfiguration hostConfig = getHostConfig(target);
HttpState httpState = getHttpState(target); HttpState httpState = getHttpState(target);
try try
{ {
getReportRequest.setPath(target.getEndpointPath() + "/report"); getReportRequest.setPath(target.getEndpointPath() + "/report");
//Put the transferId on the query string //Put the transferId on the query string
getReportRequest.setQueryString( getReportRequest.setQueryString(
new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
int responseStatus = httpClient.executeMethod(hostConfig, getReportRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, getReportRequest, httpState);
checkResponseStatus("getReport", responseStatus, getReportRequest); checkResponseStatus("getReport", responseStatus, getReportRequest);
InputStream is = getReportRequest.getResponseBodyAsStream(); InputStream is = getReportRequest.getResponseBodyAsStream();
// Now copy the response input stream to result. // Now copy the response input stream to result.
final ReadableByteChannel inputChannel = Channels.newChannel(is); final ReadableByteChannel inputChannel = Channels.newChannel(is);
final WritableByteChannel outputChannel = Channels.newChannel(result); final WritableByteChannel outputChannel = Channels.newChannel(result);
@@ -660,46 +680,46 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
inputChannel.close(); inputChannel.close();
outputChannel.close(); outputChannel.close();
} }
return; return;
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
throw e; throw e;
} }
catch (Exception e) catch (Exception e)
{ {
String error = "Failed to execute HTTP request to target"; String error = "Failed to execute HTTP request to target";
log.debug(error, e); log.debug(error, e);
throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"getTransferReport", target.toString(), e.toString()}, e); throw new TransferException(MSG_HTTP_REQUEST_FAILED, new Object[]{"getTransferReport", target.toString(), e.toString()}, e);
} }
} }
finally finally
{ {
getReportRequest.releaseConnection(); getReportRequest.releaseConnection();
} }
} }
private static void channelCopy(final ReadableByteChannel src, final WritableByteChannel dest) throws IOException private static void channelCopy(final ReadableByteChannel src, final WritableByteChannel dest) throws IOException
{ {
final ByteBuffer buffer = ByteBuffer.allocateDirect(2 * 1024); final ByteBuffer buffer = ByteBuffer.allocateDirect(2 * 1024);
while (src.read(buffer) != -1) while (src.read(buffer) != -1)
{ {
// prepare the buffer to be drained // prepare the buffer to be drained
buffer.flip(); buffer.flip();
// write to the channel, may block // write to the channel, may block
dest.write(buffer); dest.write(buffer);
// If partial transfer, shift remainder down // If partial transfer, shift remainder down
// If buffer is empty, same as doing clear() // If buffer is empty, same as doing clear()
buffer.compact(); buffer.compact();
} }
// EOF will leave buffer in fill state // EOF will leave buffer in fill state
buffer.flip(); buffer.flip();
// make sure the buffer is fully drained. // make sure the buffer is fully drained.
while (buffer.hasRemaining()) while (buffer.hasRemaining())
{ {
dest.write(buffer); dest.write(buffer);
} }
@@ -709,20 +729,20 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
return httpMethodFactory.createPostMethod(); return httpMethodFactory.createPostMethod();
} }
/** /**
* *
* @param errorJSON A JSON object expected to hold the name of the error class ("errorType"), * @param errorJSON A JSON object expected to hold the name of the error class ("errorType"),
* the error message ("errorMessage"), and, optionally, the Alfresco message id ("alfrescoErrorId") * the error message ("errorMessage"), and, optionally, the Alfresco message id ("alfrescoErrorId")
* and Alfresco message parameters ("alfrescoErrorParams"). * and Alfresco message parameters ("alfrescoErrorParams").
* @return The rehydrated error object, or null if errorJSON is null. * @return The rehydrated error object, or null if errorJSON is null.
* @throws JSONException if an error occurs while parsing the supplied JSON object * @throws JSONException if an error occurs while parsing the supplied JSON object
*/ */
private Throwable rehydrateError(JSONObject errorJSON) private Throwable rehydrateError(JSONObject errorJSON)
{ {
return jsonErrorSerializer.deserialize(errorJSON); return jsonErrorSerializer.deserialize(errorJSON);
} }
public void setContentService(ContentService contentService) public void setContentService(ContentService contentService)
{ {
this.contentService = contentService; this.contentService = contentService;
@@ -741,5 +761,26 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
public void setJsonErrorSerializer(JsonSerializer<Throwable, JSONObject> jsonErrorSerializer) public void setJsonErrorSerializer(JsonSerializer<Throwable, JSONObject> jsonErrorSerializer)
{ {
this.jsonErrorSerializer = jsonErrorSerializer; this.jsonErrorSerializer = jsonErrorSerializer;
} }
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
private NodeRef getFileTransferRootNodeRef(NodeRef transferNodeRef)
{
//testing if transferring to file system
if(!nodeService.hasAspect(transferNodeRef, TransferModel.ASPECT_FILE_TRANSFER_TARGET))
return null;
//get association
List<AssociationRef> assocs = nodeService.getTargetAssocs(transferNodeRef, TransferModel.ASSOC_ROOT_FILE_TRANSFER);
if(assocs.size() == 0 || assocs.size() > 1)
return null;
return assocs.get(0).getTargetRef();
}
} }

View File

@@ -106,7 +106,7 @@ import org.springframework.util.FileCopyUtils;
* *
* @author brian * @author brian
*/ */
public class RepoTransferReceiverImpl implements TransferReceiver, public class RepoTransferReceiverImpl implements TransferReceiver,
NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateChildAssociationPolicy,
NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy,
NodeServicePolicies.OnRestoreNodePolicy, NodeServicePolicies.OnRestoreNodePolicy,
@@ -115,9 +115,9 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
/** /**
* This embedded class is used to push requests for asynchronous commits onto a different thread * This embedded class is used to push requests for asynchronous commits onto a different thread
* *
* @author Brian * @author Brian
* *
*/ */
public class AsyncCommitCommand implements Runnable public class AsyncCommitCommand implements Runnable
{ {
@@ -171,7 +171,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
private static final String MSG_LOCK_NOT_FOUND = "transfer_service.receiver.lock_not_found"; private static final String MSG_LOCK_NOT_FOUND = "transfer_service.receiver.lock_not_found";
private static final String MSG_TRANSFER_TO_SELF = "transfer_service.receiver.error.transfer_to_self"; private static final String MSG_TRANSFER_TO_SELF = "transfer_service.receiver.error.transfer_to_self";
private static final String MSG_INCOMPATIBLE_VERSIONS = "transfer_service.incompatible_versions"; private static final String MSG_INCOMPATIBLE_VERSIONS = "transfer_service.incompatible_versions";
private static final String SNAPSHOT_FILE_NAME = "snapshot.xml"; private static final String SNAPSHOT_FILE_NAME = "snapshot.xml";
private NodeService nodeService; private NodeService nodeService;
@@ -192,49 +192,49 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
private AlienProcessor alienProcessor; private AlienProcessor alienProcessor;
private JobLockService jobLockService; private JobLockService jobLockService;
private TransferVersionChecker transferVersionChecker; private TransferVersionChecker transferVersionChecker;
/** /**
* Where the temporary files are stored. Tenant Domain Name, NodeRef * Where the temporary files are stored. Tenant Domain Name, NodeRef
*/ */
private Map<String,NodeRef> transferTempFolderMap = new ConcurrentHashMap<String, NodeRef>(); private Map<String,NodeRef> transferTempFolderMap = new ConcurrentHashMap<String, NodeRef>();
/** /**
* Where the destination side transfer report is generated. Tenant Domain Name, NodeRef * Where the destination side transfer report is generated. Tenant Domain Name, NodeRef
*/ */
private Map<String,NodeRef> inboundTransferRecordsFolderMap = new ConcurrentHashMap<String, NodeRef>(); private Map<String,NodeRef> inboundTransferRecordsFolderMap = new ConcurrentHashMap<String, NodeRef>();
private ClassPolicyDelegate<BeforeStartInboundTransferPolicy> beforeStartInboundTransferDelegate; private ClassPolicyDelegate<BeforeStartInboundTransferPolicy> beforeStartInboundTransferDelegate;
private ClassPolicyDelegate<OnStartInboundTransferPolicy> onStartInboundTransferDelegate; private ClassPolicyDelegate<OnStartInboundTransferPolicy> onStartInboundTransferDelegate;
private ClassPolicyDelegate<OnEndInboundTransferPolicy> onEndInboundTransferDelegate; private ClassPolicyDelegate<OnEndInboundTransferPolicy> onEndInboundTransferDelegate;
/** /**
* Locks for the transfers in progress * Locks for the transfers in progress
* <p> * <p>
* TransferId, Lock * TransferId, Lock
*/ */
private Map<String, Lock> locks = new ConcurrentHashMap<String, Lock>(); private Map<String, Lock> locks = new ConcurrentHashMap<String, Lock>();
/** /**
* How many mS before refreshing the lock? * How many mS before refreshing the lock?
*/ */
private long lockRefreshTime = 60000; private long lockRefreshTime = 60000;
/** /**
* How many times to retry to obtain the lock * How many times to retry to obtain the lock
*/ */
private int lockRetryCount = 2; private int lockRetryCount = 2;
/** /**
* How long to wait between retries * How long to wait between retries
*/ */
private long lockRetryWait = 100; private long lockRetryWait = 100;
/** /**
* How long in mS to keep the lock before giving up and ending the transfer, * How long in mS to keep the lock before giving up and ending the transfer,
* possibly the client has terminated? * possibly the client has terminated?
*/ */
private long lockTimeOut = 3600000; private long lockTimeOut = 3600000;
public void init() public void init()
{ {
PropertyCheck.mandatory(this, "nodeService", nodeService); PropertyCheck.mandatory(this, "nodeService", nodeService);
@@ -262,15 +262,15 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
*/ */
this.getPolicyComponent().bindAssociationBehaviour( this.getPolicyComponent().bindAssociationBehaviour(
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
TransferModel.ASPECT_TRANSFERRED, TransferModel.ASPECT_TRANSFERRED,
new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT));
/** /**
* For every update of a transferred node * For every update of a transferred node
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
ContentServicePolicies.OnContentUpdatePolicy.QNAME, ContentServicePolicies.OnContentUpdatePolicy.QNAME,
TransferModel.ASPECT_TRANSFERRED, TransferModel.ASPECT_TRANSFERRED,
new JavaBehaviour(this, "onContentUpdate", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onContentUpdate", NotificationFrequency.EVERY_EVENT));
/** /**
@@ -278,53 +278,53 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
CopyServicePolicies.OnCopyNodePolicy.QNAME, CopyServicePolicies.OnCopyNodePolicy.QNAME,
TransferModel.ASPECT_TRANSFERRED, TransferModel.ASPECT_TRANSFERRED,
new JavaBehaviour(this, "onCopyTransferred", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onCopyTransferred", NotificationFrequency.EVERY_EVENT));
/** /**
* For every new child of a node with the trx:alien aspect run this.onCreateChildAssociation * For every new child of a node with the trx:alien aspect run this.onCreateChildAssociation
*/ */
this.getPolicyComponent().bindAssociationBehaviour( this.getPolicyComponent().bindAssociationBehaviour(
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
TransferModel.ASPECT_ALIEN, TransferModel.ASPECT_ALIEN,
new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT));
/** /**
* For every node with the trx:alien aspect run this.beforeDeleteNode * For every node with the trx:alien aspect run this.beforeDeleteNode
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
NodeServicePolicies.BeforeDeleteNodePolicy.QNAME, NodeServicePolicies.BeforeDeleteNodePolicy.QNAME,
TransferModel.ASPECT_ALIEN, TransferModel.ASPECT_ALIEN,
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT));
/** /**
* For every restore of a node with the trx:alien aspect * For every restore of a node with the trx:alien aspect
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
NodeServicePolicies.OnRestoreNodePolicy.QNAME, NodeServicePolicies.OnRestoreNodePolicy.QNAME,
TransferModel.ASPECT_ALIEN, TransferModel.ASPECT_ALIEN,
new JavaBehaviour(this, "onRestoreNode", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onRestoreNode", NotificationFrequency.EVERY_EVENT));
/** /**
* For every move of a node with the trx:alien aspect. * For every move of a node with the trx:alien aspect.
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
NodeServicePolicies.OnMoveNodePolicy.QNAME, NodeServicePolicies.OnMoveNodePolicy.QNAME,
TransferModel.ASPECT_ALIEN, TransferModel.ASPECT_ALIEN,
new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT));
/** /**
* For every copy of an alien node remove the alien aspect * For every copy of an alien node remove the alien aspect
*/ */
this.getPolicyComponent().bindClassBehaviour( this.getPolicyComponent().bindClassBehaviour(
CopyServicePolicies.OnCopyNodePolicy.QNAME, CopyServicePolicies.OnCopyNodePolicy.QNAME,
TransferModel.ASPECT_ALIEN, TransferModel.ASPECT_ALIEN,
new JavaBehaviour(this, "onCopyAlien", NotificationFrequency.EVERY_EVENT)); new JavaBehaviour(this, "onCopyAlien", NotificationFrequency.EVERY_EVENT));
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.alfresco.repo.web.scripts.transfer.TransferReceiver#getStagingFolder(org.alfresco.service.cmr.repository. * org.alfresco.repo.web.scripts.transfer.TransferReceiver#getStagingFolder(org.alfresco.service.cmr.repository.
* NodeRef) * NodeRef)
@@ -355,7 +355,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser()); String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
NodeRef transferTempFolder = transferTempFolderMap.get(tenantDomain); NodeRef transferTempFolder = transferTempFolderMap.get(tenantDomain);
// Have we already resolved the node that is the temp folder? // Have we already resolved the node that is the temp folder?
// If not then do so. // If not then do so.
if (transferTempFolder == null) if (transferTempFolder == null)
@@ -401,28 +401,28 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.repo.web.scripts.transfer.TransferReceiver#start() * @see org.alfresco.repo.web.scripts.transfer.TransferReceiver#start()
*/ */
public String start(String fromRepositoryId, boolean transferToSelf, TransferVersion fromVersion) public String start(String fromRepositoryId, boolean transferToSelf, TransferVersion fromVersion)
{ {
log.debug("Start transfer"); log.debug("Start transfer");
/** /**
* Check that transfer is allowed to this repository * Check that transfer is allowed to this repository
*/ */
checkTransfer(fromRepositoryId, transferToSelf); checkTransfer(fromRepositoryId, transferToSelf);
/** /**
* Check that the versions are compatible * Check that the versions are compatible
*/ */
TransferVersion toVersion = getVersion(); TransferVersion toVersion = getVersion();
if(!getTransferVersionChecker().checkTransferVersions(fromVersion, toVersion)) if(!getTransferVersionChecker().checkTransferVersions(fromVersion, toVersion))
{ {
throw new TransferException(MSG_INCOMPATIBLE_VERSIONS, new Object[] {"None", fromVersion, toVersion}); throw new TransferException(MSG_INCOMPATIBLE_VERSIONS, new Object[] {"None", fromVersion, toVersion});
} }
/** /**
* First get the transfer lock for this domain * First get the transfer lock for this domain
*/ */
@@ -430,15 +430,15 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
String lockStr = tenantDomain.isEmpty() ? "transfer.server.default" : "transfer.server.tenant." + tenantDomain; String lockStr = tenantDomain.isEmpty() ? "transfer.server.default" : "transfer.server.tenant." + tenantDomain;
QName lockQName = QName.createQName(TransferModel.TRANSFER_MODEL_1_0_URI, lockStr); QName lockQName = QName.createQName(TransferModel.TRANSFER_MODEL_1_0_URI, lockStr);
Lock lock = new Lock(lockQName); Lock lock = new Lock(lockQName);
try try
{ {
TransferServicePolicies.BeforeStartInboundTransferPolicy beforeStartPolicy = TransferServicePolicies.BeforeStartInboundTransferPolicy beforeStartPolicy =
beforeStartInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD); beforeStartInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD);
beforeStartPolicy.beforeStartInboundTransfer(); beforeStartPolicy.beforeStartInboundTransfer();
lock.makeLock(); lock.makeLock();
/** /**
* Transfer Lock held if we get this far * Transfer Lock held if we get this far
*/ */
@@ -450,7 +450,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
* Now create a transfer record and use its NodeRef as the transfer id * Now create a transfer record and use its NodeRef as the transfer id
*/ */
RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper(); RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();
transferId = txHelper.doInTransaction( transferId = txHelper.doInTransaction(
new RetryingTransactionHelper.RetryingTransactionCallback<String>() new RetryingTransactionHelper.RetryingTransactionCallback<String>()
{ {
@@ -461,10 +461,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
getTempFolder(transferId); getTempFolder(transferId);
getStagingFolder(transferId); getStagingFolder(transferId);
TransferServicePolicies.OnStartInboundTransferPolicy onStartPolicy = TransferServicePolicies.OnStartInboundTransferPolicy onStartPolicy =
onStartInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD); onStartInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD);
onStartPolicy.onStartInboundTransfer(transferId); onStartPolicy.onStartInboundTransfer(transferId);
return transferId; return transferId;
} }
}, false, true); }, false, true);
@@ -476,7 +476,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
lock.releaseLock(); lock.releaseLock();
throw new TransferException(MSG_ERROR_WHILE_STARTING, e); throw new TransferException(MSG_ERROR_WHILE_STARTING, e);
} }
/** /**
* Here if we have begun a transfer and have a valid transfer id * Here if we have begun a transfer and have a valid transfer id
*/ */
@@ -485,7 +485,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.info("transfer started:" + transferId); log.info("transfer started:" + transferId);
lock.enableLockTimeout(); lock.enableLockTimeout();
return transferId; return transferId;
} }
catch (LockAcquisitionException lae) catch (LockAcquisitionException lae)
{ {
@@ -525,7 +525,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ"); SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
String timeNow = format.format(new Date()); String timeNow = format.format(new Date());
String name = timeNow + ".xml"; String name = timeNow + ".xml";
QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name); QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name);
Map<QName, Serializable> props = new HashMap<QName, Serializable>(); Map<QName, Serializable> props = new HashMap<QName, Serializable>();
@@ -541,33 +541,33 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
return assoc.getChildRef(); return assoc.getChildRef();
} }
/** /**
* Timeout a transfer. Called after the lock has been released via a timeout. * Timeout a transfer. Called after the lock has been released via a timeout.
* *
* This is the last chance to clean up. * This is the last chance to clean up.
* *
* @param transferId * @param transferId
*/ */
private void timeout(final String transferId) private void timeout(final String transferId)
{ {
log.info("Inbound Transfer has timed out transferId:" + transferId); log.info("Inbound Transfer has timed out transferId:" + transferId);
/* /*
* There is no transaction or authentication context in this method since it is called via a * There is no transaction or authentication context in this method since it is called via a
* timer thread. * timer thread.
*/ */
final RetryingTransactionCallback<Void> timeoutCB = new RetryingTransactionCallback<Void>() { final RetryingTransactionCallback<Void> timeoutCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
TransferProgress progress = getProgressMonitor().getProgress(transferId); TransferProgress progress = getProgressMonitor().getProgress(transferId);
if (progress.getStatus().equals(TransferProgress.Status.PRE_COMMIT)) if (progress.getStatus().equals(TransferProgress.Status.PRE_COMMIT))
{ {
log.warn("Inbound Transfer Lock Timeout - transferId:" + transferId); log.warn("Inbound Transfer Lock Timeout - transferId:" + transferId);
/** /**
* Did not get out of PRE_COMMIT. The client has probably "gone away" after calling * Did not get out of PRE_COMMIT. The client has probably "gone away" after calling
* "start", but before calling commit, cancel or error. * "start", but before calling commit, cancel or error.
*/ */
locks.remove(transferId); locks.remove(transferId);
@@ -578,28 +578,28 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
else else
{ {
// We got beyond PRE_COMMIT, therefore leave the clean up to either // We got beyond PRE_COMMIT, therefore leave the clean up to either
// commit, cancel or error command, since there may still be "in-flight" // commit, cancel or error command, since there may still be "in-flight"
// transfer in another thread. Although why, in that case, are we here? // transfer in another thread. Although why, in that case, are we here?
log.warn("Inbound Transfer Lock Timeout - already past PRE-COMMIT - do no cleanup transferId:" + transferId); log.warn("Inbound Transfer Lock Timeout - already past PRE-COMMIT - do no cleanup transferId:" + transferId);
} }
return null; return null;
} }
}; };
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>() AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>()
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
transactionService.getRetryingTransactionHelper().doInTransaction(timeoutCB, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(timeoutCB, false, true);
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.repo.web.scripts.transfer.TransferReceiver#end(org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.repo.web.scripts.transfer.TransferReceiver#end(org.alfresco.service.cmr.repository.NodeRef)
*/ */
public void end(final String transferId) public void end(final String transferId)
@@ -622,9 +622,9 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
lock.releaseLock(); lock.releaseLock();
locks.remove(lock); locks.remove(lock);
} }
removeTempFolders(transferId); removeTempFolders(transferId);
//Fire the OnEndInboundTransfer policy //Fire the OnEndInboundTransfer policy
Set<NodeRef> createdNodes = Collections.emptySet(); Set<NodeRef> createdNodes = Collections.emptySet();
@@ -637,7 +637,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
updatedNodes = new HashSet<NodeRef>(changesRecord.getUpdatedNodes()); updatedNodes = new HashSet<NodeRef>(changesRecord.getUpdatedNodes());
deletedNodes = new HashSet<NodeRef>(changesRecord.getDeletedNodes()); deletedNodes = new HashSet<NodeRef>(changesRecord.getDeletedNodes());
} }
TransferServicePolicies.OnEndInboundTransferPolicy onEndPolicy = TransferServicePolicies.OnEndInboundTransferPolicy onEndPolicy =
onEndInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD); onEndInboundTransferDelegate.get(TransferModel.TYPE_TRANSFER_RECORD);
onEndPolicy.onEndInboundTransfer(transferId, createdNodes, updatedNodes, deletedNodes); onEndPolicy.onEndInboundTransfer(transferId, createdNodes, updatedNodes, deletedNodes);
} }
@@ -663,10 +663,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
catch (Exception ex) catch (Exception ex)
{ {
log.warn("Failed to delete temp store node for transfer id " + transferId + log.warn("Failed to delete temp store node for transfer id " + transferId +
"\nTemp store noderef = " + tempStoreNode); "\nTemp store noderef = " + tempStoreNode);
} }
File stagingFolder = null; File stagingFolder = null;
try try
{ {
@@ -678,7 +678,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
catch(Exception ex) catch(Exception ex)
{ {
log.warn("Failed to delete staging folder for transfer id " + transferId + log.warn("Failed to delete staging folder for transfer id " + transferId +
"\nStaging folder = " + stagingFolder.toString()); "\nStaging folder = " + stagingFolder.toString());
} }
} }
@@ -701,7 +701,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
Lock lock = checkLock(transferId); Lock lock = checkLock(transferId);
try try
{ {
} }
finally finally
{ {
@@ -728,10 +728,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
file.delete(); file.delete();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.service.cmr.transfer.TransferReceiver#nudgeLock(java.lang.String) * @see org.alfresco.service.cmr.transfer.TransferReceiver#nudgeLock(java.lang.String)
*/ */
public Lock checkLock(final String transferId) throws TransferException public Lock checkLock(final String transferId) throws TransferException
@@ -740,7 +740,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
throw new IllegalArgumentException("nudgeLock: transferId = null"); throw new IllegalArgumentException("nudgeLock: transferId = null");
} }
Lock lock = locks.get(transferId); Lock lock = locks.get(transferId);
if(lock != null) if(lock != null)
{ {
@@ -754,7 +754,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
// lock is no longer active // lock is no longer active
log.debug("lock not active"); log.debug("lock not active");
throw new TransferException(MSG_LOCK_TIMED_OUT, new Object[]{transferId}); throw new TransferException(MSG_LOCK_TIMED_OUT, new Object[]{transferId});
} }
} }
else else
@@ -767,7 +767,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.service.cmr.transfer.TransferReceiver#saveSnapshot(java.io.InputStream) * @see org.alfresco.service.cmr.transfer.TransferReceiver#saveSnapshot(java.io.InputStream)
*/ */
public void saveSnapshot(String transferId, InputStream openStream) throws TransferException public void saveSnapshot(String transferId, InputStream openStream) throws TransferException
@@ -780,7 +780,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
log.debug("Saving snapshot for transferId =" + transferId); log.debug("Saving snapshot for transferId =" + transferId);
} }
File snapshotFile = new File(getStagingFolder(transferId), SNAPSHOT_FILE_NAME); File snapshotFile = new File(getStagingFolder(transferId), SNAPSHOT_FILE_NAME);
try try
{ {
@@ -806,7 +806,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.service.cmr.transfer.TransferReceiver#saveContent(java.lang.String, java.lang.String, * @see org.alfresco.service.cmr.transfer.TransferReceiver#saveContent(java.lang.String, java.lang.String,
* java.io.InputStream) * java.io.InputStream)
*/ */
@@ -815,7 +815,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
Lock lock = checkLock(transferId); Lock lock = checkLock(transferId);
try try
{ {
File stagedFile = new File(getStagingFolder(transferId), contentFileId); File stagedFile = new File(getStagingFolder(transferId), contentFileId);
if (stagedFile.createNewFile()) if (stagedFile.createNewFile())
{ {
@@ -836,7 +836,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
/** /**
* A side-effect of checking the lock here is that the lock timeout is suspended. * A side-effect of checking the lock here is that the lock timeout is suspended.
* *
*/ */
Lock lock = checkLock(transferId); Lock lock = checkLock(transferId);
try try
@@ -857,13 +857,13 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
* Error somewhere in the action service? * Error somewhere in the action service?
*/ */
//TODO consider whether the methods in this class should be retried/retryable.. //TODO consider whether the methods in this class should be retried/retryable..
// need to re-enable the lock timeout otherwise we will hold the lock forever... // need to re-enable the lock timeout otherwise we will hold the lock forever...
lock.enableLockTimeout(); lock.enableLockTimeout();
throw new TransferException(MSG_ERROR_WHILE_COMMITTING_TRANSFER, new Object[]{transferId}, error); throw new TransferException(MSG_ERROR_WHILE_COMMITTING_TRANSFER, new Object[]{transferId}, error);
} }
/** /**
* Lock intentionally not re-enabled here * Lock intentionally not re-enabled here
*/ */
@@ -875,18 +875,18 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
log.debug("Committing transferId=" + transferId); log.debug("Committing transferId=" + transferId);
} }
/** /**
* A side-effect of checking the lock here is that it ensures that the lock timeout is suspended. * A side-effect of checking the lock here is that it ensures that the lock timeout is suspended.
*/ */
checkLock(transferId); checkLock(transferId);
/** /**
* Turn off rules while transfer is being committed. * Turn off rules while transfer is being committed.
*/ */
boolean rulesEnabled = ruleService.isEnabled(); boolean rulesEnabled = ruleService.isEnabled();
ruleService.disableRules(); ruleService.disableRules();
try try
{ {
/* lock is going to be released */ checkLock(transferId); /* lock is going to be released */ checkLock(transferId);
@@ -919,7 +919,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
//behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE); //behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableAllBehaviours(); behaviourFilter.disableAllBehaviours();
try try
{ {
parser.parse(snapshotFile, reader); parser.parse(snapshotFile, reader);
@@ -984,7 +984,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
*/ */
ruleService.enableRules(); ruleService.enableRules();
} }
/** /**
* Clean up at the end of the transfer * Clean up at the end of the transfer
*/ */
@@ -1116,7 +1116,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
this.actionService = actionService; this.actionService = actionService;
} }
/** /**
* Set the ruleService * Set the ruleService
* @param ruleService * @param ruleService
@@ -1142,7 +1142,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
public void generateRequsite(String transferId, OutputStream out) throws TransferException public void generateRequsite(String transferId, OutputStream out) throws TransferException
{ {
log.debug("Generate Requsite for transfer:" + transferId); log.debug("Generate Requsite for transfer:" + transferId);
try try
{ {
File snapshotFile = getSnapshotFile(transferId); File snapshotFile = getSnapshotFile(transferId);
@@ -1150,12 +1150,12 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
log.debug("snapshot does exist"); log.debug("snapshot does exist");
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
SAXParser parser = saxParserFactory.newSAXParser(); SAXParser parser = saxParserFactory.newSAXParser();
OutputStreamWriter dest = new OutputStreamWriter(out, "UTF-8"); OutputStreamWriter dest = new OutputStreamWriter(out, "UTF-8");
XMLTransferRequsiteWriter writer = new XMLTransferRequsiteWriter(dest); XMLTransferRequsiteWriter writer = new XMLTransferRequsiteWriter(dest);
TransferManifestProcessor processor = manifestProcessorFactory.getRequsiteProcessor( TransferManifestProcessor processor = manifestProcessorFactory.getRequsiteProcessor(
RepoTransferReceiverImpl.this, RepoTransferReceiverImpl.this,
transferId, transferId,
writer); writer);
@@ -1165,15 +1165,15 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
* Now run the parser * Now run the parser
*/ */
parser.parse(snapshotFile, reader); parser.parse(snapshotFile, reader);
/** /**
* And flush the destination in case any content remains in the writer. * And flush the destination in case any content remains in the writer.
*/ */
dest.flush(); dest.flush();
} }
log.debug("Generate Requsite done transfer:" + transferId); log.debug("Generate Requsite done transfer:" + transferId);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1187,7 +1187,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
} }
} }
public InputStream getTransferReport(String transferId) public InputStream getTransferReport(String transferId)
{ {
return progressMonitor.getLogInputStream(transferId); return progressMonitor.getLogInputStream(transferId);
@@ -1205,21 +1205,21 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
/** /**
* When a new node is created as a child of a Transferred or Alien node then * When a new node is created as a child of a Transferred or Alien node then
* the new node needs to be marked as an alien. * the new node needs to be marked as an alien.
* <p> * <p>
* Then the tree needs to be walked upwards to mark all parent * Then the tree needs to be walked upwards to mark all parent
* transferred nodes as alien. * transferred nodes as alien.
*/ */
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, public void onCreateChildAssociation(ChildAssociationRef childAssocRef,
boolean isNewNode) boolean isNewNode)
{ {
log.debug("on create child association to transferred node"); log.debug("on create child association to transferred node");
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId(); final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
alienProcessor.onCreateChild(childAssocRef, localRepositoryId, isNewNode); alienProcessor.onCreateChild(childAssocRef, localRepositoryId, isNewNode);
} }
/** /**
* When an alien node is deleted the it may be the last alien invader * When an alien node is deleted the it may be the last alien invader
* <p> * <p>
@@ -1230,9 +1230,9 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.debug("on delete node - need to check for transferred node"); log.debug("on delete node - need to check for transferred node");
alienProcessor.beforeDeleteAlien(deletedNodeRef, null); alienProcessor.beforeDeleteAlien(deletedNodeRef, null);
} }
/** /**
* When a transferred node is restored it may be a new invader or it may no * When a transferred node is restored it may be a new invader or it may no
* longer be an invader. * longer be an invader.
* <p> * <p>
* Walk the tree checking the invasion status! * Walk the tree checking the invasion status!
@@ -1243,22 +1243,22 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.debug("restoredAssocRef:" + childAssocRef); log.debug("restoredAssocRef:" + childAssocRef);
alienProcessor.afterMoveAlien(childAssocRef); alienProcessor.afterMoveAlien(childAssocRef);
} }
/** /**
* When an alien node is moved it may un-invade its old location and invade a new * When an alien node is moved it may un-invade its old location and invade a new
* location. The node may also cease to be alien. * location. The node may also cease to be alien.
*/ */
public void onMoveNode(ChildAssociationRef oldChildAssocRef, public void onMoveNode(ChildAssociationRef oldChildAssocRef,
ChildAssociationRef newChildAssocRef) ChildAssociationRef newChildAssocRef)
{ {
log.debug("onMoveNode"); log.debug("onMoveNode");
log.debug("oldChildAssocRef:" + oldChildAssocRef); log.debug("oldChildAssocRef:" + oldChildAssocRef);
log.debug("newChildAssocRef:" + newChildAssocRef); log.debug("newChildAssocRef:" + newChildAssocRef);
NodeRef oldParentRef = oldChildAssocRef.getParentRef(); NodeRef oldParentRef = oldChildAssocRef.getParentRef();
NodeRef newParentRef = newChildAssocRef.getParentRef(); NodeRef newParentRef = newChildAssocRef.getParentRef();
if(newParentRef.equals(oldParentRef)) if(newParentRef.equals(oldParentRef))
{ {
log.debug("old parent and new parent are the same - this is a rename, do nothing"); log.debug("old parent and new parent are the same - this is a rename, do nothing");
@@ -1273,35 +1273,35 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
alienProcessor.afterMoveAlien(newChildAssocRef); alienProcessor.afterMoveAlien(newChildAssocRef);
} }
} }
/** /**
* When a transferred node is copied, don't copy the transferred aspect. * When a transferred node is copied, don't copy the transferred aspect.
*/ */
public CopyBehaviourCallback onCopyTransferred(QName classRef, public CopyBehaviourCallback onCopyTransferred(QName classRef,
CopyDetails copyDetails) CopyDetails copyDetails)
{ {
return TransferredAspectCopyBehaviourCallback.INSTANCE; return TransferredAspectCopyBehaviourCallback.INSTANCE;
} }
/** /**
* When an alien node is copied, don't copy the alien aspect. * When an alien node is copied, don't copy the alien aspect.
*/ */
public CopyBehaviourCallback onCopyAlien(QName classRef, public CopyBehaviourCallback onCopyAlien(QName classRef,
CopyDetails copyDetails) CopyDetails copyDetails)
{ {
return AlienAspectCopyBehaviourCallback.INSTANCE; return AlienAspectCopyBehaviourCallback.INSTANCE;
} }
/** /**
* Extends the default copy behaviour to prevent copying of transferred aspect and properties. * Extends the default copy behaviour to prevent copying of transferred aspect and properties.
* *
* @author Mark Rogers * @author Mark Rogers
* @since 3.4 * @since 3.4
*/ */
private static class TransferredAspectCopyBehaviourCallback extends DefaultCopyBehaviourCallback private static class TransferredAspectCopyBehaviourCallback extends DefaultCopyBehaviourCallback
{ {
private static final CopyBehaviourCallback INSTANCE = new TransferredAspectCopyBehaviourCallback(); private static final CopyBehaviourCallback INSTANCE = new TransferredAspectCopyBehaviourCallback();
/** /**
* @return Returns an empty map * @return Returns an empty map
*/ */
@@ -1311,10 +1311,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
return Collections.emptyMap(); return Collections.emptyMap();
} }
/** /**
* Don't copy the transferred aspect. * Don't copy the transferred aspect.
* *
* @return Returns <tt>true</tt> always * @return Returns <tt>true</tt> always
*/ */
@Override @Override
@@ -1330,17 +1330,17 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
} }
} }
/** /**
* Extends the default copy behaviour to prevent copying of alien aspect and properties. * Extends the default copy behaviour to prevent copying of alien aspect and properties.
* *
* @author Mark Rogers * @author Mark Rogers
* @since 3.4 * @since 3.4
*/ */
private static class AlienAspectCopyBehaviourCallback extends DefaultCopyBehaviourCallback private static class AlienAspectCopyBehaviourCallback extends DefaultCopyBehaviourCallback
{ {
private static final CopyBehaviourCallback INSTANCE = new AlienAspectCopyBehaviourCallback(); private static final CopyBehaviourCallback INSTANCE = new AlienAspectCopyBehaviourCallback();
/** /**
* @return Returns an empty map * @return Returns an empty map
*/ */
@@ -1350,10 +1350,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
return Collections.emptyMap(); return Collections.emptyMap();
} }
/** /**
* Don't copy the transferred aspect. * Don't copy the transferred aspect.
* *
* @return Returns <tt>true</tt> always * @return Returns <tt>true</tt> always
*/ */
@Override @Override
@@ -1370,7 +1370,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
} }
public void setDescriptorService(DescriptorService descriptorService) public void setDescriptorService(DescriptorService descriptorService)
{ {
this.descriptorService = descriptorService; this.descriptorService = descriptorService;
@@ -1380,7 +1380,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
return descriptorService; return descriptorService;
} }
public void setAlienProcessor(AlienProcessor alienProcessor) public void setAlienProcessor(AlienProcessor alienProcessor)
{ {
this.alienProcessor = alienProcessor; this.alienProcessor = alienProcessor;
@@ -1404,7 +1404,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
nodeService.setProperty(nodeRef, TransferModel.PROP_FROM_CONTENT, null); nodeService.setProperty(nodeRef, TransferModel.PROP_FROM_CONTENT, null);
} }
} }
public void setJobLockService(JobLockService jobLockService) public void setJobLockService(JobLockService jobLockService)
{ {
this.jobLockService = jobLockService; this.jobLockService = jobLockService;
@@ -1464,41 +1464,41 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
* The name of the lock - unique for each domain * The name of the lock - unique for each domain
*/ */
QName lockQName; QName lockQName;
/** /**
* The unique token for this lock instance. * The unique token for this lock instance.
*/ */
String lockToken; String lockToken;
/** /**
* The transfer that this lock belongs to. * The transfer that this lock belongs to.
*/ */
String transferId; String transferId;
/** /**
* Is the lock active ? * Is the lock active ?
*/ */
private boolean active = false; private boolean active = false;
/** /**
* Is the server processing ? * Is the server processing ?
*/ */
private boolean processing = false; private boolean processing = false;
/** /**
* When did we last check whether the lock is active * When did we last check whether the lock is active
*/ */
Date lastActive = new Date(); Date lastActive = new Date();
public Lock(QName lockQName) public Lock(QName lockQName)
{ {
this.lockQName = lockQName; this.lockQName = lockQName;
} }
/** /**
* Make the lock - called on main thread * Make the lock - called on main thread
* *
* @throws LockAquisitionException * @throws LockAquisitionException
*/ */
public void makeLock() public void makeLock()
@@ -1507,14 +1507,14 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
log.debug("makeLock" + lockQName); log.debug("makeLock" + lockQName);
} }
lockToken = getJobLockService().getLock(lockQName, getLockRefreshTime(), getLockRetryWait(), getLockRetryCount()); lockToken = getJobLockService().getLock(lockQName, getLockRefreshTime(), getLockRetryWait(), getLockRetryCount());
synchronized(this) synchronized(this)
{ {
active = true; active = true;
} }
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{ {
log.debug("lock taken: name" + lockQName + " token:" +lockToken); log.debug("lock taken: name" + lockQName + " token:" +lockToken);
@@ -1523,10 +1523,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
getJobLockService().refreshLock(lockToken, lockQName, getLockRefreshTime(), this); getJobLockService().refreshLock(lockToken, lockQName, getLockRefreshTime(), this);
log.debug("refreshLock callback registered"); log.debug("refreshLock callback registered");
} }
/** /**
* Check that the lock is still active * Check that the lock is still active
* *
* Called on main transfer thread as transfer proceeds. * Called on main transfer thread as transfer proceeds.
* @throws TransferException (Lock timeout) * @throws TransferException (Lock timeout)
*/ */
@@ -1535,7 +1535,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.debug("suspend lock called"); log.debug("suspend lock called");
if(active) if(active)
{ {
processing = true; processing = true;
} }
else else
{ {
@@ -1544,24 +1544,24 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
throw new TransferException(MSG_LOCK_TIMED_OUT); throw new TransferException(MSG_LOCK_TIMED_OUT);
} }
} }
public void enableLockTimeout() public void enableLockTimeout()
{ {
Date now = new Date(); Date now = new Date();
// Update lastActive to 1S boundary // Update lastActive to 1S boundary
if(now.getTime() > lastActive.getTime() + 1000) if(now.getTime() > lastActive.getTime() + 1000)
{ {
lastActive = new Date(); lastActive = new Date();
log.debug("start waiting : lastActive:" + lastActive); log.debug("start waiting : lastActive:" + lastActive);
} }
processing = false; processing = false;
} }
/** /**
* Release the lock * Release the lock
* *
* Called on main thread * Called on main thread
*/ */
public void releaseLock() public void releaseLock()
@@ -1570,7 +1570,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
{ {
log.debug("transfer service about to releaseLock : " + lockQName); log.debug("transfer service about to releaseLock : " + lockQName);
} }
synchronized(this) synchronized(this)
{ {
if(active) if(active)
@@ -1580,7 +1580,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
active = false; active = false;
} }
} }
/** /**
* Called by Job Lock Service to determine whether the lock is still active * Called by Job Lock Service to determine whether the lock is still active
*/ */
@@ -1588,7 +1588,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
public boolean isActive() public boolean isActive()
{ {
Date now = new Date(); Date now = new Date();
synchronized(this) synchronized(this)
{ {
if(active) if(active)
@@ -1601,7 +1601,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
} }
} }
if(log.isDebugEnabled()) if(log.isDebugEnabled())
{ {
log.debug("transfer service callback isActive: " + active); log.debug("transfer service callback isActive: " + active);
@@ -1624,7 +1624,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.info("transfer service: lock has timed out, timeout :" + lockQName); log.info("transfer service: lock has timed out, timeout :" + lockQName);
timeout(transferId); timeout(transferId);
} }
active = false; active = false;
} }
} }
@@ -1642,7 +1642,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
log.debug("checkTransfer fromRepository:" + fromRepository + ", transferToSelf:" + transferToSelf ); log.debug("checkTransfer fromRepository:" + fromRepository + ", transferToSelf:" + transferToSelf );
} }
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId(); final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
if(!transferToSelf) if(!transferToSelf)
{ {
if(fromRepository != null) if(fromRepository != null)
@@ -1658,7 +1658,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
} }
} }
} }
public void setTransferVersionChecker(TransferVersionChecker transferVersionChecker) public void setTransferVersionChecker(TransferVersionChecker transferVersionChecker)
{ {
this.transferVersionChecker = transferVersionChecker; this.transferVersionChecker = transferVersionChecker;
@@ -1675,5 +1675,10 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
Descriptor d = descriptorService.getServerDescriptor(); Descriptor d = descriptorService.getServerDescriptor();
// needs to be serverDescriptor to pick up versionEdition // needs to be serverDescriptor to pick up versionEdition
return new TransferVersionImpl(d); return new TransferVersionImpl(d);
} }
public void setFileTransferRootNodeFileFileSystem(String rootFileSystem)
{
//just ignore, no relevant for transferring on file system
}
} }

View File

@@ -19,10 +19,10 @@
package org.alfresco.repo.transfer; package org.alfresco.repo.transfer;
/** /**
* A bucket for little odds and ends for the transfer service. * A bucket for little odds and ends for the transfer service.
* *
* If this becomes a big class then refactor it away. * If this becomes a big class then refactor it away.
* *
* @author Mark Rogers * @author Mark Rogers
*/ */
public class TransferCommons public class TransferCommons
@@ -31,45 +31,51 @@ public class TransferCommons
* The Mime Part Name of the manifest file * The Mime Part Name of the manifest file
*/ */
public final static String PART_NAME_MANIFEST = "manifest"; public final static String PART_NAME_MANIFEST = "manifest";
/** /**
* The Query String for the begin method. * The Query String for the begin method.
*/ */
public final static String PARAM_FROM_REPOSITORYID = "fromRepositoryId"; public final static String PARAM_FROM_REPOSITORYID = "fromRepositoryId";
/** /**
* The Query String for the begin method. * The Query String for the begin method.
*/ */
public final static String PARAM_ALLOW_TRANSFER_TO_SELF = "allowTransferToSelf"; public final static String PARAM_ALLOW_TRANSFER_TO_SELF = "allowTransferToSelf";
/** /**
* TransferId * TransferId
*/ */
public final static String PARAM_TRANSFER_ID = "transferId"; public final static String PARAM_TRANSFER_ID = "transferId";
/** /**
* Major version * Major version
*/ */
public final static String PARAM_VERSION_MAJOR = "versionMajor"; public final static String PARAM_VERSION_MAJOR = "versionMajor";
/** /**
* Minor version * Minor version
*/ */
public final static String PARAM_VERSION_MINOR = "versionMinor"; public final static String PARAM_VERSION_MINOR = "versionMinor";
/** /**
* Revision version * Revision version
*/ */
public final static String PARAM_VERSION_REVISION = "versionRevision"; public final static String PARAM_VERSION_REVISION = "versionRevision";
/** /**
* Edition * Edition
*/ */
public final static String PARAM_VERSION_EDITION = "versionEdition"; public final static String PARAM_VERSION_EDITION = "versionEdition";
/**
* File Root File Transfer
*/
public final static String PARAM_ROOT_FILE_TRANSFER = "rootFileTransfer";
/** /**
* Mapping between contentUrl and part name. * Mapping between contentUrl and part name.
* *
* @param URL * @param URL
* @return the part name * @return the part name
*/ */

View File

@@ -22,7 +22,7 @@ import org.alfresco.service.namespace.QName;
/** /**
* Transfer Model Constants * Transfer Model Constants
* *
* @author Mark Rogers * @author Mark Rogers
* @author Brian Remmington * @author Brian Remmington
*/ */
@@ -32,7 +32,7 @@ public interface TransferModel
static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable"); static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable");
// static final QName ASSOC_IMAP_ATTACHMENTS_FOLDER = QName.createQName(IMAP_MODEL_1_0_URI, "attachmentsFolder"); // static final QName ASSOC_IMAP_ATTACHMENTS_FOLDER = QName.createQName(IMAP_MODEL_1_0_URI, "attachmentsFolder");
/** /**
* Aspect : transferred * Aspect : transferred
*/ */
@@ -47,11 +47,17 @@ public interface TransferModel
static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien"); static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien");
static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy"); static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy");
/**
* Aspect : fileTransferTarget
*/
static final QName ASPECT_FILE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferTarget");
static final QName ASSOC_ROOT_FILE_TRANSFER = QName.createQName(TRANSFER_MODEL_1_0_URI, "rootFileTransfer");
/* /*
* Type : Transfer Group * Type : Transfer Group
*/ */
static final QName TYPE_TRANSFER_GROUP = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferGroup"); static final QName TYPE_TRANSFER_GROUP = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferGroup");
/* /*
* Type : Transfer Target * Type : Transfer Target
*/ */
@@ -62,7 +68,7 @@ public interface TransferModel
static final QName PROP_ENDPOINT_PATH = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointpath"); static final QName PROP_ENDPOINT_PATH = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointpath");
static final QName PROP_USERNAME = QName.createQName(TRANSFER_MODEL_1_0_URI, "username"); static final QName PROP_USERNAME = QName.createQName(TRANSFER_MODEL_1_0_URI, "username");
static final QName PROP_PASSWORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "password"); static final QName PROP_PASSWORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "password");
static final QName PROP_ENABLED = QName.createQName(TRANSFER_MODEL_1_0_URI, "enabled"); static final QName PROP_ENABLED = QName.createQName(TRANSFER_MODEL_1_0_URI, "enabled");
/* /*
@@ -79,7 +85,7 @@ public interface TransferModel
static final QName PROP_PROGRESS_ENDPOINT = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressEndpoint"); static final QName PROP_PROGRESS_ENDPOINT = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressEndpoint");
static final QName PROP_TRANSFER_STATUS = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferStatus"); static final QName PROP_TRANSFER_STATUS = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferStatus");
static final QName PROP_TRANSFER_ERROR = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferError"); static final QName PROP_TRANSFER_ERROR = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferError");
/* /*
* Type : Transfer report * Type : Transfer report
*/ */
@@ -91,5 +97,6 @@ public interface TransferModel
*/ */
static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore"); static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore");
static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan"); static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan");
} }

View File

@@ -27,9 +27,9 @@ public class TransferVersionImpl implements TransferVersion
private String versionMinor; private String versionMinor;
private String versionRevision; private String versionRevision;
private String edition; private String edition;
/** /**
* *
* @param versionMajor * @param versionMajor
* @param versionMinor * @param versionMinor
* @param versionRevision * @param versionRevision
@@ -42,7 +42,7 @@ public class TransferVersionImpl implements TransferVersion
this.versionRevision = versionRevision; this.versionRevision = versionRevision;
this.edition = edition; this.edition = edition;
} }
/** /**
* Construct a transferVersion from a system descriptor * Construct a transferVersion from a system descriptor
* @param d the system descriptor * @param d the system descriptor
@@ -54,7 +54,7 @@ public class TransferVersionImpl implements TransferVersion
this.versionRevision = d.getVersionRevision(); this.versionRevision = d.getVersionRevision();
this.edition = d.getEdition(); this.edition = d.getEdition();
} }
@Override @Override
public String getVersionMajor() public String getVersionMajor()
{ {
@@ -78,7 +78,7 @@ public class TransferVersionImpl implements TransferVersion
{ {
return edition; return edition;
} }
public String toString() public String toString()
{ {
StringBuilder version = new StringBuilder(); StringBuilder version = new StringBuilder();
@@ -89,10 +89,10 @@ public class TransferVersionImpl implements TransferVersion
version.append(getVersionMinor()); version.append(getVersionMinor());
version.append("."); version.append(".");
version.append(getVersionRevision()); version.append(getVersionRevision());
return version.toString(); return version.toString();
} }
public int hashCode() public int hashCode()
{ {
if(edition != null && versionMinor != null) if(edition != null && versionMinor != null)
@@ -104,18 +104,18 @@ public class TransferVersionImpl implements TransferVersion
return 1; return 1;
} }
} }
public boolean equals(Object other) public boolean equals(Object other)
{ {
if(other == null) if(other == null)
{ {
return false; return false;
} }
if (other instanceof TransferVersion) if (other instanceof TransferVersion)
{ {
TransferVersion v = (TransferVersion)other; TransferVersion v = (TransferVersion)other;
if(!edition.equalsIgnoreCase(v.getEdition())) if(!edition.equalsIgnoreCase(v.getEdition()))
{ {
return false; return false;

View File

@@ -33,19 +33,19 @@ import org.alfresco.service.cmr.repository.NodeRef;
public interface TransferReceiver public interface TransferReceiver
{ {
/** /**
* *
* @param transferId * @param transferId
* @return * @return
*/ */
File getStagingFolder(String transferId); File getStagingFolder(String transferId);
/** /**
* *
* @param transferId * @param transferId
* @return * @return
*/ */
NodeRef getTempFolder(String transferId); NodeRef getTempFolder(String transferId);
/** /**
* Asks the receiver to setup a new transfer. * Asks the receiver to setup a new transfer.
* @param fromRepositoryId the repositoryId of the sending system * @param fromRepositoryId the repositoryId of the sending system
@@ -66,14 +66,14 @@ public interface TransferReceiver
/** /**
* Store the specified snapshot file into the transfer staging area. * Store the specified snapshot file into the transfer staging area.
* The specified transfer must currently be the holder of the transfer lock, otherwise an exception is thrown. * The specified transfer must currently be the holder of the transfer lock, otherwise an exception is thrown.
* This operation does not close the supplied stream, so the caller must do it as appropriate. The caller * This operation does not close the supplied stream, so the caller must do it as appropriate. The caller
* should assume that the supplied stream has been fully read when this operation returns. * should assume that the supplied stream has been fully read when this operation returns.
* @param transferId The identifier of the transfer with which this snapshot is associated * @param transferId The identifier of the transfer with which this snapshot is associated
* @param snapshotStream The open stream that holds the snapshot file. * @param snapshotStream The open stream that holds the snapshot file.
* @throws TransferException If an error occurs while saving the snapshot file. * @throws TransferException If an error occurs while saving the snapshot file.
*/ */
void saveSnapshot(String transferId, InputStream snapshotStream) throws TransferException; void saveSnapshot(String transferId, InputStream snapshotStream) throws TransferException;
/** /**
* Save a content item * Save a content item
* @param transferId * @param transferId
@@ -82,28 +82,28 @@ public interface TransferReceiver
* @throws TransferException * @throws TransferException
*/ */
void saveContent(String transferId, String contentId, InputStream contentStream) throws TransferException; void saveContent(String transferId, String contentId, InputStream contentStream) throws TransferException;
/** /**
* Write the requsite (the bits required to support the Manifest) to the output stream. * Write the requsite (the bits required to support the Manifest) to the output stream.
* @param requsiteStream an open stream to receive the requisite * @param requsiteStream an open stream to receive the requisite
* @throws TransferException * @throws TransferException
*/ */
void generateRequsite(String transferId, OutputStream requsiteStream) throws TransferException; void generateRequsite(String transferId, OutputStream requsiteStream) throws TransferException;
/** /**
* Prepare * Prepare
* @param transferId * @param transferId
* @throws TransferException * @throws TransferException
*/ */
void prepare(String transferId) throws TransferException; void prepare(String transferId) throws TransferException;
/** /**
* Abort * Abort
* @param transferId * @param transferId
* @throws TransferException * @throws TransferException
*/ */
void cancel(String transferId) throws TransferException; void cancel(String transferId) throws TransferException;
/** /**
* Commit asynchronously * Commit asynchronously
* @param transferId * @param transferId
@@ -117,29 +117,35 @@ public interface TransferReceiver
* @throws TransferException * @throws TransferException
*/ */
void commit(String transferId) throws TransferException; void commit(String transferId) throws TransferException;
/** /**
* *
* @param transferId * @param transferId
* @return the trabsfer progress * @return the trabsfer progress
* @throws TransferException * @throws TransferException
*/ */
TransferProgress getStatus(String transferId) throws TransferException; TransferProgress getStatus(String transferId) throws TransferException;
/** /**
* Get the version that we are transfering to. * Get the version that we are transfering to.
*/ */
TransferVersion getVersion(); TransferVersion getVersion();
/** /**
* *
* @return * @return
*/ */
TransferProgressMonitor getProgressMonitor(); TransferProgressMonitor getProgressMonitor();
/** /**
* get the transfer report for the specified transfer * get the transfer report for the specified transfer
* @param transferId * @param transferId
*/ */
InputStream getTransferReport(String transferId); InputStream getTransferReport(String transferId);
/**
* set the root node for the file system receiver
* @param rootFileSystem
*/
void setFileTransferRootNodeFileFileSystem(String rootFileSystem);
} }

View File

@@ -19,33 +19,33 @@
package org.alfresco.service.cmr.transfer; package org.alfresco.service.cmr.transfer;
public interface TransferVersion public interface TransferVersion
{ {
/** /**
* Gets the major version number, e.g. <u>1</u>.2.3 * Gets the major version number, e.g. <u>1</u>.2.3
* *
* @return major version number * @return major version number
*/ */
public String getVersionMajor(); public String getVersionMajor();
/** /**
* Gets the minor version number, e.g. 1.<u>2</u>.3 * Gets the minor version number, e.g. 1.<u>2</u>.3
* *
* @return minor version number * @return minor version number
*/ */
public String getVersionMinor(); public String getVersionMinor();
/** /**
* Gets the version revision number, e.g. 1.2.<u>3</u> * Gets the version revision number, e.g. 1.2.<u>3</u>
* *
* @return revision number * @return revision number
*/ */
public String getVersionRevision(); public String getVersionRevision();
/** /**
* Gets the edition * Gets the edition
* *
* @return the edition * @return the edition
*/ */
public String getEdition(); public String getEdition();
} }