aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml47
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java29
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java34
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java33
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java53
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java44
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java163
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java104
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java28
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java107
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java42
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json9
12 files changed, 693 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml
new file mode 100644
index 0000000000..764fb84db4
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-rest-webapp</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <name>openecomp-sdc-common-rest</name>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-common-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>${hibernate.validator.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>${ws.rs.version}</version>
+ </dependency>
+ <!-- Swagger -->
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-core</artifactId>
+ <version>${swagger.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java
new file mode 100644
index 0000000000..499bd6e785
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.common;
+
+public class RestConstants {
+ public static final String USER_HEADER_PARAM = "USER_ID";
+ public static final String USER_MISSING_ERROR_MSG =
+ "Field does not conform to predefined criteria : user : may not be null";
+ public static final String INVALID_JSON_ERROR_MESSAGE =
+ "Field does not conform to predefined criteria : body :must be in JSON format";
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java
new file mode 100644
index 0000000000..cad5c69899
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.common.mapping;
+
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdcrests.common.types.ErrorCodeDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapErrorCodeToDto extends MappingBase<ErrorCode, ErrorCodeDto> {
+ @Override
+ public void doMapping(ErrorCode source, ErrorCodeDto target) {
+ target.setId(source.id());
+ target.setCategory(source.category());
+ target.setMessage(source.message());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java
new file mode 100644
index 0000000000..83c7b15980
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.common.mapping;
+
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdcrests.common.types.ErrorMessageDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapErrorMessageToDto extends MappingBase<ErrorMessage, ErrorMessageDto> {
+ @Override
+ public void doMapping(ErrorMessage source, ErrorMessageDto target) {
+ target.setMessage(source.getMessage());
+ target.setLevel(source.getLevel());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java
new file mode 100644
index 0000000000..3615f89afc
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.common.types;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+
+public class ErrorCodeDto {
+ private String id;
+ private String message;
+ private ErrorCategory category;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public ErrorCategory getCategory() {
+ return category;
+ }
+
+ public void setCategory(ErrorCategory category) {
+ this.category = category;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java
new file mode 100644
index 0000000000..f63a9b0ced
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.common.types;
+
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+
+public class ErrorMessageDto {
+ private ErrorLevel level;
+ private String message;
+
+ public ErrorLevel getLevel() {
+ return level;
+ }
+
+ public void setLevel(ErrorLevel level) {
+ this.level = level;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
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
new file mode 100644
index 0000000000..67da814f48
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.errors;
+
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hibernate.validator.internal.engine.path.PathImpl;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+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.ErrorCodeAndMessage;
+import org.openecomp.sdc.common.errors.GeneralErrorBuilder;
+import org.openecomp.sdc.common.errors.JsonMappingErrorBuilder;
+import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Path;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
+ private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE =
+ "errorCodesToResponseStatusMapping.json";
+ private static Map<String, String> errorCodeToResponseStatus = JsonUtil
+ .json2Object(FileUtils.getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE),
+ Map.class);
+ private static org.slf4j.Logger logger = LoggerFactory.getLogger(DefaultExceptionMapper.class);
+
+ @Override
+ public Response toResponse(Exception e0) {
+ Response response;
+ if (e0 instanceof CoreException) {
+ response = transform(CoreException.class.cast(e0));
+ } else if (e0 instanceof ConstraintViolationException) {
+ response = transform(ConstraintViolationException.class.cast(e0));
+
+ } else if (e0 instanceof JsonMappingException) {
+ response = transform(JsonMappingException.class.cast(e0));
+
+ } else {
+ response = transform(e0);
+ }
+
+ List<Object> contentTypes = new ArrayList<>();
+ contentTypes.add(MediaType.APPLICATION_JSON);
+ response.getMetadata().put("Content-Type", contentTypes);
+ return response;
+ }
+
+ private Response transform(CoreException coreException) {
+ Response response;
+ ErrorCode code = coreException.code();
+ logger.error(code.message(), coreException);
+
+ if (coreException.code().category().equals(ErrorCategory.APPLICATION)) {
+ if (Response.Status.NOT_FOUND.name().equals(errorCodeToResponseStatus.get(code.id()))) {
+ response = Response
+ .status(Response.Status.NOT_FOUND)
+ .entity(toEntity(Response.Status.NOT_FOUND, code))
+ .build();
+ } else if (Response.Status.BAD_REQUEST.name()
+ .equals(errorCodeToResponseStatus.get(code.id()))) {
+ response = Response
+ .status(Response.Status.BAD_REQUEST)
+ .entity(toEntity(Response.Status.BAD_REQUEST, code))
+ .build();
+ } else {
+ response = Response
+ .status(Response.Status.EXPECTATION_FAILED)
+ .entity(toEntity(Response.Status.EXPECTATION_FAILED, code))
+ .build();
+ }
+ } else {
+ response = Response
+ .status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, code))
+ .build();
+ }
+
+
+ return response;
+ }
+
+ private Response transform(ConstraintViolationException validationException) {
+ Set<ConstraintViolation<?>> constraintViolationSet =
+ validationException.getConstraintViolations();
+ String message;
+
+ String fieldName = null;
+ if (!CommonMethods.isEmpty(constraintViolationSet)) {
+ // getting the first violation message for the output response.
+ ConstraintViolation<?> constraintViolation = constraintViolationSet.iterator().next();
+ message = constraintViolation.getMessage();
+ fieldName = getFieldName(constraintViolation.getPropertyPath());
+
+ } else {
+ message = validationException.getMessage();
+ }
+
+ ErrorCode validationErrorCode = new ValidationErrorBuilder(message, fieldName).build();
+
+ logger.error(validationErrorCode.message(), validationException);
+ return Response
+ .status(Response.Status.EXPECTATION_FAILED) //error 417
+ .entity(toEntity(Response.Status.EXPECTATION_FAILED, validationErrorCode))
+ .build();
+ }
+
+
+ private Response transform(JsonMappingException jsonMappingException) {
+ ErrorCode jsonMappingErrorCode = new JsonMappingErrorBuilder().build();
+ logger.error(jsonMappingErrorCode.message(), jsonMappingException);
+ return Response
+ .status(Response.Status.EXPECTATION_FAILED) //error 417
+ .entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode))
+ .build();
+ }
+
+ private Response transform(Exception e0) {
+ ErrorCode generalErrorCode = new GeneralErrorBuilder(e0.getMessage()).build();
+ logger.error(generalErrorCode.message(), e0);
+ return Response
+ .status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, generalErrorCode))
+ .build();
+ }
+
+ private String getFieldName(Path propertyPath) {
+ return ((PathImpl) propertyPath).getLeafNode().toString();
+ }
+
+ private Object toEntity(Response.Status status, ErrorCode code) {
+ return new ErrorCodeAndMessage(status, code);
+ }
+
+}
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
new file mode 100644
index 0000000000..7382ef72eb
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.mapping;
+
+/**
+ * Base class for all mapping classes. Mapping classes will perform data mapping from source object
+ * to target object Base class provides following<br>
+ * <ol>
+ * <li>provides life cycle of mapping class , first mapSimpleProperties is called and then
+ * mapComplexProperties is called.</li>
+ * <li>methods mapSimpleProperties and mapComplexProperties with default implementation,
+ * these should be overridden by concrete mapping classes for writing mapping logic.</li>
+ * </ol>
+ */
+
+public abstract class MappingBase<S, T> {
+
+ /**
+ * Method is called for starting mapping from source object to target object method sets context
+ * in the thread locale and than calls mapSimpleProperties and mapComplexProperties respectively.
+ *
+ * @param source : source object for mapping
+ * @param clazz : target <code>Class</code> for mapping
+ * @return <code>T</code> - instance of type <code>T</code>
+ */
+
+ public final T applyMapping(final S source, Class<T> clazz) {
+ T target = (T) instantiateTarget(clazz);
+ if (source == null || target == null) {
+ //TODO: what what?
+ } else {
+ preMapping(source, target);
+ doMapping(source, target);
+ postMapping(source, target);
+
+ }
+ return target;
+
+ }
+
+ /**
+ * This method is called before the <code>doMapping</code> method.
+ */
+
+ public void preMapping(final S source, T target) {
+ }
+
+ /**
+ * The actual method that does the mapping between the <code>source</code>
+ * to <code>target</code> objects.
+ * This method is being called automatically as part of the mapper class.
+ * This method must be override (it is abstract) by the mapper class.
+ *
+ * @param source - the source object.
+ * @param target - the target object.
+ */
+
+ public abstract void doMapping(final S source, T target);
+
+ /**
+ * This method is called after the <code>doMapping</code> method.
+ */
+
+ public void postMapping(final S source, T target) {
+ }
+
+ /**
+ * Creates the instance of the input class.
+ *
+ * @return <code>Object</code>
+ */
+
+ private Object instantiateTarget(final Class<?> clazz) {
+ Object object = null;
+ try {
+ object = clazz.newInstance();
+
+ } catch (InstantiationException | IllegalAccessException e0) {
+ //Do nothing
+ }
+ return object;
+
+ }
+
+}
+
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java
new file mode 100644
index 0000000000..8cb5a061b9
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.versioning.types;
+
+public enum VersioningAction {
+ Checkout,
+ Undo_Checkout,
+ Checkin,
+ Submit;
+}
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
new file mode 100644
index 0000000000..b8d47e4ef3
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.wrappers;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class represents a generic collection wrapper to be used by paginated results.
+ *
+ * @param <T> the type parameter
+ */
+public class GenericCollectionWrapper<T> implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private List<T> results;
+ private int listCount;
+
+ /**
+ * Instantiates a new Generic collection wrapper.
+ */
+ public GenericCollectionWrapper() {
+ this.results = new ArrayList<>();
+ }
+
+ /**
+ * Instantiates a new Generic collection wrapper.
+ *
+ * @param list the list
+ * @param listCount the list count
+ */
+ public GenericCollectionWrapper(List<T> list, int listCount) {
+ if (!list.isEmpty()) {
+ this.results = list;
+ this.listCount = listCount;
+ }
+ }
+
+ /**
+ * Gets results.
+ *
+ * @return the results
+ */
+ public List<T> getResults() {
+ return results;
+ }
+
+ /**
+ * Sets results.
+ *
+ * @param results the results
+ */
+ public void setResults(List<T> results) {
+ this.results = results;
+ }
+
+ /**
+ * Gets list count.
+ *
+ * @return the list count
+ */
+ public int getListCount() {
+ return listCount;
+ }
+
+ /**
+ * Sets list count.
+ *
+ * @param listCount the list count
+ */
+ public void setListCount(int listCount) {
+ this.listCount = listCount;
+ }
+
+ /**
+ * Add boolean.
+ *
+ * @param e0 the e 0
+ * @return the boolean
+ */
+ public boolean add(T e0) {
+ if (this.getResults().add(e0)) {
+ this.setListCount(this.getResults().size());
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java
new file mode 100644
index 0000000000..d472eb9d14
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdcrests.wrappers;
+
+public class StringWrapperResponse {
+ private String value;
+
+ public StringWrapperResponse() {
+ }
+
+ public StringWrapperResponse(String value) {
+ super();
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json
new file mode 100644
index 0000000000..e4c6962847
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json
@@ -0,0 +1,9 @@
+{
+ "VSP_NOT_FOUND": "NOT_FOUND",
+ "VSP_INVALID": "BAD_REQUEST",
+ "UPLOAD_INVALID" : "PRECONDITION_FAILED",
+ "PACKAGE_NOT_FOUND": "NOT_FOUND",
+ "PACKAGE_INVALID": "BAD_REQUEST",
+ "VENDOR_LICENSE_MODEL_NOT_FOUND": "NOT_FOUND",
+ "VENDOR_LICENSE_ENTITY_NOT_FOUND": "NOT_FOUND"
+} \ No newline at end of file