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%2FIngressRoute.java;h=329e77fa1f89c58e5c3278fe35249f6b4912ad50;hp=033b39003a1aece2c0c4c1144ea16cef62f3079f;hb=534c164c124950a2019acf71d253ac96be12c78c;hpb=3a2e2a602b9aa3677d941f3d5d65ea0dce80b7ab diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java index 033b3900..329e77fa 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java @@ -39,8 +39,9 @@ import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; import org.json.JSONArray; import org.json.JSONObject; import org.onap.dmaap.datarouter.provisioning.utils.DB; @@ -53,7 +54,8 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; */ public class IngressRoute extends NodeClass implements Comparable { - private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal"); + private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); + private static final String SQLEXCEPTION = "SQLException: "; private final int seq; private final int feedid; private final String userid; @@ -101,7 +103,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0001 getAllIngressRoutesForSQL: " + e.getMessage(), e); } return set; } @@ -139,7 +141,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0002 getMax: " + e.getMessage(), e); } return rv; } @@ -174,51 +176,19 @@ public class IngressRoute extends NodeClass implements Comparable ps.close(); db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0003 getIngressRoute: " + 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 v; } - /** - * Get a collection of all Ingress Routes with a particular sequence number. - * - * @param seq the sequence number to look for - * @return the collection (may be empty). - */ - public static Collection getIngressRoute(int seq) { - Collection rv = new ArrayList(); - try { - DB db = new DB(); - @SuppressWarnings("resource") - Connection conn = db.getConnection(); - String sql = "select FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = ?"; - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, seq); - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - int feedid = rs.getInt("FEEDID"); - String user = rs.getString("USERID"); - String subnet = rs.getString("SUBNET"); - int nodeset = rs.getInt("NODESET"); - rv.add(new IngressRoute(seq, feedid, user, subnet, nodeset)); - } - } - } - db.release(conn); - } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); - } - return rv; - } - public IngressRoute(int seq, int feedid, String user, String subnet, Collection nodes) throws IllegalArgumentException { this(seq, feedid, user, subnet); @@ -306,6 +276,7 @@ public class IngressRoute extends NodeClass implements Comparable SubnetMatcher sm = new SubnetMatcher(subnet); return sm.matches(inet.getAddress()); } catch (UnknownHostException e) { + intlogger.error("PROV0008 matches: " + e.getMessage(), e); return false; } } @@ -336,6 +307,7 @@ public class IngressRoute extends NodeClass implements Comparable len = sn.length; valid = true; } catch (UnknownHostException e) { + intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e); len = 0; valid = false; } @@ -346,6 +318,7 @@ public class IngressRoute extends NodeClass implements Comparable sn = InetAddress.getByName(subnet.substring(0, i)).getAddress(); valid = true; } catch (UnknownHostException e) { + intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e); valid = false; } len = n / 8; @@ -389,7 +362,7 @@ public class IngressRoute extends NodeClass implements Comparable } private Collection readNodes() { - Collection set = new TreeSet(); + Collection set = new TreeSet<>(); try { DB db = new DB(); @SuppressWarnings("resource") @@ -406,7 +379,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } return set; } @@ -433,14 +406,14 @@ public class IngressRoute extends NodeClass implements Comparable ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("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; @@ -476,14 +449,14 @@ public class IngressRoute extends NodeClass implements Comparable ps.close(); rv = true; } catch (SQLException e) { - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + 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; @@ -523,14 +496,10 @@ public class IngressRoute extends NodeClass implements Comparable @Override public boolean equals(Object obj) { - try { - if (!(obj instanceof IngressRoute)) { - return false; - } - return this.compareTo((IngressRoute) obj) == 0; - } catch (NullPointerException e) { + if (!(obj instanceof IngressRoute)) { return false; } + return this.compareTo((IngressRoute) obj) == 0; } @Override