diff --git a/source/java/org/alfresco/repo/web/scripts/transfer/StatusCommandProcessor.java b/source/java/org/alfresco/repo/web/scripts/transfer/StatusCommandProcessor.java index ea31b8215a..ea3053eebb 100644 --- a/source/java/org/alfresco/repo/web/scripts/transfer/StatusCommandProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/transfer/StatusCommandProcessor.java @@ -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(); diff --git a/source/java/org/alfresco/repo/web/scripts/transfer/TransferProcessorUtil.java b/source/java/org/alfresco/repo/web/scripts/transfer/TransferProcessorUtil.java index cb66fe33fd..98c062ea78 100644 --- a/source/java/org/alfresco/repo/web/scripts/transfer/TransferProcessorUtil.java +++ b/source/java/org/alfresco/repo/web/scripts/transfer/TransferProcessorUtil.java @@ -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