/*-
- * ================================================================================
- * 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.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * 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,
+ * 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.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.openecomp.portalapp.portal.logging.aop;
* @param securityEventType
* @param args
* @param passOnArgs
- * @return
+ * @return Object array
*/
public Object[] before(SecurityEventTypeEnum securityEventType, Object[] args, Object[] passOnArgs) {
String className = "";
- if (passOnArgs[0] != null) {
+ if (passOnArgs.length > 0 && passOnArgs[0] != null)
className = passOnArgs[0].toString();
- }
-
String methodName = "";
- if (passOnArgs[1] != null) {
+ if (passOnArgs.length > 1 && passOnArgs[1] != null)
methodName = passOnArgs[1].toString();
- }
// Initialize Request defaults only for controller methods.
MDC.put(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC());
MDC.put(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
getCurrentDateTimeUTC());
HttpServletRequest req = null;
- if (args[0] != null && args[0] instanceof HttpServletRequest) {
+ if (args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest) {
req = (HttpServletRequest) args[0];
this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName);
}
public void after(SecurityEventTypeEnum securityEventType, String statusCode, String responseCode, Object[] args,
Object[] returnArgs, Object[] passOnArgs) {
String className = "";
- if (passOnArgs[0] != null)
+ if (passOnArgs.length > 0 && passOnArgs[0] != null)
className = passOnArgs[0].toString();
-
// Method Name
String methodName = "";
- if (passOnArgs[1] != null)
+ if (passOnArgs.length > 1 && passOnArgs[1] != null)
methodName = passOnArgs[1].toString();
if (MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME) == null
// 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
+ if (securityEventType != null && args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest
&& securityEventType == SecurityEventTypeEnum.INCOMING_REST_MESSAGE
&& (MDC.get(EPCommonSystemProperties.FULL_URL) == null
|| MDC.get(EPCommonSystemProperties.FULL_URL) == "")) {
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
+ // add the metrics log
+ logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed.");
// Log security message, if necessary
if (securityEventType != null) {