From: Aron Roberts Date: Fri, 16 Mar 2012 02:23:42 +0000 (-0700) Subject: CSPACE-4866,CSPACE-4818: In Imports service, allow multipart/form-data upload of... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=727ec5078b48a2951a20575fc9335fe9b9a6c616;p=tmp%2Fjakarta-migration.git CSPACE-4866,CSPACE-4818: In Imports service, allow multipart/form-data upload of XML files using 'text/xml' MIME type, as well as 'application/xml', to support upload form functionality of that service. Minor cleanup of error and success messages, and of the HTML upload form. --- diff --git a/services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java b/services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java index 5e96b150b..3ca85110d 100644 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java @@ -165,13 +165,14 @@ public class ImportsResource extends ResourceBase { ImportCommand importCommand = new ImportCommand(); // String destWorkspaces = "/default-domain/workspaces"; String destWorkspaces = getWorkspaces(); - String report = "NORESULTS"; + String result = ""; try { + String report = "NORESULTS"; report = importCommand.run(outputDir, destWorkspaces); + result = "SUCCESS"+report+""; } catch (Exception e){ - report = "ERROR"+Tools.errorToString(e, true)+""; + result = "ERROR"+Tools.errorToString(e, true)+""; } - String result = "SUCCESS"+report+""; return result; } @@ -187,8 +188,14 @@ public class ImportsResource extends ResourceBase { ImportCommand importCommand = new ImportCommand(); // String destWorkspaces = "/default-domain/workspaces"; String destWorkspaces = getWorkspaces(); - String report = importCommand.run(outputDir, destWorkspaces); - String result = "SUCCESS"+report+""; + String result = ""; + try { + String report = "NORESULTS"; + report = importCommand.run(outputDir, destWorkspaces); + result = "SUCCESS"+report+""; + } catch (Exception e){ + result = "ERROR"+Tools.errorToString(e, true)+""; + } return result; } @@ -288,7 +295,7 @@ public class ImportsResource extends ResourceBase { for (InputPart part : fileParts){ String mediaType = part.getMediaType().toString(); System.out.println("Media type is:" + mediaType); - if (mediaType.equalsIgnoreCase(MediaType.APPLICATION_XML)){ + if (mediaType.equalsIgnoreCase(MediaType.APPLICATION_XML) || mediaType.equalsIgnoreCase(MediaType.TEXT_XML)){ InputSource inputSource = new InputSource(part.getBody(InputStream.class, null)); String result = createFromInputSource(inputSource); resultBuf.append(result); @@ -323,8 +330,24 @@ public class ImportsResource extends ResourceBase { return response; } - String page = "
" - + "Choose a file to import:
"; + String page = "\n" + + "\n" + + " \n" + + " CollectionSpace Import\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + " Choose a file to import:" + + " \n" + + "
\n" + + " \n" + + "
\n" + + " \n" + + "\n"; @GET @Produces("text/html") public String getInputForm(@QueryParam("form") String form) {