Merged BRANCHES/DEV/BRIAN/FSTR to HEAD:

29575: FTR:
   - Removed obsolete package
 29576: FTR:
   - Moved config files into "org.alfresco.repo.transfer.fsr" package
 29579: FTR:
   - Simplified build process
 29590: FTR:
   - Initial pass at bringing the FTR into build process.
 29597: Commiting the 2 missing files    AbstractFileManifestProcessorBase.java and FileTransferSecondaryManifestProcessor.java
 29609: FTR:
   - Further changes to build process. Now builds a ZIP file with the correct structure.
 29610: Added reception and positioning of TransferCommons.PARAM_ROOT_FILE_TRANSFER in the FileTransferReceiver
 29614: FTR:
   - Updated svn ignore list

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29648 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-08-09 21:41:33 +00:00
parent bbf45a3304
commit 7e7fb817bc

View File

@@ -37,21 +37,21 @@ import org.springframework.extensions.webscripts.json.JSONWriter;
/** /**
* This command processor is used to record the start a transfer. No other transfer can be started after this command * This command processor is used to record the start a transfer. No other transfer can be started after this command
* has executed until the started transfer terminates. * has executed until the started transfer terminates.
* *
* @author brian * @author brian
* *
*/ */
public class BeginTransferCommandProcessor implements CommandProcessor public class BeginTransferCommandProcessor implements CommandProcessor
{ {
private static final String MSG_CAUGHT_UNEXPECTED_EXCEPTION = "transfer_service.receiver.caught_unexpected_exception"; private static final String MSG_CAUGHT_UNEXPECTED_EXCEPTION = "transfer_service.receiver.caught_unexpected_exception";
private TransferReceiver receiver; private TransferReceiver receiver;
private final static Log logger = LogFactory.getLog(BeginTransferCommandProcessor.class); private final static Log logger = LogFactory.getLog(BeginTransferCommandProcessor.class);
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.repo.web.scripts.transfer.CommandProcessor#process(org.alfresco .web.scripts.WebScriptRequest, * @see org.alfresco.repo.web.scripts.transfer.CommandProcessor#process(org.alfresco .web.scripts.WebScriptRequest,
* org.alfresco.web.scripts.WebScriptResponse) * org.alfresco.web.scripts.WebScriptResponse)
*/ */
@@ -64,15 +64,16 @@ public class BeginTransferCommandProcessor implements CommandProcessor
String [] transferToSelfValues = req.getParameterValues(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF); String [] transferToSelfValues = req.getParameterValues(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF);
String [] editionValues = req.getParameterValues(TransferCommons.PARAM_VERSION_EDITION); String [] editionValues = req.getParameterValues(TransferCommons.PARAM_VERSION_EDITION);
String [] majorValues = req.getParameterValues(TransferCommons.PARAM_VERSION_MAJOR); String [] majorValues = req.getParameterValues(TransferCommons.PARAM_VERSION_MAJOR);
String [] minorValues = req.getParameterValues(TransferCommons.PARAM_VERSION_MINOR); String [] minorValues = req.getParameterValues(TransferCommons.PARAM_VERSION_MINOR);
String [] revisionValues = req.getParameterValues(TransferCommons.PARAM_VERSION_REVISION); String [] revisionValues = req.getParameterValues(TransferCommons.PARAM_VERSION_REVISION);
String [] rootFileTransfer = req.getParameterValues(TransferCommons.PARAM_ROOT_FILE_TRANSFER);
String fromRepositoryId = null; String fromRepositoryId = null;
if(fromRepositoryIdValues != null && fromRepositoryIdValues.length > 0) if(fromRepositoryIdValues != null && fromRepositoryIdValues.length > 0)
{ {
fromRepositoryId = fromRepositoryIdValues[0]; fromRepositoryId = fromRepositoryIdValues[0];
} }
boolean transferToSelf = false; boolean transferToSelf = false;
if(transferToSelfValues != null && transferToSelfValues.length > 0) if(transferToSelfValues != null && transferToSelfValues.length > 0)
{ {
@@ -81,7 +82,7 @@ public class BeginTransferCommandProcessor implements CommandProcessor
transferToSelf = true; transferToSelf = true;
} }
} }
String edition = "Unknown"; String edition = "Unknown";
if(editionValues != null && editionValues.length > 0) if(editionValues != null && editionValues.length > 0)
{ {
@@ -102,47 +103,54 @@ public class BeginTransferCommandProcessor implements CommandProcessor
{ {
revision = revisionValues[0]; revision = revisionValues[0];
} }
TransferVersion fromVersion = new TransferVersionImpl(major, minor, revision, edition); TransferVersion fromVersion = new TransferVersionImpl(major, minor, revision, edition);
//set the root for the root node for the file transfer receiver
//It replaces the root node if transfers on file system
if(rootFileTransfer != null && rootFileTransfer.length > 0 )
{
receiver.setFileTransferRootNodeFileFileSystem(rootFileTransfer[0]);
}
// attempt to start the transfer // attempt to start the transfer
transferId = receiver.start(fromRepositoryId, transferToSelf, fromVersion); transferId = receiver.start(fromRepositoryId, transferToSelf, fromVersion);
// Create a temporary folder into which we can place transferred files // Create a temporary folder into which we can place transferred files
receiver.getStagingFolder(transferId); receiver.getStagingFolder(transferId);
TransferVersion version = receiver.getVersion(); TransferVersion version = receiver.getVersion();
// return the unique transfer id (the lock id) // return the unique transfer id (the lock id)
StringWriter stringWriter = new StringWriter(1000); StringWriter stringWriter = new StringWriter(1000);
JSONWriter jsonWriter = new JSONWriter(stringWriter); JSONWriter jsonWriter = new JSONWriter(stringWriter);
jsonWriter.startObject(); jsonWriter.startObject();
jsonWriter.writeValue(TransferCommons.PARAM_TRANSFER_ID, transferId); jsonWriter.writeValue(TransferCommons.PARAM_TRANSFER_ID, transferId);
if(version != null) if(version != null)
{ {
jsonWriter.writeValue(TransferCommons.PARAM_VERSION_EDITION, version.getEdition()); jsonWriter.writeValue(TransferCommons.PARAM_VERSION_EDITION, version.getEdition());
jsonWriter.writeValue(TransferCommons.PARAM_VERSION_MAJOR, version.getVersionMajor()); jsonWriter.writeValue(TransferCommons.PARAM_VERSION_MAJOR, version.getVersionMajor());
jsonWriter.writeValue(TransferCommons.PARAM_VERSION_MINOR, version.getVersionMinor()); jsonWriter.writeValue(TransferCommons.PARAM_VERSION_MINOR, version.getVersionMinor());
jsonWriter.writeValue(TransferCommons.PARAM_VERSION_REVISION, version.getVersionRevision()); jsonWriter.writeValue(TransferCommons.PARAM_VERSION_REVISION, version.getVersionRevision());
} }
jsonWriter.endObject(); jsonWriter.endObject();
String response = stringWriter.toString(); String response = stringWriter.toString();
resp.setContentType("application/json"); resp.setContentType("application/json");
resp.setContentEncoding("UTF-8"); resp.setContentEncoding("UTF-8");
int length = response.getBytes("UTF-8").length; int length = response.getBytes("UTF-8").length;
resp.addHeader("Content-Length", "" + length); resp.addHeader("Content-Length", "" + length);
resp.setStatus(Status.STATUS_OK); resp.setStatus(Status.STATUS_OK);
resp.getWriter().write(response); resp.getWriter().write(response);
logger.debug("transfer started" + transferId); logger.debug("transfer started" + transferId);
return Status.STATUS_OK; return Status.STATUS_OK;
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.debug("exception caught", ex); logger.debug("exception caught", ex);
@@ -167,5 +175,5 @@ public class BeginTransferCommandProcessor implements CommandProcessor
this.receiver = receiver; this.receiver = receiver;
} }
} }