X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-subscriber%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fsubscriber%2FSampleSubscriberServlet.java;h=e9a0bf9bb93bb726cda525bd11c6dd9cc2d7dcdc;hb=29c4f8051e4fc856cd84b97e31f445f65f7e497d;hp=38425748f3c77dbefb0208341493fdcec8f8d0da;hpb=46ef61c0fe477483be17dbf9af2ef3b1023da0d8;p=dmaap%2Fdatarouter.git diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java index 38425748..e9a0bf9b 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java @@ -63,7 +63,7 @@ public class SampleSubscriberServlet extends HttpServlet { try { Files.createDirectory(Paths.get(outputDirectory)); } catch (IOException e) { - logger.info("SubServlet: Failed to create delivery dir: " + e.getMessage()); + logger.info("SubServlet: Failed to create delivery dir: " + e.getMessage(), e); } basicAuth = "Basic " + Base64.encodeBase64String((login + ":" + password).getBytes()); } @@ -135,14 +135,17 @@ public class SampleSubscriberServlet extends HttpServlet { if (queryString != null) { fileid = fileid + "?" + queryString; } - String publishid = req.getHeader("X-ATT-DR-PUBLISH-ID"); + String publishid = req.getHeader("X-DMAAP-DR-PUBLISH-ID"); String filename = URLEncoder.encode(fileid, "UTF-8").replaceAll("^\\.", "%2E").replaceAll("\\*", "%2A"); String fullPath = outputDirectory + "/" + filename; String tmpPath = outputDirectory + "/." + filename; + String fullMetaDataPath = outputDirectory + "/" + filename + ".M"; + String tmpMetaDataPath = outputDirectory + "/." + filename + ".M"; try { if (isdelete) { Files.deleteIfExists(Paths.get(fullPath)); + Files.deleteIfExists(Paths.get(fullMetaDataPath)); logger.info( "SampleSubServlet: Received delete for file id " + fileid @@ -154,6 +157,7 @@ public class SampleSubscriberServlet extends HttpServlet { + fullPath); } else { new File(tmpPath).createNewFile(); + new File(tmpMetaDataPath).createNewFile(); try (InputStream is = req.getInputStream(); OutputStream os = new FileOutputStream(tmpPath)) { byte[] buf = new byte[65536]; @@ -163,6 +167,11 @@ public class SampleSubscriberServlet extends HttpServlet { } } Files.move(Paths.get(tmpPath), Paths.get(fullPath), StandardCopyOption.REPLACE_EXISTING); + try (PrintWriter writer = new PrintWriter(new FileOutputStream(tmpMetaDataPath))) { + String metaData = req.getHeader("X-DMAAP-DR-META"); + writer.print(metaData); + } + Files.move(Paths.get(tmpMetaDataPath), Paths.get(fullMetaDataPath), StandardCopyOption.REPLACE_EXISTING); logger.info( "SampleSubServlet: Received file id " + fileid @@ -177,6 +186,7 @@ public class SampleSubscriberServlet extends HttpServlet { resp.setStatus(HttpServletResponse.SC_NO_CONTENT); } catch (IOException ioe) { Files.deleteIfExists(Paths.get(tmpPath)); + Files.deleteIfExists(Paths.get(tmpMetaDataPath)); logger.info( "SampleSubServlet: Failed to process file " + fullPath