package org.onap.dmaap.datarouter.provisioning;
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.cert.X509Certificate;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
-import java.security.cert.X509Certificate;
-import java.sql.Connection;
-import java.sql.SQLException;
import java.util.*;
import java.util.regex.Pattern;
-import static com.att.eelf.configuration.Configuration.*;
/**
* This is the base class for all Servlets in the provisioning code. It provides standard constants and some common
/**
* This logger is used to log provisioning events
*/
- protected static Logger eventlogger;
+ protected static EELFLogger eventlogger;
/**
* This logger is used to log internal events (errors, etc.)
*/
- protected static Logger intlogger;
+ protected static EELFLogger intlogger;
/**
* Authorizer - interface to the Policy Engine
*/
* Initialize data common to all the provisioning server servlets.
*/
protected BaseServlet() {
- if (eventlogger == null) {
- eventlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.events");
+ if(eventlogger == null) {
+ this.eventlogger = EELFManager.getInstance().getLogger("EventLog");
}
- if (intlogger == null) {
- intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
+ if(intlogger == null) {
+ this.intlogger = EELFManager.getInstance().getLogger("InternalLog");
}
if (authz == null) {
authz = new ProvAuthorizer(this);
loopback = InetAddress.getLoopbackAddress();
//checkHttpsRelaxation(); //Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.
} catch (UnknownHostException e) {
- // ignore
+ intlogger.info("BaseServlet.init: " + e.getMessage(), e);
}
}
return "Unauthorized address: " + remote;
}
} catch (UnknownHostException e) {
- intlogger.error("PROV0051 BaseServlet.isAuthorizedForProvisioning: ", e);
+ intlogger.error("PROV0051 BaseServlet.isAuthorizedForProvisioning: " + e.getMessage(), e);
return "Unauthorized address: " + remote;
}
// Does remote have a valid certificate?
return true;
}
} catch (UnknownHostException e) {
- intlogger.error("PROV0052 BaseServlet.isAuthorizedForInternal: ", e);
+ intlogger.error("PROV0052 BaseServlet.isAuthorizedForInternal: " + e.getMessage(), e);
}
return false;
}
}
}
} catch (UnknownHostException e) {
- intlogger.error("PROV0053 BaseServlet.addressMatchesNetwork: ", e);
+ intlogger.error("PROV0053 BaseServlet.addressMatchesNetwork: " + e.getMessage(), e);
return false;
}
return true;
thisPod = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
thisPod = "";
- intlogger.warn("PROV0014 Cannot determine the name of this provisioning server.");
+ intlogger.warn("PROV0014 Cannot determine the name of this provisioning server.", e);
}
// Normalize the nodes, and fill in nodeAddresses
intlogger.debug("PROV0003 DNS lookup: " + nodes[i] + " => " + na[i].toString());
} catch (UnknownHostException e) {
na[i] = null;
- intlogger.warn("PROV0004 Cannot lookup " + nodes[i] + ": " + e);
+ intlogger.warn("PROV0004 Cannot lookup " + nodes[i] + ": " + e.getMessage(), e);
}
}
intlogger.debug("PROV0003 DNS lookup: " + pods[i] + " => " + na[i].toString());
} catch (UnknownHostException e) {
na[i] = null;
- intlogger.warn("PROV0004 Cannot lookup " + pods[i] + ": " + e);
+ intlogger.warn("PROV0004 Cannot lookup " + pods[i] + ": " + e.getMessage(), e);
}
}
podAddresses = na;
try (InputStream inStream = getClass().getClassLoader().getResourceAsStream(MAILCONFIG_FILE)) {
mailprops.load(inStream);
} catch (IOException e) {
- intlogger.fatal("PROV9003 Opening properties: " + e.getMessage());
+ intlogger.error("PROV9003 Opening properties: " + e.getMessage(), e);
System.exit(1);
}
}
try {
notifyPSTeam(p.get("org.onap.dmaap.datarouter.provserver.https.relax.notify").toString());
} catch (Exception e) {
- intlogger.warn("Exception: " + e.getMessage());
+ intlogger.warn("Exception: " + e.getMessage(), e);
}
}
mailSendFlag = true;
* @param email - list of email ids to notify if HTTP relexcation is enabled.
* @author vs215k
**/
- private void notifyPSTeam(String email) throws Exception {
+ private void notifyPSTeam(String email) {
loadMailProperties(); //Load HTTPS Relex mail properties.
String[] emails = email.split(Pattern.quote("|"));
intlogger.info("HTTPS relaxation mail is sent to - : " + email);
} catch (MessagingException e) {
- intlogger.error("Invalid email address, unable to send https relaxation mail to - : " + email);
+ intlogger.error("Invalid email address, unable to send https relaxation mail to - : " + email, e);
+ } catch (UnknownHostException uhe) {
+ intlogger.error("UnknownHostException", uhe);
}
}
rv = bean.doInsert(conn);
} catch (SQLException e) {
rv = false;
- intlogger.warn("PROV0005 doInsert: " + e.getMessage());
+ intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e);
} finally {
if (conn != null) {
db.release(conn);
rv = bean.doUpdate(conn);
} catch (SQLException e) {
rv = false;
- intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
+ intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e);
} finally {
if (conn != null) {
db.release(conn);
rv = bean.doDelete(conn);
} catch (SQLException e) {
rv = false;
- intlogger.warn("PROV0007 doDelete: " + e.getMessage());
+ intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e);
} finally {
if (conn != null) {
db.release(conn);
return true;
}
} catch (JSONException e) {
- intlogger.error("JSONException: " + e.getMessage());
+ intlogger.error("JSONException: " + e.getMessage(), e);
}
}
return false;
MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
} catch (Exception e) {
- intlogger.error("Exception: " + e.getMessage());
+ intlogger.error("Exception: " + e.getMessage(), e);
}
}
}
return type + "|" + aafInstance + "|" + action;
} catch (Exception e) {
- intlogger.error("PROV7005 BaseServlet.getFeedPermission: ", e);
+ intlogger.error("PROV7005 BaseServlet.getFeedPermission: " + e.getMessage(), e);
}
return null;
}
}
return type + "|" + aafInstance + "|" + action;
} catch (Exception e) {
- intlogger.error("PROV7005 BaseServlet.getSubscriberPermission: ", e);
+ intlogger.error("PROV7005 BaseServlet.getSubscriberPermission: " + e.getMessage(), e);
}
return null;
}