diff options
Diffstat (limited to 'ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging')
8 files changed, 0 insertions, 1179 deletions
diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java deleted file mode 100644 index 15a4c7f0..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.aop; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface EPAuditLog { - String value() default ""; -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java deleted file mode 100644 index a03f5153..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java +++ /dev/null @@ -1,341 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.aop; - -import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY; -import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID; -import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; -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_INSTANCE_ID; -import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; - -import java.net.InetAddress; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.format.AuditLogFormatter; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; - -@org.springframework.context.annotation.Configuration -public class EPEELFLoggerAdvice { - - EELFLoggerDelegate adviceLogger = EELFLoggerDelegate.getLogger(EPEELFLoggerAdvice.class); - //DateTime Format according to the ECOMP Application Logging Guidelines. - private static final SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - - public void loadServletRequestBasedDefaults(HttpServletRequest req, SecurityEventTypeEnum securityEventType) { - try { - this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, req.getServletPath()); - } catch(Exception e) { - adviceLogger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - } - } - - public Object[] before(SecurityEventTypeEnum securityEventType, Object[] args, Object[] passOnArgs) { - String className = ""; - if (passOnArgs[0]!=null) { - className = passOnArgs[0].toString(); - } - - String methodName = ""; - if (passOnArgs[1]!=null) { - methodName = passOnArgs[1].toString(); - } - - //Initialize Request defaults only for controller methods. - MDC.put(className + methodName + EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC()); - MDC.put(EPSystemProperties.TARGET_ENTITY, EPSystemProperties.ECOMP_PORTAL_BE); - MDC.put(EPSystemProperties.TARGET_SERVICE_NAME, methodName); - if (securityEventType!=null) { - MDC.put(className + methodName + EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC()); - HttpServletRequest req = null; - if (args[0]!=null && args[0] instanceof HttpServletRequest ) { - req = (HttpServletRequest)args[0]; - this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName); - } - } - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); - - //StopWatch stopWatch = new StopWatch("Metrics for " + className + "." + methodName); - //stopWatch.start(); - - logger.debug(EELFLoggerDelegate.debugLogger, "Entered executing " + methodName +"."); - - return new Object[] {""}; - } - - public void after(SecurityEventTypeEnum securityEventType, String statusCode, String responseCode, Object[] args, Object[] returnArgs, Object[] passOnArgs) { - //ClassName - String className = ""; - if (passOnArgs[0]!=null) { - className = passOnArgs[0].toString(); - } - - //Method Name - String methodName = ""; - if (passOnArgs[1]!=null) { - methodName = passOnArgs[1].toString(); - } - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); - /*/ - StopWatch stopWatch = (StopWatch)returnArgs[0]; - if (stopWatch!=null && stopWatch.isRunning()) { - stopWatch.stop(); - MDC.put(SystemProperties.MDC_TIMER, stopWatch.getTotalTimeMillis() + "ms"); - } - /**/ - - if (MDC.get(EPSystemProperties.TARGET_SERVICE_NAME) == null || MDC.get(EPSystemProperties.TARGET_SERVICE_NAME) == "") { - MDC.put(EPSystemProperties.TARGET_SERVICE_NAME, methodName); - } - - if (MDC.get(EPSystemProperties.TARGET_ENTITY) == null || MDC.get(EPSystemProperties.TARGET_ENTITY) == "") { - MDC.put(EPSystemProperties.TARGET_ENTITY, EPSystemProperties.ECOMP_PORTAL_BE); - } - - MDC.put(EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, MDC.get(className + methodName + EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP)); - MDC.put(EPSystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); - this.calculateDateTimeDifference(MDC.get(EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP), MDC.get(EPSystemProperties.METRICSLOG_END_TIMESTAMP)); - - //Making sure to reload the INCOMING request MDC defaults if they have - //been wiped out by either Outgoing or LDAP Phone book search operations. - if (securityEventType!=null && args[0]!=null && args[0] instanceof HttpServletRequest && - securityEventType==SecurityEventTypeEnum.INCOMING_REST_MESSAGE && - (MDC.get(EPSystemProperties.FULL_URL)==null || MDC.get(EPSystemProperties.FULL_URL)=="")) { - HttpServletRequest req = (HttpServletRequest)args[0]; - this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName); - } - - //Use external API response code in case if it resulted in an error. - String externalAPIResponseCode = MDC.get(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE); - if (externalAPIResponseCode==null || externalAPIResponseCode=="" || externalAPIResponseCode.trim().equalsIgnoreCase("200")) { - MDC.put(EPSystemProperties.RESPONSE_CODE, responseCode); - MDC.put(EPSystemProperties.STATUS_CODE, statusCode); - } else { - MDC.put(EPSystemProperties.RESPONSE_CODE, externalAPIResponseCode); - MDC.put(EPSystemProperties.STATUS_CODE, "ERROR"); - } - - logger.debug(EELFLoggerDelegate.debugLogger, "Finished executing " + methodName + "."); - logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed."); - - //Log security message, if necessary - if (securityEventType!=null) { - MDC.put(EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, MDC.get(className + methodName + EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP)); - MDC.put(EPSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); - this.calculateDateTimeDifference(MDC.get(EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP), MDC.get(EPSystemProperties.AUDITLOG_END_TIMESTAMP)); - - this.logSecurityMessage(logger, securityEventType, methodName); - - //Outgoing & LDAP messages are part of Incoming requests so, - //keep "RequestId", "PartnerName", "ServiceName", "LoginId" & - //"ResponseCode" etc. in memory and remove it only when - //finished processing the parent incoming message. - if (securityEventType!=SecurityEventTypeEnum.OUTGOING_REST_MESSAGE && - securityEventType!=SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { - MDC.remove(MDC_KEY_REQUEST_ID); - MDC.remove(EPSystemProperties.PARTNER_NAME); - MDC.remove(Configuration.MDC_SERVICE_NAME); - MDC.remove(EPSystemProperties.MDC_LOGIN_ID); - MDC.remove(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE); - } - - //clear when finishes audit logging - MDC.remove(EPSystemProperties.FULL_URL); - MDC.remove(EPSystemProperties.PROTOCOL); - MDC.remove(EPSystemProperties.STATUS_CODE); - MDC.remove(className + methodName + EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); - MDC.remove(EPSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); - MDC.remove(EPSystemProperties.AUDITLOG_END_TIMESTAMP); - MDC.remove(EPSystemProperties.RESPONSE_CODE); - } - MDC.remove(className + methodName + EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); - MDC.remove(EPSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); - MDC.remove(EPSystemProperties.METRICSLOG_END_TIMESTAMP); - MDC.remove(EPSystemProperties.MDC_TIMER); - MDC.remove(EPSystemProperties.TARGET_ENTITY); - MDC.remove(EPSystemProperties.TARGET_SERVICE_NAME); - } - - private void logSecurityMessage(EELFLoggerDelegate logger, SecurityEventTypeEnum securityEventType, String restMethod) { - StringBuilder additionalInfoAppender = new StringBuilder(); - String auditMessage = ""; - - if (securityEventType == SecurityEventTypeEnum.OUTGOING_REST_MESSAGE) { - additionalInfoAppender.append(String.format("%s '%s' request was initiated.", - restMethod, MDC.get(EPSystemProperties.TARGET_SERVICE_NAME))); - } else if (securityEventType==SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { - additionalInfoAppender.append("LDAP Phonebook search operation is performed."); - } else { - additionalInfoAppender.append(String.format("%s request was received.", restMethod)); - - if (securityEventType == SecurityEventTypeEnum.FE_LOGIN_ATTEMPT) { - String loginId = ""; - String additionalMessage = " Successfully authenticated."; - loginId = MDC.get(EPSystemProperties.MDC_LOGIN_ID); - if (loginId==null || loginId=="" || loginId== EPSystemProperties.UNKNOWN) { - additionalMessage = " No cookies are found."; - } - additionalInfoAppender.append(additionalMessage); - } else if (securityEventType == SecurityEventTypeEnum.FE_LOGOUT) { - additionalInfoAppender.append(" User has been successfully logged out."); - } - } - - String fullURL = MDC.get(EPSystemProperties.FULL_URL); - if (fullURL!=null && fullURL!="") { - additionalInfoAppender.append(" Request-URL:" + MDC.get(EPSystemProperties.FULL_URL)); - } - - auditMessage = AuditLogFormatter.getInstance().createMessage( MDC.get(EPSystemProperties.PROTOCOL), - securityEventType.name(), - MDC.get(EPSystemProperties.MDC_LOGIN_ID), - additionalInfoAppender.toString()); - - logger.info(EELFLoggerDelegate.auditLogger, auditMessage); - } - - private void setHttpRequestBasedDefaultsIntoGlobalLoggingContext(HttpServletRequest req, SecurityEventTypeEnum securityEventType, String restMethod) { - //No need to load the request based defaults for the following security messages - //since either they are initiated by the Portal BE or not Http request based. - if (req!=null) { - if (securityEventType!=SecurityEventTypeEnum.OUTGOING_REST_MESSAGE && - securityEventType!=SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH && - securityEventType!=SecurityEventTypeEnum.INCOMING_UEB_MESSAGE) { - //Load the RequestID (aka TrasactionId) into MDC context. - String requestId = UserUtils.getRequestId(req); - if (requestId=="" || requestId==null) { - requestId = UUID.randomUUID().toString(); - } - MDC.put(MDC_KEY_REQUEST_ID, requestId); - - //Load user agent into MDC context, if available. - String accessingClient = "Unknown"; - accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME); - if (accessingClient!=null && accessingClient!="" && - (accessingClient.contains("Mozilla") || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) { - accessingClient = EPSystemProperties.ECOMP_PORTAL_FE; - } - MDC.put(EPSystemProperties.PARTNER_NAME, accessingClient); - - //Load loginId into MDC context. - String loginId = ""; - try { - loginId = UserUtils.getUserIdFromCookie(req); - } catch (Exception e) { - adviceLogger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - } - if (loginId == null || loginId == "") { - EPUser user = EPUserUtils.getUserSession(req); - if (user != null) { - loginId = user.getLoginId(); - } - - if (loginId==null || loginId=="") { - loginId = "Unknown"; - } - } - MDC.put(EPSystemProperties.MDC_LOGIN_ID, loginId); - - //Rest URL & Protocol - String restURL = ""; - MDC.put(EPSystemProperties.FULL_URL, EPSystemProperties.UNKNOWN); - MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTP); - restURL = UserUtils.getFullURL(req); - if (restURL!=null && restURL!="") { - MDC.put(EPSystemProperties.FULL_URL, restURL); - if (restURL.toLowerCase().contains("https")) { - MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTPS); - } - } - - //Rest Path - MDC.put(MDC_SERVICE_NAME, restMethod); - String restPath = req.getServletPath(); - if (restPath!=null && restPath!="") { - MDC.put(MDC_SERVICE_NAME, restPath); - } - - //Client IPAddress i.e. IPAddress of the remote host who is making this request. - String clientIPAddress = ""; - clientIPAddress = req.getHeader("X-FORWARDED-FOR"); - if (clientIPAddress == null) { - clientIPAddress = req.getRemoteAddr(); - } - MDC.put(EPSystemProperties.CLIENT_IP_ADDRESS, clientIPAddress); - } else if(securityEventType==SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { - MDC.put(EPSystemProperties.TARGET_ENTITY, "Phonebook"); - MDC.put(EPSystemProperties.TARGET_SERVICE_NAME, "search"); - } - } else { - MDC.put(MDC_SERVICE_NAME, restMethod); - MDC.put(EPSystemProperties.PARTNER_NAME, EPSystemProperties.ECOMP_PORTAL_FE); - } - - MDC.put(MDC_SERVICE_INSTANCE_ID, ""); - MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.toString()); - try { - MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName()); - MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); - MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); - } catch (Exception e) { - adviceLogger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - } - } - - private String getCurrentDateTimeUTC() { - String currentDateTime = ecompLogDateFormat.format(new Date()); - return currentDateTime; - } - - private void calculateDateTimeDifference(String beginDateTime, String endDateTime) { - if (beginDateTime!=null && endDateTime!=null) { - try { - Date beginDate = ecompLogDateFormat.parse(beginDateTime); - Date endDate = ecompLogDateFormat.parse(endDateTime); - String timeDifference = String.format("%d ms", endDate.getTime() - beginDate.getTime()); - MDC.put(SystemProperties.MDC_TIMER, timeDifference); - } catch(Exception e) { - adviceLogger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - } - } - } - - public String getInternalResponseCode() { - return MDC.get(EPSystemProperties.RESPONSE_CODE); - } -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java deleted file mode 100644 index 80ae9262..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java +++ /dev/null @@ -1,204 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.aop; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; -import org.springframework.beans.factory.annotation.Autowired; - -@Aspect -@org.springframework.context.annotation.Configuration -public class EPEELFLoggerAspect { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPEELFLoggerAspect.class); - - @Autowired - EPEELFLoggerAdvice epAdvice; - - /* - * Point-cut expression to handle all INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.controller.*.*(..))") - public void incomingAuditMessages() {} - - /* - * Handles all INCOMING_REST_MESSAGES from kpiDashboard - */ - @Pointcut("execution(public * org.openecomp.portalapp.kpidash.controller.*.*(..))") - public void kpiDashboardAuditMessages() {} - - /* - * Point-cut expression to handle all session management INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.sessionmgt.*.*(..))") - public void sessionMgtIncomingAuditMessages() {} - - /* - * Point-cut expression to handle UserProfileController INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.UserProfileController.*(..))") - public void userProfileIncomingAuditMessages() {} - - /* - * Point-cut expression to handle UserProfileController INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.WelcomeController.*(..))") - public void welcomeIncomingAuditMessages() {} - - /* - * Point-cut expression to handle INCOING Logout Rest Messages - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.ECOMPLogoutController.*(..))") - public void logoutAuditMessages() {} - - - /* - * Point-cut expression which handles all the OUTGOING_REST_MESSAGES. - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.service.ApplicationsRestClientServiceImpl.*(..))") - public void outgoingAuditMessages() {} - - /* - * Point-cut expression to handle all the session management OUTGOING_REST_MESSAGES. - */ - @Pointcut("execution(public * org.openecomp.portalapp.service.sessionmgt.SessionCommunication.*(..))") - public void sessionMgtOutgoingAuditMessages() {} - - /* - * Point-cut expression which handles all the LDAP_PHONEBOOK_USER_SEARCH calls. - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.service.EPLdapServiceImpl.*(..))") - public void phoneBookSearchAuditMessages() {} - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at class-level - */ - @Around("(incomingAuditMessages() || kpiDashboardAuditMessages() || sessionMgtIncomingAuditMessages() || " - + "userProfileIncomingAuditMessages() || welcomeIncomingAuditMessages()) && @within(epAuditLog)") - public Object incomingAuditMessagesAroundClass(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.INCOMING_REST_MESSAGE); - } - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at class-level - */ - @Around("(outgoingAuditMessages() || sessionMgtOutgoingAuditMessages()) && @within(epAuditLog)") - public Object outgoingAuditMessagesAroundClass(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.OUTGOING_REST_MESSAGE); - } - - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at method-level - */ - @Around("(outgoingAuditMessages() || sessionMgtOutgoingAuditMessages()) && @annotation(epAuditLog)") - public Object outgoingAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.OUTGOING_REST_MESSAGE); - } - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at method-level - */ - @Around("(incomingAuditMessages() || kpiDashboardAuditMessages() || sessionMgtIncomingAuditMessages() ||" - + "userProfileIncomingAuditMessages() || welcomeIncomingAuditMessages()) && @annotation(epAuditLog)") - public Object incomingAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.INCOMING_REST_MESSAGE); - } - - @Around("@annotation(epAuditLog)") - public Object loginAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.FE_LOGIN_ATTEMPT); - } - - @Around("logoutAuditMessages() && @annotation(epAuditLog)") - public Object logoutAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.FE_LOGOUT); - } - - @Around("phoneBookSearchAuditMessages() && @annotation(epAuditLog)") - public Object phonebookSearchAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH); - } - - private Object logAroundMethod(ProceedingJoinPoint joinPoint, SecurityEventTypeEnum securityEventType) throws Throwable { - //Before - Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(), joinPoint.getSignature().getName()}; - Object[] returnArgs = epAdvice.before(securityEventType, joinPoint.getArgs(), passOnArgs); - - //Call the actual method - Object result = null; - String statusCode = "COMPLETE"; - String responseCode = "200"; - try { - result = joinPoint.proceed(); - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - statusCode = "ERROR"; - responseCode = "500"; //Internal server error - } - - //Check the result - if (securityEventType!=null) { - if (result==null) { - statusCode = "ERROR"; - //Check if there is an internal response code - //and use it if the caller function has configured it. - responseCode = epAdvice.getInternalResponseCode(); - if (responseCode==null||responseCode=="") { - responseCode = "500"; //Internal server error - } - } else if (result instanceof FieldsValidator) { - FieldsValidator fieldsValidator = (FieldsValidator) result; - if (fieldsValidator!=null && fieldsValidator.httpStatusCode!=null) { - responseCode = fieldsValidator.httpStatusCode.toString(); - } - } - } - - //After - epAdvice.after(securityEventType, statusCode, responseCode, joinPoint.getArgs(), returnArgs, passOnArgs); - - return result; - } - - //Metrics Logging - @Pointcut("execution(* *(..))") - public void performMetricsLogging() {} - - @Around("performMetricsLogging() && @within(epMetricsLog)") - public Object metricsLoggingAroundClass(ProceedingJoinPoint joinPoint, EPMetricsLog epMetricsLog) throws Throwable { - return this.logAroundMethod(joinPoint, null); - } - - @Around("performMetricsLogging() && @annotation(epMetricsLog)") - public Object metricsLoggingAroundMethod(ProceedingJoinPoint joinPoint, EPMetricsLog epMetricsLog) throws Throwable { - return this.logAroundMethod(joinPoint, null); - } -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java deleted file mode 100644 index cc325a12..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.aop; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface EPMetricsLog { - String value() default ""; -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties deleted file mode 100644 index 2533dfa8..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties +++ /dev/null @@ -1,141 +0,0 @@ -### -# ================================================================================ -# eCOMP Portal -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ================================================================================ -### -######################################################################## -#Resource key=Error Code|Message text|Resolution text |Description text -####### -#Newlines can be utilized to add some clarity ensuring continuing line -#has atleast one leading space -#ResourceKey=\ -# ERR0000E\ -# Sample error msg txt\ -# Sample resolution msg\ -# Sample description txt -# -###### -#Error code classification category -#100 Permission errors -#200 Availability errors/Timeouts -#300 Data errors -#400 Schema Interface type/validation errors -#500 Business process errors -#900 Unknown errors -# -######################################################################## - -# Define Alarm Codes Specific to ECOMP Portal -BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT= ||Reason: {0}.|\ - An Authentication failure occurred during access to UEB server. Please check that UEB keys are configured correctly under fusion.properties file. - -BERESTAPIAUTHENTICATIONERROR = |||Please check application credentials defined in Database or portal.properties file. - -INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. - -INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. - -INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. - -INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. - -BEHEALTHCHECKERROR= |||Please check the logs for more information. - -BEHEALTHCHECKMYSQLERROR= ||Please check the logs for more information.|\ - Check connectivity to MYSQL is configured correctly under system.properties file. - -BEHEALTHCHECKUEBCLUSTERERROR= ||Please check the logs for more information.|\ - Check connectivity to UEB cluster which is configured under portal.properties file. - -FEHEALTHCHECKERROR= |||Please check connectivity from this FE instance towards BE or BE Load Balancer. - -BEHEALTHCHECKRECOVERY= |||Please check logs for more specific information about the problem. - -BEHEALTHCHECKMYSQLRECOVERY= |||Please check logs for more specific information about the problem. - -BEHEALTHCHECKUEBCLUSTERRECOVERY= |||Please check logs for more specific information about the problem. - -FEHEALTHCHECKRECOVERY= |||Please check logs for more specific information about the problem. - -#UEB communication -BEUEBCONNECTIONERROR_ONE_ARGUMENT= ||Reason: {0}.|\ - Please check UEB server list and keys configured under Portal.Properties file. - -BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT= ||Cannot reach host {0}.|\ - Please check UEB server list and keys configured under Portal.Properties file. - -#Onboarding apps -BEUEBREGISTERONBOARDINGAPPERROR= ||Reason: {0}.|\ - Please check UEB server list and keys configured under Portal.Properties file. - -#HTTP communication -BEHTTPCONNECTIONERROR_ONE_ARGUMENT= ||Reason: {0}.|Please check the logs for more information. - -INTERNALCONNECTIONINFO_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. - -INTERNALCONNECTIONWARNING_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. - -INTERNALCONNECTIONERROR_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. - -INTERNALCONNECTIONFATAL_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. - -BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT= ||Data not found: {0}.|\ - An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic. - -#Login error codes -BEUSERMISSINGERROR_ONE_ARGUMENT= |||\ - User {0} must be added to the corresponding application with proper user roles. - -BEUSERINACTIVEWARNING_ONE_ARGUMENT= |||\ - User {0} must be added to the corresponding application with proper user roles. - -BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT= |||\ - User {0} should be given proper administrator role for the corresponding application to perform the necessary actions. - -BEINVALIDJSONINPUT= |||Please check error logs for more information. - -BEINCORRECTHTTPSTATUSERROR= |||Please check logs for more information. - -BEINITIALIZATIONERROR= |||Please check logs for more information. - -BEUEBSYSTEMERROR= ||\ - Operation: {0}.|\ - An error occurred in {1} distribution mechanism. Please check the logs for more information. - -BEDAOSYSTEMERROR= |||Please check MySQL DB health or look at the logs for more details. - -BESYSTEMERROR= |||Please check logs for more information. - -BEEXECUTEROLLBACKERROR= |||Please check MYSQL DB health or look at the logs for more details. - -FEHTTPLOGGINGERROR= |||Please check MYSQL DB health or look at the logs for more details. - -FEPORTALSERVLETERROR= |||Please check logs for more specific information about the problem. - -BEDAOCLOSESESSIONERROR= |||Please check MYSQL DB health or look at the logs form more details. - -BERESTAPIGENERALERROR= |||Please check error log for more information. - -FEHEALTHCHECKGENERALERROR= |||Please check error log for more information. - -INTERNALUNEXPECTEDINFO_ONE_ARGUMENT= |||Description: {0}. - -INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT= |||Description: {0}. - -INTERNALUNEXPECTEDERROR_ONE_ARGUMENT= |||Description: {0}. - -INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT= |||Description: {0}. diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java deleted file mode 100644 index aae56e93..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.format; - -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.format.ErrorSeverityEnum; -import org.openecomp.portalsdk.core.logging.format.ErrorTypeEnum; - -/** - * - * @author rc580q - * Add ECOMP Portal Specific Error Code Enums here, for generic - * ones (ones you think are useful not only Portal but also SDK), add it - * to the enum class AppMessagesEnum defined in SDK. - */ -public enum EPAppMessagesEnum { - /* - 100-199 Security/Permission Related - - Authentication problems (from external client, to external server) - - Certification errors - - - - 200-299 Availability/Timeout Related - - connectivity error - - connection timeout - - 300-399 Data Access/Integrity Related - - Data in graph in invalid(E.g. no creator is found for service) - - Artifact is missing in ES, but exists in graph. - - 400-499 Schema Interface Type/Validation - - received Pay-load checksum is invalid - - received JSON is not valid - - 500-599 Business/Flow Processing Related - - check out to service is not allowed - - Roll-back is done - - failed to generate heat file - - - 600-899 Reserved - do not use - - 900-999 Unknown Errors - - Unexpected exception - */ - - BeUebAuthenticationError(EPErrorCodesEnum.BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR100E", "An Authentication failure occurred during access to UEB server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeRestApiAuthenticationError(EPErrorCodesEnum.BERESTAPIAUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR101E", "Rejected an incoming REST API request due to invalid credentials", "", "Please check application credentials defined in Database or properties files."), - - InternalAuthenticationInfo(EPErrorCodesEnum.INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR199I", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationWarning(EPErrorCodesEnum.INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR199W", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationError(EPErrorCodesEnum.INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR199E", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationFatal(EPErrorCodesEnum.INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR199F", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - BeHealthCheckError(EPErrorCodesEnum.BeHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR200E", "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", "", "Please check the logs for more information."), - - BeHealthCheckMySqlError(EPErrorCodesEnum.BEHEALTHCHECKMYSQLERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR201E", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", "Check connectivity to MYSQL is configured correctly under system.properties file."), - - BeHealthCheckUebClusterError(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR203E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", "Check connectivity to UEB cluster which is configured under portal.properties file."), - - FeHealthCheckError(EPErrorCodesEnum.FEHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR204E", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", "Please check connectivity from this FE instance towards BE or BE Load Balancer."), - - BeHealthCheckRecovery(EPErrorCodesEnum.BEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR205I", "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", "Please check logs for more specific information about the problem."), - - BeHealthCheckMySqlRecovery(EPErrorCodesEnum.BEHEALTHCHECKMYSQLRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR206I", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", "Please check logs for more specific information about the problem."), - - BeHealthCheckUebClusterRecovery(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR208I", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", "Please check logs for more specific information about the problem."), - - FeHealthCheckRecovery(EPErrorCodesEnum.FEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR209I", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", "Please check logs for more specific information about the problem."), - - BeUebConnectionError(EPErrorCodesEnum.BEUEBCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR210E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeUebUnkownHostError(EPErrorCodesEnum.BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR211E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeUebRegisterOnboardingAppError(EPErrorCodesEnum.BEUEBREGISTERONBOARDINGAPPERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR212E", "Failed to register the On-boarding application with UEB Communication server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeHttpConnectionError(EPErrorCodesEnum.BEHTTPCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR213E", "It could be that communication to an external application might resulted an exception or failed to reach the external application", - "Details: {0}.", "Please check logs for more information."), - - InternalConnectionInfo(EPErrorCodesEnum.INTERNALCONNECTIONINFO_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR299I", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionWarning(EPErrorCodesEnum.INTERNALCONNECTIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR299W", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionError(EPErrorCodesEnum.INTERNALCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR299E", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionFatal(EPErrorCodesEnum.INTERNALCONNECTIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR299F", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - BeUebObjectNotFoundError(EPErrorCodesEnum.BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR303E", "Error occurred during access to U-EB Server.", "Data not found: {0}.", "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."), - - BeUserMissingError(EPErrorCodesEnum.BEUSERMISSINGERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR310E", "User is not found", "", "User {0} must be added to the corresponding application with proper user roles."), - - BeUserInactiveWarning(EPErrorCodesEnum.BEUSERINACTIVEWARNING_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR313W", "User is found but in-active", "", "User {0} must be added to the corresponding application with proper user roles."), - - BeUserAdminPrivilegesInfo(EPErrorCodesEnum.BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR314W", "User is found but don't have administrative privileges", "", "User {0} should be given administrator role for the corresponding application to perform the necessary actions."), - - BeInvalidJsonInput(EPErrorCodesEnum.BEINVALIDJSONINPUT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR405E", "Failed to convert JSON input to object", "", "Please check logs for more information."), - - BeIncorrectHttpStatusError(EPErrorCodesEnum.BEINCORRECTHTTPSTATUSERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR407E", "Communication to an external application is resulted in with Incorrect Http response code", "", "Please check logs for more information."), - - BeInitializationError(EPErrorCodesEnum.BEINITIALIZATIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR500E", "ECOMP-PORTAL Back-end was not initialized properly", "", "Please check logs for more information."), - - BeUebSystemError(EPErrorCodesEnum.BEUEBSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR502E", "Error occurred during access to U-EB Server", "Details: {0}.", "An error occurred in {1} distribution mechanism. Please check the logs for more information."), - - BeDaoSystemError(EPErrorCodesEnum.BEDAOSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR505E", "Performing DDL or DML operations on database might have failed", "", "Please check MySQL DB health or look at the logs for more details."), - - BeSystemError(EPErrorCodesEnum.BESYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR506E", "Unexpected error during operation", "", "Please check logs for more information."), - - BeExecuteRollbackError(EPErrorCodesEnum.BEEXECUTEROLLBACKERROR, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR507E", "Roll-back operation towards database has failed", "", "Please check MYSQL DB health or look at the logs for more details."), - - FeHttpLoggingError(EPErrorCodesEnum.FEHTTPLOGGINGERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.ERROR, - "ERR517E", "Error when logging FE HTTP request/response", "", "Please check MYSQL DB health or look at the logs for more details."), - - FePortalServletError(EPErrorCodesEnum.FEPORTALSERVLETERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR518E", "Error when trying to access FE Portal page.", "", "Please check logs for more information."), - - BeDaoCloseSessionError(EPErrorCodesEnum.BEDAOCLOSESESSIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR519E", "Close local session operation with database failed", "", "Please check MYSQL DB health or look at the logs form more details."), - - BeRestApiGeneralError(EPErrorCodesEnum.BERESTAPIGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR900E", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", "Please check error log for more information."), - - FeHealthCheckGeneralError(EPErrorCodesEnum.FEHEALTHCHECKGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR901E", "General error during FE Health Check", "", "Please check error log for more information."), - - InternalUnexpectedInfo(EPErrorCodesEnum.INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR999I", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedWarning(EPErrorCodesEnum.INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR999W", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedError(EPErrorCodesEnum.INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR999E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedFatal(EPErrorCodesEnum.INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR999F", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - ; - - ErrorTypeEnum eType; - AlarmSeverityEnum alarmSeverity; - EPErrorCodesEnum messageCode; - ErrorSeverityEnum errorSeverity; - String errorCode; - String errorDescription; - String details; - String resolution; - - EPAppMessagesEnum(EPErrorCodesEnum messageCode, ErrorTypeEnum eType, AlarmSeverityEnum alarmSeverity, ErrorSeverityEnum errorSeverity, String errorCode, String errorDescription, - String details, String resolution) { - this.messageCode = messageCode; - this.eType = eType; - this.alarmSeverity = alarmSeverity; - this.errorSeverity = errorSeverity; - this.errorCode = errorCode; - this.errorDescription = errorDescription; - this.details = details; - this.resolution = resolution; - } - - public String getDetails() { - return this.details; - } - - public String getResolution() { - return this.resolution; - } - public String getErrorCode() { - return this.errorCode; - } - - public String getErrorDescription() { - return this.errorDescription; - } - - public ErrorSeverityEnum getErrorSeverity() { - return this.errorSeverity; - } - - public void setErrorSeverity(ErrorSeverityEnum errorSeverity) { - this.errorSeverity = errorSeverity; - } - - public EPErrorCodesEnum getMessageCode() { - return messageCode; - } - - public void setMessageCode(EPErrorCodesEnum messageCode) { - this.messageCode = messageCode; - } - - public AlarmSeverityEnum getAlarmSeverity() { - return alarmSeverity; - } - - public void setAlarmSeverity(AlarmSeverityEnum alarmSeverity) { - this.alarmSeverity = alarmSeverity; - } - - public ErrorTypeEnum getErrorType() { - return eType; - } - - public void setErrorType(ErrorTypeEnum eType) { - this.eType = eType; - } -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java deleted file mode 100644 index 39771e3d..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.format; - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import com.att.eelf.i18n.EELFResourceManager; - -/** - * - * @author rc580q - * Add ECOMP Portal Specific Error Code Enums here, for generic - * ones (ones you think are useful not only Portal but also SDK), add it - * to the enum class AppMessagesEnum defined in SDK. - */ -public enum EPErrorCodesEnum implements EELFResolvableErrorEnum { - BERESTAPIAUTHENTICATIONERROR, - BEHTTPCONNECTIONERROR_ONE_ARGUMENT, - BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, - - INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, - INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, - INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, - INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, - - BEHEALTHCHECKRECOVERY, - BEHEALTHCHECKMYSQLRECOVERY, - BEHEALTHCHECKUEBCLUSTERRECOVERY, - FEHEALTHCHECKRECOVERY, - BeHEALTHCHECKERROR, - - BEHEALTHCHECKMYSQLERROR, - BEHEALTHCHECKUEBCLUSTERERROR, - FEHEALTHCHECKERROR, - BEUEBCONNECTIONERROR_ONE_ARGUMENT, - BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, - BEUEBREGISTERONBOARDINGAPPERROR, - - INTERNALCONNECTIONINFO_ONE_ARGUMENT, - INTERNALCONNECTIONWARNING_ONE_ARGUMENT, - INTERNALCONNECTIONERROR_ONE_ARGUMENT, - INTERNALCONNECTIONFATAL_ONE_ARGUMENT, - - BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, - BEUSERMISSINGERROR_ONE_ARGUMENT, - - BEUSERINACTIVEWARNING_ONE_ARGUMENT, - BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, - - BEINVALIDJSONINPUT, - BEINCORRECTHTTPSTATUSERROR, - - BEINITIALIZATIONERROR, - BEUEBSYSTEMERROR, - BEDAOSYSTEMERROR, - BESYSTEMERROR, - BEEXECUTEROLLBACKERROR, - - FEHTTPLOGGINGERROR, - FEPORTALSERVLETERROR, - BEDAOCLOSESESSIONERROR, - - BERESTAPIGENERALERROR, - FEHEALTHCHECKGENERALERROR, - - INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, - INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, - INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, - INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, - ; - - /** - * Static initializer to ensure the resource bundles for this class are loaded... - * Here this application loads messages from three bundles - */ - static { - EELFResourceManager.loadMessageBundle("org/openecomp/portalapp/portal/logging/format/ApplicationCodes"); - } -} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java deleted file mode 100644 index 489a68a8..00000000 --- a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.portal.logging.logic; - -import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY; - -import java.text.MessageFormat; - -import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.format.ErrorSeverityEnum; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.slf4j.MDC; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class EPLogUtil { - private static EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger(); - public static void logEcompError(EPAppMessagesEnum epMessageEnum, String... param) { - try { - AlarmSeverityEnum alarmSeverityEnum = epMessageEnum.getAlarmSeverity(); - ErrorSeverityEnum errorSeverityEnum = epMessageEnum.getErrorSeverity(); - - MDC.put(MDC_ALERT_SEVERITY, alarmSeverityEnum.name()); - MDC.put("ErrorCode", epMessageEnum.getErrorCode()); - MDC.put("ErrorDescription", epMessageEnum.getErrorDescription()); - MDC.put("ClassName", EPLogUtil.class.getName()); - - String resolution = EPLogUtil.formatMessage(epMessageEnum.getDetails() + " " + epMessageEnum.getResolution(), (Object[]) param); - if (errorSeverityEnum == ErrorSeverityEnum.WARN) { - errorLogger.warn(resolution); - } else if(errorSeverityEnum == ErrorSeverityEnum.INFO) { - errorLogger.info(resolution); - } else { - errorLogger.error(resolution); - } - } catch(Exception e) { - errorLogger.error("Failed to log the error code. Details: " + UserUtils.getStackTrace(e)); - } finally { - MDC.remove("ErrorCode"); - MDC.remove("ErrorDescription"); - MDC.remove("ClassName"); - MDC.remove(MDC_ALERT_SEVERITY); - } - } - - public static String formatMessage(String message, Object...args) { - StringBuilder sbFormattedMessage = new StringBuilder(); - if (args!=null && args.length>0 && message!=null && message != "") { - MessageFormat mf = new MessageFormat(message); - sbFormattedMessage.append(mf.format(args)); - } else { - sbFormattedMessage.append(message); - } - - return sbFormattedMessage.toString(); - } -} |