Merge "Fix delete of feed pubs and subs"
diff --git a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafDecrypt.java b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafDecrypt.java
index 8728988..31e2a34 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafDecrypt.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafDecrypt.java
@@ -36,6 +36,7 @@
 			dec = (DecryptionInterface) (Class.forName(dClass).newInstance());	
 			dec.init( p.getProperty("CredentialCodecKeyfile", "LocalKey"));
 		} catch (Exception ee ) {
+			logger.error("Error", ee);
 			errorLogger.error(DmaapbcLogMessageEnum.UNEXPECTED_CONDITION, "attempting to instantiate " + dClass  );		
 		}	
 	}
@@ -46,6 +47,7 @@
 		try {		
 			pwd = dec.decrypt( encPwd );
 		} catch( IOException io ) {
+			logger.error("Error", io);
 			errorLogger.error(DmaapbcLogMessageEnum.DECRYPT_IO_ERROR, dClass, encPwd );
 		} 
 		
diff --git a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafLurService.java b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafLurService.java
index cb0be04..edc522e 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafLurService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafLurService.java
@@ -37,13 +37,13 @@
 import org.onap.aaf.cadi.principal.UnAuthPrincipal;
 import org.onap.aaf.misc.env.APIException;
 import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
 
 /*
  * this service uses the AAF Lur object to lookup identities and perms
  */
 public class AafLurService extends BaseLoggingClass {
+	
+	static Logger logger = Logger.getLogger(AafLurService.class.getName());
 
 	
 	 private static AAFConHttp aafcon;
@@ -66,6 +66,7 @@
 		} catch ( CadiException | LocatorException e) {
 			appLogger.error( "Failure of AAFConHttp: " + e.getMessage() );
 			errorLogger.error( "Failure of AAFConHttp: " + e.getMessage() );
+			logger.error(e);
 			e.printStackTrace();
 			throw e;
 		} 
@@ -74,6 +75,7 @@
 		} catch ( CadiException  e) {
 			appLogger.error( "Failure of newLur(): " + e.getMessage() );
 			errorLogger.error( "Failure of newLur(): " + e.getMessage() );
+			logger.error(e);
 			e.printStackTrace();
 			throw e;
 		} 
@@ -87,6 +89,7 @@
 				init( myAccess );
 			} catch (APIException | CadiException | LocatorException e) {
 				// TODO Auto-generated catch block
+				logger.error(e);
 				e.printStackTrace();
 				throw e;
 			} 
@@ -120,7 +123,10 @@
 			return rc;
 		}
 		rc =  aafLur.fish( principal, aafPerm );
-		if (rc == true ) return rc;
+		boolean flag = true;
+		if (rc == flag ) {
+			return rc;
+		}
 		
 		List<Permission> perms = new ArrayList<Permission>();
 		aafLur.fishAll( principal,  perms);
diff --git a/src/main/java/org/onap/dmaap/dbcapi/authentication/AafLurAndFish.java b/src/main/java/org/onap/dmaap/dbcapi/authentication/AafLurAndFish.java
index b699a29..2366452 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/authentication/AafLurAndFish.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/authentication/AafLurAndFish.java
@@ -31,8 +31,6 @@
 import org.onap.aaf.misc.env.APIException;
 import org.onap.dmaap.dbcapi.aaf.AafLurService;
 import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
-import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
-import org.onap.dmaap.dbcapi.server.Main;
 import org.onap.dmaap.dbcapi.util.DmaapConfig;
 
 
@@ -45,7 +43,6 @@
 	
 	AafLurAndFish()  throws AuthenticationErrorException  {
 	
-		String[] args = new String[1];
 		DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
 		api_namespace = p.getProperty( "ApiNamespace", "org.onap.dmaap-bc.api");
 
@@ -61,13 +58,15 @@
 			}
 		} catch ( IOException e ) {
 			logger.error( "Unable to load " + cadiprop );
+			logger.error("Error", e);
 			throw new AuthenticationErrorException( );
 		}
 		try {
 			PropAccess myAccess = new PropAccess( props );
 		
 			svc =  AafLurService.getInstance(myAccess);
-		} catch (APIException | CadiException | LocatorException e ) { 
+		} catch (APIException | CadiException | LocatorException e ) {
+			logger.error("Error", e);
 			logger.error( e.toString() );
 			throw new AuthenticationErrorException();
 		}
