mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-4127 - F86 Provide target log to source repository
implemented with unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21836 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -94,20 +94,6 @@ public class PostSnapshotCommandProcessor implements CommandProcessor
|
||||
receiver.saveSnapshot(transferId, item.openStream());
|
||||
}
|
||||
}
|
||||
|
||||
// <formdata multipart-processing="false" /> so the following code does not work
|
||||
// WebScriptServletRequest alfRequest = (WebScriptServletRequest)req;
|
||||
// FormField field = alfRequest.getFileField(TransferCommons.PART_NAME_MANIFEST);
|
||||
//
|
||||
// if(field != null)
|
||||
// {
|
||||
// logger.debug("got manifest file");
|
||||
// receiver.saveSnapshot(transferId, field.getInputStream());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// logger.debug("manifest is missing");
|
||||
// }
|
||||
|
||||
logger.debug("success");
|
||||
resp.setStatus(Status.STATUS_OK);
|
||||
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.web.scripts.transfer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.extensions.webscripts.json.JSONWriter;
|
||||
import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest;
|
||||
|
||||
/**
|
||||
* This command processor is used to get the server side transfer report.
|
||||
*
|
||||
* @author brian
|
||||
*
|
||||
*/
|
||||
public class ReportCommandProcessor 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(ReportCommandProcessor.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.web.scripts.transfer.CommandProcessor#process(org.alfresco .web.scripts.WebScriptRequest,
|
||||
* org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
public int process(WebScriptRequest req, WebScriptResponse resp)
|
||||
{
|
||||
//Read the transfer id from the request
|
||||
HttpServletRequest servletRequest = ((WebScriptServletRequest)req).getHttpServletRequest();
|
||||
String transferId = servletRequest.getParameter("transferId");
|
||||
|
||||
if (transferId == null)
|
||||
{
|
||||
logger.debug("transferId is missing");
|
||||
resp.setStatus(Status.STATUS_BAD_REQUEST);
|
||||
return Status.STATUS_BAD_REQUEST;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OutputStream out = resp.getOutputStream();
|
||||
resp.setContentType("text/xml");
|
||||
resp.setContentEncoding("utf-8");
|
||||
|
||||
BufferedInputStream br = new BufferedInputStream(receiver.getProgressMonitor().getLogInputStream(transferId));
|
||||
byte[] buffer = new byte[1000];
|
||||
int i = br.read(buffer);
|
||||
while(i > 0)
|
||||
{
|
||||
out.write(buffer, 0, i);
|
||||
i = br.read(buffer);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
return Status.STATUS_OK;
|
||||
}
|
||||
catch (TransferException ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new TransferException(MSG_CAUGHT_UNEXPECTED_EXCEPTION, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param receiver
|
||||
* the receiver to set
|
||||
*/
|
||||
public void setReceiver(TransferReceiver receiver)
|
||||
{
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user