Transfer Service:

- Exception from server is now reported back over the wire via the "get status" request
- Added another test case to TransferServiceCallbackTest

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22349 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2010-09-08 21:15:07 +00:00
parent b971b71658
commit c1074cf17c
2 changed files with 34 additions and 8 deletions

View File

@@ -82,7 +82,8 @@ public class StatusCommandProcessor implements CommandProcessor
jsonWriter.writeValue("endPosition", progress.getEndPosition());
if (progress.getError() != null)
{
//FIXME: bjr: write this
jsonWriter.startValue("error");
TransferProcessorUtil.writeError(progress.getError(), jsonWriter);
}
jsonWriter.endObject();
String response = stringWriter.toString();

View File

@@ -21,6 +21,7 @@ package org.alfresco.repo.web.scripts.transfer;
import java.io.IOException;
import java.io.StringWriter;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.transfer.TransferException;
import org.springframework.extensions.webscripts.json.JSONWriter;
@@ -30,16 +31,40 @@ public class TransferProcessorUtil
{
StringWriter stringWriter = new StringWriter(300);
JSONWriter jsonWriter = new JSONWriter(stringWriter);
jsonWriter.startObject();
jsonWriter.writeValue("errorId", ex.getMsgId());
jsonWriter.startValue("errorParams");
jsonWriter.startArray();
stringWriter.write(writeErrorParams(ex.getMsgParams()));
jsonWriter.endArray();
jsonWriter.endObject();
writeError(ex, jsonWriter);
return stringWriter.toString();
}
public static void writeError(Throwable ex, JSONWriter jsonWriter) throws IOException
{
jsonWriter.startObject();
jsonWriter.writeValue("errorType", JSONWriter.encodeJSONString(ex.getClass().getName()));
if (AlfrescoRuntimeException.class.isAssignableFrom(ex.getClass()))
{
AlfrescoRuntimeException alfEx = (AlfrescoRuntimeException)ex;
jsonWriter.writeValue("errorId", JSONWriter.encodeJSONString(alfEx.getMsgId()));
jsonWriter.startValue("errorParams");
jsonWriter.startArray();
Object[] msgParams = alfEx.getMsgParams();
if (msgParams != null)
{
for (Object param : msgParams)
{
if (param != null)
{
jsonWriter.writeValue(JSONWriter.encodeJSONString(param.toString()));
}
else
{
jsonWriter.writeNullValue();
}
}
}
jsonWriter.endArray();
}
jsonWriter.endObject();
}
/**
* @param stringWriter
* @param msgParams