@@ -78,10 +77,12 @@
 	
 		try {
 			boolean resp = svc.checkPerm( api_namespace, mechid, pwd, p );
-			if ( resp == false ) {
+			boolean flag = false;
+			if ( resp == flag ) {
 				throw new AuthenticationErrorException();
 			}
 		} catch ( IOException | CadiException  e ) { 
+			logger.error("Error", e);
 			logger.error( e.toString() );
 			throw new AuthenticationErrorException();
 		}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiAuthorizationCheckInterface.java b/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiAuthorizationCheckInterface.java
index a7f0d76..1fef09d 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiAuthorizationCheckInterface.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiAuthorizationCheckInterface.java
@@ -22,6 +22,7 @@
 
 import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
 
+@FunctionalInterface
 public interface ApiAuthorizationCheckInterface {
 	public void check( String mechid, String pwd, DmaapPerm p ) throws AuthenticationErrorException;
 
diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
index 18fdeba..492037c 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
@@ -33,7 +33,6 @@
 import javax.net.ssl.SSLException;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
 import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
 import org.onap.dmaap.dbcapi.model.ApiError;
 import org.onap.dmaap.dbcapi.model.MR_Cluster;
@@ -81,7 +80,7 @@
 			return(true);
 		} catch (Exception e) {
             logger.error("Unexpected error during openConnection of " + pURL );
-            e.printStackTrace();
+            logger.error("Error", e);;
             return(false);
         }
 
@@ -97,7 +96,7 @@
 			return(true);
 		} catch (Exception e) {
             logger.error("Unexpected error during openConnection of " + pURL );
-            e.printStackTrace();
+            logger.error("error", e);
             return(false);
         }
 
@@ -147,13 +146,10 @@
 
             } catch (ProtocolException pe) {
                  // Rcvd error instead of 100-Continue
-                 try {
-                     // work around glitch in Java 1.7.0.21 and likely others
-                     // without this, Java will connect multiple times to the server to run the same request
-                     uc.setDoOutput(false);
-                 } catch (Exception e) {
-                 }
+            	callSetDoOutputOnError();
+                 
             }  catch ( SSLException se ) {
+            	logger.error("Error", se);
         		response.setCode(500);
     			response.setMessage( se.getMessage());
     			return response;
@@ -194,16 +190,28 @@
 				response.setCode(500);
 				response.setMessage( "Unable to read response");
 				logger.warn( response.getMessage() );
-            	e.printStackTrace();
+            	logger.error("Error", e);
 			}
         }
 		finally {
 			try {
 				uc.disconnect();
-			} catch ( Exception e ) {}
+			} catch ( Exception e ) {
+				logger.error("Error", e);
+			}
 		}
 		return response;
 
 	}
+	
+	public void callSetDoOutputOnError() {
+		try {
+            // work around glitch in Java 1.7.0.21 and likely others
+            // without this, Java will connect multiple times to the server to run the same request
+            uc.setDoOutput(false);
+        } catch (Exception e) {
+       	 	logger.error("Error", e);
+        }
+	}
 
 }
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java b/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
index e0c7819..2317fe4 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
@@ -22,17 +22,22 @@
 
 import java.sql.*;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
 
 public abstract class ConnWrapper<T, U>	{
+	EELFLogger logger = EELFManager.getInstance().getLogger( ConnWrapper.class );
 	protected Connection c;
 	protected PreparedStatement ps;
 	protected ResultSet	rs;
 	protected abstract T run(U u) throws Exception;
-	public T protect(ConnectionFactory cf, U u) throws DBException {
+	public T protect(ConnectionFactory cf, U u) {
 		try {
 			try {
 				return(attempt(cf, u, false));
 			} catch (SQLException sqle) {
+				logger.error("Error", sqle);
 				return(attempt(cf, u, true));
 			}
 		} catch (RuntimeException rte) {
@@ -52,11 +57,26 @@
 			c = null;
 			return(ret);
 		} finally {
-			if (rs != null) { try { rs.close(); } catch (Exception e) {}}
+			if (rs != null) { 
+				try { 
+					rs.close(); 
+				} catch (Exception e) {
+					logger.error("Error", e);
+				}}
 			rs = null;
-			if (ps != null) { try { ps.close(); } catch (Exception e) {}}
+			if (ps != null) { 
+				try { 
+					ps.close(); 
+				} catch (Exception e) {
+					logger.error("Error", e);
+				}}
 			ps = null;
-			if (c != null) { try { c.close(); } catch (Exception e) {}}
+			if (c != null) { 
+				try { 
+					c.close(); 
+				} catch (Exception e) {
+					logger.error("Error", e);
+				}}
 			c = null;
 		}
 	}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/ConnectionFactory.java b/src/main/java/org/onap/dmaap/dbcapi/database/ConnectionFactory.java
index 38c063c..aee3ff1 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/ConnectionFactory.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/ConnectionFactory.java
@@ -23,12 +23,9 @@
 import java.sql.*;
 import java.util.*;
 
-import org.apache.log4j.Logger;
-
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
 import org.onap.dmaap.dbcapi.util.DmaapConfig;
 
 public class ConnectionFactory	{
@@ -90,6 +87,10 @@
 				return;
 			}
 		}
-		try { c.close(); } catch (Exception e) {}
+		try { 
+			c.close(); 
+		} catch (Exception e) {
+			logger.error("Error", e);
+		}
 	}
 }
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java b/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java
index a9bf56e..6f63848 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java
@@ -30,42 +30,42 @@
 	public DBMap(ConnectionFactory cf, Class<C> cls, String tabname, String keyfield) throws Exception {
 		super(cf, cls, tabname, keyfield);
 	}
