X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FFeed.java;h=3462e2347bbe57bd11c6292afcfecf2ec38bc488;hb=8ebd052e0b1066c432f5dba6ef69599eaf5ec27e;hp=502dbbd15156c3c8920de0b4ab8ee61fc3ff6b5a;hpb=5775de7b0fc84a29511dc4a1a480c3ab32da2ade;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java index 502dbbd1..3462e234 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java @@ -24,18 +24,16 @@ package org.onap.dmaap.datarouter.provisioning.beans; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.onap.dmaap.datarouter.provisioning.utils.DB; import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities; -import org.onap.dmaap.datarouter.provisioning.utils.PasswordProcessor; import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities; import java.io.InvalidObjectException; -import java.security.GeneralSecurityException; import java.sql.*; import java.util.Date; import java.util.*; @@ -47,8 +45,9 @@ import java.util.*; * @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $ */ public class Feed extends Syncable { - private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal"); + private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); private static int next_feedid = getMaxFeedID() + 1; + private static final String SQLEXCEPTION = "SQLException: "; private int feedid; private int groupid; //New field is added - Groups feature Rally:US708115 - 1610 @@ -87,7 +86,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.log(Level.WARN, "PROV0024 Feed.isFeedValid: ", e); + intlogger.warn("PROV0024 Feed.isFeedValid: " + e.getMessage(), e); } return count != 0; } @@ -137,8 +136,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.info("PROV0025 Feed.countActiveFeeds: " + e.getMessage()); - intlogger.log(Level.WARN, "PROV0025 Feed.countActiveFeeds: ", e); + intlogger.warn("PROV0025 Feed.countActiveFeeds: " + e.getMessage(), e); } return count; } @@ -158,14 +156,13 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.info("PROV0026 Feed.getMaxFeedID: "+e.getMessage()); - intlogger.log(Level.WARN, "PROV0026 Feed.getMaxFeedID: ", e); + intlogger.warn("PROV0026 Feed.getMaxFeedID: " + e.getMessage(), e); } return max; } public static Collection getAllFeeds() { - Map map = new HashMap(); + Map map = new HashMap<>(); try { DB db = new DB(); @SuppressWarnings("resource") @@ -205,13 +202,13 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.log(Level.WARN, "PROV0027 Feed.getAllFeeds: ", e); + intlogger.warn("PROV0027 Feed.getAllFeeds: " + e.getMessage(), e); } return map.values(); } public static List getFilteredFeedUrlList(final String name, final String val) { - List list = new ArrayList(); + List list = new ArrayList<>(); String sql = "select SELF_LINK from FEEDS where DELETED = 0"; if (name.equals("name")) { sql += " and NAME = ?"; @@ -239,7 +236,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.log(Level.WARN, "PROV0028 Feed.getFilteredFeedUrlList: ", e); + intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: " + e.getMessage(), e); } return list; } @@ -276,7 +273,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.log(Level.WARN, "PROV0029 Feed.getFeedBySQL: ", e); + intlogger.warn("PROV0029 Feed.getFeedBySQL: " + e.getMessage(), e); } return feed; } @@ -332,16 +329,15 @@ public class Feed extends Syncable { this.groupid = jo.optInt("groupid"); this.name = jo.getString("name"); this.aaf_instance = jo.optString("aaf_instance", "legacy"); - if(!(aaf_instance.equalsIgnoreCase("legacy"))){ - if (aaf_instance.length() > 255){ + if(!(aaf_instance.equalsIgnoreCase("legacy")) && aaf_instance.length() > 255){ throw new InvalidObjectException("aaf_instance field is too long"); - } } if (name.length() > 255) throw new InvalidObjectException("name field is too long"); try { this.version = jo.getString("version"); } catch (JSONException e) { + intlogger.warn("PROV0023 Feed.Feed: " + e.getMessage(), e); this.version = null; } if(version != null && version.length() > 20) @@ -367,7 +363,7 @@ public class Feed extends Syncable { throw new InvalidObjectException("password field is too long ("+ fid.getPassword()+")"); //Fortify scan fixes - Privacy Violation this.authorization.getEndpoint_ids().add(fid); } - if (this.authorization.getEndpoint_ids().size() < 1) + if (this.authorization.getEndpoint_ids().isEmpty()) throw new InvalidObjectException("need to specify at least one endpoint_id"); endPointIds = jauth.getJSONArray("endpoint_addrs"); for (int i = 0; i < endPointIds.length(); i++) { @@ -383,11 +379,10 @@ public class Feed extends Syncable { JSONObject jol = jo.optJSONObject("links"); this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol)); } catch (InvalidObjectException e) { - intlogger.log(Level.WARN, "PROV0030 Feed.Feed: ", e); throw e; } catch (Exception e) { - intlogger.error("PROV0031 Feed.Feed: invalid JSON: "+e); - throw new InvalidObjectException("invalid JSON: " + e.getMessage()); + intlogger.warn("Invalid JSON: " + e.getMessage(), e); + throw new InvalidObjectException("Invalid JSON: " + e.getMessage()); } } @@ -500,14 +495,6 @@ public class Feed extends Syncable { this.suspended = suspended; } - public Date getLast_mod() { - return last_mod; - } - - public Date getCreated_date() { - return created_date; - } - @Override public JSONObject asJSONObject() { JSONObject jo = new JSONObject(); @@ -559,15 +546,14 @@ public class Feed extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -628,8 +614,7 @@ public class Feed extends Syncable { } } catch (SQLException e) { rv = false; - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0005 doInsert: " + e.getMessage(), e); } return rv; } @@ -709,13 +694,13 @@ public class Feed extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) ps.close(); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -741,14 +726,14 @@ public class Feed extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0008 changeOwnerShip: " + e.getMessage(), e); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv;