diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-11-16 12:40:25 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-11-27 17:09:25 -0500 |
commit | fbe2ea46cf3d8902bf2425f12e679523455beaa3 (patch) | |
tree | 1d878c49399aa4a3d2e21352a820ac196481f974 /mso-api-handlers/mso-api-handler-common/src/main/java/org/onap | |
parent | 36f1cf5f916d97dfb8c1b345771e58951fea8849 (diff) |
Remove all usage of AlarmLogger
Fix broken UT from removing alarm logger
fixed compilation and merge issues
Remove all usage of AlarmLogger
Change-Id: Ic87abd51423274570bfca0ed976d9642a91a843d
Issue-ID: SO-1229
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-common/src/main/java/org/onap')
4 files changed, 13 insertions, 108 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java index 3c72e479c7..414ac8b3cc 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java @@ -33,7 +33,7 @@ import javax.xml.validation.Validator; import org.apache.commons.io.IOUtils; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.xml.sax.SAXException; @@ -55,7 +55,7 @@ public class XMLValidator { private Schema schema; private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, XMLValidator.class); - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + public XMLValidator (String xsdFile){ @@ -94,7 +94,7 @@ public class XMLValidator { } catch (Exception e) { msoLogger.error (MessageEnum.APIH_CANNOT_READ_SCHEMA, "", "", MsoLogger.ErrorCode.SchemaError, "APIH cannot read schema file", e); - alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, "Unable to read the schema file"); + return "ErrorDetails: " + "Unable to read the schema file"; } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java index dc52bfcc6b..fdf6b80e1c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java @@ -23,7 +23,7 @@ package org.onap.so.apihandlerinfra.exceptions; import java.util.List; -import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; + import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; public abstract class ApiException extends Exception{ @@ -34,7 +34,7 @@ public abstract class ApiException extends Exception{ private int httpResponseCode; private String messageID; private ErrorLoggerInfo errorLoggerInfo; - private AlarmLoggerInfo alarmLoggerInfo; + private List<String> variables; public ApiException(Builder builder){ @@ -44,7 +44,6 @@ public abstract class ApiException extends Exception{ this.messageID = builder.messageID; this.variables = builder.variables; this.errorLoggerInfo = builder.errorLoggerInfo; - this.alarmLoggerInfo = builder.alarmLoggerInfo; this.variables = builder.variables; } @@ -64,9 +63,6 @@ public abstract class ApiException extends Exception{ return errorLoggerInfo; } - public AlarmLoggerInfo getAlarmLoggerInfo() { - return alarmLoggerInfo; - } public List<String> getVariables() { return variables; @@ -78,7 +74,7 @@ public abstract class ApiException extends Exception{ private int httpResponseCode; private String messageID; private ErrorLoggerInfo errorLoggerInfo = null; - private AlarmLoggerInfo alarmLoggerInfo = null; + private List<String> variables = null; public Builder(String message, int httpResponseCode, String messageID) { @@ -112,11 +108,6 @@ public abstract class ApiException extends Exception{ return (T) this; } - public T alarmInfo(AlarmLoggerInfo alarmLoggerInfo){ - this.alarmLoggerInfo = alarmLoggerInfo; - return (T) this; - } - public T variables(List<String> variables) { this.variables = variables; return (T) this; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java index 7c49eeadcc..ef19852cd1 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java @@ -36,10 +36,10 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; -import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; + import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; @@ -53,7 +53,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; public class ApiExceptionMapper implements ExceptionMapper<ApiException> { private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ApiExceptionMapper.class); - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + private final JAXBContext context; private final Marshaller marshaller; @@ -81,14 +81,14 @@ public class ApiExceptionMapper implements ExceptionMapper<ApiException> { String messageId = exception.getMessageID(); List<String> variables = exception.getVariables(); ErrorLoggerInfo errorLoggerInfo = exception.getErrorLoggerInfo(); - AlarmLoggerInfo alarmLoggerInfo = exception.getAlarmLoggerInfo(); + if (errorText.length() > 1999) { errorText = errorText.substring(0, 1999); } - writeErrorLog(exception, errorText, errorLoggerInfo, alarmLoggerInfo); + List<MediaType> typeList = Optional.ofNullable(headers.getAcceptableMediaTypes()).orElse(new ArrayList<>()); List<String> typeListString = typeList.stream().map(item -> item.toString()).collect(Collectors.toList()); @@ -139,14 +139,12 @@ public class ApiExceptionMapper implements ExceptionMapper<ApiException> { return requestErrorStr; } - protected void writeErrorLog(Exception e, String errorText, ErrorLoggerInfo errorLogInfo, AlarmLoggerInfo alarmLogInfo) { + protected void writeErrorLog(Exception e, String errorText, ErrorLoggerInfo errorLogInfo) { if( e!= null) logger.error(e); if(errorLogInfo != null) logger.error(errorLogInfo.getLoggerMessageType().toString(), errorLogInfo.getErrorSource(), errorLogInfo.getTargetEntity(), errorLogInfo.getTargetServiceName(), errorLogInfo.getErrorCode(), errorText); - if(alarmLogInfo != null){ - alarmLogger.sendAlarm(alarmLogInfo.getAlarm(),alarmLogInfo.getState(),alarmLogInfo.getDetail()); - } + } public ObjectMapper createObjectMapper(){ diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java deleted file mode 100644 index 2746da4f2d..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra.logging; - -import java.io.Serializable; - -public class AlarmLoggerInfo implements Serializable{ - /** - * - */ - private static final long serialVersionUID = -6730979289437576112L; - private String alarm; - private int state; - private String detail; - - - private AlarmLoggerInfo(String alarm, int state, String detail){ - this.alarm = alarm; - this.state = state; - this.detail = detail; - } - - public int getState() { - return state; - } - - public String getAlarm() { - return alarm; - } - - public String getDetail() { - return detail; - } - - public static class Builder{ - private String alarm = ""; - private int state; - private String detail = ""; - - public Builder(String alarm, int state, String detail){ - this.alarm = alarm; - this.state = state; - this.detail = detail; - } - - public Builder alarm(String alarm){ - this.alarm = alarm; - return this; - } - - public Builder state(int state){ - this.state = state; - return this; - } - - public Builder detail(String detail){ - this.detail = detail; - return this; - } - - public AlarmLoggerInfo build(){ - return new AlarmLoggerInfo(alarm, state, detail); - } - - } -} |