-	public void clear() throws UnsupportedOperationException {
+	public void clear() {
 		throw new UnsupportedOperationException();
 	}
-	public boolean containsKey(Object key) throws DBException {
+	public boolean containsKey(Object key) {
 		return(get(key) != null);
 	}
-	public boolean containsValue(Object value) throws UnsupportedOperationException {
+	public boolean containsValue(Object value) {
 		throw new UnsupportedOperationException();
 	}
 	public boolean isEmpty() {
 		return(false);
 	}
-	public Set<Map.Entry<String, C>> entrySet() throws DBException {
+	public Set<Map.Entry<String, C>> entrySet() {
 		return(list());
 	}
-	public Set<String> keySet() throws DBException {
-		Set<String> ret = new HashSet<String>();
+	public Set<String> keySet() {
+		Set<String> ret = new HashSet<>();
 		for (Map.Entry<String, C> x: list()) {
 			ret.add(x.getKey());
 		}
 		return(ret);
 	}
-	public void putAll(Map<? extends String, ? extends C> m) throws UnsupportedOperationException {
+	public void putAll(Map<? extends String, ? extends C> m) {
 		throw new UnsupportedOperationException();
 	}
 	public int size() {
 		return(2);
 	}
-	public Collection<C> values() throws DBException {
-		Collection<C> ret = new Vector<C>();
+	public Collection<C> values() {
+		Collection<C> ret = new Vector<>();
 		for (Map.Entry<String, C> x: list()) {
 			ret.add(x.getValue());
 		}
 		return(ret);
 	}
-	public C get(Object key) throws DBException {
+	public C get(Object key) {
 		if (!(key instanceof String)) {
 			return(null);
 		}
@@ -85,13 +85,13 @@
 			}
 		}).protect(cf, (String)key));
 	}
-	public Set<Map.Entry<String, C>> list() throws DBException {
+	public Set<Map.Entry<String, C>> list() {
 		return((new ConnWrapper<Set<Map.Entry<String, C>>, Object>() {
 			protected Set<Map.Entry<String, C>> run(Object junk) throws Exception {
 				DBFieldHandler keyfield = fields[fields.length - 1];
 				ps = c.prepareStatement(liststmt);
 				rs = ps.executeQuery();
-				Set<Map.Entry<String, C>> ret = new HashSet<Map.Entry<String, C>>();
+				Set<Map.Entry<String, C>> ret = new HashSet<>();
 				while (rs.next()) {
 					C val = cls.newInstance();
 					for (DBFieldHandler f: fields) {
@@ -104,7 +104,7 @@
 			}
 		}).protect(cf, null));
 	}
-	public C put(String key, C val) throws DBException {
+	public C put(String key, C val) {
 		try {
 			fields[fields.length - 1].setKey(val, key);
 		} catch (Exception e) {
@@ -122,7 +122,7 @@
 			}
 		}).protect(cf, val));
 	}
-	public C remove(Object key) throws DBException {
+	public C remove(Object key) {
 		if (!(key instanceof String)) {
 			return(null);
 		}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/DBSingleton.java b/src/main/java/org/onap/dmaap/dbcapi/database/DBSingleton.java
index 9a34f58..2633d70 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/DBSingleton.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/DBSingleton.java
@@ -34,7 +34,7 @@
 		super(cf, cls, tabname, null);
 		singleton = cls.newInstance();
 	}
-	public C get() throws DBException {
+	public C get() {
 		return((new ConnWrapper<C, Object>() {
 			protected C run(Object junk) throws Exception {
 				ps = c.prepareStatement(getstmt);
@@ -49,7 +49,7 @@
 			}
 		}).protect(cf, null));
 	}
-	public void init(C val) throws DBException {
+	public void init(C val) {
 		if (get() != null) {
 			return;
 		}
@@ -69,7 +69,7 @@
 			}
 		}).protect(cf, val);
 	}
-	public void update(C val) throws DBException {
+	public void update(C val) {
 		(new ConnWrapper<Void, C>() {
 			protected Void run(C val) throws Exception {
 				ps = c.prepareStatement(insorreplstmt);
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/AuthorizationFilter.java b/src/main/java/org/onap/dmaap/dbcapi/resources/AuthorizationFilter.java
index ab0e262..9dafb55 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/AuthorizationFilter.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/AuthorizationFilter.java
@@ -25,15 +25,15 @@
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 
+import org.apache.log4j.Logger;
 import org.onap.dmaap.dbcapi.authentication.AuthenticationErrorException;
 import org.onap.dmaap.dbcapi.service.ApiService;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
 
 
 @Authorization
 public class AuthorizationFilter implements ContainerRequestFilter   {
 	
-
+	private Logger logger = Logger.getLogger(AuthorizationFilter.class.getName());
 	
 	@Override
 	public void filter(ContainerRequestContext requestContext)
@@ -48,9 +48,11 @@
 		try {
 			apiResp.checkAuthorization();
 		} catch ( AuthenticationErrorException ae ) {
+			logger.error("Error", ae);
 			requestContext.abortWith( apiResp.unauthorized( apiResp.getErr().getMessage() ) );
 			return ;
 		} catch ( Exception e ) {
+			logger.error("Error", e);
 			requestContext.abortWith( apiResp.unavailable() ); 
 			return;
 		}