From 7e7fb817bcce371d84838c7966bb4404cf8fe6dc Mon Sep 17 00:00:00 2001 From: Brian Remmington Date: Tue, 9 Aug 2011 21:41:33 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20BRANCHES/DEV/BRIAN/FSTR=20to=20HEAD:?= =?UTF-8?q?=20=2029575:=20FTR:=20=20=20=20-=20Removed=20obsolete=20package?= =?UTF-8?q?=20=2029576:=20FTR:=20=20=20=20-=20Moved=20config=20files=20int?= =?UTF-8?q?o=20"org.alfresco.repo.transfer.fsr"=20package=20=2029579:=20FT?= =?UTF-8?q?R:=20=20=20=20-=20Simplified=20build=20process=20=2029590:=20FT?= =?UTF-8?q?R:=20=20=20=20-=20Initial=20pass=20at=20bringing=20the=20FTR=20?= =?UTF-8?q?into=20build=20process.=20=2029597:=20Commiting=20the=202=20mis?= =?UTF-8?q?sing=20files=20=C2=A0=C2=A0=20AbstractFileManifestProcessorBase?= =?UTF-8?q?.java=20and=20FileTransferSecondaryManifestProcessor.java=20=20?= =?UTF-8?q?29609:=20FTR:=20=20=20=20-=20Further=20changes=20to=20build=20p?= =?UTF-8?q?rocess.=20Now=20builds=20a=20ZIP=20file=20with=20the=20correct?= =?UTF-8?q?=20structure.=20=2029610:=20Added=20reception=20and=20positioni?= =?UTF-8?q?ng=20of=20TransferCommons.PARAM=5FROOT=5FFILE=5FTRANSFER=20in?= =?UTF-8?q?=20the=20FileTransferReceiver=20=2029614:=20FTR:=20=20=20=20-?= =?UTF-8?q?=20Updated=20svn=20ignore=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29648 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../BeginTransferCommandProcessor.java | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java b/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java index 53458d85a2..3be9b94869 100644 --- a/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java @@ -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 * has executed until the started transfer terminates. - * + * * @author brian - * + * */ public class BeginTransferCommandProcessor implements CommandProcessor { private static final String MSG_CAUGHT_UNEXPECTED_EXCEPTION = "transfer_service.receiver.caught_unexpected_exception"; private TransferReceiver receiver; - + private final static Log logger = LogFactory.getLog(BeginTransferCommandProcessor.class); /* * (non-Javadoc) - * + * * @see org.alfresco.repo.web.scripts.transfer.CommandProcessor#process(org.alfresco .web.scripts.WebScriptRequest, * 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 [] editionValues = req.getParameterValues(TransferCommons.PARAM_VERSION_EDITION); 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 [] rootFileTransfer = req.getParameterValues(TransferCommons.PARAM_ROOT_FILE_TRANSFER); + String fromRepositoryId = null; if(fromRepositoryIdValues != null && fromRepositoryIdValues.length > 0) { fromRepositoryId = fromRepositoryIdValues[0]; } - + boolean transferToSelf = false; if(transferToSelfValues != null && transferToSelfValues.length > 0) { @@ -81,7 +82,7 @@ public class BeginTransferCommandProcessor implements CommandProcessor transferToSelf = true; } } - + String edition = "Unknown"; if(editionValues != null && editionValues.length > 0) { @@ -102,47 +103,54 @@ public class BeginTransferCommandProcessor implements CommandProcessor { revision = revisionValues[0]; } - + 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 transferId = receiver.start(fromRepositoryId, transferToSelf, fromVersion); // Create a temporary folder into which we can place transferred files receiver.getStagingFolder(transferId); - + TransferVersion version = receiver.getVersion(); // return the unique transfer id (the lock id) StringWriter stringWriter = new StringWriter(1000); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.startObject(); - + jsonWriter.writeValue(TransferCommons.PARAM_TRANSFER_ID, transferId); - + if(version != null) { jsonWriter.writeValue(TransferCommons.PARAM_VERSION_EDITION, version.getEdition()); 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.endObject(); - + String response = stringWriter.toString(); - + resp.setContentType("application/json"); resp.setContentEncoding("UTF-8"); int length = response.getBytes("UTF-8").length; resp.addHeader("Content-Length", "" + length); resp.setStatus(Status.STATUS_OK); resp.getWriter().write(response); - + logger.debug("transfer started" + transferId); - + return Status.STATUS_OK; - } + } catch (Exception ex) { logger.debug("exception caught", ex); @@ -167,5 +175,5 @@ public class BeginTransferCommandProcessor implements CommandProcessor this.receiver = receiver; } - + }