From 644017cb3edd5b7a077a634ffd5daf2fee6bc088 Mon Sep 17 00:00:00 2001 From: az2497 Date: Thu, 10 Aug 2017 17:49:40 +0300 Subject: [SDC] OnBoard with enabled tests and features Change-Id: I4c1bbf6e1c854cf97a3561c736f83da44b58b7c0 Signed-off-by: az2497 [SDC] OnBoard with enabled tests and features. Change-Id: Icd52f039aee4dd393a1404d530bb9fdd0b20e604 Signed-off-by: az2497 --- .../sdcrests/errors/DefaultExceptionMapper.java | 25 ++++------------------ .../openecomp/sdcrests/mapping/MappingBase.java | 22 ++++++++++++++++++- .../wrappers/GenericCollectionWrapper.java | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index e8a6c7e7db..d399469745 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -54,9 +54,10 @@ import javax.ws.rs.ext.ExceptionMapper; public class DefaultExceptionMapper implements ExceptionMapper { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json"; - private static Map errorCodeToResponseStatus = JsonUtil - .json2Object(FileUtils.getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), - Map.class); + @SuppressWarnings("unchecked") + private static Map errorCodeToResponseStatus = + JsonUtil.json2Object(FileUtils + .getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class); private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override @@ -74,11 +75,6 @@ public class DefaultExceptionMapper implements ExceptionMapper { response = transform(exception); } - try { - writeStackTraceToFile(exception); - } catch (IOException ex) { - ex.printStackTrace(); - } List contentTypes = new ArrayList<>(); contentTypes.add(MediaType.APPLICATION_JSON); response.getMetadata().put("Content-Type", contentTypes); @@ -169,17 +165,4 @@ public class DefaultExceptionMapper implements ExceptionMapper { private Object toEntity(Response.Status status, ErrorCode code) { return new ErrorCodeAndMessage(status, code); } - - private void writeStackTraceToFile(Exception exception) throws IOException { - File file = new File("stack_trace.txt"); - if (!file.exists()) { - file.createNewFile(); - } - OutputStream outputStream = new FileOutputStream(file); - PrintWriter printWriter = new PrintWriter(file); - exception.printStackTrace(printWriter); - printWriter.close(); - outputStream.close(); - } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java index 6573485db7..91f2656f16 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java @@ -20,6 +20,15 @@ package org.openecomp.sdcrests.mapping; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; + /** * Base class for all mapping classes. Mapping classes will perform data mapping from source object * to target object Base class provides following
  1. provides life cycle of @@ -93,8 +102,19 @@ public abstract class MappingBase { try { object = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException exception) { + } catch (InstantiationException | IllegalAccessException exception ) { //TODO: what what? + MdcDataErrorMessage.createErrorMessageAndUpdateMdc( + LoggerConstants.TARGET_ENTITY, + LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), + exception.getMessage(), exception.getMessage()); + + throw new CoreException((new ErrorCode.ErrorCodeBuilder()) + .withMessage(exception.getMessage()) + .withId(exception.getMessage()) + .withCategory(ErrorCategory.APPLICATION).build()); + + } return object; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java index 22ce0a4e45..ea69249944 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java @@ -27,7 +27,7 @@ import java.util.List; public class GenericCollectionWrapper implements Serializable { private static final long serialVersionUID = 1L; - private List results; + private transient List results; private int listCount; public GenericCollectionWrapper() { -- cgit 1.2.3-korg