summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-common/src')
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java6
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java15
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java16
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java84
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java12
5 files changed, 18 insertions, 115 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);
- }
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java
index bd3728c599..1be521952a 100644
--- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java
+++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java
@@ -26,10 +26,10 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.exceptions.*;
-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 java.io.IOException;
@@ -101,15 +101,13 @@ public class ApiExceptionTest {
@Test
- public void testValidateException() throws ApiException {
- AlarmLoggerInfo testLog = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
- Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_SDNC_ADAPTER)).build();
+ public void testValidateException() throws ApiException {
thrown.expect(ValidateException.class);
thrown.expectMessage("Test Message");
thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)));
- thrown.expect(hasProperty("alarmLoggerInfo", sameBeanAs(testLog)));
- ValidateException testException = new ValidateException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).messageID(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).alarmInfo(testLog).build();
+
+ ValidateException testException = new ValidateException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).messageID(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build();
throw testException;
}