aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
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/src/main/java/org/openecomp/sdcrests/common/RestConstants.java18
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java18
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java16
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java48
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java34
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java40
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java38
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java55
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java9
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java121
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java90
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java31
12 files changed, 228 insertions, 290 deletions
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
index 230d1610eb..3f7dd523f9 100644
--- 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
@@ -13,20 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.common;
public class RestConstants {
- // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER
- public static final String USER_ID_HEADER_PARAM = "USER_ID";
- public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_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";
- private RestConstants() {
+ // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER
+ public static final String USER_ID_HEADER_PARAM = "USER_ID";
+ public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_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";
- }
+ private RestConstants() {
+ }
}
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
index cad5c69899..558d2e7c22 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.common.mapping;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -25,10 +24,11 @@ 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());
- }
+
+ @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
index 83c7b15980..78262b8c30 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.common.mapping;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -25,9 +24,10 @@ 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());
- }
+
+ @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
index 3615f89afc..f70d863653 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,37 +17,37 @@
* 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;
- }
+ private String id;
+ private String message;
+ private ErrorCategory category;
+
+ public String getId() {
+ return id;
+ }
- public void setId(String id) {
- this.id = id;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public void setMessage(String message) {
+ this.message = message;
+ }
- public ErrorCategory getCategory() {
- return category;
- }
+ public ErrorCategory getCategory() {
+ return category;
+ }
- public void setCategory(ErrorCategory category) {
- this.category = 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
index f63a9b0ced..9bac491ed1 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,28 +17,28 @@
* 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;
- }
+ private ErrorLevel level;
+ private String message;
+
+ public ErrorLevel getLevel() {
+ return level;
+ }
- public void setLevel(ErrorLevel level) {
- this.level = level;
- }
+ public void setLevel(ErrorLevel level) {
+ this.level = level;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String message) {
- this.message = 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
index 9fe70fc5e5..0546180575 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
@@ -13,23 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.errors;
+import com.fasterxml.jackson.databind.JsonMappingException;
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;
-
import org.apache.commons.collections4.CollectionUtils;
-import com.fasterxml.jackson.databind.JsonMappingException;
import org.hibernate.validator.internal.engine.path.PathImpl;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
@@ -47,9 +44,8 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json";
@SuppressWarnings("unchecked")
- private static final Map<String, String> ERROR_CODE_TO_RESPONSE_STATUS = FileUtils.readViaInputStream(
- ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
-
+ private static final Map<String, String> ERROR_CODE_TO_RESPONSE_STATUS = FileUtils
+ .readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExceptionMapper.class);
@Override
@@ -59,14 +55,11 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
response = transform(CoreException.class.cast(exception));
} else if (exception instanceof ConstraintViolationException) {
response = transform(ConstraintViolationException.class.cast(exception));
-
} else if (exception instanceof JsonMappingException) {
response = transform(JsonMappingException.class.cast(exception));
-
} else {
response = transform(exception);
}
-
List<Object> contentTypes = new ArrayList<>();
contentTypes.add(MediaType.APPLICATION_JSON);
response.getMetadata().put("Content-Type", contentTypes);
@@ -77,32 +70,23 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
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(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) {
- response = Response.status(Response.Status.NOT_FOUND).entity(toEntity(Response.Status.NOT_FOUND, code))
- .build();
+ response = Response.status(Response.Status.NOT_FOUND).entity(toEntity(Response.Status.NOT_FOUND, code)).build();
} else if (Response.Status.BAD_REQUEST.name().equals(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) {
- response =
- Response.status(Response.Status.BAD_REQUEST).entity(toEntity(Response.Status.BAD_REQUEST, code))
- .build();
+ 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();
+ 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();
+ 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 (CollectionUtils.isEmpty(constraintViolationSet)) {
message = validationException.getMessage();
@@ -111,28 +95,24 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
ConstraintViolation<?> constraintViolation = constraintViolationSet.iterator().next();
message = constraintViolation.getMessage();
fieldName = getFieldName(constraintViolation.getPropertyPath());
-
}
-
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();
+ .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();
+ .entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode)).build();
}
private Response transform(Exception exception) {
ErrorCode errorCode = new GeneralErrorBuilder().build();
LOGGER.error(errorCode.message(), exception);
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
- .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build();
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build();
}
private String getFieldName(Path propertyPath) {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java
index abf6024701..497d3cfeb7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java
@@ -13,16 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.errors;
import com.amdocs.zusammen.datatypes.response.Module;
-
import java.util.stream.Stream;
-
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
-
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ErrorCodeAndMessage;
import org.openecomp.sdc.common.errors.GeneralErrorBuilder;
@@ -32,19 +28,16 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeException> {
+
private static final String ZUSAMMEN_DB_PREFIX = Module.ZDB + "-";
static final String VLM_VSP_VERSION_ID_DOES_NOT_EXISTS =
- ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_NOT_EXIST;
+ ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_NOT_EXIST;
static final String VLM_VSP_ITEM_ID_DOES_NOT_EXISTS =
- ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_DOES_NOT_EXIST;
- static final String SUB_ENTITY_ID_DOES_NOT_EXISTS =
- ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ELEMENT_GET_INFO;
- static final String FAILED_TO_SYNC =
- ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_SYNC;
+ ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_DOES_NOT_EXIST;
+ static final String SUB_ENTITY_ID_DOES_NOT_EXISTS = ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ELEMENT_GET_INFO;
+ static final String FAILED_TO_SYNC = ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_SYNC;
static final String FAILED_TO_PUBLISH_OUT_OF_SYNC =
- ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode
- .ZU_ITEM_VERSION_PUBLISH_NOT_ALLOWED;
-
+ ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_PUBLISH_NOT_ALLOWED;
private static final Logger LOGGER = LoggerFactory.getLogger(ZusammenExceptionMapper.class);
@Override
@@ -53,29 +46,24 @@ public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeExcept
}
private Response transform(SdcRuntimeException exception) {
- if (Stream.of(VLM_VSP_ITEM_ID_DOES_NOT_EXISTS, VLM_VSP_VERSION_ID_DOES_NOT_EXISTS)
- .anyMatch(exception.getMessage()::contains)) {
+ if (Stream.of(VLM_VSP_ITEM_ID_DOES_NOT_EXISTS, VLM_VSP_VERSION_ID_DOES_NOT_EXISTS).anyMatch(exception.getMessage()::contains)) {
return generateSdcErrorResponse(Messages.ENTITY_NOT_FOUND, Response.Status.NOT_FOUND,
- new SdcRuntimeException(Messages.ENTITY_NOT_FOUND.getErrorMessage(), exception));
+ new SdcRuntimeException(Messages.ENTITY_NOT_FOUND.getErrorMessage(), exception));
} else if (exception.getMessage().contains(SUB_ENTITY_ID_DOES_NOT_EXISTS)) {
return generateSdcErrorResponse(Messages.SUB_ENTITY_NOT_FOUND, Response.Status.NOT_FOUND,
- new SdcRuntimeException(Messages.SUB_ENTITY_NOT_FOUND.getErrorMessage(), exception));
+ new SdcRuntimeException(Messages.SUB_ENTITY_NOT_FOUND.getErrorMessage(), exception));
} else if (exception.getMessage().contains(FAILED_TO_SYNC)) {
return generateSdcErrorResponse(Messages.FAILED_TO_SYNC, Response.Status.EXPECTATION_FAILED,
- new SdcRuntimeException(Messages.FAILED_TO_SYNC.getErrorMessage(), exception));
+ new SdcRuntimeException(Messages.FAILED_TO_SYNC.getErrorMessage(), exception));
} else if (exception.getMessage().contains(FAILED_TO_PUBLISH_OUT_OF_SYNC)) {
return generateSdcErrorResponse(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC, Response.Status.EXPECTATION_FAILED,
- new SdcRuntimeException(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC.getErrorMessage(), exception));
+ new SdcRuntimeException(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC.getErrorMessage(), exception));
}
-
return genericError(exception);
}
private Response generateSdcErrorResponse(Messages messages, Response.Status status, Exception exception) {
- ErrorCode errorCode = new ErrorCode.ErrorCodeBuilder()
- .withId(messages.name())
- .withMessage(exception.getMessage()).build();
-
+ ErrorCode errorCode = new ErrorCode.ErrorCodeBuilder().withId(messages.name()).withMessage(exception.getMessage()).build();
LOGGER.error(errorCode.message(), exception);
return Response.status(status).entity(new ErrorCodeAndMessage(status, errorCode)).build();
}
@@ -84,6 +72,6 @@ public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeExcept
ErrorCode errorCode = new GeneralErrorBuilder().build();
LOGGER.error(errorCode.message(), exception);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
- .entity(new ErrorCodeAndMessage(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build();
+ .entity(new ErrorCodeAndMessage(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java
index 2770d24959..3149d01b50 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,12 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.filters;
-import org.openecomp.sdc.common.session.SessionContextProvider;
-import org.openecomp.sdc.common.session.SessionContextProviderFactory;
-
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -31,37 +27,34 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
public abstract class SessionContextFilter implements Filter {
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- @Override
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
- FilterChain filterChain) throws IOException, ServletException {
- SessionContextProvider contextProvider =
- SessionContextProviderFactory.getInstance().createInterface();
-
- try {
- if (servletRequest instanceof HttpServletRequest) {
-
- contextProvider.create(getUser(servletRequest),getTenant(servletRequest));
- }
-
- filterChain.doFilter(servletRequest, servletResponse);
- } finally {
- contextProvider.close();
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
}
- }
- @Override
- public void destroy() {
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
+ SessionContextProvider contextProvider = SessionContextProviderFactory.getInstance().createInterface();
+ try {
+ if (servletRequest instanceof HttpServletRequest) {
+ contextProvider.create(getUser(servletRequest), getTenant(servletRequest));
+ }
+ filterChain.doFilter(servletRequest, servletResponse);
+ } finally {
+ contextProvider.close();
+ }
+ }
- }
+ @Override
+ public void destroy() {
+ }
- public abstract String getUser(ServletRequest servletRequest);
+ public abstract String getUser(ServletRequest servletRequest);
- public abstract String getTenant(ServletRequest servletRequest);
+ public abstract String getTenant(ServletRequest servletRequest);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java
index 0d394eb9aa..688b49c6e0 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.mapping;
import java.util.Map;
@@ -23,8 +22,8 @@ import java.util.Map;
*/
public class EchoMapMapping extends MappingBase<Map<String, String>, Map<String, String>> {
- @Override
- public void doMapping(Map<String, String> source, Map<String, String> target) {
- target.putAll(source);
- }
+ @Override
+ public void doMapping(Map<String, String> source, Map<String, String> target) {
+ target.putAll(source);
+ }
}
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 8b6fca5ae1..68a16e854c 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
@@ -13,86 +13,71 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.mapping;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
/**
- * 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>
- *
- *
+ * 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) {
- preMapping(source, target);
- doMapping(source, target);
- postMapping(source, target);
-
+ /**
+ * 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) {
+ preMapping(source, target);
+ doMapping(source, target);
+ postMapping(source, target);
+ }
+ return target;
}
- return target;
-
- }
- /**
- * This method is called before the <code>doMapping</code> method.
- */
- public void preMapping(final S source, T target) {
- // extension point
- }
-
- /**
- * 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) {
- // extension point
- }
-
- /**
- * Creates the instance of the input class.
- *
- * @return <code>Object</code>
- */
+ /**
+ * This method is called before the <code>doMapping</code> method.
+ */
+ public void preMapping(final S source, T target) {
+ // extension point
+ }
- private Object instantiateTarget(final Class<?> clazz) {
+ /**
+ * 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) {
+ // extension point
+ }
- try {
- return clazz.newInstance();
- } catch (InstantiationException | IllegalAccessException exception ) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(exception.getMessage()).build(), exception);
+ /**
+ * Creates the instance of the input class.
+ *
+ * @return <code>Object</code>
+ */
+ private Object instantiateTarget(final Class<?> clazz) {
+ try {
+ return clazz.newInstance();
+ } catch (InstantiationException | IllegalAccessException exception) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(exception.getMessage()).build(), exception);
+ }
}
- }
}
-
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 b73d2d93c5..7bff3d5b77 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.wrappers;
import java.io.Serializable;
@@ -25,57 +24,56 @@ import java.util.ArrayList;
import java.util.List;
public class GenericCollectionWrapper<T> implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private transient List<T> results;
- private int listCount;
- public GenericCollectionWrapper() {
- this.results = new ArrayList<>();
- }
+ private static final long serialVersionUID = 1L;
+ private transient List<T> results;
+ private int listCount;
- /**
- * Instantiates a new Generic collection wrapper.
- *
- * @param list the list
- */
- public GenericCollectionWrapper(List<T> list) {
- if (!list.isEmpty()) {
- this.results = list;
- this.listCount = list.size();
+ public GenericCollectionWrapper() {
+ this.results = new ArrayList<>();
}
- else {
- this.results = new ArrayList<>();
+
+ /**
+ * Instantiates a new Generic collection wrapper.
+ *
+ * @param list the list
+ */
+ public GenericCollectionWrapper(List<T> list) {
+ if (!list.isEmpty()) {
+ this.results = list;
+ this.listCount = list.size();
+ } else {
+ this.results = new ArrayList<>();
+ }
}
- }
- public List<T> getResults() {
- return results;
- }
+ public List<T> getResults() {
+ return results;
+ }
- public void setResults(List<T> results) {
- this.results = results;
- }
+ public void setResults(List<T> results) {
+ this.results = results;
+ }
- public int getListCount() {
- return listCount;
- }
+ public int getListCount() {
+ return listCount;
+ }
- public void setListCount(int listCount) {
- this.listCount = listCount;
- }
+ public void setListCount(int listCount) {
+ this.listCount = listCount;
+ }
- /**
- * Add boolean.
- *
- * @param item the list item
- * @return the boolean
- */
- public boolean add(T item) {
- if (this.getResults().add(item)) {
- this.setListCount(this.getResults().size());
- return true;
+ /**
+ * Add boolean.
+ *
+ * @param item the list item
+ * @return the boolean
+ */
+ public boolean add(T item) {
+ if (this.getResults().add(item)) {
+ this.setListCount(this.getResults().size());
+ return true;
+ }
+ return false;
}
- 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
index aad4e606de..0cfd5838f4 100644
--- 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
@@ -13,28 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdcrests.wrappers;
public class StringWrapperResponse {
- private String value;
- public StringWrapperResponse() {
- // defualt ctor is used by reflection, for instance JSON mapping
- super();
- }
+ private String value;
- public StringWrapperResponse(String value) {
- super();
- this.value = value;
- }
+ public StringWrapperResponse() {
+ // defualt ctor is used by reflection, for instance JSON mapping
+ super();
+ }
- public String getValue() {
- return value;
- }
+ public StringWrapperResponse(String value) {
+ super();
+ this.value = value;
+ }
- public void setValue(String value) {
- this.value = value;
- }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
}