]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3911: Workaround - at best - for problem where ampersand character entities...
authorAron Roberts <aron@socrates.berkeley.edu>
Mon, 19 Mar 2012 19:47:47 +0000 (12:47 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Mon, 19 Mar 2012 19:47:47 +0000 (12:47 -0700)
services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java

index 3ca85110d525c332e5f1db09bfec73b196f2d07e..dae22ab4235390f8e371ceb6bdbac2b633b33278 100644 (file)
@@ -52,6 +52,8 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
+
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -296,7 +298,13 @@ public class ImportsResource extends ResourceBase {
                     String mediaType = part.getMediaType().toString();
                     System.out.println("Media type is:" + mediaType);
                     if (mediaType.equalsIgnoreCase(MediaType.APPLICATION_XML) || mediaType.equalsIgnoreCase(MediaType.TEXT_XML)){
-                        InputSource inputSource = new InputSource(part.getBody(InputStream.class, null));
+                        // FIXME For an alternate approach, potentially preferable, see:
+                        // http://stackoverflow.com/questions/4586222/right-way-of-formatting-an-input-stream
+                        String str = encodeAmpersands(part.getBodyAsString());
+                        byte[] buf = str.getBytes("UTF8");
+                        InputStream stream = new ByteArrayInputStream(str.getBytes("UTF8"));
+                        InputSource inputSource = new InputSource(stream);
+                        // InputSource inputSource = new InputSource(part.getBody(InputStream.class, null));
                         String result = createFromInputSource(inputSource);
                         resultBuf.append(result);
                         continue;