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=28051285771a2ea40dc545745daa3a87dabed158;hb=63bda59aac59f9fc99245d583decda254d1d3e5f;hp=58bc4c4020c35c64ea545709f066ab5a21c297b6;hpb=320a85770f0f3c15d2e5e658c42b713485a999c4;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 58bc4c40..28051285 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 @@ -38,8 +38,8 @@ public class SampleSubscriberServlet extends HttpServlet { private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.SampleSubscriberServlet"); - private String outputDirectory; - private String basicAuth; + private static String outputDirectory; + private static String basicAuth; /** * Configure the SampleSubscriberServlet. @@ -140,9 +140,12 @@ public class SampleSubscriberServlet extends HttpServlet { 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-ATT-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