X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FPublishRecord.java;h=2cde3971626c74295d1b7536706e7ce5ae69d955;hp=e7575ff33f5d0426312c9399ee6b0358a3537a1b;hb=5da50e90e6c78700d48d7468849d4a1599a249b3;hpb=14b8d9552808063686e0c22760cec6e35b960b59 diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java index e7575ff3..2cde3971 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java @@ -30,6 +30,7 @@ import java.sql.Types; import java.text.ParseException; import java.util.LinkedHashMap; +import org.apache.commons.lang3.StringUtils; import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject; @@ -44,14 +45,10 @@ public class PublishRecord extends BaseLogRecord { private String remoteAddr; private String user; private int status; + private String fileName; public PublishRecord(String[] pp) throws ParseException { super(pp); -// This is too slow! -// Matcher m = Pattern.compile(".*/publish/(\\d+)/(.*)$").matcher(pp[4]); -// if (!m.matches()) -// throw new ParseException("bad pattern", 0); -// this.feedFileid = m.group(2); int ix = pp[4].indexOf("/publish/"); if (ix < 0) throw new ParseException("bad pattern", 0); @@ -62,6 +59,7 @@ public class PublishRecord extends BaseLogRecord { this.remoteAddr = pp[8]; this.user = pp[9]; this.status = Integer.parseInt(pp[10]); + this.fileName = StringUtils.substringAfterLast(this.getRequestUri(), "/"); } public PublishRecord(ResultSet rs) throws SQLException { @@ -70,6 +68,7 @@ public class PublishRecord extends BaseLogRecord { this.remoteAddr = rs.getString("REMOTE_ADDR"); this.user = rs.getString("USER"); this.status = rs.getInt("STATUS"); + this.fileName = StringUtils.substringAfterLast(this.getRequestUri(), "/"); } public String getFeedFileid() { @@ -104,6 +103,10 @@ public class PublishRecord extends BaseLogRecord { this.status = status; } + public String getFileName() { return fileName;} + + public void setFileName(String fileName) { this.fileName = fileName; } + public LOGJSONObject reOrderObject(LOGJSONObject jo) { LinkedHashMap logrecordObj = new LinkedHashMap(); @@ -119,6 +122,7 @@ public class PublishRecord extends BaseLogRecord { logrecordObj.put("type", jo.get("type")); logrecordObj.put("date", jo.get("date")); logrecordObj.put("contentLength", jo.get("contentLength")); + logrecordObj.put("fileName", jo.get("fileName")); LOGJSONObject newjo = new LOGJSONObject(logrecordObj); return newjo; @@ -128,12 +132,13 @@ public class PublishRecord extends BaseLogRecord { public LOGJSONObject asJSONObject() { LOGJSONObject jo = super.asJSONObject(); jo.put("type", "pub"); -// jo.put("feedFileid", feedFileid); -// jo.put("remoteAddr", remoteAddr); -// jo.put("user", user); + jo.put("feedFileid", feedFileid); + jo.put("remoteAddr", remoteAddr); + jo.put("user", user); jo.put("sourceIP", remoteAddr); jo.put("endpointId", user); jo.put("statusCode", status); + jo.put("fileName", fileName); LOGJSONObject newjo = this.reOrderObject(jo); @@ -154,5 +159,6 @@ public class PublishRecord extends BaseLogRecord { ps.setNull(16, Types.INTEGER); ps.setNull(17, Types.VARCHAR); ps.setNull(19, Types.BIGINT); + ps.setString(20, getFileName()); } }